Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 159c046

Browse files
committed
Improved tests to avoid randomly failed tests on Travis and AppVeyor
1 parent 7f3926f commit 159c046

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

Tests/Controller/DisabledActionsTest.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace JavierEguiluz\Bundle\EasyAdminBundle\Tests\Controller;
1313

1414
use JavierEguiluz\Bundle\EasyAdminBundle\Tests\Fixtures\AbstractTestCase;
15+
use Symfony\Component\HttpKernel\Kernel;
1516

1617
class DisabledActionsTest extends AbstractTestCase
1718
{
@@ -24,17 +25,25 @@ public function setUp()
2425

2526
public function testAssociationLinksInListView()
2627
{
28+
if (2 === Kernel::MAJOR_VERSION && 3 === Kernel::MINOR_VERSION) {
29+
$this->markTestSkipped('This test is not compatible with Symfony 2.3.');
30+
}
31+
2732
$crawler = $this->requestListView('Purchase');
2833

2934
$this->assertSame(
30-
'user11',
35+
'user1',
3136
trim($crawler->filter('td[data-label="Buyer"]')->first()->html()),
3237
'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.'
3338
);
3439
}
3540

3641
public function testAssociationLinksInShowView()
3742
{
43+
if (2 === Kernel::MAJOR_VERSION && 3 === Kernel::MINOR_VERSION) {
44+
$this->markTestSkipped('This test is not compatible with Symfony 2.3.');
45+
}
46+
3847
// 'Purchase' entity 'id' is generated randomly. In order to browse the
3948
// 'show' view of the first 'Purchase' entity, browse the 'list' view
4049
// and get the 'id' from the first row of the listing
@@ -43,8 +52,8 @@ public function testAssociationLinksInShowView()
4352
$crawler = $this->requestShowView('Purchase', $firstPurchaseId);
4453

4554
$this->assertSame(
46-
'user11',
47-
trim($crawler->filter('.field-association:contains("Buyer") .form-control')->html()),
55+
'user1',
56+
trim($crawler->filter('.field-association:contains("Buyer") .form-control')->first()->html()),
4857
'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.'
4958
);
5059
}

Tests/Fixtures/App/config/config_disabled_actions.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ easy_admin:
77
class: AppTestBundle\Entity\FunctionalTests\Purchase
88
list:
99
fields: ['id', 'buyer']
10+
sort: ['buyer', 'ASC']
1011
User:
1112
class: AppTestBundle\Entity\FunctionalTests\User
1213
# the 'show' action is disabled so the 'buyer' field is not linked

0 commit comments

Comments
 (0)