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