|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace ProxyManagerTest\GeneratorStrategy; |
|
6
|
|
|
|
|
7
|
|
|
use PHPUnit\Framework\TestCase; |
|
8
|
|
|
use ProxyManager\Generator\ClassGenerator; |
|
9
|
|
|
use ProxyManager\Generator\Util\UniqueIdentifierGenerator; |
|
10
|
|
|
use ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy; |
|
11
|
|
|
use function class_exists; |
|
12
|
|
|
use function ini_get; |
|
13
|
|
|
use function strpos; |
|
14
|
|
|
use function uniqid; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Tests for {@see \ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy} |
|
18
|
|
|
* |
|
19
|
|
|
* @group Coverage |
|
20
|
|
|
*/ |
|
21
|
|
|
final class EvaluatingGeneratorStrategyTest extends TestCase |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* @covers \ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy::generate |
|
25
|
|
|
* @covers \ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy::__construct |
|
26
|
|
|
*/ |
|
27
|
|
|
public function testGenerate() : void |
|
28
|
|
|
{ |
|
29
|
|
|
$strategy = new EvaluatingGeneratorStrategy(); |
|
30
|
|
|
$className = UniqueIdentifierGenerator::getIdentifier('Foo'); |
|
31
|
|
|
$classGenerator = new ClassGenerator($className); |
|
32
|
|
|
$generated = $strategy->generate($classGenerator); |
|
33
|
|
|
|
|
34
|
|
|
self::assertGreaterThan(0, strpos($generated, $className)); |
|
|
|
|
|
|
35
|
|
|
self::assertTrue(class_exists($className, false)); |
|
|
|
|
|
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @covers \ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy::generate |
|
40
|
|
|
* @covers \ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy::__construct |
|
41
|
|
|
*/ |
|
42
|
|
|
public function testGenerateWithDisabledEval() : void |
|
43
|
|
|
{ |
|
44
|
|
|
if (! ini_get('suhosin.executor.disable_eval')) { |
|
45
|
|
|
self::markTestSkipped('Ini setting "suhosin.executor.disable_eval" is needed to run this test'); |
|
|
|
|
|
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
$strategy = new EvaluatingGeneratorStrategy(); |
|
49
|
|
|
$className = 'Foo' . uniqid(); |
|
50
|
|
|
$classGenerator = new ClassGenerator($className); |
|
51
|
|
|
$generated = $strategy->generate($classGenerator); |
|
52
|
|
|
|
|
53
|
|
|
self::assertGreaterThan(0, strpos($generated, $className)); |
|
|
|
|
|
|
54
|
|
|
self::assertTrue(class_exists($className, false)); |
|
|
|
|
|
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.