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 (#837)
by E
07:31 queued 05:03
created

GeneratorQueueTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 58
rs 10
c 0
b 0
f 0
wmc 3

7 Methods

Rating   Name   Duplication   Size   Complexity  
A hp$0 ➔ isAllowed() 0 4 1
A hp$0 ➔ generate() 0 3 1
A setUp() 0 5 1
A testRun() 0 12 1
A testGetAllowedQueue() 0 6 1
A testGetStepCount() 0 9 1
A createConditionalTemplateGenerator() 0 14 1
1
<?php declare(strict_types=1);
2
3
namespace ApiGen\Tests\Generator;
4
5
use ApiGen\Contracts\Console\Helper\ProgressBarInterface;
6
use ApiGen\Contracts\Generator\StepCounterInterface;
7
use ApiGen\Contracts\Generator\TemplateGenerators\ConditionalTemplateGeneratorInterface;
8
use ApiGen\Contracts\Generator\TemplateGenerators\TemplateGeneratorInterface;
9
use ApiGen\Generator\GeneratorQueue;
10
use ApiGen\Tests\MethodInvoker;
11
use PHPUnit\Framework\TestCase;
12
13
final class GeneratorQueueTest extends TestCase
14
{
15
    /**
16
     * @var GeneratorQueue
17
     */
18
    private $generatorQueue;
19
20
    protected function setUp(): void
21
    {
22
        $progressBarMock = $this->createMock(ProgressBarInterface::class);
23
        $this->generatorQueue = new GeneratorQueue($progressBarMock);
24
    }
25
26
    public function testRun(): void
27
    {
28
        $this->assertFileNotExists(TEMP_DIR . '/file.txt');
29
30
        $templateGeneratorMock = $this->createMock(TemplateGeneratorInterface::class);
31
        $templateGeneratorMock->method('generate')
32
            ->willReturn(file_put_contents(TEMP_DIR . '/file.txt', '...'));
33
        $this->generatorQueue->addToQueue($templateGeneratorMock);
34
        $this->generatorQueue->run();
35
36
        $this->assertFileExists(TEMP_DIR . '/file.txt');
37
    }
38
39
    public function testGetAllowedQueue(): void
40
    {
41
        $this->generatorQueue->addToQueue($this->createConditionalTemplateGenerator());
42
43
        $this->assertCount(0, MethodInvoker::callMethodOnObject($this->generatorQueue, 'getAllowedQueue'));
44
    }
45
46
    public function testGetStepCount(): void
47
    {
48
        $templateGeneratorMock = $this->createMock([TemplateGeneratorInterface::class, StepCounterInterface::class]);
49
        $templateGeneratorMock->method('getStepCount')
50
            ->willReturn(50);
51
        $this->generatorQueue->addToQueue($templateGeneratorMock);
52
53
        $this->assertSame(50, MethodInvoker::callMethodOnObject($this->generatorQueue, 'getStepCount'));
54
    }
55
56
    private function createConditionalTemplateGenerator(): ConditionalTemplateGeneratorInterface
57
    {
58
        return new class implements ConditionalTemplateGeneratorInterface
59
        {
60
            public function isAllowed(): bool
61
            {
62
                return false;
63
            }
64
65
            public function generate(): void
66
            {
67
            }
68
        };
69
    }
70
}
71