Skip to content
Snippets Groups Projects
Commit a28978e8 authored by Demian Katz's avatar Demian Katz
Browse files

More tests.

parent 136bd75f
No related merge requests found
...@@ -118,6 +118,79 @@ class ManagerTest extends \VuFindTest\Unit\TestCase ...@@ -118,6 +118,79 @@ class ManagerTest extends \VuFindTest\Unit\TestCase
$manager->setAuthMethod('MultiILS'); $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. * Get a manager object to test with.
* *
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment