Automated tests are great. Learn more about them on symfony tests documentation.
You can write your own functional tests the same way you do with symfony.
IMPORTANT
When writing functional tests for Diem, you must replace the sfBrowser object with a dmSfBrowser one.
Instead of$browser = new sfTestFunctional(new sfBrowser());
You must write
$browser = new sfTestFunctional(new dmSfBrowser());
This is because in sfBrowser, the sfContext class is hardcoded. But Diem has to override it with dmContext to include the service container.
You can test all your front and admin pages without writing a line of code.
$ php symfony test:functional admin dm
The test configuration file can be found in test/functional/admin/dmTest.php
$ php symfony test:functional front dm
The test configuration file can be found in test/functional/front/dmTest.php
In the configuration file, we can see
require_once realpath(dirname(__FILE__).'/../../../config/ProjectConfiguration.class.php'); require_once dm::getDir().'/dmCorePlugin/lib/test/dmAdminFunctionalCoverageTest.php'; $config = array( 'login' => true, // whether to log a user or not at the beginning of the tests 'username' => 'admin', // username to log in 'validate' => false, // perform html validation on each page, based on its doctype 'debug' => true, // use debug mode ( slower, use more memory ) 'env' => 'test', // sf_environment when running tests ); $test = new dmAdminFunctionalCoverageTest($config); $test->run();
Feel free to customize the test configuration for your needs.
Learn more about symfony unit and functional testing.
They just work like in symfony.
The test will use an SQLite database and will never alter your project.
Just replace /diem/path with the path to Diem and run:
php /diem/path/prove
A getBrowser() method has been added to the user object. It returns an instance of the browser service, that describes the current user browser:
$browser = $this->getUser()->getBrowser(); echo $browser->getName(); // Firefox echo $browser->getVersion(); // 3.6 echo $browser->isUnknown(); // false
The browser detection uses a very light and fast algorithm. It is not as efficient as heavy solutions like browscap. It will only detect browsers, and not bots.
If you want to change the way the broser is detected, you can replace the browser service by your own.
Use of APC is strongly recommended on both development and production servers. Diem will use it to store database and template cache.
A secured APC monitor is available in admin application. On the upper tool bar is a tiny bar indicating the APC load. By clicking on it you access to a complete APC monitor. From this monitor you are given informations about cache status, you can see opcode cache and user cache, and clear them globally or selectively.
Note : when refreshing the project, the whole APC cache is cleared.
Questions and Feedback
If you need support or have a technical question, you can
The documentation is hosted on GitHub. Feel free to submit issues and patches!