mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENHANCEMENT Added ObjectTest->testSingletonCreation()
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@63619 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
82d6b7e640
commit
d909754999
@ -59,6 +59,20 @@ class ObjectTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testSingletonCreation() {
|
||||||
|
$myObject = singleton('ObjectTest_MyObject');
|
||||||
|
$this->assertEquals($myObject->class, 'ObjectTest_MyObject', 'singletons are creating a correct class instance');
|
||||||
|
$this->assertEquals(get_class($myObject), 'ObjectTest_MyObject', 'singletons are creating a correct class instance');
|
||||||
|
|
||||||
|
$mySubObject = singleton('ObjectTest_MySubObject');
|
||||||
|
$this->assertEquals($mySubObject->class, 'ObjectTest_MySubObject', 'singletons are creating a correct subclass instance');
|
||||||
|
$this->assertEquals(get_class($mySubObject), 'ObjectTest_MySubObject', 'singletons are creating a correct subclass instance');
|
||||||
|
|
||||||
|
$myFirstObject = singleton('ObjectTest_MyObject');
|
||||||
|
$mySecondObject = singleton('ObjectTest_MyObject');
|
||||||
|
$this->assertTrue($myFirstObject === $mySecondObject, 'singletons are using the same object on subsequent calls');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ObjectTest_T1A extends Object {
|
class ObjectTest_T1A extends Object {
|
||||||
@ -113,3 +127,11 @@ class ObjectTest_T2 extends Object {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ObjectTest_MyObject extends Object {
|
||||||
|
public $title = 'my object';
|
||||||
|
}
|
||||||
|
|
||||||
|
class ObjectTest_MySubObject extends ObjectTest_MyObject {
|
||||||
|
public $title = 'my subobject';
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user