/** @test * */ public function updateAsset_UsesTheDefaultThemeIdWhenNoneIsGiven() { // Arrange $assetKey = "an/asset.txt"; $newContent = "This is new content"; $expectedThemeId = 828155753; $this->wrapperMock->expects($this->once())->method("get")->with(ShopifyEndpoints::themesIndex())->willReturn(StubApiResponses\Theme::$themesIndex); $this->wrapperMock->expects($this->once())->method("put")->with(ShopifyEndpoints::updateAsset($expectedThemeId), ["asset" => ["key" => $assetKey, "value" => $newContent]])->willReturn(["asset" => ["key" => $assetKey, "public_url" => null, "created_at" => "2010-01-01T00:00:00-00:00", "updated_at" => "2010-01-01T00:00:00-00:00", "content_type" => "text\\plain", "size" => sizeof($newContent), "theme_id" => $expectedThemeId]]); // Act $this->clientWithMock->updateAsset($assetKey, AssetType::Text, $newContent); }
/** * @param int $themeId * @param string $filePath * @param string $asset * @return void */ public function execute($themeId, $filePath, $asset) { $assetType = $this->isImage($filePath) ? AssetType::Image : AssetType::Text; $this->shopify->updateAsset($asset, $assetType, file_get_contents($filePath), $themeId); }