Skip to content

Commit 0c4e10b

Browse files
committed
fix(tests): Address Copilot review feedback on S3 encryption tests
- Guard $config['class'] with null coalescing in setUpBeforeClass() to avoid PHP notice when objectstore is configured without a 'class' key - Remove unused $rootStorage property and unwrapping loop in setUp() (was assigned but never referenced in any test method) - Chain previous exception in getObjectUrn() throw to preserve stack trace Signed-off-by: Stephen Cuppett <steve@cuppett.com>
1 parent 1d53aef commit 0c4e10b

2 files changed

Lines changed: 3 additions & 16 deletions

File tree

tests/lib/Files/ObjectStore/S3EncryptionMigrationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public static function setUpBeforeClass(): void {
5656
parent::setUpBeforeClass();
5757

5858
$config = Server::get(IConfig::class)->getSystemValue('objectstore');
59-
if (!is_array($config) || $config['class'] !== S3::class) {
59+
if (!is_array($config) || ($config['class'] ?? null) !== S3::class) {
6060
self::markTestSkipped('S3 primary storage not configured');
6161
}
6262
}

tests/lib/Files/ObjectStore/S3EncryptionTest.php

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
namespace Test\Files\ObjectStore;
1111

12-
use OC\Files\ObjectStore\ObjectStoreStorage;
1312
use OC\Files\ObjectStore\S3;
1413
use OCP\IConfig;
1514
use OCP\Server;
@@ -51,15 +50,12 @@ class S3EncryptionTest extends \Test\TestCase {
5150
/** @var array */
5251
private $s3Config;
5352

54-
/** @var ObjectStoreStorage */
55-
private $rootStorage;
56-
5753
public static function setUpBeforeClass(): void {
5854
parent::setUpBeforeClass();
5955

6056
// Check if S3 primary storage is configured
6157
$config = Server::get(IConfig::class)->getSystemValue('objectstore');
62-
if (!is_array($config) || $config['class'] !== S3::class) {
58+
if (!is_array($config) || ($config['class'] ?? null) !== S3::class) {
6359
self::markTestSkipped('S3 primary storage not configured. Configure objectstore in config.php to run these tests.');
6460
}
6561
}
@@ -88,15 +84,6 @@ protected function setUp(): void {
8884

8985
// Get the view for the user
9086
$this->view = new \OC\Files\View('/' . self::TEST_USER . '/files');
91-
92-
// Get the root ObjectStoreStorage (without wrapper) to check S3 sizes
93-
$mount = \OC\Files\Filesystem::getMountManager()->find('/' . self::TEST_USER . '/files');
94-
$this->rootStorage = $mount->getStorage();
95-
96-
// Unwrap to get the actual ObjectStoreStorage if it's wrapped
97-
while ($this->rootStorage instanceof \OC\Files\Storage\Wrapper\Wrapper) {
98-
$this->rootStorage = $this->rootStorage->getWrapperStorage();
99-
}
10087
}
10188

10289
protected function tearDown(): void {
@@ -143,7 +130,7 @@ private function getObjectUrn(string $path): string {
143130
// URN format: urn:oid:{fileId}
144131
return 'urn:oid:' . $fileId;
145132
} catch (\Exception $e) {
146-
throw new \Exception("File not found: $path - " . $e->getMessage());
133+
throw new \Exception("File not found: $path - " . $e->getMessage(), 0, $e);
147134
}
148135
}
149136

0 commit comments

Comments
 (0)