Completed
Push — master ( f74359...e7cb9d )
by Marco
37:27 queued 12:15
created

FileNotWritableExceptionTest::testFromPrevious()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProxyManagerTest\Exception;
6
7
use PHPUnit\Framework\TestCase;
8
use ProxyManager\Exception\FileNotWritableException;
9
use Webimpress\SafeWriter\Exception\ExceptionInterface as FileWriterException;
10
11
/**
12
 * Tests for {@see \ProxyManager\Exception\FileNotWritableException}
13
 *
14
 * @covers \ProxyManager\Exception\FileNotWritableException
15
 * @group Coverage
16
 */
17
final class FileNotWritableExceptionTest extends TestCase
18
{
19
    public function testFromPrevious() : void
20
    {
21
        $previousExceptionMock = $this->getMockBuilder(FileWriterException::class);
22
        $previousExceptionMock->enableOriginalConstructor();
23
        $previousExceptionMock->setConstructorArgs(['Previous exception message']);
24
        $previousException = $previousExceptionMock->getMock();
25
26
        $exception = FileNotWritableException::fromPrevious($previousException);
0 ignored issues
show
Documentation introduced by
$previousException is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Webimpress\SafeWr...ion\ExceptionInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
27
28
        self::assertSame('Previous exception message', $exception->getMessage());
29
        self::assertSame($previousException, $exception->getPrevious());
30
    }
31
}
32