Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

MultipleProxyGenerationTest.php

Zuletzt modifiziert: 09.10.2024, 12:58 - Dateigröße: 4.96 KiB


001  <?php
002  /*
003   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
004   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
005   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
006   * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
007   * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
008   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
009   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
010   * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
011   * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
012   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
013   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
014   *
015   * This software consists of voluntary contributions made by many individuals
016   * and is licensed under the MIT license.
017   */
018   
019  namespace ProxyManagerTest\Functional;
020   
021  use PHPUnit_Framework_TestCase;
022  use ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory;
023  use ProxyManager\Factory\AccessInterceptorValueHolderFactory;
024  use ProxyManager\Factory\LazyLoadingGhostFactory;
025  use ProxyManager\Factory\LazyLoadingValueHolderFactory;
026  use ReflectionClass;
027  use ReflectionProperty;
028   
029  /**
030   * Verifies that proxy factories don't conflict with each other when generating proxies
031   *
032   * @author Marco Pivetta <ocramius@gmail.com>
033   * @license MIT
034   *
035   * @link https://github.com/Ocramius/ProxyManager/issues/10
036   *
037   * @group Functional
038   * @group issue-10
039   * @coversNothing
040   */
041  class MultipleProxyGenerationTest extends PHPUnit_Framework_TestCase
042  {
043      /**
044       * Verifies that proxies generated from different factories will retain their specific implementation
045       * and won't conflict
046       *
047       * @dataProvider getTestedClasses
048       */
049      public function testCanGenerateMultipleDifferentProxiesForSameClass($className)
050      {
051          $skipScopeLocalizerTests                = false;
052          $ghostProxyFactory                      = new LazyLoadingGhostFactory();
053          $virtualProxyFactory                    = new LazyLoadingValueHolderFactory();
054          $accessInterceptorFactory               = new AccessInterceptorValueHolderFactory();
055          $accessInterceptorScopeLocalizerFactory = new AccessInterceptorScopeLocalizerFactory();
056          $initializer                            = function () {
057          };
058   
059          $reflectionClass = new ReflectionClass($className);
060   
061          if ((! method_exists('Closure', 'bind')) && $reflectionClass->getProperties(ReflectionProperty::IS_PRIVATE)) {
062              $skipScopeLocalizerTests = true;
063          }
064   
065          $generated = array(
066              $ghostProxyFactory->createProxy($className, $initializer),
067              $virtualProxyFactory->createProxy($className, $initializer),
068              $accessInterceptorFactory->createProxy(new $className()),
069          );
070   
071          if (! $skipScopeLocalizerTests) {
072              $generated[] = $accessInterceptorScopeLocalizerFactory->createProxy(new $className());
073          }
074   
075          foreach ($generated as $key => $proxy) {
076              $this->assertInstanceOf($className, $proxy);
077   
078              foreach ($generated as $comparedKey => $comparedProxy) {
079                  if ($comparedKey === $key) {
080                      continue;
081                  }
082   
083                  $this->assertNotSame(get_class($comparedProxy), get_class($proxy));
084              }
085          }
086   
087          $this->assertInstanceOf('ProxyManager\Proxy\GhostObjectInterface', $generated[0]);
088          $this->assertInstanceOf('ProxyManager\Proxy\VirtualProxyInterface', $generated[1]);
089          $this->assertInstanceOf('ProxyManager\Proxy\AccessInterceptorInterface', $generated[2]);
090          $this->assertInstanceOf('ProxyManager\Proxy\ValueHolderInterface', $generated[2]);
091   
092          if (! $skipScopeLocalizerTests) {
093              $this->assertInstanceOf('ProxyManager\Proxy\AccessInterceptorInterface', $generated[3]);
094          }
095      }
096   
097      /**
098       * @return string[][]
099       */
100      public function getTestedClasses()
101      {
102          $data = array(
103              array('ProxyManagerTestAsset\\BaseClass'),
104              array('ProxyManagerTestAsset\\ClassWithMagicMethods'),
105              array('ProxyManagerTestAsset\\ClassWithFinalMethods'),
106              array('ProxyManagerTestAsset\\ClassWithFinalMagicMethods'),
107              array('ProxyManagerTestAsset\\ClassWithByRefMagicMethods'),
108              array('ProxyManagerTestAsset\\ClassWithMixedProperties'),
109              array('ProxyManagerTestAsset\\ClassWithPrivateProperties'),
110              array('ProxyManagerTestAsset\\ClassWithProtectedProperties'),
111              array('ProxyManagerTestAsset\\ClassWithPublicProperties'),
112              array('ProxyManagerTestAsset\\EmptyClass'),
113              array('ProxyManagerTestAsset\\HydratedObject'),
114          );
115   
116          if (PHP_VERSION_ID >= 50401) {
117              // PHP < 5.4.1 misbehaves, throwing strict standards, see https://bugs.php.net/bug.php?id=60573
118              $data[] = array('ProxyManagerTestAsset\\ClassWithSelfHint');
119          }
120   
121          return $data;
122      }
123  }
124