Testing - marella/phd GitHub Wiki
# cd to project's root directory
chmod +x phpunit.sh
./phpunit.sh
Real Database Testing
Some of the tests run on a real database. To enable them, copy config.example.php
to config.php
in tests
directory, fill in the database details and run phpunit
again.
Testing With DB Facade
DB
class is a static proxy to a DatabaseManager
instance. Use the DB::setFacadeRoot()
method to pass a mock object. It accepts only a DatabaseManager
instance so a stub has to be created.
class DatabaseManagerStub extends DatabaseManager
{
public function __construct()
{
}
}
...
// inside test method
$mock = $this->getMock('DatabaseManagerStub');
DB::setFacadeRoot($mock);
See the tests directory for more examples.