GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( c317f4...56a5d3 )
by Christian
05:39
created

DompdfWrapperTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 7
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
/*
4
 * (c) Christian Gripp <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Core23\DompdfBundle\Tests\Wrapper;
11
12
use Core23\DompdfBundle\Factory\DompdfFactory;
13
use Core23\DompdfBundle\Factory\DompdfFactoryInterface;
14
use Core23\DompdfBundle\Wrapper\DompdfWrapper;
15
use Dompdf\Dompdf;
16
use PHPUnit\Framework\TestCase;
17
18
class DompdfWrapperTest extends TestCase
19
{
20
    /**
21
     * @var \PHPUnit_Framework_MockObject_MockObject|DompdfFactory
22
     */
23
    private $dompdfFactory;
24
25
    /**
26
     * @var DompdfWrapper
27
     */
28
    private $dompdfWrapper;
29
30
    /**
31
     * @var \PHPUnit_Framework_MockObject_MockObject|Dompdf
32
     */
33
    private $dompdf;
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    protected function setUp()
39
    {
40
        $this->dompdf        = $this->createMock(Dompdf::class);
41
        $this->dompdfFactory = $this->createMock(DompdfFactoryInterface::class);
42
43
        $this->dompdfWrapper = new DompdfWrapper($this->dompdfFactory);
44
    }
45
46 View Code Duplication
    public function testStreamHtml()
47
    {
48
        $input = "<h1>Foo</h1>Bar <b>baz</b><img src='img/foo'>";
49
50
        $this->dompdfFactory->expects($this->any())
1 ignored issue
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Core23\DompdfBundle\Factory\DompdfFactory.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
51
            ->method('create')
52
            ->will($this->returnValue($this->dompdf));
53
54
        $this->dompdf->expects($this->once())
55
            ->method('loadHtml')
56
            ->with($this->equalTo($input));
57
        $this->dompdf->expects($this->once())
58
            ->method('render');
59
        $this->dompdf->expects($this->once())
60
            ->method('stream')
61
            ->with($this->equalTo('file.pdf'));
62
63
        $this->dompdfWrapper->streamHtml($input, 'file.pdf');
64
    }
65
66
    public function testStreamHtmlWithImg()
67
    {
68
        $input  = "<h1>Foo</h1>Bar <b>baz</b><img src='img/foo'>";
69
        $output = "<h1>Foo</h1>Bar <b>baz</b><img src='img/foo'>";
70
71
        $this->dompdfFactory->expects($this->any())
1 ignored issue
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Core23\DompdfBundle\Factory\DompdfFactory.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
72
            ->method('create')
73
            ->with($this->equalTo(array('tempDir' => 'bar')))
74
            ->will($this->returnValue($this->dompdf));
75
76
        $this->dompdf->expects($this->once())
77
            ->method('loadHtml')
78
            ->with($this->equalTo($output));
79
        $this->dompdf->expects($this->once())
80
            ->method('render');
81
        $this->dompdf->expects($this->once())
82
            ->method('stream')
83
            ->with($this->equalTo('file.pdf'));
84
85
        $this->dompdfWrapper->streamHtml($input, 'file.pdf', array('tempDir' => 'bar'));
86
    }
87
88 View Code Duplication
    public function testGetPdf()
89
    {
90
        $input = "<h1>Foo</h1>Bar <b>baz</b><img src='img/foo'>";
91
92
        $this->dompdfFactory->expects($this->any())
1 ignored issue
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Core23\DompdfBundle\Factory\DompdfFactory.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
93
            ->method('create')
94
            ->will($this->returnValue($this->dompdf));
95
96
        $this->dompdf->expects($this->once())
97
            ->method('loadHtml')
98
            ->with($this->equalTo($input));
99
        $this->dompdf->expects($this->once())
100
            ->method('render');
101
        $this->dompdf->expects($this->once())
102
            ->method('output')
103
            ->willReturn('BINARY_CONTENT');
104
105
        $this->dompdfWrapper->getPdf($input, array('tempDir' => 'bar'));
106
    }
107
}
108