Skip to content

Commit

Permalink
set up test environment
Browse files Browse the repository at this point in the history
  • Loading branch information
stfalcon committed Dec 2, 2010
1 parent 28dfc0b commit fc2ad50
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/application/ControllerTestCase.php
@@ -0,0 +1,19 @@
<?php

/**
* @see Zend_Test_PHPUnit_ControllerTestCase
*/
require_once 'Zend/Test/PHPUnit/ControllerTestCase.php';

abstract class ControllerTestCase extends Zend_Test_PHPUnit_ControllerTestCase
{
public function setUp()
{
$this->bootstrap = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);

parent::setUp();
}
}
26 changes: 26 additions & 0 deletions tests/application/bootstrap.php
@@ -0,0 +1,26 @@
<?php
error_reporting(E_ALL | E_STRICT);

// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));

// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', 'testing');

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));

//require_once 'Zend/Loader.php';
//Zend_Loader::registerAutoload();

/**
* @see Zend_Application
*/
require_once 'Zend/Application.php';

require_once 'ControllerTestCase.php';
15 changes: 15 additions & 0 deletions tests/application/controllers/ErrorControllerTest.php
@@ -0,0 +1,15 @@
<?php

require_once realpath(dirname(__FILE__) . '/../bootstrap.php');

class ErrorControllerTest extends ControllerTestCase
{
public function testErrorUrl()
{
$this->dispatch('foo');
$this->assertModule('default');
$this->assertController('error');
$this->assertAction('error');
$this->assertResponseCode(404);
}
}
14 changes: 14 additions & 0 deletions tests/application/controllers/IndexControllerTest.php
@@ -0,0 +1,14 @@
<?php

require_once realpath(dirname(__FILE__) . '/../bootstrap.php');

class IndexControllerTest extends ControllerTestCase
{
public function testIndexAction()
{
$this->dispatch('/');
$this->assertModule('default');
$this->assertController('index');
$this->assertAction('index');
}
}
30 changes: 30 additions & 0 deletions tests/phpunit.xml
@@ -0,0 +1,30 @@
<phpunit bootstrap="./application/bootstrap.php"
colors="true"
stopOnFailure="true">

<testsuite name="Main Test Suite">
<directory>./</directory>
</testsuite>

<filter>
<blacklist>
<directory suffix=".php">/usr/share/php</directory>
<directory suffix=".php">../tests</directory>
</blacklist>
<whitelist>
<directory suffix=".php">../library/</directory>
<directory suffix=".php">../application/</directory>
<exclude>
<directory suffix=".phtml">../application/</directory>
</exclude>
</whitelist>
</filter>

<!-- <logging>
<log type="coverage-html" target="./log/report" charset="UTF-8"
yui="true" highlight="true"
lowUpperBound="50" highLowerBound="80"/>
<log type="testdox-html" target="./log/testdox.html" />
</logging> -->

</phpunit>

0 comments on commit fc2ad50

Please sign in to comment.