Completed
Pull Request — master (#6)
by Chuck
02:31
created

AndSpecificationTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 3
dl 0
loc 50
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
A tearDown() 0 4 1
A testIfSpecificationIsSatisfied() 0 7 1
A testIfSpecificationIsNotSatisfied() 0 7 1
1
<?php
2
/**
3
 * This file is part of phpDocumentor.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @copyright 2010-2015 Mike van Riel<[email protected]>
9
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
10
 * @link      http://phpdoc.org
11
 */
12
13
namespace Flyfinder\Specification;
14
15
use PHPUnit\Framework\TestCase;
16
use Mockery as m;
17
use Flyfinder\Specification\HasExtension;
18
use Flyfinder\Specification\IsHidden;
19
20
/**
21
 * Test case for AndSpecification
22
 * @coversDefaultClass Flyfinder\Specification\AndSpecification
23
 */
24
class AndSpecificationTest extends TestCase
25
{
26
    /** @var HasExtension */
27
    private $hasExtension;
28
29
    /** @var IsHidden */
30
    private $isHidden;
31
32
    /** @var AndSpecification */
33
    private $fixture;
34
35
    /**
36
     * Initializes the fixture for this test.
37
     */
38
    public function setUp()
39
    {
40
        $this->hasExtension = m::mock('Flyfinder\Specification\HasExtension');
41
        $this->isHidden = m::mock('Flyfinder\Specification\IsHidden');
42
        $this->fixture = new AndSpecification($this->hasExtension, $this->isHidden);
43
    }
44
45
    public function tearDown()
46
    {
47
        m::close();
48
    }
49
50
    /**
51
     * @covers ::__construct
52
     * @covers ::isSatisfiedBy
53
     */
54
    public function testIfSpecificationIsSatisfied()
55
    {
56
        $this->hasExtension->shouldReceive('isSatisfiedBy')->once()->andReturn(true);
0 ignored issues
show
Bug introduced by
The method shouldReceive() does not seem to exist on object<Flyfinder\Specification\HasExtension>.

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...
57
        $this->isHidden->shouldReceive('isSatisfiedBy')->once()->andReturn(true);
0 ignored issues
show
Bug introduced by
The method shouldReceive() does not seem to exist on object<Flyfinder\Specification\IsHidden>.

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...
58
59
        $this->assertTrue($this->fixture->isSatisfiedBy(['test']));
60
    }
61
62
    /**
63
     * @covers ::__construct
64
     * @covers ::isSatisfiedBy
65
     */
66
    public function testIfSpecificationIsNotSatisfied()
67
    {
68
        $this->hasExtension->shouldReceive('isSatisfiedBy')->once()->andReturn(true);
0 ignored issues
show
Bug introduced by
The method shouldReceive() does not seem to exist on object<Flyfinder\Specification\HasExtension>.

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...
69
        $this->isHidden->shouldReceive('isSatisfiedBy')->once()->andReturn(false);
0 ignored issues
show
Bug introduced by
The method shouldReceive() does not seem to exist on object<Flyfinder\Specification\IsHidden>.

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...
70
71
        $this->assertFalse($this->fixture->isSatisfiedBy(['test']));
72
    }
73
}
74