Completed
Push — master ( 6a6c80...a2c1e8 )
by Marco
79:00 queued 52:38
created

Signature/ClassSignatureGeneratorTest.php (2 issues)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProxyManagerTest\Signature;
6
7
use PHPUnit\Framework\MockObject\MockObject;
8
use PHPUnit\Framework\TestCase;
9
use ProxyManager\Signature\ClassSignatureGenerator;
10
use ProxyManager\Signature\SignatureGeneratorInterface;
11
use Zend\Code\Generator\ClassGenerator;
12
use Zend\Code\Generator\PropertyGenerator;
13
14
/**
15
 * Tests for {@see \ProxyManager\Signature\ClassSignatureGenerator}
16
 *
17
 * @covers \ProxyManager\Signature\ClassSignatureGenerator
18
 * @group Coverage
19
 */
20
class ClassSignatureGeneratorTest extends TestCase
21
{
22
    /** @var SignatureGeneratorInterface|MockObject */
23
    private $signatureGenerator;
24
25
    /** @var ClassSignatureGenerator */
26
    private $classSignatureGenerator;
27
28
    /**
29
     * {@inheritDoc}
30
     */
31
    protected function setUp() : void
32
    {
33
        $this->signatureGenerator      = $this->createMock(SignatureGeneratorInterface::class);
34
        $this->classSignatureGenerator = new ClassSignatureGenerator($this->signatureGenerator);
35
    }
36
37
    public function testAddSignature() : void
38
    {
39
        /** @var MockObject|ClassGenerator $classGenerator */
40
        $classGenerator = $this->createMock(ClassGenerator::class);
41
42
        $classGenerator
43
            ->expects(self::once())
44
            ->method('addPropertyFromGenerator')
45
            ->with(self::callback(static function (PropertyGenerator $property) : bool {
46
                return $property->getName() === 'signaturePropertyName'
47
                    && $property->isStatic()
48
                    && $property->getVisibility() === 'private'
49
                    && $property->getDefaultValue()->getValue() === 'valid-signature';
50
            }));
51
52
        $this
0 ignored issues
show
The method expects() does not seem to exist on object<ProxyManager\Sign...tureGeneratorInterface>.

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...
53
            ->signatureGenerator
54
            ->expects(self::any())
55
            ->method('generateSignature')
56
            ->with(['foo' => 'bar'])
57
            ->will(self::returnValue('valid-signature'));
58
59
        $this
0 ignored issues
show
The method expects() does not seem to exist on object<ProxyManager\Sign...tureGeneratorInterface>.

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...
60
            ->signatureGenerator
61
            ->expects(self::any())
62
            ->method('generateSignatureKey')
63
            ->with(['foo' => 'bar'])
64
            ->will(self::returnValue('PropertyName'));
65
66
        $this->classSignatureGenerator->addSignature($classGenerator, ['foo' => 'bar']);
67
    }
68
}
69