@@ -15,7 +15,7 @@ abstract class AbstractZipAdapter extends \PHPUnit\Framework\TestCase
15
15
/**
16
16
* Returns a new instance of the adapter to test
17
17
*
18
- * @return \PhpOffice\Common\Adapter\Zip\ ZipInterface
18
+ * @return ZipInterface
19
19
*/
20
20
abstract protected function createAdapter (): ZipInterface ;
21
21
@@ -50,17 +50,43 @@ public function testClose(): void
50
50
$ this ->assertSame ($ adapter , $ adapter ->close ());
51
51
}
52
52
53
- public function testAddFromString (): void
53
+ public function testAddFromStringWithCompression (): void
54
54
{
55
- $ expectedPath = 'file.test ' ;
56
- $ expectedContent = 'Content ' ;
55
+ $ expectedPath = 'file.png ' ;
56
+ $ expectedContent = file_get_contents (
57
+ PHPOFFICE_COMMON_TESTS_BASE_DIR
58
+ . DIRECTORY_SEPARATOR . 'resources '
59
+ . DIRECTORY_SEPARATOR . 'images '
60
+ . DIRECTORY_SEPARATOR . 'PHPPowerPointLogo.png '
61
+ );
57
62
58
63
$ adapter = $ this ->createAdapter ();
59
64
$ adapter ->open ($ this ->zipTest );
60
- $ this ->assertSame ($ adapter , $ adapter ->addFromString ($ expectedPath , $ expectedContent ));
65
+ $ this ->assertSame ($ adapter , $ adapter ->addFromString ($ expectedPath , $ expectedContent, true ));
61
66
$ adapter ->close ();
62
67
63
68
$ this ->assertTrue (TestHelperZip::assertFileExists ($ this ->zipTest , $ expectedPath ));
69
+ $ this ->assertTrue (TestHelperZip::assertFileIsCompressed ($ this ->zipTest , $ expectedPath ));
70
+ $ this ->assertTrue (TestHelperZip::assertFileContent ($ this ->zipTest , $ expectedPath , $ expectedContent ));
71
+ }
72
+
73
+ public function testAddFromStringWithNoCompression (): void
74
+ {
75
+ $ expectedPath = 'file.png ' ;
76
+ $ expectedContent = file_get_contents (
77
+ PHPOFFICE_COMMON_TESTS_BASE_DIR
78
+ . DIRECTORY_SEPARATOR . 'resources '
79
+ . DIRECTORY_SEPARATOR . 'images '
80
+ . DIRECTORY_SEPARATOR . 'PHPPowerPointLogo.png '
81
+ );
82
+
83
+ $ adapter = $ this ->createAdapter ();
84
+ $ adapter ->open ($ this ->zipTest );
85
+ $ this ->assertSame ($ adapter , $ adapter ->addFromString ($ expectedPath , $ expectedContent , false ));
86
+ $ adapter ->close ();
87
+
88
+ $ this ->assertTrue (TestHelperZip::assertFileExists ($ this ->zipTest , $ expectedPath ));
89
+ $ this ->assertFalse (TestHelperZip::assertFileIsCompressed ($ this ->zipTest , $ expectedPath ));
64
90
$ this ->assertTrue (TestHelperZip::assertFileContent ($ this ->zipTest , $ expectedPath , $ expectedContent ));
65
91
}
66
92
}
0 commit comments