FileNotWritableExceptionTest::testFromPrevious()   A
last analyzed

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);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $previousExceptionMock is correct as $this->getMockBuilder(\W...eptionInterface::class) (which targets PHPUnit\Framework\TestCase::getMockBuilder()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
22
        $previousExceptionMock->enableOriginalConstructor();
0 ignored issues
show
Bug introduced by
The method enableOriginalConstructor cannot be called on $previousExceptionMock (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
23
        $previousExceptionMock->setConstructorArgs(['Previous exception message']);
0 ignored issues
show
Bug introduced by
The method setConstructorArgs cannot be called on $previousExceptionMock (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
24
        $previousException = $previousExceptionMock->getMock();
0 ignored issues
show
Bug introduced by
The method getMock cannot be called on $previousExceptionMock (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
25
26
        $exception = FileNotWritableException::fromPrevious($previousException);
27
28
        self::assertSame('Previous exception message', $exception->getMessage());
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<ProxyManagerTest\...tWritableExceptionTest>.

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...
29
        self::assertSame($previousException, $exception->getPrevious());
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<ProxyManagerTest\...tWritableExceptionTest>.

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...
30
    }
31
}
32