From a28978e8ab77996ac033e8f9e2056716f007a95e Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Thu, 25 Sep 2014 15:49:56 -0400 Subject: [PATCH] More tests. --- .../src/VuFindTest/Auth/ManagerTest.php | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/ManagerTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/ManagerTest.php index 9be874e7999..d7b76024e8d 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/ManagerTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Auth/ManagerTest.php @@ -118,6 +118,79 @@ class ManagerTest extends \VuFindTest\Unit\TestCase $manager->setAuthMethod('MultiILS'); } + /** + * Test supportsCreation + * + * @return void + */ + public function testSupportsCreation() + { + $config = array('Authentication' => array('method' => 'ChoiceAuth')); + $pm = $this->getMockPluginManager(); + $db = $pm->get('Database'); + $db->expects($this->once())->method('supportsCreation')->will($this->returnValue(true)); + $shib = $pm->get('Shibboleth'); + $shib->expects($this->once())->method('supportsCreation')->will($this->returnValue(false)); + $manager = $this->getManager($config, null, null, $pm); + $this->assertTrue($manager->supportsCreation('Database')); + $this->assertFalse($manager->supportsCreation('Shibboleth')); + } + + /** + * Test supportsRecovery + * + * @return void + */ + public function testSupportsRecovery() + { + // Most common case -- no: + $this->assertFalse($this->getManager()->supportsRecovery()); + + // Less common case -- yes: + $pm = $this->getMockPluginManager(); + $db = $pm->get('Database'); + $db->expects($this->once())->method('supportsPasswordChange')->will($this->returnValue(true)); + $config = array('Authentication' => array('recover_password' => true)); + $this->assertTrue($this->getManager($config, null, null, $pm)->supportsRecovery()); + } + + /** + * Test supportsPasswordChange + * + * @return void + */ + public function testSupportsPasswordChange() + { + // Most common case -- no: + $this->assertFalse($this->getManager()->supportsPasswordChange()); + + // Less common case -- yes: + $pm = $this->getMockPluginManager(); + $db = $pm->get('Database'); + $db->expects($this->once())->method('supportsPasswordChange')->will($this->returnValue(true)); + $config = array('Authentication' => array('change_password' => true)); + $this->assertTrue($this->getManager($config, null, null, $pm)->supportsPasswordChange()); + } + + /** + * Test getAuthClassForTemplateRendering + * + * @return void + */ + public function testGetAuthClassForTemplateRendering() + { + // Simple default case: + $pm = $this->getMockPluginManager(); + $this->assertEquals(get_class($pm->get('Database')), $this->getManager()->getAuthClassForTemplateRendering()); + + // Complex case involving proxied authenticator in ChoiceAuth: + $config = array('Authentication' => array('method' => 'ChoiceAuth')); + $choice = $pm->get('ChoiceAuth'); + $choice->expects($this->once())->method('getSelectedAuthOption')->will($this->returnValue('Shibboleth')); + $manager = $this->getManager($config, null, null, $pm); + $this->assertEquals(get_class($pm->get('Shibboleth')), $manager->getAuthClassForTemplateRendering()); + } + /** * Get a manager object to test with. * -- GitLab