MethodMetadataTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace Metadata\Tests;
  3. use Metadata\Tests\Fixtures\TestObject;
  4. use Metadata\MethodMetadata;
  5. class MethodMetadataTest extends \PHPUnit_Framework_TestCase
  6. {
  7. public function testConstructor()
  8. {
  9. $metadata = new MethodMetadata('Metadata\Tests\Fixtures\TestObject', 'setFoo');
  10. $expectedReflector = new \ReflectionMethod('Metadata\Tests\Fixtures\TestObject', 'setFoo');
  11. $expectedReflector->setAccessible(true);
  12. $this->assertEquals('Metadata\Tests\Fixtures\TestObject', $metadata->class);
  13. $this->assertEquals('setFoo', $metadata->name);
  14. $this->assertEquals($expectedReflector, $metadata->reflection);
  15. }
  16. public function testSerializeUnserialize()
  17. {
  18. $metadata = new MethodMetadata('Metadata\Tests\Fixtures\TestObject', 'setFoo');
  19. $this->assertEquals($metadata, unserialize(serialize($metadata)));
  20. }
  21. public function testInvoke()
  22. {
  23. $obj = new TestObject();
  24. $metadata = new MethodMetadata('Metadata\Tests\Fixtures\TestObject', 'setFoo');
  25. $this->assertNull($obj->getFoo());
  26. $metadata->invoke($obj, array('foo'));
  27. $this->assertEquals('foo', $obj->getFoo());
  28. }
  29. }