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

MagicIssetTest.php

Zuletzt modifiziert: 09.10.2024, 12:59 - Dateigröße: 5.08 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\MagicIsset;
024   
025  /**
026   * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicIsset}
027   *
028   * @author Marco Pivetta <ocramius@gmail.com>
029   * @license MIT
030   *
031   * @group Coverage
032   */
033  class MagicIssetTest 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\MagicIsset::__construct
070       */
071      public function testBodyStructure()
072      {
073          $reflection = new ReflectionClass('ProxyManagerTestAsset\\EmptyClass');
074          $magicIsset = new MagicIsset($reflection, $this->initializer, $this->initMethod, $this->publicProperties);
075   
076          $this->assertSame('__isset', $magicIsset->getName());
077          $this->assertCount(1, $magicIsset->getParameters());
078          $this->assertStringMatchesFormat(
079              "\$this->foo && \$this->baz('__isset', array('name' => \$name));\n\n"
080              . "if (isset(self::\$bar[\$name])) {\n    return isset(\$this->\$name);\n}\n\n"
081              . "%areturn %s;",
082              $magicIsset->getBody()
083          );
084      }
085   
086      /**
087       * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicIsset::__construct
088       */
089      public function testBodyStructureWithPublicProperties()
090      {
091          $reflection = new ReflectionClass(
092              'ProxyManagerTestAsset\\ProxyGenerator\\LazyLoading\\MethodGenerator\\ClassWithTwoPublicProperties'
093          );
094          $magicIsset = new MagicIsset($reflection, $this->initializer, $this->initMethod, $this->publicProperties);
095   
096          $this->assertSame('__isset', $magicIsset->getName());
097          $this->assertCount(1, $magicIsset->getParameters());
098          $this->assertStringMatchesFormat(
099              "\$this->foo && \$this->baz('__isset', array('name' => \$name));\n\n"
100              . "if (isset(self::\$bar[\$name])) {\n    return isset(\$this->\$name);\n}\n\n"
101              . "%areturn %s;",
102              $magicIsset->getBody()
103          );
104      }
105   
106      /**
107       * @covers \ProxyManager\ProxyGenerator\LazyLoadingGhost\MethodGenerator\MagicIsset::__construct
108       */
109      public function testBodyStructureWithOverriddenMagicGet()
110      {
111          $reflection = new ReflectionClass('ProxyManagerTestAsset\\ClassWithMagicMethods');
112          $magicIsset = new MagicIsset($reflection, $this->initializer, $this->initMethod, $this->publicProperties);
113   
114          $this->assertSame('__isset', $magicIsset->getName());
115          $this->assertCount(1, $magicIsset->getParameters());
116          $this->assertSame(
117              "\$this->foo && \$this->baz('__isset', array('name' => \$name));\n\n"
118              . "if (isset(self::\$bar[\$name])) {\n    return isset(\$this->\$name);\n}\n\n"
119              . "return parent::__isset(\$name);",
120              $magicIsset->getBody()
121          );
122      }
123  }
124