You are here

class ObjectManagerDecoratorTest in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/ObjectManagerDecoratorTest.php \Doctrine\Tests\Common\Persistence\ObjectManagerDecoratorTest

Hierarchy

  • class \Doctrine\Tests\Common\Persistence\ObjectManagerDecoratorTest extends \Doctrine\Tests\Common\Persistence\PHPUnit_Framework_TestCase

Expanded class hierarchy of ObjectManagerDecoratorTest

File

vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/ObjectManagerDecoratorTest.php, line 16

Namespace

Doctrine\Tests\Common\Persistence
View source
class ObjectManagerDecoratorTest extends \PHPUnit_Framework_TestCase {
  private $wrapped;
  private $decorated;
  public function setUp() {
    $this->wrapped = $this
      ->getMock('Doctrine\\Common\\Persistence\\ObjectManager');
    $this->decorated = new NullObjectManagerDecorator($this->wrapped);
  }
  public function getMethodParameters() {
    $class = new \ReflectionClass('Doctrine\\Common\\Persistence\\ObjectManager');
    $methods = array();
    foreach ($class
      ->getMethods() as $method) {
      if ($method
        ->getNumberOfRequiredParameters() === 0) {
        $methods[] = array(
          $method
            ->getName(),
          array(),
        );
      }
      elseif ($method
        ->getNumberOfRequiredParameters() > 0) {
        $methods[] = array(
          $method
            ->getName(),
          array_fill(0, $method
            ->getNumberOfRequiredParameters(), 'req') ?: array(),
        );
      }
      if ($method
        ->getNumberOfParameters() != $method
        ->getNumberOfRequiredParameters()) {
        $methods[] = array(
          $method
            ->getName(),
          array_fill(0, $method
            ->getNumberOfParameters(), 'all') ?: array(),
        );
      }
    }
    return $methods;
  }

  /**
   * @dataProvider getMethodParameters
   */
  public function testAllMethodCallsAreDelegatedToTheWrappedInstance($method, array $parameters) {
    $stub = $this->wrapped
      ->expects($this
      ->once())
      ->method($method)
      ->will($this
      ->returnValue('INNER VALUE FROM ' . $method));
    call_user_func_array(array(
      $stub,
      'with',
    ), $parameters);
    $this
      ->assertSame('INNER VALUE FROM ' . $method, call_user_func_array(array(
      $this->decorated,
      $method,
    ), $parameters));
  }

}

Members