Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F45314732
D4177.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D4177.diff
View Options
diff --git a/workspaces/tests/Engines/Collection/FilesCollectionTest.php b/workspaces/tests/Engines/Collection/FilesCollectionTest.php
--- a/workspaces/tests/Engines/Collection/FilesCollectionTest.php
+++ b/workspaces/tests/Engines/Collection/FilesCollectionTest.php
@@ -52,6 +52,7 @@
}
protected function setUp () : void {
+ $this->removeCollectionFiles();
$this->initializeDocuments();
global $Config;
@@ -100,7 +101,7 @@
$oldConfigDocumentStorage = $Config['DocumentStorage'];
$Config['DocumentStorage'] = []; //Path isn't defined
- $this>$this->expectException(Exception::class);
+ $this->expectException(Exception::class);
FilesCollection::getCollectionPath('quux');
$Config['DocumentStorage'] = $oldConfigDocumentStorage;
@@ -138,7 +139,7 @@
$filename = $this->collection->getDocumentPath('greenBook');
$this->assertJsonFileEqualsJsonFile(
- 'includes/collection/greenBook1.json',
+ __DIR__ . '/greenBook1.json',
$filename
);
@@ -146,7 +147,7 @@
$this->collection->update($book);
$this->assertJsonFileEqualsJsonFile(
- 'includes/collection/greenBook2.json',
+ __DIR__ . '/greenBook2.json',
$filename
);
@@ -162,9 +163,20 @@
* Tears down resources when tests are done
*/
public static function tearDownAfterClass () : void {
- //Removes created directories
- rmdir(UNITTESTING_FILESCOLLECTION_PATH . '/quux');
- rmdir(UNITTESTING_FILESCOLLECTION_PATH);
+ self::removeCollectionFiles();
+ }
+
+ private static function removeCollectionFiles () : void {
+ $collectionPath = UNITTESTING_FILESCOLLECTION_PATH . '/quux';
+ if (is_dir($collectionPath)) {
+ foreach (glob($collectionPath . '/*') as $filename) {
+ unlink($filename);
+ }
+ rmdir($collectionPath);
+ }
+ if (is_dir(UNITTESTING_FILESCOLLECTION_PATH)) {
+ rmdir(UNITTESTING_FILESCOLLECTION_PATH);
+ }
}
}
diff --git a/workspaces/tests/Engines/Collection/MongoDBCollectionTest.php b/workspaces/tests/Engines/Collection/MongoDBCollectionTest.php
--- a/workspaces/tests/Engines/Collection/MongoDBCollectionTest.php
+++ b/workspaces/tests/Engines/Collection/MongoDBCollectionTest.php
@@ -49,6 +49,10 @@
}
public function setUp () : void {
+ if (!class_exists('MongoClient')) {
+ $this->markTestSkipped('The legacy MongoDB driver is not available.');
+ }
+
global $Config;
$Config = static::getConfig();
diff --git a/workspaces/tests/Engines/Collection/MySQLCollectionTest.php b/workspaces/tests/Engines/Collection/MySQLCollectionTest.php
--- a/workspaces/tests/Engines/Collection/MySQLCollectionTest.php
+++ b/workspaces/tests/Engines/Collection/MySQLCollectionTest.php
@@ -65,6 +65,10 @@
* Initializes the resources needed for thist test.
*/
public function setUp () : void {
+ if (!class_exists(__NAMESPACE__ . '\\MySQLDatabase')) {
+ $this->markTestSkipped('The legacy MySQL database adapter is not available.');
+ }
+
$db = new MySQLDatabase(
UNITTESTING_MYSQL_HOST,
UNITTESTING_MYSQL_USERNAME,
diff --git a/workspaces/tests/Engines/Collection/SQLiteCollectionTest.php b/workspaces/tests/Engines/Collection/SQLiteCollectionTest.php
--- a/workspaces/tests/Engines/Collection/SQLiteCollectionTest.php
+++ b/workspaces/tests/Engines/Collection/SQLiteCollectionTest.php
@@ -62,6 +62,14 @@
}
public function setUp () : void {
+ if (!class_exists("SQLite3")) {
+ $this->markTestSkipped("The SQLite3 extension is not available.");
+ }
+
+ if (!defined('COLLECTIONS_SQLITE_DATABASE_READY') && file_exists(UNITTESTING_SQLITE_FILE)) {
+ unlink(UNITTESTING_SQLITE_FILE);
+ }
+
$this->initializeDocuments();
global $Config;
@@ -169,6 +177,8 @@
* Clears resources created for this test
*/
public static function tearDownAfterClass () : void {
- unlink(UNITTESTING_SQLITE_FILE);
+ if (file_exists(UNITTESTING_SQLITE_FILE)) {
+ unlink(UNITTESTING_SQLITE_FILE);
+ }
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Aug 22, 16:39 (5 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4024188
Default Alt Text
D4177.diff (4 KB)
Attached To
Mode
D4177: Improve tests for Collection engines
Attached
Detach File
Event Timeline
Log In to Comment