-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#47: Add tests for term visibility admin.
- Loading branch information
1 parent
378d297
commit f2fff05
Showing
3 changed files
with
80 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
|
||
namespace App\Tests\Controller; | ||
|
||
use App\Security\SamlUser; | ||
use App\Tests\AppDatabaseTestTrait; | ||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; | ||
|
||
class AdminTest extends WebTestCase | ||
{ | ||
use AppDatabaseTestTrait; | ||
|
||
private function setUpUser(): SamlUser | ||
{ | ||
$user = new SamlUser('WEBID99999990'); | ||
$user->setSamlAttributes([ | ||
'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress' => ['[email protected]'], | ||
'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname' => ['Winnie'], | ||
'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname' => ['The-Pooh'], | ||
'AssignedRoles' => ['App.EmailSendAllowed', 'App.Manager'], | ||
]); | ||
|
||
return $user; | ||
} | ||
|
||
public function testIndex(): void | ||
{ | ||
$client = static::createClient(); | ||
$client->loginUser($this->setUpUser()); | ||
|
||
$crawler = $client->request('GET', '/admin'); | ||
|
||
$this->assertResponseIsSuccessful(); | ||
} | ||
|
||
public function testIndexAnonymous(): void | ||
{ | ||
$client = static::createClient(); | ||
|
||
$crawler = $client->request('GET', '/admin'); | ||
|
||
$this->assertResponseRedirects(); | ||
} | ||
|
||
public function testIndexNonManager(): void | ||
{ | ||
$client = static::createClient(); | ||
|
||
$user = new SamlUser('WEBID99999990'); | ||
$user->setSamlAttributes([ | ||
'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress' => ['[email protected]'], | ||
'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname' => ['Winnie'], | ||
'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname' => ['The-Pooh'], | ||
'AssignedRoles' => ['App.EmailSendAllowed'], | ||
]); | ||
$client->loginUser($user); | ||
|
||
$client->request('GET', '/admin'); | ||
|
||
$this->assertEquals(403, $client->getResponse()->getStatusCode()); | ||
} | ||
|
||
public function testTermVisibilityList(): void | ||
{ | ||
$client = static::createClient(); | ||
$client->loginUser($this->setUpUser()); | ||
|
||
$crawler = $client->request('GET', '/admin/terms'); | ||
$this->assertResponseIsSuccessful(); | ||
|
||
$crawler = $client->request('GET', '/admin/terms?catalog=MCUG'); | ||
$this->assertResponseIsSuccessful(); | ||
$this->assertSelectorTextContains('.section_admin', '200990'); | ||
} | ||
} |