2015-08-17 17:00:26 -07:00
< ? php
class Framework_MockObject_Invocation_ObjectTest extends PHPUnit_Framework_TestCase
{
public function testConstructorRequiresClassAndMethodAndParametersAndObject ()
{
new PHPUnit_Framework_MockObject_Invocation_Object (
'FooClass' ,
'FooMethod' ,
array ( 'an_argument' ),
2015-10-08 11:40:12 -07:00
new StdClass
);
2015-08-17 17:00:26 -07:00
}
public function testAllowToGetClassNameSetInConstructor ()
{
$invocation = new PHPUnit_Framework_MockObject_Invocation_Object (
'FooClass' ,
'FooMethod' ,
array ( 'an_argument' ),
2015-10-08 11:40:12 -07:00
new StdClass
);
2015-08-17 17:00:26 -07:00
$this -> assertSame ( 'FooClass' , $invocation -> className );
}
public function testAllowToGetMethodNameSetInConstructor ()
{
$invocation = new PHPUnit_Framework_MockObject_Invocation_Object (
'FooClass' ,
'FooMethod' ,
array ( 'an_argument' ),
2015-10-08 11:40:12 -07:00
new StdClass
);
2015-08-17 17:00:26 -07:00
$this -> assertSame ( 'FooMethod' , $invocation -> methodName );
}
public function testAllowToGetObjectSetInConstructor ()
{
$expectedObject = new StdClass ;
$invocation = new PHPUnit_Framework_MockObject_Invocation_Object (
'FooClass' ,
'FooMethod' ,
array ( 'an_argument' ),
2015-10-08 11:40:12 -07:00
$expectedObject
);
2015-08-17 17:00:26 -07:00
$this -> assertSame ( $expectedObject , $invocation -> object );
}
public function testAllowToGetMethodParametersSetInConstructor ()
{
$expectedParameters = array (
2015-10-08 11:40:12 -07:00
'foo' , 5 , array ( 'a' , 'b' ), new StdClass , null , false
2015-08-17 17:00:26 -07:00
);
$invocation = new PHPUnit_Framework_MockObject_Invocation_Object (
2015-10-08 11:40:12 -07:00
'FooClass' ,
'FooMethod' ,
$expectedParameters ,
new StdClass
2015-08-17 17:00:26 -07:00
);
$this -> assertSame ( $expectedParameters , $invocation -> parameters );
}
public function testConstructorAllowToSetFlagCloneObjectsInParameters ()
{
$parameters = array ( new StdClass );
2015-10-08 11:40:12 -07:00
$cloneObjects = true ;
2015-08-17 17:00:26 -07:00
$invocation = new PHPUnit_Framework_MockObject_Invocation_Object (
2015-10-08 11:40:12 -07:00
'FooClass' ,
'FooMethod' ,
$parameters ,
new StdClass ,
$cloneObjects
2015-08-17 17:00:26 -07:00
);
$this -> assertEquals ( $parameters , $invocation -> parameters );
$this -> assertNotSame ( $parameters , $invocation -> parameters );
}
}