| | 217 | * When the index.html file cannot be created an error should be displayed. |
| | 218 | * |
| | 219 | * @ticket 44233 |
| | 220 | */ |
| | 221 | public function test_detects_cannot_create_index() { |
| | 222 | // Make the export directory read only so the index.html file can't be created. |
| | 223 | mkdir( self::$exports_dir ); |
| | 224 | chmod( self::$exports_dir, 0444 ); |
| | 225 | |
| | 226 | if ( '444' !== substr( decoct( fileperms( self::$exports_dir ) ), -3 ) ) { |
| | 227 | $this->markTestSkipped( 'Data export directory permissions were not changed correctly.' ); |
| | 228 | } |
| | 229 | |
| | 230 | $this->setExpectedException( 'WPDieException' ); |
| | 231 | $this->expectOutputString( '{"success":false,"data":"Unable to protect export folder from browsing."}' ); |
| | 232 | wp_privacy_generate_personal_data_export_file( self::$export_request_id ); |
| | 233 | } |
| | 234 | |
| | 235 | /** |
| | 248 | * When the export directory is not writable the report should fail to write. |
| | 249 | * |
| | 250 | * @ticket 44233 |
| | 251 | */ |
| | 252 | public function test_detects_cannot_write_html() { |
| | 253 | // Make the folder read only so HTML writing will fail. |
| | 254 | mkdir( self::$exports_dir ); |
| | 255 | touch( self::$exports_dir . 'index.html' ); |
| | 256 | chmod( self::$exports_dir, 0555 ); |
| | 257 | |
| | 258 | if ( '555' !== substr( decoct( fileperms( self::$exports_dir ) ), -3 ) ) { |
| | 259 | $this->markTestSkipped( 'Data export directory permissions were not changed correctly.' ); |
| | 260 | } |
| | 261 | |
| | 262 | $this->setExpectedException( 'WPDieException' ); |
| | 263 | $this->expectOutputString( '{"success":false,"data":"Unable to open export file (HTML report) for writing."}' ); |
| | 264 | wp_privacy_generate_personal_data_export_file( self::$export_request_id ); |
| | 265 | |
| | 266 | $this->assertEmpty( $this->export_file_name ); |
| | 267 | } |
| | 268 | |
| | 269 | /** |