/** * @runInSeparateProcess * @outputBuffering disabled */ public function testProtectedController() { if (!function_exists('xdebug_get_headers')) { $this->markTestSkipped('Xdebug not installed'); } $autoloader = new Autoloader(); $autoloader->register(); $autoloader->addNamespaces([['Linna\\FOO', dirname(__DIR__) . '/FOO']]); //config options $session = new Session(); $session->start(); $password = new Password(); $storedPassword = $password->hash('password'); //attemp first login $login = new Login($session, $password); $login->login('root', 'password', $storedUser = '******', $storedPassword, 1); $loginLogged = $login->logged; $model = new FOOModel(); $controller1 = new FOOProtectedController($model, $login); $controllerTest1 = $controller1->test; $login->logout(); $loginNoLogged = $login->logged; ob_start(); $controller2 = new FOOProtectedController($model, $login); $headers_list = xdebug_get_headers(); ob_end_clean(); $this->assertEquals(true, $loginLogged); $this->assertEquals(false, $loginNoLogged); $this->assertEquals(true, $controllerTest1); $this->assertEquals(true, in_array('Location: http://localhost', $headers_list)); $session->destroy(); }
public function __construct() { $autoloader = new Autoloader(); $autoloader->register(); $autoloader->addNamespaces([['Linna\\FOO', dirname(__DIR__) . '/FOO']]); $this->routes = array(); $this->routes[] = ['name' => 'Foo', 'method' => 'GET', 'url' => '/Foo/(modifyData)', 'model' => 'FOOModel', 'view' => 'FOOView', 'controller' => 'FOOController', 'action' => '']; $this->routes[] = ['name' => 'Foo', 'method' => 'GET', 'url' => '/Foo/[passedData]/(modifyDataFromParam)', 'model' => 'FOOModel', 'view' => 'FOOView', 'controller' => 'FOOController', 'action' => '']; }
*/ //load configuration from config file require dirname(__DIR__) . '/App/config/config.php'; //load routes. require APP . '/config/routes.php'; //composer autoload require ROOT . '/vendor/autoload.php'; /** * Autoloader Section * */ //linna autoloader, load application class //for more information see http://www.php-fig.org/psr/psr-4/ $loader = new Autoloader(); $loader->register(); $loader->addNamespaces([['App\\Models', __DIR__ . '/../App/Models'], ['App\\Views', __DIR__ . '/../App/Views'], ['App\\Controllers', __DIR__ . '/../App/Controllers'], ['App\\Templates', __DIR__ . '/../App/Templates'], ['App\\Mappers', __DIR__ . '/../App/Mappers'], ['App\\DomainObjects', __DIR__ . '/../App/DomainObjects']]); /** * Memcached Section * */ //create memcached instance //$memcached = new Memcached(); //connect to memcached server //$memcached->addServer($options['memcached']['host'], $options['memcached']['port']); /** * Database Section * */ //create adapter $MysqlAdapter = new MysqlPDOAdapter($options['pdo_mysql']['db_type'] . ':host=' . $options['pdo_mysql']['host'] . ';dbname=' . $options['pdo_mysql']['db_name'] . ';charset=' . $options['pdo_mysql']['charset'], $options['pdo_mysql']['user'], $options['pdo_mysql']['password'], array(\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_OBJ, \PDO::ATTR_ERRMODE => \PDO::ERRMODE_WARNING)); //create data base object