OSDN Git Service

APIの変更にともなってテストケースを修正
[ethna/ethna.git] / test / Ethna_ClassFactory_Test.php
1 <?php
2 // vim: foldmethod=marker
3 /**
4  *  Ethna_ClassFactory_Test.php
5  *
6  *  @author     Yoshinari Takaoka <takaoka@beatcraft.com>
7  *  @version    $Id$
8  */
9
10 require_once ETHNA_BASE . '/test/Ethna_MocktestManager.php';
11
12 //{{{    Ethna_ClassFactory_Test
13 /**
14  *  Test Case For Ethna_ClassFactory_Test 
15  *
16  *  @access public
17  */
18 class Ethna_ClassFactory_Test extends Ethna_UnitTestBase
19 {
20     var $cf;
21
22     function setUp()
23     {
24         $ctl =& new Ethna_Controller();
25         $this->cf =& $ctl->getClassFactory();
26     }
27
28     //    Ethna_Controller と Ethna_ClassFactory は
29     //    循環参照している。PHP4では、循環参照しているオブジェクト同士を
30     //    比較しようとすると延々再帰的にプロパティと値を比較しようとする
31     //    ため Fatal Error を起こす。よって、PHP5以降でのみ以下はテストする
32     //    @see http://www.php.net/manual/en/language.oop.object-comparison.php
33     //    @see http://www.php.net/manual/en/language.oop5.object-comparison.php
34
35     function test_getManager()
36     {
37         //    大文字小文字を区別されても、
38         //    同じインスタンスを返さなければ
39         //    ならない
40         if (version_compare(phpversion(), '5', '>=')) {
41             $manager = $this->cf->getManager('mocktest');
42             $manager_alt = $this->cf->getManager('Mocktest');
43             $this->assertTrue($manager === $manager_alt);
44     
45             //    weakパラメータが指定された場合は 
46             //    強制的に違うオブジェクトを返さなければならない
47             $manager = $this->cf->getManager('mocktest');
48             $manager_alt = $this->cf->getManager('Mocktest', true);
49             $this->assertFalse($manager === $manager_alt);
50         }
51     }
52 }
53 // }}}
54
55 ?>