' ); $this->assertNotFalse($document); $tmpFile = tempnam('./', 'open-document-test'); $this->assertNotFalse($tmpFile); $this->assertNotFalse(file_put_contents($tmpFile, $document), 'The temp file should be written'); $zipExtension = new ZipExtension(new ZipArchive()); $this->assertSame([ 'error' => '', 'data' => 'application/vnd.oasis.opendocument.text', ], $zipExtension->getContents($tmpFile)); $this->assertSame([ 'error' => '', 'data' => '', ], $zipExtension->getContents($tmpFile, '/content\.xml/')); $dateTimeCreation = (new DateTime())->format('Y-m-d\TH:i'); $this->assertStringContainsString( // Do not use a full version or seconds could be out of sync and cause flaky test failures '' . $dateTimeCreation, $zipExtension->getContents($tmpFile, '/meta\.xml/')['data'] ); $this->assertSame(5, $zipExtension->getNumberOfFiles($tmpFile)); // Unset to close any file that were left open. unset($zipExtension); $this->assertTrue(unlink($tmpFile)); } }