protected function setUp() { parent::setUp(); $this->useFilesystemRoot(); $this->loadArea("adminhtml"); $this->config = $this->getObjectManager()->get("Tinify\\Magento\\Model\\Config"); $this->messageList = $this->getObjectManager()->get("Magento\\Framework\\Notification\\MessageList"); $this->configModel = $this->getObjectManager()->get("Magento\\Config\\Model\\Config"); AspectMock\Test::double("Tinify\\Client", ["request" => function () { throw new Tinify\ClientException("error"); }]); Tinify\Tinify::setCompressionCount(6); }
protected function setUp() { parent::setUp(); $this->loadArea("adminhtml"); $logHandler = $this->getObjectManager()->get("Magento\\Framework\\Logger\\Handler\\System"); $this->setProperty($logHandler, "url", $this->getVfs() . "/system.log"); $scopeConfig = $this->getObjectManager()->get("Magento\\Framework\\App\\Config\\MutableScopeConfigInterface"); $scopeConfig->setValue(Model\Config::KEY_PATH, "my_api_key"); $scopeConfig->setValue(Model\Config::TYPES_PATH . "/swatch", 0); $config = $this->getObjectManager()->get("Tinify\\Magento\\Model\\Config"); $this->dir = $config->getMediaDirectory(); $this->dir->create(); $this->pngSuboptimal = file_get_contents(__DIR__ . "/../fixtures/example.png"); $this->dir->writeFile("catalog/product/example.png", $this->pngSuboptimal); $this->jpgSuboptimal = file_get_contents(__DIR__ . "/../fixtures/example.jpg"); $this->dir->writeFile("catalog/product/example.jpg", $this->jpgSuboptimal); $this->pngOptimal = file_get_contents(__DIR__ . "/../fixtures/example-tiny.png"); AspectMock\Test::double("Tinify\\Source", ["fromBuffer" => new Tinify\Result([], $this->pngOptimal)]); $this->image = $this->getObjectManager()->create("Magento\\Catalog\\Model\\Product\\Image"); }