MethodMetadataTest.php 1.1KB

123456789101112131415161718192021222324252627282930313233343536
  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. $this->assertEquals('Metadata\Tests\Fixtures\TestObject', $metadata->class);
  11. $this->assertEquals('setFoo', $metadata->name);
  12. $this->assertEquals(new \ReflectionMethod('Metadata\Tests\Fixtures\TestObject', 'setFoo'), $metadata->reflection);
  13. }
  14. public function testSerializeUnserialize()
  15. {
  16. $metadata = new MethodMetadata('Metadata\Tests\Fixtures\TestObject', 'setFoo');
  17. $this->assertEquals($metadata, unserialize(serialize($metadata)));
  18. }
  19. public function testInvoke()
  20. {
  21. $obj = new TestObject();
  22. $metadata = new MethodMetadata('Metadata\Tests\Fixtures\TestObject', 'setFoo');
  23. $this->assertNull($obj->getFoo());
  24. $metadata->invoke($obj, array('foo'));
  25. $this->assertEquals('foo', $obj->getFoo());
  26. }
  27. }