-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
project: implement binding for statObject() (#15)
* Update phpstan * project: implement binding for statObject()
- Loading branch information
Showing
7 changed files
with
120 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,30 @@ | ||
parameters: | ||
level: 6 | ||
paths: | ||
- src | ||
- test | ||
ignoreErrors: | ||
- '/Call to an undefined method FFI::.*/' | ||
- '/Access to an undefined property FFI\\CData::.*/' | ||
- | ||
message: '/Binary operation "-" between string&numeric and string results in an error./' | ||
paths: | ||
- test/ListObjectsTest.php | ||
level: 6 | ||
paths: | ||
- src | ||
- test | ||
ignoreErrors: | ||
- '/Call to an undefined method FFI::.*/' | ||
- '/Access to an undefined property FFI\\CData::.*/' | ||
- | ||
message: '/Binary operation "-" between numeric-string and string results in an error./' | ||
paths: | ||
- test/ListObjectsTest.php | ||
- | ||
message: "#^Binary operation \"\\-\" between int and string results in an error\\.$#" | ||
count: 1 | ||
path: test/StatObjectTest.php | ||
- | ||
message: "#^Property Storj\\\\Uplink\\\\Access\\:\\:\\$scope is never read, only written\\.$#" | ||
count: 1 | ||
path: src/Access.php | ||
|
||
- | ||
message: "#^Property Storj\\\\Uplink\\\\EncryptionKey\\:\\:\\$scope is never read, only written\\.$#" | ||
count: 1 | ||
path: src/EncryptionKey.php | ||
|
||
- | ||
message: "#^Property Storj\\\\Uplink\\\\Project\\:\\:\\$scope is never read, only written\\.$#" | ||
count: 1 | ||
path: src/Project.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
namespace Storj\Uplink\Test; | ||
|
||
use DateTimeImmutable; | ||
use PHPUnit\Framework\TestCase; | ||
use Storj\Uplink\Exception\Object\ObjectNotFound; | ||
|
||
class StatObjectTest extends TestCase | ||
{ | ||
public static function setUpBeforeClass(): void | ||
{ | ||
$project = Util::emptyAccess()->openProject(); | ||
$project->createBucket('phpunit'); | ||
|
||
$upload = $project->uploadObject('phpunit', 'StatPrefix/StatObject'); | ||
$upload->setCustomMetadata(['myhouse' => 'myrules']); | ||
$upload->write(random_bytes(55)); | ||
$upload->commit(); | ||
} | ||
|
||
public function testStatObject(): void | ||
{ | ||
$objectInfo = Util::project()->statObject('phpunit', 'StatPrefix/StatObject'); | ||
|
||
self::assertEquals('StatPrefix/StatObject', $objectInfo->getKey()); | ||
self::assertEquals(['myhouse' => 'myrules'], $objectInfo->getCustomMetadata()); | ||
self::assertFalse($objectInfo->isPrefix()); | ||
|
||
$systemMetaData = $objectInfo->getSystemMetadata(); | ||
|
||
self::assertEquals(55, $systemMetaData->getContentLength()); | ||
self::assertEquals(null, $systemMetaData->getExpires()); | ||
self::assertLessThan( | ||
60, | ||
abs(time() - $systemMetaData->getCreated()->format('U')) | ||
); | ||
} | ||
|
||
/** | ||
* Stat on a prefix is not implemented in Uplink | ||
*/ | ||
public function testStatPrefixWithSlash(): void | ||
{ | ||
$this->expectException(ObjectNotFound::class); | ||
|
||
$objectInfo = Util::project()->statObject('phpunit', 'StatPrefix/'); | ||
|
||
// code not reached | ||
self::assertEquals('StatPrefix/', $objectInfo->getKey()); | ||
self::assertTrue($objectInfo->isPrefix()); | ||
} | ||
|
||
/** | ||
* Stat on a prefix is not implemented in Uplink | ||
*/ | ||
public function testStatPrefixWithoutSlash(): void | ||
{ | ||
$this->expectException(ObjectNotFound::class); | ||
|
||
$objectInfo = Util::project()->statObject('phpunit', 'StatPrefix'); | ||
|
||
// code not reached | ||
self::assertEquals('StatPrefix/', $objectInfo->getKey()); | ||
self::assertTrue($objectInfo->isPrefix()); | ||
} | ||
|
||
public function testStatNonExistentObject(): void | ||
{ | ||
self::expectException(ObjectNotFound::class); | ||
|
||
$objectInfo = Util::project()->statObject('phpunit', 'OtherObject'); | ||
} | ||
} |