DoctrineProxyMatcherTest.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace DeepCopyTest\Matcher;
  3. use BadMethodCallException;
  4. use DeepCopy\Matcher\Doctrine\DoctrineProxyMatcher;
  5. use Doctrine\Common\Persistence\Proxy;
  6. use PHPUnit\Framework\TestCase;
  7. use stdClass;
  8. /**
  9. * @covers \DeepCopy\Matcher\Doctrine\DoctrineProxyMatcher
  10. */
  11. class DoctrineProxyMatcherTest extends TestCase
  12. {
  13. /**
  14. * @dataProvider providePairs
  15. */
  16. public function test_it_matches_the_given_objects($object, $expected)
  17. {
  18. $matcher = new DoctrineProxyMatcher();
  19. $actual = $matcher->matches($object, 'unknown');
  20. $this->assertEquals($expected, $actual);
  21. }
  22. public function providePairs()
  23. {
  24. return [
  25. [new FooProxy(), true],
  26. [new stdClass(), false],
  27. ];
  28. }
  29. }
  30. class FooProxy implements Proxy
  31. {
  32. /**
  33. * @inheritdoc
  34. */
  35. public function __load()
  36. {
  37. throw new BadMethodCallException();
  38. }
  39. /**
  40. * @inheritdoc
  41. */
  42. public function __isInitialized()
  43. {
  44. throw new BadMethodCallException();
  45. }
  46. }