SRIT
21.07.2009, 13:56
Hallo,
hat schon mal jemand rausgefunden, wie man mit Zend_Test_PHPUnit_ControllerTestCase POST Requests testen kann?
class ClientsLogControllerTest extends ControllerTestCase {
public function testShowLoginForm() {
$this->dispatch ( '/clients/log/login' );
$this->assertAction ( 'login' );
$this->assertController ( 'log' );
$this->assertModule ( 'clients' );
}
public function testLogin() {
$this->getRequest ()->setMethod ( 'POST' );
$_POST ['username'] = 'riedel';
$_POST ['password'] = 'xxx';
$this->dispatch ( '/clients/log/login' );
}
}
Der erste Test läuft ohne Probleme, nur der zweite Test verhällt sich wie der erste (GET). Bevor gefragt wird hier noch meine ControllerTestCase:
<?php
require_once 'Zend/Application.php';
require_once 'Zend/Test/PHPUnit/ControllerTestCase.php';
abstract class ControllerTestCase extends Zend_Test_PHPUnit_ControllerTestCase
{
public $application;
public function setUp()
{
$this->application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$this->bootstrap = array($this, 'appBootstrap');
parent::setUp();
}
public function appBootstrap()
{
$this->application->bootstrap();
}
}
Jemand ne Ahnung, was ich falsch mache?
hat schon mal jemand rausgefunden, wie man mit Zend_Test_PHPUnit_ControllerTestCase POST Requests testen kann?
class ClientsLogControllerTest extends ControllerTestCase {
public function testShowLoginForm() {
$this->dispatch ( '/clients/log/login' );
$this->assertAction ( 'login' );
$this->assertController ( 'log' );
$this->assertModule ( 'clients' );
}
public function testLogin() {
$this->getRequest ()->setMethod ( 'POST' );
$_POST ['username'] = 'riedel';
$_POST ['password'] = 'xxx';
$this->dispatch ( '/clients/log/login' );
}
}
Der erste Test läuft ohne Probleme, nur der zweite Test verhällt sich wie der erste (GET). Bevor gefragt wird hier noch meine ControllerTestCase:
<?php
require_once 'Zend/Application.php';
require_once 'Zend/Test/PHPUnit/ControllerTestCase.php';
abstract class ControllerTestCase extends Zend_Test_PHPUnit_ControllerTestCase
{
public $application;
public function setUp()
{
$this->application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$this->bootstrap = array($this, 'appBootstrap');
parent::setUp();
}
public function appBootstrap()
{
$this->application->bootstrap();
}
}
Jemand ne Ahnung, was ich falsch mache?