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

MagicGetTest.php

Zuletzt modifiziert: 09.10.2024, 12:59 - Dateigröße: 4.99 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\LazyLoadingGhost\MethodGenerator;
020   
021  use ReflectionClass;
022  use PHPUnit_Framework_TestCase;
023  use ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicGet;
024   
025  /**
026   * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicGet}
027   *
028   * @author Marco Pivetta <ocramius@gmail.com>
029   * @license MIT
030   *
031   * @group Coverage
032   */
033  class MagicGetTest extends PHPUnit_Framework_TestCase
034  {
035      /**
036       * @var \Zend\Code\Generator\PropertyGenerator|\PHPUnit_Framework_MockObject_MockObject
037       */
038      protected $initializer;
039   
040      /**
041       * @var \Zend\Code\Generator\MethodGenerator|\PHPUnit_Framework_MockObject_MockObject
042       */
043      protected $initMethod;
044   
045      /**
046       * @var \ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap|\PHPUnit_Framework_MockObject_MockObject
047       */
048      protected $publicProperties;
049   
050      /**
051       * {@inheritDoc}
052       */
053      protected function setUp()
054      {
055          $this->initializer      = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator');
056          $this->initMethod       = $this->getMock('Zend\\Code\\Generator\\MethodGenerator');
057          $this->publicProperties = $this
058              ->getMockBuilder('ProxyManager\\ProxyGenerator\\PropertyGenerator\\PublicPropertiesMap')
059              ->disableOriginalConstructor()
060              ->getMock();
061   
062          $this->initializer->expects($this->any())->method('getName')->will($this->returnValue('foo'));
063          $this->initMethod->expects($this->any())->method('getName')->will($this->returnValue('baz'));
064          $this->publicProperties->expects($this->any())->method('isEmpty')->will($this->returnValue(false));
065          $this->publicProperties->expects($this->any())->method('getName')->will($this->returnValue('bar'));
066      }
067   
068      /**
069       * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicGet::__construct
070       */
071      public function testBodyStructure()
072      {
073          $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass');
074          $magicGet   = new MagicGet($reflection, $this->initializer, $this->initMethod, $this->publicProperties);
075   
076          $this->assertSame('__get', $magicGet->getName());
077          $this->assertCount(1, $magicGet->getParameters());
078          $this->assertStringMatchesFormat(
079              "\$this->foo && \$this->baz('__get', array('name' => \$name));\n\n"
080              . "if (isset(self::\$bar[\$name])) {\n    return \$this->\$name;\n}\n\n"
081              . "%a",
082              $magicGet->getBody()
083          );
084      }
085   
086      /**
087       * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicGet::__construct
088       */
089      public function testBodyStructureWithPublicProperties()
090      {
091          $reflection = new ReflectionClass(
092              'ProxyManagerTestAsset\\ProxyGenerator\\LazyLoading\\MethodGenerator\\ClassWithTwoPublicProperties'
093          );
094   
095          $magicGet = new MagicGet($reflection, $this->initializer, $this->initMethod, $this->publicProperties);
096   
097          $this->assertSame('__get', $magicGet->getName());
098          $this->assertCount(1, $magicGet->getParameters());
099          $this->assertStringMatchesFormat(
100              "\$this->foo && \$this->baz('__get', array('name' => \$name));\n\n"
101              . "if (isset(self::\$bar[\$name])) {\n    return \$this->\$name;\n}\n\n"
102              . "%a",
103              $magicGet->getBody()
104          );
105      }
106   
107      /**
108       * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicGet::__construct
109       */
110      public function testBodyStructureWithOverriddenMagicGet()
111      {
112          $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithMagicMethods');
113          $magicGet   = new MagicGet($reflection, $this->initializer, $this->initMethod, $this->publicProperties);
114   
115          $this->assertSame('__get', $magicGet->getName());
116          $this->assertCount(1, $magicGet->getParameters());
117          $this->assertSame(
118              "\$this->foo && \$this->baz('__get', array('name' => \$name));\n\n"
119              . "if (isset(self::\$bar[\$name])) {\n    return \$this->\$name;\n}\n\n"
120              . "return parent::__get(\$name);",
121              $magicGet->getBody()
122          );
123      }
124  }
125