[ '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 testPage10AccessHome() { foreach ($this->ROLES as $role) $this->subtestPageAccessHomeAs($role); } //public function testDisplay() private function subtestPageAccessHomeAs($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 testPage20AccessTools() { foreach ($this->ROLES as $role) $this->subtestPageAccessToolsAs($role); } //public function testDisplay() private function subtestPageAccessToolsAs($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 ($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'); } }