@@ -15,7 +15,7 @@ abstract class AbstractZipAdapter extends \PHPUnit\Framework\TestCase
1515 /**
1616 * Returns a new instance of the adapter to test
1717 *
18- * @return \PhpOffice\Common\Adapter\Zip\ ZipInterface
18+ * @return ZipInterface
1919 */
2020 abstract protected function createAdapter (): ZipInterface ;
2121
@@ -50,17 +50,43 @@ public function testClose(): void
5050 $ this ->assertSame ($ adapter , $ adapter ->close ());
5151 }
5252
53- public function testAddFromString (): void
53+ public function testAddFromStringWithCompression (): void
5454 {
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+ );
5762
5863 $ adapter = $ this ->createAdapter ();
5964 $ adapter ->open ($ this ->zipTest );
60- $ this ->assertSame ($ adapter , $ adapter ->addFromString ($ expectedPath , $ expectedContent ));
65+ $ this ->assertSame ($ adapter , $ adapter ->addFromString ($ expectedPath , $ expectedContent, true ));
6166 $ adapter ->close ();
6267
6368 $ 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 ));
6490 $ this ->assertTrue (TestHelperZip::assertFileContent ($ this ->zipTest , $ expectedPath , $ expectedContent ));
6591 }
6692}
0 commit comments