Passed
Push — master ( 32c6c0...17128d )
by Simon
05:46
created

CastsToStringTest::setUpBeforeClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
declare(strict_types=1);
3
/**
4
 * This file is part of the Enum package.
5
 * For the full copyright information please view the LICENCE file that was
6
 * distributed with this package.
7
 *
8
 * @copyright Simon Deeley 2017
9
 */
10
11
use ReflectionClass;
12
use PHPUnit\Framework\TestCase;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use StandardLibrary\Contracts\CastsToString;
14
15
/**
16
 * Unit tests for CastsToString
17
 *
18
 * @author Simon Deeley <[email protected]>
19
 * @final
20
 */
21
final class CastsToStringTest extends TestCase
22
{
23
    /**
24
     * @static
25
     * @var ReflectionClass
26
     */
27
    protected static $interface;
28
29
    /**
30
     * Set up ReflectionClass instance
31
     *
32
     * @static
33
     * @return void
34
     */
35
    final public static function setUpBeforeClass(): void
36
    {
37
        self::$interface = new ReflectionClass(CastsToString::class);
38
    }
39
40
    /**
41
     * CastsToString should be an interface
42
     *
43
     * @test
44
     * @final
45
     * @return void
46
     */
47
    final public function shouldBeInterface(): void
48
    {
49
        $this->assertTrue(self::$interface->isInterface());
50
    }
51
52
    /**
53
     * Interface should have one method named '__toString'
54
     *
55
     * @test
56
     * @final
57
     * @return void
58
     */
59
    final public function interfaceShouldHaveOneMethod(): void
60
    {
61
        $this->assertTrue(self::$interface->hasMethod('__toString'));
62
        $this->assertCount(1, self::$interface->getMethods());
63
    }
64
65
    /**
66
     * Describe method signatue of '__toString'
67
     *
68
     * @test
69
     * @final
70
     * @return void
71
     */
72
    final public function describeMethodSignatureOfToString(): void
73
    {
74
        $method = self::$interface->getMethod('__toString');
75
76
        $this->assertEquals(0, $method->getNumberOfParameters());
77
        $this->assertTrue((string) $method->getReturnType() === 'string');
78
    }
79
}