-
-
Notifications
You must be signed in to change notification settings - Fork 122
Expand file tree
/
Copy pathControllerHelperTest.php
More file actions
64 lines (55 loc) · 2.29 KB
/
Copy pathControllerHelperTest.php
File metadata and controls
64 lines (55 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\FrameworkBundle\Tests\Controller;
use Psr\Container\ContainerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Bundle\FrameworkBundle\Controller\ControllerHelper;
class ControllerHelperTest extends AbstractControllerTest
{
protected function createController()
{
return new class extends ControllerHelper {
public function __construct()
{
}
public function setContainer(ContainerInterface $container)
{
parent::__construct($container);
}
};
}
public function testSync()
{
$r = new \ReflectionClass(ControllerHelper::class);
$m = $r->getMethod('getSubscribedServices');
$helperSrc = file($r->getFileName());
$helperSrc = implode('', \array_slice($helperSrc, $m->getStartLine() - 1, $r->getEndLine() - $m->getStartLine()));
$r = new \ReflectionClass(AbstractController::class);
$m = $r->getMethod('getSubscribedServices');
$abstractSrc = file($r->getFileName());
$code = [
implode('', \array_slice($abstractSrc, $m->getStartLine() - 1, $m->getEndLine() - $m->getStartLine() + 1)),
];
foreach ($r->getMethods(\ReflectionMethod::IS_PROTECTED) as $m) {
if ($m->getDocComment()) {
$code[] = ' '.$m->getDocComment();
}
$code[] = substr_replace(implode('', \array_slice($abstractSrc, $m->getStartLine() - 1, $m->getEndLine() - $m->getStartLine() + 1)), 'public', 4, 9);
}
foreach ($r->getMethods(\ReflectionMethod::IS_PRIVATE) as $m) {
if ($m->getDocComment()) {
$code[] = ' '.$m->getDocComment();
}
$code[] = implode('', \array_slice($abstractSrc, $m->getStartLine() - 1, $m->getEndLine() - $m->getStartLine() + 1));
}
$code = implode("\n", $code);
$this->assertSame($code, $helperSrc, 'Methods from AbstractController are not properly synced in ControllerHelper');
}
}