From 159c046a4b564fabac691bff185059c21b06edc4 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 26 Nov 2016 10:15:56 +0100 Subject: [PATCH] Improved tests to avoid randomly failed tests on Travis and AppVeyor --- Tests/Controller/DisabledActionsTest.php | 15 ++++++++++++--- .../App/config/config_disabled_actions.yml | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Tests/Controller/DisabledActionsTest.php b/Tests/Controller/DisabledActionsTest.php index 023d525eb7..a9506551d5 100644 --- a/Tests/Controller/DisabledActionsTest.php +++ b/Tests/Controller/DisabledActionsTest.php @@ -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 { @@ -24,10 +25,14 @@ 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.' ); @@ -35,6 +40,10 @@ public function testAssociationLinksInListView() 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 @@ -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.' ); } diff --git a/Tests/Fixtures/App/config/config_disabled_actions.yml b/Tests/Fixtures/App/config/config_disabled_actions.yml index d69cd65e86..e8af5d8c1b 100644 --- a/Tests/Fixtures/App/config/config_disabled_actions.yml +++ b/Tests/Fixtures/App/config/config_disabled_actions.yml @@ -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