diff options
author | Fyorl <gaelreth@gmail.com> | 2012-08-07 12:25:21 +0100 |
---|---|---|
committer | Fyorl <gaelreth@gmail.com> | 2012-08-28 09:33:31 +0100 |
commit | 570502e4a3a70d63a235ef634560477da8782865 (patch) | |
tree | f64ce4861ff191a37d4ca33cd597386ab5f37064 /tests/compress | |
parent | 012c2817434e6b03b29076c644fb7b0f5fc83ff2 (diff) | |
download | forums-570502e4a3a70d63a235ef634560477da8782865.tar forums-570502e4a3a70d63a235ef634560477da8782865.tar.gz forums-570502e4a3a70d63a235ef634560477da8782865.tar.bz2 forums-570502e4a3a70d63a235ef634560477da8782865.tar.xz forums-570502e4a3a70d63a235ef634560477da8782865.zip |
[ticket/11045] Added tests for file conflicts
PHPBB3-11045
Diffstat (limited to 'tests/compress')
-rw-r--r-- | tests/compress/compress_test.php | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/tests/compress/compress_test.php b/tests/compress/compress_test.php index a88e5e5b32..826abbc0c8 100644 --- a/tests/compress/compress_test.php +++ b/tests/compress/compress_test.php @@ -17,6 +17,7 @@ class phpbb_compress_test extends phpbb_test_case const ARCHIVE_DIR = '/archive/'; private $path; + protected $filelist = array( '1.txt', 'dir/2.txt', @@ -24,6 +25,12 @@ class phpbb_compress_test extends phpbb_test_case 'dir/subdir/4.txt', ); + protected $conflicts = array( + '1_1.txt', + '1_2.txt', + 'dir/2_1.txt', + ); + protected function setUp() { // Required for compress::add_file @@ -81,17 +88,26 @@ class phpbb_compress_test extends phpbb_test_case ); $compress->add_custom_file($this->path . 'dir/3.txt', 'dir/3.txt'); $compress->add_data(file_get_contents($this->path . 'dir/subdir/4.txt'), 'dir/subdir/4.txt'); + + // Add multiples of the same file to check conflicts are handled + $compress->add_file($this->path . '1.txt', $this->path); + $compress->add_file($this->path . '1.txt', $this->path); + $compress->add_file($this->path . 'dir/2.txt', $this->path); } - protected function valid_extraction() + protected function valid_extraction($extra = array()) { - foreach ($this->filelist as $filename) + $filelist = array_merge($this->filelist, $extra); + + foreach ($filelist as $filename) { $path = __DIR__ . self::EXTRACT_DIR . $filename; $this->assertTrue(file_exists($path)); // Check the file's contents is correct - $this->assertEquals(basename($filename, '.txt') . "\n", file_get_contents($path)); + $contents = explode('_', basename($filename, '.txt')); + $contents = $contents[0]; + $this->assertEquals($contents . "\n", file_get_contents($path)); } } @@ -136,7 +152,7 @@ class phpbb_compress_test extends phpbb_test_case $compress->mode = 'r'; $compress->open(); $compress->extract('tests/compress/' . self::EXTRACT_DIR); - $this->valid_extraction(); + $this->valid_extraction($this->conflicts); } /** @@ -152,6 +168,6 @@ class phpbb_compress_test extends phpbb_test_case $compress = new compress_zip('r', $zip); $compress->extract('tests/compress/' . self::EXTRACT_DIR); - $this->valid_extraction(); + $this->valid_extraction($this->conflicts); } } |