В простом и слегка модифицированном функциональном тесте, сгенерированном генератором CRUD, тест сканера завершается некорректно. Это определяется путем проверки содержимого внешнего файла, созданного перед утверждением. И путем проверки элементов страницы. И при ручном запуске кода jquery $("td:contains('Test')").length;
Итак, почему тест не проходит?
Тестовый класс:
class ApplianceControllerTest extends WebTestCase {
private $client;
public function __construct() {
$this->client = static::createClient(array(), array(
...
));
$this->client->followRedirects();
}
public function testCompleteScenario() {
// Create a new entry in the database
$crawler = $this->client->request('GET', '/appliance/');
$crawler = $this->client->click($crawler->selectLink('Create a new entry')->link());
// Fill in the form and submit it
$form = $crawler->selectButton('Create')->form(array(
'appliance[appliance]' => 'Test',
// ... other fields to fill
));
$this->client->submit($form);
// $crawler = $this->client->followRedirect();
$content = $this->client->getResponse()->getContent();
file_put_contents('somefile', $content);
// Check data in the show view
$this->assertGreaterThan(0, $crawler->filter('td:contains("Test")')->count(), 'Missing element td:contains("Test")');
}
Выход:
Отсутствует элемент td:contains("Test") Не удалось подтвердить, что 0 больше 0.
Выдержка из захваченного контента:
<div class="title">Appliance</div>
<div class="width40">
<table class="record_properties">
<tbody>
<tr>
<th>Id</th>
<td>14</td>
</tr>
<tr>
<th>Appliance</th>
<td>Test</td>
</tr>
<tr>
<th>Enabled</th>
<td>Yes</td>
</tr>
</tbody>
</table>
$crawler = $this->client->followRedirect();
? - person mattexx   schedule 25.10.2013$this->client->followRedirects();
из __construct() и восстановить строку$crawler = $this->client->followRedirect();
!! Любопытно, что в версии 2.1 мне все это уже сошло с рук. Вы можете опубликовать это как ответ, и я приму его. Ваш комментарий заставил меня протестировать мод. - person geoB   schedule 25.10.2013