@@ -74,6 +74,12 @@ public function testEncryptFile($filename, $contents, $visibility)
74
74
? $ assetStore ->getProtectedFilesystem ()->getAdapter ()
75
75
: $ assetStore ->getPublicFilesystem ()->getAdapter ();
76
76
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
+
77
83
$ file = File::create ();
78
84
$ file ->setFromString ($ originalText , $ originalFilename );
79
85
$ file ->write ();
@@ -84,7 +90,7 @@ public function testEncryptFile($filename, $contents, $visibility)
84
90
$ file ->publishFile ();
85
91
}
86
92
87
- $ oldFilename = $ adapter ->applyPathPrefix (
93
+ $ oldFilename = $ adapter ->$ prefixPath (
88
94
$ strategy ->buildFileID (
89
95
new ParsedFileID (
90
96
$ file ->getFilename (),
@@ -102,9 +108,9 @@ public function testEncryptFile($filename, $contents, $visibility)
102
108
$ this ->assertEquals ($ originalFilename , $ file ->getFilename ());
103
109
104
110
if ($ visibility === AssetStore::VISIBILITY_PROTECTED ) {
105
- $ this ->assertContains ('assets/.protected/ ' , $ oldFilename );
111
+ $ this ->assertStringContainsString ('assets/.protected/ ' , $ oldFilename );
106
112
} elseif ($ visibility === AssetStore::VISIBILITY_PUBLIC ) {
107
- $ this ->assertNotContains ('assets/.protected/ ' , $ oldFilename );
113
+ $ this ->assertStringNotContainsString ('assets/.protected/ ' , $ oldFilename );
108
114
}
109
115
110
116
/** @var AtRestCryptoService $service */
@@ -114,9 +120,9 @@ public function testEncryptFile($filename, $contents, $visibility)
114
120
$ this ->assertEquals ($ originalFilename . '.enc ' , $ encryptedFile ->getFilename ());
115
121
116
122
// Confirm the old file has been deleted
117
- $ this ->assertFileNotExists ($ oldFilename );
123
+ $ this ->assertFileDoesNotExist ($ oldFilename );
118
124
119
- $ encryptedFilename = $ adapter ->applyPathPrefix (
125
+ $ encryptedFilename = $ adapter ->$ prefixPath (
120
126
$ strategy ->buildFileID (
121
127
new ParsedFileID (
122
128
$ encryptedFile ->getFilename (),
@@ -130,20 +136,21 @@ public function testEncryptFile($filename, $contents, $visibility)
130
136
$ this ->assertFileExists ($ encryptedFilename );
131
137
132
138
if ($ visibility === AssetStore::VISIBILITY_PROTECTED ) {
133
- $ this ->assertContains ('assets/.protected/ ' , $ encryptedFilename );
139
+ $ this ->assertStringContainsString ('assets/.protected/ ' , $ encryptedFilename );
134
140
} elseif ($ visibility === AssetStore::VISIBILITY_PUBLIC ) {
135
- $ this ->assertNotContains ('assets/.protected/ ' , $ encryptedFilename );
141
+ $ this ->assertStringNotContainsString ('assets/.protected/ ' , $ encryptedFilename );
136
142
}
137
143
144
+ $ encryptedFileString = $ encryptedFile ->getString () ?: '' ;
138
145
// 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 );
141
148
$ this ->assertEquals ($ originalFilename , $ encryptedFile ->Name );
142
149
$ this ->assertEquals ($ originalFilename . '.enc ' , $ file ->getFilename ());
143
150
144
151
// Now decrypt the file back
145
152
$ decryptedFile = $ service ->decryptFile ($ encryptedFile , null , $ visibility );
146
- $ decryptedFilename = $ adapter ->applyPathPrefix (
153
+ $ decryptedFilename = $ adapter ->$ prefixPath (
147
154
$ strategy ->buildFileID (
148
155
new ParsedFileID (
149
156
$ decryptedFile ->getFilename (),
@@ -160,16 +167,16 @@ public function testEncryptFile($filename, $contents, $visibility)
160
167
$ this ->assertEquals ($ originalFilename , $ decryptedFile ->getFilename ());
161
168
162
169
if ($ visibility === AssetStore::VISIBILITY_PROTECTED ) {
163
- $ this ->assertContains ('assets/.protected/ ' , $ decryptedFilename );
170
+ $ this ->assertStringContainsString ('assets/.protected/ ' , $ decryptedFilename );
164
171
} elseif ($ visibility === AssetStore::VISIBILITY_PUBLIC ) {
165
- $ this ->assertNotContains ('assets/.protected/ ' , $ decryptedFilename );
172
+ $ this ->assertStringNotContainsString ('assets/.protected/ ' , $ decryptedFilename );
166
173
}
167
174
168
175
// Confirm that original text has been decoded properly
169
176
$ this ->assertEquals ($ originalText , $ decryptedFile ->getString ());
170
177
171
178
// Confirm that encrypted file has been deleted
172
- $ this ->assertFileNotExists ($ encryptedFilename );
179
+ $ this ->assertFileDoesNotExist ($ encryptedFilename );
173
180
}
174
181
175
182
/**
0 commit comments