Sadece kayıt için, ben bu bahsettiğiniz kod beton parçası olduğunu tahmin:
class ControllerTestCase extends Zend_Test_PHPUnit_ControllerTestCase
{
public $application;
public function setUp()
{
$this->application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/config/settings.ini'
);
$this->bootstrap = array($this, 'bootstrap');
parent::setUp();
}
public function tearDown()
{
Zend_Controller_Front::getInstance()->resetInstance();
$this->resetRequest();
$this->resetResponse();
$this->request->setPost(array());
$this->request->setQuery(array());
}
public function bootstrap()
{
$this->application->bootstrap();
}
}
Birim test olarak, setUp
ve tearDown
yöntemleri için kullanılır
set the world up in a known state and
then return it to its original state
when the test is complete. This known state is called the fixture of the test.
Demirbaşlar işlenir yolu xUnit kütüphaneleri arasında farklılık olabilir, henüz kavram aynı kalır. PHPUnit kılavuzunda da fixtures chapter Bkz:
PHPUnit supports sharing the setup
code. Before a test method is run, a
template method called setUp() is
invoked. setUp() is where you create
the objects against which you will
test. Once the test method has
finished running, whether it succeeded
or failed, another template method
called tearDown() is invoked.
tearDown() is where you clean up the
objects against which you tested.
tearDown
Her yürütme sonrasında işlenirken Dolayısıyla, PHPUnit, every single test yöntemi, test durumda sınıfına dahil önce setUp
yöntemi yürütme ilgilenir.
Bunu söyledikten sonra, Zend Framework bu, functional tests çalışan için PHPUnit üstüne ekstra bir tabaka ile sağlar, özellikleri yerine kaynak kodunu tek tek birimler siyah-kutulu testleri. Bu uygulama kaynaklara erişim sağlanır ve böylece Zend_Test_PHPUnit_ControllerTestCase uzatılarak elde edilir.
Test halinde her bir test idam edilmeden önce bu özel örnekte, uygulama önyükleyicisini edilir. Biz çiğ birim testleri (diğer test olguların parçası) örneğin her yerde, gibi uygulama kaynaklarını gerekmez dikkate alırsak, bu mantıklı.