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

PublicScopeSimulatorTest.php

Zuletzt modifiziert: 09.10.2024, 12:59 - Dateigröße: 4.04 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\Util;
020   
021  use PHPUnit_Framework_TestCase;
022  use ProxyManager\ProxyGenerator\Util\PublicScopeSimulator;
023  use Zend\Code\Generator\PropertyGenerator;
024   
025  /**
026   * Tests for {@see \ProxyManager\ProxyGenerator\Util\PublicScopeSimulator}
027   *
028   * @author Marco Pivetta <ocramius@gmail.com>
029   * @license MIT
030   *
031   * @covers \ProxyManager\ProxyGenerator\Util\PublicScopeSimulator
032   * @group Coverage
033   */
034  class PublicScopeSimulatorTest extends PHPUnit_Framework_TestCase
035  {
036      public function testSimpleGet()
037      {
038          $code = PublicScopeSimulator::getPublicAccessSimulationCode(
039              PublicScopeSimulator::OPERATION_GET,
040              'foo',
041              null,
042              null,
043              'bar'
044          );
045   
046          $this->assertStringMatchesFormat('%a{%areturn $%s->$foo;%a}%a$bar = %s;', $code);
047      }
048   
049      public function testSimpleSet()
050      {
051          $code = PublicScopeSimulator::getPublicAccessSimulationCode(
052              PublicScopeSimulator::OPERATION_SET,
053              'foo',
054              'baz',
055              null,
056              'bar'
057          );
058   
059          $this->assertStringMatchesFormat('%a{%areturn $%s->$foo = $baz;%a}%a$bar = %s;', $code);
060      }
061   
062      public function testSimpleIsset()
063      {
064          $code = PublicScopeSimulator::getPublicAccessSimulationCode(
065              PublicScopeSimulator::OPERATION_ISSET,
066              'foo',
067              null,
068              null,
069              'bar'
070          );
071   
072          $this->assertStringMatchesFormat('%a{%areturn isset($%s->$foo);%a}%a$bar = %s;', $code);
073      }
074   
075      public function testSimpleUnset()
076      {
077          $code = PublicScopeSimulator::getPublicAccessSimulationCode(
078              PublicScopeSimulator::OPERATION_UNSET,
079              'foo',
080              null,
081              null,
082              'bar'
083          );
084   
085          $this->assertStringMatchesFormat('%a{%aunset($%s->$foo);%a}%a$bar = %s;', $code);
086      }
087   
088      public function testSetRequiresValueParameterName()
089      {
090          $this->setExpectedException('InvalidArgumentException');
091   
092          PublicScopeSimulator::getPublicAccessSimulationCode(
093              PublicScopeSimulator::OPERATION_SET,
094              'foo',
095              null,
096              null,
097              'bar'
098          );
099      }
100   
101      public function testDelegatesToValueHolderWhenAvailable()
102      {
103          $code = PublicScopeSimulator::getPublicAccessSimulationCode(
104              PublicScopeSimulator::OPERATION_SET,
105              'foo',
106              'baz',
107              new PropertyGenerator('valueHolder'),
108              'bar'
109          );
110   
111          $this->assertStringMatchesFormat(
112              '%A$targetObject = $this->valueHolder;%a{%areturn $%s->$foo = $baz;%a}%a$bar = %s;',
113              $code
114          );
115      }
116   
117      public function testSetRequiresValidOperation()
118      {
119          $this->setExpectedException('InvalidArgumentException');
120   
121          PublicScopeSimulator::getPublicAccessSimulationCode('invalid', 'foo');
122      }
123   
124      public function testWillReturnDirectlyWithNoReturnParam()
125      {
126          $code = PublicScopeSimulator::getPublicAccessSimulationCode(
127              PublicScopeSimulator::OPERATION_GET,
128              'foo'
129          );
130   
131          $this->assertStringMatchesFormat('%a{%areturn $%s->$foo;%a}%areturn %s;', $code);
132      }
133  }
134