public function testDeleteArchiveBuilder() { /** @var AbstractArchiveBuilder $instance */ $instance = $this->getMock("Thelia\\Core\\FileFormat\\Archive\\AbstractArchiveBuilder", ["isAvailable", "getName", "getExtension", "getMimeType", "addFile", "addFileFromString", "getFileContent", "deleteFile", "addDirectory", "buildArchiveResponse", "loadArchive", "hasFile", "hasDirectory"]); $instance->expects($this->any())->method("isAvailable")->willReturn(true); $instance->expects($this->any())->method("getName")->willReturn("foo"); $this->manager->add($instance); $this->manager->delete($instance->getName()); $this->assertTrue(count($this->manager->getAll()) === 0); }
/** * @return mixed */ protected function buildContainer(ContainerBuilder $container) { $cacheDir = THELIA_CACHE_DIR . "test"; if (!is_dir($cacheDir)) { mkdir($cacheDir); } $archiveBuilders = [new ZipArchiveBuilder(), new TarArchiveBuilder(), new TarBz2ArchiveBuilder(), new TarGzArchiveBuilder()]; $archiveBuilderManager = new ArchiveBuilderManager("test"); /** * @var \Thelia\Core\FileFormat\Archive\AbstractArchiveBuilder $archiveBuilder */ foreach ($archiveBuilders as $key => $archiveBuilder) { if (!$archiveBuilder->isAvailable()) { unset($archiveBuilders[$key]); } else { $archiveBuilderManager->add($archiveBuilder); } } if (empty($archiveBuilders)) { $this->markTestSkipped("You don't have any archive builder, you can't run this test"); } $container->set("thelia.manager.archive_builder_manager", $archiveBuilderManager); $formatterManager = (new FormatterManager())->add(new XMLFormatter())->add(new JsonFormatter())->add(new CSVFormatter()); $container->set("thelia.manager.formatter_manager", $formatterManager); }