EvaluatingGeneratorStrategyTest::testGenerate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
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));
0 ignored issues
show
Bug introduced by
The method assertGreaterThan() does not seem to exist on object<ProxyManagerTest\...gGeneratorStrategyTest>.

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.

Loading history...
35
        self::assertTrue(class_exists($className, false));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ProxyManagerTest\...gGeneratorStrategyTest>.

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.

Loading history...
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');
0 ignored issues
show
Bug introduced by
The method markTestSkipped() does not seem to exist on object<ProxyManagerTest\...gGeneratorStrategyTest>.

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.

Loading history...
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));
0 ignored issues
show
Bug introduced by
The method assertGreaterThan() does not seem to exist on object<ProxyManagerTest\...gGeneratorStrategyTest>.

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.

Loading history...
54
        self::assertTrue(class_exists($className, false));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<ProxyManagerTest\...gGeneratorStrategyTest>.

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.

Loading history...
55
    }
56
}
57