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

ConstructorTest.php

Zuletzt modifiziert: 09.10.2024, 12:59 - Dateigröße: 7.43 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\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator;
020   
021  use PHPUnit_Framework_TestCase;
022  use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Constructor;
023  use ReflectionClass;
024   
025  /**
026   * Tests for {@see \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Constructor}
027   *
028   * @author Marco Pivetta <ocramius@gmail.com>
029   * @license MIT
030   *
031   * @group Coverage
032   */
033  class ConstructorTest extends PHPUnit_Framework_TestCase
034  {
035      private $prefixInterceptors;
036      private $suffixInterceptors;
037      public function setUp()
038      {
039          $this->prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator');
040          $this->suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator');
041   
042          $this->prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre'));
043          $this->suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post'));
044      }
045   
046      /**
047       * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Constructor::__construct
048       */
049      public function testSignature()
050      {
051          $constructor = new Constructor(
052              new ReflectionClass('ProxyManagerTestAsset\\ClassWithProtectedProperties'),
053              $this->prefixInterceptors,
054              $this->suffixInterceptors
055          );
056          $this->assertSame('__construct', $constructor->getName());
057   
058          $parameters = $constructor->getParameters();
059   
060          $this->assertCount(3, $parameters);
061   
062          $this->assertSame(
063              'ProxyManagerTestAsset\\ClassWithProtectedProperties',
064              $parameters['localizedObject']->getType()
065          );
066          $this->assertSame('array', $parameters['prefixInterceptors']->getType());
067          $this->assertSame('array', $parameters['suffixInterceptors']->getType());
068      }
069   
070      /**
071       * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Constructor::__construct
072       */
073      public function testBodyStructure()
074      {
075          $constructor = new Constructor(
076              new ReflectionClass('ProxyManagerTestAsset\\ClassWithPublicProperties'),
077              $this->prefixInterceptors,
078              $this->suffixInterceptors
079          );
080   
081          $this->assertSame(
082              '$this->property0 = & $localizedObject->property0;
083   
084  $this->property1 = & $localizedObject->property1;
085   
086  $this->property2 = & $localizedObject->property2;
087   
088  $this->property3 = & $localizedObject->property3;
089   
090  $this->property4 = & $localizedObject->property4;
091   
092  $this->property5 = & $localizedObject->property5;
093   
094  $this->property6 = & $localizedObject->property6;
095   
096  $this->property7 = & $localizedObject->property7;
097   
098  $this->property8 = & $localizedObject->property8;
099   
100  $this->property9 = & $localizedObject->property9;
101   
102  $this->pre = $prefixInterceptors;
103  $this->post = $suffixInterceptors;',
104              $constructor->getBody()
105          );
106      }
107   
108      /**
109       * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Constructor::__construct
110       */
111      public function testBodyStructureWithProtectedProperties()
112      {
113          $constructor = new Constructor(
114              new ReflectionClass('ProxyManagerTestAsset\\ClassWithProtectedProperties'),
115              $this->prefixInterceptors,
116              $this->suffixInterceptors
117          );
118   
119          $this->assertSame(
120              '$this->property0 = & $localizedObject->property0;
121   
122  $this->property1 = & $localizedObject->property1;
123   
124  $this->property2 = & $localizedObject->property2;
125   
126  $this->property3 = & $localizedObject->property3;
127   
128  $this->property4 = & $localizedObject->property4;
129   
130  $this->property5 = & $localizedObject->property5;
131   
132  $this->property6 = & $localizedObject->property6;
133   
134  $this->property7 = & $localizedObject->property7;
135   
136  $this->property8 = & $localizedObject->property8;
137   
138  $this->property9 = & $localizedObject->property9;
139   
140  $this->pre = $prefixInterceptors;
141  $this->post = $suffixInterceptors;',
142              $constructor->getBody()
143          );
144      }
145   
146      /**
147       * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Constructor::__construct
148       */
149      public function testBodyStructureWithPrivateProperties()
150      {
151          if (! method_exists('Closure', 'bind')) {
152              $this->setExpectedException('ProxyManager\Exception\UnsupportedProxiedClassException');
153          }
154   
155          $constructor = new Constructor(
156              new ReflectionClass('ProxyManagerTestAsset\\ClassWithPrivateProperties'),
157              $this->prefixInterceptors,
158              $this->suffixInterceptors
159          );
160   
161          $this->assertSame(
162              '\Closure::bind(function () use ($localizedObject) {
163      $this->property0 = & $localizedObject->property0;
164  }, $this, \'ProxyManagerTestAsset\\\\ClassWithPrivateProperties\')->__invoke();
165   
166  \Closure::bind(function () use ($localizedObject) {
167      $this->property1 = & $localizedObject->property1;
168  }, $this, \'ProxyManagerTestAsset\\\\ClassWithPrivateProperties\')->__invoke();
169   
170  \Closure::bind(function () use ($localizedObject) {
171      $this->property2 = & $localizedObject->property2;
172  }, $this, \'ProxyManagerTestAsset\\\\ClassWithPrivateProperties\')->__invoke();
173   
174  \Closure::bind(function () use ($localizedObject) {
175      $this->property3 = & $localizedObject->property3;
176  }, $this, \'ProxyManagerTestAsset\\\\ClassWithPrivateProperties\')->__invoke();
177   
178  \Closure::bind(function () use ($localizedObject) {
179      $this->property4 = & $localizedObject->property4;
180  }, $this, \'ProxyManagerTestAsset\\\\ClassWithPrivateProperties\')->__invoke();
181   
182  \Closure::bind(function () use ($localizedObject) {
183      $this->property5 = & $localizedObject->property5;
184  }, $this, \'ProxyManagerTestAsset\\\\ClassWithPrivateProperties\')->__invoke();
185   
186  \Closure::bind(function () use ($localizedObject) {
187      $this->property6 = & $localizedObject->property6;
188  }, $this, \'ProxyManagerTestAsset\\\\ClassWithPrivateProperties\')->__invoke();
189   
190  \Closure::bind(function () use ($localizedObject) {
191      $this->property7 = & $localizedObject->property7;
192  }, $this, \'ProxyManagerTestAsset\\\\ClassWithPrivateProperties\')->__invoke();
193   
194  \Closure::bind(function () use ($localizedObject) {
195      $this->property8 = & $localizedObject->property8;
196  }, $this, \'ProxyManagerTestAsset\\\\ClassWithPrivateProperties\')->__invoke();
197   
198  \Closure::bind(function () use ($localizedObject) {
199      $this->property9 = & $localizedObject->property9;
200  }, $this, \'ProxyManagerTestAsset\\\\ClassWithPrivateProperties\')->__invoke();
201   
202  $this->pre = $prefixInterceptors;
203  $this->post = $suffixInterceptors;',
204              $constructor->getBody()
205          );
206      }
207  }
208