Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit c4b2d86

Browse files
committed
fix test for symfony 2.2
1 parent 68ceea0 commit c4b2d86

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Tests/WebTest/Voter/BaseTestCase.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Symfony\Cmf\Bundle\MenuBundle\Tests\WebTest\Voter;
44

5+
use Symfony\Component\DomCrawler\Crawler;
56
use Symfony\Cmf\Component\Testing\Functional\BaseTestCase as BaseBaseTestCase;
67

78
abstract class BaseTestCase extends BaseBaseTestCase
@@ -14,9 +15,20 @@ public function setUp()
1415
$this->client = $this->createClient();
1516
}
1617

17-
protected function assertCurrentItem($crawler, $title)
18+
protected function assertCurrentItem(Crawler $crawler, $title)
1819
{
1920
$res = $crawler->filter('li.current:contains("'.$title.'")')->count();
20-
$this->assertEquals(1, $res, 'Failed matching current menu item "'.$title.'", got '.$crawler->html());
21+
if (method_exists($crawler, 'html')) {
22+
// since symfony 2.3
23+
$html = $crawler->html();
24+
} else {
25+
// symfony 2.2
26+
$html = '';
27+
foreach ($crawler as $domElement) {
28+
$html .= $domElement->ownerDocument->saveHTML($domElement);
29+
}
30+
31+
}
32+
$this->assertEquals(1, $res, 'Failed matching current menu item "'.$title.'", got '.$html);
2133
}
2234
}

0 commit comments

Comments
 (0)