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 ( 75bdf9...8faa57 )
by joseph
83:56 queued 81:04
created

DirectoryTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 28
dl 0
loc 78
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A itCanLoadAnExistingDirectory() 0 7 1
A itCachesDirectoryObjectInstances() 0 3 1
A itCanSetDirectoryPermissionsToUseWhenCreating() 0 8 1
A itCanCreateANewDirectory() 0 10 1
A itCannotCreateADirectoryThatAlreadyExists() 0 8 1
A setUpBeforeClass() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Tests\Medium\CodeGeneration\Filesystem;
4
5
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Filesystem\Directory;
6
use EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException;
7
use EdmondsCommerce\DoctrineStaticMeta\Tests\Assets\AbstractTest;
8
use PHPUnit\Framework\TestCase;
9
10
/**
11
 * @covers \EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Filesystem\Directory
12
 * @covers \EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Filesystem\AbstractFilesystemItem
13
 */
14
class DirectoryTest extends TestCase
15
{
16
    private const WORK_DIR = AbstractTest::VAR_PATH . '/DirectoryTest';
17
18
    public static function setUpBeforeClass()
19
    {
20
        mkdir(self::WORK_DIR);
21
    }
22
23
    /**
24
     * @test
25
     * @medium
26
     */
27
    public function itCanCreateANewDirectory(): Directory
28
    {
29
        $path   = self::WORK_DIR . '/directoryToCreate';
30
        $object = new Directory($path);
31
        $object->create();
32
        self::assertDirectoryExists(self::WORK_DIR . '/directoryToCreate');
33
        self::assertSame($path, $object->getPath());
34
        self::assertSame(realpath($path), $object->getSplFileInfo()->getRealPath());
35
36
        return $object;
37
    }
38
39
    /**
40
     * @test
41
     * @medium
42
     * @depends itCanCreateANewDirectory
43
     *
44
     * @param Directory $object
45
     *
46
     * @throws DoctrineStaticMetaException
47
     */
48
    public function itCachesDirectoryObjectInstances(Directory $object): void
49
    {
50
        self::assertSame($object->getSplFileInfo(), $object->getSplFileInfo());
51
    }
52
53
    /**
54
     * @test
55
     * @medium
56
     */
57
    public function itCanLoadAnExistingDirectory(): void
58
    {
59
        $path = self::WORK_DIR . '/alreadyExists';
60
        mkdir($path);
61
        $object = new Directory($path);
62
        self::assertSame($path, $object->getPath());
63
        self::assertTrue($object->exists());
64
    }
65
66
    /**
67
     * @test
68
     * @medium
69
     */
70
    public function itCannotCreateADirectoryThatAlreadyExists(): void
71
    {
72
        $path = self::WORK_DIR . '/alreadyExists2';
73
        mkdir($path);
74
        $object = new Directory($path);
75
        $this->expectException(DoctrineStaticMetaException::class);
76
        $this->expectExceptionMessage('directory already exists at path ');
77
        $object->create();
78
    }
79
80
    /**
81
     * @test
82
     * @medium
83
     */
84
    public function itCanSetDirectoryPermissionsToUseWhenCreating()
85
    {
86
        $path        = self::WORK_DIR . '/hasCustomPermissions';
87
        $permissions = 0666;
88
        $object      = new Directory($path);
89
        $object->setCreateMode($permissions);
90
        $object->create();
91
        self::assertSame(decoct($permissions), decoct(fileperms($path) & 0777));
92
    }
93
}
94