StaticTest.php 2.4 KB

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