-
-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Changed to use interfaces for type-hinting where necessary. - Closes #565
- Loading branch information
Showing
16 changed files
with
185 additions
and
42 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
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
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
36 changes: 36 additions & 0 deletions
36
spec/Drupal/DrupalExtension/Manager/DrupalAuthenticationManagerSpec.php
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,36 @@ | ||
<?php | ||
|
||
namespace spec\Drupal\DrupalExtension\Manager; | ||
|
||
use Behat\Mink\Element\DocumentElement; | ||
use Behat\Mink\Mink; | ||
use Behat\Mink\Session; | ||
use Drupal\DrupalDriverManagerInterface; | ||
use Drupal\DrupalExtension\Manager\DrupalAuthenticationManager; | ||
use Drupal\DrupalExtension\Manager\DrupalUserManagerInterface; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
class DrupalAuthenticationManagerSpec extends ObjectBehavior | ||
{ | ||
function let(Mink $mink, DrupalUserManagerInterface $userManager, DrupalDriverManagerInterface $driverManager, Session $session) | ||
{ | ||
$mink->getSession(null)->willReturn($session); | ||
$this->beConstructedWith($mink, $userManager, $driverManager, [], []); | ||
} | ||
|
||
function it_is_initializable() | ||
{ | ||
$this->shouldHaveType(DrupalAuthenticationManager::class); | ||
} | ||
|
||
function it_can_check_login_status(Session $session, DocumentElement $page) | ||
{ | ||
$this->loggedIn()->shouldBe(false); | ||
|
||
$page->has('css', '.a-class')->willReturn(true); | ||
$session->isStarted()->willReturn(true); | ||
$session->getPage()->willReturn($page); | ||
$this->setDrupalParameters(['selectors' => ['logged_in_selector' => '.a-class']]); | ||
$this->loggedIn()->shouldBe(true); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
spec/Drupal/DrupalExtension/Manager/DrupalUserManagerSpec.php
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,61 @@ | ||
<?php | ||
|
||
namespace spec\Drupal\DrupalExtension\Manager; | ||
|
||
use Drupal\DrupalExtension\Manager\DrupalUserManager; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
class DrupalUserManagerSpec extends ObjectBehavior | ||
{ | ||
function it_is_initializable() | ||
{ | ||
$this->shouldHaveType(DrupalUserManager::class); | ||
} | ||
|
||
function it_can_set_and_get_the_current_user() | ||
{ | ||
$user = new \stdClass(); | ||
$user->name = 'some_name'; | ||
$this->setCurrentUser($user); | ||
$this->getCurrentUser()->shouldBe($user); | ||
} | ||
|
||
function it_can_add_and_remove_users() | ||
{ | ||
$user = new \stdClass(); | ||
$user->name = 'some_name'; | ||
$this->addUser($user); | ||
$this->getUser('some_name')->shouldBe($user); | ||
$this->removeUser('some_name'); | ||
$this->shouldThrow(\InvalidArgumentException::class)->duringGetUser('some_name'); | ||
} | ||
|
||
function it_can_get_all_registered_users() | ||
{ | ||
$this->hasUsers()->shouldBe(false); | ||
$user = new \stdClass(); | ||
$user->name = 'some_name'; | ||
$this->addUser($user); | ||
$this->hasUsers()->shouldBe(true); | ||
$this->getUsers()->shouldBe(['some_name' => $user]); | ||
} | ||
|
||
function it_can_determine_anonymous_users() | ||
{ | ||
$this->currentUserIsAnonymous()->shouldBe(true); | ||
$user = new \stdClass(); | ||
$user->name = 'some_name'; | ||
$this->setCurrentUser($user); | ||
$this->currentUserIsAnonymous()->shouldBe(false); | ||
} | ||
|
||
function it_can_check_roles() | ||
{ | ||
$this->currentUserHasRole('some_role')->shouldBe(false); | ||
$user = new \stdClass(); | ||
$user->name = 'some_name'; | ||
$user->role = 'some_role'; | ||
$this->setCurrentUser($user); | ||
$this->currentUserHasRole('some_role')->shouldBe(true); | ||
} | ||
} |
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
Oops, something went wrong.