Drupal investigation

ObjectTest.php 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. class Framework_MockObject_Invocation_ObjectTest extends PHPUnit_Framework_TestCase
  3. {
  4. public function testConstructorRequiresClassAndMethodAndParametersAndObject()
  5. {
  6. new PHPUnit_Framework_MockObject_Invocation_Object(
  7. 'FooClass',
  8. 'FooMethod',
  9. array('an_argument'),
  10. new StdClass
  11. );
  12. }
  13. public function testAllowToGetClassNameSetInConstructor()
  14. {
  15. $invocation = new PHPUnit_Framework_MockObject_Invocation_Object(
  16. 'FooClass',
  17. 'FooMethod',
  18. array('an_argument'),
  19. new StdClass
  20. );
  21. $this->assertSame('FooClass', $invocation->className);
  22. }
  23. public function testAllowToGetMethodNameSetInConstructor()
  24. {
  25. $invocation = new PHPUnit_Framework_MockObject_Invocation_Object(
  26. 'FooClass',
  27. 'FooMethod',
  28. array('an_argument'),
  29. new StdClass
  30. );
  31. $this->assertSame('FooMethod', $invocation->methodName);
  32. }
  33. public function testAllowToGetObjectSetInConstructor()
  34. {
  35. $expectedObject = new StdClass;
  36. $invocation = new PHPUnit_Framework_MockObject_Invocation_Object(
  37. 'FooClass',
  38. 'FooMethod',
  39. array('an_argument'),
  40. $expectedObject
  41. );
  42. $this->assertSame($expectedObject, $invocation->object);
  43. }
  44. public function testAllowToGetMethodParametersSetInConstructor()
  45. {
  46. $expectedParameters = array(
  47. 'foo', 5, array('a', 'b'), new StdClass, null, false
  48. );
  49. $invocation = new PHPUnit_Framework_MockObject_Invocation_Object(
  50. 'FooClass',
  51. 'FooMethod',
  52. $expectedParameters,
  53. new StdClass
  54. );
  55. $this->assertSame($expectedParameters, $invocation->parameters);
  56. }
  57. public function testConstructorAllowToSetFlagCloneObjectsInParameters()
  58. {
  59. $parameters = array(new StdClass);
  60. $cloneObjects = true;
  61. $invocation = new PHPUnit_Framework_MockObject_Invocation_Object(
  62. 'FooClass',
  63. 'FooMethod',
  64. $parameters,
  65. new StdClass,
  66. $cloneObjects
  67. );
  68. $this->assertEquals($parameters, $invocation->parameters);
  69. $this->assertNotSame($parameters, $invocation->parameters);
  70. }
  71. }