Backend\Modules\Extensions\Tests\UploadThemeTest::testUploadThemeZipGithub PHP Method

testUploadThemeZipGithub() public method

Test if we can upload a theme with a zip that contains a subfolder containing the themefiles.
public testUploadThemeZipGithub ( ) : void
return void
    public function testUploadThemeZipGithub()
    {
        // Generate zip with no info.xml
        $this->fileName = tempnam(sys_get_temp_dir(), 'Theme');
        $filePath = $this->fileName . '.zip';
        $baseName = self::THEME_NAME;
        $archive = new ZipArchive();
        $archive->open($filePath, ZipArchive::CREATE);
        $archive->addEmptyDir($baseName);
        $archive->addFromString("{$baseName}/info.xml", $this->getSampleInfoXmlContents($baseName));
        $archive->close();
        if (file_exists($archive->filename)) {
            throw new FileNotFoundException('Could not create zip file with theme');
        }
        $this->submitThemeUploadForm();
        // We should get a 200 and be redirected to the themes index page.
        self::assertEquals(200, $this->client->getResponse()->getStatusCode());
        self::assertContains(self::URL_THEMES_INDEX, $this->client->getHistory()->current()->getUri());
        self::assertContains(self::THEME_NAME, $this->client->getResponse()->getContent());
    }