Skip to content

Commit

Permalink
MDL-41022 cleanup core_files_zip_packer_testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Aug 24, 2013
1 parent 4c34571 commit 5f15f7c
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions lib/filestorage/tests/zip_packer_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function test_list_files() {
);

if (function_exists('normalizer_normalize')) {
// Unfortunately there is no way to standardise UTF-8 strings without INTL extension
// Unfortunately there is no way to standardise UTF-8 strings without INTL extension.
$files[] = __DIR__.'/fixtures/test_infozip_3.zip';
$files[] = __DIR__.'/fixtures/test_osx_1074.zip';
$files[] = __DIR__.'/fixtures/test_osx_compress.zip';
Expand All @@ -91,7 +91,7 @@ public function test_list_files() {
$archivefiles = $packer->list_files($archive);
$this->assertTrue(is_array($archivefiles), "Archive not extracted properly: ".basename($archive).' ');
$this->assertTrue(count($this->files) === count($archivefiles) or count($this->files) === count($archivefiles) - 1); // Some zippers create empty dirs.
foreach($archivefiles as $file) {
foreach ($archivefiles as $file) {
if ($file->pathname === 'Žluťoučký/') {
// Some zippers create empty dirs.
continue;
Expand All @@ -100,12 +100,12 @@ public function test_list_files() {
}
}

// Windows packer supports only DOS encoding
// Windows packer supports only DOS encoding.
$archive = __DIR__.'/fixtures/test_win8_de.zip';
$archivefiles = $packer->list_files($archive);
$this->assertTrue(is_array($archivefiles), "Archive not extracted properly: ".basename($archive).' ');
$this->assertEquals(2, count($archivefiles));
foreach($archivefiles as $file) {
foreach ($archivefiles as $file) {
$this->assertTrue($file->pathname === 'Prüfung.txt' or $file->pathname === 'test.test');
}

Expand All @@ -114,7 +114,7 @@ public function test_list_files() {
$archivefiles = $zip_archive->list_files();
$this->assertTrue(is_array($archivefiles), "Archive not extracted properly: ".basename($archive).' ');
$this->assertEquals(3, count($archivefiles));
foreach($archivefiles as $file) {
foreach ($archivefiles as $file) {
$this->assertTrue($file->pathname === 'Žluťoučký/Koníček.txt' or $file->pathname === 'testíček.txt' or $file->pathname === 'test.test');
}
$zip_archive->close();
Expand Down Expand Up @@ -144,7 +144,7 @@ public function test_archive_to_pathname() {
$archivefiles = $packer->list_files($archive);
$this->assertTrue(is_array($archivefiles));
$this->assertEquals(count($this->files), count($archivefiles));
foreach($archivefiles as $file) {
foreach ($archivefiles as $file) {
$this->assertArrayHasKey($file->pathname, $this->files);
}

Expand Down Expand Up @@ -201,7 +201,7 @@ public function test_archive_to_storage() {
$archivefiles = $result->list_files($packer);
$this->assertTrue(is_array($archivefiles));
$this->assertEquals(count($this->files), count($archivefiles));
foreach($archivefiles as $file) {
foreach ($archivefiles as $file) {
$this->assertArrayHasKey($file->pathname, $this->files);
}
}
Expand Down Expand Up @@ -229,7 +229,7 @@ public function test_extract_to_pathname() {
$result = $packer->extract_to_pathname($archive, $target);
$this->assertTrue(is_array($result));
$this->assertEquals(count($this->files), count($result));
foreach($this->files as $file=>$unused) {
foreach ($this->files as $file => $unused) {
$this->assertTrue($result[$file]);
$this->assertFileExists($target.$file);
$this->assertSame($testcontent, file_get_contents($target.$file));
Expand All @@ -240,7 +240,7 @@ public function test_extract_to_pathname() {
$result = $packer->extract_to_pathname($archive, $target);
$this->assertTrue(is_array($result));
$this->assertEquals(count($this->files), count($result));
foreach($this->files as $file=>$unused) {
foreach ($this->files as $file => $unused) {
$this->assertTrue($result[$file]);
$this->assertFileExists($target.$file);
$this->assertSame($testcontent, file_get_contents($target.$file));
Expand Down Expand Up @@ -275,12 +275,12 @@ public function test_extract_to_pathname_onlyfiles() {
$this->assertTrue(is_array($result));
$this->assertEquals(count($willbeextracted), count($result));

foreach($willbeextracted as $file) {
foreach ($willbeextracted as $file) {
$this->assertTrue($result[$file]);
$this->assertFileExists($target.$file);
$this->assertSame($testcontent, file_get_contents($target.$file));
}
foreach($donotextract as $file) {
foreach ($donotextract as $file) {
$this->assertFalse(isset($result[$file]));
$this->assertFileNotExists($target.$file);
}
Expand All @@ -306,7 +306,7 @@ public function test_extract_to_storage() {
$result = $packer->extract_to_storage($archive, $context->id, 'phpunit', 'target', 0, '/');
$this->assertTrue(is_array($result));
$this->assertEquals(count($this->files), count($result));
foreach($this->files as $file=>$unused) {
foreach ($this->files as $file => $unused) {
$this->assertTrue($result[$file]);
$stored_file = $fs->get_file_by_hash(sha1("/$context->id/phpunit/target/0/$file"));
$this->assertInstanceOf('stored_file', $stored_file);
Expand All @@ -318,7 +318,7 @@ public function test_extract_to_storage() {
$result = $packer->extract_to_storage($archive, $context->id, 'phpunit', 'target', 0, '/');
$this->assertTrue(is_array($result));
$this->assertEquals(count($this->files), count($result));
foreach($this->files as $file=>$unused) {
foreach ($this->files as $file => $unused) {
$this->assertTrue($result[$file]);
$stored_file = $fs->get_file_by_hash(sha1("/$context->id/phpunit/target/0/$file"));
$this->assertInstanceOf('stored_file', $stored_file);
Expand Down

0 comments on commit 5f15f7c

Please sign in to comment.