Zum Testen wurde PHPUnit verwendet als Standard-Testing-Tool für PHP und in Netbeans intergriert.
Dazu wurde eine Bootstrap Datei angelegt, in der die Applikationsvariablen geladen werden (IndexControllerTest.php):
class IndexControllerTest extends Zend_Test_PHPUnit_ControllerTestCase
{
public function setUp()
{
$this->bootstrap = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
parent::setUp();
}
}
Ein Test kann dan so aussehen (Test Files/application/controllers/IndexControllerTest.php):
require_once '/../../TestConfiguration.php';
require_once '/../../../application/models/Players.php';
class PlayersTest extends PhpUnit_Framework_TestCase{
public function setUp()
{
TestConfiguration::setupDatabase();
}
public function testFetchAll(){
$TippspielObjekt = new Players();
$TippspielAnzahl = $TippspielObjekt->fetchAll();
$this->assertGreaterThan(10, $TippspielAnzahl->count());
}
public function testLatest(){
$TippspielObjekt = new Players();
$TippspielAnzahl = $TippspielObjekt->fetchLatest(1);
$this->assertSame(1,$TippspielAnzahl->count());
}
}
