Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for the factory and singleton methods.
git-svn-id: http://svn.php.net/repository/pear/packages/Auth_PrefManager2/trunk@162309 c90b9560-bf6c-de11-be94-00142212c4b1
- Loading branch information
Jon Wood
committed
Jun 29, 2004
1 parent
672551b
commit c3ce247
Showing
3 changed files
with
128 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
/* vim: set expandtab tabstop=4 shiftwidth=4 foldmethod=marker: */ | ||
// +----------------------------------------------------------------------+ | ||
// | Copyright (c) 2004 Jon Wood | | ||
// +----------------------------------------------------------------------+ | ||
// | This source file is subject to version 2.02 of the PHP license, | | ||
// | that is bundled with this package in the file LICENSE, and is | | ||
// | available at through the world-wide-web at | | ||
// | http://www.php.net/license/2_02.txt. | | ||
// | If you did not receive a copy of the PHP license and are unable to | | ||
// | obtain it through the world-wide-web, please send a note to | | ||
// | license@php.net so we can mail you a copy immediately. | | ||
// +----------------------------------------------------------------------+ | ||
// | Authors: Jon Wood <jon@jellybob.co.uk> | | ||
// | Paul M. Jones <pmjones@ciaweb.net> | | ||
// +----------------------------------------------------------------------+ | ||
// | ||
// $Id$ | ||
|
||
/** | ||
* Require Auth_PrefManager2 for testing. | ||
*/ | ||
require_once('Auth/PrefManager2.php'); | ||
require_once('support/MockContainer.php'); | ||
|
||
/** | ||
* Test cases to ensure that the factory and singleton methods work. | ||
* | ||
* @author Jon Wood <jon@jellybob.co.uk> | ||
* @package Auth_PrefManager2 | ||
* @version 0.1.0 | ||
*/ | ||
class CreationTests extends UnitTestCase | ||
{ | ||
/** | ||
* Constructor | ||
* | ||
* @access public | ||
* @return void | ||
*/ | ||
function CreationTests() | ||
{ | ||
$this->UnitTestCase(); | ||
} | ||
|
||
/** | ||
* Test the factory method. | ||
* | ||
* @access public | ||
* @return void | ||
* @todo Switch to using a full container once one is done. | ||
*/ | ||
function testFactory() | ||
{ | ||
$object =& Auth_PrefManager2::factory("Mock"); | ||
$this->assertIsA($object, "Auth_PrefManager2_Mock"); | ||
} | ||
|
||
/** | ||
* Test the factory method. | ||
* | ||
* @access public | ||
* @return void | ||
* @todo Switch to using a full container once one is done. | ||
*/ | ||
function testSingleton() | ||
{ | ||
$object =& Auth_PrefManager2::singleton("Mock"); | ||
$reference =& Auth_PrefManager2::singleton("Mock"); | ||
|
||
$this->assertReference($object, $reference); | ||
} | ||
} | ||
?> |
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,51 @@ | ||
<?php | ||
/* vim: set expandtab tabstop=4 shiftwidth=4 foldmethod=marker: */ | ||
// +----------------------------------------------------------------------+ | ||
// | Copyright (c) 2004 Jon Wood | | ||
// +----------------------------------------------------------------------+ | ||
// | This source file is subject to version 2.02 of the PHP license, | | ||
// | that is bundled with this package in the file LICENSE, and is | | ||
// | available at through the world-wide-web at | | ||
// | http://www.php.net/license/2_02.txt. | | ||
// | If you did not receive a copy of the PHP license and are unable to | | ||
// | obtain it through the world-wide-web, please send a note to | | ||
// | license@php.net so we can mail you a copy immediately. | | ||
// +----------------------------------------------------------------------+ | ||
// | Authors: Jon Wood <jon@jellybob.co.uk> | | ||
// | Paul M. Jones <pmjones@ciaweb.net> | | ||
// +----------------------------------------------------------------------+ | ||
// | ||
// $Id$ | ||
|
||
/** | ||
* Require the base class. | ||
*/ | ||
require_once('Auth/PrefManager2.php'); | ||
|
||
/** | ||
* A mock container for testing the factory and singleton methods. | ||
* | ||
* @author Jon Wood <jon@jellybob.co.uk> | ||
* @package Auth_PrefManager2 | ||
* @category Authentication | ||
* @version 0.1.0 | ||
*/ | ||
class Auth_PrefManager2_Mock extends Auth_PrefManager2 | ||
{ | ||
/** | ||
* Constructor | ||
* | ||
* Applications should never call this constructor directly, instead | ||
* create a container with the factory method. | ||
* | ||
* @access protected | ||
* @param array $options An associative array of options. | ||
* @return void | ||
* @see Auth_PrefManager2::&factory() | ||
*/ | ||
function Auth_PrefManager2_Mock($options = array()) | ||
{ | ||
$this->Auth_PrefManager2($options); | ||
} | ||
} | ||
?> |