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 |
InterceptorGeneratorTest.php
01 <?php
02 /*
03 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
04 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
05 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
06 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
07 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
08 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
09 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14 *
15 * This software consists of voluntary contributions made by many individuals
16 * and is licensed under the MIT license.
17 */
18
19 namespace ProxyManagerTest\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Util;
20
21 use PHPUnit_Framework_TestCase;
22 use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Util\InterceptorGenerator;
23
24 /**
25 * Tests for {@see \ProxyManager\ProxyGenerator\AccessInterceptorValueHolderGenerator}
26 *
27 * @author Marco Pivetta <ocramius@gmail.com>
28 * @license MIT
29 *
30 * @group Coverage
31 */
32 class InterceptorGeneratorTest extends PHPUnit_Framework_TestCase
33 {
34 /**
35 * @covers \ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Util\InterceptorGenerator
36 */
37 public function testInterceptorGenerator()
38 {
39 $method = $this->getMock('ProxyManager\\Generator\\MethodGenerator');
40 $bar = $this->getMock('ProxyManager\\Generator\\ParameterGenerator');
41 $baz = $this->getMock('ProxyManager\\Generator\\ParameterGenerator');
42 $prefixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator');
43 $suffixInterceptors = $this->getMock('Zend\\Code\\Generator\\PropertyGenerator');
44
45 $bar->expects($this->any())->method('getName')->will($this->returnValue('bar'));
46 $baz->expects($this->any())->method('getName')->will($this->returnValue('baz'));
47 $method->expects($this->any())->method('getName')->will($this->returnValue('fooMethod'));
48 $method->expects($this->any())->method('getParameters')->will($this->returnValue(array($bar, $baz)));
49 $prefixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('pre'));
50 $suffixInterceptors->expects($this->any())->method('getName')->will($this->returnValue('post'));
51
52 $body = InterceptorGenerator::createInterceptedMethodBody(
53 '$returnValue = "foo";',
54 $method,
55 $prefixInterceptors,
56 $suffixInterceptors
57 );
58
59 $this->assertSame(
60 'if (isset($this->pre[\'fooMethod\'])) {' . "\n"
61 . ' $returnEarly = false;' . "\n"
62 . ' $prefixReturnValue = $this->pre[\'fooMethod\']->__invoke($this, $this, \'fooMethod\', '
63 . 'array(\'bar\' => $bar, \'baz\' => $baz), $returnEarly);' . "\n\n"
64 . ' if ($returnEarly) {' . "\n"
65 . ' return $prefixReturnValue;' . "\n"
66 . ' }' . "\n"
67 . '}' . "\n\n"
68 . '$returnValue = "foo";' . "\n\n"
69 . 'if (isset($this->post[\'fooMethod\'])) {' . "\n"
70 . ' $returnEarly = false;' . "\n"
71 . ' $suffixReturnValue = $this->post[\'fooMethod\']->__invoke($this, $this, \'fooMethod\', '
72 . 'array(\'bar\' => $bar, \'baz\' => $baz), $returnValue, $returnEarly);' . "\n\n"
73 . ' if ($returnEarly) {' . "\n"
74 . ' return $suffixReturnValue;' . "\n"
75 . ' }' . "\n"
76 . '}' . "\n\n"
77 . 'return $returnValue;',
78 $body
79 );
80 }
81 }
82