<?php
namespace gnomephp\testsuite;
/**
* This test controller tests if the application is a valid application.
* It tests for directory structure and required files.
*
* You can extend this class and create a setup method and set $this->appPath to another application if you want to test another application
* then the one you are in.
*
* Application Tests should override this TestController instead of "TestController" because this provides good testing for the application by base.
*
*/
class TestApplication extends TestController{
/**
* The application path of the app to test.
* @var string
*/
protected $appPath = GNOME_APP_PATH;
public function getAppPath(){
return $this->appPath;
}
protected function testRequiredConfigFiles(){
$this->test(file_exists($this->getAppPath() . DIRECTORY_SEPARATOR .
'config' . DIRECTORY_SEPARATOR . 'routes.conf'),'routes.conf file existance')
->assertTrue();
$this->test(file_exists($this->getAppPath() . DIRECTORY_SEPARATOR .
'config' . DIRECTORY_SEPARATOR . 'application.yml'),'application.yml file existance')
->assertTrue();
$this->test(file_exists($this->getAppPath() . DIRECTORY_SEPARATOR .
'config' . DIRECTORY_SEPARATOR . 'database.yml'),'database.yml file existance')
->assertTrue();
}
protected function testAdditionalFiles(){
$this->test(file_exists($this->getAppPath() . DIRECTORY_SEPARATOR . 'app-data.php'),'app-data.php file existance')
->assertTrue();
}
protected function testDirectoryStructure(){
$this->test(file_exists($this->getAppPath() . DIRECTORY_SEPARATOR . 'cache'),'cache directory existance')
->assertTrue();
$this->test(file_exists($this->getAppPath() . DIRECTORY_SEPARATOR . 'bin'),'bin directory existance')
->assertTrue();
$this->test(file_exists($this->getAppPath() . DIRECTORY_SEPARATOR . 'command'),'command directory existance')
->assertTrue();
$this->test(file_exists($this->getAppPath() . DIRECTORY_SEPARATOR . 'config'),'config directory existance')
->assertTrue();
$this->test(file_exists($this->getAppPath() . DIRECTORY_SEPARATOR . 'controller'),'controller directory existance')
->assertTrue();
$this->test(file_exists($this->getAppPath() . DIRECTORY_SEPARATOR . 'language'),'language directory existance')
->assertTrue();
$this->test(file_exists($this->getAppPath() . DIRECTORY_SEPARATOR . 'logs'),'model directory existance')
->assertTrue();
$this->test(file_exists($this->getAppPath() . DIRECTORY_SEPARATOR . 'notifiers'),'notifiers directory existance')
->assertTrue();
$this->test(file_exists($this->getAppPath() . DIRECTORY_SEPARATOR . 'public'),'public directory existance')
->assertTrue();
$this->test(file_exists($this->getAppPath() . DIRECTORY_SEPARATOR . 'view'),'view directory existance')
->assertTrue();
}
protected function testFilesWritable(){
$this->test(is_writable($this->getAppPath() . DIRECTORY_SEPARATOR . 'cache'),'cache directory writable')
->assertTrue();
$this->test(is_writable($this->getAppPath() . DIRECTORY_SEPARATOR . 'logs'), 'logs directory writable')
->assertTrue();
}
}