/** * Assert Link block for downloadable product on front-end * * @param CatalogProductView $downloadableProductView * @param CatalogProductDownloadable $product * @param Browser $browser * @return void */ public function processAssert(CatalogProductView $downloadableProductView, CatalogProductDownloadable $product, Browser $browser) { $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); $linksBlock = $downloadableProductView->getDownloadableViewBlock()->getDownloadableLinksBlock(); $fields = $product->getData(); // Title for for Link block \PHPUnit_Framework_Assert::assertEquals($linksBlock->getTitleForLinkBlock(), $fields['downloadable_links']['title'], 'Title for for Link block for downloadable product on front-end is not correct.'); $this->sortDownloadableArray($fields['downloadable_links']['downloadable']['link']); foreach ($fields['downloadable_links']['downloadable']['link'] as $index => $link) { $index++; // Titles for each links // Links are displaying according to Sort Order \PHPUnit_Framework_Assert::assertEquals($linksBlock->getItemTitle($index), $link['title'], 'Link item ' . $index . ' with title "' . $link['title'] . '" is not visible.'); // If Links can be Purchase Separately, check-nob is presented near each link // If Links CANNOT be Purchase Separately, check-nob is not presented near each link if ($fields['downloadable_links']['links_purchased_separately'] == "Yes") { \PHPUnit_Framework_Assert::assertTrue($linksBlock->isVisibleItemCheckbox($index), 'Item ' . $index . ' link block CANNOT be Purchase Separately.'); // Price is equals passed according to fixture $link['price'] = sprintf('$%1.2f', $link['price']); \PHPUnit_Framework_Assert::assertEquals($linksBlock->getItemPrice($index), $link['price'], 'Link item ' . $index . ' price is not visible.'); } elseif ($fields['downloadable_links']['links_purchased_separately'] == "No") { \PHPUnit_Framework_Assert::assertFalse($linksBlock->isVisibleItemCheckbox($index), 'Item ' . $index . ' link block can be Purchase Separately.'); } } }
/** * Assert Sample block for downloadable product on front-end * * @param CatalogProductView $productView * @param CatalogProductDownloadable $product * @param Browser $browser * @return void */ public function processAssert(CatalogProductView $productView, CatalogProductDownloadable $product, Browser $browser) { $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); $sampleBlock = $productView->getDownloadableViewBlock()->getDownloadableSamplesBlock(); $fields = $product->getData(); // Title for for sample block \PHPUnit_Framework_Assert::assertEquals($sampleBlock->getTitleForSampleBlock(), $fields['downloadable_sample']['title'], 'Title for for Samples block for downloadable product on front-end is not correct.'); $this->sortDownloadableArray($fields['downloadable_sample']['downloadable']['sample']); foreach ($fields['downloadable_sample']['downloadable']['sample'] as $index => $sample) { // Titles for each sample // Samples are displaying according to Sort Order \PHPUnit_Framework_Assert::assertEquals($sampleBlock->getItemTitle(++$index), $sample['title'], 'Sample item ' . $index . ' with title "' . $sample['title'] . '" is not visible.'); } }
/** * Test update downloadable product * * @param CatalogProductDownloadable $product * @param CatalogCategory $category * @return void */ public function testUpdateDownloadableProduct(CatalogProductDownloadable $product, CatalogCategory $category) { $filter = ['sku' => $this->product->getSku()]; $this->catalogProductIndex->open()->getProductGrid()->searchAndOpen($filter); $productBlockForm = $this->catalogProductEdit->getForm(); $productBlockForm->fillProduct($product, $category); $this->catalogProductEdit->getFormAction()->save(); }