Skip to content

Commit

Permalink
Fixup relative paths to work/localstorage
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-davis committed Sep 20, 2018
1 parent 9695994 commit 62039ce
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 13 deletions.
41 changes: 36 additions & 5 deletions tests/acceptance/features/bootstrap/BasicStructure.php
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,7 @@ public static function removeFile($path, $filename) {
* @return void
*/
public function createFileSpecificSize($name, $size) {
$file = \fopen("work/$name", 'w');
$file = \fopen($this->workStorageDirLocation() . $name, 'w');
\fseek($file, $size - 1, SEEK_CUR);
\fwrite($file, 'a'); // write a dummy char at SIZE position
\fclose($file);
Expand All @@ -1117,7 +1117,7 @@ public function createFileSpecificSize($name, $size) {
* @return void
*/
public function createFileWithText($name, $text) {
$file = \fopen("work/$name", 'w');
$file = \fopen($this->workStorageDirLocation() . $name, 'w');
\fwrite($file, $text);
\fclose($file);
}
Expand Down Expand Up @@ -1154,7 +1154,8 @@ public function fileHasBeenCreatedInLocalStorageWithText($filename, $text) {
* @return void
*/
public function fileHasBeenDeletedInLocalStorage($filename) {
\unlink("work/local_storage/$filename");
// ToDo: use testing app to cleanup files in local storage
\unlink($this->localStorageDirLocation() . $filename);
}

/**
Expand Down Expand Up @@ -1367,13 +1368,42 @@ public function substituteInLineCodes($value, $functions = []) {
return $value;
}

/**
* @return string
*/
public function temporaryStorageSubfolderName() {
return "work";
}

/**
* @return string
*/
public function acceptanceTestsDirLocation() {
return \dirname(__FILE__) . "/../../";
}

/**
* @return string
*/
public function workStorageDirLocation() {
return $this->acceptanceTestsDirLocation() . $this->temporaryStorageSubfolderName() . "/";
}

/**
* @return string
*/
public function localStorageDirLocation() {
return $this->workStorageDirLocation() . "local_storage/";
}

/**
* @BeforeScenario @local_storage
*
* @return void
*/
public function removeFilesFromLocalStorageBefore() {
$dir = "./work/local_storage/";
// ToDo: use testing app to cleanup files in local storage
$dir = $this->localStorageDirLocation();
$di = new RecursiveDirectoryIterator(
$dir, FilesystemIterator::SKIP_DOTS
);
Expand All @@ -1391,7 +1421,8 @@ public function removeFilesFromLocalStorageBefore() {
* @return void
*/
public function removeFilesFromLocalStorageAfter() {
$dir = "./work/local_storage/";
// ToDo: use testing app to cleanup files in local storage
$dir = $this->localStorageDirLocation();
$di = new RecursiveDirectoryIterator(
$dir, FilesystemIterator::SKIP_DOTS
);
Expand Down
7 changes: 6 additions & 1 deletion tests/acceptance/features/bootstrap/Checksums.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ trait Checksums {
public function userUploadsFileToWithChecksumUsingTheAPI(
$user, $source, $destination, $checksum
) {
$file = \GuzzleHttp\Stream\Stream::factory(\fopen($source, 'r'));
$file = \GuzzleHttp\Stream\Stream::factory(
\fopen(
$this->acceptanceTestsDirLocation() . $source,
'r'
)
);
$this->response = $this->makeDavRequest(
$user,
'PUT',
Expand Down
25 changes: 19 additions & 6 deletions tests/acceptance/features/bootstrap/WebDav.php
Original file line number Diff line number Diff line change
Expand Up @@ -1421,7 +1421,12 @@ public function checkElementList(
* @return void
*/
public function userUploadsAFileTo($user, $source, $destination) {
$file = \GuzzleHttp\Stream\Stream::factory(\fopen($source, 'r'));
$file = \GuzzleHttp\Stream\Stream::factory(
\fopen(
$this->acceptanceTestsDirLocation() . $source,
'r'
)
);
$this->response = $this->makeDavRequest(
$user, "PUT", $destination, [], $file
);
Expand Down Expand Up @@ -1457,8 +1462,12 @@ public function userOnUploadsAFileTo($user, $server, $source, $destination) {
public function userUploadsAFileToWithChunks(
$user, $source, $destination, $chunkingVersion = null
) {
$size = \filesize($source);
$contents = \file_get_contents($source);
$size = \filesize(
$this->acceptanceTestsDirLocation() . $source
);
$contents = \file_get_contents(
$this->acceptanceTestsDirLocation() . $source
);

// use two chunks for the sake of testing
$chunks = [];
Expand Down Expand Up @@ -1674,9 +1683,13 @@ public function filesUploadedToWithAllMechanismsShouldExist(
public function userAddsAFileTo($user, $destination, $bytes) {
$filename = "filespecificSize.txt";
$this->createFileSpecificSize($filename, $bytes);
PHPUnit_Framework_Assert::assertFileExists("work/$filename");
$this->userUploadsAFileTo($user, "work/$filename", $destination);
$this->removeFile("work/", $filename);
PHPUnit_Framework_Assert::assertFileExists($this->workStorageDirLocation() . $filename);
$this->userUploadsAFileTo(
$user,
$this->temporaryStorageSubfolderName() . "/$filename",
$destination
);
$this->removeFile($this->workStorageDirLocation(), $filename);
$expectedElements = new TableNode([["$destination"]]);
$this->checkElementList($user, $expectedElements);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ function teardown() {
# Clear storage folder
# This depends on the test runner and server being the same file system
# ToDo: use the testing app to cleanup.
rm -Rf work/local_storage/*
rm -Rf ${SCRIPT_PATH}/work/local_storage/*
fi

if [ "${OC_TEST_ALT_HOME}" = "1" ]
Expand Down

0 comments on commit 62039ce

Please sign in to comment.