Skip to content

Commit

Permalink
bug #1410 Improved tests to avoid randomly failed tests on Travis and…
Browse files Browse the repository at this point in the history
… AppVeyor (javiereguiluz)

This PR was squashed before being merged into the master branch (closes #1410).

Discussion
----------

Improved tests to avoid randomly failed tests on Travis and AppVeyor

Commits
-------

159c046 Improved tests to avoid randomly failed tests on Travis and AppVeyor
  • Loading branch information
javiereguiluz committed Nov 26, 2016
2 parents 7f3926f + 159c046 commit 1f43c96
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
15 changes: 12 additions & 3 deletions Tests/Controller/DisabledActionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace JavierEguiluz\Bundle\EasyAdminBundle\Tests\Controller;

use JavierEguiluz\Bundle\EasyAdminBundle\Tests\Fixtures\AbstractTestCase;
use Symfony\Component\HttpKernel\Kernel;

class DisabledActionsTest extends AbstractTestCase
{
Expand All @@ -24,17 +25,25 @@ public function setUp()

public function testAssociationLinksInListView()
{
if (2 === Kernel::MAJOR_VERSION && 3 === Kernel::MINOR_VERSION) {
$this->markTestSkipped('This test is not compatible with Symfony 2.3.');
}

$crawler = $this->requestListView('Purchase');

$this->assertSame(
'user11',
'user1',
trim($crawler->filter('td[data-label="Buyer"]')->first()->html()),
'The "buyer" field in the "list" view of the "Purchase" item does not contain a link because the "show" action is disabled for the "User" entity.'
);
}

public function testAssociationLinksInShowView()
{
if (2 === Kernel::MAJOR_VERSION && 3 === Kernel::MINOR_VERSION) {
$this->markTestSkipped('This test is not compatible with Symfony 2.3.');
}

// 'Purchase' entity 'id' is generated randomly. In order to browse the
// 'show' view of the first 'Purchase' entity, browse the 'list' view
// and get the 'id' from the first row of the listing
Expand All @@ -43,8 +52,8 @@ public function testAssociationLinksInShowView()
$crawler = $this->requestShowView('Purchase', $firstPurchaseId);

$this->assertSame(
'user11',
trim($crawler->filter('.field-association:contains("Buyer") .form-control')->html()),
'user1',
trim($crawler->filter('.field-association:contains("Buyer") .form-control')->first()->html()),
'The "buyer" field in the "show" view of the "Purchase" item does not contain a link because the "show" action is disabled for the "User" entity.'
);
}
Expand Down
1 change: 1 addition & 0 deletions Tests/Fixtures/App/config/config_disabled_actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ easy_admin:
class: AppTestBundle\Entity\FunctionalTests\Purchase
list:
fields: ['id', 'buyer']
sort: ['buyer', 'ASC']
User:
class: AppTestBundle\Entity\FunctionalTests\User
# the 'show' action is disabled so the 'buyer' field is not linked
Expand Down

0 comments on commit 1f43c96

Please sign in to comment.