gnu-social/vendor/jms/metadata/tests/Metadata/Tests/MethodMetadataTest.php

37 lines
1.2 KiB
PHP
Raw Normal View History

2020-08-07 23:42:38 +01:00
<?php
namespace Metadata\Tests;
use Metadata\Tests\Fixtures\TestObject;
use Metadata\MethodMetadata;
class MethodMetadataTest extends \PHPUnit_Framework_TestCase
{
public function testConstructor()
{
$metadata = new MethodMetadata('Metadata\Tests\Fixtures\TestObject', 'setFoo');
$expectedReflector = new \ReflectionMethod('Metadata\Tests\Fixtures\TestObject', 'setFoo');
$expectedReflector->setAccessible(true);
$this->assertEquals('Metadata\Tests\Fixtures\TestObject', $metadata->class);
$this->assertEquals('setFoo', $metadata->name);
$this->assertEquals($expectedReflector, $metadata->reflection);
}
public function testSerializeUnserialize()
{
$metadata = new MethodMetadata('Metadata\Tests\Fixtures\TestObject', 'setFoo');
$this->assertEquals($metadata, unserialize(serialize($metadata)));
}
public function testInvoke()
{
$obj = new TestObject();
$metadata = new MethodMetadata('Metadata\Tests\Fixtures\TestObject', 'setFoo');
$this->assertNull($obj->getFoo());
$metadata->invoke($obj, array('foo'));
$this->assertEquals('foo', $obj->getFoo());
}
}