[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/vendor/ocramius/proxy-manager/tests/ProxyManagerTest/ProxyGenerator/Util/ -> ProxiedMethodsFilterTest.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\Util;
  20  
  21  use PHPUnit_Framework_TestCase;
  22  use ProxyManager\ProxyGenerator\Util\ProxiedMethodsFilter;
  23  use ReflectionClass;
  24  use ReflectionMethod;
  25  
  26  /**
  27   * Tests for {@see \ProxyManager\ProxyGenerator\Util\ProxiedMethodsFilter}
  28   *
  29   * @author Marco Pivetta <ocramius@gmail.com>
  30   * @license MIT
  31   *
  32   * @covers \ProxyManager\ProxyGenerator\Util\ProxiedMethodsFilter
  33   * @group Coverage
  34   */
  35  class ProxiedMethodsFilterTest extends PHPUnit_Framework_TestCase
  36  {
  37      /**
  38       * @dataProvider expectedMethods
  39       */
  40      public function testFiltering(ReflectionClass $reflectionClass, $excludes, array $expectedMethods)
  41      {
  42          if (is_array($excludes)) {
  43              $filtered = ProxiedMethodsFilter::getProxiedMethods($reflectionClass, $excludes);
  44          } else {
  45              $filtered = ProxiedMethodsFilter::getProxiedMethods($reflectionClass);
  46          }
  47  
  48          foreach ($filtered as $method) {
  49              $this->assertInstanceOf('ReflectionMethod', $method);
  50          }
  51  
  52          $keys = array_map(
  53              function (ReflectionMethod $method) {
  54                  return $method->getName();
  55              },
  56              $filtered
  57          );
  58  
  59          sort($keys);
  60          sort($expectedMethods);
  61  
  62          $this->assertSame($keys, $expectedMethods);
  63      }
  64  
  65      /**
  66       * @return array[][]
  67       */
  68      public function expectedMethods()
  69      {
  70          return array(
  71              array(
  72                  new ReflectionClass('ProxyManagerTestAsset\\BaseClass'),
  73                  null,
  74                  array(
  75                      'publicArrayHintedMethod',
  76                      'publicByReferenceMethod',
  77                      'publicByReferenceParameterMethod',
  78                      'publicMethod',
  79                      'publicTypeHintedMethod',
  80                  ),
  81              ),
  82              array(
  83                  new ReflectionClass('ProxyManagerTestAsset\\EmptyClass'),
  84                  null,
  85                  array(),
  86              ),
  87              array(
  88                  new ReflectionClass('ProxyManagerTestAsset\\LazyLoadingMock'),
  89                  null,
  90                  array(),
  91              ),
  92              array(
  93                  new ReflectionClass('ProxyManagerTestAsset\\LazyLoadingMock'),
  94                  array(),
  95                  array(),
  96              ),
  97              array(
  98                  new ReflectionClass('ProxyManagerTestAsset\\HydratedObject'),
  99                  array('doFoo'),
 100                  array('__get'),
 101              ),
 102              array(
 103                  new ReflectionClass('ProxyManagerTestAsset\\HydratedObject'),
 104                  array('Dofoo'),
 105                  array('__get'),
 106              ),
 107              array(
 108                  new ReflectionClass('ProxyManagerTestAsset\\HydratedObject'),
 109                  array(),
 110                  array('doFoo', '__get'),
 111              ),
 112          );
 113      }
 114  }


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