[ 'User' => [ 'sn' => [0 => 'test2'], 'mail' => [0 => 'test@test.fr'], 'givenname' => [0 => 'test1'], 'cn' => [0 => 'testa'], 'userpassword' => [0 => 'test'], ] ] ]; $this->session($user); $authType = ['authType' => 'cn']; $this->session($authType); } */ /** * testDisplay method * * @return void */ //public function testDisplay() /* public function testPage10AccessHome() { foreach ($this->ROLES as $role) $this->subtestPageAccessHomeAs($role); } */ public function testPage10AccessHomeAsUser() { $this->_testPageAccessHomeAs('USER'); } public function testPage10AccessHomeAsResp() { $this->_testPageAccessHomeAs('RESP'); } public function testPage10AccessHomeAsAdmin() { $this->_testPageAccessHomeAs('ADMIN'); } public function testPage10AccessHomeAsAdminPlus() { $this->_testPageAccessHomeAs('ADMINP'); } public function testPage10AccessHomeAsSuperAdmin() { $this->_testPageAccessHomeAs('SUPER'); } private function _testPageAccessHomeAs($role) { //$this->authUser(); $this->authAs($role); $this->get('/pages/home'); $this->assertResponseOk(); $this->assertResponseContains('Accueil'); $this->assertResponseContains('Voir mes matériels'); switch ($role) { case 'USER': $this->assertResponseContains('Utilisateur'); //$configuration->procedure_sur_accueil = TRUE; $this->assertResponseContains('Procédure à suivre'); break; case 'RESP': break; case 'ADMIN': $this->assertResponseContains('Administration'); $this->assertResponseContains('Voir les matériels à valider'); break; case 'ADMINP': break; case 'SUPER': $this->assertResponseContains('Super Administrateur'); break; } } //public function testDisplay() /* public function testPage20AccessTools() { foreach ($this->ROLES as $role) $this->subtestPageAccessToolsAs($role); } */ public function testPage20AccessToolsAsUser() { $this->_testPageAccessToolsAs('USER'); } public function testPage20AccessToolsAsResp() { $this->_testPageAccessToolsAs('RESP'); } public function testPage20AccessToolsAsAdmin() { $this->_testPageAccessToolsAs('ADMIN'); } public function testPage20AccessToolsAsAdminPlus() { $this->_testPageAccessToolsAs('ADMINP'); } public function testPage20AccessToolsAsSuperAdmin() { $this->_testPageAccessToolsAs('SUPER'); } private function _testPageAccessToolsAs($role) { $this->authAs($role); $this->get('/pages/tools'); if ( $this->USER_IS_ADMIN_AT_LEAST() ) { //if ( in_array($role, ['ADMIN','ADMINP','SUPER']) ) { //if ( $this->userHasRoleAtLeast('Administration') ) { //if ( $this->ControllerApp->userHasRoleAtLeast('Administration') ) { $this->assertResponseOk(); $this->assertResponseContains('Outils', $role.' should be allowed to access the Tools page'); $this->assertResponseContains('Gérer le contenu variable de ', $role); if ($this->USER_IS_SUPERADMIN()) //if ($role == 'SUPER') $this->assertResponseContains('Passer en mode DEBUG'); else $this->assertResponseNotContains('Passer en mode DEBUG'); } else { $this->assertResponseNotContains('Outils', $role.' should not be allowed to access the Tools page'); } } /** * Test that missing template renders 404 page in production * * @return void */ public function testMissingTemplate() { //$this->authUser(); $this->authSuperAdmin(); Configure::write('debug', false); $this->get('/pages/not_existing'); $this->assertResponseContains('Cette action est impossible'); } /** * Test that missing template in debug mode renders missing_template error page * * @return void */ public function testMissingTemplateInDebug() { //$this->authUser(); $this->authSuperAdmin(); Configure::write('debug', true); $this->get('/pages/not_existing'); $this->assertResponseFailure(); $this->assertResponseContains('Missing Template'); $this->assertResponseContains('Stacktrace'); } }