diff options
author | Olivier Paroz <github@oparoz.com> | 2015-08-19 19:09:16 +0300 |
---|---|---|
committer | Olivier Paroz <github@oparoz.com> | 2015-08-19 19:09:16 +0300 |
commit | 309e8b4f81579dca11ffecb60ca9851156ac4cec (patch) | |
tree | b3f019df75cdf56a3a8fc8ab6b8c2cff2b869718 /tests/_support | |
parent | 718e9be8a54ede8396819ef79ebd61bdba954a01 (diff) |
Add sampe gallery.cnf for testing
Diffstat (limited to 'tests/_support')
-rw-r--r-- | tests/_support/Helper/DataSetup.php | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/tests/_support/Helper/DataSetup.php b/tests/_support/Helper/DataSetup.php index c0cf91bb..c3e94a73 100644 --- a/tests/_support/Helper/DataSetup.php +++ b/tests/_support/Helper/DataSetup.php @@ -159,13 +159,13 @@ class DataSetup extends \Codeception\Module { /** * Called when a test fails * - * Here we want to make sure the setup is restored to its original state + * This is called after every test, not after a suite run * * @param TestCase $test * @param $fail */ public function _failed(\Codeception\TestCase $test, $fail) { - $this->_afterSuite(); + } /** @@ -214,7 +214,6 @@ class DataSetup extends \Codeception\Module { // Create folders and files $this->createSampleData($userId, $this->filesHierarchy); - $this->coreTestCase->logoutUser(); } @@ -290,6 +289,9 @@ class DataSetup extends \Codeception\Module { $userFolder = $this->server->getUserFolder($userId); $this->createStructure($userFolder, $structure); + + // Add configuration. This will break if the config filename or the userId is changed + $this->addFile($userFolder, 'gallery.cnf', $userId . '-' . 'gallery.cnf'); } /** @@ -313,10 +315,7 @@ class DataSetup extends \Codeception\Module { $this->createStructure($subFolder, $value); } } else { - $file = $baseFolder->newFile($value); - // Not the most reliable way - $imgData = file_get_contents(__DIR__ . '/../../_data/' . $value); - $file->putContent($imgData); + $file = $this->addFile($baseFolder, $value, $value); if ($value === $this->sharedFileName) { $this->sharedFile = $file; @@ -326,6 +325,23 @@ class DataSetup extends \Codeception\Module { } /** + * Copies the content of one file to another + * + * @param Folder $folder + * @param string $sourceName + * @param string $destinationName + * + * @return File + */ + private function addFile($folder, $sourceName, $destinationName) { + $file = $folder->newFile($sourceName); + $fileData = file_get_contents(__DIR__ . '/../../_data/' . $destinationName); + $file->putContent($fileData); + + return $file; + } + + /** * Shares the file and folder, both publicly and with the tester * * Warning - File operations don't work properly in the test environment provided by core as |