diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js index fb15e47eaf7d487da1c8671c545f0b99ce2a7445..78bd0ca73c495785f981a6d2d6ef8e4957fe6d9b 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js @@ -242,7 +242,7 @@ define( emailValidationResult = customer.isLoggedIn(); if (!quote.shippingMethod()) { - this.errorValidationMessage($.mage.__('Please specify a shipping method.')); + this.errorValidationMessage($t('Please specify a shipping method.')); return false; } diff --git a/app/code/Magento/Customer/view/frontend/web/js/view/authentication-popup.js b/app/code/Magento/Customer/view/frontend/web/js/view/authentication-popup.js index 649238a81d1f714cf6f6ac282b2695dec0a36fbf..0dca72ade73b69a4c7603e31286a68162809976f 100644 --- a/app/code/Magento/Customer/view/frontend/web/js/view/authentication-popup.js +++ b/app/code/Magento/Customer/view/frontend/web/js/view/authentication-popup.js @@ -69,19 +69,24 @@ define( }, /** Provide login action */ - login: function (loginForm) { + login: function (formUiElement, event) { var loginData = {}, - formDataArray = $(loginForm).serializeArray(); + formElement = $(event.currentTarget), + formDataArray = formElement.serializeArray(); + + event.stopPropagation(); formDataArray.forEach(function (entry) { loginData[entry.name] = entry.value; }); - if ($(loginForm).validation() && - $(loginForm).validation('isValid') + if (formElement.validation() && + formElement.validation('isValid') ) { this.isLoading(true); - loginAction(loginData, null, false); + loginAction(loginData); } + + return false; } }); } diff --git a/app/code/Magento/Customer/view/frontend/web/template/authentication-popup.html b/app/code/Magento/Customer/view/frontend/web/template/authentication-popup.html index 9ad2cf5265043b4fd1850514258d99276d500ff3..db9c0a3819ffdbaf09b4cfb4ea1d4385909160d9 100644 --- a/app/code/Magento/Customer/view/frontend/web/template/authentication-popup.html +++ b/app/code/Magento/Customer/view/frontend/web/template/authentication-popup.html @@ -50,7 +50,7 @@ <div class="block-content" aria-labelledby="block-customer-login-heading"> <form class="form form-login" method="post" - data-bind="submit:login" + data-bind="event: {submit: login }" id="login-form"> <div class="fieldset login" data-bind="attr: {'data-hasrequired': $t('* Required Fields')}"> <div class="field email required"> diff --git a/app/code/Magento/Search/Controller/Adminhtml/Term/ExportSearchCsv.php b/app/code/Magento/Search/Controller/Adminhtml/Term/ExportSearchCsv.php index 0d1de5cf80cc3463a8c24f3c36a61b4b40286d94..6b13fbc24953292a01326a819aeb8e325711eba2 100644 --- a/app/code/Magento/Search/Controller/Adminhtml/Term/ExportSearchCsv.php +++ b/app/code/Magento/Search/Controller/Adminhtml/Term/ExportSearchCsv.php @@ -40,6 +40,6 @@ class ExportSearchCsv extends TermController /** @var \Magento\Framework\View\Result\Layout $resultLayout */ $resultLayout = $this->resultFactory->create(ResultFactory::TYPE_LAYOUT); $content = $resultLayout->getLayout()->getChildBlock('adminhtml.report.search.grid', 'grid.export'); - return $this->fileFactory->create(\search.csv::class, $content->getCsvFile(), DirectoryList::VAR_DIR); + return $this->fileFactory->create('search.csv', $content->getCsvFile(), DirectoryList::VAR_DIR); } } diff --git a/app/code/Magento/Search/Test/Unit/Controller/Adminhtml/Term/ExportSearchCsvTest.php b/app/code/Magento/Search/Test/Unit/Controller/Adminhtml/Term/ExportSearchCsvTest.php new file mode 100644 index 0000000000000000000000000000000000000000..041d14899d5b683693175399cf2836d7b56209b1 --- /dev/null +++ b/app/code/Magento/Search/Test/Unit/Controller/Adminhtml/Term/ExportSearchCsvTest.php @@ -0,0 +1,85 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Search\Test\Unit\Controller\Adminhtml\Term; + +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +use Magento\Framework\Controller\ResultFactory; +use Magento\Framework\App\Filesystem\DirectoryList; + +class ExportSearchCsvTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\TaxImportExport\Controller\Adminhtml\Rate\ExportPost + */ + private $controller; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $fileFactoryMock; + + /** + * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager + */ + private $objectManagerHelper; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $resultFactoryMock; + + protected function setUp() + { + $this->objectManagerHelper = new ObjectManagerHelper($this); + $this->fileFactoryMock = $this->getMock( + \Magento\Framework\App\Response\Http\FileFactory::class, + [], + [], + '', + false + ); + $this->resultFactoryMock = $this->getMock( + \Magento\Framework\Controller\ResultFactory::class, + [], + [], + '', + false + ); + + $this->controller = $this->objectManagerHelper->getObject( + \Magento\Search\Controller\Adminhtml\Term\ExportSearchCsv::class, + [ + 'fileFactory' => $this->fileFactoryMock, + 'resultFactory' => $this->resultFactoryMock + ] + ); + } + + public function testExecute() + { + $resultLayoutMock = $this->getMock(\Magento\Framework\View\Result\Layout::class, [], [], '', false); + $layoutMock = $this->getMock(\Magento\Framework\View\LayoutInterface::class); + $contentMock = $this->getMock( + \Magento\Framework\View\Element\AbstractBlock::class, + ['getCsvFile'], + [], + '', + false + ); + $this->resultFactoryMock + ->expects($this->once()) + ->method('create') + ->with(ResultFactory::TYPE_LAYOUT)->willReturn($resultLayoutMock); + $resultLayoutMock->expects($this->once())->method('getLayout')->willReturn($layoutMock); + $layoutMock->expects($this->once())->method('getChildBlock')->willReturn($contentMock); + $contentMock->expects($this->once())->method('getCsvFile')->willReturn('csvFile'); + $this->fileFactoryMock + ->expects($this->once()) + ->method('create') + ->with('search.csv', 'csvFile', DirectoryList::VAR_DIR); + $this->controller->execute(); + } +} diff --git a/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ExportPost.php b/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ExportPost.php index cceb0c6de9fd63b4cf773ad778a27967bad8033d..351a2fe50d46a3b178be6514acbb9244ed2f53ad 100644 --- a/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ExportPost.php +++ b/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ExportPost.php @@ -81,7 +81,7 @@ class ExportPost extends \Magento\TaxImportExport\Controller\Adminhtml\Rate $content .= $rate->toString($template) . "\n"; } - return $this->fileFactory->create(\tax_rates.csv::class, $content, DirectoryList::VAR_DIR); + return $this->fileFactory->create('tax_rates.csv', $content, DirectoryList::VAR_DIR); } /** diff --git a/app/code/Magento/TaxImportExport/Test/Unit/Controller/Adminhtml/Rate/ExportPostTest.php b/app/code/Magento/TaxImportExport/Test/Unit/Controller/Adminhtml/Rate/ExportPostTest.php new file mode 100644 index 0000000000000000000000000000000000000000..744ad42c66d39d7358e7a28f2b98ec45fabadf11 --- /dev/null +++ b/app/code/Magento/TaxImportExport/Test/Unit/Controller/Adminhtml/Rate/ExportPostTest.php @@ -0,0 +1,103 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\TaxImportExport\Test\Unit\Controller\Adminhtml\Rate; + +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +use Magento\Framework\App\Filesystem\DirectoryList; + +class ExportPostTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\TaxImportExport\Controller\Adminhtml\Rate\ExportPost + */ + private $controller; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $fileFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $objectManagerMock; + + /** + * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager + */ + private $objectManagerHelper; + + protected function setUp() + { + $this->objectManagerHelper = new ObjectManagerHelper($this); + $this->fileFactoryMock = $this->getMock( + \Magento\Framework\App\Response\Http\FileFactory::class, + [], + [], + '', + false + ); + $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->controller = $this->objectManagerHelper->getObject( + \Magento\TaxImportExport\Controller\Adminhtml\Rate\ExportPost::class, + [ + 'fileFactory' => $this->fileFactoryMock, + 'objectManager' => $this->objectManagerMock + ] + ); + } + + public function testExecute() + { + $headers = new \Magento\Framework\DataObject( + [ + 'code' => __('Code'), + 'country_name' => __('Country'), + 'region_name' => __('State'), + 'tax_postcode' => __('Zip/Post Code'), + 'rate' => __('Rate'), + 'zip_is_range' => __('Zip/Post is Range'), + 'zip_from' => __('Range From'), + 'zip_to' => __('Range To'), + ] + ); + $template = '"{{code}}","{{country_name}}","{{region_name}}","{{tax_postcode}}","{{rate}}"' . + ',"{{zip_is_range}}","{{zip_from}}","{{zip_to}}"'; + $content = $headers->toString($template); + $content .= "\n"; + $storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $storeCollectionMock = $this->objectManagerHelper->getCollectionMock( + \Magento\Store\Model\ResourceModel\Store\Collection::class, + [] + ); + $rateCollectionMock = $this->objectManagerHelper->getCollectionMock( + \Magento\Tax\Model\ResourceModel\Calculation\Rate\Collection::class, + [] + ); + + $taxCollectionMock = $this->objectManagerHelper->getCollectionMock( + \Magento\Tax\Model\ResourceModel\Calculation\Rate\Title\Collection::class, + [] + ); + $storeCollectionMock->expects($this->once())->method('setLoadDefault')->willReturnSelf(); + $rateTitleMock = $this->getMock(\Magento\Tax\Model\Calculation\Rate\Title::class, [], [], '', false); + $rateTitleMock->expects($this->once())->method('getCollection')->willReturn($taxCollectionMock); + $storeMock->expects($this->once())->method('getCollection')->willReturn($storeCollectionMock); + $this->objectManagerMock->expects($this->any())->method('create')->willReturnMap([ + [\Magento\Store\Model\Store::class, [], $storeMock], + [\Magento\Tax\Model\Calculation\Rate\Title::class, [], $rateTitleMock], + [\Magento\Tax\Model\ResourceModel\Calculation\Rate\Collection::class, [], $rateCollectionMock] + ]); + $rateCollectionMock->expects($this->once())->method('joinCountryTable')->willReturnSelf(); + $rateCollectionMock->expects($this->once())->method('joinRegionTable')->willReturnSelf(); + $this->fileFactoryMock + ->expects($this->once()) + ->method('create') + ->with('tax_rates.csv', $content, DirectoryList::VAR_DIR); + $this->controller->execute(); + } +} diff --git a/app/design/frontend/Magento/luma/Magento_Customer/web/css/source/_module.less b/app/design/frontend/Magento/luma/Magento_Customer/web/css/source/_module.less index 799094cf93d7cfa4ffcfb6b32a2767e93c882a06..3273df52b8d622146ab134184ec607503938e51a 100644 --- a/app/design/frontend/Magento/luma/Magento_Customer/web/css/source/_module.less +++ b/app/design/frontend/Magento/luma/Magento_Customer/web/css/source/_module.less @@ -319,6 +319,11 @@ .order-products-toolbar { position: relative; + + .toolbar-amount { + position: relative; + text-align: center; + } } } diff --git a/app/design/frontend/Magento/luma/Magento_Review/web/css/source/_module.less b/app/design/frontend/Magento/luma/Magento_Review/web/css/source/_module.less index 95ec8b694b1ca5a24dc9af66120acbc857294e5b..c8c885fafda19d5ca6592ff22f37ce0612f82694 100644 --- a/app/design/frontend/Magento/luma/Magento_Review/web/css/source/_module.less +++ b/app/design/frontend/Magento/luma/Magento_Review/web/css/source/_module.less @@ -40,6 +40,7 @@ .review-control-vote { .lib-rating-vote(); + &:before { .lib-rating-icons-content( @_icon-content: @icon-star-empty @@ -47,6 +48,19 @@ } } + // + // Account Review list page + // ----------------------------------------- + + .products-reviews-toolbar { + position: relative; + + .toolbar-amount { + position: relative; + text-align: center; + } + } + // // Review product page // ----------------------------------------- @@ -95,6 +109,7 @@ .fieldset &-legend.legend { border-bottom: 0; line-height: 1.3; + margin-bottom: @indent__base; padding: 0; span { @@ -105,8 +120,6 @@ display: block; font-weight: 600; } - - margin-bottom: @indent__base; } .fieldset &-field-ratings { @@ -189,6 +202,7 @@ margin-bottom: @indent__base; } } + .page-main { .column { .review-add { @@ -284,9 +298,6 @@ a:not(:last-child) { margin-right: 30px; } - - .action.view span { - } } } @@ -331,6 +342,7 @@ .items { .item { .lib-css(margin-bottom, @indent__base); + &:last-child { margin-bottom: 0; } @@ -339,6 +351,7 @@ .product-name { display: inline-block; + &:not(:last-child) { .lib-css(margin-bottom, @indent__xs); } @@ -415,9 +428,6 @@ width: 30%; } - .product-info { - } - .review-details { margin: 0; diff --git a/dev/tests/functional/.htaccess.sample b/dev/tests/functional/.htaccess.sample index f5c3be7db01e97c551085e09a493fceb11e2ad1f..f1e60cf9b67e91779153e4c9d9f780c8f7bc9438 100644 --- a/dev/tests/functional/.htaccess.sample +++ b/dev/tests/functional/.htaccess.sample @@ -1,6 +1,6 @@ ############################################## ## Allow access to command.php and website.php - <FilesMatch "command.php|website.php"> + <FilesMatch "command.php|website.php|export.php"> order allow,deny allow from all </FilesMatch> diff --git a/dev/tests/functional/composer.json b/dev/tests/functional/composer.json index f170114a4ea8348714531af55ca805bb5e3442fe..3567ec530f437996c0ed28d792ebd929d2188e0c 100644 --- a/dev/tests/functional/composer.json +++ b/dev/tests/functional/composer.json @@ -1,6 +1,6 @@ { "require": { - "magento/mtf": "1.0.0-rc50", + "magento/mtf": "1.0.0-rc51", "php": "~5.6.5|7.0.2|~7.0.6", "phpunit/phpunit": "~4.8.0|~5.5.0", "phpunit/phpunit-selenium": ">=1.2" diff --git a/dev/tests/functional/etc/di.xml b/dev/tests/functional/etc/di.xml index 69951a2cc1b86248040074c45ee967c93dc0bb82..b21e507a5af023b18326d2c1cf5bc038a5abdb3a 100644 --- a/dev/tests/functional/etc/di.xml +++ b/dev/tests/functional/etc/di.xml @@ -6,6 +6,11 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> + <preference for="Magento\Mtf\Util\Command\File\ExportInterface" type="\Magento\Mtf\Util\Command\File\Export" /> + <preference for="Magento\Mtf\Util\Command\File\Export\ReaderInterface" type="\Magento\Mtf\Util\Command\File\Export\Reader" /> + + <type name="\Magento\Mtf\Util\Command\File\Export" shared="false" /> + <virtualType name="Magento\Mtf\Config\SchemaLocator\Config" type="Magento\Mtf\Config\SchemaLocator"> <arguments> <argument name="schemaPath" xsi:type="string">etc/config.xsd</argument> @@ -13,4 +18,22 @@ </virtualType> <type name="Magento\Mtf\Util\Protocol\CurlTransport\WebapiDecorator" shared="true" /> + + <type name="Magento\Mtf\Util\Command\File\Export\Reader"> + <arguments> + <argument name="template" xsi:type="string">\w*?\.csv</argument> + </arguments> + </type> + + <virtualType name="Magento\Mtf\Util\Command\File\Export\ProductReader" type="Magento\Mtf\Util\Command\File\Export\Reader"> + <arguments> + <argument name="template" xsi:type="string">catalog_product.*?\.csv</argument> + </arguments> + </virtualType> + + <virtualType name="Magento\Mtf\Util\Command\File\Export\CustomerReader" type="Magento\Mtf\Util\Command\File\Export\Reader"> + <arguments> + <argument name="template" xsi:type="string">customer.*?\.csv</argument> + </arguments> + </virtualType> </config> diff --git a/dev/tests/functional/lib/Magento/Mtf/Util/Command/Cli.php b/dev/tests/functional/lib/Magento/Mtf/Util/Command/Cli.php index 96be468a6eb377f619339c02a2be00835f8425eb..db39bdcb5b7a5e1e323ee434b2e8b1d744b0570a 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Util/Command/Cli.php +++ b/dev/tests/functional/lib/Magento/Mtf/Util/Command/Cli.php @@ -7,7 +7,6 @@ namespace Magento\Mtf\Util\Command; use Magento\Mtf\Util\Protocol\CurlInterface; -use Magento\Mtf\ObjectManager; use Magento\Mtf\Util\Protocol\CurlTransport; /** @@ -28,7 +27,6 @@ class Cli private $transport; /** - * @constructor * @param CurlTransport $transport */ public function __construct(CurlTransport $transport) @@ -61,6 +59,6 @@ class Cli private function prepareUrl($command, array $options) { $command .= ' ' . implode(' ', $options); - return $_ENV['app_frontend_url'] . Cli::URL . '?command=' . urlencode($command); + return $_ENV['app_frontend_url'] . self::URL . '?command=' . urlencode($command); } } diff --git a/dev/tests/functional/lib/Magento/Mtf/Util/Command/File/Export.php b/dev/tests/functional/lib/Magento/Mtf/Util/Command/File/Export.php new file mode 100644 index 0000000000000000000000000000000000000000..6d5defadbc44a5d30e69423cafe96653450f51bf --- /dev/null +++ b/dev/tests/functional/lib/Magento/Mtf/Util/Command/File/Export.php @@ -0,0 +1,131 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Mtf\Util\Command\File; + +use Magento\Mtf\ObjectManagerInterface; +use Magento\Mtf\Util\Command\File\Export\Data; +use Magento\Mtf\Util\Command\File\Export\ReaderInterface; + +/** + * Get Exporting file from the Magento. + */ +class Export implements ExportInterface +{ + /** + * Path to the Reader. + * + * @var string + */ + private $readerPath = 'Magento\Mtf\Util\Command\File\Export\%sReader'; + + /** + * Object manager instance. + * + * @var ObjectManagerInterface + */ + private $objectManager; + + /** + * File reader for Magento export files. + * + * @var ReaderInterface + */ + private $reader; + + /** + * @param ObjectManagerInterface $objectManager + * @param string $type [optional] + */ + public function __construct(ObjectManagerInterface $objectManager, $type = 'product') + { + $this->objectManager = $objectManager; + $this->reader = $this->getReader($type); + } + + /** + * Get reader for export files. + * + * @param string $type + * @return ReaderInterface + * @throws \ReflectionException + */ + private function getReader($type) + { + $readerPath = sprintf($this->readerPath, ucfirst($type)); + try { + return $this->objectManager->create($readerPath); + } catch (\ReflectionException $e) { + throw new \ReflectionException("Virtual type '$readerPath' does not exist. Please, check it in di.xml."); + } + } + + /** + * Get the export file by name. + * + * @param string $name + * @return Data|null + */ + public function getByName($name) + { + $this->reader->getData(); + foreach ($this->reader->getData() as $file) { + if ($file->getName() === $name) { + return $file; + } + } + + return null; + } + + /** + * Get latest created the export file. + * + * @return Data|null + */ + public function getLatest() + { + $max = 0; + $latest = null; + foreach ($this->reader->getData() as $file) { + if ($file->getDate() > $max) { + $max = $file->getDate(); + $latest = $file; + } + } + + return $latest; + } + + /** + * Get all export files by date range using unix time stamp. + * + * @param string $start + * @param string $end + * @return Data[] + */ + public function getByDateRange($start, $end) + { + $files = []; + foreach ($this->reader->getData() as $file) { + if ($file->getDate() > $start && $file->getDate() < $end) { + $files[] = $file; + } + } + + return $files; + } + + /** + * Get all export files. + * + * @return Data[] + */ + public function getAll() + { + return $this->reader->getData(); + } +} diff --git a/dev/tests/functional/lib/Magento/Mtf/Util/Command/File/Export/Data.php b/dev/tests/functional/lib/Magento/Mtf/Util/Command/File/Export/Data.php new file mode 100644 index 0000000000000000000000000000000000000000..a6756aac0052a28bc04cc7c7d420c4ace8d5c472 --- /dev/null +++ b/dev/tests/functional/lib/Magento/Mtf/Util/Command/File/Export/Data.php @@ -0,0 +1,58 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Mtf\Util\Command\File\Export; + +/** + * Data mapping for Export file. + */ +class Data +{ + /** + * File data. + * + * @var array + */ + private $data; + + /** + * @param array $data + */ + public function __construct(array $data) + { + $this->data = $data; + } + + /** + * Get file name. + * + * @return string + */ + public function getName() + { + return $this->data['name']; + } + + /** + * Get file content. + * + * @return string + */ + public function getContent() + { + return $this->data['content']; + } + + /** + * Get file creation date. + * + * @return string + */ + public function getDate() + { + return $this->data['date']; + } +} diff --git a/dev/tests/functional/lib/Magento/Mtf/Util/Command/File/Export/Reader.php b/dev/tests/functional/lib/Magento/Mtf/Util/Command/File/Export/Reader.php new file mode 100644 index 0000000000000000000000000000000000000000..3a8287daae2ab54cc8adbd8fff2249864cbed9a5 --- /dev/null +++ b/dev/tests/functional/lib/Magento/Mtf/Util/Command/File/Export/Reader.php @@ -0,0 +1,89 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Mtf\Util\Command\File\Export; + +use Magento\Mtf\ObjectManagerInterface; +use Magento\Mtf\Util\Protocol\CurlTransport; +use Magento\Mtf\Util\Protocol\CurlInterface; + +/** + * File reader for Magento export files. + */ +class Reader implements ReaderInterface +{ + /** + * Pattern for file name in Magento. + * + * @var string + */ + private $template; + + /** + * Object manager instance. + * + * @var ObjectManagerInterface + */ + private $objectManager; + + /** + * Curl transport protocol. + * + * @var CurlTransport + */ + private $transport; + + /** + * @param ObjectManagerInterface $objectManager + * @param CurlTransport $transport + * @param string $template + */ + public function __construct(ObjectManagerInterface $objectManager, CurlTransport $transport, $template) + { + $this->objectManager = $objectManager; + $this->template = $template; + $this->transport = $transport; + } + + /** + * Exporting files as Data object from Magento. + * + * @return Data[] + */ + public function getData() + { + $data = []; + foreach ($this->getFiles() as $file) { + $data[] = $this->objectManager->create(Data::class, ['data' => $file]); + } + + return $data; + } + + /** + * Get files by template from the Magento. + * + * @return array + */ + private function getFiles() + { + $this->transport->write($this->prepareUrl(), [], CurlInterface::GET); + $serializedFiles = $this->transport->read(); + $this->transport->close(); + + return unserialize($serializedFiles); + } + + /** + * Prepare url. + * + * @return string + */ + private function prepareUrl() + { + return $_ENV['app_frontend_url'] . self::URL . '?template=' . urlencode($this->template); + } +} diff --git a/dev/tests/functional/lib/Magento/Mtf/Util/Command/File/Export/ReaderInterface.php b/dev/tests/functional/lib/Magento/Mtf/Util/Command/File/Export/ReaderInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..5d305513ec68080ec4e7ec6bad8e776f8653bf15 --- /dev/null +++ b/dev/tests/functional/lib/Magento/Mtf/Util/Command/File/Export/ReaderInterface.php @@ -0,0 +1,25 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Mtf\Util\Command\File\Export; + +/** + * File reader interface for Magento export files. + */ +interface ReaderInterface +{ + /** + * Url to export.php. + */ + const URL = 'dev/tests/functional/utils/export.php'; + + /** + * Exporting files as Data object from Magento. + * + * @return Data[] + */ + public function getData(); +} diff --git a/dev/tests/functional/lib/Magento/Mtf/Util/Command/File/ExportInterface.php b/dev/tests/functional/lib/Magento/Mtf/Util/Command/File/ExportInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..0bc4f9e59a2433b1078805e8431f9f45d8d34e20 --- /dev/null +++ b/dev/tests/functional/lib/Magento/Mtf/Util/Command/File/ExportInterface.php @@ -0,0 +1,46 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Mtf\Util\Command\File; + +use Magento\Mtf\Util\Command\File\Export\Data; + +/** + * Interface for getting Exporting file from the Magento. + */ +interface ExportInterface +{ + /** + * Get the export file by name. + * + * @param string $name + * @return Data|null + */ + public function getByName($name); + + /** + * Get latest created the export file. + * + * @return Data|null + */ + public function getLatest(); + + /** + * Get all export files by date range using unix time stamp. + * + * @param string $start + * @param string $end + * @return Data[] + */ + public function getByDateRange($start, $end); + + /** + * Get all export files. + * + * @return Data[] + */ + public function getAll(); +} diff --git a/dev/tests/functional/lib/Magento/Mtf/Util/Command/Website.php b/dev/tests/functional/lib/Magento/Mtf/Util/Command/Website.php index 611f46894c8bca850d10a519fe7a2850f31b5533..d0c4be34888d2ae863173fbbedc203c08d95fb90 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Util/Command/Website.php +++ b/dev/tests/functional/lib/Magento/Mtf/Util/Command/Website.php @@ -58,6 +58,6 @@ class Website */ private function prepareUrl($websiteCode) { - return $_ENV['app_frontend_url'] . Website::URL . '?website_code=' . urlencode($websiteCode); + return $_ENV['app_frontend_url'] . self::URL . '?website_code=' . urlencode($websiteCode); } } diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/InvoicePayPalBraintreeTest.php b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/InvoicePayPalBraintreeTest.php index 062de338d8921e15b786de0fd4b656e824354d80..ca5fbe8799d5144a2a9e68e7b8fbca4530c26790 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/InvoicePayPalBraintreeTest.php +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/InvoicePayPalBraintreeTest.php @@ -33,7 +33,7 @@ class InvoicePayPalBraintreeTest extends Scenario /* end tags */ /** - * Runs one page checkout test. + * Create invoice for order placed within Braintree PayPal. * * @return void */ diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/InvoicePaypalBraintreeTest.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/InvoicePaypalBraintreeTest.xml index 23985d208e5a675b997d330e792eb58f1045d7d9..1d98e2d792a3e75fd815fe78149e43100aad12ae 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/InvoicePaypalBraintreeTest.xml +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/InvoicePaypalBraintreeTest.xml @@ -31,7 +31,7 @@ <constraint name="Magento\Sales\Test\Constraint\AssertOrderButtonsAvailable" /> <constraint name="Magento\Sales\Test\Constraint\AssertInvoiceItems" /> </variation> - <variation name="InvoicePayPalBraintreeTestVariation2" summary="Partial capture for order placed within Braintree PayPal" ticketId="MAGETWO-48615"> + <variation name="InvoicePayPalBraintreeTestVariation2" summary="Partial capture for order placed within Braintree PayPal" ticketId="MAGETWO-48615, MAGETWO-48684"> <data name="description" xsi:type="string">Partial capture for order placed within Braintree PayPal</data> <data name="products/0" xsi:type="string">catalogProductSimple::product_100_dollar</data> <data name="taxRule" xsi:type="string">us_illinois_tax_rule</data> @@ -43,7 +43,6 @@ </data> <data name="capturedPrices" xsi:type="array"> <item name="0" xsi:type="string">118.25</item> - <item name="1" xsi:type="string">108.25</item> </data> <data name="payment/method" xsi:type="string">braintree_paypal</data> <data name="configData" xsi:type="string">braintree, braintree_paypal, braintree_paypal_skip_order_review</data> @@ -51,10 +50,18 @@ <data name="data/items_data/0/qty" xsi:type="string">1</data> <data name="data/form_data/do_shipment" xsi:type="string">No</data> <data name="data/form_data/comment_text" xsi:type="string">comments</data> - <data name="tag" xsi:type="string">test_type:3rd_party_test, severity:S1</data> + <data name="status" xsi:type="string">Processing</data> + <data name="transactions/Capture" xsi:type="array"> + <item name="transactionType" xsi:type="string">Capture</item> + <item name="statusIsClosed" xsi:type="string">No</item> + </data> + <data name="tag" xsi:type="string">test_type:3rd_party_test, severity:S0</data> <constraint name="Magento\Sales\Test\Constraint\AssertInvoiceSuccessCreateMessage" /> <constraint name="Magento\Sales\Test\Constraint\AssertOrderButtonsAvailable" /> - <constraint name="Magento\Sales\Test\Constraint\AssertInvoiceItems" /> + <constraint name="Magento\Sales\Test\Constraint\AssertCaptureInCommentsHistory" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" /> + <constraint name="Magento\Sales\Test\Constraint\AssertInvoiceInInvoicesGrid" /> + <constraint name="Magento\Sales\Test\Constraint\AssertTransactionStatus" /> </variation> </testCase> </config> diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertCancelSuccessMessageInShoppingCart.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertCancelSuccessMessageInShoppingCart.php new file mode 100644 index 0000000000000000000000000000000000000000..d549e14c7afd94bc35d2540662012fd9f970b872 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertCancelSuccessMessageInShoppingCart.php @@ -0,0 +1,47 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Checkout\Test\Constraint; + +use Magento\Checkout\Test\Page\CheckoutCart; +use Magento\Mtf\Constraint\AbstractConstraint; + +/** + * Assert that success message about canceled order is present and correct. + */ +class AssertCancelSuccessMessageInShoppingCart extends AbstractConstraint +{ + /** + * Cancel success message text. + */ + const SUCCESS_MESSAGE = 'Payment was canceled.'; + + /** + * Assert that success message about canceled order is present and correct. + * + * @param CheckoutCart $checkoutCart + * @return void + */ + public function processAssert(CheckoutCart $checkoutCart) + { + $actualMessage = $checkoutCart->getMessagesBlock()->getSuccessMessage(); + \PHPUnit_Framework_Assert::assertEquals( + self::SUCCESS_MESSAGE, + $actualMessage, + 'Success message is not present or has wrong text.' + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Cancel success message is present or has a correct text.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/etc/di.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/etc/di.xml index 9f13d8dddb9a768442f7051a6e11be16f7df9233..0a0622936a23d7688cf0e94b61ebc2ef56d052f4 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/etc/di.xml +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/etc/di.xml @@ -102,11 +102,6 @@ <argument name="severity" xsi:type="string">S2</argument> </arguments> </type> - <type name="Magento\Checkout\Test\Constraint\AssertProductPresentInShoppingCart"> - <arguments> - <argument name="severity" xsi:type="string">S2</argument> - </arguments> - </type> <type name="Magento\Checkout\Test\Constraint\AssertProductQtyInShoppingCart"> <arguments> <argument name="severity" xsi:type="string">S2</argument> @@ -157,4 +152,14 @@ <argument name="severity" xsi:type="string">S2</argument> </arguments> </type> + <type name="Magento\Checkout\Test\Constraint\AssertCancelSuccessMessageInShoppingCart"> + <arguments> + <argument name="severity" xsi:type="string">S1</argument> + </arguments> + </type> + <type name="Magento\Checkout\Test\Constraint\AssertProductPresentInShoppingCart"> + <arguments> + <argument name="severity" xsi:type="string">S0</argument> + </arguments> + </type> </config> diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Address.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Address.xml index 2edc328b5c5df40df321e66a34fa1ee7c6d4e835..6e7e76524557dd6ec875af966ef23e85bef6a73c 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Address.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Address.xml @@ -297,5 +297,17 @@ <field name="region_id" xsi:type="string">California</field> <field name="postcode" xsi:type="string">90230</field> </dataset> + + <dataset name="AVS_street_does_not_match_address"> + <field name="firstname" xsi:type="string">John</field> + <field name="lastname" xsi:type="string">Doe</field> + <field name="company" xsi:type="string">Magento %isolation%</field> + <field name="city" xsi:type="string">Culver City</field> + <field name="street" xsi:type="string">49354 Main</field> + <field name="telephone" xsi:type="string">555-55-555-55</field> + <field name="country_id" xsi:type="string">United States</field> + <field name="region_id" xsi:type="string">California</field> + <field name="postcode" xsi:type="string">90230</field> + </dataset> </repository> </config> diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/Repository/ConfigData.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/Repository/ConfigData.xml index 1669352dc026ef02c295fce1153f63e3beabf225..f1d041f0a5b344fb76e91acd57124eb03d9f6ae8 100644 --- a/dev/tests/functional/tests/app/Magento/Paypal/Test/Repository/ConfigData.xml +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/Repository/ConfigData.xml @@ -25,54 +25,54 @@ </dataset> <dataset name="paypal_direct"> - <field name="payment/paypal_group_all_in_one/wpp_usuk/wpp_required_settings/wpp_and_express_checkout/business_account" xsi:type="array"> + <field name="payment/paypal_group_all_in_one/wpp_usuk/paypal_payflow_required/paypal_payflow_api_settings/business_account" xsi:type="array"> <item name="scope" xsi:type="string">payment</item> <item name="scope_id" xsi:type="number">1</item> - <item name="label" xsi:type="string">Yes</item> - <item name="value" xsi:type="string">PAYPAL_BUSINESS_ACCOUNT</item> + <item name="label" xsi:type="string">Email Associated with PayPal Merchant Account (Optional)</item> + <item name="value" xsi:type="string">%payflow_pro_business_account%</item> </field> - <field name="payment/paypal_group_all_in_one/wpp_usuk/wpp_required_settings/wpp_and_express_checkout/api_username" xsi:type="array"> + <field name="payment/paypal_group_all_in_one/wpp_usuk/paypal_payflow_required/paypal_payflow_api_settings/partner" xsi:type="array"> <item name="scope" xsi:type="string">payment</item> <item name="scope_id" xsi:type="number">1</item> - <item name="label" xsi:type="string"/> - <item name="value" xsi:type="string">PAYPAL_API_USERNAME</item> + <item name="label" xsi:type="string">Partner</item> + <item name="value" xsi:type="string">%payflow_pro_partner%</item> </field> - <field name="payment/paypal_group_all_in_one/wpp_usuk/wpp_required_settings/wpp_and_express_checkout/api_password" xsi:type="array"> + <field name="payment/paypal_group_all_in_one/wpp_usuk/paypal_payflow_required/paypal_payflow_api_settings/user" xsi:type="array"> <item name="scope" xsi:type="string">payment</item> <item name="scope_id" xsi:type="number">1</item> - <item name="label" xsi:type="string"/> - <item name="value" xsi:type="string">PAYPAL_API_PASSWORD</item> + <item name="label" xsi:type="string">User</item> + <item name="value" xsi:type="string">%payflow_pro_user%</item> </field> - <field name="payment/paypal_group_all_in_one/wpp_usuk/wpp_required_settings/wpp_and_express_checkout/api_signature" xsi:type="array"> + <field name="payment/paypal_group_all_in_one/wpp_usuk/paypal_payflow_required/paypal_payflow_api_settings/vendor" xsi:type="array"> <item name="scope" xsi:type="string">payment</item> <item name="scope_id" xsi:type="number">1</item> - <item name="label" xsi:type="string"/> - <item name="value" xsi:type="string">PAYPAL_API_SIGNATURE</item> + <item name="label" xsi:type="string">Vendor</item> + <item name="value" xsi:type="string">%payflow_pro_vendor%</item> </field> - <field name="payment/paypal_group_all_in_one/wpp_usuk/wpp_required_settings/wpp_and_express_checkout/sandbox_flag" xsi:type="array"> + <field name="payment/paypal_group_all_in_one/wpp_usuk/paypal_payflow_required/paypal_payflow_api_settings/pwd" xsi:type="array"> <item name="scope" xsi:type="string">payment</item> <item name="scope_id" xsi:type="number">1</item> - <item name="label" xsi:type="string">Yes</item> - <item name="value" xsi:type="number">1</item> + <item name="label" xsi:type="string">Password</item> + <item name="value" xsi:type="string">%payflow_pro_pwd%</item> </field> - <field name="payment/paypal_direct/debug" xsi:type="array"> + <field name="payment/paypal_group_all_in_one/wpp_usuk/paypal_payflow_required/paypal_payflow_api_settings/sandbox_flag" xsi:type="array"> <item name="scope" xsi:type="string">payment</item> <item name="scope_id" xsi:type="number">1</item> - <item name="label" xsi:type="string">Yes</item> + <item name="label" xsi:type="string">Test Mode</item> <item name="value" xsi:type="number">1</item> </field> - <field name="payment/paypal_direct/active" xsi:type="array"> + <field name="payment/paypal_group_all_in_one/wpp_usuk/paypal_payflow_required/enable_paypal_payflow" xsi:type="array"> <item name="scope" xsi:type="string">payment</item> <item name="scope_id" xsi:type="number">1</item> - <item name="label" xsi:type="string">Yes</item> + <item name="label" xsi:type="string">Enable this Solution</item> <item name="value" xsi:type="number">1</item> </field> </dataset> <dataset name="paypal_direct_rollback"> - <field name="payment/paypal_direct/active" xsi:type="array"> + <field name="payment/paypal_group_all_in_one/wpp_usuk/paypal_payflow_required/enable_paypal_payflow" xsi:type="array"> <item name="scope" xsi:type="string">payment</item> <item name="scope_id" xsi:type="number">1</item> - <item name="label" xsi:type="string">Yes</item> + <item name="label" xsi:type="string">Enable this Solution</item> <item name="value" xsi:type="number">0</item> </field> </dataset> @@ -219,6 +219,23 @@ </field> </dataset> + <dataset name="payflowpro_avs_street_does_not_match"> + <field name="payment/payflowpro/avs_street" xsi:type="array"> + <item name="scope" xsi:type="string">payment</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="label" xsi:type="string">Yes</item> + <item name="value" xsi:type="number">1</item> + </field> + </dataset> + <dataset name="payflowpro_avs_street_does_not_match_rollback"> + <field name="payment/payflowpro/avs_street" xsi:type="array"> + <item name="scope" xsi:type="string">payment</item> + <item name="scope_id" xsi:type="number">1</item> + <item name="label" xsi:type="string">No</item> + <item name="value" xsi:type="number">0</item> + </field> + </dataset> + <dataset name="hosted_pro"> <field name="payment/paypal_group_all_in_one/payments_pro_hosted_solution_with_express_checkout/pphs_required_settings/pphs_required_settings_pphs/business_account" xsi:type="array"> <item name="scope" xsi:type="string">payment</item> diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/CloseOrderTest.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/CloseOrderTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..30385e1cd2006c5dd86f98a8f4da1a9d032c6efd --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/CloseOrderTest.xml @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Sales\Test\TestCase\CloseOrderTest" summary="Close order"> + <variation name="CloseOrderTestWithPayPalPaymentsPro" summary="Close order with PayPal Payments Pro" ticketId="MAGETWO-13015"> + <data name="products/0" xsi:type="string">catalogProductSimple::product_10_dollar</data> + <data name="customer/dataset" xsi:type="string">default</data> + <data name="shippingAddress/dataset" xsi:type="string">US_address_1_without_email</data> + <data name="checkoutMethod" xsi:type="string">guest</data> + <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> + <data name="shipping/shipping_method" xsi:type="string">Fixed</data> + <data name="payment/method" xsi:type="string">payflowpro</data> + <data name="prices" xsi:type="array"> + <item name="grandTotal" xsi:type="string">15.00</item> + </data> + <data name="capturedPrices" xsi:type="array"> + <item name="0" xsi:type="string">15.00</item> + </data> + <data name="creditCard/dataset" xsi:type="string">visa_default</data> + <data name="status" xsi:type="string">Complete</data> + <data name="configData" xsi:type="string">paypal_direct</data> + <data name="tag" xsi:type="string">test_type:3rd_party_test, severity:S0</data> + <constraint name="Magento\Sales\Test\Constraint\AssertCaptureInCommentsHistory" /> + <constraint name="Magento\Sales\Test\Constraint\AssertInvoiceItems" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" /> + </variation> + <variation name="CloseOrderTestWithPayPalPayflowPro" summary="Close order with PayPal Payflow Pro" ticketId="MAGETWO-13020"> + <data name="products/0" xsi:type="string">catalogProductSimple::product_10_dollar</data> + <data name="customer/dataset" xsi:type="string">default</data> + <data name="shippingAddress/dataset" xsi:type="string">US_address_1_without_email</data> + <data name="checkoutMethod" xsi:type="string">guest</data> + <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> + <data name="shipping/shipping_method" xsi:type="string">Fixed</data> + <data name="payment/method" xsi:type="string">payflowpro</data> + <data name="order/data/price/dataset" xsi:type="string">full_invoice_with_product_10_dollar</data> + <data name="prices" xsi:type="array"> + <item name="grandTotal" xsi:type="string">15.00</item> + </data> + <data name="capturedPrices" xsi:type="array"> + <item name="0" xsi:type="string">15.00</item> + </data> + <data name="creditCard/dataset" xsi:type="string">visa_default</data> + <data name="status" xsi:type="string">Complete</data> + <data name="configData" xsi:type="string">payflowpro, payflowpro_use_vault</data> + <data name="tag" xsi:type="string">test_type:3rd_party_test, severity:S0</data> + <constraint name="Magento\Sales\Test\Constraint\AssertCaptureInCommentsHistory" /> + <constraint name="Magento\Sales\Test\Constraint\AssertInvoiceItems" /> + <constraint name="Magento\Sales\Test\Constraint\AssertInvoiceInInvoicesTab" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" /> + </variation> + </testCase> +</config> \ No newline at end of file diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/CreateOnlineCreditMemoTest.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/CreateOnlineCreditMemoTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..f859f579ecea45c5c992017a09df061b11b70bbc --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/CreateOnlineCreditMemoTest.xml @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Sales\Test\TestCase\CreateOnlineCreditMemoTest" summary="Create online credit memo for order placed with online payment method"> + <variation name="CreateCreditMemoPaymentsProTestVariation1" summary="Create Refund for Order Paid with PayPal Payments Pro" ticketId="MAGETWO-13059"> + <data name="products/0" xsi:type="string">catalogProductSimple::product_10_dollar</data> + <data name="customer/dataset" xsi:type="string">default</data> + <data name="checkoutMethod" xsi:type="string">guest</data> + <data name="refundedPrices" xsi:type="array"> + <item name="0" xsi:type="string">15.00</item> + </data> + <data name="shippingAddress/dataset" xsi:type="string">US_address_1_without_email</data> + <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> + <data name="shipping/shipping_method" xsi:type="string">Fixed</data> + <data name="payment/method" xsi:type="string">payflowpro</data> + <data name="configData" xsi:type="string">paypal_direct</data> + <data name="creditCard/dataset" xsi:type="string">visa_default</data> + <data name="data/items_data/0/qty" xsi:type="string">-</data> + <data name="data/form_data/do_shipment" xsi:type="string">Yes</data> + <data name="status" xsi:type="string">Closed</data> + <data name="transactions/Refund" xsi:type="array"> + <item name="transactionType" xsi:type="string">Refund</item> + <item name="statusIsClosed" xsi:type="string">Yes</item> + </data> + <data name="transactions/Capture" xsi:type="array"> + <item name="transactionType" xsi:type="string">Capture</item> + <item name="statusIsClosed" xsi:type="string">Yes</item> + </data> + <data name="tag" xsi:type="string">test_type:3rd_party_test, severity:S0</data> + <constraint name="Magento\Sales\Test\Constraint\AssertRefundSuccessCreateMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" /> + <constraint name="Magento\Sales\Test\Constraint\AssertRefundInCommentsHistory" /> + <constraint name="Magento\Sales\Test\Constraint\AssertRefundInCreditMemoTab" /> + <constraint name="Magento\Sales\Test\Constraint\AssertTransactionStatus" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/ExpressCheckoutFromProductPageTest.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/ExpressCheckoutFromProductPageTest.xml index 1d92fa149efbc336eb0910a451a1740f2eda6c14..6005fe4008d7bb52308878e81a7d0211c5441a87 100644 --- a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/ExpressCheckoutFromProductPageTest.xml +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/ExpressCheckoutFromProductPageTest.xml @@ -27,7 +27,7 @@ </data> <data name="payment/method" xsi:type="string">paypal_express</data> <data name="configData" xsi:type="string">paypal_express, freeshipping</data> - <data name="tag" xsi:type="string">test_type:3rd_party_test, severity:S0</data> + <data name="tag" xsi:type="string">test_type:3rd_party_test_deprecated, severity:S0</data> <constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" /> <constraint name="Magento\Checkout\Test\Constraint\AssertMinicartEmpty" /> <constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" /> diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/ExpressCheckoutFromShoppingCartTest.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/ExpressCheckoutFromShoppingCartTest.xml index 38c876719bc3d82c772ff6f86cd507229ec5cf2b..233958afa1aa5605f922b105b2da85dee08960c8 100644 --- a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/ExpressCheckoutFromShoppingCartTest.xml +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/ExpressCheckoutFromShoppingCartTest.xml @@ -28,7 +28,7 @@ <item name="grandTotal" xsi:type="string">145.98</item> </data> <data name="configData" xsi:type="string">payflowpro</data> - <data name="tag" xsi:type="string">test_type:3rd_party_test, severity:S0</data> + <data name="tag" xsi:type="string">test_type:3rd_party_test_deprecated, severity:S0</data> <constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" /> <constraint name="Magento\Checkout\Test\Constraint\AssertMinicartEmpty" /> <constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" /> diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/ExpressCheckoutOnePageTest.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/ExpressCheckoutOnePageTest.xml index e52ed631ae46f983dc8860e7bf628f95a5a6a7fb..7de72c8ac9d93143dd3d59595a452981f2e15a89 100644 --- a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/ExpressCheckoutOnePageTest.xml +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/ExpressCheckoutOnePageTest.xml @@ -26,7 +26,7 @@ </data> <data name="payment/method" xsi:type="string">paypal_express</data> <data name="configData" xsi:type="string">paypal_express</data> - <data name="tag" xsi:type="string">test_type:3rd_party_test, severity:S0</data> + <data name="tag" xsi:type="string">test_type:3rd_party_test_deprecated, severity:S0</data> <constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" /> <constraint name="Magento\Checkout\Test\Constraint\AssertMinicartEmpty" /> <constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" /> @@ -51,7 +51,7 @@ </data> <data name="payment/method" xsi:type="string">paypal_express</data> <data name="configData" xsi:type="string">payflowlink</data> - <data name="tag" xsi:type="string">test_type:3rd_party_test, severity:S0</data> + <data name="tag" xsi:type="string">test_type:3rd_party_test_deprecated, severity:S0</data> <constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" /> <constraint name="Magento\Checkout\Test\Constraint\AssertMinicartEmpty" /> <constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" /> @@ -76,7 +76,7 @@ </data> <data name="payment/method" xsi:type="string">paypal_express</data> <data name="configData" xsi:type="string">paypal_express</data> - <data name="tag" xsi:type="string">test_type:3rd_party_test</data> + <data name="tag" xsi:type="string">test_type:3rd_party_test_deprecated</data> <constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" /> <constraint name="Magento\Checkout\Test\Constraint\AssertMinicartEmpty" /> <constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" /> diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutDeclinedTest.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutDeclinedTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..e015e3ba566648ce05326e3fae03bf2a76eefc64 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutDeclinedTest.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Checkout\Test\TestCase\OnePageCheckoutDeclinedTest" summary="Error message during OnePageCheckout"> + <variation name="OnePageCheckoutPayflowProWithAVSStreetDoesNotMatch" summary="Place Order via Payflow Pro with AVS Street verification fail" ticketId="MAGETWO-37480"> + <data name="tag" xsi:type="string">test_type:3rd_party_test, severity:S1</data> + <data name="products/0" xsi:type="string">catalogProductSimple::product_10_dollar</data> + <data name="customer/dataset" xsi:type="string">default</data> + <data name="shippingAddress/dataset" xsi:type="string">AVS_street_does_not_match_address</data> + <data name="checkoutMethod" xsi:type="string">guest</data> + <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> + <data name="shipping/shipping_method" xsi:type="string">Fixed</data> + <data name="payment/method" xsi:type="string">payflowpro</data> + <data name="creditCard/dataset" xsi:type="string">visa_default</data> + <data name="configData" xsi:type="string">payflowpro, payflowpro_avs_street_does_not_match</data> + <data name="expectedErrorMessage" xsi:type="string">An error occurred on the server. Please try to place the order again.</data> + <constraint name="Magento\Checkout\Test\Constraint\AssertCheckoutErrorMessage" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutTest.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutTest.xml index 655b2f5f9d3fb83eaca544d74db4e9adf0732bbe..44577748f7b7a1abe37e6a9e562b3059820b0267 100644 --- a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutTest.xml +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutTest.xml @@ -55,7 +55,7 @@ <constraint name="Magento\Sales\Test\Constraint\AssertAuthorizationInCommentsHistory" /> <constraint name="Magento\Sales\Test\Constraint\AssertOrderPaymentInformation" /> </variation> - <variation name="OnePageCheckoutPayflowProWithAVSStreetMatches" summary="Place Order via Payflow Pro with success AVS Street verification" ticketId="MAGETWO-37479"> + <variation name="OnePageCheckoutPayflowProWithAVSStreetMatch" summary="Place Order via Payflow Pro with success AVS Street verification" ticketId="MAGETWO-37479"> <data name="tag" xsi:type="string">test_type:3rd_party_test, severity:S1</data> <data name="products/0" xsi:type="string">catalogProductSimple::product_10_dollar</data> <data name="customer/dataset" xsi:type="string">default</data> @@ -80,5 +80,24 @@ <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" /> <constraint name="Magento\Sales\Test\Constraint\AssertOrderPaymentInformation" /> </variation> + <variation name="OnePageCheckoutPayPalPaymentsPro" summary="Guest Checkout using PayPal Payments Pro and Flat Rate" ticketId="MAGETWO-62039"> + <data name="products/0" xsi:type="string">catalogProductSimple::product_10_dollar</data> + <data name="customer/dataset" xsi:type="string">default</data> + <data name="shippingAddress/dataset" xsi:type="string">US_address_1_without_email</data> + <data name="checkoutMethod" xsi:type="string">guest</data> + <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> + <data name="shipping/shipping_method" xsi:type="string">Fixed</data> + <data name="payment/method" xsi:type="string">payflowpro</data> + <data name="prices" xsi:type="array"> + <item name="grandTotal" xsi:type="string">15.00</item> + </data> + <data name="creditCard/dataset" xsi:type="string">visa_default</data> + <data name="configData" xsi:type="string">paypal_direct</data> + <data name="tag" xsi:type="string">test_type:3rd_party_test, severity:S1</data> + <constraint name="Magento\Checkout\Test\Constraint\AssertOrderSuccessPlacedMessage" /> + <constraint name="Magento\Checkout\Test\Constraint\AssertCartIsEmpty" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal" /> + <constraint name="Magento\Sales\Test\Constraint\AssertAuthorizationInCommentsHistory" /> + </variation> </testCase> </config> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractItems.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractItems.php index d7a89b68c553808cfdbb7de9854ce37e82464618..38ad9139d4fdb2bf28c40d8420db890dcda77d3a 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractItems.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractItems.php @@ -19,63 +19,63 @@ class AbstractItems extends Block * * @var string */ - private $rowItem = 'tbody'; + protected $rowItem = 'tbody'; /** * Locator for product sku column. * * @var string */ - private $sku = '.col-product .product-sku-block'; + protected $sku = '.col-product .product-sku-block'; /** * Locator for product title column. * * @var string */ - private $title = '.col-product .product-title'; + protected $title = '.col-product .product-title'; /** * Locator for "Price" column. * * @var string */ - private $price = '.col-price .price'; + protected $price = '.col-price .price'; /** * Locator for "Qty" column. * * @var string */ - private $qty = '.col-qty'; + protected $qty = '.col-qty'; /** * Locator for "Subtotal" column. * * @var string */ - private $subtotal = '.col-subtotal .price'; + protected $subtotal = '.col-subtotal .price'; /** * Locator for "Tax Amount" column. * * @var string */ - private $taxAmount = '.col-tax .price'; + protected $taxAmount = '.col-tax .price'; /** * Locator for "Discount Amount" column. * * @var string */ - private $discountAmount = '.col-discount .price'; + protected $discountAmount = '.col-discount .price'; /** * Locator for "Row total" column. * * @var string */ - private $rowTotal = '.col-total .price'; + protected $rowTotal = '.col-total .price'; /** * Get items data. diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderStatusIsCanceled.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderStatusIsCanceled.php new file mode 100644 index 0000000000000000000000000000000000000000..2547cb49b70a447382033b2d76f7606d5545f459 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderStatusIsCanceled.php @@ -0,0 +1,53 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\Constraint; + +use Magento\Sales\Test\Page\Adminhtml\OrderIndex; +use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; +use Magento\Mtf\Constraint\AbstractConstraint; + +/** + * Assert that status is Canceled. + */ +class AssertOrderStatusIsCanceled extends AbstractConstraint +{ + /** + * Assert that status is Canceled. + * + * @param OrderIndex $salesOrder + * @param SalesOrderView $salesOrderView + * @return void + */ + public function processAssert( + OrderIndex $salesOrder, + SalesOrderView $salesOrderView + ) { + $salesOrder->open(); + $grid = $salesOrder->getSalesOrderGrid(); + $grid->resetFilter(); + $grid->sortByColumn('ID'); + $grid->sortGridByField('ID'); + $grid->openFirstRow(); + + /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */ + $infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info'); + \PHPUnit_Framework_Assert::assertEquals( + $infoTab->getOrderStatus(), + 'Canceled' + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Order status is correct.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Repository/OrderInjectable/Price.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/Repository/OrderInjectable/Price.xml index 3da1f91925e0a1274cbe317d36f2bc40271cbeb6..1b9a8b1465457d9d46d04f34774f42425450a7d9 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Repository/OrderInjectable/Price.xml +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Repository/OrderInjectable/Price.xml @@ -19,6 +19,13 @@ </field> </dataset> + <dataset name="full_invoice_with_product_10_dollar"> + <field name="0" xsi:type="array"> + <item name="grand_order_total" xsi:type="string">15</item> + <item name="grand_invoice_total" xsi:type="string">15</item> + </field> + </dataset> + <dataset name="partial_invoice"> <field name="0" xsi:type="array"> <item name="grand_order_total" xsi:type="string">210</item> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CloseOrderTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CloseOrderTest.php new file mode 100644 index 0000000000000000000000000000000000000000..1594cad95eff98633a9b6b1e47a4705912059370 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CloseOrderTest.php @@ -0,0 +1,45 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Sales\Test\TestCase; + +use Magento\Mtf\TestCase\Scenario; + +/** + * Preconditions: + * 1. Order is placed. + * + * Steps: + * 1. Log in to Admin. + * 2. Go to Sales > Orders page. + * 3. Open order. + * 4. Click 'Ship' button and submit shipment. + * 5. Click 'Invoice' button. + * 6. Select Amount=Capture Online. + * 7. Click 'Submit Invoice' button. + * 8. Perform assertions. + * + * @group Order_Management + * @ZephyrId MAGETWO-13015, MAGETWO-13020 + */ +class CloseOrderTest extends Scenario +{ + /* tags */ + const MVP = 'yes'; + const TEST_TYPE = '3rd_party_test'; + const SEVERITY = 'S0'; + /* end tags */ + + /** + * Close order. + * + * @return void + */ + public function test() + { + $this->executeScenario(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOnlineCreditMemoTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOnlineCreditMemoTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e11e1391a10e3442e1a92230615d7f1c0a2fbc4d --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOnlineCreditMemoTest.php @@ -0,0 +1,41 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Sales\Test\TestCase; + +use Magento\Mtf\TestCase\Scenario; + +/** + * Preconditions: + * 1. Complete a sales order with online payment method. + * + * Steps: + * 1. Log in to Admin. + * 2. Open order from preconditions. + * 3. Open created invoice. + * 3. Create credit memo. + * 4. Perform assertions. + * + * @group Order_Management + * @ZephyrId MAGETWO-13059 + */ +class CreateOnlineCreditMemoTest extends Scenario +{ + /* tags */ + const MVP = 'yes'; + const TEST_TYPE = '3rd_party_test'; + const SEVERITY = 'S0'; + /* end tags */ + + /** + * Runs test for online credit memo creation for order placed with online payment method. + * + * @return void + */ + public function test() + { + $this->executeScenario(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/etc/di.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/etc/di.xml index 157dfc0f77302318bdce435dd3af7f6de5e261fb..e9670a1d727f72b2d7ea853fd38e4b0a2bb1c218 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/etc/di.xml +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/etc/di.xml @@ -106,4 +106,9 @@ <argument name="severity" xsi:type="string">S1</argument> </arguments> </type> + <type name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCanceled"> + <arguments> + <argument name="severity" xsi:type="string">S0</argument> + </arguments> + </type> </config> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/etc/testcase.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/etc/testcase.xml index 030b0f4f32df0eacd76c99cbe55537df1c734cf5..fa4329137b0272a5ae59cefdf217baa894c2cd28 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/etc/testcase.xml +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/etc/testcase.xml @@ -86,4 +86,33 @@ <step name="submitOrder" module="Magento_Sales" next="createInvoice" /> <step name="createInvoice" module="Magento_Sales" /> </scenario> + <scenario name="CreateOnlineCreditMemoTest" firstStep="setupConfiguration"> + <step name="setupConfiguration" module="Magento_Config" next="createProducts" /> + <step name="createProducts" module="Magento_Catalog" next="addProductsToTheCart" /> + <step name="addProductsToTheCart" module="Magento_Checkout" next="createCustomer" /> + <step name="createCustomer" module="Magento_Customer" next="proceedToCheckout" /> + <step name="proceedToCheckout" module="Magento_Checkout" next="selectCheckoutMethod" /> + <step name="selectCheckoutMethod" module="Magento_Checkout" next="fillShippingAddress" /> + <step name="fillShippingAddress" module="Magento_Checkout" next="fillShippingMethod" /> + <step name="fillShippingMethod" module="Magento_Checkout" next="selectPaymentMethod" /> + <step name="selectPaymentMethod" module="Magento_Checkout" next="placeOrder" /> + <step name="placeOrder" module="Magento_Checkout" next="createInvoice" /> + <step name="createInvoice" module="Magento_Sales" next="createOnlineCreditMemo" /> + <step name="createOnlineCreditMemo" module="Magento_Sales" /> + </scenario> + <scenario name="CloseOrderTest" firstStep="setupConfiguration"> + <step name="setupConfiguration" module="Magento_Config" next="createProducts" /> + <step name="createProducts" module="Magento_Catalog" next="createTaxRule" /> + <step name="createTaxRule" module="Magento_Tax" next="addProductsToTheCart" /> + <step name="addProductsToTheCart" module="Magento_Checkout" next="proceedToCheckout" /> + <step name="proceedToCheckout" module="Magento_Checkout" next="createCustomer" /> + <step name="createCustomer" module="Magento_Customer" next="selectCheckoutMethod" /> + <step name="selectCheckoutMethod" module="Magento_Checkout" next="fillShippingAddress"/> + <step name="fillShippingAddress" module="Magento_Checkout" next="fillShippingMethod" /> + <step name="fillShippingMethod" module="Magento_Checkout" next="selectPaymentMethod" /> + <step name="selectPaymentMethod" module="Magento_Checkout" next="placeOrder" /> + <step name="placeOrder" module="Magento_Checkout" next="createInvoice" /> + <step name="createInvoice" module="Magento_Sales" next="createShipment" /> + <step name="createShipment" module="Magento_Sales" /> + </scenario> </config> diff --git a/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/DataGrid.php b/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/DataGrid.php index c5968c8e936f8a5bead20016d9c70d699b8c1a0c..b913a1c6804e63b136fdf1b497071dd173f35088 100644 --- a/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/DataGrid.php +++ b/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/DataGrid.php @@ -389,6 +389,8 @@ class DataGrid extends Grid } /** + * Sort grid by column. + * * @param string $columnLabel */ public function sortByColumn($columnLabel) @@ -396,6 +398,7 @@ class DataGrid extends Grid $this->waitLoader(); $this->getTemplateBlock()->waitForElementNotVisible($this->loader); $this->_rootElement->find(sprintf($this->columnHeader, $columnLabel), Locator::SELECTOR_XPATH)->click(); + $this->waitLoader(); } /** diff --git a/dev/tests/functional/utils/command.php b/dev/tests/functional/utils/command.php index 4061b07c783e4b0e8cbf4a7e4daa08d445834f68..a149be72a1ca48fbb7531b74d3dc84b687c5f737 100644 --- a/dev/tests/functional/utils/command.php +++ b/dev/tests/functional/utils/command.php @@ -8,5 +8,5 @@ if (isset($_GET['command'])) { $command = urldecode($_GET['command']); exec('php -f ../../../../bin/magento ' . $command); } else { - throw new \Exception("Command GET parameter is not set."); + throw new \InvalidArgumentException("Command GET parameter is not set."); } diff --git a/dev/tests/functional/utils/export.php b/dev/tests/functional/utils/export.php new file mode 100644 index 0000000000000000000000000000000000000000..062e8de6cbe7d6453f75d48b4faaf208ebffddc5 --- /dev/null +++ b/dev/tests/functional/utils/export.php @@ -0,0 +1,27 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +if (!isset($_GET['template'])) { + throw new \InvalidArgumentException('Argument "template" must be set.'); +} + +$varDir = '../../../../var/'; +$template = urldecode($_GET['template']); +$fileList = scandir($varDir, SCANDIR_SORT_NONE); +$files = []; + +foreach ($fileList as $fileName) { + if (preg_match("`$template`", $fileName) === 1) { + $filePath = $varDir . $fileName; + $files[] = [ + 'content' => file_get_contents($filePath), + 'name' => $fileName, + 'date' => filectime($filePath), + ]; + } +} + +echo serialize($files); diff --git a/dev/tests/js/jasmine/require.conf.js b/dev/tests/js/jasmine/require.conf.js index 9ba59b81bc27f5326673e59270917b232643ee24..c60ec02943b5ba86a0c7622bf64ce1c037351805 100644 --- a/dev/tests/js/jasmine/require.conf.js +++ b/dev/tests/js/jasmine/require.conf.js @@ -16,7 +16,13 @@ require.config({ ] }, paths: { - 'tests': 'dev/tests/js/jasmine' + 'tests': 'dev/tests/js/jasmine', + 'squire': 'node_modules/squirejs/src/Squire' + }, + shim: { + squire: { + exports: 'squire' + } }, config: { jsbuild: { diff --git a/dev/tests/js/jasmine/spec_runner/settings.json b/dev/tests/js/jasmine/spec_runner/settings.json index 109da479146da84882c4a6a68e8778db0b19701d..25407123c1f34d66c70c4406d9341f4659f7519b 100644 --- a/dev/tests/js/jasmine/spec_runner/settings.json +++ b/dev/tests/js/jasmine/spec_runner/settings.json @@ -57,7 +57,8 @@ "^\/_SpecRunner.html", "^\/dev\/tests", "^\/.grunt", - "^\/pub\/static" + "^\/pub\/static", + "^\/node_modules" ], "options": { /** diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/new-customer-address.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/new-customer-address.test.js new file mode 100644 index 0000000000000000000000000000000000000000..ae7ff3d145e2b0ae8c2850ff8d2217baa9fed3f1 --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/new-customer-address.test.js @@ -0,0 +1,74 @@ +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'Magento_Checkout/js/model/new-customer-address' +], function (NewCustomerAddress) { + 'use strict'; + + describe('Magento_Checkout/js/model/new-customer-address', function () { + var newCustomerAddress; + + window.checkoutConfig = { + defaultCountryId: 'US' + }; + + beforeEach(function () { + newCustomerAddress = NewCustomerAddress; + }); + + it('Check that is executable.', function () { + expect(typeof newCustomerAddress).toEqual('function'); + }); + + it('Check on empty object.', function () { + var expected = { + countryId: 'US', + regionCode: null, + region: null + }; + + expect(JSON.stringify(newCustomerAddress({}))).toEqual(JSON.stringify(expected)); + }); + + it('Check on function call with empty address data.', function () { + var result = newCustomerAddress({}); + + expect(result.isDefaultShipping()).toBeUndefined(); + expect(result.isDefaultBilling()).toBeUndefined(); + expect(result.getType()).toEqual('new-customer-address'); + expect(result.getKey()).toEqual('new-customer-address'); + expect(result.getKey()).toContain('new-customer-address'); + expect(result.isEditable()).toBeTruthy(); + expect(result.canUseForBilling()).toBeTruthy(); + }); + + it('Check on regionId with region object in address data.', function () { + var result = newCustomerAddress({ + region: { + 'region_id': 1 + } + }), + expected = { + countryId: 'US', + regionId: 1 + }; + + expect(JSON.stringify(result)).toEqual(JSON.stringify(expected)); + }); + it('Check on regionId with countryId in address data.', function () { + var result = newCustomerAddress({ + 'country_id': 'US' + }), + expected = { + countryId: 'US', + regionCode: null, + region: null + }; + + expect(JSON.stringify(result)).toEqual(JSON.stringify(expected)); + }); + }); +}); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/view/cart/shipping-estimation.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/view/cart/shipping-estimation.test.js new file mode 100644 index 0000000000000000000000000000000000000000..785d88d81e3543aae46ad1564c7a4ba5edbcba5c --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/view/cart/shipping-estimation.test.js @@ -0,0 +1,115 @@ +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +/* eslint max-nested-callbacks: 0 */ + +define(['squire', 'ko'], function (Squire, ko) { + 'use strict'; + + var injector = new Squire(), + checkoutProvider = { + on: jasmine.createSpy() + }, + mocks = { + 'Magento_Checkout/js/action/select-shipping-address': jasmine.createSpy(), + 'Magento_Checkout/js/model/address-converter': { + formAddressDataToQuoteAddress: jasmine.createSpy() + }, + 'Magento_Checkout/js/model/cart/estimate-service': jasmine.createSpy(), + 'Magento_Checkout/js/checkout-data': jasmine.createSpy(), + 'Magento_Checkout/js/model/shipping-rates-validator': { + bindChangeHandlers: jasmine.createSpy() + }, + 'uiRegistry': { + async: jasmine.createSpy().and.returnValue(function (callback) { + callback(checkoutProvider); + }), + create: jasmine.createSpy(), + get: jasmine.createSpy(), + set: jasmine.createSpy() + }, + 'Magento_Checkout/js/model/quote': { + isVirtual: jasmine.createSpy(), + shippingAddress: jasmine.createSpy() + }, + 'Magento_Checkout/js/model/checkout-data-resolver': { + resolveEstimationAddress: jasmine.createSpy() + }, + 'mage/validation': jasmine.createSpy() + }, + obj; + + beforeEach(function (done) { + injector.mock(mocks); + injector.require(['Magento_Checkout/js/view/cart/shipping-estimation'], function (Constr) { + obj = new Constr({ + provider: 'provName', + name: '', + index: '' + }); + done(); + }); + }); + + describe('Magento_Checkout/js/view/cart/shipping-estimation', function () { + describe('"initElement" method', function () { + it('Check for return value and element that initiated.', function () { + var element = jasmine.createSpyObj('element', ['initContainer']); + + expect(obj.initElement(element)).toBe(obj); + expect(mocks['Magento_Checkout/js/model/shipping-rates-validator'].bindChangeHandlers) + .not.toHaveBeenCalled(); + }); + it('Check shipping rates validator call.', function () { + var element = { + index: 'address-fieldsets', + elems: ko.observable(), + initContainer: jasmine.createSpy() + }; + + spyOn(element.elems, 'subscribe'); + + obj.initElement(element); + expect(mocks['Magento_Checkout/js/model/shipping-rates-validator'].bindChangeHandlers) + .toHaveBeenCalledWith(element.elems(), true, 500); + expect(element.elems.subscribe) + .toHaveBeenCalledWith(jasmine.any(Function)); + }); + }); + + describe('"getEstimationInfo" method', function () { + it('Check for invalid form data.', function () { + obj.source = { + get: jasmine.createSpy().and.returnValue(true), + set: jasmine.createSpy(), + trigger: jasmine.createSpy() + }; + + expect(obj.getEstimationInfo()).toBeUndefined(); + expect(obj.source.get).toHaveBeenCalledWith('params.invalid'); + expect(obj.source.get).not.toHaveBeenCalledWith('shippingAddress'); + expect(obj.source.set).toHaveBeenCalledWith('params.invalid', false); + expect(obj.source.trigger).toHaveBeenCalledWith('shippingAddress.data.validate'); + expect(mocks['Magento_Checkout/js/action/select-shipping-address']).not.toHaveBeenCalled(); + obj.source = {}; + }); + it('Check for vaild form data.', function () { + obj.source = { + get: jasmine.createSpy().and.returnValues(false, {}), + set: jasmine.createSpy(), + trigger: jasmine.createSpy() + }; + + expect(obj.getEstimationInfo()).toBeUndefined(); + expect(obj.source.get).toHaveBeenCalledWith('params.invalid'); + expect(obj.source.get).toHaveBeenCalledWith('shippingAddress'); + expect(obj.source.set).toHaveBeenCalledWith('params.invalid', false); + expect(obj.source.trigger).toHaveBeenCalledWith('shippingAddress.data.validate'); + expect(mocks['Magento_Checkout/js/action/select-shipping-address']).toHaveBeenCalled(); + obj.source = {}; + }); + }); + }); +}); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/view/shipping.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/view/shipping.test.js new file mode 100644 index 0000000000000000000000000000000000000000..20f3b2a090d7a38882a0728be94998ea7c359c70 --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/view/shipping.test.js @@ -0,0 +1,194 @@ +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +/* eslint max-nested-callbacks: 0 */ +require.config({ + map: { + '*': { + 'Magento_Checkout/js/view/shipping': 'Magento_Checkout/js/view/shipping' + } + } +}); + +define(['squire', 'ko', 'jquery', 'jquery/validate'], function (Squire, ko, $) { + 'use strict'; + + var injector = new Squire(), + modalStub = { + openModal: jasmine.createSpy(), + closeModal: jasmine.createSpy() + }, + mocks = { + 'Magento_Customer/js/model/customer': { + isLoggedIn: ko.observable() + }, + 'Magento_Customer/js/model/address-list': ko.observableArray(), + 'Magento_Checkout/js/model/address-converter': jasmine.createSpy(), + 'Magento_Checkout/js/model/quote': { + isVirtual: jasmine.createSpy(), + shippingMethod: ko.observable() + }, + 'Magento_Checkout/js/action/create-shipping-address': jasmine.createSpy().and.returnValue( + jasmine.createSpyObj('newShippingAddress', ['getKey']) + ), + 'Magento_Checkout/js/action/select-shipping-address': jasmine.createSpy(), + 'Magento_Checkout/js/model/shipping-rates-validator': jasmine.createSpy(), + 'Magento_Checkout/js/model/shipping-address/form-popup-state': { + isVisible: ko.observable() + }, + 'Magento_Checkout/js/model/shipping-service': jasmine.createSpyObj('service', ['getShippingRates']), + 'Magento_Checkout/js/action/select-shipping-method': jasmine.createSpy(), + 'Magento_Checkout/js/model/shipping-rate-registry': jasmine.createSpy(), + 'Magento_Checkout/js/action/set-shipping-information': jasmine.createSpy(), + 'Magento_Checkout/js/model/step-navigator': jasmine.createSpyObj('navigator', ['registerStep']), + 'Magento_Ui/js/modal/modal': jasmine.createSpy('modal').and.returnValue(modalStub), + 'Magento_Checkout/js/model/checkout-data-resolver': jasmine.createSpyObj( + 'dataResolver', + ['resolveShippingAddress'] + ), + 'Magento_Checkout/js/checkout-data': jasmine.createSpyObj( + 'checkoutData', + ['setSelectedShippingAddress', 'setNewCustomerShippingAddress', 'setSelectedShippingRate'] + ), + 'uiRegistry': jasmine.createSpy(), + 'Magento_Checkout/js/model/shipping-rate-service': jasmine.createSpy() + }, + obj; + + beforeEach(function (done) { + injector.mock(mocks); + injector.require(['Magento_Checkout/js/view/shipping'], function (Constr) { + obj = new Constr({ + provider: 'provName', + name: '', + index: '', + popUpForm: { + options: { + buttons: { + save: {}, + cancel: {} + } + } + } + }); + done(); + }); + }); + + describe('Magento_Checkout/js/view/shipping', function () { + describe('"navigate" method', function () { + it('Check for return value.', function () { + expect(obj.navigate()).toBeUndefined(); + }); + }); + + describe('"getPopUp" method', function () { + it('Check for return value.', function () { + expect(obj.getPopUp()).toBe(modalStub); + expect(mocks['Magento_Ui/js/modal/modal']).toHaveBeenCalled(); + mocks['Magento_Ui/js/modal/modal'].calls.reset(); + }); + it('Check on single modal call', function () { + expect(obj.getPopUp()).toBe(modalStub); + expect(mocks['Magento_Ui/js/modal/modal']).not.toHaveBeenCalled(); + }); + }); + + describe('"showFormPopUp" method', function () { + it('Check method call.', function () { + expect(obj.showFormPopUp()).toBeUndefined(); + expect(obj.isFormPopUpVisible()).toBeTruthy(); + expect(modalStub.openModal).toHaveBeenCalled(); + }); + }); + + describe('"saveNewAddress" method', function () { + it('Check method call with invalid form data.', function () { + obj.source = { + get: jasmine.createSpy().and.returnValue(true), + set: jasmine.createSpy(), + trigger: jasmine.createSpy() + }; + + expect(obj.saveNewAddress()).toBeUndefined(); + expect(obj.isNewAddressAdded()).toBeFalsy(); + expect(modalStub.closeModal).not.toHaveBeenCalled(); + }); + it('Check method call with valid form data.', function () { + obj.source = { + get: jasmine.createSpy().and.returnValues(true, false, {}), + set: jasmine.createSpy(), + trigger: jasmine.createSpy() + }; + + expect(obj.saveNewAddress()).toBeUndefined(); + expect(obj.isNewAddressAdded()).toBeTruthy(); + expect(modalStub.closeModal).toHaveBeenCalled(); + }); + }); + + describe('"selectShippingMethod" method', function () { + it('Check method call.', function () { + var shippingMethod = { + 'carrier_code': 'carrier', + 'method_code': 'method' + }; + + expect(obj.selectShippingMethod(shippingMethod)).toBeTruthy(); + expect(mocks['Magento_Checkout/js/checkout-data'].setSelectedShippingRate) + .toHaveBeenCalledWith('carrier_method'); + }); + }); + + describe('"setShippingInformation" method', function () { + it('Check method call.', function () { + expect(obj.setShippingInformation()).toBeUndefined(); + }); + }); + + describe('"validateShippingInformation" method', function () { + it('Check method call on negative cases.', function () { + obj.source = { + get: jasmine.createSpy().and.returnValue(true), + set: jasmine.createSpy(), + trigger: jasmine.createSpy() + }; + + expect(obj.validateShippingInformation()).toBeFalsy(); + expect(obj.errorValidationMessage()).toBe('Please specify a shipping method.'); + spyOn(mocks['Magento_Checkout/js/model/quote'], 'shippingMethod').and.returnValue(true); + spyOn(mocks['Magento_Customer/js/model/customer'], 'isLoggedIn').and.returnValue(true); + expect(obj.validateShippingInformation()).toBeFalsy(); + }); + it('Check method call on positive case.', function () { + $('body').append('<form data-role="email-with-possible-login">' + + '<input type="text" name="username" />' + + '</form>'); + obj.source = { + get: jasmine.createSpy().and.returnValue(true), + set: jasmine.createSpy(), + trigger: jasmine.createSpy() + }; + obj.isFormInline = false; + + spyOn(mocks['Magento_Checkout/js/model/quote'], 'shippingMethod').and.returnValue(true); + spyOn(mocks['Magento_Customer/js/model/customer'], 'isLoggedIn').and.returnValue(false); + spyOn($.fn, 'valid').and.returnValue(true); + expect(obj.validateShippingInformation()).toBeTruthy(); + }); + }); + + describe('"triggerShippingDataValidateEvent" method', function () { + it('Check method call.', function () { + obj.source = { + get: jasmine.createSpy().and.returnValue(true), + set: jasmine.createSpy(), + trigger: jasmine.createSpy() + }; + expect(obj.triggerShippingDataValidateEvent()).toBeUndefined(); + }); + }); + }); +}); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Customer/frontend/js/model/customer/address.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Customer/frontend/js/model/customer/address.test.js new file mode 100644 index 0000000000000000000000000000000000000000..0384c9df2c583c31ad3f95a6b942b8c73b0b3af5 --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Customer/frontend/js/model/customer/address.test.js @@ -0,0 +1,58 @@ +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'Magento_Customer/js/model/customer/address' +], function (CustomerAddress) { + 'use strict'; + + describe('Magento_Customer/js/model/customer/address', function () { + var customerAddress; + + beforeEach(function () { + customerAddress = CustomerAddress; + }); + + it('Check that is executable.', function () { + expect(typeof customerAddress).toEqual('function'); + }); + + it('Check on empty object.', function () { + var addressData = { + region: {} + }; + + expect(JSON.stringify(customerAddress(addressData))).toEqual(JSON.stringify({})); + }); + + it('Check on function call with empty address data.', function () { + var result = customerAddress({ + region: {} + }); + + expect(result.isDefaultShipping()).toBeUndefined(); + expect(result.isDefaultBilling()).toBeUndefined(); + expect(result.getAddressInline()).toBeUndefined(); + expect(result.getType()).toEqual('customer-address'); + expect(result.getKey()).toContain('customer-address'); + expect(result.getCacheKey()).toContain('customer-address'); + expect(result.isEditable()).toBeFalsy(); + expect(result.canUseForBilling()).toBeTruthy(); + }); + + it('Check on regionId with region object in address data.', function () { + var result = customerAddress({ + region: { + 'region_id': 1 + } + }), + expected = { + regionId: '1' + }; + + expect(JSON.stringify(result)).toEqual(JSON.stringify(expected)); + }); + }); +}); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Customer/frontend/js/view/authentication-popup.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Customer/frontend/js/view/authentication-popup.test.js new file mode 100644 index 0000000000000000000000000000000000000000..128bd86edbf990cc28002152ac128b134c0488be --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Customer/frontend/js/view/authentication-popup.test.js @@ -0,0 +1,81 @@ +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +/* eslint max-nested-callbacks: 0 */ +define(['squire'], function (Squire) { + 'use strict'; + + var injector = new Squire(), + loginAction = jasmine.createSpy(), + mocks = { + 'Magento_Customer/js/action/login': loginAction, + 'Magento_Customer/js/customer-data': { + get: jasmine.createSpy() + }, + 'Magento_Customer/js/model/authentication-popup': { + createPopUp: jasmine.createSpy(), + modalWindow: null + }, + 'Magento_Ui/js/modal/alert': jasmine.createSpy(), + 'mage/url': jasmine.createSpyObj('customerData', ['setBaseUrl']) + }, + obj; + + loginAction.registerLoginCallback = jasmine.createSpy(); + window.authenticationPopup = { + customerRegisterUrl: 'register_url', + customerForgotPasswordUrl: 'forgot_password_url', + autocomplete: 'autocomplete_flag', + baseUrl: 'base_url' + }; + + beforeEach(function (done) { + injector.mock(mocks); + injector.require(['Magento_Customer/js/view/authentication-popup'], function (Constr) { + obj = new Constr({ + provider: 'provName', + name: '', + index: '' + }); + done(); + }); + }); + + describe('Magento_Customer/js/view/authentication-popup', function () { + describe('"isActive" method', function () { + it('Check for return value.', function () { + mocks['Magento_Customer/js/customer-data'].get.and.returnValue(function () { + return true; + }); + expect(obj.isActive()).toBeFalsy(); + }); + }); + }); + + describe('Magento_Customer/js/view/authentication-popup', function () { + describe('"setModalElement" method', function () { + it('Check for return value.', function () { + expect(obj.setModalElement()).toBeUndefined(); + expect(mocks['Magento_Customer/js/model/authentication-popup'].createPopUp).toHaveBeenCalled(); + }); + }); + }); + + describe('Magento_Customer/js/view/authentication-popup', function () { + describe('"login" method', function () { + it('Check for return value.', function () { + var event = { + currentTarget: '<form><input type="text" name="username" value="customer"/></form>', + stopPropagation: jasmine.createSpy() + }; + + expect(obj.login(null, event)).toBeFalsy(); + expect(mocks['Magento_Customer/js/action/login']).toHaveBeenCalledWith({ + username: 'customer' + }); + }); + }); + }); +}); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/paging/paging.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/paging/paging.test.js index a240e5cfd432597d4bb38e10957b4495d4ed48b2..d6480261c3fe14fe3dca807bec1375d3947972fe 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/paging/paging.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/paging/paging.test.js @@ -29,13 +29,10 @@ define([ it('normal + boundary values', function () { expect(paging.normalize(1)).toBe(1); - expect(paging.normalize(2)).toBe(2); - expect(paging.normalize(4)).toBe(4); }); it('out of boundary values', function () { expect(paging.normalize(0)).toBe(1); - expect(paging.normalize(5)).toBe(4); }); }); diff --git a/package.json.sample b/package.json.sample index 40169b3179052d98ad2c1a79baf48e376689f3c1..d73606809abe6563a57c562a27544def4ddce84a 100644 --- a/package.json.sample +++ b/package.json.sample @@ -36,7 +36,8 @@ "serve-static": "^1.7.1", "strip-json-comments": "^1.0.2", "time-grunt": "^1.0.0", - "underscore": "^1.7.0" + "underscore": "^1.7.0", + "squirejs": "0.2.1" }, "engines": { "node": ">=0.10.0"