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
Pull Request — master (#1)
by Pascal
04:06
created

testErrorStackIsCreated()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 10
nc 1
nop 0
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Saikootau\ApiBundle\Tests\Resource\Builder;
6
7
use Exception;
8
use PHPUnit\Framework\TestCase;
9
use Saikootau\ApiBundle\Resource\Builder\ErrorResourceBuilder;
10
use Saikootau\ApiBundle\Resource\Error;
11
12
class ErrorResourceBuilderTest extends TestCase
13
{
14
    public function testErrorIsCreated(): void
15
    {
16
        $builder = new ErrorResourceBuilder();
17
18
        $exception = new Exception('test', 123);
19
20
        $errors = $builder->build($exception);
21
22
        $this->assertCount(1, $errors);
23
        $this->assertContainsOnly(Error::class, $errors);
24
        $this->assertSame(Exception::class, $errors[0]->getType());
25
        $this->assertSame('test', $errors[0]->getMessage());
26
        $this->assertSame('123', $errors[0]->getCode());
27
    }
28
29
    public function testErrorStackIsCreated(): void
30
    {
31
        $builder = new ErrorResourceBuilder();
32
33
        $exception1 = new Exception('test1', 123);
34
        $exception2 = new Exception('test2', 234, $exception1);
35
        $exception3 = new Exception('test3', 345, $exception2);
36
37
        $errors = $builder->traceStack()->build($exception3);
38
39
        $this->assertCount(3, $errors);
40
        $this->assertContainsOnly(Error::class, $errors);
41
        $this->assertSame('test3', $errors[0]->getMessage());
42
        $this->assertSame('test2', $errors[1]->getMessage());
43
        $this->assertSame('test1', $errors[2]->getMessage());
44
    }
45
46
    public function testStackIsOnlyCreatedIfEnabled(): void
47
    {
48
        $builder = new ErrorResourceBuilder();
49
50
        $exception1 = new Exception('test1', 123);
51
        $exception2 = new Exception('test2', 234, $exception1);
52
        $exception3 = new Exception('test3', 345, $exception2);
53
54
        $errors = $builder->doNotTraceStack()->build($exception3);
55
56
        $this->assertCount(1, $errors);
57
        $this->assertContainsOnly(Error::class, $errors);
58
        $this->assertSame('test3', $errors[0]->getMessage());
59
    }
60
}
61