Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions tests/Utils/FileSystem.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,13 @@ test(function () { // copy
FileSystem::copy(TEMP_DIR . '/3/file', TEMP_DIR . '/3/x/file');
Assert::same('Hello', file_get_contents(TEMP_DIR . '/3/x/file'));

FileSystem::copy('http://example.com', TEMP_DIR . '/3/x/y/file');
Assert::true(is_file(TEMP_DIR . '/3/x/y/file'));
if (getenv('SKIP_ONLINE_TESTS')) {
FileSystem::copy(__FILE__, TEMP_DIR . '/3/x/y/file');
Assert::true(is_file(TEMP_DIR . '/3/x/y/file'));
} else {
FileSystem::copy('http://example.com', TEMP_DIR . '/3/x/y/file');
Assert::true(is_file(TEMP_DIR . '/3/x/y/file'));
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just

if (!getenv('SKIP_ONLINE_TESTS')) {
    FileSystem::copy('http://example.com', TEMP_DIR . '/3/x/y/file');
    Assert::true(is_file(TEMP_DIR . '/3/x/y/file'));
}

?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else is needed because '/3/x/y/file' is expected to exists in file "copy" test.


FileSystem::write(TEMP_DIR . '/5/newfile', 'World');

Expand All @@ -51,10 +56,17 @@ test(function () { // copy
}, 'Nette\InvalidStateException', "File or directory '%a%' already exists.");
Assert::same('Hello', file_get_contents(TEMP_DIR . '/3/x/file'));

Assert::exception(function () {
FileSystem::copy('http://example.com', TEMP_DIR . '/3/x/file', FALSE);
}, 'Nette\InvalidStateException', "File or directory '%a%' already exists.");
Assert::same('Hello', file_get_contents(TEMP_DIR . '/3/x/file'));
if (getenv('SKIP_ONLINE_TESTS')) {
Assert::exception(function () {
FileSystem::copy(__FILE__, TEMP_DIR . '/3/x/file', FALSE);
}, 'Nette\InvalidStateException', "File or directory '%a%' already exists.");
Assert::same('Hello', file_get_contents(TEMP_DIR . '/3/x/file'));
} else {
Assert::exception(function () {
FileSystem::copy('http://example.com', TEMP_DIR . '/3/x/file', FALSE);
}, 'Nette\InvalidStateException', "File or directory '%a%' already exists.");
Assert::same('Hello', file_get_contents(TEMP_DIR . '/3/x/file'));
}

FileSystem::copy(TEMP_DIR . '/5/newfile', TEMP_DIR . '/3/x/file');
Assert::same('World', file_get_contents(TEMP_DIR . '/3/x/file'));
Expand Down