[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/Assertion/ -> CanProxyAssertionTest.php (source)

   1  <?php
   2  /*
   3   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   4   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   5   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
   6   * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
   7   * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   8   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   9   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  10   * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11   * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  13   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14   *
  15   * This software consists of voluntary contributions made by many individuals
  16   * and is licensed under the MIT license.
  17   */
  18  
  19  namespace ProxyManagerTest\ProxyGenerator\Assertion;
  20  
  21  use PHPUnit_Framework_TestCase;
  22  use ProxyManager\ProxyGenerator\Assertion\CanProxyAssertion;
  23  use ReflectionClass;
  24  
  25  /**
  26   * Tests for {@see \ProxyManager\ProxyGenerator\Assertion\CanProxyAssertion}
  27   *
  28   * @author Marco Pivetta <ocramius@gmail.com>
  29   * @license MIT
  30   *
  31   * @covers \ProxyManager\ProxyGenerator\Assertion\CanProxyAssertion
  32   * @group Coverage
  33   */
  34  class CanProxyAssertionTest extends PHPUnit_Framework_TestCase
  35  {
  36      public function testDeniesFinalClasses()
  37      {
  38          $this->setExpectedException('ProxyManager\Exception\InvalidProxiedClassException');
  39  
  40          CanProxyAssertion::assertClassCanBeProxied(new ReflectionClass('ProxyManagerTestAsset\\FinalClass'));
  41      }
  42  
  43      public function testDeniesClassesWithAbstractProtectedMethods()
  44      {
  45          $this->setExpectedException('ProxyManager\Exception\InvalidProxiedClassException');
  46  
  47          CanProxyAssertion::assertClassCanBeProxied(new ReflectionClass(
  48              'ProxyManagerTestAsset\\ClassWithAbstractProtectedMethod'
  49          ));
  50      }
  51  
  52      public function testAllowsInterfaceByDefault()
  53      {
  54          CanProxyAssertion::assertClassCanBeProxied(new ReflectionClass(
  55              'ProxyManagerTestAsset\\BaseInterface'
  56          ));
  57  
  58          $this->assertTrue(true); // not nice, but assertions are just fail-checks, no real code executed
  59      }
  60  
  61      public function testDeniesInterfaceIfSpecified()
  62      {
  63          $this->setExpectedException('ProxyManager\Exception\InvalidProxiedClassException');
  64  
  65          CanProxyAssertion::assertClassCanBeProxied(new ReflectionClass('ProxyManagerTestAsset\\BaseInterface'), false);
  66      }
  67  
  68      /**
  69       * @param string $className
  70       *
  71       * @dataProvider validClasses
  72       */
  73      public function testAllowedClass($className)
  74      {
  75          CanProxyAssertion::assertClassCanBeProxied(new ReflectionClass($className));
  76  
  77          $this->assertTrue(true); // not nice, but assertions are just fail-checks, no real code executed
  78      }
  79  
  80      public function testDisallowsConstructor()
  81      {
  82          $this->setExpectedException('BadMethodCallException');
  83  
  84          new CanProxyAssertion();
  85      }
  86  
  87      /**
  88       * @return string[][]
  89       */
  90      public function validClasses()
  91      {
  92          return array(
  93              array('ProxyManagerTestAsset\AccessInterceptorValueHolderMock'),
  94              array('ProxyManagerTestAsset\BaseClass'),
  95              array('ProxyManagerTestAsset\BaseInterface'),
  96              array('ProxyManagerTestAsset\CallableTypeHintClass'),
  97              array('ProxyManagerTestAsset\ClassWithByRefMagicMethods'),
  98              array('ProxyManagerTestAsset\ClassWithFinalMagicMethods'),
  99              array('ProxyManagerTestAsset\ClassWithFinalMethods'),
 100              array('ProxyManagerTestAsset\ClassWithMethodWithDefaultParameters'),
 101              array('ProxyManagerTestAsset\ClassWithMixedProperties'),
 102              array('ProxyManagerTestAsset\ClassWithPrivateProperties'),
 103              array('ProxyManagerTestAsset\ClassWithProtectedProperties'),
 104              array('ProxyManagerTestAsset\ClassWithPublicProperties'),
 105              array('ProxyManagerTestAsset\ClassWithPublicArrayProperty'),
 106              array('ProxyManagerTestAsset\ClassWithSelfHint'),
 107              array('ProxyManagerTestAsset\EmptyClass'),
 108              array('ProxyManagerTestAsset\HydratedObject'),
 109              array('ProxyManagerTestAsset\LazyLoadingMock'),
 110              array('ProxyManagerTestAsset\NullObjectMock'),
 111          );
 112      }
 113  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1