Eclipse 외부 도구를 통해 빌드 할 때 테스트를 실행하기 위해 Phing을 사용하여 Zend Framework 프로젝트에서 PHPUnit 설정을 얻을 수있었습니다. 내 테스트는 빌드시에 발견되어 실행되지만, 어떤 이유로 PHP 페이지가 해석되지 않습니다.PHPUnit 테스트 응답의 원시 PHP
내 주장이 실패하는 이유를 알아 내려고 노력한 결과, echo $this->response->outputBody();
이 내 테스트에 추가되어 원시 PHP가 울리고 있음을 깨달았습니다. echo get_class($this->response);
을 추가하면 클래스 이름으로 Zend_Controller_Response_HttpTestCase를 얻습니다.이 클래스 이름은 올바른 것으로 수집됩니다.
파일 핸들러가 PHP 실행 파일을 통해 PHP 코드를 전송하도록 설정되지 않은 Apache에서이 문제가 발생했지만, 알고있는 한 Phing/PHPUnit은 실행을 처리해야하므로 문제가되지 않습니다. 실행 파일을 통해 모든 것을 직접 수행 할 수 있습니다. 필자는 PHPUnit이나 Phing이 내가 무엇을 잘못하고 있는지 알 수있는 방법에 대해 아직 충분히 알지 못합니다. 어떤 제안? 제가 테스트 중 하나를 실행할 때
<?php
class SearchControllerTest extends ControllerTestCase
{
public function setUp()
{
parent::setUp();
}
public function testSearchPizzaChicago()
{
$this->_search('restaurants', 'chicago, il');
}
private function _search($what, $where)
{
$this->request->setMethod('POST');
$this->request->setPost(
array(
'search_what' => $what,
'search_where' => $where,
)
);
$this->dispatch(Zend_Registry::get('base_url') . '/search/results');
echo $this->response->outputBody();
//echo get_class($this->response);
$this->assertQuery('#results');
}
public function tearDown()
{
/* Tear Down Routine */
}
}
가 여기 내 콘솔 출력입니다 :
여기 내 테스트 클래스의
Buildfile: C:\workspace\myproject\build.xml
myproject > test:
... raw PHP code here ...
[phpunit] Testsuite: SearchControllerTest
[phpunit] Tests run: 1, Failures: 1, Errors: 0, Incomplete: 0, Skipped: 0, Time elapsed: 0.25874 s
[phpunit] testSearchPizzaChicago FAILED
[phpunit] Failed asserting node DENOTED BY #results EXISTS
[phpunit] C:\workspace\frameworks\ZendFramework-1.11\library\Zend\Test\PHPUnit\Constraint\DomQuery.php:263
[phpunit] C:\workspace\frameworks\ZendFramework-1.11\library\Zend\Test\PHPUnit\ControllerTestCase.php:300
[phpunit] C:\workspace\myproject\tests\application\controllers\SearchControllerTest.php:34
[phpunit] C:\workspace\myproject\tests\application\controllers\SearchControllerTest.php:13
[phpunit] C:\wamp\bin\php\php5.3.5\PEAR\phing.php:37
BUILD FINISHED
Total time: 2.0895 seconds
출력되는 원시 코드에 짧은 태그 ( ?> 또는 = ?>)를 사용하고 있습니까? 서버가 PHP 단축 태그로 설정되지 않은 경우 PHP로 처리하지 않으므로 –