@@ -74,6 +74,12 @@ public function testEncryptFile($filename, $contents, $visibility)
7474 ? $ assetStore ->getProtectedFilesystem ()->getAdapter ()
7575 : $ assetStore ->getPublicFilesystem ()->getAdapter ();
7676
77+ // Check for existence of $adaptor->prefixPath() showing we are using SS5.0+
78+ $ prefixPath = 'applyPathPrefix ' ;
79+ if (method_exists ($ adapter , 'prefixPath ' )) {
80+ $ prefixPath = 'prefixPath ' ;
81+ }
82+
7783 $ file = File::create ();
7884 $ file ->setFromString ($ originalText , $ originalFilename );
7985 $ file ->write ();
@@ -84,7 +90,7 @@ public function testEncryptFile($filename, $contents, $visibility)
8490 $ file ->publishFile ();
8591 }
8692
87- $ oldFilename = $ adapter ->applyPathPrefix (
93+ $ oldFilename = $ adapter ->$ prefixPath (
8894 $ strategy ->buildFileID (
8995 new ParsedFileID (
9096 $ file ->getFilename (),
@@ -102,9 +108,9 @@ public function testEncryptFile($filename, $contents, $visibility)
102108 $ this ->assertEquals ($ originalFilename , $ file ->getFilename ());
103109
104110 if ($ visibility === AssetStore::VISIBILITY_PROTECTED ) {
105- $ this ->assertContains ('assets/.protected/ ' , $ oldFilename );
111+ $ this ->assertStringContainsString ('assets/.protected/ ' , $ oldFilename );
106112 } elseif ($ visibility === AssetStore::VISIBILITY_PUBLIC ) {
107- $ this ->assertNotContains ('assets/.protected/ ' , $ oldFilename );
113+ $ this ->assertStringNotContainsString ('assets/.protected/ ' , $ oldFilename );
108114 }
109115
110116 /** @var AtRestCryptoService $service */
@@ -114,9 +120,9 @@ public function testEncryptFile($filename, $contents, $visibility)
114120 $ this ->assertEquals ($ originalFilename . '.enc ' , $ encryptedFile ->getFilename ());
115121
116122 // Confirm the old file has been deleted
117- $ this ->assertFileNotExists ($ oldFilename );
123+ $ this ->assertFileDoesNotExist ($ oldFilename );
118124
119- $ encryptedFilename = $ adapter ->applyPathPrefix (
125+ $ encryptedFilename = $ adapter ->$ prefixPath (
120126 $ strategy ->buildFileID (
121127 new ParsedFileID (
122128 $ encryptedFile ->getFilename (),
@@ -130,20 +136,21 @@ public function testEncryptFile($filename, $contents, $visibility)
130136 $ this ->assertFileExists ($ encryptedFilename );
131137
132138 if ($ visibility === AssetStore::VISIBILITY_PROTECTED ) {
133- $ this ->assertContains ('assets/.protected/ ' , $ encryptedFilename );
139+ $ this ->assertStringContainsString ('assets/.protected/ ' , $ encryptedFilename );
134140 } elseif ($ visibility === AssetStore::VISIBILITY_PUBLIC ) {
135- $ this ->assertNotContains ('assets/.protected/ ' , $ encryptedFilename );
141+ $ this ->assertStringNotContainsString ('assets/.protected/ ' , $ encryptedFilename );
136142 }
137143
144+ $ encryptedFileString = $ encryptedFile ->getString () ?: '' ;
138145 // Confirm the new file is encrypted
139- $ this ->assertFalse (ctype_print ($ encryptedFile -> getString () ));
140- $ this ->assertNotEquals ($ originalText , $ encryptedFile -> getString () );
146+ $ this ->assertFalse (ctype_print ($ encryptedFileString ));
147+ $ this ->assertNotEquals ($ originalText , $ encryptedFileString );
141148 $ this ->assertEquals ($ originalFilename , $ encryptedFile ->Name );
142149 $ this ->assertEquals ($ originalFilename . '.enc ' , $ file ->getFilename ());
143150
144151 // Now decrypt the file back
145152 $ decryptedFile = $ service ->decryptFile ($ encryptedFile , null , $ visibility );
146- $ decryptedFilename = $ adapter ->applyPathPrefix (
153+ $ decryptedFilename = $ adapter ->$ prefixPath (
147154 $ strategy ->buildFileID (
148155 new ParsedFileID (
149156 $ decryptedFile ->getFilename (),
@@ -160,16 +167,16 @@ public function testEncryptFile($filename, $contents, $visibility)
160167 $ this ->assertEquals ($ originalFilename , $ decryptedFile ->getFilename ());
161168
162169 if ($ visibility === AssetStore::VISIBILITY_PROTECTED ) {
163- $ this ->assertContains ('assets/.protected/ ' , $ decryptedFilename );
170+ $ this ->assertStringContainsString ('assets/.protected/ ' , $ decryptedFilename );
164171 } elseif ($ visibility === AssetStore::VISIBILITY_PUBLIC ) {
165- $ this ->assertNotContains ('assets/.protected/ ' , $ decryptedFilename );
172+ $ this ->assertStringNotContainsString ('assets/.protected/ ' , $ decryptedFilename );
166173 }
167174
168175 // Confirm that original text has been decoded properly
169176 $ this ->assertEquals ($ originalText , $ decryptedFile ->getString ());
170177
171178 // Confirm that encrypted file has been deleted
172- $ this ->assertFileNotExists ($ encryptedFilename );
179+ $ this ->assertFileDoesNotExist ($ encryptedFilename );
173180 }
174181
175182 /**
0 commit comments