Skip to content

Commit

Permalink
Bump dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
christeredvartsen committed Apr 12, 2023
1 parent c5655b3 commit 819e058
Show file tree
Hide file tree
Showing 11 changed files with 917 additions and 892 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ name: CI
on: push
jobs:
ci:
runs-on: ${{ matrix.os }}
runs-on: ubuntu-22.04
strategy:
matrix:
os: ['ubuntu-22.04']
php: ['8.1', '8.2']
name: Run CI build
steps:
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
build
vendor
.phpunit.result.cache
.phpunit.cache
.vscode
test.php
test.php
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
"php": ">=8.1"
},
"require-dev": {
"phpunit/phpunit": "^9.4",
"phpunit/phpunit": "^10.0",
"psalm/plugin-phpunit": "^0.18.4",
"symfony/var-dumper": "^6.2",
"vimeo/psalm": "^5.5"
},
"support": {
Expand Down
887 changes: 471 additions & 416 deletions composer.lock

Large diffs are not rendered by default.

15 changes: 2 additions & 13 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
executionOrder="depends,defects"
forceCoversAnnotation="true"
beStrictAboutCoversAnnotation="false"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true"
bootstrap="tests/bootstrap.php"
>
<coverage processUncoveredFiles="true">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" executionOrder="depends,defects" beStrictAboutOutputDuringTests="true" bootstrap="tests/bootstrap.php" cacheDirectory=".phpunit.cache" requireCoverageMetadata="true" beStrictAboutCoverageMetadata="false">
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
<exclude>
<file>src/functions.php</file>
</exclude>
</coverage>

<testsuites>
<testsuite name="default">
<directory suffix="Test.php">tests</directory>
Expand Down
26 changes: 5 additions & 21 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
findUnusedCode="false"
findUnusedBaselineEntry="true"
>
<stubs>
<file name="tests/bootstrap.php" />
</stubs>

<projectFiles>
<directory name="src" />
<directory name="tests" />
Expand All @@ -19,32 +20,15 @@
<directory name="vendor" />
</ignoreFiles>
</projectFiles>

<issueHandlers>
<PossiblyUndefinedMethod>
<errorLevel type="suppress">
<directory name="tests" />
<referencedMethod name="TestFs\File::hasChild" />
<referencedMethod name="TestFs\File::getChild" />
</errorLevel>
</PossiblyUndefinedMethod>

<PossiblyNullReference>
<errorLevel type="suppress">
<directory name="tests" />
</errorLevel>
</PossiblyNullReference>

<PropertyNotSetInConstructor>
<errorLevel type="suppress">
<directory name="tests" />
<referencedProperty name="TestFs\StreamWrapperTest::$root" />
</errorLevel>

<errorLevel type="suppress">
<file name="src/Asset.php" />
<referencedProperty name="TestFs\Asset::$name" />
</errorLevel>
</PropertyNotSetInConstructor>
</issueHandlers>
<plugins>
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
</plugins>
</psalm>
240 changes: 120 additions & 120 deletions tests/AssetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,6 @@ public function testCanSetAndGetName() : void {
$this->assertSame('newname', $asset->getName(), 'Incorrect name');
}

/**
* @return array<string,array<string,string>>
*/
public function getInvalidAssetNames() : array {
return [
'empty name' => [
'name' => ' ',
'exceptionMessage' => 'Name can not be empty',
],
'dir separators' => [
'name' => 'foo/bar',
'exceptionMessage' => 'Name can not contain a directory separator',
],
];
}

/**
* @dataProvider getInvalidAssetNames
* @covers ::setName
Expand Down Expand Up @@ -262,9 +246,122 @@ public function testSetExistingParentReturnsEarly() : void {
}

/**
* @return array<string,array<string,mixed>>
* @dataProvider getAccessCheckDataForReadable
* @covers ::isReadable
*/
public function testCanCheckIfAssetIsReadable(int $ownerUid, int $ownerGid, int $mode, int $checkUid, int $checkGid, bool $expectedResult) : void {
$file = new File('filename');
$file->setUid($ownerUid);
$file->setGid($ownerGid);
$file->setMode($mode);

$this->assertSame($expectedResult, $file->isReadable($checkUid, $checkGid), 'Wrong result for isReadable');
}

/**
* @covers ::isReadable
*/
public function testAssetIsNotReadableWhenParentIsNotReadable() : void {
$dir = new Directory('dir');
$dir->setUid(1);
$dir->setGid(1);
$dir->setMode(0770);

$file = new File('file');
$file->setUid(2);
$file->setGid(2);
$file->setMode(0777);
$file->setParent($dir);

$this->assertTrue($file->isReadable(1, 1), 'Expected user to be able to read file');
$this->assertFalse($file->isReadable(2, 2), 'Did not expect user to be able to read');
}

/**
* @dataProvider getAccessCheckDataForWritable
* @covers ::isWritable
*/
public function testCanCheckIfAssetIsWritable(int $ownerUid, int $ownerGid, int $mode, int $checkUid, int $checkGid, bool $expectedResult) : void {
$file = new File('filename');
$file->setUid($ownerUid);
$file->setGid($ownerGid);
$file->setMode($mode);

$this->assertSame($expectedResult, $file->isWritable($checkUid, $checkGid), 'Wrong result for isWritable');
}

/**
* @dataProvider getAccessCheckDataForExecutable
* @covers ::isExecutable
*/
public function testCanCheckIfAssetIsExecutable(int $ownerUid, int $ownerGid, int $mode, int $checkUid, int $checkGid, bool $expectedResult) : void {
$file = new File('filename');
$file->setUid($ownerUid);
$file->setGid($ownerGid);
$file->setMode($mode);

$this->assertSame($expectedResult, $file->isExecutable($checkUid, $checkGid), 'Wrong result for isExecutable');
}

/**
* @covers ::isOwnedByUser
*/
public function testCanCheckIfAssetIsOwnedByUser() : void {
$asset = new File('filename');
$this->assertTrue($asset->isOwnedByUser(0), 'Expected UID 0 to own the asset');
$asset->setUid(1);
$this->assertFalse($asset->isOwnedByUser(0), 'Did not expect UID 0 to own the asset');
$this->assertTrue($asset->isOwnedByUser(1), 'Expected UID 1 to own the asset');
}

/**
* @covers ::getDevice
* @covers TestFs\Device::getDevice
*/
public function testCanGetDevice() : void {
$file = new File('name');
$dir = new Directory('name');
$device = new Device('some name');
$dir->addChild($file);
$device->addChild($dir);

$this->assertSame($device, $file->getDevice(), 'Incorrect instance returned');
$this->assertSame($device, $dir->getDevice(), 'Incorrect instance returned');
$this->assertSame($device, $device->getDevice(), 'Incorrect instance returned');
}

/**
* @covers ::getDevice
*/
public function testReturnNullIfThereIsNoDevice() : void {
$file = new File('name');
$dir = new Directory('name');
$dir->addChild($file);

$this->assertNull($file->getDevice(), 'Did not expect any device');
$this->assertNull($dir->getDevice(), 'Did not expect any device');
}

/**
* @return array<string,array{name:string,exceptionMessage:string}>
*/
public function getAccessCheckDataForReadable() : array {
public static function getInvalidAssetNames() : array {
return [
'empty name' => [
'name' => ' ',
'exceptionMessage' => 'Name can not be empty',
],
'dir separators' => [
'name' => 'foo/bar',
'exceptionMessage' => 'Name can not contain a directory separator',
],
];
}

/**
* @return array<string,array{ownerUid:int,ownerGid:int,mode:int,checkUid:int,checkGid:int,expectedResult:bool}>
*/
public static function getAccessCheckDataForReadable() : array {
return [
'root user' => [
'ownerUid' => 1,
Expand Down Expand Up @@ -318,41 +415,9 @@ public function getAccessCheckDataForReadable() : array {
}

/**
* @dataProvider getAccessCheckDataForReadable
* @covers ::isReadable
*/
public function testCanCheckIfAssetIsReadable(int $ownerUid, int $ownerGid, int $mode, int $checkUid, int $checkGid, bool $expectedResult) : void {
$file = new File('filename');
$file->setUid($ownerUid);
$file->setGid($ownerGid);
$file->setMode($mode);

$this->assertSame($expectedResult, $file->isReadable($checkUid, $checkGid), 'Wrong result for isReadable');
}

/**
* @covers ::isReadable
*/
public function testAssetIsNotReadableWhenParentIsNotReadable() : void {
$dir = new Directory('dir');
$dir->setUid(1);
$dir->setGid(1);
$dir->setMode(0770);

$file = new File('file');
$file->setUid(2);
$file->setGid(2);
$file->setMode(0777);
$file->setParent($dir);

$this->assertTrue($file->isReadable(1, 1), 'Expected user to be able to read file');
$this->assertFalse($file->isReadable(2, 2), 'Did not expect user to be able to read');
}

/**
* @return array<string,array<string,mixed>>
* @return array<string,array{ownerUid:int,ownerGid:int,mode:int,checkUid:int,checkGid:int,expectedResult:bool}>
*/
public function getAccessCheckDataForWritable() : array {
public static function getAccessCheckDataForWritable() : array {
return [
'root user' => [
'ownerUid' => 1,
Expand Down Expand Up @@ -406,22 +471,9 @@ public function getAccessCheckDataForWritable() : array {
}

/**
* @dataProvider getAccessCheckDataForWritable
* @covers ::isWritable
* @return array<string,array{ownerUid:int,ownerGid:int,mode:int,checkUid:int,checkGid:int,expectedResult:bool}>
*/
public function testCanCheckIfAssetIsWritable(int $ownerUid, int $ownerGid, int $mode, int $checkUid, int $checkGid, bool $expectedResult) : void {
$file = new File('filename');
$file->setUid($ownerUid);
$file->setGid($ownerGid);
$file->setMode($mode);

$this->assertSame($expectedResult, $file->isWritable($checkUid, $checkGid), 'Wrong result for isWritable');
}

/**
* @return array<string,array<string,mixed>>
*/
public function getAccessCheckDataForExecutable() : array {
public static function getAccessCheckDataForExecutable() : array {
return [
'root user' => [
'ownerUid' => 1,
Expand Down Expand Up @@ -473,56 +525,4 @@ public function getAccessCheckDataForExecutable() : array {
],
];
}

/**
* @dataProvider getAccessCheckDataForExecutable
* @covers ::isExecutable
*/
public function testCanCheckIfAssetIsExecutable(int $ownerUid, int $ownerGid, int $mode, int $checkUid, int $checkGid, bool $expectedResult) : void {
$file = new File('filename');
$file->setUid($ownerUid);
$file->setGid($ownerGid);
$file->setMode($mode);

$this->assertSame($expectedResult, $file->isExecutable($checkUid, $checkGid), 'Wrong result for isExecutable');
}

/**
* @covers ::isOwnedByUser
*/
public function testCanCheckIfAssetIsOwnedByUser() : void {
$asset = new File('filename');
$this->assertTrue($asset->isOwnedByUser(0), 'Expected UID 0 to own the asset');
$asset->setUid(1);
$this->assertFalse($asset->isOwnedByUser(0), 'Did not expect UID 0 to own the asset');
$this->assertTrue($asset->isOwnedByUser(1), 'Expected UID 1 to own the asset');
}

/**
* @covers ::getDevice
* @covers TestFs\Device::getDevice
*/
public function testCanGetDevice() : void {
$file = new File('name');
$dir = new Directory('name');
$device = new Device('some name');
$dir->addChild($file);
$device->addChild($dir);

$this->assertSame($device, $file->getDevice(), 'Incorrect instance returned');
$this->assertSame($device, $dir->getDevice(), 'Incorrect instance returned');
$this->assertSame($device, $device->getDevice(), 'Incorrect instance returned');
}

/**
* @covers ::getDevice
*/
public function testReturnNullIfThereIsNoDevice() : void {
$file = new File('name');
$dir = new Directory('name');
$dir->addChild($file);

$this->assertNull($file->getDevice(), 'Did not expect any device');
$this->assertNull($dir->getDevice(), 'Did not expect any device');
}
}
}
Loading

0 comments on commit 819e058

Please # to comment.