Skip to content

Commit

Permalink
fix: system tests are working
Browse files Browse the repository at this point in the history
  • Loading branch information
vishwarajanand committed Mar 17, 2024
1 parent b04f999 commit ec97f87
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
6 changes: 5 additions & 1 deletion Storage/src/Bucket.php
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,10 @@ public function object($name, array $options = [])
* @param array $options [optional] {
* Configuration Options.
*
* @type string $ifGenerationMatch Makes the operation conditional on whether
* the object's current generation matches the given value.
* @type string $ifGenerationNotMatch Makes the operation conditional on whether
* the object's current generation matches the given value.
* @type string $ifMetagenerationMatch If set, only restores
* if its metageneration matches this value.
* @type string $ifMetagenerationNotMatch If set, only restores
Expand All @@ -638,8 +642,8 @@ public function restore($name, $generation, array $options = [])
{
$res = $this->connection->restoreObject([
'bucket' => $this->identity['bucket'],
'generation' => $generation,
'object' => $name,
'generation' => $generation
] + $options);
return new StorageObject(
$this->connection,
Expand Down
26 changes: 18 additions & 8 deletions Storage/tests/System/ManageObjectsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,19 +299,21 @@ public function testSoftDeleteObject($object)
]
]);

$this->assertObjectExists($object);
$this->assertStorageObjectExists($object);
$generation = $object->info()['generation'];

$object->delete();

$this->assertObjectExists($object, [], false);
$this->assertObjectExists($object, [
$this->assertStorageObjectNotExists($object);
$this->assertStorageObjectExists($object, [
'softDeleted' => true,
'generation' => $object->info()['generation']
], true);
'generation' => $generation
]);

self::$bucket->restore($object->name(), $object->info()['generation']);
$restoredObject = self::$bucket->restore($object->name(), $generation);
$this->assertNotEquals($generation, $restoredObject->info()['generation']);

$this->assertObjectExists($object);
$this->assertStorageObjectExists($restoredObject);
}

public function testRotatesCustomerSuppliedEncrpytion()
Expand Down Expand Up @@ -443,13 +445,21 @@ public function testStringNormalization()
}
}

private function assertObjectExists($object, $options = [], $isPresent = true)
private function assertStorageObjectExists($object, $options = [], $isPresent = true)
{
// $this->assertEquals($isPresent, $object->exists($options));
$object = self::$bucket->object($object->name(), $options);
$this->assertEquals($isPresent, $object->exists($options));
$this->assertEquals($isPresent, $object->exists($options));
$objects = self::$bucket->objects($options);
$objects = array_map(function ($o) {
return $o->name();
}, iterator_to_array($objects));
$this->assertEquals($isPresent, in_array($object->name(), $objects));
}

private function assertStorageObjectNotExists($object, $options = [])
{
$this->assertStorageObjectExists($object, $options, false);
}
}

0 comments on commit ec97f87

Please sign in to comment.