diff --git a/.travis.yml b/.travis.yml index 3a68256c04a28..42c2bcab0c901 100644 --- a/.travis.yml +++ b/.travis.yml @@ -59,5 +59,6 @@ script: - test $TEST_SUITE = "functional" && TEST_FILTER='dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests.php' || true # The scripts for grunt/phpunit type tests - - if [ $TEST_SUITE != "js" ]; then phpunit -c dev/tests/$TEST_SUITE $TEST_FILTER; fi + - if [ $TEST_SUITE == "functional" ]; then dev/tests/functional/vendor/phpunit/phpunit/phpunit -c dev/tests/$TEST_SUITE $TEST_FILTER; fi + - if [ $TEST_SUITE != "functional" ] && [ $TEST_SUITE != "js" ]; then phpunit -c dev/tests/$TEST_SUITE $TEST_FILTER; fi - if [ $TEST_SUITE == "js" ]; then grunt $GRUNT_COMMAND; fi diff --git a/app/bootstrap.php b/app/bootstrap.php index 94142dcf0c225..6701a9f4dd51e 100644 --- a/app/bootstrap.php +++ b/app/bootstrap.php @@ -62,6 +62,6 @@ date_default_timezone_set('UTC'); -/* Adjustment of precision value for several versions of PHP */ -ini_set('precision', 17); -ini_set('serialize_precision', 17); +/* For data consistency between displaying (printing) and serialization a float number */ +ini_set('precision', 14); +ini_set('serialize_precision', 14); diff --git a/app/code/Magento/AdminNotification/Block/Inbox.php b/app/code/Magento/AdminNotification/Block/Inbox.php index 7137181e3cb3d..4c989f74991ff 100644 --- a/app/code/Magento/AdminNotification/Block/Inbox.php +++ b/app/code/Magento/AdminNotification/Block/Inbox.php @@ -9,6 +9,7 @@ /** * @api + * @since 100.0.2 */ class Inbox extends \Magento\Backend\Block\Widget\Grid\Container { diff --git a/app/code/Magento/AdminNotification/Block/System/Messages/UnreadMessagePopup.php b/app/code/Magento/AdminNotification/Block/System/Messages/UnreadMessagePopup.php index bd9153968973f..7ea0062581467 100644 --- a/app/code/Magento/AdminNotification/Block/System/Messages/UnreadMessagePopup.php +++ b/app/code/Magento/AdminNotification/Block/System/Messages/UnreadMessagePopup.php @@ -9,6 +9,7 @@ /** * @api + * @since 100.0.2 */ class UnreadMessagePopup extends \Magento\Backend\Block\Template { diff --git a/app/code/Magento/AdminNotification/Block/ToolbarEntry.php b/app/code/Magento/AdminNotification/Block/ToolbarEntry.php index 9b05dd200e31c..c097edfd8af65 100644 --- a/app/code/Magento/AdminNotification/Block/ToolbarEntry.php +++ b/app/code/Magento/AdminNotification/Block/ToolbarEntry.php @@ -11,6 +11,7 @@ * * @api * @author Magento Core Team + * @since 100.0.2 */ class ToolbarEntry extends \Magento\Backend\Block\Template { diff --git a/app/code/Magento/AdminNotification/Block/Window.php b/app/code/Magento/AdminNotification/Block/Window.php index 277e25dac1727..b80e12a8674db 100644 --- a/app/code/Magento/AdminNotification/Block/Window.php +++ b/app/code/Magento/AdminNotification/Block/Window.php @@ -9,6 +9,7 @@ /** * @api + * @since 100.0.2 */ class Window extends \Magento\Backend\Block\Template { diff --git a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification.php b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification.php index 850af7dcd6954..cb50a9d0705bb 100644 --- a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification.php +++ b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification.php @@ -9,6 +9,7 @@ /** * @api + * @since 100.0.2 */ abstract class Notification extends \Magento\Backend\App\AbstractAction { diff --git a/app/code/Magento/AdminNotification/Controller/Adminhtml/System/Message/ListAction.php b/app/code/Magento/AdminNotification/Controller/Adminhtml/System/Message/ListAction.php index 2cd761f746f78..c332440276083 100644 --- a/app/code/Magento/AdminNotification/Controller/Adminhtml/System/Message/ListAction.php +++ b/app/code/Magento/AdminNotification/Controller/Adminhtml/System/Message/ListAction.php @@ -8,6 +8,11 @@ class ListAction extends \Magento\Backend\App\AbstractAction { + /** + * Authorization level of a basic admin session + */ + const ADMIN_RESOURCE = 'Magento_AdminNotification::show_list'; + /** * @var \Magento\Framework\Json\Helper\Data */ diff --git a/app/code/Magento/AdminNotification/Model/Config/Source/Frequency.php b/app/code/Magento/AdminNotification/Model/Config/Source/Frequency.php index 3a42b4c752d55..6defd92ea48cb 100644 --- a/app/code/Magento/AdminNotification/Model/Config/Source/Frequency.php +++ b/app/code/Magento/AdminNotification/Model/Config/Source/Frequency.php @@ -10,6 +10,7 @@ * * @codeCoverageIgnore * @api + * @since 100.0.2 */ class Frequency implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/AdminNotification/Model/Feed.php b/app/code/Magento/AdminNotification/Model/Feed.php index 0d628bd9c9d07..1766425fb19b1 100644 --- a/app/code/Magento/AdminNotification/Model/Feed.php +++ b/app/code/Magento/AdminNotification/Model/Feed.php @@ -13,6 +13,7 @@ * @author Magento Core Team * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @api + * @since 100.0.2 */ class Feed extends \Magento\Framework\Model\AbstractModel { @@ -147,9 +148,9 @@ public function checkUpdate() $feedData[] = [ 'severity' => (int)$item->severity, 'date_added' => date('Y-m-d H:i:s', $itemPublicationDate), - 'title' => (string)$item->title, - 'description' => (string)$item->description, - 'url' => (string)$item->link, + 'title' => $this->escapeString($item->title), + 'description' => $this->escapeString($item->description), + 'url' => $this->escapeString($item->link), ]; } } @@ -245,4 +246,15 @@ public function getFeedXml() return $xml; } + + /** + * Converts incoming data to string format and escapes special characters. + * + * @param \SimpleXMLElement $data + * @return string + */ + private function escapeString(\SimpleXMLElement $data) + { + return htmlspecialchars((string)$data); + } } diff --git a/app/code/Magento/AdminNotification/Model/Inbox.php b/app/code/Magento/AdminNotification/Model/Inbox.php index d13045a5c9cb5..174ca7545b092 100644 --- a/app/code/Magento/AdminNotification/Model/Inbox.php +++ b/app/code/Magento/AdminNotification/Model/Inbox.php @@ -12,8 +12,6 @@ /** * AdminNotification Inbox model * - * @method \Magento\AdminNotification\Model\ResourceModel\Inbox _getResource() - * @method \Magento\AdminNotification\Model\ResourceModel\Inbox getResource() * @method int getSeverity() * @method \Magento\AdminNotification\Model\Inbox setSeverity(int $value) * @method string getDateAdded() @@ -30,6 +28,7 @@ * @method \Magento\AdminNotification\Model\Inbox setIsRemove(int $value) * * @api + * @since 100.0.2 */ class Inbox extends \Magento\Framework\Model\AbstractModel implements NotifierInterface, InboxInterface { diff --git a/app/code/Magento/AdminNotification/Model/InboxInterface.php b/app/code/Magento/AdminNotification/Model/InboxInterface.php index 5248f171ceb21..4e87822763fc3 100644 --- a/app/code/Magento/AdminNotification/Model/InboxInterface.php +++ b/app/code/Magento/AdminNotification/Model/InboxInterface.php @@ -10,6 +10,7 @@ * * @author Magento Core Team * @api + * @since 100.0.2 */ interface InboxInterface { diff --git a/app/code/Magento/AdminNotification/Model/NotificationService.php b/app/code/Magento/AdminNotification/Model/NotificationService.php index 96ed6dcab9df4..d44e98aaf2203 100644 --- a/app/code/Magento/AdminNotification/Model/NotificationService.php +++ b/app/code/Magento/AdminNotification/Model/NotificationService.php @@ -10,6 +10,7 @@ * * @author Magento Core Team * @api + * @since 100.0.2 */ class NotificationService { diff --git a/app/code/Magento/AdminNotification/Model/ResourceModel/Grid/Collection.php b/app/code/Magento/AdminNotification/Model/ResourceModel/Grid/Collection.php index d325ed437a3a6..e12419155d52b 100644 --- a/app/code/Magento/AdminNotification/Model/ResourceModel/Grid/Collection.php +++ b/app/code/Magento/AdminNotification/Model/ResourceModel/Grid/Collection.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class Collection extends \Magento\AdminNotification\Model\ResourceModel\Inbox\Collection { diff --git a/app/code/Magento/AdminNotification/Model/ResourceModel/Inbox.php b/app/code/Magento/AdminNotification/Model/ResourceModel/Inbox.php index 612ce319d938e..a92eebfaec510 100644 --- a/app/code/Magento/AdminNotification/Model/ResourceModel/Inbox.php +++ b/app/code/Magento/AdminNotification/Model/ResourceModel/Inbox.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Inbox extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { diff --git a/app/code/Magento/AdminNotification/Model/ResourceModel/Inbox/Collection.php b/app/code/Magento/AdminNotification/Model/ResourceModel/Inbox/Collection.php index 5bebf436eb883..44ec765b9d0a2 100644 --- a/app/code/Magento/AdminNotification/Model/ResourceModel/Inbox/Collection.php +++ b/app/code/Magento/AdminNotification/Model/ResourceModel/Inbox/Collection.php @@ -11,6 +11,7 @@ * @api * @author Magento Core Team * @api + * @since 100.0.2 */ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { diff --git a/app/code/Magento/AdminNotification/Model/ResourceModel/Inbox/Collection/Critical.php b/app/code/Magento/AdminNotification/Model/ResourceModel/Inbox/Collection/Critical.php index bd45860556c9e..47091ba5458cc 100644 --- a/app/code/Magento/AdminNotification/Model/ResourceModel/Inbox/Collection/Critical.php +++ b/app/code/Magento/AdminNotification/Model/ResourceModel/Inbox/Collection/Critical.php @@ -9,6 +9,7 @@ /** * @api + * @since 100.0.2 */ class Critical extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { diff --git a/app/code/Magento/AdminNotification/Model/ResourceModel/Inbox/Collection/Unread.php b/app/code/Magento/AdminNotification/Model/ResourceModel/Inbox/Collection/Unread.php index 211657fac5b77..b9e77f8a35295 100644 --- a/app/code/Magento/AdminNotification/Model/ResourceModel/Inbox/Collection/Unread.php +++ b/app/code/Magento/AdminNotification/Model/ResourceModel/Inbox/Collection/Unread.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class Unread extends \Magento\AdminNotification\Model\ResourceModel\Inbox\Collection { diff --git a/app/code/Magento/AdminNotification/Model/ResourceModel/System/Message.php b/app/code/Magento/AdminNotification/Model/ResourceModel/System/Message.php index 90cd28dd228ff..c7e9d348f3aca 100644 --- a/app/code/Magento/AdminNotification/Model/ResourceModel/System/Message.php +++ b/app/code/Magento/AdminNotification/Model/ResourceModel/System/Message.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Message extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { diff --git a/app/code/Magento/AdminNotification/Model/ResourceModel/System/Message/Collection.php b/app/code/Magento/AdminNotification/Model/ResourceModel/System/Message/Collection.php index 2cf19318e0723..31946200d296b 100644 --- a/app/code/Magento/AdminNotification/Model/ResourceModel/System/Message/Collection.php +++ b/app/code/Magento/AdminNotification/Model/ResourceModel/System/Message/Collection.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { diff --git a/app/code/Magento/AdminNotification/Model/ResourceModel/System/Message/Collection/Synchronized.php b/app/code/Magento/AdminNotification/Model/ResourceModel/System/Message/Collection/Synchronized.php index 89f00fe0f52f2..097e84ceff83c 100644 --- a/app/code/Magento/AdminNotification/Model/ResourceModel/System/Message/Collection/Synchronized.php +++ b/app/code/Magento/AdminNotification/Model/ResourceModel/System/Message/Collection/Synchronized.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Synchronized extends \Magento\AdminNotification\Model\ResourceModel\System\Message\Collection { diff --git a/app/code/Magento/AdminNotification/Model/System/Message.php b/app/code/Magento/AdminNotification/Model/System/Message.php index de437d9bf3e28..ed5e2c8854440 100644 --- a/app/code/Magento/AdminNotification/Model/System/Message.php +++ b/app/code/Magento/AdminNotification/Model/System/Message.php @@ -8,6 +8,7 @@ /** * @codeCoverageIgnore * @api + * @since 100.0.2 */ class Message extends \Magento\Framework\Model\AbstractModel implements \Magento\Framework\Notification\MessageInterface { diff --git a/app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php b/app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php index 2f686b542fd2c..f7374a961bc84 100644 --- a/app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php +++ b/app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php @@ -9,7 +9,7 @@ use Magento\Store\Model\Store; /** - * @deprecated + * @deprecated 100.1.0 */ class Baseurl implements \Magento\Framework\Notification\MessageInterface { diff --git a/app/code/Magento/AdminNotification/Model/System/Message/CacheOutdated.php b/app/code/Magento/AdminNotification/Model/System/Message/CacheOutdated.php index a5dc649a266a2..c4884ee840ba3 100644 --- a/app/code/Magento/AdminNotification/Model/System/Message/CacheOutdated.php +++ b/app/code/Magento/AdminNotification/Model/System/Message/CacheOutdated.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class CacheOutdated implements \Magento\Framework\Notification\MessageInterface { diff --git a/app/code/Magento/AdminNotification/Model/System/Message/Media/AbstractSynchronization.php b/app/code/Magento/AdminNotification/Model/System/Message/Media/AbstractSynchronization.php index 20f7e1f46b64d..daf29db540d4d 100644 --- a/app/code/Magento/AdminNotification/Model/System/Message/Media/AbstractSynchronization.php +++ b/app/code/Magento/AdminNotification/Model/System/Message/Media/AbstractSynchronization.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ abstract class AbstractSynchronization implements \Magento\Framework\Notification\MessageInterface { diff --git a/app/code/Magento/AdminNotification/Model/System/Message/Media/Synchronization/Error.php b/app/code/Magento/AdminNotification/Model/System/Message/Media/Synchronization/Error.php index 8b9695c1d3bad..38477c015cad3 100644 --- a/app/code/Magento/AdminNotification/Model/System/Message/Media/Synchronization/Error.php +++ b/app/code/Magento/AdminNotification/Model/System/Message/Media/Synchronization/Error.php @@ -8,6 +8,7 @@ /** * @api + * @since 100.0.2 */ class Error extends \Magento\AdminNotification\Model\System\Message\Media\AbstractSynchronization { diff --git a/app/code/Magento/AdminNotification/Model/System/Message/Media/Synchronization/Success.php b/app/code/Magento/AdminNotification/Model/System/Message/Media/Synchronization/Success.php index 82f98b97f230d..81bea14099e9e 100644 --- a/app/code/Magento/AdminNotification/Model/System/Message/Media/Synchronization/Success.php +++ b/app/code/Magento/AdminNotification/Model/System/Message/Media/Synchronization/Success.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Success extends \Magento\AdminNotification\Model\System\Message\Media\AbstractSynchronization { diff --git a/app/code/Magento/AdminNotification/Model/System/Message/Security.php b/app/code/Magento/AdminNotification/Model/System/Message/Security.php index dad52074befeb..7cbdd68727b94 100644 --- a/app/code/Magento/AdminNotification/Model/System/Message/Security.php +++ b/app/code/Magento/AdminNotification/Model/System/Message/Security.php @@ -10,6 +10,7 @@ /** * @api + * @since 100.0.2 */ class Security implements \Magento\Framework\Notification\MessageInterface { diff --git a/app/code/Magento/AdminNotification/Test/Unit/Block/ToolbarEntryTest.php b/app/code/Magento/AdminNotification/Test/Unit/Block/ToolbarEntryTest.php index 150e406e4c4a4..2afa9eced1d95 100644 --- a/app/code/Magento/AdminNotification/Test/Unit/Block/ToolbarEntryTest.php +++ b/app/code/Magento/AdminNotification/Test/Unit/Block/ToolbarEntryTest.php @@ -9,7 +9,7 @@ */ namespace Magento\AdminNotification\Test\Unit\Block; -class ToolbarEntryTest extends \PHPUnit_Framework_TestCase +class ToolbarEntryTest extends \PHPUnit\Framework\TestCase { /** * Retrieve toolbar entry block instance @@ -21,12 +21,9 @@ protected function _getBlockInstance($unreadNotifications) { $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); // mock collection of unread notifications - $notificationList = $this->getMock( + $notificationList = $this->createPartialMock( \Magento\AdminNotification\Model\ResourceModel\Inbox\Collection\Unread::class, - ['getSize', 'setCurPage', 'setPageSize'], - [], - '', - false + ['getSize', 'setCurPage', 'setPageSize'] ); $notificationList->expects($this->any())->method('getSize')->will($this->returnValue($unreadNotifications)); diff --git a/app/code/Magento/AdminNotification/Test/Unit/Model/FeedTest.php b/app/code/Magento/AdminNotification/Test/Unit/Model/FeedTest.php index 8423f091b5ccc..2b3eb6247e899 100644 --- a/app/code/Magento/AdminNotification/Test/Unit/Model/FeedTest.php +++ b/app/code/Magento/AdminNotification/Test/Unit/Model/FeedTest.php @@ -6,13 +6,13 @@ namespace Magento\AdminNotification\Test\Unit\Model; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; use Magento\Framework\Config\ConfigOptionsListConstants; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class FeedTest extends \PHPUnit_Framework_TestCase +class FeedTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\AdminNotification\Model\Feed */ protected $feed; @@ -52,34 +52,19 @@ class FeedTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->inboxFactory = $this->getMock( + $this->inboxFactory = $this->createPartialMock( \Magento\AdminNotification\Model\InboxFactory::class, - ['create'], - [], - '', - false - ); - $this->curlFactory = $this->getMock( - \Magento\Framework\HTTP\Adapter\CurlFactory::class, - ['create'], - [], - '', - false + ['create'] ); + $this->curlFactory = $this->createPartialMock(\Magento\Framework\HTTP\Adapter\CurlFactory::class, ['create']); $this->curl = $this->getMockBuilder(\Magento\Framework\HTTP\Adapter\Curl::class) ->disableOriginalConstructor()->getMock(); - $this->appState = $this->getMock(\Magento\Framework\App\State::class, ['getInstallDate'], [], '', false); - $this->inboxModel = $this->getMock( - \Magento\AdminNotification\Model\Inbox::class, - [ + $this->appState = $this->createPartialMock(\Magento\Framework\App\State::class, ['getInstallDate']); + $this->inboxModel = $this->createPartialMock(\Magento\AdminNotification\Model\Inbox::class, [ '__wakeup', 'parse' - ], - [], - '', - false - ); - $this->backendConfig = $this->getMock( + ]); + $this->backendConfig = $this->createPartialMock( \Magento\Backend\App\ConfigInterface::class, [ 'getValue', @@ -87,7 +72,7 @@ protected function setUp() 'isSetFlag' ] ); - $this->cacheManager = $this->getMock( + $this->cacheManager = $this->createPartialMock( \Magento\Framework\App\CacheInterface::class, [ 'load', @@ -106,7 +91,7 @@ protected function setUp() $this->productMetadata = $this->getMockBuilder(\Magento\Framework\App\ProductMetadata::class) ->disableOriginalConstructor()->getMock(); - $this->urlBuilder = $this->getMock(\Magento\Framework\UrlInterface::class); + $this->urlBuilder = $this->createMock(\Magento\Framework\UrlInterface::class); $this->feed = $this->objectManagerHelper->getObject( \Magento\AdminNotification\Model\Feed::class, @@ -160,8 +145,27 @@ public function testCheckUpdate($callInbox, $curlRequest) ->will($this->returnValue('Sat, 6 Sep 2014 16:46:11 UTC')); if ($callInbox) { $this->inboxFactory->expects($this->once())->method('create') - ->will(($this->returnValue($this->inboxModel))); - $this->inboxModel->expects($this->once())->method('parse')->will($this->returnSelf()); + ->will($this->returnValue($this->inboxModel)); + $this->inboxModel->expects($this->once()) + ->method('parse') + ->with( + $this->callback( + function ($data) { + $fieldsToCheck = ['title', 'description', 'url']; + return array_reduce( + $fieldsToCheck, + function ($initialValue, $item) use ($data) { + $haystack = $data[0][$item] ?? false; + return $haystack + ? $initialValue && !strpos($haystack, '<') && !strpos($haystack, '>') + : true; + }, + true + ); + } + ) + ) + ->will($this->returnSelf()); } else { $this->inboxFactory->expects($this->never())->method('create'); $this->inboxModel->expects($this->never())->method('parse'); @@ -211,7 +215,27 @@ public function checkUpdateDataProvider() ' - ] + ], + [ + true, + // @codingStandardsIgnoreStart + 'HEADER + + + + + MagentoCommerce + + <![CDATA[<script>alert("Hello!");</script>Test Title]]> + alert("Hello!");]]> + 4 + alert("Hello!");Description]]> + Tue, 20 Jun 2017 13:14:47 UTC + + + ' + // @codingStandardsIgnoreEnd + ], ]; } } diff --git a/app/code/Magento/AdminNotification/Test/Unit/Model/NotificationServiceTest.php b/app/code/Magento/AdminNotification/Test/Unit/Model/NotificationServiceTest.php index d72351c8ad4ed..f8485847ccae2 100644 --- a/app/code/Magento/AdminNotification/Test/Unit/Model/NotificationServiceTest.php +++ b/app/code/Magento/AdminNotification/Test/Unit/Model/NotificationServiceTest.php @@ -9,7 +9,7 @@ */ namespace Magento\AdminNotification\Test\Unit\Model; -class NotificationServiceTest extends \PHPUnit_Framework_TestCase +class NotificationServiceTest extends \PHPUnit\Framework\TestCase { /** * Retrieve instance of notification service model @@ -23,19 +23,13 @@ protected function _getServiceInstanceForMarkAsReadTest($notificationId) * @var * $notificationFactory \PHPUnit_Framework_MockObject_MockObject|\Magento\AdminNotification\Model\InboxFactory */ - $notificationFactory = $this->getMock( + $notificationFactory = $this->createPartialMock( \Magento\AdminNotification\Model\InboxFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $notification = $this->getMock( + $notification = $this->createPartialMock( \Magento\AdminNotification\Model\Inbox::class, - ['load', 'getId', 'save', 'setIsRead', '__sleep', '__wakeup'], - [], - '', - false + ['load', 'getId', 'save', 'setIsRead', '__sleep', '__wakeup'] ); $notification->expects($this->once())->method('load')->with($notificationId)->will($this->returnSelf()); $notification->expects($this->once())->method('getId')->will($this->returnValue($notificationId)); diff --git a/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/CacheOutdatedTest.php b/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/CacheOutdatedTest.php index ae177b4e8d597..2fbfc43aa8775 100644 --- a/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/CacheOutdatedTest.php +++ b/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/CacheOutdatedTest.php @@ -5,7 +5,7 @@ */ namespace Magento\AdminNotification\Test\Unit\Model\System\Message; -class CacheOutdatedTest extends \PHPUnit_Framework_TestCase +class CacheOutdatedTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -29,9 +29,9 @@ class CacheOutdatedTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_authorizationMock = $this->getMock(\Magento\Framework\AuthorizationInterface::class); - $this->_urlInterfaceMock = $this->getMock(\Magento\Framework\UrlInterface::class); - $this->_cacheTypeListMock = $this->getMock(\Magento\Framework\App\Cache\TypeListInterface::class); + $this->_authorizationMock = $this->createMock(\Magento\Framework\AuthorizationInterface::class); + $this->_urlInterfaceMock = $this->createMock(\Magento\Framework\UrlInterface::class); + $this->_cacheTypeListMock = $this->createMock(\Magento\Framework\App\Cache\TypeListInterface::class); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $arguments = [ @@ -64,10 +64,10 @@ public function testGetIdentity($expectedSum, $cacheTypes) public function getIdentityDataProvider() { - $cacheTypeMock1 = $this->getMock(\stdClass::class, ['getCacheType']); + $cacheTypeMock1 = $this->createPartialMock(\stdClass::class, ['getCacheType']); $cacheTypeMock1->expects($this->any())->method('getCacheType')->will($this->returnValue('Simple')); - $cacheTypeMock2 = $this->getMock(\stdClass::class, ['getCacheType']); + $cacheTypeMock2 = $this->createPartialMock(\stdClass::class, ['getCacheType']); $cacheTypeMock2->expects($this->any())->method('getCacheType')->will($this->returnValue('Advanced')); return [ @@ -97,7 +97,7 @@ public function testIsDisplayed($expected, $allowed, $cacheTypes) public function isDisplayedDataProvider() { - $cacheTypesMock = $this->getMock(\stdClass::class, ['getCacheType']); + $cacheTypesMock = $this->createPartialMock(\stdClass::class, ['getCacheType']); $cacheTypesMock->expects($this->any())->method('getCacheType')->will($this->returnValue('someVal')); $cacheTypes = [$cacheTypesMock, $cacheTypesMock]; return [ diff --git a/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/Media/Synchronization/ErrorTest.php b/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/Media/Synchronization/ErrorTest.php index 42d377c16d90f..2c259db868851 100644 --- a/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/Media/Synchronization/ErrorTest.php +++ b/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/Media/Synchronization/ErrorTest.php @@ -5,7 +5,7 @@ */ namespace Magento\AdminNotification\Test\Unit\Model\System\Message\Media\Synchronization; -class ErrorTest extends \PHPUnit_Framework_TestCase +class ErrorTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -24,9 +24,12 @@ class ErrorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_syncFlagMock = $this->getMock(\Magento\MediaStorage\Model\File\Storage\Flag::class, [], [], '', false); + $this->_syncFlagMock = $this->createPartialMock( + \Magento\MediaStorage\Model\File\Storage\Flag::class, + ['setState', 'save', 'getFlagData'] + ); - $this->_fileStorage = $this->getMock(\Magento\MediaStorage\Model\File\Storage\Flag::class, [], [], '', false); + $this->_fileStorage = $this->createMock(\Magento\MediaStorage\Model\File\Storage\Flag::class); $this->_fileStorage->expects($this->any())->method('loadSelf')->will($this->returnValue($this->_syncFlagMock)); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); diff --git a/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/SecurityTest.php b/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/SecurityTest.php index 8a69f7adb0876..1e71570a5e30b 100644 --- a/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/SecurityTest.php +++ b/app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/SecurityTest.php @@ -5,7 +5,7 @@ */ namespace Magento\AdminNotification\Test\Unit\Model\System\Message; -class SecurityTest extends \PHPUnit_Framework_TestCase +class SecurityTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -35,14 +35,11 @@ class SecurityTest extends \PHPUnit_Framework_TestCase protected function setUp() { //Prepare objects for constructor - $this->_cacheMock = $this->getMock(\Magento\Framework\App\CacheInterface::class); - $this->_scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $this->_curlFactoryMock = $this->getMock( + $this->_cacheMock = $this->createMock(\Magento\Framework\App\CacheInterface::class); + $this->_scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->_curlFactoryMock = $this->createPartialMock( \Magento\Framework\HTTP\Adapter\CurlFactory::class, - ['create'], - [], - '', - false + ['create'] ); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); @@ -70,7 +67,7 @@ public function testIsDisplayed($expectedResult, $cached, $response) $this->_cacheMock->expects($this->any())->method('load')->will($this->returnValue($cached)); $this->_cacheMock->expects($this->any())->method('save')->will($this->returnValue(null)); - $httpAdapterMock = $this->getMock(\Magento\Framework\HTTP\Adapter\Curl::class, [], [], '', false); + $httpAdapterMock = $this->createMock(\Magento\Framework\HTTP\Adapter\Curl::class); $httpAdapterMock->expects($this->any())->method('read')->will($this->returnValue($response)); $this->_curlFactoryMock->expects($this->any())->method('create')->will($this->returnValue($httpAdapterMock)); diff --git a/app/code/Magento/AdminNotification/Ui/Component/DataProvider/DataProvider.php b/app/code/Magento/AdminNotification/Ui/Component/DataProvider/DataProvider.php index 84176d86f0fcc..6fca6ca8e2e7f 100644 --- a/app/code/Magento/AdminNotification/Ui/Component/DataProvider/DataProvider.php +++ b/app/code/Magento/AdminNotification/Ui/Component/DataProvider/DataProvider.php @@ -10,6 +10,7 @@ /** * @api + * @since 100.2.0 */ class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider { diff --git a/app/code/Magento/AdminNotification/etc/config.xml b/app/code/Magento/AdminNotification/etc/config.xml index b30cec378ca71..fd423cc554499 100644 --- a/app/code/Magento/AdminNotification/etc/config.xml +++ b/app/code/Magento/AdminNotification/etc/config.xml @@ -12,7 +12,7 @@ notifications.magentocommerce.com/magento2/community/notifications.rss widgets.magentocommerce.com/notificationPopup widgets.magentocommerce.com/%s/%s.gif - 0 + 1 1 0 diff --git a/app/code/Magento/AdminNotification/view/adminhtml/ui_component/notification_area.xml b/app/code/Magento/AdminNotification/view/adminhtml/ui_component/notification_area.xml index f58b368e2b0f5..dcf2e996892fb 100644 --- a/app/code/Magento/AdminNotification/view/adminhtml/ui_component/notification_area.xml +++ b/app/code/Magento/AdminNotification/view/adminhtml/ui_component/notification_area.xml @@ -24,6 +24,7 @@ + Magento_AdminNotification::show_list identity diff --git a/app/code/Magento/AdvancedPricingImportExport/Model/Indexer/Product/Price/Plugin/Import.php b/app/code/Magento/AdvancedPricingImportExport/Model/Indexer/Product/Price/Plugin/Import.php index 01ff4a22d8e0f..ab4ba525df846 100644 --- a/app/code/Magento/AdvancedPricingImportExport/Model/Indexer/Product/Price/Plugin/Import.php +++ b/app/code/Magento/AdvancedPricingImportExport/Model/Indexer/Product/Price/Plugin/Import.php @@ -7,8 +7,21 @@ use Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing; -class Import extends \Magento\Catalog\Model\Indexer\Product\Price\Plugin\AbstractPlugin +class Import { + /** + * @var \Magento\Framework\Indexer\IndexerRegistry + */ + private $indexerRegistry; + + /** + * @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry + */ + public function __construct(\Magento\Framework\Indexer\IndexerRegistry $indexerRegistry) + { + $this->indexerRegistry = $indexerRegistry; + } + /** * After import handler * @@ -18,9 +31,7 @@ class Import extends \Magento\Catalog\Model\Indexer\Product\Price\Plugin\Abstrac */ public function afterSaveAdvancedPricing(AdvancedPricing $subject) { - if (!$this->getPriceIndexer()->isScheduled()) { - $this->invalidateIndexer(); - } + $this->invalidateIndexer(); } /** @@ -32,18 +43,19 @@ public function afterSaveAdvancedPricing(AdvancedPricing $subject) */ public function afterDeleteAdvancedPricing(AdvancedPricing $subject) { - if (!$this->getPriceIndexer()->isScheduled()) { - $this->invalidateIndexer(); - } + $this->invalidateIndexer(); } /** - * Get price indexer + * Invalidate indexer * - * @return \Magento\Framework\Indexer\IndexerInterface + * @return void */ - protected function getPriceIndexer() + private function invalidateIndexer() { - return $this->indexerRegistry->get(\Magento\Catalog\Model\Indexer\Product\Price\Processor::INDEXER_ID); + $priceIndexer = $this->indexerRegistry->get(\Magento\Catalog\Model\Indexer\Product\Price\Processor::INDEXER_ID); + if (!$priceIndexer->isScheduled()) { + $priceIndexer->invalidate(); + } } } diff --git a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Export/AdvancedPricingTest.php b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Export/AdvancedPricingTest.php index 8c404cdaf62b3..48b4c58918740 100644 --- a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Export/AdvancedPricingTest.php +++ b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Export/AdvancedPricingTest.php @@ -5,12 +5,12 @@ */ namespace Magento\AdvancedPricingImportExport\Test\Unit\Model\Export; -use \Magento\Store\Model\Store; +use Magento\Store\Model\Store; /** * @SuppressWarnings(PHPMD) */ -class AdvancedPricingTest extends \PHPUnit_Framework_TestCase +class AdvancedPricingTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\Stdlib\DateTime\Timezone|\PHPUnit_Framework_MockObject_MockObject @@ -127,56 +127,14 @@ class AdvancedPricingTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->localeDate = $this->getMock( - \Magento\Framework\Stdlib\DateTime\Timezone::class, - [], - [], - '', - false - ); - $this->config = $this->getMock( - \Magento\Eav\Model\Config::class, - ['getEntityType'], - [], - '', - false - ); - $type = $this->getMock( - \Magento\Eav\Model\Entity\Type::class, - [], - [], - '', - false - ); + $this->localeDate = $this->createMock(\Magento\Framework\Stdlib\DateTime\Timezone::class); + $this->config = $this->createPartialMock(\Magento\Eav\Model\Config::class, ['getEntityType']); + $type = $this->createMock(\Magento\Eav\Model\Entity\Type::class); $this->config->expects($this->once())->method('getEntityType')->willReturn($type); - $this->resource = $this->getMock( - \Magento\Framework\App\ResourceConnection::class, - [], - [], - '', - false - ); - $this->storeManager = $this->getMock( - \Magento\Store\Model\StoreManager::class, - [], - [], - '', - false - ); - $this->logger = $this->getMock( - \Magento\Framework\Logger\Monolog::class, - [], - [], - '', - false - ); - $this->collection = $this->getMock( - \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::class, - [], - [], - '', - false - ); + $this->resource = $this->createMock(\Magento\Framework\App\ResourceConnection::class); + $this->storeManager = $this->createMock(\Magento\Store\Model\StoreManager::class); + $this->logger = $this->createMock(\Magento\Framework\Logger\Monolog::class); + $this->collection = $this->createMock(\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::class); $this->abstractCollection = $this->getMockForAbstractClass( \Magento\Eav\Model\Entity\Collection\AbstractCollection::class, [], @@ -192,110 +150,46 @@ protected function setUp() 'getLastPageNumber', ] ); - $this->exportConfig = $this->getMock( - \Magento\ImportExport\Model\Export\Config::class, - [], - [], - '', - false - ); - $this->productFactory = $this->getMock( - \Magento\Catalog\Model\ResourceModel\ProductFactory::class, - [ + $this->exportConfig = $this->createMock(\Magento\ImportExport\Model\Export\Config::class); + $this->productFactory = $this->createPartialMock(\Magento\Catalog\Model\ResourceModel\ProductFactory::class, [ 'create', 'getTypeId', - ], - [], - '', - false - ); - $this->attrSetColFactory = $this->getMock( + ]); + $this->attrSetColFactory = $this->createPartialMock( \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory::class, [ 'create', 'setEntityTypeFilter', - ], - [], - '', - false + ] ); - $this->categoryColFactory = $this->getMock( + $this->categoryColFactory = $this->createPartialMock( \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory::class, [ 'create', 'addNameToResult', - ], - [], - '', - false - ); - $this->itemFactory = $this->getMock( - \Magento\CatalogInventory\Model\ResourceModel\Stock\ItemFactory::class, - [], - [], - '', - false - ); - $this->optionColFactory = $this->getMock( - \Magento\Catalog\Model\ResourceModel\Product\Option\CollectionFactory::class, - [], - [], - '', - false - ); - $this->attributeColFactory = $this->getMock( - \Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory::class, - [], - [], - '', - false - ); - $this->typeFactory = $this->getMock( - \Magento\CatalogImportExport\Model\Export\Product\Type\Factory::class, - [], - [], - '', - false + ] ); - $this->linkTypeProvider = $this->getMock( - \Magento\Catalog\Model\Product\LinkTypeProvider::class, - [], - [], - '', - false + $this->itemFactory = $this->createMock(\Magento\CatalogInventory\Model\ResourceModel\Stock\ItemFactory::class); + $this->optionColFactory = $this->createMock( + \Magento\Catalog\Model\ResourceModel\Product\Option\CollectionFactory::class ); - $this->rowCustomizer = $this->getMock( - \Magento\CatalogImportExport\Model\Export\RowCustomizer\Composite::class, - [], - [], - '', - false + $this->attributeColFactory = $this->createMock( + \Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory::class ); - $this->storeResolver = $this->getMock( - \Magento\CatalogImportExport\Model\Import\Product\StoreResolver::class, - [], - [], - '', - false + $this->typeFactory = $this->createMock(\Magento\CatalogImportExport\Model\Export\Product\Type\Factory::class); + $this->linkTypeProvider = $this->createMock(\Magento\Catalog\Model\Product\LinkTypeProvider::class); + $this->rowCustomizer = $this->createMock( + \Magento\CatalogImportExport\Model\Export\RowCustomizer\Composite::class ); - $this->groupRepository = $this->getMock( - \Magento\Customer\Api\GroupRepositoryInterface::class, - [], - [], - '', - false + $this->storeResolver = $this->createMock( + \Magento\CatalogImportExport\Model\Import\Product\StoreResolver::class ); - $this->writer = $this->getMock( - \Magento\ImportExport\Model\Export\Adapter\AbstractAdapter::class, - [ + $this->groupRepository = $this->createMock(\Magento\Customer\Api\GroupRepositoryInterface::class); + $this->writer = $this->createPartialMock(\Magento\ImportExport\Model\Export\Adapter\AbstractAdapter::class, [ 'setHeaderCols', 'writeRow', 'getContents', - ], - [], - '', - false - ); + ]); $constructorMethods = [ 'initTypeModels', 'initAttributes', @@ -315,14 +209,16 @@ protected function setUp() 'getItemsPerPage', 'paginateCollection', '_getHeaderColumns', + '_getWebsiteCode', + '_getCustomerGroupById', + 'correctExportData' ]); - $this->advancedPricing = $this->getMock( - \Magento\AdvancedPricingImportExport\Model\Export\AdvancedPricing::class, - $mockMethods, - [], - '', - false - ); + $this->advancedPricing = $this->getMockbuilder( + \Magento\AdvancedPricingImportExport\Model\Export\AdvancedPricing::class + ) + ->setMethods($mockMethods) + ->disableOriginalConstructor() + ->getMock(); foreach ($constructorMethods as $method) { $this->advancedPricing->expects($this->once())->method($method)->will($this->returnSelf()); } diff --git a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/TierPriceTest.php b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/TierPriceTest.php index 7fe9453273a2b..bb64acb558320 100644 --- a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/TierPriceTest.php +++ b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/TierPriceTest.php @@ -6,12 +6,12 @@ namespace Magento\AdvancedPricingImportExport\Test\Unit\Model\Import\AdvancedPricing\Validator; -use \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing as AdvancedPricing; +use Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing as AdvancedPricing; /** * @SuppressWarnings(PHPMD) */ -class TierPriceTest extends \PHPUnit_Framework_TestCase +class TierPriceTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Api\GroupRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject @@ -40,36 +40,22 @@ protected function setUp() ->setMethods(['getList']) ->getMockForAbstractClass(); - $this->searchCriteriaBuilder = $this->getMock( - \Magento\Framework\Api\SearchCriteriaBuilder::class, - [], - [], - '', - false - ); - $this->storeResolver = $this->getMock( - \Magento\CatalogImportExport\Model\Import\Product\StoreResolver::class, - [], - [], - '', - false + $this->searchCriteriaBuilder = $this->createMock(\Magento\Framework\Api\SearchCriteriaBuilder::class); + $this->storeResolver = $this->createMock( + \Magento\CatalogImportExport\Model\Import\Product\StoreResolver::class ); - $this->tierPrice = $this->getMock( - \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator\TierPrice::class, - ['isValidValueAndLength', 'hasEmptyColumns', '_addMessages'], - [ - $this->groupRepository, - $this->searchCriteriaBuilder, - $this->storeResolver, - ], - '' - ); + $this->tierPrice = $this->getMockBuilder( + \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator\TierPrice::class + ) + ->setMethods(['isValidValueAndLength', 'hasEmptyColumns', '_addMessages']) + ->setConstructorArgs([$this->groupRepository, $this->searchCriteriaBuilder, $this->storeResolver]) + ->getMock(); } public function testInitInternalCalls() { - $searchCriteria = $this->getMock(\Magento\Framework\Api\SearchCriteria::class, [], [], '', false); + $searchCriteria = $this->createMock(\Magento\Framework\Api\SearchCriteria::class); $this->searchCriteriaBuilder->expects($this->any())->method('create')->willReturn($searchCriteria); $groupSearchResult = $this->getMockForAbstractClass( \Magento\Customer\Api\Data\GroupSearchResultsInterface::class, @@ -97,7 +83,7 @@ public function testInitInternalCalls() public function testInitAddToCustomerGroups() { - $searchCriteria = $this->getMock(\Magento\Framework\Api\SearchCriteria::class, [], [], '', false); + $searchCriteria = $this->createMock(\Magento\Framework\Api\SearchCriteria::class); $this->searchCriteriaBuilder->expects($this->any())->method('create')->willReturn($searchCriteria); $groupSearchResult = $this->getMockForAbstractClass( \Magento\Customer\Api\Data\GroupSearchResultsInterface::class, @@ -150,27 +136,25 @@ public function testIsValidResultTrue() */ public function testIsValidAddMessagesCall($value, $hasEmptyColumns, $customerGroups, $expectedMessages) { - $priceContextMock = $this->getMock( - \Magento\CatalogImportExport\Model\Import\Product::class, - [], - [ - \Magento\Framework\Json\Helper\Data::class, - \Magento\ImportExport\Helper\Data::class, - \Magento\ImportExport\Model\ResourceModel\Import\Data::class, - \Magento\Eav\Model\Config::class, \Magento\Framework\App\ResourceConnection::class, - \Magento\ImportExport\Model\ResourceModel\Helper::class, - \Magento\Framework\Stdlib\StringUtils::class, - 'ProcessingErrorAggregatorInterface', - ], - '', - false - ); + $priceContextMock = $this->getMockBuilder(\Magento\CatalogImportExport\Model\Import\Product::class) + ->setConstructorArgs( + [ + \Magento\Framework\Json\Helper\Data::class, + \Magento\ImportExport\Helper\Data::class, + \Magento\ImportExport\Model\ResourceModel\Import\Data::class, + \Magento\Eav\Model\Config::class, + \Magento\Framework\App\ResourceConnection::class, + \Magento\ImportExport\Model\ResourceModel\Helper::class, + \Magento\Framework\Stdlib\StringUtils::class, + 'ProcessingErrorAggregatorInterface' + ] + ); $this->tierPrice->expects($this->once())->method('isValidValueAndLength')->willReturn(true); $this->tierPrice->expects($this->any())->method('hasEmptyColumns')->willReturn($hasEmptyColumns); $this->setPropertyValue($this->tierPrice, 'customerGroups', $customerGroups); - $searchCriteria = $this->getMock(\Magento\Framework\Api\SearchCriteria::class, [], [], '', false); + $searchCriteria = $this->createMock(\Magento\Framework\Api\SearchCriteria::class); $this->searchCriteriaBuilder->expects($this->any())->method('create')->willReturn($searchCriteria); $groupSearchResult = $this->getMockForAbstractClass( \Magento\Customer\Api\Data\GroupSearchResultsInterface::class, diff --git a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/TierPriceTypeTest.php b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/TierPriceTypeTest.php index 5660d32f051cc..0dc2a0b7e6ddf 100644 --- a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/TierPriceTypeTest.php +++ b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/TierPriceTypeTest.php @@ -11,7 +11,7 @@ /** * Class TierPriceTypeTest. */ -class TierPriceTypeTest extends \PHPUnit_Framework_TestCase +class TierPriceTypeTest extends \PHPUnit\Framework\TestCase { /** * @var AdvancedPricing\Validator\TierPriceType diff --git a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/WebsiteTest.php b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/WebsiteTest.php index def602c853206..5111b4932d7a8 100644 --- a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/WebsiteTest.php +++ b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/Validator/WebsiteTest.php @@ -8,7 +8,7 @@ use Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing as AdvancedPricing; -class WebsiteTest extends \PHPUnit_Framework_TestCase +class WebsiteTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Store\Model\WebSite|\PHPUnit_Framework_MockObject_MockObject @@ -27,30 +27,21 @@ class WebsiteTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->webSiteModel = $this->getMock( - \Magento\Store\Model\WebSite::class, - ['getBaseCurrency'], - [], - '', - false - ); - $this->storeResolver = $this->getMock( + $this->webSiteModel = $this->getMockBuilder(\Magento\Store\Model\WebSite::class) + ->setMethods(['getBaseCurrency']) + ->disableOriginalConstructor() + ->getMock(); + $this->storeResolver = $this->createPartialMock( \Magento\CatalogImportExport\Model\Import\Product\StoreResolver::class, - ['getWebsiteCodeToId'], - [], - '', - false + ['getWebsiteCodeToId'] ); - $this->website = $this->getMock( - \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator\Website::class, - ['getAllWebsitesValue', '_clearMessages', '_addMessages'], - [ - $this->storeResolver, - $this->webSiteModel, - ], - '' - ); + $this->website = $this->getMockBuilder( + \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator\Website::class + ) + ->setMethods(['getAllWebsitesValue', '_clearMessages', '_addMessages']) + ->setConstructorArgs([$this->storeResolver, $this->webSiteModel]) + ->getMock(); } public function testInit() @@ -106,24 +97,20 @@ public function testIsValidReturnAddMessagesCall() public function testGetAllWebsitesValue() { $currencyCode = 'currencyCodeValue'; - $currency = $this->getMock(\Magento\Directory\Model\Currency::class, ['getCurrencyCode'], [], '', false); + $currency = $this->createPartialMock(\Magento\Directory\Model\Currency::class, ['getCurrencyCode']); $currency->expects($this->once())->method('getCurrencyCode')->willReturn($currencyCode); $this->webSiteModel->expects($this->once())->method('getBaseCurrency')->willReturn($currency); $expectedResult = AdvancedPricing::VALUE_ALL_WEBSITES . ' [' . $currencyCode . ']'; + $this->websiteString = $this->getMockBuilder( + \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator\Website::class + ) + ->setMethods(['_clearMessages', '_addMessages']) + ->setConstructorArgs([$this->storeResolver, $this->webSiteModel]) + ->getMock(); + $result = $this->websiteString->getAllWebsitesValue(); - $website = $this->getMock( - \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator\Website::class, - null, - [ - $this->storeResolver, - $this->webSiteModel, - ], - '' - ); - - $result = $website->getAllWebsitesValue(); $this->assertEquals($expectedResult, $result); } diff --git a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/ValidatorTest.php b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/ValidatorTest.php index c396818a5094d..d9fce98826105 100644 --- a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/ValidatorTest.php +++ b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricing/ValidatorTest.php @@ -5,10 +5,10 @@ */ namespace Magento\AdvancedPricingImportExport\Test\Unit\Model\Import\AdvancedPricing; -use \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator as Validator; -use \Magento\CatalogImportExport\Model\Import\Product\RowValidatorInterface as RowValidatorInterface; +use Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator as Validator; +use Magento\CatalogImportExport\Model\Import\Product\RowValidatorInterface as RowValidatorInterface; -class ValidatorTest extends \PHPUnit_Framework_TestCase +class ValidatorTest extends \PHPUnit\Framework\TestCase { /** * @var Validator |\PHPUnit_Framework_MockObject_MockObject @@ -37,11 +37,12 @@ protected function setUp() $this->validatorTest->expects($this->any())->method('getMessages')->willReturn($messages); $this->validators = [$this->validatorTest]; - $this->validator = $this->getMock( - \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator::class, - ['_clearMessages', '_addMessages'], - [$this->validators] - ); + $this->validator = $this->getMockBuilder( + \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator::class + ) + ->setMethods(['_clearMessages', '_addMessages']) + ->setConstructorArgs([$this->validators]) + ->getMock(); } /** diff --git a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricingTest.php b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricingTest.php index bb4e8c0af12c6..6d130d93ee6a5 100644 --- a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricingTest.php +++ b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Import/AdvancedPricingTest.php @@ -6,9 +6,9 @@ namespace Magento\AdvancedPricingImportExport\Test\Unit\Model\Import; -use \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing as AdvancedPricing; -use \Magento\CatalogImportExport\Model\Import\Proxy\Product\ResourceModelFactory as ResourceFactory; -use \Magento\CatalogImportExport\Model\Import\Product\RowValidatorInterface as RowValidatorInterface; +use Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing as AdvancedPricing; +use Magento\CatalogImportExport\Model\Import\Product\RowValidatorInterface as RowValidatorInterface; +use Magento\CatalogImportExport\Model\Import\Proxy\Product\ResourceModelFactory as ResourceFactory; /** * @SuppressWarnings(PHPMD) @@ -127,34 +127,10 @@ protected function setUp() { parent::setUp(); - $this->jsonHelper = $this->getMock( - \Magento\Framework\Json\Helper\Data::class, - [], - [], - '', - false - ); - $this->importExportData = $this->getMock( - \Magento\ImportExport\Helper\Data::class, - [], - [], - '', - false - ); - $this->resourceHelper = $this->getMock( - \Magento\ImportExport\Model\ResourceModel\Helper::class, - [], - [], - '', - false - ); - $this->resource = $this->getMock( - \Magento\Framework\App\ResourceConnection::class, - ['getConnection'], - [], - '', - false - ); + $this->jsonHelper = $this->createMock(\Magento\Framework\Json\Helper\Data::class); + $this->importExportData = $this->createMock(\Magento\ImportExport\Helper\Data::class); + $this->resourceHelper = $this->createMock(\Magento\ImportExport\Model\ResourceModel\Helper::class); + $this->resource = $this->createPartialMock(\Magento\Framework\App\ResourceConnection::class, ['getConnection']); $this->connection = $this->getMockForAbstractClass( \Magento\Framework\DB\Adapter\AdapterInterface::class, [], @@ -162,101 +138,40 @@ protected function setUp() false ); $this->resource->expects($this->any())->method('getConnection')->willReturn($this->connection); - $this->dataSourceModel = $this->getMock( - \Magento\ImportExport\Model\ResourceModel\Import\Data::class, - [], - [], - '', - false - ); - $this->eavConfig = $this->getMock( - \Magento\Eav\Model\Config::class, - [], - [], - '', - false - ); - $entityType = $this->getMock( - \Magento\Eav\Model\Entity\Type::class, - [], - [], - '', - false - ); + $this->dataSourceModel = $this->createMock(\Magento\ImportExport\Model\ResourceModel\Import\Data::class); + $this->eavConfig = $this->createMock(\Magento\Eav\Model\Config::class); + $entityType = $this->createMock(\Magento\Eav\Model\Entity\Type::class); $entityType->method('getEntityTypeId')->willReturn(''); $this->eavConfig->method('getEntityType')->willReturn($entityType); - $this->resourceFactory = $this->getMock( - \Magento\CatalogImportExport\Model\Import\Proxy\Product\ResourceModelFactory::class, - ['create', 'getTable'], - [], - '', - false - ); + $this->resourceFactory = $this->getMockBuilder( + \Magento\CatalogImportExport\Model\Import\Proxy\Product\ResourceModelFactory::class + ) + ->setMethods(['create', 'getTable']) + ->disableOriginalConstructor() + ->getMock(); $this->resourceFactory->expects($this->any())->method('create')->willReturnSelf(); $this->resourceFactory->expects($this->any())->method('getTable')->willReturn(self::TABLE_NAME); - $this->catalogData = $this->getMock( - \Magento\Catalog\Helper\Data::class, - [], - [], - '', - false - ); - $this->storeResolver = $this->getMock( - \Magento\CatalogImportExport\Model\Import\Product\StoreResolver::class, - [], - [], - '', - false - ); - $this->importProduct = $this->getMock( - \Magento\CatalogImportExport\Model\Import\Product::class, - [], - [], - '', - false + $this->catalogData = $this->createMock(\Magento\Catalog\Helper\Data::class); + $this->storeResolver = $this->createMock( + \Magento\CatalogImportExport\Model\Import\Product\StoreResolver::class ); - $this->productModel = $this->getMock( - \Magento\Catalog\Model\Product::class, - [], - [], - '', - false - ); - $this->validator = $this->getMock( + $this->importProduct = $this->createMock(\Magento\CatalogImportExport\Model\Import\Product::class); + $this->productModel = $this->createMock(\Magento\Catalog\Model\Product::class); + $this->validator = $this->createPartialMock( \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator::class, - ['isValid', 'getMessages'], - [], - '', - false + ['isValid', 'getMessages'] ); - $this->websiteValidator = $this->getMock( - \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator\Website::class, - [], - [], - '', - false - ); - $this->tierPriceValidator = $this->getMock( - \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator\TierPrice::class, - [], - [], - '', - false + $this->websiteValidator = $this->createMock( + \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator\Website::class ); - $this->stringObject = $this->getMock( - \Magento\Framework\Stdlib\StringUtils::class, - [], - [], - '', - false + $this->tierPriceValidator = $this->createMock( + \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator\TierPrice::class ); + $this->stringObject = $this->createMock(\Magento\Framework\Stdlib\StringUtils::class); $this->errorAggregator = $this->getErrorAggregatorObject(); - $this->dateTime = $this->getMock( + $this->dateTime = $this->createPartialMock( \Magento\Framework\Stdlib\DateTime\DateTime::class, - ['date', 'format'], - [], - '', - false + ['date', 'format'] ); $this->dateTime->expects($this->any())->method('date')->willReturnSelf(); @@ -890,7 +805,7 @@ public function testDeleteProductTierPrices( $result ) { $this->advancedPricing = $this->getAdvancedPricingMock(['addRowError', 'retrieveOldSkus']); - $dbSelectMock = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); + $dbSelectMock = $this->createMock(\Magento\Framework\DB\Select::class); if ($listSku) { $this->connection->expects($this->once()) ->method('fetchCol') @@ -983,7 +898,7 @@ public function testProcessCountExistingPrices( 'retrieveOldSkus' ] ); - $dbSelectMock = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); + $dbSelectMock = $this->createMock(\Magento\Framework\DB\Select::class); $this->connection->expects($this->once()) ->method('fetchAssoc') ->willReturn($existingPrices); @@ -1086,20 +1001,8 @@ private function invokeMethod($object, $method, $args = []) */ private function getAdvancedPricingMock($methods = []) { - $metadataPoolMock = $this->getMock( - \Magento\Framework\EntityManager\MetadataPool::class, - [], - [], - '', - false - ); - $metadataMock = $this->getMock( - \Magento\Framework\EntityManager\EntityMetadata::class, - [], - [], - '', - false - ); + $metadataPoolMock = $this->createMock(\Magento\Framework\EntityManager\MetadataPool::class); + $metadataMock = $this->createMock(\Magento\Framework\EntityManager\EntityMetadata::class); $metadataMock->expects($this->any()) ->method('getLinkField') ->willReturn(self::LINK_FIELD); @@ -1107,30 +1010,32 @@ private function getAdvancedPricingMock($methods = []) ->method('getMetaData') ->with(\Magento\Catalog\Api\Data\ProductInterface::class) ->willReturn($metadataMock); - $advancedPricingMock = $this->getMock( - \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing::class, - $methods, - [ - $this->jsonHelper, - $this->importExportData, - $this->dataSourceModel, - $this->eavConfig, - $this->resource, - $this->resourceHelper, - $this->stringObject, - $this->errorAggregator, - $this->dateTime, - $this->resourceFactory, - $this->productModel, - $this->catalogData, - $this->storeResolver, - $this->importProduct, - $this->validator, - $this->websiteValidator, - $this->tierPriceValidator - ], - '' - ); + $advancedPricingMock = $this->getMockBuilder( + \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing::class + ) + ->setMethods($methods) + ->setConstructorArgs( + [ + $this->jsonHelper, + $this->importExportData, + $this->dataSourceModel, + $this->eavConfig, + $this->resource, + $this->resourceHelper, + $this->stringObject, + $this->errorAggregator, + $this->dateTime, + $this->resourceFactory, + $this->productModel, + $this->catalogData, + $this->storeResolver, + $this->importProduct, + $this->validator, + $this->websiteValidator, + $this->tierPriceValidator + ] + ) + ->getMock(); $reflection = new \ReflectionClass(\Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing::class); $reflectionProperty = $reflection->getProperty('metadataPool'); $reflectionProperty->setAccessible(true); diff --git a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Indexer/Product/Price/Plugin/ImportTest.php b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Indexer/Product/Price/Plugin/ImportTest.php index 49b03762a725f..e2afe10137f27 100644 --- a/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Indexer/Product/Price/Plugin/ImportTest.php +++ b/app/code/Magento/AdvancedPricingImportExport/Test/Unit/Model/Indexer/Product/Price/Plugin/ImportTest.php @@ -6,24 +6,29 @@ namespace Magento\AdvancedPricingImportExport\Test\Unit\Model\Indexer\Product\Price\Plugin; -use \Magento\AdvancedPricingImportExport\Model\Indexer\Product\Price\Plugin\Import as Import; +use Magento\AdvancedPricingImportExport\Model\Indexer\Product\Price\Plugin\Import as Import; -class ImportTest extends \PHPUnit_Framework_TestCase +class ImportTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\Indexer\IndexerInterface |\PHPUnit_Framework_MockObject_MockObject */ - protected $indexer; + private $indexer; /** * @var Import |\PHPUnit_Framework_MockObject_MockObject */ - protected $import; + private $import; /** * @var \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing|\PHPUnit_Framework_MockObject_MockObject */ - protected $advancedPricing; + private $advancedPricing; + + /** + * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + */ + private $indexerRegistry; protected function setUp() { @@ -33,36 +38,58 @@ protected function setUp() '', false ); - $this->import = $this->getMock( - \Magento\AdvancedPricingImportExport\Model\Indexer\Product\Price\Plugin\Import::class, - ['getPriceIndexer', 'invalidateIndexer'], - [], - '', - false + $this->indexerRegistry = $this->createMock( + \Magento\Framework\Indexer\IndexerRegistry::class ); - $this->advancedPricing = $this->getMock( - \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing::class, - [], - [], - '', - false + $this->import = new \Magento\AdvancedPricingImportExport\Model\Indexer\Product\Price\Plugin\Import( + $this->indexerRegistry + ); + $this->advancedPricing = $this->createMock( + \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing::class ); - $this->import->expects($this->any())->method('getPriceIndexer')->willReturn($this->indexer); + $this->indexerRegistry->expects($this->any()) + ->method('get') + ->with(\Magento\Catalog\Model\Indexer\Product\Price\Processor::INDEXER_ID) + ->willReturn($this->indexer); } - public function testAfterSaveAdvancedPricing() + public function testAfterSaveReindexIsOnSave() { - $this->indexer->expects($this->once())->method('isScheduled')->willReturn(false); - $this->import->expects($this->once())->method('invalidateIndexer'); + $this->indexer->expects($this->once()) + ->method('isScheduled') + ->willReturn(false); + $this->indexer->expects($this->once()) + ->method('invalidate'); + $this->import->afterSaveAdvancedPricing($this->advancedPricing); + } + public function testAfterSaveReindexIsOnSchedule() + { + $this->indexer->expects($this->once()) + ->method('isScheduled') + ->willReturn(true); + $this->indexer->expects($this->never()) + ->method('invalidate'); $this->import->afterSaveAdvancedPricing($this->advancedPricing); } - public function testAfterDeleteAdvancedPricing() + public function testAfterDeleteReindexIsOnSave() { - $this->indexer->expects($this->once())->method('isScheduled')->willReturn(false); - $this->import->expects($this->once())->method('invalidateIndexer'); + $this->indexer->expects($this->once()) + ->method('isScheduled') + ->willReturn(false); + $this->indexer->expects($this->once()) + ->method('invalidate'); + $this->import->afterSaveAdvancedPricing($this->advancedPricing); + } + public function testAfterDeleteReindexIsOnSchedule() + { + $this->indexer->expects($this->once()) + ->method('isScheduled') + ->willReturn(true); + $this->indexer->expects($this->never()) + ->method('invalidate'); $this->import->afterSaveAdvancedPricing($this->advancedPricing); } } diff --git a/app/code/Magento/Analytics/Api/Data/LinkInterface.php b/app/code/Magento/Analytics/Api/Data/LinkInterface.php deleted file mode 100644 index 6597dff868b9f..0000000000000 --- a/app/code/Magento/Analytics/Api/Data/LinkInterface.php +++ /dev/null @@ -1,24 +0,0 @@ -' . $element->getLabel() . ''; - $html .= '
' . $element->getComment() . '
'; - return $this->decorateRowHtml($element, $html); - } - - /** - * @param \Magento\Framework\Data\Form\Element\AbstractElement $element - * @param string $html - * @return string - */ - private function decorateRowHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element, $html) - { - return sprintf( - '
%s
', - $element->getHtmlId(), - $html - ); - } -} diff --git a/app/code/Magento/Analytics/Block/Adminhtml/System/Config/CollectionTimeLabel.php b/app/code/Magento/Analytics/Block/Adminhtml/System/Config/CollectionTimeLabel.php deleted file mode 100644 index c4118792255cd..0000000000000 --- a/app/code/Magento/Analytics/Block/Adminhtml/System/Config/CollectionTimeLabel.php +++ /dev/null @@ -1,29 +0,0 @@ -_localeDate->getConfigTimezone(); - $getLongTimeZoneName = \IntlTimeZone::createTimeZone($timeZoneCode)->getDisplayName(); - $element->setData( - 'comment', - sprintf("%s (%s)", $getLongTimeZoneName, $timeZoneCode) - ); - return parent::render($element); - } -} diff --git a/app/code/Magento/Analytics/Block/Adminhtml/System/Config/SubscriptionStatusLabel.php b/app/code/Magento/Analytics/Block/Adminhtml/System/Config/SubscriptionStatusLabel.php deleted file mode 100644 index c09213c7f009d..0000000000000 --- a/app/code/Magento/Analytics/Block/Adminhtml/System/Config/SubscriptionStatusLabel.php +++ /dev/null @@ -1,64 +0,0 @@ -subscriptionStatusProvider = $labelStatusProvider; - } - - /** - * Add Subscription status to comment - * - * @param \Magento\Framework\Data\Form\Element\AbstractElement $element - * @return string - */ - public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element) - { - $element->setData( - 'comment', - $this->prepareLabelValue() - ); - return parent::render($element); - } - - /** - * Prepare label for subscription status - * - * @return string - */ - private function prepareLabelValue() - { - return __('Subscription status') . ': ' . __($this->subscriptionStatusProvider->getStatus()); - } -} diff --git a/app/code/Magento/Analytics/Controller/Adminhtml/BIEssentials/SignUp.php b/app/code/Magento/Analytics/Controller/Adminhtml/BIEssentials/SignUp.php deleted file mode 100644 index a90a971cf41b4..0000000000000 --- a/app/code/Magento/Analytics/Controller/Adminhtml/BIEssentials/SignUp.php +++ /dev/null @@ -1,64 +0,0 @@ -config = $config; - parent::__construct($context); - } - - /** - * Check admin permissions for this controller - * - * @return boolean - */ - protected function _isAllowed() - { - return $this->_authorization->isAllowed('Magento_Analytics::bi_essentials'); - } - - /** - * Provides link to BI Essentials signup - * - * @return \Magento\Framework\Controller\AbstractResult - */ - public function execute() - { - return $this->resultRedirectFactory->create()->setUrl( - $this->config->getValue($this->urlBIEssentialsConfigPath) - ); - } -} diff --git a/app/code/Magento/Analytics/Controller/Adminhtml/Reports/Show.php b/app/code/Magento/Analytics/Controller/Adminhtml/Reports/Show.php deleted file mode 100644 index 1b0e5c92420de..0000000000000 --- a/app/code/Magento/Analytics/Controller/Adminhtml/Reports/Show.php +++ /dev/null @@ -1,75 +0,0 @@ -reportUrlProvider = $reportUrlProvider; - parent::__construct($context); - } - - /** - * Check admin permissions for this controller. - * - * @return boolean - */ - protected function _isAllowed() - { - return $this->_authorization->isAllowed('Magento_Analytics::analytics_settings'); - } - - /** - * Redirect to resource with reports. - * - * @return Redirect $resultRedirect - */ - public function execute() - { - /** @var Redirect $resultRedirect */ - $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); - try { - $resultRedirect->setUrl($this->reportUrlProvider->getUrl()); - } catch (SubscriptionUpdateException $e) { - $this->getMessageManager()->addNoticeMessage($e->getMessage()); - $resultRedirect->setPath('adminhtml'); - } catch (LocalizedException $e) { - $this->getMessageManager()->addExceptionMessage($e, $e->getMessage()); - $resultRedirect->setPath('adminhtml'); - } catch (\Exception $e) { - $this->getMessageManager()->addExceptionMessage( - $e, - __('Sorry, there has been an error processing your request. Please try again later.') - ); - $resultRedirect->setPath('adminhtml'); - } - - return $resultRedirect; - } -} diff --git a/app/code/Magento/Analytics/Controller/Adminhtml/Subscription/Activate.php b/app/code/Magento/Analytics/Controller/Adminhtml/Subscription/Activate.php deleted file mode 100644 index b5731fc07bb07..0000000000000 --- a/app/code/Magento/Analytics/Controller/Adminhtml/Subscription/Activate.php +++ /dev/null @@ -1,133 +0,0 @@ -logger = $logger; - $this->notificationTime = $notificationTime; - $this->configValueResource = $configValueResource; - $this->preparedValueFactory = $preparedValueFactory; - parent::__construct($context); - } - - /** - * Check admin permissions for this controller - * - * @return boolean - */ - protected function _isAllowed() - { - return $this->_authorization->isAllowed('Magento_Analytics::analytics_settings'); - } - - /** - * Activate subscription to Magento BI via AJAX. - * - * @return Json - */ - public function execute() - { - try { - if ($this->getRequest()->getParam($this->subscriptionApprovedField)) { - $configValue = $this->preparedValueFactory->create( - Enabled::XML_ENABLED_CONFIG_STRUCTURE_PATH, - Enabledisable::ENABLE_VALUE, - ScopeConfigInterface::SCOPE_TYPE_DEFAULT - ); - - $this->configValueResource - ->save($configValue); - } else { - $this->notificationTime->unsetLastTimeNotificationValue(); - } - $responseContent = [ - 'success' => true, - 'error_message' => '', - ]; - } catch (LocalizedException $e) { - $responseContent = [ - 'success' => false, - 'error_message' => $e->getMessage(), - ]; - $this->logger->error($e->getMessage()); - } catch (\Exception $e) { - $responseContent = [ - 'success' => false, - 'error_message' => __( - 'Sorry, there was an error processing your registration request to Magento Analytics. ' - . 'Please try again later.' - ), - ]; - $this->logger->error($e->getMessage()); - } - /** @var Json $resultJson */ - $resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON); - return $resultJson->setData($responseContent); - } -} diff --git a/app/code/Magento/Analytics/Controller/Adminhtml/Subscription/Postpone.php b/app/code/Magento/Analytics/Controller/Adminhtml/Subscription/Postpone.php deleted file mode 100644 index 29918be63d898..0000000000000 --- a/app/code/Magento/Analytics/Controller/Adminhtml/Subscription/Postpone.php +++ /dev/null @@ -1,96 +0,0 @@ -dateTimeFactory = $dateTimeFactory; - $this->notificationTime = $notificationTime; - $this->logger = $logger; - parent::__construct($context); - } - - /** - * Check admin permissions for this controller - * - * @return boolean - */ - protected function _isAllowed() - { - return $this->_authorization->isAllowed('Magento_Analytics::analytics_settings'); - } - - /** - * Postpones notification about subscription - * - * @return Json - */ - public function execute() - { - try { - $dateTime = $this->dateTimeFactory->create(); - $responseContent = [ - 'success' => $this->notificationTime->storeLastTimeNotification($dateTime->getTimestamp()), - 'error_message' => '' - ]; - } catch (LocalizedException $e) { - $this->logger->error($e->getMessage()); - $responseContent = [ - 'success' => false, - 'error_message' => $e->getMessage() - ]; - } catch (\Exception $e) { - $this->logger->error($e->getMessage()); - $responseContent = [ - 'success' => false, - 'error_message' => __('Error occurred during postponement notification') - ]; - } - /** @var Json $resultJson */ - $resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON); - return $resultJson->setData($responseContent); - } -} diff --git a/app/code/Magento/Analytics/Controller/Adminhtml/Subscription/Retry.php b/app/code/Magento/Analytics/Controller/Adminhtml/Subscription/Retry.php deleted file mode 100644 index 122cf74123cc9..0000000000000 --- a/app/code/Magento/Analytics/Controller/Adminhtml/Subscription/Retry.php +++ /dev/null @@ -1,73 +0,0 @@ -subscriptionHandler = $subscriptionHandler; - parent::__construct($context); - } - - /** - * Check admin permissions for this controller - * - * @return boolean - */ - protected function _isAllowed() - { - return $this->_authorization->isAllowed('Magento_Analytics::analytics_settings'); - } - - /** - * Retry process of subscription. - * - * @return Redirect - */ - public function execute() - { - /** @var Redirect $resultRedirect */ - $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); - try { - $resultRedirect->setPath('adminhtml'); - $this->subscriptionHandler->processEnabled(); - } catch (LocalizedException $e) { - $this->getMessageManager()->addExceptionMessage($e, $e->getMessage()); - } catch (\Exception $e) { - $this->getMessageManager()->addExceptionMessage( - $e, - __('Sorry, there has been an error processing your request. Please try again later.') - ); - } - - return $resultRedirect; - } -} diff --git a/app/code/Magento/Analytics/Cron/CollectData.php b/app/code/Magento/Analytics/Cron/CollectData.php deleted file mode 100644 index ff0b3e4f67638..0000000000000 --- a/app/code/Magento/Analytics/Cron/CollectData.php +++ /dev/null @@ -1,53 +0,0 @@ -exportDataHandler = $exportDataHandler; - $this->subscriptionStatus = $subscriptionStatus; - } - - /** - * @return bool - */ - public function execute() - { - if ($this->subscriptionStatus->getStatus() === SubscriptionStatusProvider::ENABLED) { - $this->exportDataHandler->prepareExportData(); - } - - return true; - } -} diff --git a/app/code/Magento/Analytics/Cron/SignUp.php b/app/code/Magento/Analytics/Cron/SignUp.php deleted file mode 100644 index c17b9b8c381c3..0000000000000 --- a/app/code/Magento/Analytics/Cron/SignUp.php +++ /dev/null @@ -1,101 +0,0 @@ -connector = $connector; - $this->configWriter = $configWriter; - $this->flagManager = $flagManager; - $this->reinitableConfig = $reinitableConfig; - } - - /** - * Execute scheduled subscription operation - * In case of failure writes message to notifications inbox - * - * @return bool - */ - public function execute() - { - $attemptsCount = $this->flagManager->getFlagData(SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE); - - if (($attemptsCount === null) || ($attemptsCount <= 0)) { - $this->deleteAnalyticsCronExpr(); - $this->flagManager->deleteFlag(SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE); - return false; - } - - $attemptsCount -= 1; - $this->flagManager->saveFlag(SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE, $attemptsCount); - $signUpResult = $this->connector->execute('signUp'); - if ($signUpResult === false) { - return false; - } - - $this->deleteAnalyticsCronExpr(); - $this->flagManager->deleteFlag(SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE); - return true; - } - - /** - * Delete cron schedule setting into config. - * - * Delete cron schedule setting for subscription handler into config and - * re-initialize config cache to avoid auto-generate new schedule items. - * - * @return bool - */ - private function deleteAnalyticsCronExpr() - { - $this->configWriter->delete(SubscriptionHandler::CRON_STRING_PATH); - $this->reinitableConfig->reinit(); - return true; - } -} diff --git a/app/code/Magento/Analytics/Cron/Update.php b/app/code/Magento/Analytics/Cron/Update.php deleted file mode 100644 index 9062a7bac7551..0000000000000 --- a/app/code/Magento/Analytics/Cron/Update.php +++ /dev/null @@ -1,92 +0,0 @@ -connector = $connector; - $this->configWriter = $configWriter; - $this->reinitableConfig = $reinitableConfig; - $this->flagManager = $flagManager; - $this->analyticsToken = $analyticsToken; - } - - /** - * Execute scheduled update operation - * - * @return bool - */ - public function execute() - { - $result = false; - $attemptsCount = $this->flagManager - ->getFlagData(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE); - - if ($attemptsCount) { - $attemptsCount -= 1; - $result = $this->connector->execute('update'); - } - - if ($result || ($attemptsCount <= 0) || (!$this->analyticsToken->isTokenExist())) { - $this->flagManager - ->deleteFlag(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE); - $this->flagManager->deleteFlag(SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE); - $this->configWriter->delete(SubscriptionUpdateHandler::UPDATE_CRON_STRING_PATH); - $this->reinitableConfig->reinit(); - } - - return $result; - } -} diff --git a/app/code/Magento/Analytics/Model/AnalyticsToken.php b/app/code/Magento/Analytics/Model/AnalyticsToken.php deleted file mode 100644 index ccec4d1bbe958..0000000000000 --- a/app/code/Magento/Analytics/Model/AnalyticsToken.php +++ /dev/null @@ -1,92 +0,0 @@ -reinitableConfig = $reinitableConfig; - $this->config = $config; - $this->configWriter = $configWriter; - } - - /** - * Get Magento BI token value. - * - * @return string|null - */ - public function getToken() - { - return $this->config->getValue($this->tokenPath); - } - - /** - * Stores Magento BI token value. - * - * @param string $value - * - * @return bool - */ - public function storeToken($value) - { - $this->configWriter->save($this->tokenPath, $value); - $this->reinitableConfig->reinit(); - - return true; - } - - /** - * Check Magento BI token value exist. - * - * @return bool - */ - public function isTokenExist() - { - return (bool)$this->getToken(); - } -} diff --git a/app/code/Magento/Analytics/Model/Condition/CanViewNotification.php b/app/code/Magento/Analytics/Model/Condition/CanViewNotification.php deleted file mode 100644 index bffe746fe7383..0000000000000 --- a/app/code/Magento/Analytics/Model/Condition/CanViewNotification.php +++ /dev/null @@ -1,80 +0,0 @@ -notificationTime = $notificationTime; - $this->dateTimeFactory = $dateTimeFactory; - } - - /** - * Validate is notification popup can be shown - * - * @inheritdoc - */ - public function isVisible(array $arguments) - { - $lastNotificationTime = $this->notificationTime->getLastTimeNotification(); - if (!$lastNotificationTime) { - return false; - } - $datetime = $this->dateTimeFactory->create(); - return ( - $datetime->getTimestamp() >= $lastNotificationTime + $this->notificationInterval - ); - } - - /** - * @return string - */ - public function getName() - { - return self::NAME; - } -} diff --git a/app/code/Magento/Analytics/Model/Config.php b/app/code/Magento/Analytics/Model/Config.php deleted file mode 100644 index ba508187b4b9f..0000000000000 --- a/app/code/Magento/Analytics/Model/Config.php +++ /dev/null @@ -1,40 +0,0 @@ -data = $data; - } - - /** - * Get config value by key. - * - * @param string|null $key - * @param string|null $default - * @return array - */ - public function get($key = null, $default = null) - { - return $this->data->get($key, $default); - } -} diff --git a/app/code/Magento/Analytics/Model/Config/Backend/Baseurl/SubscriptionUpdateHandler.php b/app/code/Magento/Analytics/Model/Config/Backend/Baseurl/SubscriptionUpdateHandler.php deleted file mode 100644 index 6e6f008d49f7e..0000000000000 --- a/app/code/Magento/Analytics/Model/Config/Backend/Baseurl/SubscriptionUpdateHandler.php +++ /dev/null @@ -1,107 +0,0 @@ -analyticsToken = $analyticsToken; - $this->flagManager = $flagManager; - $this->reinitableConfig = $reinitableConfig; - $this->configWriter = $configWriter; - } - - /** - * Activate process of subscription update handling. - * - * @param string $url - * @return bool - */ - public function processUrlUpdate(string $url) - { - if ($this->analyticsToken->isTokenExist()) { - if (!$this->flagManager->getFlagData(self::PREVIOUS_BASE_URL_FLAG_CODE)) { - $this->flagManager->saveFlag(self::PREVIOUS_BASE_URL_FLAG_CODE, $url); - } - - $this->flagManager - ->saveFlag(self::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE, $this->attemptsInitValue); - $this->configWriter->save(self::UPDATE_CRON_STRING_PATH, $this->cronExpression); - $this->reinitableConfig->reinit(); - } - - return true; - } -} diff --git a/app/code/Magento/Analytics/Model/Config/Backend/CollectionTime.php b/app/code/Magento/Analytics/Model/Config/Backend/CollectionTime.php deleted file mode 100644 index e26ad01fc74bf..0000000000000 --- a/app/code/Magento/Analytics/Model/Config/Backend/CollectionTime.php +++ /dev/null @@ -1,91 +0,0 @@ -configWriter = $configWriter; - parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); - } - - /** - * {@inheritdoc} - * - * {@inheritdoc}. Set schedule setting for cron. - * - * @return Value - */ - public function afterSave() - { - $result = preg_match('#(?\d{2}),(?\d{2}),(?\d{2})#', $this->getValue(), $time); - - if (!$result) { - throw new LocalizedException(__('Time value has an unsupported format')); - } - - $cronExprArray = [ - $time['min'], # Minute - $time['hour'], # Hour - '*', # Day of the Month - '*', # Month of the Year - '*', # Day of the Week - ]; - - $cronExprString = join(' ', $cronExprArray); - - try { - $this->configWriter->save(self::CRON_SCHEDULE_PATH, $cronExprString); - } catch (\Exception $e) { - $this->_logger->error($e->getMessage()); - throw new LocalizedException(__('Cron settings can\'t be saved')); - } - - return parent::afterSave(); - } -} diff --git a/app/code/Magento/Analytics/Model/Config/Backend/Enabled.php b/app/code/Magento/Analytics/Model/Config/Backend/Enabled.php deleted file mode 100644 index ac97f2a843e61..0000000000000 --- a/app/code/Magento/Analytics/Model/Config/Backend/Enabled.php +++ /dev/null @@ -1,84 +0,0 @@ -subscriptionHandler = $subscriptionHandler; - parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); - } - - /** - * Add additional handling after config value was saved. - * - * @return Value - * @throws LocalizedException - */ - public function afterSave() - { - try { - if ($this->isValueChanged()) { - $enabled = $this->getData('value'); - - if ($enabled) { - $this->subscriptionHandler->processEnabled(); - } else { - $this->subscriptionHandler->processDisabled(); - } - } - } catch (\Exception $e) { - $this->_logger->error($e->getMessage()); - throw new LocalizedException(__('There was an error save new configuration value.')); - } - - return parent::afterSave(); - } -} diff --git a/app/code/Magento/Analytics/Model/Config/Backend/Enabled/SubscriptionHandler.php b/app/code/Magento/Analytics/Model/Config/Backend/Enabled/SubscriptionHandler.php deleted file mode 100644 index d23f5a7c60d91..0000000000000 --- a/app/code/Magento/Analytics/Model/Config/Backend/Enabled/SubscriptionHandler.php +++ /dev/null @@ -1,184 +0,0 @@ -configWriter = $configWriter; - $this->flagManager = $flagManager; - $this->analyticsToken = $analyticsToken; - $this->notificationTime = $notificationTime; - $this->reinitableConfig = $reinitableConfig; - } - - /** - * Processing of activation MBI subscription. - * - * Activate process of subscription handling if Analytics token is not received. - * - * @return bool - */ - public function processEnabled() - { - if (!$this->analyticsToken->isTokenExist()) { - $this->setCronSchedule(); - $this->setAttemptsFlag(); - $this->notificationTime->unsetLastTimeNotificationValue(); - $this->reinitableConfig->reinit(); - } - - return true; - } - - /** - * Set cron schedule setting into config for activation of subscription process. - * - * @return bool - */ - private function setCronSchedule() - { - $cronExprArray = [ - '0', # Minute - '*', # Hour - '*', # Day of the Month - '*', # Month of the Year - '*', # Day of the Week - ]; - - $cronExprString = join(' ', $cronExprArray); - - $this->configWriter->save(self::CRON_STRING_PATH, $cronExprString); - - return true; - } - - /** - * Set flag as reserve counter of attempts subscription operation. - * - * @return bool - */ - private function setAttemptsFlag() - { - return $this->flagManager - ->saveFlag(self::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE, $this->attemptsInitValue); - } - - /** - * Processing of deactivation MBI subscription. - * - * Disable data collection - * and interrupt subscription handling if Analytics token is not received. - * - * @return bool - */ - public function processDisabled() - { - $this->disableCollectionData(); - - if (!$this->analyticsToken->isTokenExist()) { - $this->unsetAttemptsFlag(); - } - - return true; - } - - /** - * Unset flag of attempts subscription operation. - * - * @return bool - */ - private function unsetAttemptsFlag() - { - return $this->flagManager - ->deleteFlag(self::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE); - } - - /** - * Unset schedule of collection data cron. - * - * @return bool - */ - private function disableCollectionData() - { - $this->configWriter->delete(CollectionTime::CRON_SCHEDULE_PATH); - - return true; - } -} diff --git a/app/code/Magento/Analytics/Model/Config/Backend/Vertical.php b/app/code/Magento/Analytics/Model/Config/Backend/Vertical.php deleted file mode 100644 index 1aabbb91ddf87..0000000000000 --- a/app/code/Magento/Analytics/Model/Config/Backend/Vertical.php +++ /dev/null @@ -1,32 +0,0 @@ -getValue())) { - throw new LocalizedException(__('Please select a vertical.')); - } - - return $this; - } -} diff --git a/app/code/Magento/Analytics/Model/Config/Mapper.php b/app/code/Magento/Analytics/Model/Config/Mapper.php deleted file mode 100644 index 504690b8e4763..0000000000000 --- a/app/code/Magento/Analytics/Model/Config/Mapper.php +++ /dev/null @@ -1,66 +0,0 @@ - [ - * 'name' => 'file_name', - * 'providers' => [ - * 'reportProvider' => [ - * 'name' => 'report_provider_name', - * 'class' => 'Magento\Analytics\ReportXml\ReportProvider', - * 'parameters' =>[ - * 'name' => 'report_name', - * ], - * ], - * 'customProvider' => [ - * 'name' => 'custom_provider_name', - * 'class' => 'Magento\Analytics\Model\CustomProvider', - * ], - * ], - * ] - * ]; - */ - public function execute($configData) - { - if (!isset($configData['config'][0]['file'])) { - return []; - } - - $files = []; - foreach ($configData['config'][0]['file'] as $fileData) { - /** just one set of providers is allowed by xsd */ - $providers = reset($fileData['providers']); - foreach ($providers as $providerType => $providerDataSet) { - /** just one set of provider data is allowed by xsd */ - $providerData = reset($providerDataSet); - /** just one set of parameters is allowed by xsd */ - $providerData['parameters'] = !empty($providerData['parameters']) - ? reset($providerData['parameters']) - : []; - $providerData['parameters'] = array_map( - 'reset', - $providerData['parameters'] - ); - $providers[$providerType] = $providerData; - } - $files[$fileData['name']] = $fileData; - $files[$fileData['name']]['providers'] = $providers; - } - return $files; - } -} diff --git a/app/code/Magento/Analytics/Model/Config/Reader.php b/app/code/Magento/Analytics/Model/Config/Reader.php deleted file mode 100644 index 8980e31627717..0000000000000 --- a/app/code/Magento/Analytics/Model/Config/Reader.php +++ /dev/null @@ -1,52 +0,0 @@ -mapper = $mapper; - $this->readers = $readers; - } - - /** - * Read configuration scope. - * - * @param string|null $scope - * @return array - */ - public function read($scope = null) - { - $data = []; - foreach ($this->readers as $reader) { - $data = array_merge_recursive($data, $reader->read($scope)); - } - - return $this->mapper->execute($data); - } -} diff --git a/app/code/Magento/Analytics/Model/Config/Source/Vertical.php b/app/code/Magento/Analytics/Model/Config/Source/Vertical.php deleted file mode 100644 index c9d9582ea7c7a..0000000000000 --- a/app/code/Magento/Analytics/Model/Config/Source/Vertical.php +++ /dev/null @@ -1,51 +0,0 @@ -verticals = $verticals; - } - - /** - * {@inheritdoc} - */ - public function toOptionArray() - { - $result = [ - ['value' => '', 'label' => __('--Please Select--')] - ]; - - foreach ($this->verticals as $vertical) { - $result[] = ['value' => $vertical, 'label' => __($vertical)]; - } - - return $result; - } -} diff --git a/app/code/Magento/Analytics/Model/ConfigInterface.php b/app/code/Magento/Analytics/Model/ConfigInterface.php deleted file mode 100644 index caaa2e100c1c7..0000000000000 --- a/app/code/Magento/Analytics/Model/ConfigInterface.php +++ /dev/null @@ -1,22 +0,0 @@ - 'command_class_name'. - * - * The list may be configured in each module via '/etc/di.xml'. - * - * @var string[] - */ - private $commands; - - /** - * @var ObjectManagerInterface - */ - private $objectManager; - - /** - * @param array $commands - * @param ObjectManagerInterface $objectManager - */ - public function __construct( - array $commands, - ObjectManagerInterface $objectManager - ) { - $this->commands = $commands; - $this->objectManager = $objectManager; - } - - /** - * Executes a command in accordance with the given name. - * - * @param string $commandName - * @return bool - * @throws NotFoundException if the command is not found. - */ - public function execute($commandName) - { - if (!array_key_exists($commandName, $this->commands)) { - throw new NotFoundException(__('Command was not found.')); - } - - /** @var \Magento\Analytics\Model\Connector\CommandInterface $command */ - $command = $this->objectManager->create($this->commands[$commandName]); - - return $command->execute(); - } -} diff --git a/app/code/Magento/Analytics/Model/Connector/CommandInterface.php b/app/code/Magento/Analytics/Model/Connector/CommandInterface.php deleted file mode 100644 index 7a8774fe3dba9..0000000000000 --- a/app/code/Magento/Analytics/Model/Connector/CommandInterface.php +++ /dev/null @@ -1,21 +0,0 @@ -curlFactory = $curlFactory; - $this->responseFactory = $responseFactory; - $this->converter = $converter; - $this->logger = $logger; - } - - /** - * {@inheritdoc} - */ - public function request($method, $url, array $body = [], array $headers = [], $version = '1.1') - { - $response = new \Zend_Http_Response(0, []); - - try { - $curl = $this->curlFactory->create(); - $headers = $this->applyContentTypeHeaderFromConverter($headers); - - $curl->write($method, $url, $version, $headers, $this->converter->toBody($body)); - - $result = $curl->read(); - - if ($curl->getErrno()) { - $this->logger->critical( - new \Exception( - sprintf( - 'MBI service CURL connection error #%s: %s', - $curl->getErrno(), - $curl->getError() - ) - ) - ); - - return $response; - } - - $response = $this->responseFactory->create($result); - } catch (\Exception $e) { - $this->logger->critical($e); - } - - return $response; - } - - /** - * @param array $headers - * - * @return array - */ - private function applyContentTypeHeaderFromConverter(array $headers) - { - $contentTypeHeaderKey = array_search($this->converter->getContentTypeHeader(), $headers); - if ($contentTypeHeaderKey === false) { - $headers[] = $this->converter->getContentTypeHeader(); - } - - return $headers; - } -} diff --git a/app/code/Magento/Analytics/Model/Connector/Http/ClientInterface.php b/app/code/Magento/Analytics/Model/Connector/Http/ClientInterface.php deleted file mode 100644 index a1e1f057684f6..0000000000000 --- a/app/code/Magento/Analytics/Model/Connector/Http/ClientInterface.php +++ /dev/null @@ -1,29 +0,0 @@ -converter = $converter; - $this->responseHandlers = $responseHandlers; - } - - /** - * @param \Zend_Http_Response $response - * - * @return bool|string - */ - public function getResult(\Zend_Http_Response $response) - { - $result = false; - $responseBody = $this->converter->fromBody($response->getBody()); - if (array_key_exists($response->getStatus(), $this->responseHandlers)) { - $result = $this->responseHandlers[$response->getStatus()]->handleResponse($responseBody); - } - - return $result; - } -} diff --git a/app/code/Magento/Analytics/Model/Connector/NotifyDataChangedCommand.php b/app/code/Magento/Analytics/Model/Connector/NotifyDataChangedCommand.php deleted file mode 100644 index f1a8ea6460f9d..0000000000000 --- a/app/code/Magento/Analytics/Model/Connector/NotifyDataChangedCommand.php +++ /dev/null @@ -1,93 +0,0 @@ -analyticsToken = $analyticsToken; - $this->httpClient = $httpClient; - $this->config = $config; - $this->responseResolver = $responseResolver; - $this->logger = $logger; - } - - /** - * Notify MBI about that data collection was finished - * - * @return bool - */ - public function execute() - { - $result = false; - if ($this->analyticsToken->isTokenExist()) { - $response = $this->httpClient->request( - ZendClient::POST, - $this->config->getValue($this->notifyDataChangedUrlPath), - [ - "access-token" => $this->analyticsToken->getToken(), - "url" => $this->config->getValue(Store::XML_PATH_SECURE_BASE_URL), - ] - ); - $result = $this->responseResolver->getResult($response); - } - return (bool)$result; - } -} diff --git a/app/code/Magento/Analytics/Model/Connector/OTPRequest.php b/app/code/Magento/Analytics/Model/Connector/OTPRequest.php deleted file mode 100644 index dfa283e10d070..0000000000000 --- a/app/code/Magento/Analytics/Model/Connector/OTPRequest.php +++ /dev/null @@ -1,115 +0,0 @@ -analyticsToken = $analyticsToken; - $this->httpClient = $httpClient; - $this->config = $config; - $this->responseResolver = $responseResolver; - $this->logger = $logger; - } - - /** - * Performs obtaining of an OTP from the MBI service. - * - * Returns received OTP or FALSE in case of failure. - * - * @return string|false - */ - public function call() - { - $result = false; - - if ($this->analyticsToken->isTokenExist()) { - $response = $this->httpClient->request( - ZendClient::POST, - $this->config->getValue($this->otpUrlConfigPath), - [ - "access-token" => $this->analyticsToken->getToken(), - "url" => $this->config->getValue(Store::XML_PATH_SECURE_BASE_URL), - ] - ); - - $result = $this->responseResolver->getResult($response); - if (!$result) { - $this->logger->warning( - sprintf( - 'Obtaining of an OTP from the MBI service has been failed: %s', - !empty($response->getBody()) ? $response->getBody() : 'Response body is empty.' - ) - ); - } - } - - return $result; - } -} diff --git a/app/code/Magento/Analytics/Model/Connector/ResponseHandler/OTP.php b/app/code/Magento/Analytics/Model/Connector/ResponseHandler/OTP.php deleted file mode 100644 index d9a672e81f43d..0000000000000 --- a/app/code/Magento/Analytics/Model/Connector/ResponseHandler/OTP.php +++ /dev/null @@ -1,24 +0,0 @@ -analyticsToken = $analyticsToken; - $this->subscriptionHandler = $subscriptionHandler; - $this->subscriptionStatusProvider = $subscriptionStatusProvider; - } - - /** - * @inheritdoc - */ - public function handleResponse(array $responseBody) - { - if ($this->subscriptionStatusProvider->getStatus() === SubscriptionStatusProvider::ENABLED) { - $this->analyticsToken->storeToken(null); - $this->subscriptionHandler->processEnabled(); - } - return false; - } -} diff --git a/app/code/Magento/Analytics/Model/Connector/ResponseHandler/SignUp.php b/app/code/Magento/Analytics/Model/Connector/ResponseHandler/SignUp.php deleted file mode 100644 index b2261e418abc7..0000000000000 --- a/app/code/Magento/Analytics/Model/Connector/ResponseHandler/SignUp.php +++ /dev/null @@ -1,51 +0,0 @@ -analyticsToken = $analyticsToken; - $this->converter = $converter; - } - - /** - * @inheritdoc - */ - public function handleResponse(array $body) - { - if (isset($body['access-token']) && !empty($body['access-token'])) { - $this->analyticsToken->storeToken($body['access-token']); - return $body['access-token']; - } - - return false; - } -} diff --git a/app/code/Magento/Analytics/Model/Connector/ResponseHandler/Update.php b/app/code/Magento/Analytics/Model/Connector/ResponseHandler/Update.php deleted file mode 100644 index 73fc575ae2821..0000000000000 --- a/app/code/Magento/Analytics/Model/Connector/ResponseHandler/Update.php +++ /dev/null @@ -1,24 +0,0 @@ -analyticsToken = $analyticsToken; - $this->integrationManager = $integrationManager; - $this->config = $config; - $this->httpClient = $httpClient; - $this->logger = $logger; - $this->responseResolver = $responseResolver; - } - - /** - * Executes signUp command - * - * During this call Magento generates or retrieves access token for the integration user - * In case successful generation Magento activates user and sends access token to MA - * As the response, Magento receives a token to MA - * Magento stores this token in System Configuration - * - * This method returns true in case of success - * - * @return bool - */ - public function execute() - { - $result = false; - $integrationToken = $this->integrationManager->generateToken(); - if ($integrationToken) { - $this->integrationManager->activateIntegration(); - $response = $this->httpClient->request( - ZendClient::POST, - $this->config->getValue($this->signUpUrlPath), - [ - "token" => $integrationToken->getData('token'), - "url" => $this->config->getValue(Store::XML_PATH_SECURE_BASE_URL), - ] - ); - - $result = $this->responseResolver->getResult($response); - if (!$result) { - $this->logger->warning( - sprintf( - 'Subscription for MBI service has been failed. An error occurred during token exchange: %s', - !empty($response->getBody()) ? $response->getBody() : 'Response body is empty.' - ) - ); - } - } - - return (bool)$result; - } -} diff --git a/app/code/Magento/Analytics/Model/Connector/UpdateCommand.php b/app/code/Magento/Analytics/Model/Connector/UpdateCommand.php deleted file mode 100644 index 8f05f1107e87e..0000000000000 --- a/app/code/Magento/Analytics/Model/Connector/UpdateCommand.php +++ /dev/null @@ -1,114 +0,0 @@ -analyticsToken = $analyticsToken; - $this->httpClient = $httpClient; - $this->config = $config; - $this->logger = $logger; - $this->flagManager = $flagManager; - $this->responseResolver = $responseResolver; - } - - /** - * Executes update request to MBI api in case store url was changed - * - * @return bool - */ - public function execute() - { - $result = false; - if ($this->analyticsToken->isTokenExist()) { - $response = $this->httpClient->request( - ZendClient::PUT, - $this->config->getValue($this->updateUrlPath), - [ - "url" => $this->flagManager - ->getFlagData(SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE), - "new-url" => $this->config->getValue(Store::XML_PATH_SECURE_BASE_URL), - "access-token" => $this->analyticsToken->getToken(), - ] - ); - $result = $this->responseResolver->getResult($response); - if (!$result) { - $this->logger->warning( - sprintf( - 'Update of the subscription for MBI service has been failed: %s', - !empty($response->getBody()) ? $response->getBody() : 'Response body is empty.' - ) - ); - } - } - - return (bool)$result; - } -} diff --git a/app/code/Magento/Analytics/Model/Cryptographer.php b/app/code/Magento/Analytics/Model/Cryptographer.php deleted file mode 100644 index 6905eee372ae2..0000000000000 --- a/app/code/Magento/Analytics/Model/Cryptographer.php +++ /dev/null @@ -1,130 +0,0 @@ -analyticsToken = $analyticsToken; - $this->encodedContextFactory = $encodedContextFactory; - } - - /** - * Encrypt input data. - * - * @param string $source - * @return EncodedContext - * @throws LocalizedException - */ - public function encode($source) - { - if (!is_string($source)) { - try { - $source = (string)$source; - } catch (\Exception $e) { - throw new LocalizedException(__('Input data must be string or convertible into string.')); - } - } elseif (!$source) { - throw new LocalizedException(__('Input data must be non-empty string.')); - } - if (!$this->validateCipherMethod($this->cipherMethod)) { - throw new LocalizedException(__('Not valid cipher method.')); - } - $initializationVector = $this->getInitializationVector(); - - $encodedContext = $this->encodedContextFactory->create([ - 'content' => openssl_encrypt( - $source, - $this->cipherMethod, - $this->getKey(), - OPENSSL_RAW_DATA, - $initializationVector - ), - 'initializationVector' => $initializationVector, - ]); - - return $encodedContext; - } - - /** - * Return key for encryption. - * - * @return string - * @throws LocalizedException - */ - private function getKey() - { - $token = $this->analyticsToken->getToken(); - if (!$token) { - throw new LocalizedException(__('Encryption key can\'t be empty.')); - } - return hash('sha256', $token); - } - - /** - * Return established cipher method. - * - * @return string - */ - private function getCipherMethod() - { - return $this->cipherMethod; - } - - /** - * Return each time generated random initialization vector which depends on the cipher method. - * - * @return string - */ - private function getInitializationVector() - { - $ivSize = openssl_cipher_iv_length($this->getCipherMethod()); - return openssl_random_pseudo_bytes($ivSize); - } - - /** - * Check that cipher method is allowed for encryption. - * - * @param string $cipherMethod - * @return bool - */ - private function validateCipherMethod($cipherMethod) - { - $methods = openssl_get_cipher_methods(); - return (false !== array_search($cipherMethod, $methods)); - } -} diff --git a/app/code/Magento/Analytics/Model/EncodedContext.php b/app/code/Magento/Analytics/Model/EncodedContext.php deleted file mode 100644 index 5fb2d0c15aef7..0000000000000 --- a/app/code/Magento/Analytics/Model/EncodedContext.php +++ /dev/null @@ -1,52 +0,0 @@ -content = $content; - $this->initializationVector = $initializationVector; - } - - /** - * @return string - */ - public function getContent() - { - return $this->content; - } - - /** - * @return string - */ - public function getInitializationVector() - { - return $this->initializationVector; - } -} diff --git a/app/code/Magento/Analytics/Model/Exception/State/SubscriptionUpdateException.php b/app/code/Magento/Analytics/Model/Exception/State/SubscriptionUpdateException.php deleted file mode 100644 index 5d127037afea9..0000000000000 --- a/app/code/Magento/Analytics/Model/Exception/State/SubscriptionUpdateException.php +++ /dev/null @@ -1,17 +0,0 @@ -filesystem = $filesystem; - $this->archive = $archive; - $this->reportWriter = $reportWriter; - $this->cryptographer = $cryptographer; - $this->fileRecorder = $fileRecorder; - } - - /** - * @inheritdoc - */ - public function prepareExportData() - { - try { - $tmpDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::SYS_TMP); - - $this->prepareDirectory($tmpDirectory, $this->getTmpFilesDirRelativePath()); - $this->reportWriter->write($tmpDirectory, $this->getTmpFilesDirRelativePath()); - - $tmpFilesDirectoryAbsolutePath = $this->validateSource($tmpDirectory, $this->getTmpFilesDirRelativePath()); - $archiveAbsolutePath = $this->prepareFileDirectory($tmpDirectory, $this->getArchiveRelativePath()); - $this->pack( - $tmpFilesDirectoryAbsolutePath, - $archiveAbsolutePath - ); - - $this->validateSource($tmpDirectory, $this->getArchiveRelativePath()); - $this->fileRecorder->recordNewFile( - $this->cryptographer->encode($tmpDirectory->readFile($this->getArchiveRelativePath())) - ); - } finally { - $tmpDirectory->delete($this->getTmpFilesDirRelativePath()); - $tmpDirectory->delete($this->getArchiveRelativePath()); - } - - return true; - } - - /** - * Return relative path to a directory for temporary files with reports data. - * - * @return string - */ - private function getTmpFilesDirRelativePath() - { - return $this->subdirectoryPath . 'tmp/'; - } - - /** - * Return relative path to a directory for an archive. - * - * @return string - */ - private function getArchiveRelativePath() - { - return $this->subdirectoryPath . $this->archiveName; - } - - /** - * Clean up a directory. - * - * @param WriteInterface $directory - * @param string $path - * @return string - */ - private function prepareDirectory(WriteInterface $directory, $path) - { - $directory->delete($path); - - return $directory->getAbsolutePath($path); - } - - /** - * Remove a file and a create parent directory a file. - * - * @param WriteInterface $directory - * @param string $path - * @return string - */ - private function prepareFileDirectory(WriteInterface $directory, $path) - { - $directory->delete($path); - if (dirname($path) !== '.') { - $directory->create(dirname($path)); - } - - return $directory->getAbsolutePath($path); - } - - /** - * Packing data into an archive. - * - * @param string $source - * @param string $destination - * @return bool - */ - private function pack($source, $destination) - { - $this->archive->pack( - $source, - $destination, - is_dir($source) ?: false - ); - - return true; - } - - /** - * Validate that data source exist. - * - * Return absolute path in a validated data source. - * - * @param WriteInterface $directory - * @param string $path - * @return string - * @throws LocalizedException If source is not exist. - */ - private function validateSource(WriteInterface $directory, $path) - { - if (!$directory->isExist($path)) { - throw new LocalizedException(__('Source "%1" is not exist', $directory->getAbsolutePath($path))); - } - - return $directory->getAbsolutePath($path); - } -} diff --git a/app/code/Magento/Analytics/Model/ExportDataHandlerInterface.php b/app/code/Magento/Analytics/Model/ExportDataHandlerInterface.php deleted file mode 100644 index 65efb33659c89..0000000000000 --- a/app/code/Magento/Analytics/Model/ExportDataHandlerInterface.php +++ /dev/null @@ -1,19 +0,0 @@ -exportDataHandler = $exportDataHandler; - $this->analyticsConnector = $connector; - } - - /** - * {@inheritdoc} - * Execute notification command. - * - * @return bool - */ - public function prepareExportData() - { - $result = $this->exportDataHandler->prepareExportData(); - $this->analyticsConnector->execute('notifyDataChanged'); - return $result; - } -} diff --git a/app/code/Magento/Analytics/Model/FileInfo.php b/app/code/Magento/Analytics/Model/FileInfo.php deleted file mode 100644 index 19bdaf21b2a20..0000000000000 --- a/app/code/Magento/Analytics/Model/FileInfo.php +++ /dev/null @@ -1,52 +0,0 @@ -path = $path; - $this->initializationVector = $initializationVector; - } - - /** - * @return string - */ - public function getPath() - { - return $this->path; - } - - /** - * @return string - */ - public function getInitializationVector() - { - return $this->initializationVector; - } -} diff --git a/app/code/Magento/Analytics/Model/FileInfoManager.php b/app/code/Magento/Analytics/Model/FileInfoManager.php deleted file mode 100644 index e37700e665420..0000000000000 --- a/app/code/Magento/Analytics/Model/FileInfoManager.php +++ /dev/null @@ -1,123 +0,0 @@ -flagManager = $flagManager; - $this->fileInfoFactory = $fileInfoFactory; - } - - /** - * Save FileInfo object. - * - * @param FileInfo $fileInfo - * @return bool - * @throws LocalizedException - */ - public function save(FileInfo $fileInfo) - { - $parameters = []; - $parameters['initializationVector'] = $fileInfo->getInitializationVector(); - $parameters['path'] = $fileInfo->getPath(); - - $emptyParameters = array_diff($parameters, array_filter($parameters)); - if ($emptyParameters) { - throw new LocalizedException( - __('These arguments can\'t be empty "%1"', implode(', ', array_keys($emptyParameters))) - ); - } - - foreach ($this->encodedParameters as $encodedParameter) { - $parameters[$encodedParameter] = $this->encodeValue($parameters[$encodedParameter]); - } - - $this->flagManager->saveFlag($this->flagCode, $parameters); - - return true; - } - - /** - * Load FileInfo object. - * - * @return FileInfo - */ - public function load() - { - $parameters = $this->flagManager->getFlagData($this->flagCode) ?: []; - - $encodedParameters = array_intersect($this->encodedParameters, array_keys($parameters)); - foreach ($encodedParameters as $encodedParameter) { - $parameters[$encodedParameter] = $this->decodeValue($parameters[$encodedParameter]); - } - - $fileInfo = $this->fileInfoFactory->create($parameters); - - return $fileInfo; - } - - /** - * Encode value. - * - * @param string $value - * @return string - */ - private function encodeValue($value) - { - return base64_encode($value); - } - - /** - * Decode value. - * - * @param string $value - * @return string - */ - private function decodeValue($value) - { - return base64_decode($value); - } -} diff --git a/app/code/Magento/Analytics/Model/FileRecorder.php b/app/code/Magento/Analytics/Model/FileRecorder.php deleted file mode 100644 index 70438a98d56f1..0000000000000 --- a/app/code/Magento/Analytics/Model/FileRecorder.php +++ /dev/null @@ -1,136 +0,0 @@ -fileInfoManager = $fileInfoManager; - $this->fileInfoFactory = $fileInfoFactory; - $this->filesystem = $filesystem; - } - - /** - * Save new encrypted file, register it and remove old registered file. - * - * @param EncodedContext $encodedContext - * @return bool - */ - public function recordNewFile(EncodedContext $encodedContext) - { - $directory = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA); - - $fileRelativePath = $this->getFileRelativePath(); - $directory->writeFile($fileRelativePath, $encodedContext->getContent()); - - $fileInfo = $this->fileInfoManager->load(); - $this->registerFile($encodedContext, $fileRelativePath); - $this->removeOldFile($fileInfo, $directory); - - return true; - } - - /** - * Return relative path to encoded file. - * - * @return string - */ - private function getFileRelativePath() - { - return $this->fileSubdirectoryPath . hash('sha256', time()) - . '/' . $this->encodedFileName; - } - - /** - * Register encoded file. - * - * @param EncodedContext $encodedContext - * @param string $fileRelativePath - * @return bool - */ - private function registerFile(EncodedContext $encodedContext, $fileRelativePath) - { - $newFileInfo = $this->fileInfoFactory->create( - [ - 'path' => $fileRelativePath, - 'initializationVector' => $encodedContext->getInitializationVector(), - ] - ); - $this->fileInfoManager->save($newFileInfo); - - return true; - } - - /** - * Remove previously registered file. - * - * @param FileInfo $fileInfo - * @param WriteInterface $directory - * @return bool - */ - private function removeOldFile(FileInfo $fileInfo, WriteInterface $directory) - { - if (!$fileInfo->getPath()) { - return true; - } - - $directory->delete($fileInfo->getPath()); - - $directoryName = dirname($fileInfo->getPath()); - if ($directoryName !== '.') { - $directory->delete($directoryName); - } - - return true; - } -} diff --git a/app/code/Magento/Analytics/Model/IntegrationManager.php b/app/code/Magento/Analytics/Model/IntegrationManager.php deleted file mode 100644 index 61a40a955e026..0000000000000 --- a/app/code/Magento/Analytics/Model/IntegrationManager.php +++ /dev/null @@ -1,126 +0,0 @@ -integrationService = $integrationService; - $this->config = $config; - $this->oauthService = $oauthService; - } - - /** - * Activate predefined integration user - * - * @return bool - * @throws NoSuchEntityException - */ - public function activateIntegration() - { - $integration = $this->integrationService->findByName( - $this->config->getConfigDataValue('analytics/integration_name') - ); - if (!$integration->getId()) { - throw new NoSuchEntityException(__('Cannot find predefined integration user!')); - } - $integrationData = $this->getIntegrationData(Integration::STATUS_ACTIVE); - $integrationData['integration_id'] = $integration->getId(); - $this->integrationService->update($integrationData); - return true; - } - - /** - * This method execute Generate Token command and enable integration - * - * @return bool|\Magento\Integration\Model\Oauth\Token - */ - public function generateToken() - { - $consumerId = $this->generateIntegration()->getConsumerId(); - $accessToken = $this->oauthService->getAccessToken($consumerId); - if (!$accessToken && $this->oauthService->createAccessToken($consumerId, true)) { - $accessToken = $this->oauthService->getAccessToken($consumerId); - } - return $accessToken; - } - - /** - * Returns consumer Id for MA integration user - * - * @return \Magento\Integration\Model\Integration - */ - private function generateIntegration() - { - $integration = $this->integrationService->findByName( - $this->config->getConfigDataValue('analytics/integration_name') - ); - if (!$integration->getId()) { - $integration = $this->integrationService->create($this->getIntegrationData()); - } - return $integration; - } - - /** - * Returns default attributes for MA integration user - * - * @param int $status - * @return array - */ - private function getIntegrationData($status = Integration::STATUS_INACTIVE) - { - $integrationData = [ - 'name' => $this->config->getConfigDataValue('analytics/integration_name'), - 'status' => $status, - 'all_resources' => false, - 'resource' => [ - 'Magento_Analytics::analytics', - 'Magento_Analytics::analytics_api' - ], - ]; - return $integrationData; - } -} diff --git a/app/code/Magento/Analytics/Model/Link.php b/app/code/Magento/Analytics/Model/Link.php deleted file mode 100644 index 4a40796df4fd0..0000000000000 --- a/app/code/Magento/Analytics/Model/Link.php +++ /dev/null @@ -1,54 +0,0 @@ -url = $url; - $this->initializationVector = $initializationVector; - } - - /** - * @return string - */ - public function getUrl() - { - return $this->url; - } - - /** - * @return string - */ - public function getInitializationVector() - { - return $this->initializationVector; - } -} diff --git a/app/code/Magento/Analytics/Model/LinkProvider.php b/app/code/Magento/Analytics/Model/LinkProvider.php deleted file mode 100644 index 2474653f4916c..0000000000000 --- a/app/code/Magento/Analytics/Model/LinkProvider.php +++ /dev/null @@ -1,87 +0,0 @@ -linkFactory = $linkFactory; - $this->fileInfoManager = $fileInfoManager; - $this->storeManager = $storeManager; - } - - /** - * Returns base url to file according to store configuration - * - * @param FileInfo $fileInfo - * @return string - */ - private function getBaseUrl(FileInfo $fileInfo) - { - return $this->storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_MEDIA) . $fileInfo->getPath(); - } - - /** - * Verify is requested file ready - * - * @param FileInfo $fileInfo - * @return bool - */ - private function isFileReady(FileInfo $fileInfo) - { - return $fileInfo->getPath() && $fileInfo->getInitializationVector(); - } - - /** - * @inheritdoc - */ - public function get() - { - $fileInfo = $this->fileInfoManager->load(); - if (!$this->isFileReady($fileInfo)) { - throw new NoSuchEntityException(__('File is not ready yet.')); - } - return $this->linkFactory->create( - [ - 'url' => $this->getBaseUrl($fileInfo), - 'initializationVector' => base64_encode($fileInfo->getInitializationVector()) - ] - ); - } -} diff --git a/app/code/Magento/Analytics/Model/NotificationTime.php b/app/code/Magento/Analytics/Model/NotificationTime.php deleted file mode 100644 index 9272542f4dedd..0000000000000 --- a/app/code/Magento/Analytics/Model/NotificationTime.php +++ /dev/null @@ -1,66 +0,0 @@ -flagManager = $flagManager; - } - - /** - * Stores last notification time - * - * @param string $value - * @return bool - */ - public function storeLastTimeNotification($value) - { - return $this->flagManager->saveFlag(self::NOTIFICATION_TIME, $value); - } - - /** - * Returns last time when merchant was notified about Analytic services - * - * @return int - */ - public function getLastTimeNotification() - { - return $this->flagManager->getFlagData(self::NOTIFICATION_TIME); - } - - /** - * Remove last notification time flag. - * - * @return bool - */ - public function unsetLastTimeNotificationValue() - { - return $this->flagManager->deleteFlag(self::NOTIFICATION_TIME); - } -} diff --git a/app/code/Magento/Analytics/Model/Plugin/BaseUrlConfigPlugin.php b/app/code/Magento/Analytics/Model/Plugin/BaseUrlConfigPlugin.php deleted file mode 100644 index 174272614fb19..0000000000000 --- a/app/code/Magento/Analytics/Model/Plugin/BaseUrlConfigPlugin.php +++ /dev/null @@ -1,61 +0,0 @@ -subscriptionUpdateHandler = $subscriptionUpdateHandler; - } - - /** - * Add additional handling after config value was saved. - * - * @param Value $subject - * @param Value $result - * @return Value - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function afterAfterSave( - Value $subject, - Value $result - ) { - if ($this->isPluginApplicable($result)) { - $this->subscriptionUpdateHandler->processUrlUpdate($result->getOldValue()); - } - - return $result; - } - - /** - * @param Value $result - * @return bool - */ - private function isPluginApplicable(Value $result) - { - return $result->isValueChanged() - && ($result->getPath() === Store::XML_PATH_SECURE_BASE_URL) - && ($result->getScope() === ScopeConfigInterface::SCOPE_TYPE_DEFAULT); - } -} diff --git a/app/code/Magento/Analytics/Model/ProviderFactory.php b/app/code/Magento/Analytics/Model/ProviderFactory.php deleted file mode 100644 index 3a23430fca077..0000000000000 --- a/app/code/Magento/Analytics/Model/ProviderFactory.php +++ /dev/null @@ -1,39 +0,0 @@ -objectManager = $objectManager; - } - - /** - * @param string $providerName - * @return object - */ - public function create($providerName) - { - return $this->objectManager->get($providerName); - } -} diff --git a/app/code/Magento/Analytics/Model/ReportUrlProvider.php b/app/code/Magento/Analytics/Model/ReportUrlProvider.php deleted file mode 100644 index e7fdf6f9e8132..0000000000000 --- a/app/code/Magento/Analytics/Model/ReportUrlProvider.php +++ /dev/null @@ -1,94 +0,0 @@ -analyticsToken = $analyticsToken; - $this->otpRequest = $otpRequest; - $this->config = $config; - $this->flagManager = $flagManager; - } - - /** - * Provide URL on resource with reports. - * - * @return string - * @throws SubscriptionUpdateException - */ - public function getUrl() - { - if ($this->flagManager->getFlagData(SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE)) { - throw new SubscriptionUpdateException(__( - 'Your Base URL has been changed and your reports are being updated. ' - . 'Advanced Reporting will be available once this change has been processed. Please try again later.' - )); - } - - $url = $this->config->getValue($this->urlReportConfigPath); - if ($this->analyticsToken->isTokenExist()) { - $otp = $this->otpRequest->call(); - if ($otp) { - $query = http_build_query(['otp' => $otp], '', '&'); - $url .= '?' . $query; - } - } - - return $url; - } -} diff --git a/app/code/Magento/Analytics/Model/ReportWriter.php b/app/code/Magento/Analytics/Model/ReportWriter.php deleted file mode 100644 index 7128658947908..0000000000000 --- a/app/code/Magento/Analytics/Model/ReportWriter.php +++ /dev/null @@ -1,101 +0,0 @@ -config = $config; - $this->reportValidator = $reportValidator; - $this->providerFactory = $providerFactory; - } - - /** - * {@inheritdoc} - */ - public function write(WriteInterface $directory, $path) - { - $errorsList = []; - foreach ($this->config->get() as $file) { - $provider = reset($file['providers']); - if (isset($provider['parameters']['name'])) { - $error = $this->reportValidator->validate($provider['parameters']['name']); - if ($error) { - $errorsList[] = $error; - continue; - } - } - /** @var $providerObject */ - $providerObject = $this->providerFactory->create($provider['class']); - $fileName = $provider['parameters'] ? $provider['parameters']['name'] : $provider['name']; - $fileFullPath = $path . $fileName . '.csv'; - $fileData = $providerObject->getReport(...array_values($provider['parameters'])); - $stream = $directory->openFile($fileFullPath, 'w+'); - $stream->lock(); - $headers = []; - foreach ($fileData as $row) { - if (!$headers) { - $headers = array_keys($row); - $stream->writeCsv($headers); - } - $stream->writeCsv($row); - } - $stream->unlock(); - $stream->close(); - } - if ($errorsList) { - $errorStream = $directory->openFile($path . $this->errorsFileName, 'w+'); - foreach ($errorsList as $error) { - $errorStream->lock(); - $errorStream->writeCsv($error); - $errorStream->unlock(); - } - $errorStream->close(); - } - - return true; - } -} diff --git a/app/code/Magento/Analytics/Model/ReportWriterInterface.php b/app/code/Magento/Analytics/Model/ReportWriterInterface.php deleted file mode 100644 index a611095a47ae4..0000000000000 --- a/app/code/Magento/Analytics/Model/ReportWriterInterface.php +++ /dev/null @@ -1,28 +0,0 @@ -moduleManager = $moduleManager; - } - - /** - * Returns module with module status - * - * @return array - */ - public function current() - { - $current = parent::current(); - if (is_array($current) && isset($current['module_name'])) { - $current['status'] = - $this->moduleManager->isEnabled($current['module_name']) == 1 ? 'Enabled' : "Disabled"; - } - return $current; - } -} diff --git a/app/code/Magento/Analytics/Model/StoreConfigurationProvider.php b/app/code/Magento/Analytics/Model/StoreConfigurationProvider.php deleted file mode 100644 index 0d226a9de7dc2..0000000000000 --- a/app/code/Magento/Analytics/Model/StoreConfigurationProvider.php +++ /dev/null @@ -1,102 +0,0 @@ -scopeConfig = $scopeConfig; - $this->configPaths = $configPaths; - $this->storeManager = $storeManager; - } - - /** - * Generates report using config paths from di.xml - * For each website and store - * @return \IteratorIterator - */ - public function getReport() - { - $configReport = $this->generateReportForScope(ScopeConfigInterface::SCOPE_TYPE_DEFAULT, 0); - - /** @var WebsiteInterface $website */ - foreach ($this->storeManager->getWebsites() as $website) { - $configReport = array_merge( - $this->generateReportForScope(ScopeInterface::SCOPE_WEBSITES, $website->getId()), - $configReport - ); - } - - /** @var StoreInterface $store */ - foreach ($this->storeManager->getStores() as $store) { - $configReport = array_merge( - $this->generateReportForScope(ScopeInterface::SCOPE_STORES, $store->getId()), - $configReport - ); - } - return new \IteratorIterator(new \ArrayIterator($configReport)); - } - - /** - * Creates report from config for scope type and scope id. - * - * @param string $scope - * @param int $scopeId - * @return array - */ - private function generateReportForScope($scope, $scopeId) - { - $report = []; - foreach ($this->configPaths as $configPath) { - $report[] = [ - "config_path" => $configPath, - "scope" => $scope, - "scope_id" => $scopeId, - "value" => $this->scopeConfig->getValue( - $configPath, - $scope, - $scopeId - ) - ]; - } - return $report; - } -} diff --git a/app/code/Magento/Analytics/Model/SubscriptionStatusProvider.php b/app/code/Magento/Analytics/Model/SubscriptionStatusProvider.php deleted file mode 100644 index 1dd831a672faa..0000000000000 --- a/app/code/Magento/Analytics/Model/SubscriptionStatusProvider.php +++ /dev/null @@ -1,120 +0,0 @@ -scopeConfig = $scopeConfig; - $this->analyticsToken = $analyticsToken; - $this->flagManager = $flagManager; - } - - /** - * Retrieve subscription status to Magento BI Advanced Reporting. - * - * Statuses: - * Enabled - if subscription is enabled and MA token was received; - * Pending - if subscription is enabled and MA token was not received; - * Disabled - if subscription is not enabled. - * Failed - if subscription is enabled and token was not received after attempts ended. - * - * @return string - */ - public function getStatus() - { - $isSubscriptionEnabledInConfig = $this->scopeConfig->getValue('analytics/subscription/enabled'); - if ($isSubscriptionEnabledInConfig) { - return $this->getStatusForEnabledSubscription(); - } - - return $this->getStatusForDisabledSubscription(); - } - - /** - * Retrieve status for subscription that enabled in config. - * - * @return string - */ - public function getStatusForEnabledSubscription() - { - $status = static::ENABLED; - if ($this->flagManager->getFlagData(SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE)) { - $status = self::PENDING; - } - - if (!$this->analyticsToken->isTokenExist()) { - $status = static::PENDING; - if ($this->flagManager->getFlagData(SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE) === null) { - $status = static::FAILED; - } - } - - return $status; - } - - /** - * Retrieve status for subscription that disabled in config. - * - * @return string - */ - public function getStatusForDisabledSubscription() - { - return static::DISABLED; - } -} diff --git a/app/code/Magento/Analytics/Model/System/Message/NotificationAboutFailedSubscription.php b/app/code/Magento/Analytics/Model/System/Message/NotificationAboutFailedSubscription.php deleted file mode 100644 index 9aaa2ebb3b56f..0000000000000 --- a/app/code/Magento/Analytics/Model/System/Message/NotificationAboutFailedSubscription.php +++ /dev/null @@ -1,80 +0,0 @@ -subscriptionStatusProvider = $subscriptionStatusProvider; - $this->urlBuilder = $urlBuilder; - } - - /** - * @inheritdoc - * - * @codeCoverageIgnore - */ - public function getIdentity() - { - return hash('sha256', 'ANALYTICS_NOTIFICATION'); - } - - /** - * {@inheritdoc} - */ - public function isDisplayed() - { - return $this->subscriptionStatusProvider->getStatus() === SubscriptionStatusProvider::FAILED; - } - - /** - * {@inheritdoc} - */ - public function getText() - { - $messageDetails = ''; - - $messageDetails .= __('Failed to synchronize data to the Magento Business Intelligence service. '); - $messageDetails .= __( - 'Retry Synchronization', - $this->urlBuilder->getUrl('analytics/subscription/retry') - ); - - return $messageDetails; - } - - /** - * @inheritdoc - * - * @codeCoverageIgnore - */ - public function getSeverity() - { - return self::SEVERITY_MAJOR; - } -} diff --git a/app/code/Magento/Analytics/README.md b/app/code/Magento/Analytics/README.md deleted file mode 100644 index ee6d017a1f3ac..0000000000000 --- a/app/code/Magento/Analytics/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# Magento_Analytics module - -The Magento_Analytics module integrates your Magento instance with the [Magento Business Intelligence (MBI)](https://magento.com/products/business-intelligence) to use [Advanced Reporting](http://devdocs.magento.com/guides/v2.2/advanced-reporting/modules.html) functionality. - -The module implements the following functionality: - -* enabling subscription to the MBI and automatic re-subscription -* changing the base URL with the same MBI account remained -* declaring the configuration schemas for report data collection -* collecting the Magento instance data as reports for the MBI -* introducing API that provides the collected data -* extending Magento configuration with the module parameters: - * subscription status (enabled/disabled) - * industry (a business area in which the instance website works) - * time of data collection (time of the day when the module collects data) - -## Structure - -Beyond the [usual module file structure](http://devdocs.magento.com/guides/v2.2/architecture/archi_perspectives/components/modules/mod_intro.html) the module contains a directory `ReportXml`. -[Report XML](http://devdocs.magento.com/guides/v2.2/advanced-reporting/report-xml.html) is a markup language used to build reports for Advanced Reporting. -The language declares SQL queries using XML declaration. - -## Extensibility - -We do not recommend to extend the Magento_Analytics module. It introduces an API that is purposed to transfer the collected data. Note that the API cannot be used for other needs. diff --git a/app/code/Magento/Analytics/ReportXml/Config.php b/app/code/Magento/Analytics/ReportXml/Config.php deleted file mode 100644 index f50dcf941bf50..0000000000000 --- a/app/code/Magento/Analytics/ReportXml/Config.php +++ /dev/null @@ -1,43 +0,0 @@ -data = $data; - } - - /** - * Returns config value by name - * - * @param string $queryName - * @return array - */ - public function get($queryName) - { - return $this->data->get($queryName); - } -} diff --git a/app/code/Magento/Analytics/ReportXml/Config/Converter/Xml.php b/app/code/Magento/Analytics/ReportXml/Config/Converter/Xml.php deleted file mode 100644 index 9e0b20a6ad414..0000000000000 --- a/app/code/Magento/Analytics/ReportXml/Config/Converter/Xml.php +++ /dev/null @@ -1,61 +0,0 @@ -hasAttributes()) { - $attrs = $source->attributes; - foreach ($attrs as $attr) { - $result[$attr->name] = $attr->value; - } - } - if ($source->hasChildNodes()) { - $children = $source->childNodes; - if ($children->length == 1) { - $child = $children->item(0); - if ($child->nodeType == XML_TEXT_NODE) { - $result['_value'] = $child->nodeValue; - return count($result) == 1 ? $result['_value'] : $result; - } - } - foreach ($children as $child) { - if ($child instanceof \DOMCharacterData) { - continue; - } - $result[$child->nodeName][] = $this->convertNode($child); - } - } - return $result; - } - - /** - * Converts XML document into corresponding array. - * - * @param \DOMDocument $source - * @return array - */ - public function convert($source) - { - return $this->convertNode($source); - } -} diff --git a/app/code/Magento/Analytics/ReportXml/Config/Mapper.php b/app/code/Magento/Analytics/ReportXml/Config/Mapper.php deleted file mode 100644 index 4dda8f3c733a6..0000000000000 --- a/app/code/Magento/Analytics/ReportXml/Config/Mapper.php +++ /dev/null @@ -1,37 +0,0 @@ -readers = $readers; - $this->mapper = $mapper; - } - - /** - * Reads configuration according to the given scope. - * - * @param string|null $scope - * @return array - */ - public function read($scope = null) - { - $data = []; - foreach ($this->readers as $reader) { - $data = array_merge_recursive($data, $reader->read($scope)); - } - return $this->mapper->execute($data); - } -} diff --git a/app/code/Magento/Analytics/ReportXml/ConfigInterface.php b/app/code/Magento/Analytics/ReportXml/ConfigInterface.php deleted file mode 100644 index ec03ddf429c06..0000000000000 --- a/app/code/Magento/Analytics/ReportXml/ConfigInterface.php +++ /dev/null @@ -1,23 +0,0 @@ -resourceConnection = $resourceConnection; - $this->objectManager = $objectManager; - } - - /** - * Creates one-time connection for export - * - * @param string $connectionName - * @return AdapterInterface - */ - public function getConnection($connectionName) - { - $connection = $this->resourceConnection->getConnection($connectionName); - $connectionClassName = get_class($connection); - $configData = $connection->getConfig(); - $configData['use_buffered_query'] = false; - unset($configData['persistent']); - return $this->objectManager->create( - $connectionClassName, - [ - 'config' => $configData - ] - ); - } -} diff --git a/app/code/Magento/Analytics/ReportXml/DB/Assembler/AssemblerInterface.php b/app/code/Magento/Analytics/ReportXml/DB/Assembler/AssemblerInterface.php deleted file mode 100644 index 083b4843c185a..0000000000000 --- a/app/code/Magento/Analytics/ReportXml/DB/Assembler/AssemblerInterface.php +++ /dev/null @@ -1,27 +0,0 @@ -conditionResolver = $conditionResolver; - $this->nameResolver = $nameResolver; - } - - /** - * Assembles WHERE conditions - * - * @param SelectBuilder $selectBuilder - * @param array $queryConfig - * @return SelectBuilder - */ - public function assemble(SelectBuilder $selectBuilder, $queryConfig) - { - if (!isset($queryConfig['source']['filter'])) { - return $selectBuilder; - } - $filters = $this->conditionResolver->getFilter( - $selectBuilder, - $queryConfig['source']['filter'], - $this->nameResolver->getAlias($queryConfig['source']) - ); - $selectBuilder->setFilters(array_merge_recursive($selectBuilder->getFilters(), [$filters])); - return $selectBuilder; - } -} diff --git a/app/code/Magento/Analytics/ReportXml/DB/Assembler/FromAssembler.php b/app/code/Magento/Analytics/ReportXml/DB/Assembler/FromAssembler.php deleted file mode 100644 index 811119ace221b..0000000000000 --- a/app/code/Magento/Analytics/ReportXml/DB/Assembler/FromAssembler.php +++ /dev/null @@ -1,69 +0,0 @@ -nameResolver = $nameResolver; - $this->columnsResolver = $columnsResolver; - $this->resourceConnection = $resourceConnection; - } - - /** - * Assembles FROM condition - * - * @param SelectBuilder $selectBuilder - * @param array $queryConfig - * @return SelectBuilder - */ - public function assemble(SelectBuilder $selectBuilder, $queryConfig) - { - $selectBuilder->setFrom( - [ - $this->nameResolver->getAlias($queryConfig['source']) => - $this->resourceConnection - ->getTableName($this->nameResolver->getName($queryConfig['source'])), - ] - ); - $columns = $this->columnsResolver->getColumns($selectBuilder, $queryConfig['source']); - $selectBuilder->setColumns(array_merge($selectBuilder->getColumns(), $columns)); - return $selectBuilder; - } -} diff --git a/app/code/Magento/Analytics/ReportXml/DB/Assembler/JoinAssembler.php b/app/code/Magento/Analytics/ReportXml/DB/Assembler/JoinAssembler.php deleted file mode 100644 index f3c6540a25171..0000000000000 --- a/app/code/Magento/Analytics/ReportXml/DB/Assembler/JoinAssembler.php +++ /dev/null @@ -1,113 +0,0 @@ -conditionResolver = $conditionResolver; - $this->nameResolver = $nameResolver; - $this->columnsResolver = $columnsResolver; - $this->resourceConnection = $resourceConnection; - } - - /** - * Assembles JOIN conditions - * - * @param SelectBuilder $selectBuilder - * @param array $queryConfig - * @return SelectBuilder - */ - public function assemble(SelectBuilder $selectBuilder, $queryConfig) - { - if (!isset($queryConfig['source']['link-source'])) { - return $selectBuilder; - } - $joins = []; - $filters = $selectBuilder->getFilters(); - - $sourceAlias = $this->nameResolver->getAlias($queryConfig['source']); - - foreach ($queryConfig['source']['link-source'] as $join) { - $joinAlias = $this->nameResolver->getAlias($join); - - $joins[$joinAlias] = [ - 'link-type' => isset($join['link-type']) ? $join['link-type'] : 'left', - 'table' => [ - $joinAlias => $this->resourceConnection - ->getTableName($this->nameResolver->getName($join)), - ], - 'condition' => $this->conditionResolver->getFilter( - $selectBuilder, - $join['using'], - $joinAlias, - $sourceAlias - ) - ]; - if (isset($join['filter'])) { - $filters = array_merge( - $filters, - [ - $this->conditionResolver->getFilter( - $selectBuilder, - $join['filter'], - $joinAlias, - $sourceAlias - ) - ] - ); - } - $columns = $this->columnsResolver->getColumns($selectBuilder, isset($join['attribute']) ? $join : []); - $selectBuilder->setColumns(array_merge($selectBuilder->getColumns(), $columns)); - } - $selectBuilder->setFilters($filters); - $selectBuilder->setJoins(array_merge($selectBuilder->getJoins(), $joins)); - return $selectBuilder; - } -} diff --git a/app/code/Magento/Analytics/ReportXml/DB/ColumnsResolver.php b/app/code/Magento/Analytics/ReportXml/DB/ColumnsResolver.php deleted file mode 100644 index e6474d4c5dc6d..0000000000000 --- a/app/code/Magento/Analytics/ReportXml/DB/ColumnsResolver.php +++ /dev/null @@ -1,100 +0,0 @@ -nameResolver = $nameResolver; - $this->resourceConnection = $resourceConnection; - } - - /** - * Returns connection - * - * @return \Magento\Framework\DB\Adapter\AdapterInterface - */ - private function getConnection() - { - if (!$this->connection) { - $this->connection = $this->resourceConnection->getConnection(); - } - return $this->connection; - } - - /** - * Set columns list to SelectBuilder - * - * @param SelectBuilder $selectBuilder - * @param array $entityConfig - * @return array - */ - public function getColumns(SelectBuilder $selectBuilder, $entityConfig) - { - if (!isset($entityConfig['attribute'])) { - return []; - } - $group = []; - $columns = $selectBuilder->getColumns(); - foreach ($entityConfig['attribute'] as $attributeData) { - $columnAlias = $this->nameResolver->getAlias($attributeData); - $tableAlias = $this->nameResolver->getAlias($entityConfig); - $columnName = $this->nameResolver->getName($attributeData); - if (isset($attributeData['function'])) { - $prefix = ''; - if (isset($attributeData['distinct']) && $attributeData['distinct'] == true) { - $prefix = ' DISTINCT '; - } - $expression = new ColumnValueExpression( - strtoupper($attributeData['function']) . '(' . $prefix - . $this->getConnection()->quoteIdentifier($tableAlias . '.' . $columnName) - . ')' - ); - } else { - $expression = $tableAlias . '.' . $columnName; - } - $columns[$columnAlias] = $expression; - if (isset($attributeData['group'])) { - $group[$columnAlias] = $expression; - } - } - $selectBuilder->setGroup(array_merge($selectBuilder->getGroup(), $group)); - return $columns; - } -} diff --git a/app/code/Magento/Analytics/ReportXml/DB/ConditionResolver.php b/app/code/Magento/Analytics/ReportXml/DB/ConditionResolver.php deleted file mode 100644 index 773b96959e794..0000000000000 --- a/app/code/Magento/Analytics/ReportXml/DB/ConditionResolver.php +++ /dev/null @@ -1,166 +0,0 @@ - '%1$s = %2$s', - 'neq' => '%1$s != %2$s', - 'like' => '%1$s LIKE %2$s', - 'nlike' => '%1$s NOT LIKE %2$s', - 'in' => '%1$s IN(%2$s)', - 'nin' => '%1$s NOT IN(%2$s)', - 'notnull' => '%1$s IS NOT NULL', - 'null' => '%1$s IS NULL', - 'gt' => '%1$s > %2$s', - 'lt' => '%1$s < %2$s', - 'gteq' => '%1$s >= %2$s', - 'lteq' => '%1$s <= %2$s', - 'finset' => 'FIND_IN_SET(%2$s, %1$s)' - ]; - - /** - * @var \Magento\Framework\DB\Adapter\AdapterInterface - */ - private $connection; - - /** - * @var ResourceConnection - */ - private $resourceConnection; - - /** - * ConditionResolver constructor. - * @param ResourceConnection $resourceConnection - */ - public function __construct( - ResourceConnection $resourceConnection - ) { - $this->resourceConnection = $resourceConnection; - } - - /** - * Returns connection - * - * @return \Magento\Framework\DB\Adapter\AdapterInterface - */ - private function getConnection() - { - if (!$this->connection) { - $this->connection = $this->resourceConnection->getConnection(); - } - return $this->connection; - } - - /** - * Returns value for condition - * - * @param string $condition - * @param string $referencedEntity - * @return mixed|null|string|\Zend_Db_Expr - */ - private function getValue($condition, $referencedEntity) - { - $value = null; - $argument = isset($condition['_value']) ? $condition['_value'] : null; - if (!isset($condition['type'])) { - $condition['type'] = 'value'; - } - - switch ($condition['type']) { - case "value": - $value = $this->getConnection()->quote($argument); - break; - case "variable": - $value = new Expression($argument); - break; - case "identifier": - $value = $this->getConnection()->quoteIdentifier( - $referencedEntity ? $referencedEntity . '.' . $argument : $argument - ); - break; - } - return $value; - } - - /** - * Returns condition for WHERE - * - * @param SelectBuilder $selectBuilder - * @param string $tableName - * @param array $condition - * @param null|string $referencedEntity - * @return string - */ - private function getCondition(SelectBuilder $selectBuilder, $tableName, $condition, $referencedEntity = null) - { - $columns = $selectBuilder->getColumns(); - if (isset($columns[$condition['attribute']]) - && $columns[$condition['attribute']] instanceof Expression - ) { - $expression = $columns[$condition['attribute']]; - } else { - $expression = $this->getConnection()->quoteIdentifier($tableName . '.' . $condition['attribute']); - } - return sprintf( - $this->conditionMap[$condition['operator']], - $expression, - $this->getValue($condition, $referencedEntity) - ); - } - - /** - * Build WHERE condition - * - * @param SelectBuilder $selectBuilder - * @param array $filterConfig - * @param string $aliasName - * @param null|string $referencedAlias - * @return array - */ - public function getFilter(SelectBuilder $selectBuilder, $filterConfig, $aliasName, $referencedAlias = null) - { - $filtersParts = []; - foreach ($filterConfig as $filter) { - $glue = $filter['glue']; - $parts = []; - foreach ($filter['condition'] as $condition) { - if (isset($condition['type']) && $condition['type'] == 'variable') { - $selectBuilder->setParams(array_merge($selectBuilder->getParams(), [$condition['_value']])); - } - $parts[] = $this->getCondition( - $selectBuilder, - $aliasName, - $condition, - $referencedAlias - ); - } - if (isset($filter['filter'])) { - $parts[] = '(' . $this->getFilter( - $selectBuilder, - $filter['filter'], - $aliasName, - $referencedAlias - ) . ')'; - } - $filtersParts[] = '(' . implode(' ' . strtoupper($glue) . ' ', $parts) . ')'; - } - return implode(' OR ', $filtersParts); - } -} diff --git a/app/code/Magento/Analytics/ReportXml/DB/NameResolver.php b/app/code/Magento/Analytics/ReportXml/DB/NameResolver.php deleted file mode 100644 index c9543002eb272..0000000000000 --- a/app/code/Magento/Analytics/ReportXml/DB/NameResolver.php +++ /dev/null @@ -1,40 +0,0 @@ -getName($elementConfig); - if (isset($elementConfig['alias'])) { - $alias = $elementConfig['alias']; - } - return $alias; - } -} diff --git a/app/code/Magento/Analytics/ReportXml/DB/ReportValidator.php b/app/code/Magento/Analytics/ReportXml/DB/ReportValidator.php deleted file mode 100644 index 21a641f0a71c7..0000000000000 --- a/app/code/Magento/Analytics/ReportXml/DB/ReportValidator.php +++ /dev/null @@ -1,64 +0,0 @@ -connectionFactory = $connectionFactory; - $this->queryFactory = $queryFactory; - } - - /** - * Tries to do query for provided report with limit 0 and return error information if it failed - * - * @param string $name - * @param SearchCriteriaInterface $criteria - * @return array - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function validate($name, SearchCriteriaInterface $criteria = null) - { - $query = $this->queryFactory->create($name); - $connection = $this->connectionFactory->getConnection($query->getConnectionName()); - $query->getSelect()->limit(0); - try { - $connection->query($query->getSelect()); - } catch (\Zend_Db_Statement_Exception $e) { - return [$name, $e->getMessage()]; - } - - return []; - } -} diff --git a/app/code/Magento/Analytics/ReportXml/DB/SelectBuilder.php b/app/code/Magento/Analytics/ReportXml/DB/SelectBuilder.php deleted file mode 100644 index 4e5a1940773b1..0000000000000 --- a/app/code/Magento/Analytics/ReportXml/DB/SelectBuilder.php +++ /dev/null @@ -1,289 +0,0 @@ -resourceConnection = $resourceConnection; - } - - /** - * Get join condition - * - * @return array - */ - public function getJoins() - { - return $this->joins; - } - - /** - * Set joins conditions - * - * @param array $joins - * @return void - */ - public function setJoins($joins) - { - $this->joins = $joins; - } - - /** - * Get connection name - * - * @return string - */ - public function getConnectionName() - { - return $this->connectionName; - } - - /** - * Set connection name - * - * @param string $connectionName - * @return void - */ - public function setConnectionName($connectionName) - { - $this->connectionName = $connectionName; - } - - /** - * Get columns - * - * @return array - */ - public function getColumns() - { - return $this->columns; - } - - /** - * Set columns - * - * @param array $columns - * @return void - */ - public function setColumns($columns) - { - $this->columns = $columns; - } - - /** - * Get filters - * - * @return array - */ - public function getFilters() - { - return $this->filters; - } - - /** - * Set filters - * - * @param array $filters - * @return void - */ - public function setFilters($filters) - { - $this->filters = $filters; - } - - /** - * Get from condition - * - * @return array - */ - public function getFrom() - { - return $this->from; - } - - /** - * Set from condition - * - * @param array $from - * @return void - */ - public function setFrom($from) - { - $this->from = $from; - } - - /** - * Process JOIN conditions - * - * @param Select $select - * @param array $joinConfig - * @return Select - */ - private function processJoin(Select $select, $joinConfig) - { - switch ($joinConfig['link-type']) { - case 'left': - $select->joinLeft($joinConfig['table'], $joinConfig['condition'], []); - break; - case 'inner': - $select->joinInner($joinConfig['table'], $joinConfig['condition'], []); - break; - case 'right': - $select->joinRight($joinConfig['table'], $joinConfig['condition'], []); - break; - } - return $select; - } - - /** - * Creates Select object - * - * @return Select - */ - public function create() - { - $connection = $this->resourceConnection->getConnection($this->getConnectionName()); - $select = $connection->select(); - $select->from($this->getFrom(), []); - $select->columns($this->getColumns()); - foreach ($this->getFilters() as $filter) { - $select->where($filter); - } - foreach ($this->getJoins() as $joinConfig) { - $select = $this->processJoin($select, $joinConfig); - } - if (!empty($this->getGroup())) { - $select->group(implode(', ', $this->getGroup())); - } - return $select; - } - - /** - * Returns group - * - * @return array - */ - public function getGroup() - { - return $this->group; - } - - /** - * Set group - * - * @param array $group - * @return void - */ - public function setGroup($group) - { - $this->group = $group; - } - - /** - * Get parameters - * - * @return array - */ - public function getParams() - { - return $this->params; - } - - /** - * Set parameters - * - * @param array $params - * @return void - */ - public function setParams($params) - { - $this->params = $params; - } - - /** - * Get having condition - * - * @return array - */ - public function getHaving() - { - return $this->having; - } - - /** - * Set having condition - * - * @param array $having - * @return void - */ - public function setHaving($having) - { - $this->having = $having; - } -} diff --git a/app/code/Magento/Analytics/ReportXml/DB/SelectBuilderFactory.php b/app/code/Magento/Analytics/ReportXml/DB/SelectBuilderFactory.php deleted file mode 100644 index 1d88d4618efc5..0000000000000 --- a/app/code/Magento/Analytics/ReportXml/DB/SelectBuilderFactory.php +++ /dev/null @@ -1,43 +0,0 @@ -objectManager = $objectManager; - } - - /** - * Create class instance with specified parameters - * - * @param array $data - * @return SelectBuilder - */ - public function create(array $data = []) - { - return $this->objectManager->create(SelectBuilder::class, $data); - } -} diff --git a/app/code/Magento/Analytics/ReportXml/IteratorFactory.php b/app/code/Magento/Analytics/ReportXml/IteratorFactory.php deleted file mode 100644 index a196cef8b66dc..0000000000000 --- a/app/code/Magento/Analytics/ReportXml/IteratorFactory.php +++ /dev/null @@ -1,61 +0,0 @@ -objectManager = $objectManager; - $this->defaultIteratorName = $defaultIteratorName; - } - - /** - * Creates instance of the result iterator with the query result as an input - * Result iterator can be changed through report configuration - * - * < ... - * - * Uses IteratorIterator by default - * - * @param \Traversable $result - * @param string|null $iteratorName - * @return \IteratorIterator - */ - public function create(\Traversable $result, $iteratorName = null) - { - return $this->objectManager->create( - $iteratorName ?: $this->defaultIteratorName, - [ - 'iterator' => $result - ] - ); - } -} diff --git a/app/code/Magento/Analytics/ReportXml/Query.php b/app/code/Magento/Analytics/ReportXml/Query.php deleted file mode 100644 index 46ec2fb494183..0000000000000 --- a/app/code/Magento/Analytics/ReportXml/Query.php +++ /dev/null @@ -1,96 +0,0 @@ -select = $select; - $this->connectionName = $connectionName; - $this->selectHydrator = $selectHydrator; - $this->config = $config; - } - - /** - * @return Select - */ - public function getSelect() - { - return $this->select; - } - - /** - * @return string - */ - public function getConnectionName() - { - return $this->connectionName; - } - - /** - * @return array - */ - public function getConfig() - { - return $this->config; - } - - /** - * Specify data which should be serialized to JSON - * @link http://php.net/manual/en/jsonserializable.jsonserialize.php - * @return mixed data which can be serialized by json_encode, - * which is a value of any type other than a resource. - * @since 5.4.0 - */ - public function jsonSerialize() - { - return [ - 'connectionName' => $this->getConnectionName(), - 'select_parts' => $this->selectHydrator->extract($this->getSelect()), - 'config' => $this->getConfig() - ]; - } -} diff --git a/app/code/Magento/Analytics/ReportXml/QueryFactory.php b/app/code/Magento/Analytics/ReportXml/QueryFactory.php deleted file mode 100644 index 8ed7e767b28b3..0000000000000 --- a/app/code/Magento/Analytics/ReportXml/QueryFactory.php +++ /dev/null @@ -1,142 +0,0 @@ -config = $config; - $this->selectBuilderFactory = $selectBuilderFactory; - $this->assemblers = $assemblers; - $this->queryCache = $queryCache; - $this->objectManager = $objectManager; - $this->selectHydrator = $selectHydrator; - } - - /** - * Returns query connection name according to configuration - * - * @param string $queryConfig - * @return string - */ - private function getQueryConnectionName($queryConfig) - { - $connectionName = 'default'; - if (isset($queryConfig['connection'])) { - $connectionName = $queryConfig['connection']; - } - return $connectionName; - } - - /** - * Create query according to configuration settings - * - * @param string $queryName - * @return Query - */ - private function constructQuery($queryName) - { - $queryConfig = $this->config->get($queryName); - $selectBuilder = $this->selectBuilderFactory->create(); - $selectBuilder->setConnectionName($this->getQueryConnectionName($queryConfig)); - foreach ($this->assemblers as $assembler) { - $selectBuilder = $assembler->assemble($selectBuilder, $queryConfig); - } - $select = $selectBuilder->create(); - return $this->objectManager->create( - Query::class, - [ - 'select' => $select, - 'selectHydrator' => $this->selectHydrator, - 'connectionName' => $selectBuilder->getConnectionName(), - 'config' => $queryConfig - ] - ); - } - - /** - * Creates query by name - * - * @param string $queryName - * @return Query - */ - public function create($queryName) - { - $cached = $this->queryCache->load($queryName); - if ($cached) { - $queryData = json_decode($cached, true); - return $this->objectManager->create( - Query::class, - [ - 'select' => $this->selectHydrator->recreate($queryData['select_parts']), - 'selectHydrator' => $this->selectHydrator, - 'connectionName' => $queryData['connectionName'], - 'config' => $queryData['config'] - ] - ); - } - $query = $this->constructQuery($queryName); - $this->queryCache->save(json_encode($query), $queryName); - return $query; - } -} diff --git a/app/code/Magento/Analytics/ReportXml/ReportProvider.php b/app/code/Magento/Analytics/ReportXml/ReportProvider.php deleted file mode 100644 index 3ebe5941108bc..0000000000000 --- a/app/code/Magento/Analytics/ReportXml/ReportProvider.php +++ /dev/null @@ -1,76 +0,0 @@ -queryFactory = $queryFactory; - $this->connectionFactory = $connectionFactory; - $this->iteratorFactory = $iteratorFactory; - } - - /** - * Returns custom iterator name for report - * Null for default - * - * @param Query $query - * @return string|null - */ - private function getIteratorName(Query $query) - { - $config = $query->getConfig(); - return isset($config['iterator']) ? $config['iterator'] : null; - } - - /** - * Returns report data by name and criteria - * - * @param string $name - * @return \IteratorIterator - */ - public function getReport($name) - { - $query = $this->queryFactory->create($name); - $connection = $this->connectionFactory->getConnection($query->getConnectionName()); - $statement = $connection->query($query->getSelect()); - return $this->iteratorFactory->create($statement, $this->getIteratorName($query)); - } -} diff --git a/app/code/Magento/Analytics/ReportXml/SelectHydrator.php b/app/code/Magento/Analytics/ReportXml/SelectHydrator.php deleted file mode 100644 index 02cde2fd0598d..0000000000000 --- a/app/code/Magento/Analytics/ReportXml/SelectHydrator.php +++ /dev/null @@ -1,143 +0,0 @@ -resourceConnection = $resourceConnection; - $this->objectManager = $objectManager; - $this->selectParts = $selectParts; - } - - /** - * @return array - */ - private function getSelectParts() - { - return array_merge($this->predefinedSelectParts, $this->selectParts); - } - - /** - * Extracts Select metadata parts - * - * @param Select $select - * @return array - * @throws \Zend_Db_Select_Exception - */ - public function extract(Select $select) - { - $parts = []; - foreach ($this->getSelectParts() as $partName) { - $parts[$partName] = $select->getPart($partName); - } - return $parts; - } - - /** - * @param array $selectParts - * @return Select - */ - public function recreate(array $selectParts) - { - $select = $this->resourceConnection->getConnection()->select(); - - $select = $this->processColumns($select, $selectParts); - - foreach ($selectParts as $partName => $partValue) { - $select->setPart($partName, $partValue); - } - - return $select; - } - - /** - * Process COLUMNS part values and add this part into select. - * - * If each column contains information about select expression - * an object with the type of this expression going to be created and assigned to this column. - * - * @param Select $select - * @param array $selectParts - * @return Select - */ - private function processColumns(Select $select, array &$selectParts) - { - if (!empty($selectParts[Select::COLUMNS]) && is_array($selectParts[Select::COLUMNS])) { - $part = []; - - foreach ($selectParts[Select::COLUMNS] as $columnEntry) { - list($correlationName, $column, $alias) = $columnEntry; - if (is_array($column) && !empty($column['class'])) { - $expression = $this->objectManager->create( - $column['class'], - isset($column['arguments']) ? $column['arguments'] : [] - ); - $part[] = [$correlationName, $expression, $alias]; - } else { - $part[] = $columnEntry; - } - } - - $select->setPart(Select::COLUMNS, $part); - unset($selectParts[Select::COLUMNS]); - } - - return $select; - } -} diff --git a/app/code/Magento/Analytics/Setup/InstallData.php b/app/code/Magento/Analytics/Setup/InstallData.php deleted file mode 100644 index 4314bb3199541..0000000000000 --- a/app/code/Magento/Analytics/Setup/InstallData.php +++ /dev/null @@ -1,43 +0,0 @@ -notificationTime = $notificationTime; - } - - /** - * {@inheritdoc} - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) - { - $this->notificationTime->storeLastTimeNotification(1); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/AdditionalCommentTest.php b/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/AdditionalCommentTest.php deleted file mode 100644 index b94a295c86527..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/AdditionalCommentTest.php +++ /dev/null @@ -1,76 +0,0 @@ -abstractElementMock = $this->getMockBuilder(AbstractElement::class) - ->setMethods(['getComment', 'getLabel']) - ->disableOriginalConstructor() - ->getMock(); - $this->contextMock = $this->getMockBuilder(Context::class) - ->disableOriginalConstructor() - ->getMock(); - $this->formMock = $this->getMockBuilder(Form::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->additionalComment = new AdditionalComment($this->contextMock); - } - - /** - * @return void - */ - public function testRender() - { - $this->abstractElementMock->setForm($this->formMock); - $this->abstractElementMock->expects($this->any()) - ->method('getComment') - ->willReturn('New comment'); - $this->abstractElementMock->expects($this->any()) - ->method('getLabel') - ->willReturn('Comment label'); - $html = $this->additionalComment->render($this->abstractElementMock); - $this->assertRegexp( - "/New comment/", - $html - ); - $this->assertRegexp( - "/Comment label/", - $html - ); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/CollectionTimeLabelTest.php b/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/CollectionTimeLabelTest.php deleted file mode 100644 index d37daf9525119..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/CollectionTimeLabelTest.php +++ /dev/null @@ -1,79 +0,0 @@ -abstractElementMock = $this->getMockBuilder(AbstractElement::class) - ->setMethods(['getComment']) - ->disableOriginalConstructor() - ->getMock(); - $this->contextMock = $this->getMockBuilder(Context::class) - ->setMethods(['getLocaleDate']) - ->disableOriginalConstructor() - ->getMock(); - $this->formMock = $this->getMockBuilder(Form::class) - ->disableOriginalConstructor() - ->getMock(); - $this->timeZoneMock = $this->getMockBuilder(TimezoneInterface::class) - ->disableOriginalConstructor() - ->getMock(); - $this->contextMock->expects($this->any()) - ->method('getLocaleDate') - ->willReturn($this->timeZoneMock); - $this->collectionTimeLabel = new CollectionTimeLabel($this->contextMock); - } - - /** - * @return void - */ - public function testRender() - { - $timeZone = "America/New_York"; - $this->abstractElementMock->setForm($this->formMock); - $this->timeZoneMock->expects($this->once()) - ->method('getConfigTimezone') - ->willReturn($timeZone); - $this->abstractElementMock->expects($this->any()) - ->method('getComment') - ->willReturn('Eastern Standard Time (America/New_York)'); - $this->assertRegexp( - "/Eastern Standard Time \(America\/New_York\)/", - $this->collectionTimeLabel->render($this->abstractElementMock) - ); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/SubscriptionStatusLabelTest.php b/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/SubscriptionStatusLabelTest.php deleted file mode 100644 index e25e745317699..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/SubscriptionStatusLabelTest.php +++ /dev/null @@ -1,86 +0,0 @@ -subscriptionStatusProviderMock = $this->getMockBuilder(SubscriptionStatusProvider::class) - ->disableOriginalConstructor() - ->getMock(); - $this->contextMock = $this->getMockBuilder(Context::class) - ->disableOriginalConstructor() - ->getMock(); - $this->abstractElementMock = $this->getMockBuilder(AbstractElement::class) - ->setMethods(['getComment']) - ->disableOriginalConstructor() - ->getMock(); - $this->formMock = $this->getMockBuilder(Form::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->subscriptionStatusLabel = new SubscriptionStatusLabel( - $this->contextMock, - $this->subscriptionStatusProviderMock - ); - } - - /** - * @return void - */ - public function testRender() - { - $this->abstractElementMock->setForm($this->formMock); - $this->subscriptionStatusProviderMock->expects($this->once()) - ->method('getStatus') - ->willReturn('Enabled'); - $this->abstractElementMock->expects($this->any()) - ->method('getComment') - ->willReturn('Subscription status: Enabled'); - $this->assertRegexp( - "/Subscription status: Enabled/", - $this->subscriptionStatusLabel->render($this->abstractElementMock) - ); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/BIEssentials/SignUpTest.php b/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/BIEssentials/SignUpTest.php deleted file mode 100644 index 3a251f9a8685a..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/BIEssentials/SignUpTest.php +++ /dev/null @@ -1,84 +0,0 @@ -configMock = $this->getMockBuilder(ScopeConfigInterface::class) - ->disableOriginalConstructor() - ->getMock(); - $this->resultRedirectFactoryMock = $this->getMockBuilder(RedirectFactory::class) - ->disableOriginalConstructor() - ->getMock(); - $this->redirectMock = $this->getMockBuilder(Redirect::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->objectManagerHelper = new ObjectManagerHelper($this); - - $this->signUpController = $this->objectManagerHelper->getObject( - SignUp::class, - [ - 'config' => $this->configMock, - 'resultRedirectFactory' => $this->resultRedirectFactoryMock - ] - ); - } - - /** - * @return void - */ - public function testExecute() - { - $urlBIEssentialsConfigPath = 'analytics/url/bi_essentials'; - $this->configMock->expects($this->once()) - ->method('getValue') - ->with($urlBIEssentialsConfigPath) - ->willReturn('value'); - $this->resultRedirectFactoryMock->expects($this->once())->method('create')->willReturn($this->redirectMock); - $this->redirectMock->expects($this->once())->method('setUrl')->with('value')->willReturnSelf(); - $this->assertEquals($this->redirectMock, $this->signUpController->execute()); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Reports/ShowTest.php b/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Reports/ShowTest.php deleted file mode 100644 index 99de92cc63905..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Reports/ShowTest.php +++ /dev/null @@ -1,185 +0,0 @@ -reportUrlProviderMock = $this->getMockBuilder(ReportUrlProvider::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->resultFactoryMock = $this->getMockBuilder(ResultFactory::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->redirectMock = $this->getMockBuilder(Redirect::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->messageManagerMock = $this->getMockBuilder(ManagerInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->objectManagerHelper = new ObjectManagerHelper($this); - - $this->showController = $this->objectManagerHelper->getObject( - Show::class, - [ - 'reportUrlProvider' => $this->reportUrlProviderMock, - 'resultFactory' => $this->resultFactoryMock, - 'messageManager' => $this->messageManagerMock, - ] - ); - } - - /** - * @return void - */ - public function testExecute() - { - $otpUrl = 'http://example.com?otp=15vbjcfdvd15645'; - - $this->resultFactoryMock - ->expects($this->once()) - ->method('create') - ->with(ResultFactory::TYPE_REDIRECT) - ->willReturn($this->redirectMock); - $this->reportUrlProviderMock - ->expects($this->once()) - ->method('getUrl') - ->with() - ->willReturn($otpUrl); - $this->redirectMock - ->expects($this->once()) - ->method('setUrl') - ->with($otpUrl) - ->willReturnSelf(); - $this->assertSame($this->redirectMock, $this->showController->execute()); - } - - /** - * @dataProvider executeWithExceptionDataProvider - * - * @param \Exception $exception - */ - public function testExecuteWithException(\Exception $exception) - { - - $this->resultFactoryMock - ->expects($this->once()) - ->method('create') - ->with(ResultFactory::TYPE_REDIRECT) - ->willReturn($this->redirectMock); - $this->reportUrlProviderMock - ->expects($this->once()) - ->method('getUrl') - ->with() - ->willThrowException($exception); - if ($exception instanceof LocalizedException) { - $message = $exception->getMessage(); - } else { - $message = __('Sorry, there has been an error processing your request. Please try again later.'); - } - $this->messageManagerMock - ->expects($this->once()) - ->method('addExceptionMessage') - ->with($exception, $message) - ->willReturnSelf(); - $this->redirectMock - ->expects($this->once()) - ->method('setPath') - ->with('adminhtml') - ->willReturnSelf(); - $this->assertSame($this->redirectMock, $this->showController->execute()); - } - - /** - * @return array - */ - public function executeWithExceptionDataProvider() - { - return [ - 'ExecuteWithLocalizedException' => [new LocalizedException(__('TestMessage'))], - 'ExecuteWithException' => [new \Exception('TestMessage')], - ]; - } - - /** - * @return void - */ - public function testExecuteWithSubscriptionUpdateException() - { - $exception = new SubscriptionUpdateException(__('TestMessage')); - $this->resultFactoryMock - ->expects($this->once()) - ->method('create') - ->with(ResultFactory::TYPE_REDIRECT) - ->willReturn($this->redirectMock); - $this->reportUrlProviderMock - ->expects($this->once()) - ->method('getUrl') - ->with() - ->willThrowException($exception); - $this->messageManagerMock - ->expects($this->once()) - ->method('addNoticeMessage') - ->with($exception->getMessage()) - ->willReturnSelf(); - $this->redirectMock - ->expects($this->once()) - ->method('setPath') - ->with('adminhtml') - ->willReturnSelf(); - $this->assertSame($this->redirectMock, $this->showController->execute()); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Subscription/ActivateTest.php b/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Subscription/ActivateTest.php deleted file mode 100644 index 9097349e9137c..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Subscription/ActivateTest.php +++ /dev/null @@ -1,252 +0,0 @@ -resultFactoryMock = $this->getMockBuilder(ResultFactory::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->resultJsonMock = $this->getMockBuilder(Json::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->preparedValueFactoryMock = $this->getMockBuilder(PreparedValueFactory::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->configValueResourceMock = $this->getMockBuilder(AbstractDb::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->loggerMock = $this->getMockBuilder(LoggerInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->requestMock = $this->getMockBuilder(RequestInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->notificationTimeMock = $this->getMockBuilder(NotificationTime::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->objectManagerHelper = new ObjectManagerHelper($this); - - $this->activateController = $this->objectManagerHelper->getObject( - Activate::class, - [ - 'resultFactory' => $this->resultFactoryMock, - 'preparedValueFactory' => $this->preparedValueFactoryMock, - 'configValueResource' => $this->configValueResourceMock, - 'logger' => $this->loggerMock, - 'notificationTime' => $this->notificationTimeMock, - '_request' => $this->requestMock, - 'subscriptionApprovedFiled' => $this->subscriptionApprovedField, - ] - ); - } - - /** - * @dataProvider executeDataProvider - * - * @param bool $isSubscriptionEnabled - * @return void - */ - public function testExecute($isSubscriptionEnabled) - { - $successResult = [ - 'success' => true, - 'error_message' => '', - ]; - - $this->requestMock - ->expects($this->once()) - ->method('getParam') - ->with($this->subscriptionApprovedField) - ->willReturn($isSubscriptionEnabled); - - if ($isSubscriptionEnabled) { - $configValue = $this->createConfigValueMock(); - $this->preparedValueFactoryMock - ->expects($this->once()) - ->method('create') - ->willReturn($configValue); - $this->configValueResourceMock->expects($this->once())->method('save')->with($configValue); - } else { - $this->notificationTimeMock - ->expects($this->once()) - ->method('unsetLastTimeNotificationValue') - ->willReturn(true); - } - - $this->resultFactoryMock->expects($this->once()) - ->method('create') - ->with(ResultFactory::TYPE_JSON) - ->willReturn($this->resultJsonMock); - $this->resultJsonMock->expects($this->once()) - ->method('setData') - ->with($successResult) - ->willReturnSelf(); - $this->assertSame( - $this->resultJsonMock, - $this->activateController->execute() - ); - } - - /** - * @dataProvider executeExceptionsDataProvider - * - * @param \Exception $exception - */ - public function testExecuteWithException(\Exception $exception) - { - $this->requestMock - ->expects($this->once()) - ->method('getParam') - ->with($this->subscriptionApprovedField) - ->willReturn(true); - - $this->preparedValueFactoryMock - ->expects($this->once()) - ->method('create') - ->willThrowException($exception); - $this->loggerMock - ->expects($this->once()) - ->method('error') - ->with($exception->getMessage()); - $this->resultFactoryMock - ->expects($this->once()) - ->method('create') - ->with(ResultFactory::TYPE_JSON) - ->willReturn($this->resultJsonMock); - - if ($exception instanceof LocalizedException) { - $this->resultJsonMock - ->expects($this->once()) - ->method('setData') - ->with([ - 'success' => false, - 'error_message' => $exception->getMessage(), - ]) - ->willReturnSelf(); - } else { - $this->resultJsonMock - ->expects($this->once()) - ->method('setData') - ->withAnyParameters() - ->willReturnSelf(); - } - - $this->assertSame( - $this->resultJsonMock, - $this->activateController->execute() - ); - } - - /** - * @return \PHPUnit_Framework_MockObject_MockObject - */ - private function createConfigValueMock() - { - return $this->getMockBuilder(\Magento\Framework\Model\AbstractModel::class) - ->disableOriginalConstructor() - ->getMock(); - } - - /** - * @return array - */ - public function executeExceptionsDataProvider() - { - return [ - [new LocalizedException(__('TestMessage'))], - [new \Exception('TestMessage')], - ]; - } - - /** - * @return array - */ - public function executeDataProvider() - { - return [ - [true], - [false], - ]; - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Subscription/PostponeTest.php b/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Subscription/PostponeTest.php deleted file mode 100644 index 0f425291bf999..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Subscription/PostponeTest.php +++ /dev/null @@ -1,168 +0,0 @@ -dateTimeFactoryMock = $this->getMockBuilder(DateTimeFactory::class) - ->disableOriginalConstructor() - ->getMock(); - $this->dateTimeMock = $this->getMockBuilder(\DateTime::class) - ->disableOriginalConstructor() - ->getMock(); - $this->notificationTimeMock = $this->getMockBuilder(NotificationTime::class) - ->disableOriginalConstructor() - ->getMock(); - $this->loggerMock = $this->getMockBuilder(LoggerInterface::class) - ->getMock(); - $this->resultFactoryMock = $this->getMockBuilder(ResultFactory::class) - ->disableOriginalConstructor() - ->getMock(); - $this->resultMock = $this->getMockBuilder(Json::class) - ->disableOriginalConstructor() - ->getMock(); - $this->resultFactoryMock->expects($this->once()) - ->method('create') - ->with(ResultFactory::TYPE_JSON) - ->willReturn($this->resultMock); - $objectManagerHelper = new ObjectManagerHelper($this); - $this->action = $objectManagerHelper->getObject( - Postpone::class, - [ - 'resultFactory' => $this->resultFactoryMock, - 'dateTimeFactory' => $this->dateTimeFactoryMock, - 'notificationTime' => $this->notificationTimeMock, - 'logger' => $this->loggerMock - ] - ); - } - - public function testExecuteSuccess() - { - $this->dateTimeFactoryMock->expects($this->once()) - ->method('create') - ->willReturn($this->dateTimeMock); - $this->dateTimeMock->expects($this->once()) - ->method('getTimestamp') - ->willReturn(100500); - $this->notificationTimeMock->expects($this->once()) - ->method('storeLastTimeNotification') - ->with(100500) - ->willReturn(true); - $this->resultMock->expects($this->once()) - ->method('setData') - ->with( - [ - 'success' => true, - 'error_message' => '' - ], - false, - [] - )->willReturnSelf(); - $this->assertEquals($this->resultMock, $this->action->execute()); - } - - public function testExecuteFailedWithLocalizedException() - { - $this->dateTimeFactoryMock->expects($this->once()) - ->method('create') - ->willReturn($this->dateTimeMock); - $this->dateTimeMock->expects($this->once()) - ->method('getTimestamp') - ->willReturn(100500); - $this->notificationTimeMock->expects($this->once()) - ->method('storeLastTimeNotification') - ->with(100500) - ->willThrowException(new LocalizedException(__('Error message'))); - $this->resultMock->expects($this->once()) - ->method('setData') - ->with( - [ - 'success' => false, - 'error_message' => 'Error message' - ], - false, - [] - )->willReturnSelf(); - $this->assertEquals($this->resultMock, $this->action->execute()); - } - - public function testExecuteFailedWithException() - { - $this->dateTimeFactoryMock->expects($this->once()) - ->method('create') - ->willReturn($this->dateTimeMock); - $this->dateTimeMock->expects($this->once()) - ->method('getTimestamp') - ->willReturn(100500); - $this->notificationTimeMock->expects($this->once()) - ->method('storeLastTimeNotification') - ->with(100500) - ->willThrowException(new \Exception('Any message')); - $this->resultMock->expects($this->once()) - ->method('setData') - ->with( - [ - 'success' => false, - 'error_message' => __('Error occurred during postponement notification') - ], - false, - [] - )->willReturnSelf(); - $this->assertEquals($this->resultMock, $this->action->execute()); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Subscription/RetryTest.php b/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Subscription/RetryTest.php deleted file mode 100644 index 2c921e2260140..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Controller/Adminhtml/Subscription/RetryTest.php +++ /dev/null @@ -1,159 +0,0 @@ -resultFactoryMock = $this->getMockBuilder(ResultFactory::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->resultRedirectMock = $this->getMockBuilder(Redirect::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->subscriptionHandlerMock = $this->getMockBuilder(SubscriptionHandler::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->messageManagerMock = $this->getMockBuilder(ManagerInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->objectManagerHelper = new ObjectManagerHelper($this); - - $this->retryController = $this->objectManagerHelper->getObject( - Retry::class, - [ - 'resultFactory' => $this->resultFactoryMock, - 'subscriptionHandler' => $this->subscriptionHandlerMock, - 'messageManager' => $this->messageManagerMock, - ] - ); - } - - /** - * @return void - */ - public function testExecute() - { - $this->resultFactoryMock - ->expects($this->once()) - ->method('create') - ->with(ResultFactory::TYPE_REDIRECT) - ->willReturn($this->resultRedirectMock); - $this->resultRedirectMock - ->expects($this->once()) - ->method('setPath') - ->with('adminhtml') - ->willReturnSelf(); - $this->subscriptionHandlerMock - ->expects($this->once()) - ->method('processEnabled') - ->with() - ->willReturn(true); - $this->assertSame( - $this->resultRedirectMock, - $this->retryController->execute() - ); - } - - /** - * @dataProvider executeExceptionsDataProvider - * - * @param \Exception $exception - * @param Phrase $message - */ - public function testExecuteWithException(\Exception $exception, Phrase $message) - { - $this->resultFactoryMock - ->expects($this->once()) - ->method('create') - ->with(ResultFactory::TYPE_REDIRECT) - ->willReturn($this->resultRedirectMock); - $this->resultRedirectMock - ->expects($this->once()) - ->method('setPath') - ->with('adminhtml') - ->willReturnSelf(); - $this->subscriptionHandlerMock - ->expects($this->once()) - ->method('processEnabled') - ->with() - ->willThrowException($exception); - $this->messageManagerMock - ->expects($this->once()) - ->method('addExceptionMessage') - ->with($exception, $message); - - $this->assertSame( - $this->resultRedirectMock, - $this->retryController->execute() - ); - } - - /** - * @return array - */ - public function executeExceptionsDataProvider() - { - return [ - [new LocalizedException(__('TestMessage')), __('TestMessage')], - [ - new \Exception('TestMessage'), - __('Sorry, there has been an error processing your request. Please try again later.') - ], - ]; - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Cron/CollectDataTest.php b/app/code/Magento/Analytics/Test/Unit/Cron/CollectDataTest.php deleted file mode 100644 index ef071cdf3a911..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Cron/CollectDataTest.php +++ /dev/null @@ -1,91 +0,0 @@ -exportDataHandlerMock = $this->getMockBuilder(ExportDataHandlerInterface::class) - ->getMockForAbstractClass(); - - $this->subscriptionStatusMock = $this->getMockBuilder(SubscriptionStatusProvider::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->objectManagerHelper = new ObjectManagerHelper($this); - - $this->collectData = $this->objectManagerHelper->getObject( - CollectData::class, - [ - 'exportDataHandler' => $this->exportDataHandlerMock, - 'subscriptionStatus' => $this->subscriptionStatusMock, - ] - ); - } - - /** - * @param string $status - * @return void - * @dataProvider executeDataProvider - */ - public function testExecute($status) - { - $this->subscriptionStatusMock - ->expects($this->once()) - ->method('getStatus') - ->with() - ->willReturn($status); - $this->exportDataHandlerMock - ->expects(($status === SubscriptionStatusProvider::ENABLED) ? $this->once() : $this->never()) - ->method('prepareExportData') - ->with(); - - $this->assertTrue($this->collectData->execute()); - } - - /** - * @return array - */ - public function executeDataProvider() - { - return [ - 'Subscription is enabled' => [SubscriptionStatusProvider::ENABLED], - 'Subscription is disabled' => [SubscriptionStatusProvider::DISABLED], - ]; - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Cron/SignUpTest.php b/app/code/Magento/Analytics/Test/Unit/Cron/SignUpTest.php deleted file mode 100644 index c8ab5a6f4649e..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Cron/SignUpTest.php +++ /dev/null @@ -1,133 +0,0 @@ -connectorMock = $this->getMockBuilder(Connector::class) - ->disableOriginalConstructor() - ->getMock(); - $this->configWriterMock = $this->getMockBuilder(WriterInterface::class) - ->disableOriginalConstructor() - ->getMock(); - $this->flagManagerMock = $this->getMockBuilder(FlagManager::class) - ->disableOriginalConstructor() - ->getMock(); - $this->reinitableConfigMock = $this->getMockBuilder(ReinitableConfigInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->signUp = new SignUp( - $this->connectorMock, - $this->configWriterMock, - $this->flagManagerMock, - $this->reinitableConfigMock - ); - } - - public function testExecute() - { - $attemptsCount = 10; - - $this->flagManagerMock->expects($this->once()) - ->method('getFlagData') - ->with(SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE) - ->willReturn($attemptsCount); - - $attemptsCount -= 1; - $this->flagManagerMock->expects($this->once()) - ->method('saveFlag') - ->with(SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE, $attemptsCount); - $this->connectorMock->expects($this->once()) - ->method('execute') - ->with('signUp') - ->willReturn(true); - $this->addDeleteAnalyticsCronExprAsserts(); - $this->flagManagerMock->expects($this->once()) - ->method('deleteFlag') - ->with(SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE); - $this->assertTrue($this->signUp->execute()); - } - - public function testExecuteFlagNotExist() - { - $this->flagManagerMock->expects($this->once()) - ->method('getFlagData') - ->with(SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE) - ->willReturn(null); - $this->addDeleteAnalyticsCronExprAsserts(); - $this->assertFalse($this->signUp->execute()); - } - - public function testExecuteZeroAttempts() - { - $attemptsCount = 0; - $this->flagManagerMock->expects($this->once()) - ->method('getFlagData') - ->with(SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE) - ->willReturn($attemptsCount); - $this->addDeleteAnalyticsCronExprAsserts(); - $this->flagManagerMock->expects($this->once()) - ->method('deleteFlag') - ->with(SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE); - $this->assertFalse($this->signUp->execute()); - } - - /** - * Add assertions for method deleteAnalyticsCronExpr. - * - * @return void - */ - private function addDeleteAnalyticsCronExprAsserts() - { - $this->configWriterMock - ->expects($this->once()) - ->method('delete') - ->with(SubscriptionHandler::CRON_STRING_PATH) - ->willReturn(true); - $this->reinitableConfigMock - ->expects($this->once()) - ->method('reinit') - ->willReturnSelf(); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Cron/UpdateTest.php b/app/code/Magento/Analytics/Test/Unit/Cron/UpdateTest.php deleted file mode 100644 index 23ba59a90ce7b..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Cron/UpdateTest.php +++ /dev/null @@ -1,214 +0,0 @@ -connectorMock = $this->getMockBuilder(Connector::class) - ->disableOriginalConstructor() - ->getMock(); - $this->configWriterMock = $this->getMockBuilder(WriterInterface::class) - ->disableOriginalConstructor() - ->getMock(); - $this->flagManagerMock = $this->getMockBuilder(FlagManager::class) - ->disableOriginalConstructor() - ->getMock(); - $this->reinitableConfigMock = $this->getMockBuilder(ReinitableConfigInterface::class) - ->disableOriginalConstructor() - ->getMock(); - $this->analyticsTokenMock = $this->getMockBuilder(AnalyticsToken::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->update = new Update( - $this->connectorMock, - $this->configWriterMock, - $this->reinitableConfigMock, - $this->flagManagerMock, - $this->analyticsTokenMock - ); - } - - /** - * @return void - */ - public function testExecuteWithoutToken() - { - $this->flagManagerMock - ->method('getFlagData') - ->with(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE) - ->willReturn(10); - $this->connectorMock - ->expects($this->once()) - ->method('execute') - ->with('update') - ->willReturn(false); - $this->analyticsTokenMock - ->expects($this->once()) - ->method('isTokenExist') - ->willReturn(false); - $this->addFinalOutputAsserts(); - $this->assertFalse($this->update->execute()); - } - - /** - * @param bool $isExecuted - */ - private function addFinalOutputAsserts(bool $isExecuted = true) - { - $this->flagManagerMock - ->expects($this->exactly(2 * $isExecuted)) - ->method('deleteFlag') - ->withConsecutive( - [SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE], - [SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE] - ); - $this->configWriterMock - ->expects($this->exactly((int)$isExecuted)) - ->method('delete') - ->with(SubscriptionUpdateHandler::UPDATE_CRON_STRING_PATH); - $this->reinitableConfigMock - ->expects($this->exactly((int)$isExecuted)) - ->method('reinit') - ->with(); - } - - /** - * @param $counterData - * @return void - * @dataProvider executeWithEmptyReverseCounterDataProvider - */ - public function testExecuteWithEmptyReverseCounter($counterData) - { - $this->flagManagerMock - ->method('getFlagData') - ->with(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE) - ->willReturn($counterData); - $this->connectorMock - ->expects($this->never()) - ->method('execute') - ->with('update') - ->willReturn(false); - $this->analyticsTokenMock - ->method('isTokenExist') - ->willReturn(true); - $this->addFinalOutputAsserts(); - $this->assertFalse($this->update->execute()); - } - - /** - * Provides empty states of the reverse counter. - * - * @return array - */ - public function executeWithEmptyReverseCounterDataProvider() - { - return [ - [null], - [0] - ]; - } - - /** - * @param int $reverseCount - * @param bool $commandResult - * @param bool $finalConditionsIsExpected - * @param bool $functionResult - * @return void - * @dataProvider executeRegularScenarioDataProvider - */ - public function testExecuteRegularScenario( - int $reverseCount, - bool $commandResult, - bool $finalConditionsIsExpected, - bool $functionResult - ) { - $this->flagManagerMock - ->method('getFlagData') - ->with(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE) - ->willReturn($reverseCount); - $this->connectorMock - ->expects($this->once()) - ->method('execute') - ->with('update') - ->willReturn($commandResult); - $this->analyticsTokenMock - ->method('isTokenExist') - ->willReturn(true); - $this->addFinalOutputAsserts($finalConditionsIsExpected); - $this->assertSame($functionResult, $this->update->execute()); - } - - /** - * @return array - */ - public function executeRegularScenarioDataProvider() - { - return [ - 'The last attempt with command execution result False' => [ - 'Reverse count' => 1, - 'Command result' => false, - 'Executed final output conditions' => true, - 'Function result' => false, - ], - 'Not the last attempt with command execution result False' => [ - 'Reverse count' => 10, - 'Command result' => false, - 'Executed final output conditions' => false, - 'Function result' => false, - ], - 'Command execution result True' => [ - 'Reverse count' => 10, - 'Command result' => true, - 'Executed final output conditions' => true, - 'Function result' => true, - ], - ]; - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/AnalyticsTokenTest.php b/app/code/Magento/Analytics/Test/Unit/Model/AnalyticsTokenTest.php deleted file mode 100644 index e078bbe99f93a..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/AnalyticsTokenTest.php +++ /dev/null @@ -1,129 +0,0 @@ -reinitableConfigMock = $this->getMockBuilder(ReinitableConfigInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->configMock = $this->getMockBuilder(ScopeConfigInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->configWriterMock = $this->getMockBuilder(WriterInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->objectManagerHelper = new ObjectManagerHelper($this); - - $this->tokenModel = $this->objectManagerHelper->getObject( - AnalyticsToken::class, - [ - 'reinitableConfig' => $this->reinitableConfigMock, - 'config' => $this->configMock, - 'configWriter' => $this->configWriterMock, - 'tokenPath' => $this->tokenPath, - ] - ); - } - - /** - * @return void - */ - public function testStoreToken() - { - $value = 'jjjj0000'; - - $this->configWriterMock - ->expects($this->once()) - ->method('save') - ->with($this->tokenPath, $value); - - $this->reinitableConfigMock - ->expects($this->once()) - ->method('reinit') - ->willReturnSelf(); - - $this->assertTrue($this->tokenModel->storeToken($value)); - } - - /** - * @return void - */ - public function testGetToken() - { - $value = 'jjjj0000'; - - $this->configMock - ->expects($this->once()) - ->method('getValue') - ->with($this->tokenPath) - ->willReturn($value); - - $this->assertSame($value, $this->tokenModel->getToken()); - } - - /** - * @return void - */ - public function testIsTokenExist() - { - $this->assertFalse($this->tokenModel->isTokenExist()); - - $this->configMock - ->expects($this->once()) - ->method('getValue') - ->with($this->tokenPath) - ->willReturn('0000'); - $this->assertTrue($this->tokenModel->isTokenExist()); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Condition/CanViewNotificationTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Condition/CanViewNotificationTest.php deleted file mode 100644 index bfdc971efc79e..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/Condition/CanViewNotificationTest.php +++ /dev/null @@ -1,81 +0,0 @@ -dateTimeFactoryMock = $this->getMockBuilder(DateTimeFactory::class) - ->getMock(); - $this->dateTimeMock = $this->getMockBuilder(\DateTime::class) - ->getMock(); - $this->notificationTimeMock = $this->getMockBuilder(NotificationTime::class) - ->disableOriginalConstructor() - ->getMock(); - $objectManager = new ObjectManager($this); - $this->canViewNotification = $objectManager->getObject( - CanViewNotification::class, - [ - 'notificationTime' => $this->notificationTimeMock, - 'dateTimeFactory' => $this->dateTimeFactoryMock - ] - ); - } - - public function testValidate() - { - $this->notificationTimeMock->expects($this->once()) - ->method('getLastTimeNotification') - ->willReturn(1); - $this->dateTimeFactoryMock->expects($this->once()) - ->method('create') - ->willReturn($this->dateTimeMock); - $this->dateTimeMock->expects($this->once()) - ->method('getTimestamp') - ->willReturn(10005000); - $this->assertTrue($this->canViewNotification->isVisible([])); - } - - public function testValidateFlagRemoved() - { - $this->notificationTimeMock->expects($this->once()) - ->method('getLastTimeNotification') - ->willReturn(null); - $this->dateTimeFactoryMock->expects($this->never()) - ->method('create'); - $this->assertFalse($this->canViewNotification->isVisible([])); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/Baseurl/SubscriptionUpdateHandlerTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/Baseurl/SubscriptionUpdateHandlerTest.php deleted file mode 100644 index 865ad236fc057..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/Baseurl/SubscriptionUpdateHandlerTest.php +++ /dev/null @@ -1,178 +0,0 @@ -reinitableConfigMock = $this->getMockBuilder(ReinitableConfigInterface::class) - ->disableOriginalConstructor() - ->getMockForAbstractClass(); - - $this->analyticsTokenMock = $this->getMockBuilder(AnalyticsToken::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->flagManagerMock = $this->getMockBuilder(FlagManager::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->configWriterMock = $this->getMockBuilder(WriterInterface::class) - ->disableOriginalConstructor() - ->getMockForAbstractClass(); - - $this->objectManagerHelper = new ObjectManagerHelper($this); - - $this->subscriptionUpdateHandler = $this->objectManagerHelper->getObject( - SubscriptionUpdateHandler::class, - [ - 'reinitableConfig' => $this->reinitableConfigMock, - 'analyticsToken' => $this->analyticsTokenMock, - 'flagManager' => $this->flagManagerMock, - 'configWriter' => $this->configWriterMock, - ] - ); - } - - /** - * @return void - */ - public function testTokenDoesNotExist() - { - $this->analyticsTokenMock - ->expects($this->once()) - ->method('isTokenExist') - ->with() - ->willReturn(false); - $this->flagManagerMock - ->expects($this->never()) - ->method('saveFlag'); - $this->configWriterMock - ->expects($this->never()) - ->method('save'); - $this->assertTrue($this->subscriptionUpdateHandler->processUrlUpdate('http://store.com')); - } - - /** - * @return void - */ - public function testTokenAndPreviousBaseUrlExist() - { - $url = 'https://store.com'; - $this->analyticsTokenMock - ->expects($this->once()) - ->method('isTokenExist') - ->with() - ->willReturn(true); - $this->flagManagerMock - ->expects($this->once()) - ->method('getFlagData') - ->with(SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE) - ->willReturn(true); - $this->flagManagerMock - ->expects($this->once()) - ->method('saveFlag') - ->withConsecutive( - [SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE, $this->attemptsInitValue], - [SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE, $url] - ); - $this->configWriterMock - ->expects($this->once()) - ->method('save') - ->with(SubscriptionUpdateHandler::UPDATE_CRON_STRING_PATH, $this->cronExpression); - $this->reinitableConfigMock - ->expects($this->once()) - ->method('reinit') - ->with(); - $this->assertTrue($this->subscriptionUpdateHandler->processUrlUpdate($url)); - } - - /** - * @return void - */ - public function testTokenExistAndWithoutPreviousBaseUrl() - { - $url = 'https://store.com'; - $this->analyticsTokenMock - ->expects($this->once()) - ->method('isTokenExist') - ->with() - ->willReturn(true); - $this->flagManagerMock - ->expects($this->once()) - ->method('getFlagData') - ->with(SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE) - ->willReturn(false); - $this->flagManagerMock - ->expects($this->exactly(2)) - ->method('saveFlag') - ->withConsecutive( - [SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE, $url], - [SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE, $this->attemptsInitValue] - ); - $this->configWriterMock - ->expects($this->once()) - ->method('save') - ->with(SubscriptionUpdateHandler::UPDATE_CRON_STRING_PATH, $this->cronExpression); - $this->reinitableConfigMock - ->expects($this->once()) - ->method('reinit') - ->with(); - $this->assertTrue($this->subscriptionUpdateHandler->processUrlUpdate($url)); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/CollectionTimeTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/CollectionTimeTest.php deleted file mode 100644 index 555020ffd247f..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/CollectionTimeTest.php +++ /dev/null @@ -1,111 +0,0 @@ -configWriterMock = $this->getMockBuilder(WriterInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->loggerMock = $this->getMockBuilder(LoggerInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->objectManagerHelper = new ObjectManagerHelper($this); - - $this->collectionTime = $this->objectManagerHelper->getObject( - CollectionTime::class, - [ - 'configWriter' => $this->configWriterMock, - '_logger' => $this->loggerMock, - ] - ); - } - - /** - * @return void - */ - public function testAfterSave() - { - $this->collectionTime->setData('value', '05,04,03'); - - $this->configWriterMock - ->expects($this->once()) - ->method('save') - ->with(CollectionTime::CRON_SCHEDULE_PATH, join(' ', ['04', '05', '*', '*', '*'])); - - $this->assertInstanceOf( - Value::class, - $this->collectionTime->afterSave() - ); - } - - /** - * @return void - * @expectedException \Magento\Framework\Exception\LocalizedException - */ - public function testAfterSaveWrongValue() - { - $this->collectionTime->setData('value', '00,01'); - $this->collectionTime->afterSave(); - } - - /** - * @return void - * @expectedException \Magento\Framework\Exception\LocalizedException - */ - public function testAfterSaveWithLocalizedException() - { - $exception = new \Exception('Test message'); - $this->collectionTime->setData('value', '05,04,03'); - - $this->configWriterMock - ->expects($this->once()) - ->method('save') - ->with(CollectionTime::CRON_SCHEDULE_PATH, join(' ', ['04', '05', '*', '*', '*'])) - ->willThrowException($exception); - $this->loggerMock - ->expects($this->once()) - ->method('error') - ->with($exception->getMessage()); - $this->collectionTime->afterSave(); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/Enabled/SubscriptionHandlerTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/Enabled/SubscriptionHandlerTest.php deleted file mode 100644 index d01101bf5cc3b..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/Enabled/SubscriptionHandlerTest.php +++ /dev/null @@ -1,185 +0,0 @@ -flagManagerMock = $this->getMockBuilder(FlagManager::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->configWriterMock = $this->getMockBuilder(WriterInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->tokenMock = $this->getMockBuilder(AnalyticsToken::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->notificationTimeMock = $this->getMockBuilder(NotificationTime::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->objectManagerHelper = new ObjectManagerHelper($this); - - $this->subscriptionHandler = $this->objectManagerHelper->getObject( - SubscriptionHandler::class, - [ - 'flagManager' => $this->flagManagerMock, - 'configWriter' => $this->configWriterMock, - 'attemptsInitValue' => $this->attemptsInitValue, - 'analyticsToken' => $this->tokenMock, - 'notificationTime' => $this->notificationTimeMock, - ] - ); - } - - /** - * @return void - */ - public function testProcessEnabledTokenExist() - { - $this->tokenMock - ->expects($this->once()) - ->method('isTokenExist') - ->willReturn(true); - $this->configWriterMock - ->expects($this->never()) - ->method('save'); - $this->flagManagerMock - ->expects($this->never()) - ->method('saveFlag'); - $this->notificationTimeMock - ->expects($this->never()) - ->method('unsetLastTimeNotificationValue'); - $this->assertTrue( - $this->subscriptionHandler->processEnabled() - ); - } - - /** - * @return void - */ - public function testProcessEnabledTokenDoesNotExist() - { - $this->tokenMock - ->expects($this->once()) - ->method('isTokenExist') - ->willReturn(false); - $this->configWriterMock - ->expects($this->once()) - ->method('save') - ->with(SubscriptionHandler::CRON_STRING_PATH, "0 * * * *"); - $this->flagManagerMock - ->expects($this->once()) - ->method('saveFlag') - ->with(SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE, $this->attemptsInitValue) - ->willReturn(true); - $this->notificationTimeMock - ->expects($this->once()) - ->method('unsetLastTimeNotificationValue') - ->willReturn(true); - $this->assertTrue( - $this->subscriptionHandler->processEnabled() - ); - } - - /** - * @return void - */ - public function testProcessDisabledTokenDoesNotExist() - { - $this->configWriterMock - ->expects($this->once()) - ->method('delete') - ->with(CollectionTime::CRON_SCHEDULE_PATH); - $this->tokenMock - ->expects($this->once()) - ->method('isTokenExist') - ->willReturn(false); - $this->flagManagerMock - ->expects($this->once()) - ->method('deleteFlag') - ->with(SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE) - ->willReturn(true); - $this->assertTrue( - $this->subscriptionHandler->processDisabled() - ); - } - - /** - * @return void - */ - public function testProcessDisabledTokenExists() - { - $this->configWriterMock - ->expects($this->once()) - ->method('delete') - ->with(CollectionTime::CRON_SCHEDULE_PATH); - $this->tokenMock - ->expects($this->once()) - ->method('isTokenExist') - ->willReturn(true); - $this->flagManagerMock - ->expects($this->never()) - ->method('deleteFlag'); - $this->assertTrue( - $this->subscriptionHandler->processDisabled() - ); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/EnabledTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/EnabledTest.php deleted file mode 100644 index d64827d2d18d2..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/EnabledTest.php +++ /dev/null @@ -1,184 +0,0 @@ -subscriptionHandlerMock = $this->getMockBuilder(SubscriptionHandler::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->loggerMock = $this->getMockBuilder(LoggerInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->configMock = $this->getMockBuilder(ScopeConfigInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->objectManagerHelper = new ObjectManagerHelper($this); - - $this->enabledModel = $this->objectManagerHelper->getObject( - Enabled::class, - [ - 'subscriptionHandler' => $this->subscriptionHandlerMock, - '_logger' => $this->loggerMock, - 'config' => $this->configMock, - ] - ); - } - - /** - * @return void - */ - public function testAfterSaveSuccessEnabled() - { - $this->enabledModel->setData('value', $this->valueEnabled); - - $this->configMock - ->expects($this->any()) - ->method('getValue') - ->willReturn(!$this->valueEnabled); - - $this->subscriptionHandlerMock - ->expects($this->once()) - ->method('processEnabled') - ->with() - ->willReturn(true); - - $this->assertInstanceOf( - Value::class, - $this->enabledModel->afterSave() - ); - } - - /** - * @return void - */ - public function testAfterSaveSuccessDisabled() - { - $this->enabledModel->setData('value', $this->valueDisabled); - - $this->configMock - ->expects($this->any()) - ->method('getValue') - ->willReturn(!$this->valueDisabled); - - $this->subscriptionHandlerMock - ->expects($this->once()) - ->method('processDisabled') - ->with() - ->willReturn(true); - - $this->assertInstanceOf( - Value::class, - $this->enabledModel->afterSave() - ); - } - - /** - * @return void - */ - public function testAfterSaveSuccessValueNotChanged() - { - $this->enabledModel->setData('value', null); - - $this->configMock - ->expects($this->any()) - ->method('getValue') - ->willReturn(null); - - $this->subscriptionHandlerMock - ->expects($this->never()) - ->method('processEnabled') - ->with() - ->willReturn(true); - $this->subscriptionHandlerMock - ->expects($this->never()) - ->method('processDisabled') - ->with() - ->willReturn(true); - - $this->assertInstanceOf( - Value::class, - $this->enabledModel->afterSave() - ); - } - - /** - * @return void - * @expectedException \Magento\Framework\Exception\LocalizedException - */ - public function testExecuteAfterSaveFailedWithLocalizedException() - { - $exception = new \Exception('Message'); - $this->enabledModel->setData('value', $this->valueEnabled); - - $this->subscriptionHandlerMock - ->expects($this->once()) - ->method('processEnabled') - ->with() - ->willThrowException($exception); - - $this->loggerMock - ->expects($this->once()) - ->method('error') - ->with($exception->getMessage()); - - $this->enabledModel->afterSave(); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/VerticalTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/VerticalTest.php deleted file mode 100644 index d689f040c48b3..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/Config/Backend/VerticalTest.php +++ /dev/null @@ -1,59 +0,0 @@ -objectManagerHelper = - new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - - $this->subject = $this->objectManagerHelper->getObject( - \Magento\Analytics\Model\Config\Backend\Vertical::class - ); - } - - /** - * @return void - */ - public function testBeforeSaveSuccess() - { - $this->subject->setValue('Apps and Games'); - - $this->assertInstanceOf( - \Magento\Analytics\Model\Config\Backend\Vertical::class, - $this->subject->beforeSave() - ); - } - - /** - * @return void - * @expectedException \Magento\Framework\Exception\LocalizedException - */ - public function testBeforeSaveFailedWithLocalizedException() - { - $this->subject->setValue(''); - - $this->subject->beforeSave(); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Config/MapperTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Config/MapperTest.php deleted file mode 100644 index 7c94fb1b60a14..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/Config/MapperTest.php +++ /dev/null @@ -1,142 +0,0 @@ -objectManagerHelper = new ObjectManagerHelper($this); - - $this->mapper = $this->objectManagerHelper->getObject(Mapper::class); - } - - /** - * @param array $configData - * @param array $resultData - * @return void - * - * @dataProvider executingDataProvider - */ - public function testExecution($configData, $resultData) - { - $this->assertSame($resultData, $this->mapper->execute($configData)); - } - - /** - * @return array - */ - public function executingDataProvider() - { - return [ - 'wrongConfig' => [ - ['config' => ['files']], - [] - ], - 'validConfigWithFileNodes' => [ - [ - 'config' => [ - 0 => [ - 'file' => [ - 0 => [ - 'name' => 'fileName', - 'providers' => [[]] - ] - ] - ] - ] - ], - [ - 'fileName' => [ - 'name' => 'fileName', - 'providers' => [] - ] - ], - ], - 'validConfigWithProvidersNode' => [ - [ - 'config' => [ - 0 => [ - 'file' => [ - 0 => [ - 'name' => 'fileName', - 'providers' => [ - 0 => [ - 'reportProvider' => [0 => []] - ] - ] - ] - ] - ] - ] - ], - [ - 'fileName' => [ - 'name' => 'fileName', - 'providers' => [ - 'reportProvider' => ['parameters' => []] - ] - ] - ], - ], - 'validConfigWithParametersNode' => [ - [ - 'config' => [ - 0 => [ - 'file' => [ - 0 => [ - 'name' => 'fileName', - 'providers' => [ - 0 => [ - 'reportProvider' => [ - 0 => [ - 'parameters' => [ - 0 => ['name' => ['reportName']] - ] - ] - ] - ] - ] - ] - ] - ] - ] - ], - [ - 'fileName' => [ - 'name' => 'fileName', - 'providers' => [ - 'reportProvider' => [ - 'parameters' => [ - 'name' => 'reportName' - ] - ] - ] - ] - ], - ], - ]; - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Config/ReaderTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Config/ReaderTest.php deleted file mode 100644 index 1eee74a1f93a0..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/Config/ReaderTest.php +++ /dev/null @@ -1,108 +0,0 @@ -mapperMock = $this->getMockBuilder(Mapper::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->readerXmlMock = $this->getMockBuilder(ReaderInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->readerDbMock = $this->getMockBuilder(ReaderInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->objectManagerHelper = new ObjectManagerHelper($this); - - $this->reader = $this->objectManagerHelper->getObject( - Reader::class, - [ - 'mapper' => $this->mapperMock, - 'readers' => [ - $this->readerXmlMock, - $this->readerDbMock, - ], - ] - ); - } - - /** - * @return void - */ - public function testRead() - { - $scope = 'store'; - $xmlReaderResult = [ - 'config' => ['node1' => ['node2' => 'node4']] - ]; - $dbReaderResult = [ - 'config' => ['node1' => ['node2' => 'node3']] - ]; - $mapperResult = ['node2' => ['node3', 'node4']]; - - $this->readerXmlMock - ->expects($this->once()) - ->method('read') - ->with($scope) - ->willReturn($xmlReaderResult); - - $this->readerDbMock - ->expects($this->once()) - ->method('read') - ->with($scope) - ->willReturn($dbReaderResult); - - $this->mapperMock - ->expects($this->once()) - ->method('execute') - ->with(array_merge_recursive($xmlReaderResult, $dbReaderResult)) - ->willReturn($mapperResult); - - $this->assertSame($mapperResult, $this->reader->read($scope)); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Config/Source/VerticalTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Config/Source/VerticalTest.php deleted file mode 100644 index b96f3543ff701..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/Config/Source/VerticalTest.php +++ /dev/null @@ -1,60 +0,0 @@ -objectManagerHelper = - new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - - $this->subject = $this->objectManagerHelper->getObject( - \Magento\Analytics\Model\Config\Source\Vertical::class, - [ - 'verticals' => [ - 'Apps and Games', - 'Athletic/Sporting Goods', - 'Art and Design' - ] - ] - ); - } - - /** - * @return void - */ - public function testToOptionArray() - { - $expectedOptionsArray = [ - ['value' => '', 'label' => __('--Please Select--')], - ['value' => 'Apps and Games', 'label' => __('Apps and Games')], - ['value' => 'Athletic/Sporting Goods', 'label' => __('Athletic/Sporting Goods')], - ['value' => 'Art and Design', 'label' => __('Art and Design')] - ]; - - $this->assertEquals( - $expectedOptionsArray, - $this->subject->toOptionArray() - ); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/ConfigTest.php b/app/code/Magento/Analytics/Test/Unit/Model/ConfigTest.php deleted file mode 100644 index 8282b1ae52617..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/ConfigTest.php +++ /dev/null @@ -1,68 +0,0 @@ -dataInterfaceMock = $this->getMockBuilder(DataInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->objectManagerHelper = new ObjectManagerHelper($this); - - $this->config = $this->objectManagerHelper->getObject( - Config::class, - [ - 'data' => $this->dataInterfaceMock, - ] - ); - } - - /** - * @return void - */ - public function testGet() - { - $key = 'configKey'; - $defaultValue = 'mock'; - $configValue = 'emptyString'; - - $this->dataInterfaceMock - ->expects($this->once()) - ->method('get') - ->with($key, $defaultValue) - ->willReturn($configValue); - - $this->assertSame($configValue, $this->config->get($key, $defaultValue)); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/Client/CurlTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/Client/CurlTest.php deleted file mode 100644 index 6890fe200f9dc..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/Client/CurlTest.php +++ /dev/null @@ -1,218 +0,0 @@ -curlMock = $this->getMockBuilder( - \Magento\Framework\HTTP\Adapter\Curl::class - ) - ->disableOriginalConstructor() - ->getMock(); - - $this->loggerMock = $this->getMockBuilder( - \Psr\Log\LoggerInterface::class - ) - ->disableOriginalConstructor() - ->getMock(); - $this->curlFactoryMock = $this->getMockBuilder(CurlFactory::class) - ->setMethods(['create']) - ->disableOriginalConstructor() - ->getMock(); - $this->curlFactoryMock->expects($this->any()) - ->method('create') - ->willReturn($this->curlMock); - - $this->responseFactoryMock = $this->getMockBuilder( - \Magento\Analytics\Model\Connector\Http\ResponseFactory::class - ) - ->disableOriginalConstructor() - ->getMock(); - $this->converterMock = $this->createJsonConverter(); - - $this->objectManagerHelper = - new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - - $this->subject = $this->objectManagerHelper->getObject( - \Magento\Analytics\Model\Connector\Http\Client\Curl::class, - [ - 'curlFactory' => $this->curlFactoryMock, - 'responseFactory' => $this->responseFactoryMock, - 'converter' => $this->converterMock, - 'logger' => $this->loggerMock, - ] - ); - } - - /** - * Returns test parameters for request. - * - * @return array - */ - public function getTestData() - { - return [ - [ - 'data' => [ - 'version' => '1.1', - 'body'=> ['name' => 'value'], - 'url' => 'http://www.mystore.com', - 'headers' => [JsonConverter::CONTENT_TYPE_HEADER], - 'method' => \Magento\Framework\HTTP\ZendClient::POST, - ] - ] - ]; - } - - /** - * @return void - * @dataProvider getTestData - */ - public function testRequestSuccess(array $data) - { - $responseString = 'This is response.'; - $response = new \Zend_Http_Response(201, [], $responseString); - $this->curlMock->expects($this->once()) - ->method('write') - ->with( - $data['method'], - $data['url'], - $data['version'], - $data['headers'], - json_encode($data['body']) - ); - $this->curlMock->expects($this->once()) - ->method('read') - ->willReturn($responseString); - $this->curlMock->expects($this->any()) - ->method('getErrno') - ->willReturn(0); - - $this->responseFactoryMock->expects($this->any()) - ->method('create') - ->with($responseString) - ->willReturn($response); - - $this->assertEquals( - $response, - $this->subject->request( - $data['method'], - $data['url'], - $data['body'], - $data['headers'], - $data['version'] - ) - ); - } - - /** - * @return void - * @dataProvider getTestData - */ - public function testRequestError(array $data) - { - $response = new \Zend_Http_Response(0, []); - $this->curlMock->expects($this->once()) - ->method('write') - ->with( - $data['method'], - $data['url'], - $data['version'], - $data['headers'], - json_encode($data['body']) - ); - $this->curlMock->expects($this->once()) - ->method('read'); - $this->curlMock->expects($this->atLeastOnce()) - ->method('getErrno') - ->willReturn(1); - $this->curlMock->expects($this->atLeastOnce()) - ->method('getError') - ->willReturn('CURL error.'); - - $this->loggerMock->expects($this->once()) - ->method('critical') - ->with( - new \Exception( - 'MBI service CURL connection error #1: CURL error.' - ) - ); - - $this->assertEquals( - $response, - $this->subject->request( - $data['method'], - $data['url'], - $data['body'], - $data['headers'], - $data['version'] - ) - ); - } - - /** - * @return \PHPUnit_Framework_MockObject_MockObject - */ - private function createJsonConverter() - { - $converterMock = $this->getMockBuilder(ConverterInterface::class) - ->getMockForAbstractClass(); - $converterMock->expects($this->any())->method('toBody')->willReturnCallback(function ($value) { - return json_encode($value); - }); - $converterMock->expects($this->any()) - ->method('getContentTypeHeader') - ->willReturn(JsonConverter::CONTENT_TYPE_HEADER); - return $converterMock; - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/JsonConverterTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/JsonConverterTest.php deleted file mode 100644 index 7ac6f50ea24c4..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/JsonConverterTest.php +++ /dev/null @@ -1,34 +0,0 @@ -assertEquals(JsonConverter::CONTENT_TYPE_HEADER, $converter->getContentTypeHeader()); - } - - public function testConvertBody() - { - $body = '{"token": "secret-token"}'; - $converter = new JsonConverter(); - $this->assertEquals(json_decode($body, 1), $converter->fromBody($body)); - } - - public function testConvertData() - { - $data = ["token" => "secret-token"]; - $converter = new JsonConverter(); - $this->assertEquals(json_encode($data), $converter->toBody($data)); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/ResponseResolverTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/ResponseResolverTest.php deleted file mode 100644 index 5047e8a9dd391..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/Connector/Http/ResponseResolverTest.php +++ /dev/null @@ -1,39 +0,0 @@ - 'testValue']; - $response = new \Zend_Http_Response(201, [], json_encode($expectedBody)); - $responseHandlerMock = $this->getMockBuilder(ResponseHandlerInterface::class) - ->getMockForAbstractClass(); - $responseHandlerMock->expects($this->once()) - ->method('handleResponse') - ->with($expectedBody) - ->willReturn(true); - $notFoundResponseHandlerMock = $this->getMockBuilder(ResponseHandlerInterface::class) - ->getMockForAbstractClass(); - $notFoundResponseHandlerMock->expects($this->never())->method('handleResponse'); - $responseResolver = new ResponseResolver( - new JsonConverter(), - [ - 201 => $responseHandlerMock, - 404 => $notFoundResponseHandlerMock, - ] - ); - $this->assertTrue($responseResolver->getResult($response)); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Connector/NotifyDataChangedCommandTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Connector/NotifyDataChangedCommandTest.php deleted file mode 100644 index 5b86dd6557d69..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/Connector/NotifyDataChangedCommandTest.php +++ /dev/null @@ -1,107 +0,0 @@ -analyticsTokenMock = $this->getMockBuilder(AnalyticsToken::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->httpClientMock = $this->getMockBuilder(ClientInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->configMock = $this->getMockBuilder(ScopeConfigInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->loggerMock = $this->getMockBuilder(LoggerInterface::class) - ->disableOriginalConstructor() - ->getMock(); - $successHandler = $this->getMockBuilder(\Magento\Analytics\Model\Connector\Http\ResponseHandlerInterface::class) - ->getMockForAbstractClass(); - $successHandler->method('handleResponse') - ->willReturn(true); - - $this->notifyDataChangedCommand = new NotifyDataChangedCommand( - $this->analyticsTokenMock, - $this->httpClientMock, - $this->configMock, - new ResponseResolver(new JsonConverter(), [201 => $successHandler]), - $this->loggerMock - ); - } - - public function testExecuteSuccess() - { - $configVal = "Config val"; - $token = "Secret token!"; - $this->analyticsTokenMock->expects($this->once()) - ->method('isTokenExist') - ->willReturn(true); - $this->configMock->expects($this->any()) - ->method('getValue') - ->willReturn($configVal); - $this->analyticsTokenMock->expects($this->once()) - ->method('getToken') - ->willReturn($token); - $this->httpClientMock->expects($this->once()) - ->method('request') - ->with( - ZendClient::POST, - $configVal, - ['access-token' => $token, 'url' => $configVal] - )->willReturn(new \Zend_Http_Response(201, [])); - $this->assertTrue($this->notifyDataChangedCommand->execute()); - } - - public function testExecuteWithoutToken() - { - $this->analyticsTokenMock->expects($this->once()) - ->method('isTokenExist') - ->willReturn(false); - $this->httpClientMock->expects($this->never()) - ->method('request'); - $this->assertFalse($this->notifyDataChangedCommand->execute()); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Connector/OTPRequestTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Connector/OTPRequestTest.php deleted file mode 100644 index a33d7d0d7c1bf..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/Connector/OTPRequestTest.php +++ /dev/null @@ -1,187 +0,0 @@ -loggerMock = $this->getMockBuilder(LoggerInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->configMock = $this->getMockBuilder(ScopeConfigInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->httpClientMock = $this->getMockBuilder(ClientInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->analyticsTokenMock = $this->getMockBuilder(AnalyticsToken::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->responseResolverMock = $this->getMockBuilder(ResponseResolver::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->subject = new OTPRequest( - $this->analyticsTokenMock, - $this->httpClientMock, - $this->configMock, - $this->responseResolverMock, - $this->loggerMock - ); - } - - /** - * Returns test parameters for request. - * - * @return array - */ - private function getTestData() - { - return [ - 'otp' => 'thisisotp', - 'url' => 'http://www.mystore.com', - 'access-token' => 'thisisaccesstoken', - 'method' => \Magento\Framework\HTTP\ZendClient::POST, - 'body'=> ['access-token' => 'thisisaccesstoken','url' => 'http://www.mystore.com'], - ]; - } - - /** - * @return void - */ - public function testCallSuccess() - { - $data = $this->getTestData(); - - $this->analyticsTokenMock->expects($this->once()) - ->method('isTokenExist') - ->willReturn(true); - $this->analyticsTokenMock->expects($this->once()) - ->method('getToken') - ->willReturn($data['access-token']); - - $this->configMock->expects($this->any()) - ->method('getValue') - ->willReturn($data['url']); - - $this->httpClientMock->expects($this->once()) - ->method('request') - ->with( - $data['method'], - $data['url'], - $data['body'] - ) - ->willReturn(new \Zend_Http_Response(201, [])); - $this->responseResolverMock->expects($this->once()) - ->method('getResult') - ->willReturn($data['otp']); - - $this->assertEquals( - $data['otp'], - $this->subject->call() - ); - } - - /** - * @return void - */ - public function testCallNoAccessToken() - { - $this->analyticsTokenMock->expects($this->once()) - ->method('isTokenExist') - ->willReturn(false); - - $this->httpClientMock->expects($this->never()) - ->method('request'); - - $this->assertFalse($this->subject->call()); - } - - /** - * @return void - */ - public function testCallNoOtp() - { - $data = $this->getTestData(); - - $this->analyticsTokenMock->expects($this->once()) - ->method('isTokenExist') - ->willReturn(true); - $this->analyticsTokenMock->expects($this->once()) - ->method('getToken') - ->willReturn($data['access-token']); - - $this->configMock->expects($this->any()) - ->method('getValue') - ->willReturn($data['url']); - - $this->httpClientMock->expects($this->once()) - ->method('request') - ->with( - $data['method'], - $data['url'], - $data['body'] - ) - ->willReturn(new \Zend_Http_Response(0, [])); - - $this->responseResolverMock->expects($this->once()) - ->method('getResult') - ->willReturn(false); - - $this->loggerMock->expects($this->once()) - ->method('warning'); - - $this->assertFalse($this->subject->call()); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/OTPTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/OTPTest.php deleted file mode 100644 index 203eb57157e0e..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/OTPTest.php +++ /dev/null @@ -1,22 +0,0 @@ -assertFalse($OTPHandler->handleResponse([])); - $expectedOtp = 123; - $this->assertEquals($expectedOtp, $OTPHandler->handleResponse(['otp' => $expectedOtp])); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/ReSignUpTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/ReSignUpTest.php deleted file mode 100644 index 4c3dde7a92c3f..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/ReSignUpTest.php +++ /dev/null @@ -1,36 +0,0 @@ -getMockBuilder(AnalyticsToken::class) - ->disableOriginalConstructor() - ->getMock(); - $analyticsToken->expects($this->once()) - ->method('storeToken') - ->with(null); - $subscriptionHandler = $this->getMockBuilder(SubscriptionHandler::class) - ->disableOriginalConstructor() - ->getMock(); - $subscriptionStatusProvider = $this->getMockBuilder(SubscriptionStatusProvider::class) - ->disableOriginalConstructor() - ->getMock(); - $subscriptionStatusProvider->method('getStatus')->willReturn(SubscriptionStatusProvider::ENABLED); - $reSignUpHandler = new ReSignUp($analyticsToken, $subscriptionHandler, $subscriptionStatusProvider); - $this->assertFalse($reSignUpHandler->handleResponse([])); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/SignUpTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/SignUpTest.php deleted file mode 100644 index 2bbd528638a19..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/SignUpTest.php +++ /dev/null @@ -1,30 +0,0 @@ -getMockBuilder(AnalyticsToken::class) - ->disableOriginalConstructor() - ->getMock(); - $analyticsToken->expects($this->once()) - ->method('storeToken') - ->with($accessToken); - $signUpHandler = new SignUp($analyticsToken, new JsonConverter()); - $this->assertFalse($signUpHandler->handleResponse([])); - $this->assertEquals($accessToken, $signUpHandler->handleResponse(['access-token' => $accessToken])); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/UpdateTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/UpdateTest.php deleted file mode 100644 index 90102e2c3d868..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/Connector/ResponseHandler/UpdateTest.php +++ /dev/null @@ -1,20 +0,0 @@ -assertTrue($updateHandler->handleResponse([])); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Connector/SignUpCommandTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Connector/SignUpCommandTest.php deleted file mode 100644 index cc9eba99b3d48..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/Connector/SignUpCommandTest.php +++ /dev/null @@ -1,174 +0,0 @@ -analyticsTokenMock = $this->getMockBuilder(AnalyticsToken::class) - ->disableOriginalConstructor() - ->getMock(); - $this->integrationManagerMock = $this->getMockBuilder(IntegrationManager::class) - ->disableOriginalConstructor() - ->getMock(); - $this->integrationToken = $this->getMockBuilder(IntegrationToken::class) - ->disableOriginalConstructor() - ->getMock(); - $this->configMock = $this->getMockBuilder(ScopeConfigInterface::class) - ->disableOriginalConstructor() - ->getMock(); - $this->httpClientMock = $this->getMockBuilder(ClientInterface::class) - ->disableOriginalConstructor() - ->getMock(); - $this->loggerMock = $this->getMockBuilder(LoggerInterface::class) - ->disableOriginalConstructor() - ->getMock(); - $this->responseResolverMock = $this->getMockBuilder(ResponseResolver::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->signUpCommand = new SignUpCommand( - $this->analyticsTokenMock, - $this->integrationManagerMock, - $this->configMock, - $this->httpClientMock, - $this->loggerMock, - $this->responseResolverMock - ); - } - - public function testExecuteSuccess() - { - $this->integrationManagerMock->expects($this->once()) - ->method('generateToken') - ->willReturn($this->integrationToken); - $this->integrationManagerMock->expects($this->once()) - ->method('activateIntegration') - ->willReturn(true); - $data = $this->getTestData(); - - $this->configMock->expects($this->any()) - ->method('getValue') - ->willReturn($data['url']); - $this->integrationToken->expects($this->any()) - ->method('getData') - ->with('token') - ->willReturn($data['integration-token']); - $httpResponse = new \Zend_Http_Response(201, [], '{"access-token": "' . $data['access-token'] . '"}'); - $this->httpClientMock->expects($this->once()) - ->method('request') - ->with( - $data['method'], - $data['url'], - $data['body'] - ) - ->willReturn($httpResponse); - $this->responseResolverMock->expects($this->any()) - ->method('getResult') - ->with($httpResponse) - ->willReturn(true); - $this->assertTrue($this->signUpCommand->execute()); - } - - public function testExecuteFailureCannotGenerateToken() - { - $this->integrationManagerMock->expects($this->once()) - ->method('generateToken') - ->willReturn(false); - $this->integrationManagerMock->expects($this->never()) - ->method('activateIntegration'); - $this->assertFalse($this->signUpCommand->execute()); - } - - public function testExecuteFailureResponseIsEmpty() - { - $this->integrationManagerMock->expects($this->once()) - ->method('generateToken') - ->willReturn($this->integrationToken); - $this->integrationManagerMock->expects($this->once()) - ->method('activateIntegration') - ->willReturn(true); - $httpResponse = new \Zend_Http_Response(0, []); - $this->httpClientMock->expects($this->once()) - ->method('request') - ->willReturn($httpResponse); - $this->responseResolverMock->expects($this->any()) - ->method('getResult') - ->willReturn(false); - $this->assertFalse($this->signUpCommand->execute()); - } - - /** - * Returns test parameters for request. - * - * @return array - */ - private function getTestData() - { - return [ - 'url' => 'http://www.mystore.com', - 'access-token' => 'thisisaccesstoken', - 'integration-token' => 'thisisintegrationtoken', - 'headers' => [JsonConverter::CONTENT_TYPE_HEADER], - 'method' => \Magento\Framework\HTTP\ZendClient::POST, - 'body'=> ['token' => 'thisisintegrationtoken','url' => 'http://www.mystore.com'], - ]; - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Connector/UpdateCommandTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Connector/UpdateCommandTest.php deleted file mode 100644 index eb22461d789c8..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/Connector/UpdateCommandTest.php +++ /dev/null @@ -1,143 +0,0 @@ -analyticsTokenMock = $this->getMockBuilder(AnalyticsToken::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->httpClientMock = $this->getMockBuilder(ClientInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->configMock = $this->getMockBuilder(ScopeConfigInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->loggerMock = $this->getMockBuilder(LoggerInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->flagManagerMock = $this->getMockBuilder(FlagManager::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->responseResolverMock = $this->getMockBuilder(ResponseResolver::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->updateCommand = new UpdateCommand( - $this->analyticsTokenMock, - $this->httpClientMock, - $this->configMock, - $this->loggerMock, - $this->flagManagerMock, - $this->responseResolverMock - ); - } - - public function testExecuteSuccess() - { - $url = "old.localhost.com"; - $configVal = "Config val"; - $token = "Secret token!"; - $this->analyticsTokenMock->expects($this->once()) - ->method('isTokenExist') - ->willReturn(true); - - $this->configMock->expects($this->any()) - ->method('getValue') - ->willReturn($configVal); - - $this->flagManagerMock->expects($this->once()) - ->method('getFlagData') - ->with(SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE) - ->willReturn($url); - - $this->analyticsTokenMock->expects($this->once()) - ->method('getToken') - ->willReturn($token); - - $this->httpClientMock->expects($this->once()) - ->method('request') - ->with( - ZendClient::PUT, - $configVal, - [ - 'url' => $url, - 'new-url' => $configVal, - 'access-token' => $token - ] - )->willReturn(new \Zend_Http_Response(200, [])); - - $this->responseResolverMock->expects($this->once()) - ->method('getResult') - ->willReturn(true); - - $this->assertTrue($this->updateCommand->execute()); - } - - public function testExecuteWithoutToken() - { - $this->analyticsTokenMock->expects($this->once()) - ->method('isTokenExist') - ->willReturn(false); - - $this->assertFalse($this->updateCommand->execute()); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/ConnectorTest.php b/app/code/Magento/Analytics/Test/Unit/Model/ConnectorTest.php deleted file mode 100644 index 14d641a19729d..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/ConnectorTest.php +++ /dev/null @@ -1,70 +0,0 @@ -objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class) - ->disableOriginalConstructor() - ->getMock(); - $this->signUpCommandMock = $this->getMockBuilder(SignUpCommand::class) - ->disableOriginalConstructor() - ->getMock(); - $this->commands = ['signUp' => SignUpCommand::class]; - $this->connector = new Connector($this->commands, $this->objectManagerMock); - } - - public function testExecute() - { - $commandName = 'signUp'; - $this->objectManagerMock->expects($this->once()) - ->method('create') - ->with($this->commands[$commandName]) - ->willReturn($this->signUpCommandMock); - $this->signUpCommandMock->expects($this->once()) - ->method('execute') - ->willReturn(true); - $this->assertTrue($this->connector->execute($commandName)); - } - - /** - * @expectedException \Magento\Framework\Exception\NotFoundException - */ - public function testExecuteCommandNotFound() - { - $commandName = 'register'; - $this->connector->execute($commandName); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/CryptographerTest.php b/app/code/Magento/Analytics/Test/Unit/Model/CryptographerTest.php deleted file mode 100644 index 3de718d843a1d..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/CryptographerTest.php +++ /dev/null @@ -1,226 +0,0 @@ -analyticsTokenMock = $this->getMockBuilder(AnalyticsToken::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->encodedContextFactoryMock = $this->getMockBuilder(EncodedContextFactory::class) - ->setMethods(['create']) - ->disableOriginalConstructor() - ->getMock(); - - $this->encodedContextMock = $this->getMockBuilder(EncodedContext::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->key = ''; - $this->source = ''; - $this->initializationVectors = []; - - $this->objectManagerHelper = new ObjectManagerHelper($this); - - $this->cryptographer = $this->objectManagerHelper->getObject( - Cryptographer::class, - [ - 'analyticsToken' => $this->analyticsTokenMock, - 'encodedContextFactory' => $this->encodedContextFactoryMock, - 'cipherMethod' => $this->cipherMethod, - ] - ); - } - - /** - * @return void - */ - public function testEncode() - { - $token = 'some-token-value'; - $this->source = 'Some text'; - $this->key = hash('sha256', $token); - - $checkEncodedContext = function ($parameters) { - $emptyRequiredParameters = - array_diff(['content', 'initializationVector'], array_keys(array_filter($parameters))); - if ($emptyRequiredParameters) { - return false; - } - - $encryptedData = openssl_encrypt( - $this->source, - $this->cipherMethod, - $this->key, - OPENSSL_RAW_DATA, - $parameters['initializationVector'] - ); - - return ($encryptedData === $parameters['content']); - }; - - $this->analyticsTokenMock - ->expects($this->once()) - ->method('getToken') - ->with() - ->willReturn($token); - - $this->encodedContextFactoryMock - ->expects($this->once()) - ->method('create') - ->with($this->callback($checkEncodedContext)) - ->willReturn($this->encodedContextMock); - - $this->assertSame($this->encodedContextMock, $this->cryptographer->encode($this->source)); - } - - /** - * @return void - */ - public function testEncodeUniqueInitializationVector() - { - $this->source = 'Some text'; - $token = 'some-token-value'; - - $registerInitializationVector = function ($parameters) { - if (empty($parameters['initializationVector'])) { - return false; - } - - $this->initializationVectors[] = $parameters['initializationVector']; - - return true; - }; - - $this->analyticsTokenMock - ->expects($this->exactly(2)) - ->method('getToken') - ->with() - ->willReturn($token); - - $this->encodedContextFactoryMock - ->expects($this->exactly(2)) - ->method('create') - ->with($this->callback($registerInitializationVector)) - ->willReturn($this->encodedContextMock); - - $this->assertSame($this->encodedContextMock, $this->cryptographer->encode($this->source)); - $this->assertSame($this->encodedContextMock, $this->cryptographer->encode($this->source)); - $this->assertCount(2, array_unique($this->initializationVectors)); - } - - /** - * @expectedException \Magento\Framework\Exception\LocalizedException - * @dataProvider encodeNotValidSourceDataProvider - */ - public function testEncodeNotValidSource($source) - { - $this->cryptographer->encode($source); - } - - /** - * @return array - */ - public function encodeNotValidSourceDataProvider() - { - return [ - 'Array' => [[]], - 'Empty string' => [''], - ]; - } - - /** - * @expectedException \Magento\Framework\Exception\LocalizedException - */ - public function testEncodeNotValidCipherMethod() - { - $source = 'Some string'; - $cryptographer = $this->objectManagerHelper->getObject( - Cryptographer::class, - [ - 'cipherMethod' => 'Wrong-method', - ] - ); - - $cryptographer->encode($source); - } - - /** - * @expectedException \Magento\Framework\Exception\LocalizedException - */ - public function testEncodeTokenNotValid() - { - $source = 'Some string'; - - $this->analyticsTokenMock - ->expects($this->once()) - ->method('getToken') - ->with() - ->willReturn(null); - - $this->cryptographer->encode($source); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/EncodedContextTest.php b/app/code/Magento/Analytics/Test/Unit/Model/EncodedContextTest.php deleted file mode 100644 index 283b13212919d..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/EncodedContextTest.php +++ /dev/null @@ -1,61 +0,0 @@ -objectManagerHelper = new ObjectManagerHelper($this); - } - - /** - * @param string $content - * @param string|null $initializationVector - * @return void - * @dataProvider constructDataProvider - */ - public function testConstruct($content, $initializationVector) - { - $constructorArguments = [ - 'content' => $content, - 'initializationVector' => $initializationVector, - ]; - /** @var EncodedContext $encodedContext */ - $encodedContext = $this->objectManagerHelper->getObject( - EncodedContext::class, - array_filter($constructorArguments) - ); - - $this->assertSame($content, $encodedContext->getContent()); - $this->assertSame($initializationVector ?: '', $encodedContext->getInitializationVector()); - } - - /** - * @return array - */ - public function constructDataProvider() - { - return [ - 'Without Initialization Vector' => ['content text', null], - 'With Initialization Vector' => ['content text', 'c51sd3c4sd68c5sd'], - ]; - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/ExportDataHandlerNotificationTest.php b/app/code/Magento/Analytics/Test/Unit/Model/ExportDataHandlerNotificationTest.php deleted file mode 100644 index b3826c232ed0c..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/ExportDataHandlerNotificationTest.php +++ /dev/null @@ -1,74 +0,0 @@ -objectManagerHelper = new ObjectManagerHelper($this); - } - - /** - * @return void - */ - public function testThatNotifyExecuted() - { - $expectedResult = true; - $notifyCommandName = 'notifyDataChanged'; - $exportDataHandlerMockObject = $this->createExportDataHandlerMock(); - $analyticsConnectorMockObject = $this->createAnalyticsConnectorMock(); - /** - * @var $exportDataHandlerNotification ExportDataHandlerNotification - */ - $exportDataHandlerNotification = $this->objectManagerHelper->getObject( - ExportDataHandlerNotification::class, - [ - 'exportDataHandler' => $exportDataHandlerMockObject, - 'connector' => $analyticsConnectorMockObject, - ] - ); - $exportDataHandlerMockObject->expects($this->once()) - ->method('prepareExportData') - ->willReturn($expectedResult); - $analyticsConnectorMockObject->expects($this->once()) - ->method('execute') - ->with($notifyCommandName); - $this->assertEquals($expectedResult, $exportDataHandlerNotification->prepareExportData()); - } - - /** - * @return \PHPUnit_Framework_MockObject_MockObject - */ - private function createExportDataHandlerMock() - { - return $this->getMockBuilder(ExportDataHandler::class)->disableOriginalConstructor()->getMock(); - } - - /** - * @return \PHPUnit_Framework_MockObject_MockObject - */ - private function createAnalyticsConnectorMock() - { - return $this->getMockBuilder(Connector::class)->disableOriginalConstructor()->getMock(); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/ExportDataHandlerTest.php b/app/code/Magento/Analytics/Test/Unit/Model/ExportDataHandlerTest.php deleted file mode 100644 index 7c181bea81aab..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/ExportDataHandlerTest.php +++ /dev/null @@ -1,270 +0,0 @@ -filesystemMock = $this->getMockBuilder(Filesystem::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->archiveMock = $this->getMockBuilder(Archive::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->reportWriterMock = $this->getMockBuilder(ReportWriterInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->cryptographerMock = $this->getMockBuilder(Cryptographer::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->fileRecorderMock = $this->getMockBuilder(FileRecorder::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->directoryMock = $this->getMockBuilder(WriteInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->encodedContextMock = $this->getMockBuilder(EncodedContext::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->objectManagerHelper = new ObjectManagerHelper($this); - - $this->exportDataHandler = $this->objectManagerHelper->getObject( - ExportDataHandler::class, - [ - 'filesystem' => $this->filesystemMock, - 'archive' => $this->archiveMock, - 'reportWriter' => $this->reportWriterMock, - 'cryptographer' => $this->cryptographerMock, - 'fileRecorder' => $this->fileRecorderMock, - 'subdirectoryPath' => $this->subdirectoryPath, - 'archiveName' => $this->archiveName, - ] - ); - } - - /** - * @param bool $isArchiveSourceDirectory - * @dataProvider prepareExportDataDataProvider - */ - public function testPrepareExportData($isArchiveSourceDirectory) - { - $tmpFilesDirectoryPath = $this->subdirectoryPath . 'tmp/'; - $archiveRelativePath = $this->subdirectoryPath . $this->archiveName; - - $archiveSource = $isArchiveSourceDirectory ? (__DIR__) : '/tmp/' . $tmpFilesDirectoryPath; - $archiveAbsolutePath = '/tmp/' . $archiveRelativePath; - - $this->filesystemMock - ->expects($this->once()) - ->method('getDirectoryWrite') - ->with(DirectoryList::SYS_TMP) - ->willReturn($this->directoryMock); - $this->directoryMock - ->expects($this->exactly(4)) - ->method('delete') - ->withConsecutive( - [$tmpFilesDirectoryPath], - [$archiveRelativePath] - ); - - $this->directoryMock - ->expects($this->exactly(4)) - ->method('getAbsolutePath') - ->withConsecutive( - [$tmpFilesDirectoryPath], - [$tmpFilesDirectoryPath], - [$archiveRelativePath], - [$archiveRelativePath] - ) - ->willReturnOnConsecutiveCalls( - $archiveSource, - $archiveSource, - $archiveAbsolutePath, - $archiveAbsolutePath - ); - - $this->reportWriterMock - ->expects($this->once()) - ->method('write') - ->with($this->directoryMock, $tmpFilesDirectoryPath); - - $this->directoryMock - ->expects($this->exactly(2)) - ->method('isExist') - ->withConsecutive( - [$tmpFilesDirectoryPath], - [$archiveRelativePath] - ) - ->willReturnOnConsecutiveCalls( - true, - true - ); - - $this->directoryMock - ->expects($this->once()) - ->method('create') - ->with(dirname($archiveRelativePath)); - - $this->archiveMock - ->expects($this->once()) - ->method('pack') - ->with( - $archiveSource, - $archiveAbsolutePath, - $isArchiveSourceDirectory ? true : false - ); - - $fileContent = 'Some text'; - $this->directoryMock - ->expects($this->once()) - ->method('readFile') - ->with($archiveRelativePath) - ->willReturn($fileContent); - - $this->cryptographerMock - ->expects($this->once()) - ->method('encode') - ->with($fileContent) - ->willReturn($this->encodedContextMock); - - $this->fileRecorderMock - ->expects($this->once()) - ->method('recordNewFile') - ->with($this->encodedContextMock); - - $this->assertTrue($this->exportDataHandler->prepareExportData()); - } - - /** - * @return array - */ - public function prepareExportDataDataProvider() - { - return [ - 'Data source for archive is directory' => [true], - 'Data source for archive doesn\'t directory' => [false], - ]; - } - - /** - * @return void - * @expectedException \Magento\Framework\Exception\LocalizedException - */ - public function testPrepareExportDataWithLocalizedException() - { - $tmpFilesDirectoryPath = $this->subdirectoryPath . 'tmp/'; - $archivePath = $this->subdirectoryPath . $this->archiveName; - - $this->filesystemMock - ->expects($this->once()) - ->method('getDirectoryWrite') - ->with(DirectoryList::SYS_TMP) - ->willReturn($this->directoryMock); - $this->reportWriterMock - ->expects($this->once()) - ->method('write') - ->with($this->directoryMock, $tmpFilesDirectoryPath); - $this->directoryMock - ->expects($this->exactly(3)) - ->method('delete') - ->withConsecutive( - [$tmpFilesDirectoryPath], - [$tmpFilesDirectoryPath], - [$archivePath] - ); - $this->directoryMock - ->expects($this->exactly(2)) - ->method('getAbsolutePath') - ->with($tmpFilesDirectoryPath); - $this->directoryMock - ->expects($this->once()) - ->method('isExist') - ->with($tmpFilesDirectoryPath) - ->willReturn(false); - - $this->assertNull($this->exportDataHandler->prepareExportData()); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/FileInfoManagerTest.php b/app/code/Magento/Analytics/Test/Unit/Model/FileInfoManagerTest.php deleted file mode 100644 index c8c07ae8240c3..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/FileInfoManagerTest.php +++ /dev/null @@ -1,194 +0,0 @@ -flagManagerMock = $this->getMockBuilder(FlagManager::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->fileInfoFactoryMock = $this->getMockBuilder(FileInfoFactory::class) - ->setMethods(['create']) - ->disableOriginalConstructor() - ->getMock(); - - $this->fileInfoMock = $this->getMockBuilder(FileInfo::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->objectManagerHelper = new ObjectManagerHelper($this); - - $this->fileInfoManager = $this->objectManagerHelper->getObject( - FileInfoManager::class, - [ - 'flagManager' => $this->flagManagerMock, - 'fileInfoFactory' => $this->fileInfoFactoryMock, - 'flagCode' => $this->flagCode, - 'encodedParameters' => $this->encodedParameters, - ] - ); - } - - /** - * @return void - */ - public function testSave() - { - $path = 'path/to/file'; - $initializationVector = openssl_random_pseudo_bytes(16); - $parameters = [ - 'path' => $path, - 'initializationVector' => $initializationVector, - ]; - - $this->fileInfoMock - ->expects($this->once()) - ->method('getPath') - ->with() - ->willReturn($path); - $this->fileInfoMock - ->expects($this->once()) - ->method('getInitializationVector') - ->with() - ->willReturn($initializationVector); - - foreach ($this->encodedParameters as $encodedParameter) { - $parameters[$encodedParameter] = base64_encode($parameters[$encodedParameter]); - } - $this->flagManagerMock - ->expects($this->once()) - ->method('saveFlag') - ->with($this->flagCode, $parameters); - - $this->assertTrue($this->fileInfoManager->save($this->fileInfoMock)); - } - - /** - * @param string|null $path - * @param string|null $initializationVector - * @dataProvider saveWithLocalizedExceptionDataProvider - * @expectedException \Magento\Framework\Exception\LocalizedException - */ - public function testSaveWithLocalizedException($path, $initializationVector) - { - $this->fileInfoMock - ->expects($this->once()) - ->method('getPath') - ->with() - ->willReturn($path); - $this->fileInfoMock - ->expects($this->once()) - ->method('getInitializationVector') - ->with() - ->willReturn($initializationVector); - - $this->fileInfoManager->save($this->fileInfoMock); - } - - /** - * @return array - */ - public function saveWithLocalizedExceptionDataProvider() - { - return [ - 'Empty FileInfo' => [null, null], - 'FileInfo without IV' => ['path/to/file', null], - ]; - } - - /** - * @dataProvider loadDataProvider - * @param array|null $parameters - */ - public function testLoad($parameters) - { - $this->flagManagerMock - ->expects($this->once()) - ->method('getFlagData') - ->with($this->flagCode) - ->willReturn($parameters); - - $processedParameters = $parameters ?: []; - $encodedParameters = array_intersect($this->encodedParameters, array_keys($processedParameters)); - foreach ($encodedParameters as $encodedParameter) { - $processedParameters[$encodedParameter] = base64_decode($processedParameters[$encodedParameter]); - } - - $this->fileInfoFactoryMock - ->expects($this->once()) - ->method('create') - ->with($processedParameters) - ->willReturn($this->fileInfoMock); - - $this->assertSame($this->fileInfoMock, $this->fileInfoManager->load()); - } - - /** - * @return array - */ - public function loadDataProvider() - { - return [ - 'Empty flag data' => [null], - 'Correct flag data' => [[ - 'path' => 'path/to/file', - 'initializationVector' => 'xUJjl54MVke+FvMFSBpRSA==', - ]], - ]; - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/FileInfoTest.php b/app/code/Magento/Analytics/Test/Unit/Model/FileInfoTest.php deleted file mode 100644 index 73f6ed644721a..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/FileInfoTest.php +++ /dev/null @@ -1,62 +0,0 @@ -objectManagerHelper = new ObjectManagerHelper($this); - } - - /** - * @param string|null $path - * @param string|null $initializationVector - * @return void - * @dataProvider constructDataProvider - */ - public function testConstruct($path, $initializationVector) - { - $constructorArguments = [ - 'path' => $path, - 'initializationVector' => $initializationVector, - ]; - /** @var FileInfo $fileInfo */ - $fileInfo = $this->objectManagerHelper->getObject( - FileInfo::class, - array_filter($constructorArguments) - ); - - $this->assertSame($path ?: '', $fileInfo->getPath()); - $this->assertSame($initializationVector ?: '', $fileInfo->getInitializationVector()); - } - - /** - * @return array - */ - public function constructDataProvider() - { - return [ - 'Degenerate object' => [null, null], - 'Without Initialization Vector' => ['content text', null], - 'With Initialization Vector' => ['content text', 'c51sd3c4sd68c5sd'], - ]; - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/FileRecorderTest.php b/app/code/Magento/Analytics/Test/Unit/Model/FileRecorderTest.php deleted file mode 100644 index 68ff00a433fd2..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/FileRecorderTest.php +++ /dev/null @@ -1,209 +0,0 @@ -fileInfoManagerMock = $this->getMockBuilder(FileInfoManager::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->fileInfoFactoryMock = $this->getMockBuilder(FileInfoFactory::class) - ->setMethods(['create']) - ->disableOriginalConstructor() - ->getMock(); - - $this->filesystemMock = $this->getMockBuilder(Filesystem::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->fileInfoMock = $this->getMockBuilder(FileInfo::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->directoryMock = $this->getMockBuilder(WriteInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->encodedContextMock = $this->getMockBuilder(EncodedContext::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->objectManagerHelper = new ObjectManagerHelper($this); - - $this->fileRecorder = $this->objectManagerHelper->getObject( - FileRecorder::class, - [ - 'fileInfoManager' => $this->fileInfoManagerMock, - 'fileInfoFactory' => $this->fileInfoFactoryMock, - 'filesystem' => $this->filesystemMock, - 'fileSubdirectoryPath' => $this->fileSubdirectoryPath, - 'encodedFileName' => $this->encodedFileName, - ] - ); - } - - /** - * @param string $pathToExistingFile - * @dataProvider recordNewFileDataProvider - */ - public function testRecordNewFile($pathToExistingFile) - { - $content = openssl_random_pseudo_bytes(200); - - $this->filesystemMock - ->expects($this->once()) - ->method('getDirectoryWrite') - ->with(DirectoryList::MEDIA) - ->willReturn($this->directoryMock); - - $this->encodedContextMock - ->expects($this->once()) - ->method('getContent') - ->with() - ->willReturn($content); - - $hashLength = 64; - $fileRelativePathPattern = '#' . preg_quote($this->fileSubdirectoryPath, '#') - . '.{' . $hashLength . '}/' . preg_quote($this->encodedFileName, '#') . '#'; - $this->directoryMock - ->expects($this->once()) - ->method('writeFile') - ->with($this->matchesRegularExpression($fileRelativePathPattern), $content) - ->willReturn($this->directoryMock); - - $this->fileInfoManagerMock - ->expects($this->once()) - ->method('load') - ->with() - ->willReturn($this->fileInfoMock); - - $this->encodedContextMock - ->expects($this->once()) - ->method('getInitializationVector') - ->with() - ->willReturn('init_vector***'); - - /** register file */ - $this->fileInfoFactoryMock - ->expects($this->once()) - ->method('create') - ->with($this->callback( - function ($parameters) { - return !empty($parameters['path']) && ('init_vector***' === $parameters['initializationVector']); - } - )) - ->willReturn($this->fileInfoMock); - $this->fileInfoManagerMock - ->expects($this->once()) - ->method('save') - ->with($this->fileInfoMock); - - /** remove old file */ - $this->fileInfoMock - ->expects($this->exactly($pathToExistingFile ? 3 : 1)) - ->method('getPath') - ->with() - ->willReturn($pathToExistingFile); - $directoryName = dirname($pathToExistingFile); - if ($directoryName === '.') { - $this->directoryMock - ->expects($this->once()) - ->method('delete') - ->with($pathToExistingFile); - } elseif ($directoryName) { - $this->directoryMock - ->expects($this->exactly(2)) - ->method('delete') - ->withConsecutive( - [$pathToExistingFile], - [$directoryName] - ); - } - - $this->assertTrue($this->fileRecorder->recordNewFile($this->encodedContextMock)); - } - - /** - * @return array - */ - public function recordNewFileDataProvider() - { - return [ - 'File doesn\'t exist' => [''], - 'Existing file into subdirectory' => ['dir_name/file.txt'], - 'Existing file doesn\'t into subdirectory' => ['file.txt'], - ]; - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/IntegrationManagerTest.php b/app/code/Magento/Analytics/Test/Unit/Model/IntegrationManagerTest.php deleted file mode 100644 index 31d5c77ce50b0..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/IntegrationManagerTest.php +++ /dev/null @@ -1,228 +0,0 @@ -integrationServiceMock = $this->getMockBuilder(IntegrationServiceInterface::class) - ->getMock(); - $this->configMock = $this->getMockBuilder(Config::class) - ->disableOriginalConstructor() - ->getMock(); - $this->oauthServiceMock = $this->getMockBuilder(OauthServiceInterface::class) - ->getMock(); - $this->integrationMock = $this->getMockBuilder(Integration::class) - ->disableOriginalConstructor() - ->setMethods([ - 'getId', - 'getConsumerId' - ]) - ->getMock(); - $this->integrationManager = $objectManagerHelper->getObject( - IntegrationManager::class, - [ - 'integrationService' => $this->integrationServiceMock, - 'oauthService' => $this->oauthServiceMock, - 'config' => $this->configMock - ] - ); - } - - /** - * @param string $status - * - * @return array - */ - private function getIntegrationUserData($status) - { - return [ - 'name' => 'ma-integration-user', - 'status' => $status, - 'all_resources' => false, - 'resource' => [ - 'Magento_Analytics::analytics', - 'Magento_Analytics::analytics_api' - ], - ]; - } - - /** - * @return void - */ - public function testActivateIntegrationSuccess() - { - $this->integrationServiceMock->expects($this->once()) - ->method('findByName') - ->with('ma-integration-user') - ->willReturn($this->integrationMock); - $this->integrationMock->expects($this->exactly(2)) - ->method('getId') - ->willReturn(100500); - $integrationData = $this->getIntegrationUserData(Integration::STATUS_ACTIVE); - $integrationData['integration_id'] = 100500; - $this->configMock->expects($this->exactly(2)) - ->method('getConfigDataValue') - ->with('analytics/integration_name', null, null) - ->willReturn('ma-integration-user'); - $this->integrationServiceMock->expects($this->once()) - ->method('update') - ->with($integrationData); - $this->assertTrue($this->integrationManager->activateIntegration()); - } - - /** - * @expectedException \Magento\Framework\Exception\NoSuchEntityException - */ - public function testActivateIntegrationFailureNoSuchEntity() - { - $this->integrationServiceMock->expects($this->once()) - ->method('findByName') - ->with('ma-integration-user') - ->willReturn($this->integrationMock); - $this->integrationMock->expects($this->once()) - ->method('getId') - ->willReturn(null); - $this->configMock->expects($this->once()) - ->method('getConfigDataValue') - ->with('analytics/integration_name', null, null) - ->willReturn('ma-integration-user'); - $this->integrationServiceMock->expects($this->never()) - ->method('update'); - $this->integrationManager->activateIntegration(); - } - - /** - * @dataProvider integrationIdDataProvider - * - * @param int|null $integrationId If null integration is absent. - * @return void - */ - public function testGetTokenNewIntegration($integrationId) - { - $this->configMock->expects($this->atLeastOnce()) - ->method('getConfigDataValue') - ->with('analytics/integration_name', null, null) - ->willReturn('ma-integration-user'); - $this->integrationServiceMock->expects($this->once()) - ->method('findByName') - ->with('ma-integration-user') - ->willReturn($this->integrationMock); - $this->integrationMock->expects($this->once()) - ->method('getConsumerId') - ->willReturn(100500); - $this->integrationMock->expects($this->once()) - ->method('getId') - ->willReturn($integrationId); - if (!$integrationId) { - $this->integrationServiceMock - ->expects($this->once()) - ->method('create') - ->with($this->getIntegrationUserData(Integration::STATUS_INACTIVE)) - ->willReturn($this->integrationMock); - } - $this->oauthServiceMock->expects($this->at(0)) - ->method('getAccessToken') - ->with(100500) - ->willReturn(false); - $this->oauthServiceMock->expects($this->at(2)) - ->method('getAccessToken') - ->with(100500) - ->willReturn('IntegrationToken'); - $this->oauthServiceMock->expects($this->once()) - ->method('createAccessToken') - ->with(100500, true) - ->willReturn(true); - $this->assertEquals('IntegrationToken', $this->integrationManager->generateToken()); - } - - /** - * @dataProvider integrationIdDataProvider - * - * @param int|null $integrationId If null integration is absent. - * @return void - */ - public function testGetTokenExistingIntegration($integrationId) - { - $this->configMock->expects($this->atLeastOnce()) - ->method('getConfigDataValue') - ->with('analytics/integration_name', null, null) - ->willReturn('ma-integration-user'); - $this->integrationServiceMock->expects($this->once()) - ->method('findByName') - ->with('ma-integration-user') - ->willReturn($this->integrationMock); - $this->integrationMock->expects($this->once()) - ->method('getConsumerId') - ->willReturn(100500); - $this->integrationMock->expects($this->once()) - ->method('getId') - ->willReturn($integrationId); - if (!$integrationId) { - $this->integrationServiceMock - ->expects($this->once()) - ->method('create') - ->with($this->getIntegrationUserData(Integration::STATUS_INACTIVE)) - ->willReturn($this->integrationMock); - } - $this->oauthServiceMock->expects($this->once()) - ->method('getAccessToken') - ->with(100500) - ->willReturn('IntegrationToken'); - $this->oauthServiceMock->expects($this->never()) - ->method('createAccessToken'); - $this->assertEquals('IntegrationToken', $this->integrationManager->generateToken()); - } - - /** - * @return array - */ - public function integrationIdDataProvider() - { - return [ - [1], - [null], - ]; - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/LinkProviderTest.php b/app/code/Magento/Analytics/Test/Unit/Model/LinkProviderTest.php deleted file mode 100644 index afda37962a3cb..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/LinkProviderTest.php +++ /dev/null @@ -1,166 +0,0 @@ -linkInterfaceFactoryMock = $this->getMockBuilder(LinkInterfaceFactory::class) - ->disableOriginalConstructor() - ->setMethods(['create']) - ->getMock(); - $this->fileInfoManagerMock = $this->getMockBuilder(FileInfoManager::class) - ->disableOriginalConstructor() - ->getMock(); - $this->storeManagerInterfaceMock = $this->getMockBuilder(StoreManagerInterface::class) - ->getMockForAbstractClass(); - $this->linkInterfaceMock = $this->getMockBuilder(LinkInterface::class) - ->getMockForAbstractClass(); - $this->fileInfoMock = $this->getMockBuilder(FileInfo::class) - ->disableOriginalConstructor() - ->getMock(); - $this->storeMock = $this->getMockBuilder(Store::class) - ->disableOriginalConstructor() - ->getMock(); - $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->linkProvider = $this->objectManagerHelper->getObject( - LinkProvider::class, - [ - 'linkFactory' => $this->linkInterfaceFactoryMock, - 'fileInfoManager' => $this->fileInfoManagerMock, - 'storeManager' => $this->storeManagerInterfaceMock - ] - ); - } - - public function testGet() - { - $baseUrl = 'http://magento.local/pub/media/'; - $fileInfoPath = 'analytics/data.tgz'; - $fileInitializationVector = 'er312esq23eqq'; - $this->fileInfoManagerMock->expects($this->once()) - ->method('load') - ->willReturn($this->fileInfoMock); - $this->linkInterfaceFactoryMock->expects($this->once()) - ->method('create') - ->with( - [ - 'initializationVector' => base64_encode($fileInitializationVector), - 'url' => $baseUrl . $fileInfoPath - ] - ) - ->willReturn($this->linkInterfaceMock); - $this->storeManagerInterfaceMock->expects($this->once()) - ->method('getStore')->willReturn($this->storeMock); - $this->storeMock->expects($this->once()) - ->method('getBaseUrl') - ->with( - UrlInterface::URL_TYPE_MEDIA - ) - ->willReturn($baseUrl); - $this->fileInfoMock->expects($this->atLeastOnce()) - ->method('getPath') - ->willReturn($fileInfoPath); - $this->fileInfoMock->expects($this->atLeastOnce()) - ->method('getInitializationVector') - ->willReturn($fileInitializationVector); - $this->assertEquals($this->linkInterfaceMock, $this->linkProvider->get()); - } - - /** - * @param string|null $fileInfoPath - * @param string|null $fileInitializationVector - * - * @dataProvider fileNotReadyDataProvider - * @expectedException \Magento\Framework\Exception\NoSuchEntityException - * @expectedExceptionMessage File is not ready yet. - */ - public function testFileNotReady($fileInfoPath, $fileInitializationVector) - { - $this->fileInfoManagerMock->expects($this->once()) - ->method('load') - ->willReturn($this->fileInfoMock); - $this->fileInfoMock->expects($this->once()) - ->method('getPath') - ->willReturn($fileInfoPath); - $this->fileInfoMock->expects($this->any()) - ->method('getInitializationVector') - ->willReturn($fileInitializationVector); - $this->linkProvider->get(); - } - - /** - * @return array - */ - public function fileNotReadyDataProvider() - { - return [ - [null, 'initVector'], - ['path', null], - ['', 'initVector'], - ['path', ''], - ['', ''], - [null, null] - ]; - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/NotificationTimeTest.php b/app/code/Magento/Analytics/Test/Unit/Model/NotificationTimeTest.php deleted file mode 100644 index 03fe7d968a7f5..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/NotificationTimeTest.php +++ /dev/null @@ -1,76 +0,0 @@ -flagManagerMock = $this->getMockBuilder(FlagManager::class) - ->disableOriginalConstructor() - ->getMock(); - - $objectManagerHelper = new ObjectManagerHelper($this); - $this->notificationTime = $objectManagerHelper->getObject( - NotificationTime::class, - [ - 'flagManager' => $this->flagManagerMock, - ] - ); - } - - public function testStoreLastTimeNotification() - { - $value = 100500; - - $this->flagManagerMock - ->expects($this->once()) - ->method('saveFlag') - ->with(NotificationTime::NOTIFICATION_TIME, $value) - ->willReturn(true); - $this->assertTrue($this->notificationTime->storeLastTimeNotification($value)); - } - - public function testGetLastTimeNotification() - { - $value = 100500; - - $this->flagManagerMock - ->expects($this->once()) - ->method('getFlagData') - ->with(NotificationTime::NOTIFICATION_TIME) - ->willReturn(true); - $this->assertEquals($value, $this->notificationTime->getLastTimeNotification()); - } - - public function testUnsetLastTimeNotificationValue() - { - $this->flagManagerMock - ->expects($this->once()) - ->method('deleteFlag') - ->with(NotificationTime::NOTIFICATION_TIME) - ->willReturn(true); - $this->assertTrue($this->notificationTime->unsetLastTimeNotificationValue()); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/Plugin/BaseUrlConfigPluginTest.php b/app/code/Magento/Analytics/Test/Unit/Model/Plugin/BaseUrlConfigPluginTest.php deleted file mode 100644 index 38d073a4b4550..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/Plugin/BaseUrlConfigPluginTest.php +++ /dev/null @@ -1,147 +0,0 @@ -subscriptionUpdateHandlerMock = $this->getMockBuilder(SubscriptionUpdateHandler::class) - ->disableOriginalConstructor() - ->getMock(); - $this->configValueMock = $this->getMockBuilder(Value::class) - ->disableOriginalConstructor() - ->setMethods(['isValueChanged', 'getPath', 'getScope', 'getOldValue']) - ->getMock(); - $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->plugin = $this->objectManagerHelper->getObject( - BaseUrlConfigPlugin::class, - [ - 'subscriptionUpdateHandler' => $this->subscriptionUpdateHandlerMock, - ] - ); - } - - /** - * @param array $configValueData - * @return void - * @dataProvider afterSavePluginIsNotApplicableDataProvider - */ - public function testAfterSavePluginIsNotApplicable( - array $configValueData - ) { - $this->configValueMock - ->method('isValueChanged') - ->willReturn($configValueData['isValueChanged']); - $this->configValueMock - ->method('getPath') - ->willReturn($configValueData['path']); - $this->configValueMock - ->method('getScope') - ->willReturn($configValueData['scope']); - $this->subscriptionUpdateHandlerMock - ->expects($this->never()) - ->method('processUrlUpdate'); - - $this->assertEquals( - $this->configValueMock, - $this->plugin->afterAfterSave($this->configValueMock, $this->configValueMock) - ); - } - - /** - * @return array - */ - public function afterSavePluginIsNotApplicableDataProvider() - { - return [ - 'Value has not been changed' => [ - 'Config Value Data' => [ - 'isValueChanged' => false, - 'path' => Store::XML_PATH_SECURE_BASE_URL, - 'scope' => ScopeConfigInterface::SCOPE_TYPE_DEFAULT - ], - ], - 'Unsecure URL has been changed' => [ - 'Config Value Data' => [ - 'isValueChanged' => true, - 'path' => Store::XML_PATH_UNSECURE_BASE_URL, - 'scope' => ScopeConfigInterface::SCOPE_TYPE_DEFAULT - ], - ], - 'Secure URL has been changed not in the Default scope' => [ - 'Config Value Data' => [ - 'isValueChanged' => true, - 'path' => Store::XML_PATH_SECURE_BASE_URL, - 'scope' => ScopeInterface::SCOPE_STORES - ], - ], - ]; - } - - /** - * @return void - */ - public function testAfterSavePluginIsApplicable() - { - $this->configValueMock - ->method('isValueChanged') - ->willReturn(true); - $this->configValueMock - ->method('getPath') - ->willReturn(Store::XML_PATH_SECURE_BASE_URL); - $this->configValueMock - ->method('getScope') - ->willReturn(ScopeConfigInterface::SCOPE_TYPE_DEFAULT); - $this->configValueMock - ->method('getOldValue') - ->willReturn('http://store.com'); - $this->subscriptionUpdateHandlerMock - ->expects($this->once()) - ->method('processUrlUpdate') - ->with('http://store.com'); - - $this->assertEquals( - $this->configValueMock, - $this->plugin->afterAfterSave($this->configValueMock, $this->configValueMock) - ); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/ReportUrlProviderTest.php b/app/code/Magento/Analytics/Test/Unit/Model/ReportUrlProviderTest.php deleted file mode 100644 index ee507d88c68db..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/ReportUrlProviderTest.php +++ /dev/null @@ -1,153 +0,0 @@ -configMock = $this->getMockBuilder(ScopeConfigInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->analyticsTokenMock = $this->getMockBuilder(AnalyticsToken::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->otpRequestMock = $this->getMockBuilder(OTPRequest::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->flagManagerMock = $this->getMockBuilder(FlagManager::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->objectManagerHelper = new ObjectManagerHelper($this); - - $this->reportUrlProvider = $this->objectManagerHelper->getObject( - ReportUrlProvider::class, - [ - 'config' => $this->configMock, - 'analyticsToken' => $this->analyticsTokenMock, - 'otpRequest' => $this->otpRequestMock, - 'flagManager' => $this->flagManagerMock, - 'urlReportConfigPath' => $this->urlReportConfigPath, - ] - ); - } - - /** - * @param bool $isTokenExist - * @param string|null $otp If null OTP was not received. - * - * @dataProvider getUrlDataProvider - */ - public function testGetUrl($isTokenExist, $otp) - { - $reportUrl = 'https://example.com/report'; - $url = ''; - - $this->configMock - ->expects($this->once()) - ->method('getValue') - ->with($this->urlReportConfigPath) - ->willReturn($reportUrl); - $this->analyticsTokenMock - ->expects($this->once()) - ->method('isTokenExist') - ->with() - ->willReturn($isTokenExist); - $this->otpRequestMock - ->expects($isTokenExist ? $this->once() : $this->never()) - ->method('call') - ->with() - ->willReturn($otp); - if ($isTokenExist && $otp) { - $url = $reportUrl . '?' . http_build_query(['otp' => $otp], '', '&'); - } - $this->assertSame($url ?: $reportUrl, $this->reportUrlProvider->getUrl()); - } - - /** - * @return array - */ - public function getUrlDataProvider() - { - return [ - 'TokenDoesNotExist' => [false, null], - 'TokenExistAndOtpEmpty' => [true, null], - 'TokenExistAndOtpValid' => [true, '249e6b658877bde2a77bc4ab'], - ]; - } - - /** - * @return void - */ - public function testGetUrlWhenSubscriptionUpdateRunning() - { - $this->flagManagerMock - ->expects($this->once()) - ->method('getFlagData') - ->with(SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE) - ->willReturn('http://store.com'); - $this->setExpectedException( - SubscriptionUpdateException::class, - 'Your Base URL has been changed and your reports are being updated. ' - . 'Advanced Reporting will be available once this change has been processed. Please try again later.' - ); - $this->reportUrlProvider->getUrl(); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/ReportWriterTest.php b/app/code/Magento/Analytics/Test/Unit/Model/ReportWriterTest.php deleted file mode 100644 index 96ac1143ec5ec..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/ReportWriterTest.php +++ /dev/null @@ -1,213 +0,0 @@ -configInterfaceMock = $this->getMockBuilder(ConfigInterface::class)->getMockForAbstractClass(); - $this->reportValidatorMock = $this->getMockBuilder(ReportValidator::class) - ->disableOriginalConstructor()->getMock(); - $this->providerFactoryMock = $this->getMockBuilder(ProviderFactory::class) - ->disableOriginalConstructor()->getMock(); - $this->reportProviderMock = $this->getMockBuilder(ReportProvider::class) - ->disableOriginalConstructor()->getMock(); - $this->directoryMock = $this->getMockBuilder(WriteInterface::class)->getMockForAbstractClass(); - $this->objectManagerHelper = new ObjectManagerHelper($this); - - $this->reportWriter = $this->objectManagerHelper->getObject( - ReportWriter::class, - [ - 'config' => $this->configInterfaceMock, - 'reportValidator' => $this->reportValidatorMock, - 'providerFactory' => $this->providerFactoryMock - ] - ); - } - - /** - * @param array $configData - * @return void - * - * @dataProvider configDataProvider - */ - public function testWrite(array $configData) - { - $errors = []; - $fileData = [ - ['number' => 1, 'type' => 'Shoes Usual'] - ]; - $this->configInterfaceMock - ->expects($this->once()) - ->method('get') - ->with() - ->willReturn([$configData]); - $this->providerFactoryMock - ->expects($this->once()) - ->method('create') - ->with($this->providerClass) - ->willReturn($this->reportProviderMock); - $parameterName = isset(reset($configData)[0]['parameters']['name']) - ? reset($configData)[0]['parameters']['name'] - : ''; - $this->reportProviderMock->expects($this->once()) - ->method('getReport') - ->with($parameterName ?: null) - ->willReturn($fileData); - $errorStreamMock = $this->getMockBuilder( - \Magento\Framework\Filesystem\File\WriteInterface::class - )->getMockForAbstractClass(); - $errorStreamMock - ->expects($this->once()) - ->method('lock') - ->with(); - $errorStreamMock - ->expects($this->exactly(2)) - ->method('writeCsv') - ->withConsecutive( - [array_keys($fileData[0])], - [$fileData[0]] - ); - $errorStreamMock->expects($this->once())->method('unlock'); - $errorStreamMock->expects($this->once())->method('close'); - if ($parameterName) { - $this->reportValidatorMock - ->expects($this->once()) - ->method('validate') - ->with($parameterName) - ->willReturn($errors); - } - $this->directoryMock - ->expects($this->once()) - ->method('openFile') - ->with( - $this->stringContains('/var/tmp' . $parameterName ?: $this->reportName), - 'w+' - )->willReturn($errorStreamMock); - $this->assertTrue($this->reportWriter->write($this->directoryMock, '/var/tmp')); - } - - /** - * @param array $configData - * @return void - * - * @dataProvider configDataProvider - */ - public function testWriteErrorFile($configData) - { - $errors = ['orders', 'SQL Error: test']; - $this->configInterfaceMock->expects($this->once())->method('get')->willReturn([$configData]); - $errorStreamMock = $this->getMockBuilder( - \Magento\Framework\Filesystem\File\WriteInterface::class - )->getMockForAbstractClass(); - $errorStreamMock->expects($this->once())->method('lock'); - $errorStreamMock->expects($this->once())->method('writeCsv')->with($errors); - $errorStreamMock->expects($this->once())->method('unlock'); - $errorStreamMock->expects($this->once())->method('close'); - $this->reportValidatorMock->expects($this->once())->method('validate')->willReturn($errors); - $this->directoryMock->expects($this->once())->method('openFile')->with('/var/tmp' . 'errors.csv', 'w+') - ->willReturn($errorStreamMock); - $this->assertTrue($this->reportWriter->write($this->directoryMock, '/var/tmp')); - } - - /** - * @return void - */ - public function testWriteEmptyReports() - { - $this->configInterfaceMock->expects($this->once())->method('get')->willReturn([]); - $this->reportValidatorMock->expects($this->never())->method('validate'); - $this->directoryMock->expects($this->never())->method('openFile'); - $this->assertTrue($this->reportWriter->write($this->directoryMock, '/var/tmp')); - } - - /** - * @return array - */ - public function configDataProvider() - { - return [ - 'reportProvider' => [ - [ - 'providers' => [ - [ - 'name' => $this->providerName, - 'class' => $this->providerClass, - 'parameters' => [ - 'name' => $this->reportName - ], - ] - ] - ] - ], - ]; - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/ReportXml/ModuleIteratorTest.php b/app/code/Magento/Analytics/Test/Unit/Model/ReportXml/ModuleIteratorTest.php deleted file mode 100644 index 654fad74ef309..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/ReportXml/ModuleIteratorTest.php +++ /dev/null @@ -1,50 +0,0 @@ -moduleManagerMock = $this->getMockBuilder(ModuleManager::class) - ->disableOriginalConstructor() - ->getMock(); - $objectManagerHelper = new ObjectManagerHelper($this); - $this->moduleIterator = $objectManagerHelper->getObject( - ModuleIterator::class, - [ - 'moduleManager' => $this->moduleManagerMock, - 'iterator' => new \ArrayIterator([0 => ['module_name' => 'Coco_Module']]) - ] - ); - } - - public function testCurrent() - { - $this->moduleManagerMock->expects($this->once()) - ->method('isEnabled') - ->with('Coco_Module') - ->willReturn(true); - foreach ($this->moduleIterator as $item) { - $this->assertEquals(['module_name' => 'Coco_Module', 'status' => 'Enabled'], $item); - } - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/StoreConfigurationProviderTest.php b/app/code/Magento/Analytics/Test/Unit/Model/StoreConfigurationProviderTest.php deleted file mode 100644 index a2f9be1461c15..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/StoreConfigurationProviderTest.php +++ /dev/null @@ -1,123 +0,0 @@ -scopeConfigMock = $this->getMockBuilder(ScopeConfigInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->storeManagerMock = $this->getMockBuilder(StoreManagerInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->websiteMock = $this->getMockBuilder(WebsiteInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->storeMock = $this->getMockBuilder(StoreInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->configPaths = [ - 'web/unsecure/base_url', - 'currency/options/base', - 'general/locale/timezone' - ]; - - $this->storeConfigurationProvider = new StoreConfigurationProvider( - $this->scopeConfigMock, - $this->storeManagerMock, - $this->configPaths - ); - } - - public function testGetReport() - { - $map = [ - ['web/unsecure/base_url', 'default', 0, '127.0.0.1'], - ['currency/options/base', 'default', 0, 'USD'], - ['general/locale/timezone', 'default', 0, 'America/Dawson'], - ['web/unsecure/base_url', 'websites', 1, '127.0.0.2'], - ['currency/options/base', 'websites', 1, 'USD'], - ['general/locale/timezone', 'websites', 1, 'America/Belem'], - ['web/unsecure/base_url', 'stores', 2, '127.0.0.3'], - ['currency/options/base', 'stores', 2, 'USD'], - ['general/locale/timezone', 'stores', 2, 'America/Phoenix'], - ]; - - $this->scopeConfigMock - ->method('getValue') - ->will($this->returnValueMap($map)); - - $this->storeManagerMock->expects($this->once()) - ->method('getWebsites') - ->willReturn([$this->websiteMock]); - - $this->storeManagerMock->expects($this->once()) - ->method('getStores') - ->willReturn([$this->storeMock]); - - $this->websiteMock->expects($this->once()) - ->method('getId') - ->willReturn(1); - - $this->storeMock->expects($this->once()) - ->method('getId') - ->willReturn(2); - $result = iterator_to_array($this->storeConfigurationProvider->getReport()); - $resultValues = []; - foreach ($result as $item) { - $resultValues[] = array_values($item); - } - array_multisort($resultValues); - array_multisort($map); - $this->assertEquals($resultValues, $map); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/SubscriptionStatusProviderTest.php b/app/code/Magento/Analytics/Test/Unit/Model/SubscriptionStatusProviderTest.php deleted file mode 100644 index 2e52a13f90bbf..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/SubscriptionStatusProviderTest.php +++ /dev/null @@ -1,196 +0,0 @@ -scopeConfigMock = $this->getMockBuilder(ScopeConfigInterface::class) - ->getMockForAbstractClass(); - - $this->analyticsTokenMock = $this->getMockBuilder(AnalyticsToken::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->flagManagerMock = $this->getMockBuilder(FlagManager::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->objectManagerHelper = new ObjectManagerHelper($this); - - $this->statusProvider = $this->objectManagerHelper->getObject( - SubscriptionStatusProvider::class, - [ - 'scopeConfig' => $this->scopeConfigMock, - 'analyticsToken' => $this->analyticsTokenMock, - 'flagManager' => $this->flagManagerMock, - ] - ); - } - - /** - * @param array $flagManagerData - * @dataProvider getStatusShouldBeFailedDataProvider - */ - public function testGetStatusShouldBeFailed(array $flagManagerData) - { - $this->analyticsTokenMock->expects($this->once()) - ->method('isTokenExist') - ->willReturn(false); - $this->scopeConfigMock->expects($this->once()) - ->method('getValue') - ->with('analytics/subscription/enabled') - ->willReturn(true); - - $this->expectFlagManagerReturn($flagManagerData); - $this->assertEquals(SubscriptionStatusProvider::FAILED, $this->statusProvider->getStatus()); - } - - /** - * @return array - */ - public function getStatusShouldBeFailedDataProvider() - { - return [ - 'Subscription update doesn\'t active' => [ - 'Flag Manager data mapping' => [ - [SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE, null], - [SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE, null] - ], - ], - 'Subscription update is active' => [ - 'Flag Manager data mapping' => [ - [SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE, 'http://store.com'], - [SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE, null] - ], - ], - ]; - } - - /** - * @param array $flagManagerData - * @param bool $isTokenExist - * @dataProvider getStatusShouldBePendingDataProvider - */ - public function testGetStatusShouldBePending(array $flagManagerData, bool $isTokenExist) - { - $this->analyticsTokenMock->expects($this->once()) - ->method('isTokenExist') - ->willReturn($isTokenExist); - $this->scopeConfigMock->expects($this->once()) - ->method('getValue') - ->with('analytics/subscription/enabled') - ->willReturn(true); - - $this->expectFlagManagerReturn($flagManagerData); - $this->assertEquals(SubscriptionStatusProvider::PENDING, $this->statusProvider->getStatus()); - } - - /** - * @return array - */ - public function getStatusShouldBePendingDataProvider() - { - return [ - 'Subscription update doesn\'t active and the token does not exist' => [ - 'Flag Manager data mapping' => [ - [SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE, null], - [SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE, 45] - ], - 'isTokenExist' => false, - ], - 'Subscription update is active and the token does not exist' => [ - 'Flag Manager data mapping' => [ - [SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE, 'http://store.com'], - [SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE, 45] - ], - 'isTokenExist' => false, - ], - 'Subscription update is active and token exist' => [ - 'Flag Manager data mapping' => [ - [SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE, 'http://store.com'], - [SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE, null] - ], - 'isTokenExist' => true, - ], - ]; - } - - public function testGetStatusShouldBeEnabled() - { - $this->flagManagerMock - ->method('getFlagData') - ->with(SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE) - ->willReturn(null); - $this->analyticsTokenMock->expects($this->once()) - ->method('isTokenExist') - ->willReturn(true); - $this->scopeConfigMock->expects($this->once()) - ->method('getValue') - ->with('analytics/subscription/enabled') - ->willReturn(true); - $this->assertEquals(SubscriptionStatusProvider::ENABLED, $this->statusProvider->getStatus()); - } - - public function testGetStatusShouldBeDisabled() - { - $this->scopeConfigMock->expects($this->once()) - ->method('getValue') - ->with('analytics/subscription/enabled') - ->willReturn(false); - $this->assertEquals(SubscriptionStatusProvider::DISABLED, $this->statusProvider->getStatus()); - } - - /** - * @param array $mapping - */ - private function expectFlagManagerReturn(array $mapping) - { - $this->flagManagerMock - ->method('getFlagData') - ->willReturnMap($mapping); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Model/System/Message/NotificationAboutFailedSubscriptionTest.php b/app/code/Magento/Analytics/Test/Unit/Model/System/Message/NotificationAboutFailedSubscriptionTest.php deleted file mode 100644 index 536a7dbb5dfe9..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Model/System/Message/NotificationAboutFailedSubscriptionTest.php +++ /dev/null @@ -1,106 +0,0 @@ -subscriptionStatusMock = $this->getMockBuilder(SubscriptionStatusProvider::class) - ->disableOriginalConstructor() - ->getMock(); - $this->urlBuilderMock = $this->getMockBuilder(UrlInterface::class) - ->getMockForAbstractClass(); - $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->notification = $this->objectManagerHelper->getObject( - NotificationAboutFailedSubscription::class, - [ - 'subscriptionStatusProvider' => $this->subscriptionStatusMock, - 'urlBuilder' => $this->urlBuilderMock - ] - ); - } - - public function testIsDisplayedWhenMessageShouldBeDisplayed() - { - $this->subscriptionStatusMock->expects($this->once()) - ->method('getStatus') - ->willReturn( - SubscriptionStatusProvider::FAILED - ); - $this->assertTrue($this->notification->isDisplayed()); - } - - /** - * @dataProvider notDisplayedNotificationStatuses - * - * @param $status - */ - public function testIsDisplayedWhenMessageShouldNotBeDisplayed($status) - { - $this->subscriptionStatusMock->expects($this->once()) - ->method('getStatus') - ->willReturn($status); - $this->assertFalse($this->notification->isDisplayed()); - } - - public function testGetTextShouldBuildMessage() - { - $retryUrl = 'http://magento.dev/retryUrl'; - $this->urlBuilderMock->expects($this->once()) - ->method('getUrl') - ->with('analytics/subscription/retry') - ->willReturn($retryUrl); - $messageDetails = 'Failed to synchronize data to the Magento Business Intelligence service. '; - $messageDetails .= sprintf('Retry Synchronization', $retryUrl); - $this->assertEquals($messageDetails, $this->notification->getText()); - } - - /** - * Provide statuses according to which message should not be displayed. - * - * @return array - */ - public function notDisplayedNotificationStatuses() - { - return [ - [SubscriptionStatusProvider::PENDING], - [SubscriptionStatusProvider::DISABLED], - [SubscriptionStatusProvider::ENABLED], - ]; - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/Config/Converter/XmlTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/Config/Converter/XmlTest.php deleted file mode 100644 index 325d3d4a85c7e..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/ReportXml/Config/Converter/XmlTest.php +++ /dev/null @@ -1,121 +0,0 @@ -objectManagerHelper = - new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - - $this->subject = $this->objectManagerHelper->getObject( - \Magento\Analytics\ReportXml\Config\Converter\Xml::class - ); - } - - /** - * @return void - */ - public function testConvertNoElements() - { - $this->assertEmpty( - $this->subject->convert(new \DOMDocument()) - ); - } - - /** - * @return void - */ - public function testConvert() - { - $dom = new \DOMDocument(); - - $expectedArray = [ - 'config' => [ - [ - 'noNamespaceSchemaLocation' => 'urn:magento:module:Magento_Analytics:etc/reports.xsd', - 'report' => [ - [ - 'name' => 'test_report_1', - 'connection' => 'sales', - 'source' => [ - [ - 'name' => 'sales_order', - 'alias' => 'orders', - 'attribute' => [ - [ - 'name' => 'entity_id', - 'alias' => 'identifier', - ] - ], - 'filter' => [ - [ - 'glue' => 'and', - 'condition' => [ - [ - 'attribute' => 'entity_id', - 'operator' => 'gt', - '_value' => '10' - ] - ] - ] - ] - ] - ] - ], - [ - 'name' => 'test_report_2', - 'connection' => 'default', - 'source' => [ - [ - 'name' => 'customer_entity', - 'alias' => 'customers', - 'attribute' => [ - [ - 'name' => 'email' - ] - ], - 'filter' => [ - [ - 'glue' => 'and', - 'condition' => [ - [ - 'attribute' => 'dob', - 'operator' => 'null' - ] - ] - ] - ] - ] - ] - ] - ] - ] - ] - ]; - - $dom->loadXML(file_get_contents(__DIR__ . '/../_files/valid_reports.xml')); - - $this->assertEquals($expectedArray, $this->subject->convert($dom)); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/Config/MapperTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/Config/MapperTest.php deleted file mode 100644 index f69b40118b935..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/ReportXml/Config/MapperTest.php +++ /dev/null @@ -1,47 +0,0 @@ -mapper = new Mapper(); - } - - public function testExecute() - { - $configData['config'][0]['report'] = [ - [ - 'source' => ['product'], - 'name' => 'Product', - ] - ]; - $expectedResult = [ - 'Product' => [ - 'source' => 'product', - 'name' => 'Product', - ] - ]; - $this->assertEquals($this->mapper->execute($configData), $expectedResult); - } - - public function testExecuteWithoutReports() - { - $configData = []; - $this->assertEquals($this->mapper->execute($configData), []); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/Config/_files/valid_reports.xml b/app/code/Magento/Analytics/Test/Unit/ReportXml/Config/_files/valid_reports.xml deleted file mode 100644 index e04ee96163797..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/ReportXml/Config/_files/valid_reports.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - 10 - - - - - - - - - - - - diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/ConfigTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/ConfigTest.php deleted file mode 100644 index 1b89a0d3ad671..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/ReportXml/ConfigTest.php +++ /dev/null @@ -1,64 +0,0 @@ -dataMock = $this->getMockBuilder(DataInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->objectManagerHelper = new ObjectManagerHelper($this); - - $this->config = $this->objectManagerHelper->getObject( - Config::class, - [ - 'data' => $this->dataMock, - ] - ); - } - - public function testGet() - { - $queryName = 'query string'; - $queryResult = [ 'query' => 1 ]; - - $this->dataMock - ->expects($this->once()) - ->method('get') - ->with($queryName) - ->willReturn($queryResult); - - $this->assertSame($queryResult, $this->config->get($queryName)); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/ConnectionFactoryTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/ConnectionFactoryTest.php deleted file mode 100644 index 330f7f1a6707a..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/ReportXml/ConnectionFactoryTest.php +++ /dev/null @@ -1,106 +0,0 @@ -resourceConnectionMock = $this->getMockBuilder(ResourceConnection::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->connectionMock = $this->getMockBuilder(MysqlPdoAdapter::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->connectionNewMock = $this->getMockBuilder(MysqlPdoAdapter::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->objectManagerHelper = new ObjectManagerHelper($this); - - $this->connectionFactory = $this->objectManagerHelper->getObject( - ConnectionFactory::class, - [ - 'resourceConnection' => $this->resourceConnectionMock, - 'objectManager' => $this->objectManagerMock, - ] - ); - } - - public function testGetConnection() - { - $connectionName = 'read'; - - $this->resourceConnectionMock - ->expects($this->once()) - ->method('getConnection') - ->with($connectionName) - ->willReturn($this->connectionMock); - - $this->connectionMock - ->expects($this->once()) - ->method('getConfig') - ->with() - ->willReturn(['persistent' => 1]); - - $this->objectManagerMock - ->expects($this->once()) - ->method('create') - ->with(get_class($this->connectionMock), ['config' => ['use_buffered_query' => false]]) - ->willReturn($this->connectionNewMock); - - $this->assertSame($this->connectionNewMock, $this->connectionFactory->getConnection($connectionName)); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/FilterAssemblerTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/FilterAssemblerTest.php deleted file mode 100644 index 6ebfd1ffa2da6..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/FilterAssemblerTest.php +++ /dev/null @@ -1,143 +0,0 @@ -nameResolverMock = $this->getMockBuilder( - \Magento\Analytics\ReportXml\DB\NameResolver::class - ) - ->disableOriginalConstructor() - ->getMock(); - - $this->selectBuilderMock = $this->getMockBuilder( - \Magento\Analytics\ReportXml\DB\SelectBuilder::class - ) - ->disableOriginalConstructor() - ->getMock(); - $this->selectBuilderMock->expects($this->any()) - ->method('getFilters') - ->willReturn([]); - - $this->conditionResolverMock = $this->getMockBuilder( - \Magento\Analytics\ReportXml\DB\ConditionResolver::class - ) - ->disableOriginalConstructor() - ->getMock(); - - $this->objectManagerHelper = - new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - - $this->subject = $this->objectManagerHelper->getObject( - \Magento\Analytics\ReportXml\DB\Assembler\FilterAssembler::class, - [ - 'conditionResolver' => $this->conditionResolverMock, - 'nameResolver' => $this->nameResolverMock - ] - ); - } - - /** - * @return void - */ - public function testAssembleEmpty() - { - $queryConfigMock = [ - 'source' => [ - 'name' => 'sales_order', - 'alias' => 'sales' - ] - ]; - - $this->selectBuilderMock->expects($this->never()) - ->method('setFilters'); - - $this->assertEquals( - $this->selectBuilderMock, - $this->subject->assemble($this->selectBuilderMock, $queryConfigMock) - ); - } - - /** - * @return void - */ - public function testAssembleNotEmpty() - { - $queryConfigMock = [ - 'source' => [ - 'name' => 'sales_order', - 'alias' => 'sales', - 'filter' => [ - [ - 'glue' => 'and', - 'condition' => [ - [ - 'attribute' => 'entity_id', - 'operator' => 'null' - ] - ] - ] - ] - ] - ]; - - $this->nameResolverMock->expects($this->any()) - ->method('getAlias') - ->with($queryConfigMock['source']) - ->willReturn($queryConfigMock['source']['alias']); - - $this->conditionResolverMock->expects($this->once()) - ->method('getFilter') - ->with( - $this->selectBuilderMock, - $queryConfigMock['source']['filter'], - $queryConfigMock['source']['alias'] - ) - ->willReturn('(sales.entity_id IS NULL)'); - - $this->selectBuilderMock->expects($this->once()) - ->method('setFilters') - ->with(['(sales.entity_id IS NULL)']); - - $this->assertEquals( - $this->selectBuilderMock, - $this->subject->assemble($this->selectBuilderMock, $queryConfigMock) - ); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/FromAssemblerTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/FromAssemblerTest.php deleted file mode 100644 index cbabac5613a8b..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/FromAssemblerTest.php +++ /dev/null @@ -1,167 +0,0 @@ -nameResolverMock = $this->getMockBuilder( - \Magento\Analytics\ReportXml\DB\NameResolver::class - ) - ->disableOriginalConstructor() - ->getMock(); - - $this->selectBuilderMock = $this->getMockBuilder( - \Magento\Analytics\ReportXml\DB\SelectBuilder::class - ) - ->disableOriginalConstructor() - ->getMock(); - $this->selectBuilderMock->expects($this->any()) - ->method('getColumns') - ->willReturn([]); - - $this->columnsResolverMock = $this->getMockBuilder( - \Magento\Analytics\ReportXml\DB\ColumnsResolver::class - ) - ->disableOriginalConstructor() - ->getMock(); - - $this->resourceConnection = $this->getMockBuilder(ResourceConnection::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->objectManagerHelper = - new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - - $this->subject = $this->objectManagerHelper->getObject( - \Magento\Analytics\ReportXml\DB\Assembler\FromAssembler::class, - [ - 'nameResolver' => $this->nameResolverMock, - 'columnsResolver' => $this->columnsResolverMock, - 'resourceConnection' => $this->resourceConnection, - ] - ); - } - - /** - * @dataProvider assembleDataProvider - * @param array $queryConfig - * @param string $tableName - * @return void - */ - public function testAssemble(array $queryConfig, $tableName) - { - $this->nameResolverMock->expects($this->any()) - ->method('getAlias') - ->with($queryConfig['source']) - ->willReturn($queryConfig['source']['alias']); - - $this->nameResolverMock->expects($this->once()) - ->method('getName') - ->with($queryConfig['source']) - ->willReturn($queryConfig['source']['name']); - - $this->resourceConnection - ->expects($this->once()) - ->method('getTableName') - ->with($queryConfig['source']['name']) - ->willReturn($tableName); - - $this->selectBuilderMock->expects($this->once()) - ->method('setFrom') - ->with([$queryConfig['source']['alias'] => $tableName]); - - $this->columnsResolverMock->expects($this->once()) - ->method('getColumns') - ->with($this->selectBuilderMock, $queryConfig['source']) - ->willReturn(['entity_id' => 'sales.entity_id']); - - $this->selectBuilderMock->expects($this->once()) - ->method('setColumns') - ->with(['entity_id' => 'sales.entity_id']); - - $this->assertEquals( - $this->selectBuilderMock, - $this->subject->assemble($this->selectBuilderMock, $queryConfig) - ); - } - - /** - * @return array - */ - public function assembleDataProvider() - { - return [ - 'Tables without prefixes' => [ - [ - 'source' => [ - 'name' => 'sales_order', - 'alias' => 'sales', - 'attribute' => [ - [ - 'name' => 'entity_id' - ] - ], - ], - ], - 'sales_order', - ], - 'Tables with prefixes' => [ - [ - 'source' => [ - 'name' => 'sales_order', - 'alias' => 'sales', - 'attribute' => [ - [ - 'name' => 'entity_id' - ] - ], - ], - ], - 'pref_sales_order', - ] - ]; - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/JoinAssemblerTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/JoinAssemblerTest.php deleted file mode 100644 index b913689513ce5..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/Assembler/JoinAssemblerTest.php +++ /dev/null @@ -1,279 +0,0 @@ -nameResolverMock = $this->getMockBuilder( - \Magento\Analytics\ReportXml\DB\NameResolver::class - ) - ->disableOriginalConstructor() - ->getMock(); - - $this->selectBuilderMock = $this->getMockBuilder( - \Magento\Analytics\ReportXml\DB\SelectBuilder::class - ) - ->disableOriginalConstructor() - ->getMock(); - $this->selectBuilderMock->expects($this->any()) - ->method('getFilters') - ->willReturn([]); - $this->selectBuilderMock->expects($this->any()) - ->method('getColumns') - ->willReturn([]); - $this->selectBuilderMock->expects($this->any()) - ->method('getJoins') - ->willReturn([]); - - $this->columnsResolverMock = $this->getMockBuilder( - \Magento\Analytics\ReportXml\DB\ColumnsResolver::class - ) - ->disableOriginalConstructor() - ->getMock(); - - $this->conditionResolverMock = $this->getMockBuilder( - \Magento\Analytics\ReportXml\DB\ConditionResolver::class - ) - ->disableOriginalConstructor() - ->getMock(); - - $this->resourceConnection = $this->getMockBuilder(ResourceConnection::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->objectManagerHelper = - new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - - $this->subject = $this->objectManagerHelper->getObject( - \Magento\Analytics\ReportXml\DB\Assembler\JoinAssembler::class, - [ - 'conditionResolver' => $this->conditionResolverMock, - 'nameResolver' => $this->nameResolverMock, - 'columnsResolver' => $this->columnsResolverMock, - 'resourceConnection' => $this->resourceConnection, - ] - ); - } - - /** - * @return void - */ - public function testAssembleEmpty() - { - $queryConfigMock = [ - 'source' => [ - 'name' => 'sales_order', - 'alias' => 'sales' - ] - ]; - - $this->selectBuilderMock->expects($this->never()) - ->method('setColumns'); - $this->selectBuilderMock->expects($this->never()) - ->method('setFilters'); - $this->selectBuilderMock->expects($this->never()) - ->method('setJoins'); - - $this->assertEquals( - $this->selectBuilderMock, - $this->subject->assemble($this->selectBuilderMock, $queryConfigMock) - ); - } - - /** - * @param array $queryConfigMock - * @param array $joinsMock - * @param array $tablesMapping - * @return void - * @dataProvider assembleNotEmptyDataProvider - */ - public function testAssembleNotEmpty(array $queryConfigMock, array $joinsMock, array $tablesMapping) - { - $filtersMock = []; - - $this->nameResolverMock->expects($this->at(0)) - ->method('getAlias') - ->with($queryConfigMock['source']) - ->willReturn($queryConfigMock['source']['alias']); - $this->nameResolverMock->expects($this->at(1)) - ->method('getAlias') - ->with($queryConfigMock['source']['link-source'][0]) - ->willReturn($queryConfigMock['source']['link-source'][0]['alias']); - $this->nameResolverMock->expects($this->once()) - ->method('getName') - ->with($queryConfigMock['source']['link-source'][0]) - ->willReturn($queryConfigMock['source']['link-source'][0]['name']); - - $this->resourceConnection - ->expects($this->any()) - ->method('getTableName') - ->willReturnOnConsecutiveCalls(...array_values($tablesMapping)); - - $this->conditionResolverMock->expects($this->at(0)) - ->method('getFilter') - ->with( - $this->selectBuilderMock, - $queryConfigMock['source']['link-source'][0]['using'], - $queryConfigMock['source']['link-source'][0]['alias'], - $queryConfigMock['source']['alias'] - ) - ->willReturn('(billing.parent_id = `sales`.`entity_id`)'); - - if (isset($queryConfigMock['source']['link-source'][0]['filter'])) { - $filtersMock = ['(sales.entity_id IS NULL)']; - - $this->conditionResolverMock->expects($this->at(1)) - ->method('getFilter') - ->with( - $this->selectBuilderMock, - $queryConfigMock['source']['link-source'][0]['filter'], - $queryConfigMock['source']['link-source'][0]['alias'], - $queryConfigMock['source']['alias'] - ) - ->willReturn($filtersMock[0]); - - $this->columnsResolverMock->expects($this->once()) - ->method('getColumns') - ->with($this->selectBuilderMock, $queryConfigMock['source']['link-source'][0]) - ->willReturn( - [ - 'entity_id' => 'sales.entity_id', - 'billing_address_id' => 'billing.entity_id' - ] - ); - - $this->selectBuilderMock->expects($this->once()) - ->method('setColumns') - ->with( - [ - 'entity_id' => 'sales.entity_id', - 'billing_address_id' => 'billing.entity_id' - ] - ); - } - - $this->selectBuilderMock->expects($this->once()) - ->method('setFilters') - ->with($filtersMock); - $this->selectBuilderMock->expects($this->once()) - ->method('setJoins') - ->with($joinsMock); - - $this->assertEquals( - $this->selectBuilderMock, - $this->subject->assemble($this->selectBuilderMock, $queryConfigMock) - ); - } - - /** - * @return array - */ - public function assembleNotEmptyDataProvider() - { - return [ - [ - [ - 'source' => [ - 'name' => 'sales_order', - 'alias' => 'sales', - 'link-source' => [ - [ - 'name' => 'sales_order_address', - 'alias' => 'billing', - 'link-type' => 'left', - 'attribute' => [ - [ - 'alias' => 'billing_address_id', - 'name' => 'entity_id' - ] - ], - 'using' => [ - [ - 'glue' => 'and', - 'condition' => [ - [ - 'attribute' => 'parent_id', - 'operator' => 'eq', - 'type' => 'identifier', - '_value' => 'entity_id' - ] - ] - ] - ], - 'filter' => [ - [ - 'glue' => 'and', - 'condition' => [ - [ - 'attribute' => 'entity_id', - 'operator' => 'null' - ] - ] - ] - ] - ] - ] - ] - ], - [ - 'billing' => [ - 'link-type' => 'left', - 'table' => [ - 'billing' => 'pref_sales_order_address' - ], - 'condition' => '(billing.parent_id = `sales`.`entity_id`)' - ] - ], - ['sales_order_address' => 'pref_sales_order_address'] - ] - ]; - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ColumnsResolverTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ColumnsResolverTest.php deleted file mode 100644 index c8ab79625e9c3..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ColumnsResolverTest.php +++ /dev/null @@ -1,150 +0,0 @@ -selectBuilderMock = $this->getMockBuilder(SelectBuilder::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->resourceConnectionMock = $this->getMockBuilder(ResourceConnection::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->connectionMock = $this->getMockBuilder(AdapterInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $objectManager = new ObjectManagerHelper($this); - $this->columnsResolver = $objectManager->getObject( - ColumnsResolver::class, - [ - 'nameResolver' => new NameResolver(), - 'resourceConnection' => $this->resourceConnectionMock - ] - ); - } - - public function testGetColumnsWithoutAttributes() - { - $this->assertEquals($this->columnsResolver->getColumns($this->selectBuilderMock, []), []); - } - - /** - * @dataProvider getColumnsDataProvider - */ - public function testGetColumnsWithFunction($expectedColumns, $expectedGroup, $entityConfig) - { - $this->resourceConnectionMock->expects($this->any()) - ->method('getConnection') - ->willReturn($this->connectionMock); - $this->connectionMock->expects($this->any()) - ->method('quoteIdentifier') - ->with('cpe.name') - ->willReturn('`cpe`.`name`'); - $this->selectBuilderMock->expects($this->once()) - ->method('getColumns') - ->willReturn([]); - $this->selectBuilderMock->expects($this->once()) - ->method('getGroup') - ->willReturn([]); - $this->selectBuilderMock->expects($this->once()) - ->method('setGroup') - ->with($expectedGroup); - $this->assertEquals( - $expectedColumns, - $this->columnsResolver->getColumns( - $this->selectBuilderMock, - $entityConfig - ) - ); - } - - /** - * @return array - */ - public function getColumnsDataProvider() - { - return [ - 'COUNT( DISTINCT `cpe`.`name`) AS name' => [ - 'expectedColumns' => [ - 'name' => new ColumnValueExpression('COUNT( DISTINCT `cpe`.`name`)') - ], - 'expectedGroup' => [ - 'name' => new ColumnValueExpression('COUNT( DISTINCT `cpe`.`name`)') - ], - 'entityConfig' => - [ - 'name' => 'catalog_product_entity', - 'alias' => 'cpe', - 'attribute' => [ - [ - 'name' => 'name', - 'function' => 'COUNT', - 'distinct' => true, - 'group' => true - ] - ], - ], - ], - 'AVG(`cpe`.`name`) AS avg_name' => [ - 'expectedColumns' => [ - 'avg_name' => new ColumnValueExpression('AVG(`cpe`.`name`)') - ], - 'expectedGroup' => [], - 'entityConfig' => - [ - 'name' => 'catalog_product_entity', - 'alias' => 'cpe', - 'attribute' => [ - [ - 'name' => 'name', - 'alias' => 'avg_name', - 'function' => 'AVG', - ] - ], - ], - ] - ]; - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ConditionResolverTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ConditionResolverTest.php deleted file mode 100644 index 2a97e109543cf..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ConditionResolverTest.php +++ /dev/null @@ -1,108 +0,0 @@ -resourceConnectionMock = $this->getMockBuilder(ResourceConnection::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->selectBuilderMock = $this->getMockBuilder(SelectBuilder::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->connectionMock = $this->getMockBuilder(AdapterInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->conditionResolver = new ConditionResolver($this->resourceConnectionMock); - } - - public function testGetFilter() - { - $condition = ["type" => "variable", "_value" => "1", "attribute" => "id", "operator" => "neq"]; - $valueCondition = ["type" => "value", "_value" => "2", "attribute" => "first_name", "operator" => "eq"]; - $identifierCondition = [ - "type" => "identifier", - "_value" => "other_field", - "attribute" => "last_name", - "operator" => "eq"]; - $filter = [["glue" => "AND", "condition" => [$valueCondition]]]; - $filterConfig = [ - ["glue" => "OR", "condition" => [$condition], 'filter' => $filter], - ["glue" => "OR", "condition" => [$identifierCondition]], - ]; - $aliasName = 'n'; - $this->selectBuilderMock->expects($this->any()) - ->method('setParams') - ->with(array_merge([], [$condition['_value']])); - - $this->selectBuilderMock->expects($this->once()) - ->method('getParams') - ->willReturn([]); - - $this->selectBuilderMock->expects($this->any()) - ->method('getColumns') - ->willReturn(['price' => new Expression("(n.price = 400)")]); - - $this->resourceConnectionMock->expects($this->once()) - ->method('getConnection') - ->willReturn($this->connectionMock); - - $this->connectionMock->expects($this->any()) - ->method('quote') - ->willReturn("'John'"); - $this->connectionMock->expects($this->exactly(4)) - ->method('quoteIdentifier') - ->willReturnMap([ - ['n.id', false, '`n`.`id`'], - ['n.first_name', false, '`n`.`first_name`'], - ['n.last_name', false, '`n`.`last_name`'], - ['other_field', false, '`other_field`'], - ]); - - $result = "(`n`.`id` != 1 OR ((`n`.`first_name` = 'John'))) OR (`n`.`last_name` = `other_field`)"; - $this->assertEquals( - $result, - $this->conditionResolver->getFilter($this->selectBuilderMock, $filterConfig, $aliasName) - ); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/NameResolverTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/NameResolverTest.php deleted file mode 100644 index ef051feda0722..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/NameResolverTest.php +++ /dev/null @@ -1,90 +0,0 @@ -nameResolverMock = $this->getMockBuilder(NameResolver::class) - ->disableOriginalConstructor() - ->setMethods(['getName']) - ->getMock(); - - $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->nameResolver = $this->objectManagerHelper->getObject(NameResolver::class); - } - - public function testGetName() - { - $elementConfigMock = [ - 'name' => 'sales_order', - 'alias' => 'sales', - ]; - - $this->assertSame('sales_order', $this->nameResolver->getName($elementConfigMock)); - } - - /** - * @param array $elementConfig - * @param string|null $elementAlias - * - * @dataProvider getAliasDataProvider - */ - public function testGetAlias($elementConfig, $elementAlias) - { - $elementName = 'elementName'; - - $this->nameResolverMock - ->expects($this->once()) - ->method('getName') - ->with($elementConfig) - ->willReturn($elementName); - - $this->assertSame($elementAlias ?: $elementName, $this->nameResolverMock->getAlias($elementConfig)); - } - - /** - * @return array - */ - public function getAliasDataProvider() - { - return [ - 'ElementConfigWithAliases' => [ - ['alias' => 'sales', 'name' => 'sales_order'], - 'sales', - ], - 'ElementConfigWithoutAliases' => [ - ['name' => 'sales_order'], - null, - ] - ]; - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ReportValidatorTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ReportValidatorTest.php deleted file mode 100644 index fad0a80856b70..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ReportValidatorTest.php +++ /dev/null @@ -1,125 +0,0 @@ -connectionFactoryMock = $this->getMockBuilder(ConnectionFactory::class) - ->disableOriginalConstructor()->getMock(); - $this->queryFactoryMock = $this->getMockBuilder(QueryFactory::class) - ->disableOriginalConstructor()->getMock(); - $this->queryMock = $this->getMockBuilder(Query::class)->disableOriginalConstructor() - ->getMock(); - $this->connectionMock = $this->getMockBuilder(AdapterInterface::class)->getMockForAbstractClass(); - $this->selectMock = $this->getMockBuilder(Select::class)->disableOriginalConstructor() - ->getMock(); - $this->objectManagerHelper = new ObjectManagerHelper($this); - - $this->reportValidator = $this->objectManagerHelper->getObject( - ReportValidator::class, - [ - 'connectionFactory' => $this->connectionFactoryMock, - 'queryFactory' => $this->queryFactoryMock - ] - ); - } - - /** - * @dataProvider errorDataProvider - * @param string $reportName - * @param array $result - * @param \PHPUnit_Framework_MockObject_Stub $queryReturnStub - */ - public function testValidate($reportName, $result, \PHPUnit_Framework_MockObject_Stub $queryReturnStub) - { - $connectionName = 'testConnection'; - $this->queryFactoryMock->expects($this->once()) - ->method('create') - ->willReturn($this->queryMock); - $this->queryMock->expects($this->once())->method('getConnectionName')->willReturn($connectionName); - $this->connectionFactoryMock->expects($this->once())->method('getConnection') - ->with($connectionName) - ->willReturn($this->connectionMock); - $this->queryMock->expects($this->atLeastOnce())->method('getSelect')->willReturn($this->selectMock); - $this->selectMock->expects($this->once())->method('limit')->with(0); - $this->connectionMock->expects($this->once())->method('query')->with($this->selectMock)->will($queryReturnStub); - $this->assertEquals($result, $this->reportValidator->validate($reportName)); - } - - /** - * Provide variations of the error returning - * - * @return array - */ - public function errorDataProvider() - { - $reportName = 'test'; - $errorMessage = 'SQL Error 42'; - return [ - [ - $reportName, - 'expectedResult' => [], - 'queryReturnStub' => $this->returnValue(null) - ], - [ - $reportName, - 'expectedResult' => [$reportName, $errorMessage], - 'queryReturnStub' => $this->throwException(new \Zend_Db_Statement_Exception($errorMessage)) - ] - ]; - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/SelectBuilderTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/SelectBuilderTest.php deleted file mode 100644 index fb8f5b4a1ff0e..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/SelectBuilderTest.php +++ /dev/null @@ -1,103 +0,0 @@ -resourceConnectionMock = $this->getMockBuilder(ResourceConnection::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->connectionMock = $this->getMockBuilder(AdapterInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->selectMock = $this->getMockBuilder(Select::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->selectBuilder = new SelectBuilder($this->resourceConnectionMock); - } - - public function testCreate() - { - $connectionName = 'MySql'; - $from = ['customer c']; - $columns = ['id', 'name', 'price']; - $filter = 'filter'; - $joins = [ - ['link-type' => 'left', 'table' => 'customer', 'condition' => 'in'], - ['link-type' => 'inner', 'table' => 'price', 'condition' => 'eq'], - ['link-type' => 'right', 'table' => 'attribute', 'condition' => 'neq'], - ]; - $groups = ['id', 'name']; - $this->selectBuilder->setConnectionName($connectionName); - $this->selectBuilder->setFrom($from); - $this->selectBuilder->setColumns($columns); - $this->selectBuilder->setFilters([$filter]); - $this->selectBuilder->setJoins($joins); - $this->selectBuilder->setGroup($groups); - $this->resourceConnectionMock->expects($this->once()) - ->method('getConnection') - ->with($connectionName) - ->willReturn($this->connectionMock); - $this->connectionMock->expects($this->once()) - ->method('select') - ->willReturn($this->selectMock); - $this->selectMock->expects($this->once()) - ->method('from') - ->with($from, []); - $this->selectMock->expects($this->once()) - ->method('columns') - ->with($columns); - $this->selectMock->expects($this->once()) - ->method('where') - ->with($filter); - $this->selectMock->expects($this->once()) - ->method('joinLeft') - ->with($joins[0]['table'], $joins[0]['condition'], []); - $this->selectMock->expects($this->once()) - ->method('joinInner') - ->with($joins[1]['table'], $joins[1]['condition'], []); - $this->selectMock->expects($this->once()) - ->method('joinRight') - ->with($joins[2]['table'], $joins[2]['condition'], []); - $this->selectBuilder->create(); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/IteratorFactoryTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/IteratorFactoryTest.php deleted file mode 100644 index 38abc3683f81f..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/ReportXml/IteratorFactoryTest.php +++ /dev/null @@ -1,59 +0,0 @@ -objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->iteratorIteratorMock = $this->getMockBuilder(\IteratorIterator::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->iteratorFactory = new IteratorFactory( - $this->objectManagerMock - ); - } - - public function testCreate() - { - $arrayObject = new \ArrayIterator([1, 2, 3, 4, 5]); - $this->objectManagerMock->expects($this->once()) - ->method('create') - ->with(\IteratorIterator::class, ['iterator' => $arrayObject]) - ->willReturn($this->iteratorIteratorMock); - - $this->assertEquals($this->iteratorFactory->create($arrayObject), $this->iteratorIteratorMock); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/QueryFactoryTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/QueryFactoryTest.php deleted file mode 100644 index e358bf00fe37a..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/ReportXml/QueryFactoryTest.php +++ /dev/null @@ -1,239 +0,0 @@ -queryMock = $this->getMockBuilder( - \Magento\Analytics\ReportXml\Query::class - ) - ->disableOriginalConstructor() - ->getMock(); - - $this->configMock = $this->getMockBuilder( - \Magento\Analytics\ReportXml\Config::class - ) - ->disableOriginalConstructor() - ->getMock(); - - $this->selectMock = $this->getMockBuilder( - \Magento\Framework\DB\Select::class - ) - ->disableOriginalConstructor() - ->getMock(); - - $this->assemblerMock = $this->getMockBuilder( - \Magento\Analytics\ReportXml\DB\Assembler\AssemblerInterface::class - ) - ->disableOriginalConstructor() - ->getMock(); - - $this->queryCacheMock = $this->getMockBuilder( - \Magento\Framework\App\CacheInterface::class - ) - ->disableOriginalConstructor() - ->getMock(); - - $this->objectManagerMock = $this->getMockBuilder( - \Magento\Framework\ObjectManagerInterface::class - ) - ->disableOriginalConstructor() - ->getMock(); - - $this->selectHydratorMock = $this->getMockBuilder( - \Magento\Analytics\ReportXml\SelectHydrator::class - ) - ->disableOriginalConstructor() - ->getMock(); - - $this->selectBuilderFactoryMock = $this->getMockBuilder( - \Magento\Analytics\ReportXml\DB\SelectBuilderFactory::class - ) - ->disableOriginalConstructor() - ->getMock(); - - $this->objectManagerHelper = - new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - - $this->subject = $this->objectManagerHelper->getObject( - \Magento\Analytics\ReportXml\QueryFactory::class, - [ - 'config' => $this->configMock, - 'selectBuilderFactory' => $this->selectBuilderFactoryMock, - 'assemblers' => [$this->assemblerMock], - 'queryCache' => $this->queryCacheMock, - 'objectManager' => $this->objectManagerMock, - 'selectHydrator' => $this->selectHydratorMock - ] - ); - } - - /** - * @return void - */ - public function testCreateCached() - { - $queryName = 'test_query'; - - $this->queryCacheMock->expects($this->any()) - ->method('load') - ->with($queryName) - ->willReturn('{"connectionName":"sales","config":{},"select_parts":{}}'); - - $this->selectHydratorMock->expects($this->any()) - ->method('recreate') - ->with([]) - ->willReturn($this->selectMock); - - $this->objectManagerMock->expects($this->once()) - ->method('create') - ->with( - \Magento\Analytics\ReportXml\Query::class, - [ - 'select' => $this->selectMock, - 'selectHydrator' => $this->selectHydratorMock, - 'connectionName' => 'sales', - 'config' => [] - ] - ) - ->willReturn($this->queryMock); - - $this->queryCacheMock->expects($this->never()) - ->method('save'); - - $this->assertEquals( - $this->queryMock, - $this->subject->create($queryName) - ); - } - - /** - * @return void - */ - public function testCreateNotCached() - { - $queryName = 'test_query'; - - $queryConfigMock = [ - 'name' => 'test_query', - 'connection' => 'sales' - ]; - - $selectBuilderMock = $this->getMockBuilder( - \Magento\Analytics\ReportXml\DB\SelectBuilder::class - ) - ->disableOriginalConstructor() - ->getMock(); - $selectBuilderMock->expects($this->once()) - ->method('setConnectionName') - ->with($queryConfigMock['connection']); - $selectBuilderMock->expects($this->any()) - ->method('create') - ->willReturn($this->selectMock); - $selectBuilderMock->expects($this->any()) - ->method('getConnectionName') - ->willReturn($queryConfigMock['connection']); - - $this->queryCacheMock->expects($this->any()) - ->method('load') - ->with($queryName) - ->willReturn(null); - - $this->configMock->expects($this->any()) - ->method('get') - ->with($queryName) - ->willReturn($queryConfigMock); - - $this->selectBuilderFactoryMock->expects($this->any()) - ->method('create') - ->willReturn($selectBuilderMock); - - $this->assemblerMock->expects($this->once()) - ->method('assemble') - ->with($selectBuilderMock, $queryConfigMock) - ->willReturn($selectBuilderMock); - - $this->objectManagerMock->expects($this->once()) - ->method('create') - ->with( - \Magento\Analytics\ReportXml\Query::class, - [ - 'select' => $this->selectMock, - 'selectHydrator' => $this->selectHydratorMock, - 'connectionName' => $queryConfigMock['connection'], - 'config' => $queryConfigMock - ] - ) - ->willReturn($this->queryMock); - - $this->queryCacheMock->expects($this->once()) - ->method('save') - ->with(json_encode($this->queryMock), $queryName); - - $this->assertEquals( - $this->queryMock, - $this->subject->create($queryName) - ); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/QueryTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/QueryTest.php deleted file mode 100644 index e288c668a54f7..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/ReportXml/QueryTest.php +++ /dev/null @@ -1,90 +0,0 @@ -selectMock = $this->getMockBuilder(Select::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->selectHydratorMock = $this->getMockBuilder(selectHydrator::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->objectManagerHelper = new ObjectManagerHelper($this); - - $this->query = $this->objectManagerHelper->getObject( - Query::class, - [ - 'select' => $this->selectMock, - 'connectionName' => $this->connectionName, - 'selectHydrator' => $this->selectHydratorMock, - 'config' => [] - ] - ); - } - - /** - * @return void - */ - public function testJsonSerialize() - { - $selectParts = ['part' => 1]; - - $this->selectHydratorMock - ->expects($this->once()) - ->method('extract') - ->with($this->selectMock) - ->willReturn($selectParts); - - $expectedResult = [ - 'connectionName' => $this->connectionName, - 'select_parts' => $selectParts, - 'config' => [] - ]; - - $this->assertSame($expectedResult, $this->query->jsonSerialize()); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/ReportProviderTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/ReportProviderTest.php deleted file mode 100644 index 124d5f32078c8..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/ReportXml/ReportProviderTest.php +++ /dev/null @@ -1,180 +0,0 @@ -selectMock = $this->getMockBuilder( - \Magento\Framework\DB\Select::class - ) - ->disableOriginalConstructor() - ->getMock(); - - $this->queryMock = $this->getMockBuilder( - \Magento\Analytics\ReportXml\Query::class - ) - ->disableOriginalConstructor() - ->getMock(); - $this->queryMock->expects($this->any()) - ->method('getSelect') - ->willReturn($this->selectMock); - - $this->iteratorMock = $this->getMockBuilder( - \IteratorIterator::class - ) - ->disableOriginalConstructor() - ->getMock(); - - $this->statementMock = $this->getMockBuilder( - \Magento\Framework\DB\Statement\Pdo\Mysql::class - ) - ->disableOriginalConstructor() - ->getMock(); - $this->statementMock->expects($this->any()) - ->method('getIterator') - ->willReturn($this->iteratorMock); - - $this->connectionMock = $this->getMockBuilder( - \Magento\Framework\DB\Adapter\AdapterInterface::class - ) - ->disableOriginalConstructor() - ->getMock(); - - $this->queryFactoryMock = $this->getMockBuilder( - \Magento\Analytics\ReportXml\QueryFactory::class - ) - ->disableOriginalConstructor() - ->getMock(); - - $this->iteratorFactoryMock = $this->getMockBuilder( - \Magento\Analytics\ReportXml\IteratorFactory::class - ) - ->disableOriginalConstructor() - ->getMock(); - $this->iteratorMock = $this->getMockBuilder( - \IteratorIterator::class - ) - ->disableOriginalConstructor() - ->getMock(); - $this->objectManagerHelper = - new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - - $this->connectionFactoryMock = $this->getMockBuilder( - \Magento\Analytics\ReportXml\ConnectionFactory::class - ) - ->disableOriginalConstructor() - ->getMock(); - - $this->subject = $this->objectManagerHelper->getObject( - \Magento\Analytics\ReportXml\ReportProvider::class, - [ - 'queryFactory' => $this->queryFactoryMock, - 'connectionFactory' => $this->connectionFactoryMock, - 'iteratorFactory' => $this->iteratorFactoryMock - ] - ); - } - - /** - * @return void - */ - public function testGetReport() - { - $reportName = 'test_report'; - $connectionName = 'sales'; - - $this->queryFactoryMock->expects($this->once()) - ->method('create') - ->with($reportName) - ->willReturn($this->queryMock); - - $this->connectionFactoryMock->expects($this->once()) - ->method('getConnection') - ->with($connectionName) - ->willReturn($this->connectionMock); - - $this->queryMock->expects($this->once()) - ->method('getConnectionName') - ->willReturn($connectionName); - - $this->queryMock->expects($this->once()) - ->method('getConfig') - ->willReturn( - [ - 'connection' => $connectionName - ] - ); - - $this->connectionMock->expects($this->once()) - ->method('query') - ->with($this->selectMock) - ->willReturn($this->statementMock); - - $this->iteratorFactoryMock->expects($this->once()) - ->method('create') - ->with($this->statementMock, null) - ->willReturn($this->iteratorMock); - $this->assertEquals($this->iteratorMock, $this->subject->getReport($reportName)); - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/SelectHydratorTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/SelectHydratorTest.php deleted file mode 100644 index dce8089a787dc..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/ReportXml/SelectHydratorTest.php +++ /dev/null @@ -1,257 +0,0 @@ -resourceConnectionMock = $this->getMockBuilder(ResourceConnection::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->connectionMock = $this->getMockBuilder(AdapterInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->selectMock = $this->getMockBuilder(Select::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->objectManagerHelper = new ObjectManagerHelper($this); - - $this->selectHydrator = $this->objectManagerHelper->getObject( - SelectHydrator::class, - [ - 'resourceConnection' => $this->resourceConnectionMock, - 'objectManager' => $this->objectManagerMock, - ] - ); - } - - public function testExtract() - { - $selectParts = - [ - Select::DISTINCT, - Select::COLUMNS, - Select::UNION, - Select::FROM, - Select::WHERE, - Select::GROUP, - Select::HAVING, - Select::ORDER, - Select::LIMIT_COUNT, - Select::LIMIT_OFFSET, - Select::FOR_UPDATE - ]; - - $result = []; - foreach ($selectParts as $part) { - $result[$part] = "Part"; - } - $this->selectMock->expects($this->any()) - ->method('getPart') - ->willReturn("Part"); - $this->assertEquals($this->selectHydrator->extract($this->selectMock), $result); - } - - /** - * @dataProvider recreateWithoutExpressionDataProvider - * @param array $selectParts - * @param array $parts - * @param array $partValues - */ - public function testRecreateWithoutExpression($selectParts, $parts, $partValues) - { - $this->resourceConnectionMock->expects($this->once()) - ->method('getConnection') - ->willReturn($this->connectionMock); - $this->connectionMock->expects($this->once()) - ->method('select') - ->willReturn($this->selectMock); - foreach ($parts as $key => $part) { - $this->selectMock->expects($this->at($key)) - ->method('setPart') - ->with($part, $partValues[$key]); - } - - $this->assertSame($this->selectMock, $this->selectHydrator->recreate($selectParts)); - } - - /** - * @return array - */ - public function recreateWithoutExpressionDataProvider() - { - return [ - 'Select without expressions' => [ - [ - Select::COLUMNS => [ - [ - 'table_name', - 'field_name', - 'alias', - ], - [ - 'table_name', - 'field_name_2', - 'alias_2', - ], - ] - ], - [Select::COLUMNS], - [[ - [ - 'table_name', - 'field_name', - 'alias', - ], - [ - 'table_name', - 'field_name_2', - 'alias_2', - ], - ]], - ], - ]; - } - - /** - * @dataProvider recreateWithExpressionDataProvider - * @param array $selectParts - * @param array $expectedParts - * @param \PHPUnit_Framework_MockObject_MockObject[] $expressionMocks - */ - public function testRecreateWithExpression( - array $selectParts, - array $expectedParts, - array $expressionMocks - ) { - $this->objectManagerMock - ->expects($this->exactly(count($expressionMocks))) - ->method('create') - ->with($this->isType('string'), $this->isType('array')) - ->willReturnOnConsecutiveCalls(...$expressionMocks); - $this->resourceConnectionMock - ->expects($this->once()) - ->method('getConnection') - ->with() - ->willReturn($this->connectionMock); - $this->connectionMock - ->expects($this->once()) - ->method('select') - ->with() - ->willReturn($this->selectMock); - foreach (array_keys($selectParts) as $key => $partName) { - $this->selectMock - ->expects($this->at($key)) - ->method('setPart') - ->with($partName, $expectedParts[$partName]); - } - - $this->assertSame($this->selectMock, $this->selectHydrator->recreate($selectParts)); - } - - /** - * @return array - */ - public function recreateWithExpressionDataProvider() - { - $expressionMock = $this->getMockBuilder(JsonSerializableExpression::class) - ->disableOriginalConstructor() - ->getMock(); - - return [ - 'Select without expressions' => [ - 'Parts' => [ - Select::COLUMNS => [ - [ - 'table_name', - 'field_name', - 'alias', - ], - [ - 'table_name', - [ - 'class' => 'Some_class', - 'arguments' => [ - 'expression' => ['some(expression)'] - ] - ], - 'alias_2', - ], - ] - ], - 'expectedParts' => [ - Select::COLUMNS => [ - [ - 'table_name', - 'field_name', - 'alias', - ], - [ - 'table_name', - $expressionMock, - 'alias_2', - ], - ] - ], - 'expectedExpressions' => [ - $expressionMock - ] - ], - ]; - } -} diff --git a/app/code/Magento/Analytics/Test/Unit/Ui/DataProvider/DummyDataProviderTest.php b/app/code/Magento/Analytics/Test/Unit/Ui/DataProvider/DummyDataProviderTest.php deleted file mode 100644 index 94f6ed1845c40..0000000000000 --- a/app/code/Magento/Analytics/Test/Unit/Ui/DataProvider/DummyDataProviderTest.php +++ /dev/null @@ -1,228 +0,0 @@ - 'value']; - - /** - * @return void - */ - protected function setUp() - { - $this->searchResultMock = $this->getMockBuilder(SearchResultInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->searchCriteriaMock = $this->getMockBuilder(SearchCriteriaInterface::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->dataCollectionMock = $this->getMockBuilder(Collection::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->filterMock = $this->getMockBuilder(Filter::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->objectManagerHelper = new ObjectManagerHelper($this); - - $this->dummyDataProvider = $this->objectManagerHelper->getObject( - DummyDataProvider::class, - [ - 'name' => $this->providerName, - 'searchResult' => $this->searchResultMock, - 'searchCriteria' => $this->searchCriteriaMock, - 'collection' => $this->dataCollectionMock, - 'data' => ['config' => $this->configData], - ] - ); - } - - /** - * @return void - */ - public function testGetName() - { - $this->assertSame($this->providerName, $this->dummyDataProvider->getName()); - } - - /** - * @return void - */ - public function testGetConfigData() - { - $this->assertSame($this->configData, $this->dummyDataProvider->getConfigData()); - $dataProvider = $this->objectManagerHelper - ->getObject( - DummyDataProvider::class, - [] - ); - $this->assertSame([], $dataProvider->getConfigData()); - } - - /** - * @return void - */ - public function testSetConfigData() - { - $configValue = ['key' => 'value']; - - $this->assertTrue($this->dummyDataProvider->setConfigData($configValue)); - $this->assertSame($configValue, $this->dummyDataProvider->getConfigData()); - } - - /** - * @return void - */ - public function testGetMeta() - { - $this->assertSame([], $this->dummyDataProvider->getMeta()); - } - - /** - * @return void - */ - public function testGetFieldMetaInfo() - { - $this->assertSame([], $this->dummyDataProvider->getFieldMetaInfo('', '')); - } - - /** - * @return void - */ - public function testGetFieldSetMetaInfo() - { - $this->assertSame([], $this->dummyDataProvider->getFieldSetMetaInfo('')); - } - - /** - * @return void - */ - public function testGetFieldsMetaInfo() - { - $this->assertSame([], $this->dummyDataProvider->getFieldsMetaInfo('')); - } - - /** - * @return void - */ - public function testGetPrimaryFieldName() - { - $this->assertSame('', $this->dummyDataProvider->getPrimaryFieldName()); - } - - /** - * @return void - */ - public function testGetRequestFieldName() - { - $this->assertSame('', $this->dummyDataProvider->getRequestFieldName()); - } - - /** - * @return void - */ - public function testGetData() - { - $this->dataCollectionMock - ->expects($this->once()) - ->method('toArray') - ->willReturn([]); - $this->assertSame([], $this->dummyDataProvider->getData()); - } - - /** - * @return void - */ - public function testAddFilter() - { - $this->assertNull($this->dummyDataProvider->addFilter($this->filterMock)); - } - - /** - * @return void - */ - public function testAddOrder() - { - $this->assertNull($this->dummyDataProvider->addOrder('', '')); - } - - /** - * @return void - */ - public function testSetLimit() - { - $this->assertNull($this->dummyDataProvider->setLimit(1, 1)); - } - - /** - * @return void - */ - public function testGetSearchCriteria() - { - $this->assertSame($this->searchCriteriaMock, $this->dummyDataProvider->getSearchCriteria()); - } - - /** - * @return void - */ - public function testGetSearchResult() - { - $this->assertSame($this->searchResultMock, $this->dummyDataProvider->getSearchResult()); - } -} diff --git a/app/code/Magento/Analytics/Ui/DataProvider/DummyDataProvider.php b/app/code/Magento/Analytics/Ui/DataProvider/DummyDataProvider.php deleted file mode 100644 index 87f5c7c5bc4fd..0000000000000 --- a/app/code/Magento/Analytics/Ui/DataProvider/DummyDataProvider.php +++ /dev/null @@ -1,237 +0,0 @@ -name = $name; - $this->searchResult = $searchResult; - $this->searchCriteria = $searchCriteria; - $this->collection = $collection; - $this->data = $data; - } - - /** - * Get Data Provider name - * - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * Get config data - * - * @return mixed - */ - public function getConfigData() - { - return isset($this->data['config']) ? $this->data['config'] : []; - } - - /** - * Set config data - * - * @param mixed $config - * - * @return bool - */ - public function setConfigData($config) - { - $this->data['config'] = $config; - - return true; - } - - /** - * @return array - */ - public function getMeta() - { - return []; - } - - /** - * @param string $fieldSetName - * @param string $fieldName - * - * @return array - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function getFieldMetaInfo($fieldSetName, $fieldName) - { - return []; - } - - /** - * Get field set meta info - * - * @param string $fieldSetName - * - * @return array - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function getFieldSetMetaInfo($fieldSetName) - { - return []; - } - - /** - * @param string $fieldSetName - * - * @return array - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function getFieldsMetaInfo($fieldSetName) - { - return []; - } - - /** - * Get primary field name - * - * @return string - */ - public function getPrimaryFieldName() - { - return ''; - } - - /** - * Get field name in request - * - * @return string - */ - public function getRequestFieldName() - { - return ''; - } - - /** - * Get data - * - * @return mixed - */ - public function getData() - { - return $this->collection->toArray(); - } - - /** - * Add field filter to collection - * - * @param \Magento\Framework\Api\Filter $filter - * - * @return void - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function addFilter(\Magento\Framework\Api\Filter $filter) - { - } - - /** - * Add ORDER BY to the end or to the beginning - * - * @param string $field - * @param string $direction - * - * @return void - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function addOrder($field, $direction) - { - } - - /** - * Set Query limit - * - * @param int $offset - * @param int $size - * - * @return void - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function setLimit($offset, $size) - { - } - - /** - * Returns search criteria - * - * @return SearchCriteriaInterface - */ - public function getSearchCriteria() - { - return $this->searchCriteria; - } - - /** - * @return SearchResultInterface - */ - public function getSearchResult() - { - return $this->searchResult; - } -} diff --git a/app/code/Magento/Analytics/docs/images/M2_MA_signup.png b/app/code/Magento/Analytics/docs/images/M2_MA_signup.png deleted file mode 100644 index 78ed8fad92881..0000000000000 Binary files a/app/code/Magento/Analytics/docs/images/M2_MA_signup.png and /dev/null differ diff --git a/app/code/Magento/Analytics/docs/images/analytics_modules.png b/app/code/Magento/Analytics/docs/images/analytics_modules.png deleted file mode 100644 index 0bf6048b0d9cc..0000000000000 Binary files a/app/code/Magento/Analytics/docs/images/analytics_modules.png and /dev/null differ diff --git a/app/code/Magento/Analytics/docs/images/data_transition.png b/app/code/Magento/Analytics/docs/images/data_transition.png deleted file mode 100644 index a75e97983e15d..0000000000000 Binary files a/app/code/Magento/Analytics/docs/images/data_transition.png and /dev/null differ diff --git a/app/code/Magento/Analytics/docs/images/definition.png b/app/code/Magento/Analytics/docs/images/definition.png deleted file mode 100644 index 16acc576320b0..0000000000000 Binary files a/app/code/Magento/Analytics/docs/images/definition.png and /dev/null differ diff --git a/app/code/Magento/Analytics/docs/images/mbi_file_exchange.png b/app/code/Magento/Analytics/docs/images/mbi_file_exchange.png deleted file mode 100644 index f39d2e4900703..0000000000000 Binary files a/app/code/Magento/Analytics/docs/images/mbi_file_exchange.png and /dev/null differ diff --git a/app/code/Magento/Analytics/docs/images/signup.png b/app/code/Magento/Analytics/docs/images/signup.png deleted file mode 100644 index 561e18b3a351f..0000000000000 Binary files a/app/code/Magento/Analytics/docs/images/signup.png and /dev/null differ diff --git a/app/code/Magento/Analytics/docs/images/update.png b/app/code/Magento/Analytics/docs/images/update.png deleted file mode 100644 index 149f5b5d3f9bd..0000000000000 Binary files a/app/code/Magento/Analytics/docs/images/update.png and /dev/null differ diff --git a/app/code/Magento/Analytics/docs/images/update_request.png b/app/code/Magento/Analytics/docs/images/update_request.png deleted file mode 100644 index 7181251e3634e..0000000000000 Binary files a/app/code/Magento/Analytics/docs/images/update_request.png and /dev/null differ diff --git a/app/code/Magento/Analytics/etc/acl.xml b/app/code/Magento/Analytics/etc/acl.xml deleted file mode 100644 index bf2251895f929..0000000000000 --- a/app/code/Magento/Analytics/etc/acl.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/code/Magento/Analytics/etc/adminhtml/menu.xml b/app/code/Magento/Analytics/etc/adminhtml/menu.xml deleted file mode 100644 index 915211c4bb85e..0000000000000 --- a/app/code/Magento/Analytics/etc/adminhtml/menu.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - diff --git a/app/code/Magento/Analytics/etc/adminhtml/routes.xml b/app/code/Magento/Analytics/etc/adminhtml/routes.xml deleted file mode 100644 index 0ae2762dacc5f..0000000000000 --- a/app/code/Magento/Analytics/etc/adminhtml/routes.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - diff --git a/app/code/Magento/Analytics/etc/adminhtml/system.xml b/app/code/Magento/Analytics/etc/adminhtml/system.xml deleted file mode 100644 index 32d493451ca61..0000000000000 --- a/app/code/Magento/Analytics/etc/adminhtml/system.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - -
- - general - Magento_Analytics::analytics_settings - - - For more information, view details or see our - terms and conditions.]]> - - - Magento\Config\Model\Config\Source\Enabledisable - Magento\Analytics\Model\Config\Backend\Enabled - Magento\Analytics\Block\Adminhtml\System\Config\SubscriptionStatusLabel - analytics/subscription/enabled - - - - Magento\Analytics\Model\Config\Source\Vertical - Magento\Analytics\Model\Config\Backend\Vertical - - - - Magento\Analytics\Block\Adminhtml\System\Config\CollectionTimeLabel - Magento\Analytics\Model\Config\Backend\CollectionTime - - - - Learn more about BI Essentials tier.]]> - Magento\Analytics\Block\Adminhtml\System\Config\AdditionalComment - - -
-
-
diff --git a/app/code/Magento/Analytics/etc/analytics.xml b/app/code/Magento/Analytics/etc/analytics.xml deleted file mode 100644 index 77ebe751a31cf..0000000000000 --- a/app/code/Magento/Analytics/etc/analytics.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - modules - - - - - - - - - - - - - - stores - - - - - - - - - websites - - - - - - - - - groups - - - - - diff --git a/app/code/Magento/Analytics/etc/analytics.xsd b/app/code/Magento/Analytics/etc/analytics.xsd deleted file mode 100644 index 2506e3d6a6a9a..0000000000000 --- a/app/code/Magento/Analytics/etc/analytics.xsd +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - File name attribute can has only [a-zA-Z0-9/_]. - - - - - - - - - - Value is required. - - - - - - - diff --git a/app/code/Magento/Analytics/etc/config.xml b/app/code/Magento/Analytics/etc/config.xml deleted file mode 100644 index b6194ba12993f..0000000000000 --- a/app/code/Magento/Analytics/etc/config.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - https://advancedreporting.rjmetrics.com/signup - https://advancedreporting.rjmetrics.com/update - https://dashboard.rjmetrics.com/v2/magento/signup - https://advancedreporting.rjmetrics.com/otp - https://advancedreporting.rjmetrics.com/report - https://advancedreporting.rjmetrics.com/report - - Magento Analytics user - - 02,00,00 - - - - diff --git a/app/code/Magento/Analytics/etc/crontab.xml b/app/code/Magento/Analytics/etc/crontab.xml deleted file mode 100644 index a4beef0359540..0000000000000 --- a/app/code/Magento/Analytics/etc/crontab.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - diff --git a/app/code/Magento/Analytics/etc/di.xml b/app/code/Magento/Analytics/etc/di.xml deleted file mode 100644 index 09efd7c36ad83..0000000000000 --- a/app/code/Magento/Analytics/etc/di.xml +++ /dev/null @@ -1,262 +0,0 @@ - - - - - - - - - - - - - - - Magento\Analytics\Model\Connector\SignUpCommand - Magento\Analytics\Model\Connector\UpdateCommand - Magento\Analytics\Model\Connector\NotifyDataChangedCommand - - - - - - Magento\Config\Model\ResourceModel\Config\Data - - - - - - Magento\Analytics\ReportXml\Config\Data - - - - - Magento\Analytics\ReportXml\Config\Reader - Magento_Analytics_ReportXml_CacheId - - - - - urn:magento:module:Magento_Analytics:etc/reports.xsd - - - - - Magento\Analytics\ReportXml\Config\Converter\Xml - Magento\Analytics\ReportXml\Config\SchemaLocator - reports.xml - - name - - name - alias - - name - name - - glue - - attribute - operator - - - glue - - attribute - operator - - - glue - - attribute - operator - - glue - - attribute - operator - - - - - - - - Magento\Analytics\ReportXml\Config\Reader\Xml - - - - - - - Magento\Analytics\Model\Config\Data - - - - - Magento\Analytics\Model\Config\Reader - Magento_Analytics_CacheId - - - - - urn:magento:module:Magento_Analytics:etc/analytics.xsd - - - - - Magento\Analytics\ReportXml\Config\Converter\Xml - Magento\Analytics\Model\Config\SchemaLocator - analytics.xml - - name - - - - - - - - Magento\Analytics\ReportXml\DB\Assembler\FromAssembler - Magento\Analytics\ReportXml\DB\Assembler\FilterAssembler - Magento\Analytics\ReportXml\DB\Assembler\JoinAssembler - - - - - - - Magento\Analytics\Model\Config\Reader\Xml - - - - - - - web/unsecure/base_url - currency/options/base - general/locale/timezone - general/country/default - carriers/dhl/title - carriers/dhl/active - carriers/fedex/title - carriers/fedex/active - carriers/flatrate/title - carriers/flatrate/active - carriers/tablerate/title - carriers/tablerate/active - carriers/freeshipping/title - carriers/freeshipping/active - carriers/ups/title - carriers/ups/active - carriers/usps/title - carriers/usps/active - payment/free/title - payment/free/active - payment/checkmo/title - payment/checkmo/active - payment/purchaseorder/title - payment/purchaseorder/active - payment/banktransfer/title - payment/banktransfer/active - payment/cashondelivery/title - payment/cashondelivery/active - payment/authorizenet_directpost/title - payment/authorizenet_directpost/active - payment/paypal_billing_agreement/title - payment/paypal_billing_agreement/active - payment/braintree/title - payment/braintree/active - payment/braintree_paypal/title - payment/braintree_paypal/active - analytics/general/vertical - - - - - - - Apps and Games - Athletic/Sporting Goods - Art and Design - Auto Parts - Baby/Children’s Apparel, Gear and Toys - Beauty and Cosmetics - Books, Music and Magazines - Crafts and Stationery - Consumer Electronics - Deal Site - Fashion Apparel and Accessories - Food, Beverage and Grocery - Home Goods and Furniture - Home Improvement - Jewelry and Watches - Mass Merchant - Office Supplies - Outdoor and Camping Gear - Pet Goods - Pharma and Medical Devices - Technology B2B - Other - - - - - - - - - - \Magento\Analytics\Model\Connector\ResponseHandler\SignUp - - - - - - - Magento\Analytics\Model\Connector\ResponseHandler\Update - Magento\Analytics\Model\Connector\ResponseHandler\ReSignUp - - - - - - - Magento\Analytics\Model\Connector\ResponseHandler\OTP - Magento\Analytics\Model\Connector\ResponseHandler\ReSignUp - - - - - - - Magento\Analytics\Model\Connector\ResponseHandler\ReSignUp - - - - - - SignUpResponseResolver - - - - - UpdateResponseResolver - - - - - OtpResponseResolver - - - - - NotifyDataChangedResponseResolver - - - diff --git a/app/code/Magento/Analytics/etc/module.xml b/app/code/Magento/Analytics/etc/module.xml deleted file mode 100644 index 32ee5d23a4d86..0000000000000 --- a/app/code/Magento/Analytics/etc/module.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - diff --git a/app/code/Magento/Analytics/etc/reports.xml b/app/code/Magento/Analytics/etc/reports.xml deleted file mode 100644 index 8a43658670293..0000000000000 --- a/app/code/Magento/Analytics/etc/reports.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/code/Magento/Analytics/etc/reports.xsd b/app/code/Magento/Analytics/etc/reports.xsd deleted file mode 100644 index d0ba4068244fe..0000000000000 --- a/app/code/Magento/Analytics/etc/reports.xsd +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/code/Magento/Analytics/etc/webapi.xml b/app/code/Magento/Analytics/etc/webapi.xml deleted file mode 100644 index 8252d039f1d03..0000000000000 --- a/app/code/Magento/Analytics/etc/webapi.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - diff --git a/app/code/Magento/Analytics/i18n/en_US.csv b/app/code/Magento/Analytics/i18n/en_US.csv deleted file mode 100644 index 090534923e450..0000000000000 --- a/app/code/Magento/Analytics/i18n/en_US.csv +++ /dev/null @@ -1,103 +0,0 @@ -"Subscription status","Subscription status" -"Sorry, there has been an error processing your request. Please try again later.","Sorry, there has been an error processing your request. Please try again later." -"Sorry, there was an error processing your registration request to Magento Analytics. Please try again later.","Sorry, there was an error processing your registration request to Magento Analytics. Please try again later." -"Error occurred during postponement notification","Error occurred during postponement notification" -"Time value has an unsupported format","Time value has an unsupported format" -"Cron settings can't be saved","Cron settings can't be saved" -"There was an error save new configuration value.","There was an error save new configuration value." -"Please select a vertical.","Please select a vertical." -"--Please Select--","--Please Select--" -"Command was not found.","Command was not found." -"Input data must be string or convertible into string.","Input data must be string or convertible into string." -"Input data must be non-empty string.","Input data must be non-empty string." -"Not valid cipher method.","Not valid cipher method." -"Encryption key can't be empty.","Encryption key can't be empty." -"Source ""%1"" is not exist","Source ""%1"" is not exist" -"These arguments can't be empty ""%1""","These arguments can't be empty ""%1""" -"Cannot find predefined integration user!","Cannot find predefined integration user!" -"File is not ready yet.","File is not ready yet." -"Your Base URL has been changed and your reports are being updated. Advanced Reporting will be available once this change has been processed. Please try again later.","Your Base URL has been changed and your reports are being updated. Advanced Reporting will be available once this change has been processed. Please try again later." -"Failed to synchronize data to the Magento Business Intelligence service. ","Failed to synchronize data to the Magento Business Intelligence service. " -"Retry Synchronization","Retry Synchronization" -TestMessage,TestMessage -"Error message","Error message" -"Apps and Games","Apps and Games" -"Athletic/Sporting Goods","Athletic/Sporting Goods" -"Art and Design","Art and Design" -"Advanced Reporting","Advanced Reporting" -"Gain new insights and take command of your business' performance, using our dynamic product, order, and customer reports tailored to your customer data.","Gain new insights and take command of your business' performance, using our dynamic product, order, and customer reports tailored to your customer data." -"View details","View details" -"Go to Advanced Reporting","Go to Advanced Reporting" -"An error occurred while subscription process.","An error occurred while subscription process." -Analytics,Analytics -API,API -Configuration,Configuration -"Business Intelligence","Business Intelligence" -"BI Essentials","BI Essentials" -"This service provides a suite of dynamic reports based on your product, order and - customer data. All reports are accessed securely on a personalized dashboard dedicated to your reports - - separate from your Admin Panel.
For more information, view details or see our - terms and conditions.","This service provides a suite of dynamic reports based on your product, order and - customer data. All reports are accessed securely on a personalized dashboard dedicated to your reports - - separate from your Admin Panel.
For more information, view details or see our - terms and conditions." -"Advanced Reporting Service","Advanced Reporting Service" -Industry,Industry -"Time of day to send data","Time of day to send data" -"Get more insights from Magento Business Intelligence","Get more insights from Magento Business Intelligence" -"Magento Business Intelligence provides you with a simple and clear path to - becoming more data driven.
Learn more about BI Essentials tier.","Magento Business Intelligence provides you with a simple and clear path to - becoming more data driven.
Learn more about BI Essentials tier." -"Auto Parts","Auto Parts" -"Baby/Children’s Apparel, Gear and Toys","Baby/Children’s Apparel, Gear and Toys" -"Beauty and Cosmetics","Beauty and Cosmetics" -"Books, Music and Magazines","Books, Music and Magazines" -"Crafts and Stationery","Crafts and Stationery" -"Consumer Electronics","Consumer Electronics" -"Deal Site","Deal Site" -"Fashion Apparel and Accessories","Fashion Apparel and Accessories" -"Food, Beverage and Grocery","Food, Beverage and Grocery" -"Home Goods and Furniture","Home Goods and Furniture" -"Home Improvement","Home Improvement" -"Jewelry and Watches","Jewelry and Watches" -"Mass Merchant","Mass Merchant" -"Office Supplies","Office Supplies" -"Outdoor and Camping Gear","Outdoor and Camping Gear" -"Pet Goods","Pet Goods" -"Pharma and Medical Devices","Pharma and Medical Devices" -"Technology B2B","Technology B2B" -"Analytics Subscription","Analytics Subscription" -"powered by Magento Business Intelligence","powered by Magento Business Intelligence" -"

When you turn on Advanced - Reporting, you'll have access to a suite of dynamic reports tailored to your business. Example - of the new data and trend reports, listed by category, include:

    -
  • Order: Number of orders, total revenue, and AOV
  • Customer: - New registered accounts, unique customers, number of orders, AOV, revenue by email -
  • Product: Quantity sold, bestsellers by volume/revenue

A - personalized dashboard includes all reports - separate from your Admin Panel, yet still at your - fingertips.

We're excited to offer these valuable tools that can help your business become - more data-driven. For more information, view details or see our - terms and conditions.

- ","

When you turn on Advanced - Reporting, you'll have access to a suite of dynamic reports tailored to your business. Example - of the new data and trend reports, listed by category, include:

    -
  • Order: Number of orders, total revenue, and AOV
  • Customer: - New registered accounts, unique customers, number of orders, AOV, revenue by email -
  • Product: Quantity sold, bestsellers by volume/revenue

A - personalized dashboard includes all reports - separate from your Admin Panel, yet still at your - fingertips.

We're excited to offer these valuable tools that can help your business become - more data-driven. For more information, view details or see our - terms and conditions.

- " -"Are you sure you want to opt out?","Are you sure you want to opt out?" -Cancel,Cancel -"Opt out","Opt out" -"

Advanced Reporting in included, - free of charge, in your Magento software. When you opt out, we collect no product, order, and - customer data to generate our dynamic reports.

To opt in later: You can always turn on Advanced - Reporting in you Admin Panel.

","

Advanced Reporting in included, - free of charge, in your Magento software. When you opt out, we collect no product, order, and - customer data to generate our dynamic reports.

To opt in later: You can always turn on Advanced - Reporting in you Admin Panel.

" diff --git a/app/code/Magento/Analytics/registration.php b/app/code/Magento/Analytics/registration.php deleted file mode 100644 index 58d3688b7491d..0000000000000 --- a/app/code/Magento/Analytics/registration.php +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - - diff --git a/app/code/Magento/Analytics/view/adminhtml/templates/dashboard/section.phtml b/app/code/Magento/Analytics/view/adminhtml/templates/dashboard/section.phtml deleted file mode 100644 index a22c603b2a8b3..0000000000000 --- a/app/code/Magento/Analytics/view/adminhtml/templates/dashboard/section.phtml +++ /dev/null @@ -1,28 +0,0 @@ - - -
-
-
- escapeHtml(__('Advanced Reporting')) ?> -
-
- escapeHtml(__('Gain new insights and take command of your business\' performance,' . - ' using our dynamic product, order, and customer reports tailored to your customer data.')) ?> -
-
- -
diff --git a/app/code/Magento/Analytics/view/adminhtml/ui_component/analytics_subscription_form.xml b/app/code/Magento/Analytics/view/adminhtml/ui_component/analytics_subscription_form.xml deleted file mode 100644 index b44974b32cffa..0000000000000 --- a/app/code/Magento/Analytics/view/adminhtml/ui_component/analytics_subscription_form.xml +++ /dev/null @@ -1,247 +0,0 @@ - - -
- - - analytics_subscription_form.analytics_subscription_form_data_source - - Analytics Subscription - templates/form/collapsible - - - analytics_subscription_form - true - simple - data - - analytics_subscription_form.analytics_subscription_form_data_source - - - - - - - - - - - - - Magento_Ui/js/form/provider - - - - - - - - - false - - - - - - - actionCancel - true - - - - - - - - - - -
- - - - - - - advanced-reports-subscription-text - When you turn on Advanced - Reporting, you'll have access to a suite of dynamic reports tailored to your business. Example - of the new data and trend reports, listed by category, include:

    -
  • Order: Number of orders, total revenue, and AOV
  • Customer: - New registered accounts, unique customers, number of orders, AOV, revenue by email -
  • Product: Quantity sold, bestsellers by volume/revenue

A - personalized dashboard includes all reports - separate from your Admin Panel, yet still at your - fingertips.

We're excited to offer these valuable tools that can help your business become - more data-driven. For more information, view details or see our - terms and conditions.

]]> -
-
-
-
- - - - - - - - - - - - - 1 - - - - - true - - analytics_subscription_checkbox - - - - - - Learn more.]]> - - 1 - 0 - - - - - - -
-
- - - actionCancel - - - - - - - - - - - - - - - advanced-reports-subscription-text - Advanced Reporting in included, - free of charge, in your Magento software. When you opt out, we collect no product, order, and - customer data to generate our dynamic reports.

To opt in later: You can always turn on Advanced - Reporting in you Admin Panel.

]]>
-
-
-
-
-
diff --git a/app/code/Magento/Analytics/view/adminhtml/web/js/modal/modal-component.js b/app/code/Magento/Analytics/view/adminhtml/web/js/modal/modal-component.js deleted file mode 100644 index 9dee8d0c8e9ce..0000000000000 --- a/app/code/Magento/Analytics/view/adminhtml/web/js/modal/modal-component.js +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -define([ - 'jquery', - 'Magento_Ui/js/modal/modal-component', - 'Magento_Ui/js/modal/alert', - 'mage/translate' -], function ($, Modal, alert, $t) { - 'use strict'; - - return Modal.extend({ - defaults: { - postponeOptions: {}, - imports: { - postponeUrl: '${ $.provider }:postpone_url' - }, - modules: { - form: '${ $.parentName }' - } - }, - - /** - * Send request to postpone modal appearance for a certain time. - * - * @param {Object} options - additional request options. - */ - sendPostponeRequest: function (options) { - var self = this, - data = $.extend(this.form().source.data, options); - - $.ajax({ - type: 'POST', - url: this.postponeUrl, - data: data, - showLoader: true - }).done(function (xhr) { - if (xhr.error) { - self.onError(xhr); - } - }).fail(this.onError); - }, - - /** - * Error handler. - * - * @param {Object} xhr - request result. - */ - onError: function (xhr) { - if (xhr.statusText === 'abort') { - return; - } - - alert({ - content: xhr.message || $t('An error occurred while subscription process.') - }); - }, - - /** @inheritdoc */ - actionCancel: function () { - this.sendPostponeRequest(this.postponeOptions); - this.closeModal(); - } - }); -}); diff --git a/app/code/Magento/Analytics/view/adminhtml/web/template/buttons-container.html b/app/code/Magento/Analytics/view/adminhtml/web/template/buttons-container.html deleted file mode 100644 index 784e16d72c3f5..0000000000000 --- a/app/code/Magento/Analytics/view/adminhtml/web/template/buttons-container.html +++ /dev/null @@ -1,13 +0,0 @@ - -
- - -
- -
-
diff --git a/app/code/Magento/Analytics/view/adminhtml/web/template/form/components/single/checkbox.html b/app/code/Magento/Analytics/view/adminhtml/web/template/form/components/single/checkbox.html deleted file mode 100644 index 297867c60c1e4..0000000000000 --- a/app/code/Magento/Analytics/view/adminhtml/web/template/form/components/single/checkbox.html +++ /dev/null @@ -1,17 +0,0 @@ - -
- - -
diff --git a/app/code/Magento/Authorization/Model/Acl/AclRetriever.php b/app/code/Magento/Authorization/Model/Acl/AclRetriever.php index 0dd23ab55f693..f22cbaf46332b 100644 --- a/app/code/Magento/Authorization/Model/Acl/AclRetriever.php +++ b/app/code/Magento/Authorization/Model/Acl/AclRetriever.php @@ -24,16 +24,24 @@ class AclRetriever const PERMISSION_ANONYMOUS = 'anonymous'; const PERMISSION_SELF = 'self'; - /** @var Logger */ + /** + * @var \Psr\Log\LoggerInterface + */ protected $logger; - /** @var RulesCollectionFactory */ + /** + * @var \Magento\Authorization\Model\ResourceModel\Rules\CollectionFactory + */ protected $rulesCollectionFactory; - /** @var AclBuilder */ + /** + * @var \Magento\Framework\Acl\Builder + */ protected $aclBuilder; - /** @var RoleCollectionFactory */ + /** + * @var \Magento\Authorization\Model\ResourceModel\Role\CollectionFactory + */ protected $roleCollectionFactory; /** diff --git a/app/code/Magento/Authorization/Model/CompositeUserContext.php b/app/code/Magento/Authorization/Model/CompositeUserContext.php index 1f98631188307..7678b7e639e13 100644 --- a/app/code/Magento/Authorization/Model/CompositeUserContext.php +++ b/app/code/Magento/Authorization/Model/CompositeUserContext.php @@ -15,6 +15,7 @@ * Instead, it will try to find the first suitable child and return its result. * * @api + * @since 100.0.2 */ class CompositeUserContext implements \Magento\Authorization\Model\UserContextInterface { diff --git a/app/code/Magento/Authorization/Model/ResourceModel/Permissions/Collection.php b/app/code/Magento/Authorization/Model/ResourceModel/Permissions/Collection.php index 997687868da62..978848914384d 100644 --- a/app/code/Magento/Authorization/Model/ResourceModel/Permissions/Collection.php +++ b/app/code/Magento/Authorization/Model/ResourceModel/Permissions/Collection.php @@ -8,7 +8,7 @@ /** * Admin permissions collection * - * @deprecated + * @deprecated 100.2.0 * @see \Magento\Authorization\Model\ResourceModel\Rules\Collection */ class Collection extends \Magento\Authorization\Model\ResourceModel\Rules\Collection diff --git a/app/code/Magento/Authorization/Model/ResourceModel/Role/Collection.php b/app/code/Magento/Authorization/Model/ResourceModel/Role/Collection.php index 18f932d2732d0..d9eb499d17dab 100644 --- a/app/code/Magento/Authorization/Model/ResourceModel/Role/Collection.php +++ b/app/code/Magento/Authorization/Model/ResourceModel/Role/Collection.php @@ -11,6 +11,7 @@ * Admin role collection * * @api + * @since 100.0.2 */ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { diff --git a/app/code/Magento/Authorization/Model/ResourceModel/Rules/Collection.php b/app/code/Magento/Authorization/Model/ResourceModel/Rules/Collection.php index d90cdfd1df6d7..54d3909ff3d9c 100644 --- a/app/code/Magento/Authorization/Model/ResourceModel/Rules/Collection.php +++ b/app/code/Magento/Authorization/Model/ResourceModel/Rules/Collection.php @@ -9,6 +9,7 @@ * Rules collection * * @api + * @since 100.0.2 */ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { diff --git a/app/code/Magento/Authorization/Model/Role.php b/app/code/Magento/Authorization/Model/Role.php index ab6e180762ef1..2546df86d09dd 100644 --- a/app/code/Magento/Authorization/Model/Role.php +++ b/app/code/Magento/Authorization/Model/Role.php @@ -9,8 +9,6 @@ * Admin Role Model * * @api - * @method \Magento\Authorization\Model\ResourceModel\Role _getResource() - * @method \Magento\Authorization\Model\ResourceModel\Role getResource() * @method int getParentId() * @method \Magento\Authorization\Model\Role setParentId(int $value) * @method int getTreeLevel() @@ -26,6 +24,7 @@ * @method string getRoleName() * @method \Magento\Authorization\Model\Role setRoleName(string $value) * @api + * @since 100.0.2 */ class Role extends \Magento\Framework\Model\AbstractModel { diff --git a/app/code/Magento/Authorization/Model/Rules.php b/app/code/Magento/Authorization/Model/Rules.php index 77ca82e059ca8..07ce8e57e3933 100644 --- a/app/code/Magento/Authorization/Model/Rules.php +++ b/app/code/Magento/Authorization/Model/Rules.php @@ -9,8 +9,6 @@ /** * Admin Rules Model * - * @method \Magento\Authorization\Model\ResourceModel\Rules _getResource() - * @method \Magento\Authorization\Model\ResourceModel\Rules getResource() * @method int getRoleId() * @method \Magento\Authorization\Model\Rules setRoleId(int $value) * @method string getResourceId() @@ -22,6 +20,7 @@ * @method string getPermission() * @method \Magento\Authorization\Model\Rules setPermission(string $value) * @api + * @since 100.0.2 */ class Rules extends \Magento\Framework\Model\AbstractModel { diff --git a/app/code/Magento/Authorization/Model/UserContextInterface.php b/app/code/Magento/Authorization/Model/UserContextInterface.php index 2db9cec811651..a603e26ce1826 100644 --- a/app/code/Magento/Authorization/Model/UserContextInterface.php +++ b/app/code/Magento/Authorization/Model/UserContextInterface.php @@ -10,6 +10,7 @@ * Interface for current user identification. * * @api + * @since 100.0.2 */ interface UserContextInterface { diff --git a/app/code/Magento/Authorization/Test/Unit/Model/Acl/AclRetrieverTest.php b/app/code/Magento/Authorization/Test/Unit/Model/Acl/AclRetrieverTest.php index 2b199c29dd604..bd1a3616a746e 100644 --- a/app/code/Magento/Authorization/Test/Unit/Model/Acl/AclRetrieverTest.php +++ b/app/code/Magento/Authorization/Test/Unit/Model/Acl/AclRetrieverTest.php @@ -6,7 +6,7 @@ namespace Magento\Authorization\Test\Unit\Model\Acl; -use \Magento\Authorization\Model\Acl\AclRetriever; +use Magento\Authorization\Model\Acl\AclRetriever; use Magento\Authorization\Model\ResourceModel\Role\Collection as RoleCollection; use Magento\Authorization\Model\ResourceModel\Role\CollectionFactory as RoleCollectionFactory; @@ -18,7 +18,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class AclRetrieverTest extends \PHPUnit_Framework_TestCase +class AclRetrieverTest extends \PHPUnit\Framework\TestCase { /** * @var AclRetriever @@ -80,65 +80,44 @@ public function testGetAllowedResourcesByUser() protected function createAclRetriever() { - $this->roleMock = $this->getMock( - \Magento\Authorization\Model\Role::class, - ['getId', '__wakeup'], - [], - '', - false - ); + $this->roleMock = $this->createPartialMock(\Magento\Authorization\Model\Role::class, ['getId', '__wakeup']); /** @var \PHPUnit_Framework_MockObject_MockObject|RoleCollection $roleCollectionMock */ - $roleCollectionMock = $this->getMock( + $roleCollectionMock = $this->createPartialMock( \Magento\Authorization\Model\ResourceModel\Role\Collection::class, - ['setUserFilter', 'getFirstItem'], - [], - '', - false + ['setUserFilter', 'getFirstItem'] ); $roleCollectionMock->expects($this->any())->method('setUserFilter')->will($this->returnSelf()); $roleCollectionMock->expects($this->any())->method('getFirstItem')->will($this->returnValue($this->roleMock)); /** @var \PHPUnit_Framework_MockObject_MockObject|RoleCollectionFactory $roleCollectionFactoryMock */ - $roleCollectionFactoryMock = $this->getMock( + $roleCollectionFactoryMock = $this->createPartialMock( \Magento\Authorization\Model\ResourceModel\Role\CollectionFactory::class, - ['create'], - [], - '', - false + ['create'] ); $roleCollectionFactoryMock->expects($this->any())->method('create')->will( $this->returnValue($roleCollectionMock) ); /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Authorization\Model\Rules $rulesMock1 */ - $rulesMock1 = $this->getMock( + $rulesMock1 = $this->createPartialMock( \Magento\Authorization\Model\Rules::class, - ['getResourceId', '__wakeup'], - [], - '', - false + ['getResourceId', '__wakeup'] ); $rulesMock1->expects($this->any())->method('getResourceId')->will( $this->returnValue('Magento_Backend::dashboard') ); /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Authorization\Model\Rules $rulesMock1 */ - $rulesMock2 = $this->getMock( + $rulesMock2 = $this->createPartialMock( \Magento\Authorization\Model\Rules::class, - ['getResourceId', '__wakeup'], - [], - '', - false + ['getResourceId', '__wakeup'] ); $rulesMock2->expects($this->any())->method('getResourceId')->will($this->returnValue('Magento_Cms::page')); /** @var \PHPUnit_Framework_MockObject_MockObject|RulesCollection $rulesCollectionMock */ - $rulesCollectionMock = $this->getMock( + $rulesCollectionMock = $this->createPartialMock( \Magento\Authorization\Model\ResourceModel\Rules\Collection::class, - ['getByRoles', 'load', 'getItems'], - [], - '', - false + ['getByRoles', 'load', 'getItems'] ); $rulesCollectionMock->expects($this->any())->method('getByRoles')->will($this->returnSelf()); $rulesCollectionMock->expects($this->any())->method('load')->will($this->returnSelf()); @@ -147,31 +126,28 @@ protected function createAclRetriever() ); /** @var \PHPUnit_Framework_MockObject_MockObject|RulesCollectionFactory $rulesCollectionFactoryMock */ - $rulesCollectionFactoryMock = $this->getMock( + $rulesCollectionFactoryMock = $this->createPartialMock( \Magento\Authorization\Model\ResourceModel\Rules\CollectionFactory::class, - ['create'], - [], - '', - false + ['create'] ); $rulesCollectionFactoryMock->expects($this->any())->method('create')->will( $this->returnValue($rulesCollectionMock) ); /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Acl $aclMock */ - $aclMock = $this->getMock(\Magento\Framework\Acl::class, ['has', 'isAllowed'], [], '', false); + $aclMock = $this->createPartialMock(\Magento\Framework\Acl::class, ['has', 'isAllowed']); $aclMock->expects($this->any())->method('has')->will($this->returnValue(true)); $aclMock->expects($this->any())->method('isAllowed')->will($this->returnValue(true)); /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Acl\Builder $aclBuilderMock */ - $aclBuilderMock = $this->getMock(\Magento\Framework\Acl\Builder::class, ['getAcl'], [], '', false); + $aclBuilderMock = $this->createPartialMock(\Magento\Framework\Acl\Builder::class, ['getAcl']); $aclBuilderMock->expects($this->any())->method('getAcl')->will($this->returnValue($aclMock)); return new AclRetriever( $aclBuilderMock, $roleCollectionFactoryMock, $rulesCollectionFactoryMock, - $this->getMock(\Psr\Log\LoggerInterface::class) + $this->createMock(\Psr\Log\LoggerInterface::class) ); } } diff --git a/app/code/Magento/Authorization/Test/Unit/Model/Acl/Loader/RoleTest.php b/app/code/Magento/Authorization/Test/Unit/Model/Acl/Loader/RoleTest.php index 2bdc0c540eb35..a5ae7f8e86a6e 100644 --- a/app/code/Magento/Authorization/Test/Unit/Model/Acl/Loader/RoleTest.php +++ b/app/code/Magento/Authorization/Test/Unit/Model/Acl/Loader/RoleTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Authorization\Test\Unit\Model\Acl\Loader; -class RoleTest extends \PHPUnit_Framework_TestCase +class RoleTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Authorization\Model\Acl\Loader\Role @@ -49,42 +49,26 @@ class RoleTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_resourceMock = $this->getMock( - \Magento\Framework\App\ResourceConnection::class, - [], - [], - '', - false, - false - ); - $this->_groupFactoryMock = $this->getMock( - \Magento\Authorization\Model\Acl\Role\GroupFactory::class, - ['create'], - [], - '', - false - ); - $this->_roleFactoryMock = $this->getMock( - \Magento\Authorization\Model\Acl\Role\UserFactory::class, - ['create'], - [], - '', - false - ); - - $this->selectMock = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); + $this->_resourceMock = $this->createMock(\Magento\Framework\App\ResourceConnection::class); + $this->_groupFactoryMock = $this->getMockBuilder(\Magento\Authorization\Model\Acl\Role\GroupFactory::class) + ->setMethods(['create', 'getModelInstance']) + ->disableOriginalConstructor() + ->getMock(); + $this->_roleFactoryMock = $this->getMockBuilder(\Magento\Authorization\Model\Acl\Role\UserFactory::class) + ->setMethods(['create', 'getModelInstance']) + ->disableOriginalConstructor() + ->getMock(); + + $this->selectMock = $this->createMock(\Magento\Framework\DB\Select::class); $this->selectMock->expects($this->any()) ->method('from') ->will($this->returnValue($this->selectMock)); - $this->_adapterMock = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false); + $this->_adapterMock = $this->createMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class); - $this->serializerMock = $this->getMock( + $this->serializerMock = $this->createPartialMock( \Magento\Framework\Serialize\Serializer\Json::class, - ['serialize', 'unserialize'], - [], - '', - false + ['serialize', 'unserialize'] ); $this->serializerMock->expects($this->any()) ->method('serialize') @@ -106,13 +90,7 @@ function ($value) { ) ); - $this->aclDataCacheMock = $this->getMock( - \Magento\Framework\Acl\Data\CacheInterface::class, - [], - [], - '', - false - ); + $this->aclDataCacheMock = $this->createMock(\Magento\Framework\Acl\Data\CacheInterface::class); $this->_model = new \Magento\Authorization\Model\Acl\Loader\Role( $this->_groupFactoryMock, @@ -152,7 +130,7 @@ public function testPopulateAclAddsRolesAndTheirChildren() $this->_groupFactoryMock->expects($this->once())->method('create')->with(['roleId' => '1']); $this->_roleFactoryMock->expects($this->once())->method('create')->with(['roleId' => '2']); - $aclMock = $this->getMock(\Magento\Framework\Acl::class); + $aclMock = $this->createMock(\Magento\Framework\Acl::class); $aclMock->expects($this->at(0))->method('addRole')->with($this->anything(), null); $aclMock->expects($this->at(2))->method('addRole')->with($this->anything(), '1'); @@ -181,7 +159,7 @@ public function testPopulateAclAddsMultipleParents() $this->_roleFactoryMock->expects($this->never())->method('getModelInstance'); $this->_groupFactoryMock->expects($this->never())->method('getModelInstance'); - $aclMock = $this->getMock(\Magento\Framework\Acl::class); + $aclMock = $this->createMock(\Magento\Framework\Acl::class); $aclMock->expects($this->at(0))->method('hasRole')->with('1')->will($this->returnValue(true)); $aclMock->expects($this->at(1))->method('addRoleParent')->with('1', '2'); @@ -214,7 +192,7 @@ public function testPopulateAclFromCache() $this->_roleFactoryMock->expects($this->never())->method('getModelInstance'); $this->_groupFactoryMock->expects($this->never())->method('getModelInstance'); - $aclMock = $this->getMock(\Magento\Framework\Acl::class); + $aclMock = $this->createMock(\Magento\Framework\Acl::class); $aclMock->expects($this->at(0))->method('hasRole')->with('1')->will($this->returnValue(true)); $aclMock->expects($this->at(1))->method('addRoleParent')->with('1', '2'); diff --git a/app/code/Magento/Authorization/Test/Unit/Model/Acl/Loader/RuleTest.php b/app/code/Magento/Authorization/Test/Unit/Model/Acl/Loader/RuleTest.php index ceea540d0b0d9..51801e1842eff 100644 --- a/app/code/Magento/Authorization/Test/Unit/Model/Acl/Loader/RuleTest.php +++ b/app/code/Magento/Authorization/Test/Unit/Model/Acl/Loader/RuleTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Authorization\Test\Unit\Model\Acl\Loader; -class RuleTest extends \PHPUnit_Framework_TestCase +class RuleTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Authorization\Model\Acl\Loader\Rule @@ -34,20 +34,13 @@ class RuleTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_resourceMock = $this->getMock( + $this->_resourceMock = $this->createPartialMock( \Magento\Framework\App\ResourceConnection::class, - [], - [], - '', - false, - false + ['getTable', 'getConnection'] ); - $this->serializerMock = $this->getMock( + $this->serializerMock = $this->createPartialMock( \Magento\Framework\Serialize\Serializer\Json::class, - ['serialize', 'unserialize'], - [], - '', - false + ['serialize', 'unserialize'] ); $this->serializerMock->expects($this->any()) ->method('serialize') @@ -69,13 +62,7 @@ function ($value) { ) ); - $this->aclDataCacheMock = $this->getMock( - \Magento\Framework\Acl\Data\CacheInterface::class, - [], - [], - '', - false - ); + $this->aclDataCacheMock = $this->createMock(\Magento\Framework\Acl\Data\CacheInterface::class); $this->_rootResourceMock = new \Magento\Framework\Acl\RootResource('Magento_Backend::all'); $this->_model = new \Magento\Authorization\Model\Acl\Loader\Rule( @@ -108,7 +95,7 @@ public function testPopulateAclFromCache() ) ); - $aclMock = $this->getMock(\Magento\Framework\Acl::class); + $aclMock = $this->createMock(\Magento\Framework\Acl::class); $aclMock->expects($this->any())->method('has')->will($this->returnValue(true)); $aclMock->expects($this->at(1))->method('allow')->with('1', null, null); $aclMock->expects($this->at(2))->method('allow')->with('1', 'Magento_Backend::all', null); diff --git a/app/code/Magento/Authorization/Test/Unit/Model/CompositeUserContextTest.php b/app/code/Magento/Authorization/Test/Unit/Model/CompositeUserContextTest.php index 856f96411cbd0..47da868f17190 100644 --- a/app/code/Magento/Authorization/Test/Unit/Model/CompositeUserContextTest.php +++ b/app/code/Magento/Authorization/Test/Unit/Model/CompositeUserContextTest.php @@ -11,7 +11,7 @@ use Magento\Framework\ObjectManager\Helper\Composite as CompositeHelper; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class CompositeUserContextTest extends \PHPUnit_Framework_TestCase +class CompositeUserContextTest extends \PHPUnit\Framework\TestCase { /** * @var CompositeUserContext diff --git a/app/code/Magento/Authorization/Test/Unit/Model/ResourceModel/RulesTest.php b/app/code/Magento/Authorization/Test/Unit/Model/ResourceModel/RulesTest.php index a9cd3119b62d7..260691608537e 100644 --- a/app/code/Magento/Authorization/Test/Unit/Model/ResourceModel/RulesTest.php +++ b/app/code/Magento/Authorization/Test/Unit/Model/ResourceModel/RulesTest.php @@ -14,7 +14,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class RulesTest extends \PHPUnit_Framework_TestCase +class RulesTest extends \PHPUnit\Framework\TestCase { /** * Test constants diff --git a/app/code/Magento/Authorizenet/Block/Adminhtml/Order/View/Info/FraudDetails.php b/app/code/Magento/Authorizenet/Block/Adminhtml/Order/View/Info/FraudDetails.php index ca2bc286d38a8..a7a670d64d7ce 100644 --- a/app/code/Magento/Authorizenet/Block/Adminhtml/Order/View/Info/FraudDetails.php +++ b/app/code/Magento/Authorizenet/Block/Adminhtml/Order/View/Info/FraudDetails.php @@ -9,6 +9,7 @@ /** * @api + * @since 100.0.2 */ class FraudDetails extends \Magento\Backend\Block\Template { diff --git a/app/code/Magento/Authorizenet/Block/Transparent/Iframe.php b/app/code/Magento/Authorizenet/Block/Transparent/Iframe.php index 1c8fb9ee29988..296d22d6f61b2 100644 --- a/app/code/Magento/Authorizenet/Block/Transparent/Iframe.php +++ b/app/code/Magento/Authorizenet/Block/Transparent/Iframe.php @@ -9,6 +9,7 @@ /** * @api + * @since 100.0.2 */ class Iframe extends TransparentIframe { diff --git a/app/code/Magento/Authorizenet/Controller/Directpost/Payment/BackendResponse.php b/app/code/Magento/Authorizenet/Controller/Directpost/Payment/BackendResponse.php index 5d9ac20869fe1..3ad9f470909bf 100644 --- a/app/code/Magento/Authorizenet/Controller/Directpost/Payment/BackendResponse.php +++ b/app/code/Magento/Authorizenet/Controller/Directpost/Payment/BackendResponse.php @@ -6,8 +6,48 @@ */ namespace Magento\Authorizenet\Controller\Directpost\Payment; +use Magento\Authorizenet\Helper\DataFactory; +use Magento\Authorizenet\Model\Directpost; +use Magento\Authorizenet\Model\DirectpostFactory; +use Magento\Framework\App\Action\Context; +use Magento\Framework\Controller\ResultFactory; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Registry; +use Psr\Log\LoggerInterface; + class BackendResponse extends \Magento\Authorizenet\Controller\Directpost\Payment { + /** + * @var LoggerInterface + */ + private $logger; + + /** + * @var DirectpostFactory + */ + private $directpostFactory; + + /** + * BackendResponse constructor. + * + * @param Context $context + * @param Registry $coreRegistry + * @param DataFactory $dataFactory + * @param DirectpostFactory $directpostFactory + * @param LoggerInterface|null $logger + */ + public function __construct( + Context $context, + Registry $coreRegistry, + DataFactory $dataFactory, + DirectpostFactory $directpostFactory, + LoggerInterface $logger = null + ) { + parent::__construct($context, $coreRegistry, $dataFactory); + $this->directpostFactory = $directpostFactory ?: $this->_objectManager->create(DirectpostFactory::class); + $this->logger = $logger ?: $this->_objectManager->get(LoggerInterface::class); + } + /** * Response action. * Action for Authorize.net SIM Relay Request. @@ -16,7 +56,20 @@ class BackendResponse extends \Magento\Authorizenet\Controller\Directpost\Paymen */ public function execute() { + $data = $this->getRequest()->getParams(); + /** @var Directpost $paymentMethod */ + $paymentMethod = $this->directpostFactory->create(); + if (!empty($data['store_id'])) { + $paymentMethod->setStore($data['store_id']); + } + $paymentMethod->setResponseData($data); + try { + $paymentMethod->validateResponse(); + } catch (LocalizedException $e) { + $this->logger->critical($e->getMessage()); + return $this->_redirect('noroute'); + } $this->_responseAction('adminhtml'); - return $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_PAGE); + return $this->resultFactory->create(ResultFactory::TYPE_PAGE); } } diff --git a/app/code/Magento/Authorizenet/Helper/Backend/Data.php b/app/code/Magento/Authorizenet/Helper/Backend/Data.php index c95806a524fac..24bdb23873265 100644 --- a/app/code/Magento/Authorizenet/Helper/Backend/Data.php +++ b/app/code/Magento/Authorizenet/Helper/Backend/Data.php @@ -15,6 +15,7 @@ * Authorize.net Backend Data Helper * * @api + * @since 100.0.2 */ class Data extends FrontendDataHelper { diff --git a/app/code/Magento/Authorizenet/Helper/Data.php b/app/code/Magento/Authorizenet/Helper/Data.php index 7de71d8ed11e4..8bcc1f3f3f03c 100644 --- a/app/code/Magento/Authorizenet/Helper/Data.php +++ b/app/code/Magento/Authorizenet/Helper/Data.php @@ -16,6 +16,7 @@ * Authorize.net Data Helper * * @api + * @since 100.0.2 */ class Data extends AbstractHelper { diff --git a/app/code/Magento/Authorizenet/Model/Debug.php b/app/code/Magento/Authorizenet/Model/Debug.php index 9c7bd352c58ca..255c2e3aba444 100644 --- a/app/code/Magento/Authorizenet/Model/Debug.php +++ b/app/code/Magento/Authorizenet/Model/Debug.php @@ -6,8 +6,6 @@ namespace Magento\Authorizenet\Model; /** - * @method \Magento\Authorizenet\Model\ResourceModel\Debug _getResource() - * @method \Magento\Authorizenet\Model\ResourceModel\Debug getResource() * @method string getRequestBody() * @method \Magento\Authorizenet\Model\Debug setRequestBody(string $value) * @method string getResponseBody() diff --git a/app/code/Magento/Authorizenet/Model/Directpost.php b/app/code/Magento/Authorizenet/Model/Directpost.php index f9a12a25fe781..0f10fd633cb5b 100644 --- a/app/code/Magento/Authorizenet/Model/Directpost.php +++ b/app/code/Magento/Authorizenet/Model/Directpost.php @@ -983,7 +983,7 @@ protected function getTransactionResponse($transactionId) /** * @return \Psr\Log\LoggerInterface * - * @deprecated + * @deprecated 100.1.0 */ private function getPsrLogger() { diff --git a/app/code/Magento/Authorizenet/Test/Unit/Controller/Adminhtml/Authorizenet/Directpost/Payment/RedirectTest.php b/app/code/Magento/Authorizenet/Test/Unit/Controller/Adminhtml/Authorizenet/Directpost/Payment/RedirectTest.php index 016293e827824..b26c9bf22f153 100644 --- a/app/code/Magento/Authorizenet/Test/Unit/Controller/Adminhtml/Authorizenet/Directpost/Payment/RedirectTest.php +++ b/app/code/Magento/Authorizenet/Test/Unit/Controller/Adminhtml/Authorizenet/Directpost/Payment/RedirectTest.php @@ -14,7 +14,7 @@ * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class RedirectTest extends \PHPUnit_Framework_TestCase +class RedirectTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Authorizenet\Model\Directpost @@ -107,7 +107,7 @@ protected function setUp() ]) ->disableOriginalConstructor() ->getMock(); - $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); $this->orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class) ->setMethods(['getId', 'getState', 'getIncrementId', 'registerCancellation', 'loadByIncrementId', 'save']) ->disableOriginalConstructor() @@ -139,8 +139,8 @@ protected function setUp() ->setMethods(['getParams']) ->getMockForAbstractClass(); $responseMock = $this->getMockForAbstractClass(\Magento\Framework\App\ResponseInterface::class); - $redirectMock = $this->getMock(\Magento\Framework\App\Response\RedirectInterface::class); - $this->messageManagerMock = $this->getMock(\Magento\Framework\Message\ManagerInterface::class); + $redirectMock = $this->createMock(\Magento\Framework\App\Response\RedirectInterface::class); + $this->messageManagerMock = $this->createMock(\Magento\Framework\Message\ManagerInterface::class); $this->contextMock = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class) ->setMethods(['getObjectManager', 'getRequest', 'getResponse', 'getRedirect', 'getMessageManager']) diff --git a/app/code/Magento/Authorizenet/Test/Unit/Controller/Directpost/Payment/PlaceTest.php b/app/code/Magento/Authorizenet/Test/Unit/Controller/Directpost/Payment/PlaceTest.php index 3a011783abfe3..95ceed1ee11e7 100644 --- a/app/code/Magento/Authorizenet/Test/Unit/Controller/Directpost/Payment/PlaceTest.php +++ b/app/code/Magento/Authorizenet/Test/Unit/Controller/Directpost/Payment/PlaceTest.php @@ -28,7 +28,7 @@ * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class PlaceTest extends \PHPUnit_Framework_TestCase +class PlaceTest extends \PHPUnit\Framework\TestCase { /** * @var ObjectManager diff --git a/app/code/Magento/Authorizenet/Test/Unit/Controller/Directpost/Payment/RedirectTest.php b/app/code/Magento/Authorizenet/Test/Unit/Controller/Directpost/Payment/RedirectTest.php index f959aa8a51530..0801d3c020119 100644 --- a/app/code/Magento/Authorizenet/Test/Unit/Controller/Directpost/Payment/RedirectTest.php +++ b/app/code/Magento/Authorizenet/Test/Unit/Controller/Directpost/Payment/RedirectTest.php @@ -16,7 +16,7 @@ /** * Class RedirectTest */ -class RedirectTest extends \PHPUnit_Framework_TestCase +class RedirectTest extends \PHPUnit\Framework\TestCase { /** * @var RequestInterface|MockObject diff --git a/app/code/Magento/Authorizenet/Test/Unit/Helper/Backend/DataTest.php b/app/code/Magento/Authorizenet/Test/Unit/Helper/Backend/DataTest.php index 136ffc19d55b7..14ecd7debc972 100644 --- a/app/code/Magento/Authorizenet/Test/Unit/Helper/Backend/DataTest.php +++ b/app/code/Magento/Authorizenet/Test/Unit/Helper/Backend/DataTest.php @@ -8,7 +8,7 @@ /** * Class DataTest */ -class DataTest extends \PHPUnit_Framework_TestCase +class DataTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Authorizenet\Helper\Backend\Data @@ -34,15 +34,15 @@ protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->urlBuilderMock = $this->getMock(\Magento\Backend\Model\Url::class, ['getUrl'], [], '', false); + $this->urlBuilderMock = $this->createPartialMock(\Magento\Backend\Model\Url::class, ['getUrl']); - $contextMock = $this->getMock(\Magento\Framework\App\Helper\Context::class, [], [], '', false); + $contextMock = $this->createMock(\Magento\Framework\App\Helper\Context::class); $contextMock->expects($this->any()) ->method('getUrlBuilder') ->willReturn($this->urlBuilderMock); - $this->orderFactoryMock = $this->getMock(\Magento\Sales\Model\OrderFactory::class, ['create'], [], '', false); - $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); + $this->orderFactoryMock = $this->createPartialMock(\Magento\Sales\Model\OrderFactory::class, ['create']); + $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManager::class); $this->dataHelper = $helper->getObject( \Magento\Authorizenet\Helper\Backend\Data::class, @@ -67,12 +67,9 @@ public function testGetPlaceOrderAdminUrl() public function testGetSuccessOrderUrl() { - $orderMock = $this->getMock( + $orderMock = $this->createPartialMock( \Magento\Sales\Model\Order::class, - ['loadByIncrementId', 'getId', '__wakeup'], - [], - '', - false + ['loadByIncrementId', 'getId', '__wakeup'] ); $orderMock->expects($this->once()) ->method('loadByIncrementId') diff --git a/app/code/Magento/Authorizenet/Test/Unit/Helper/DataTest.php b/app/code/Magento/Authorizenet/Test/Unit/Helper/DataTest.php index a0ec6aaa01335..28dd5f866a609 100644 --- a/app/code/Magento/Authorizenet/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Authorizenet/Test/Unit/Helper/DataTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Authorizenet\Test\Unit\Helper; -class DataTest extends \PHPUnit_Framework_TestCase +class DataTest extends \PHPUnit\Framework\TestCase { /** * Last 4 digit of cc @@ -50,15 +50,15 @@ protected function setUp() */ public function testGetTransactionMessage($type, $amount, $exception, $additionalMessage, $expected) { - $currency = $this->getMock(\Magento\Directory\Model\Currency::class, ['formatTxt', '__wakeup'], [], '', false); + $currency = $this->createPartialMock(\Magento\Directory\Model\Currency::class, ['formatTxt', '__wakeup']); $currency->expects($this->any()) ->method('formatTxt') ->will($this->returnValue($amount)); - $order = $this->getMock(\Magento\Sales\Model\Order::class, ['getBaseCurrency', '__wakeup'], [], '', false); + $order = $this->createPartialMock(\Magento\Sales\Model\Order::class, ['getBaseCurrency', '__wakeup']); $order->expects($this->any()) ->method('getBaseCurrency') ->will($this->returnValue($currency)); - $payment = $this->getMock(\Magento\Payment\Model\Info::class, ['getOrder', '__wakeup'], [], '', false); + $payment = $this->createPartialMock(\Magento\Payment\Model\Info::class, ['getOrder', '__wakeup']); $payment->expects($this->any()) ->method('getOrder') ->will($this->returnValue($order)); diff --git a/app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/Request/FactoryTest.php b/app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/Request/FactoryTest.php index 7324ea5abddee..99f2729fcdddf 100644 --- a/app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/Request/FactoryTest.php +++ b/app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/Request/FactoryTest.php @@ -7,7 +7,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class FactoryTest extends \PHPUnit_Framework_TestCase +class FactoryTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Authorizenet\Model\Directpost\Request\Factory @@ -28,9 +28,9 @@ protected function setUp() { $objectManager = new ObjectManager($this); - $this->requestMock = $this->getMock(\Magento\Authorizenet\Model\Directpost\Request::class, [], [], '', false); + $this->requestMock = $this->createMock(\Magento\Authorizenet\Model\Directpost\Request::class); - $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class, [], [], '', false); + $this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); $this->objectManagerMock->expects($this->once()) ->method('create') ->with(\Magento\Authorizenet\Model\Directpost\Request::class, []) diff --git a/app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/Response/FactoryTest.php b/app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/Response/FactoryTest.php index ed70f10aedfdd..bf59a73c14940 100644 --- a/app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/Response/FactoryTest.php +++ b/app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/Response/FactoryTest.php @@ -7,7 +7,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class FactoryTest extends \PHPUnit_Framework_TestCase +class FactoryTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Authorizenet\Model\Directpost\Response\Factory @@ -28,9 +28,9 @@ protected function setUp() { $objectManager = new ObjectManager($this); - $this->responseMock = $this->getMock(\Magento\Authorizenet\Model\Directpost\Response::class, [], [], '', false); + $this->responseMock = $this->createMock(\Magento\Authorizenet\Model\Directpost\Response::class); - $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class, [], [], '', false); + $this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); $this->objectManagerMock->expects($this->once()) ->method('create') ->with(\Magento\Authorizenet\Model\Directpost\Response::class, []) diff --git a/app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/ResponseTest.php b/app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/ResponseTest.php index 05c2a051d4738..6e5d55e52675e 100644 --- a/app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/ResponseTest.php +++ b/app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/ResponseTest.php @@ -8,7 +8,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Authorizenet\Model\Directpost; -class ResponseTest extends \PHPUnit_Framework_TestCase +class ResponseTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Authorizenet\Model\Directpost\Response diff --git a/app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/SessionTest.php b/app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/SessionTest.php index db0731cc12fed..35f7a4e15219c 100644 --- a/app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/SessionTest.php +++ b/app/code/Magento/Authorizenet/Test/Unit/Model/Directpost/SessionTest.php @@ -9,7 +9,7 @@ use Magento\Framework\Session\StorageInterface; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class SessionTest extends \PHPUnit_Framework_TestCase +class SessionTest extends \PHPUnit\Framework\TestCase { /** * @var ObjectManager diff --git a/app/code/Magento/Authorizenet/Test/Unit/Model/DirectpostTest.php b/app/code/Magento/Authorizenet/Test/Unit/Model/DirectpostTest.php index ff643890f26be..dbb6ac8333c14 100644 --- a/app/code/Magento/Authorizenet/Test/Unit/Model/DirectpostTest.php +++ b/app/code/Magento/Authorizenet/Test/Unit/Model/DirectpostTest.php @@ -18,7 +18,7 @@ * Class DirectpostTest * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class DirectpostTest extends \PHPUnit_Framework_TestCase +class DirectpostTest extends \PHPUnit\Framework\TestCase { const TOTAL_AMOUNT = 100.02; const INVOICE_NUM = '00000001'; @@ -657,7 +657,7 @@ private function getTransactionXmlDocument( /** * Get mock for authorize.net request factory - * @return \PHPUnit_Framework_MockObject_MockBuilder + * @return \PHPUnit\Framework\MockObject_MockBuilder */ private function getRequestFactoryMock() { diff --git a/app/code/Magento/Authorizenet/Test/Unit/Model/Request/FactoryTest.php b/app/code/Magento/Authorizenet/Test/Unit/Model/Request/FactoryTest.php index 9200d2e987ea1..4ac98238f9ed1 100644 --- a/app/code/Magento/Authorizenet/Test/Unit/Model/Request/FactoryTest.php +++ b/app/code/Magento/Authorizenet/Test/Unit/Model/Request/FactoryTest.php @@ -7,7 +7,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class FactoryTest extends \PHPUnit_Framework_TestCase +class FactoryTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Authorizenet\Model\Request\Factory @@ -28,9 +28,9 @@ protected function setUp() { $objectManager = new ObjectManager($this); - $this->requestMock = $this->getMock(\Magento\Authorizenet\Model\Request::class, [], [], '', false); + $this->requestMock = $this->createMock(\Magento\Authorizenet\Model\Request::class); - $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class, [], [], '', false); + $this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); $this->objectManagerMock->expects($this->once()) ->method('create') ->with(\Magento\Authorizenet\Model\Request::class, []) diff --git a/app/code/Magento/Authorizenet/Test/Unit/Model/Response/FactoryTest.php b/app/code/Magento/Authorizenet/Test/Unit/Model/Response/FactoryTest.php index 94a3dc39e7203..ddc4f28de8b81 100644 --- a/app/code/Magento/Authorizenet/Test/Unit/Model/Response/FactoryTest.php +++ b/app/code/Magento/Authorizenet/Test/Unit/Model/Response/FactoryTest.php @@ -7,7 +7,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class FactoryTest extends \PHPUnit_Framework_TestCase +class FactoryTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Authorizenet\Model\Response\Factory @@ -28,9 +28,9 @@ protected function setUp() { $objectManager = new ObjectManager($this); - $this->responseMock = $this->getMock(\Magento\Authorizenet\Model\Response::class, [], [], '', false); + $this->responseMock = $this->createMock(\Magento\Authorizenet\Model\Response::class); - $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class, [], [], '', false); + $this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); $this->objectManagerMock->expects($this->once()) ->method('create') ->with(\Magento\Authorizenet\Model\Response::class, []) diff --git a/app/code/Magento/Authorizenet/Test/Unit/Model/TransactionServiceTest.php b/app/code/Magento/Authorizenet/Test/Unit/Model/TransactionServiceTest.php index 7f6270dcf3a9b..092d633648482 100644 --- a/app/code/Magento/Authorizenet/Test/Unit/Model/TransactionServiceTest.php +++ b/app/code/Magento/Authorizenet/Test/Unit/Model/TransactionServiceTest.php @@ -9,7 +9,7 @@ use Magento\Framework\Simplexml\Element; use Magento\Authorizenet\Model\TransactionService; -class TransactionServiceTest extends \PHPUnit_Framework_TestCase +class TransactionServiceTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\HTTP\ZendClient|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Authorizenet/Test/Unit/Observer/AddFieldsToResponseObserverTest.php b/app/code/Magento/Authorizenet/Test/Unit/Observer/AddFieldsToResponseObserverTest.php index 55defc65262b2..d59d5eeaa5cae 100644 --- a/app/code/Magento/Authorizenet/Test/Unit/Observer/AddFieldsToResponseObserverTest.php +++ b/app/code/Magento/Authorizenet/Test/Unit/Observer/AddFieldsToResponseObserverTest.php @@ -12,7 +12,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class AddFieldsToResponseObserverTest extends \PHPUnit_Framework_TestCase +class AddFieldsToResponseObserverTest extends \PHPUnit\Framework\TestCase { /** * Core registry diff --git a/app/code/Magento/Backend/App/AbstractAction.php b/app/code/Magento/Backend/App/AbstractAction.php index 857b5e2a37f26..99ee86b2b6407 100644 --- a/app/code/Magento/Backend/App/AbstractAction.php +++ b/app/code/Magento/Backend/App/AbstractAction.php @@ -11,6 +11,7 @@ * @api * @SuppressWarnings(PHPMD.NumberOfChildren) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ abstract class AbstractAction extends \Magento\Framework\App\Action\Action { diff --git a/app/code/Magento/Backend/App/Action.php b/app/code/Magento/Backend/App/Action.php index 3acd60540a0ea..76d6fae58da54 100644 --- a/app/code/Magento/Backend/App/Action.php +++ b/app/code/Magento/Backend/App/Action.php @@ -12,6 +12,7 @@ /** * @api * @SuppressWarnings(PHPMD.NumberOfChildren) + * @since 100.0.2 */ abstract class Action extends \Magento\Backend\App\AbstractAction { diff --git a/app/code/Magento/Backend/App/Action/Context.php b/app/code/Magento/Backend/App/Action/Context.php index efa9c952ef788..a5941abefac1c 100644 --- a/app/code/Magento/Backend/App/Action/Context.php +++ b/app/code/Magento/Backend/App/Action/Context.php @@ -20,6 +20,7 @@ * * @api * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class Context extends \Magento\Framework\App\Action\Context { diff --git a/app/code/Magento/Backend/App/Area/FrontNameResolver.php b/app/code/Magento/Backend/App/Area/FrontNameResolver.php index 826e272ef5531..ed82c5a9c6e1e 100644 --- a/app/code/Magento/Backend/App/Area/FrontNameResolver.php +++ b/app/code/Magento/Backend/App/Area/FrontNameResolver.php @@ -15,6 +15,7 @@ /** * @api + * @since 100.0.2 */ class FrontNameResolver implements \Magento\Framework\App\Area\FrontNameResolverInterface { @@ -53,7 +54,9 @@ class FrontNameResolver implements \Magento\Framework\App\Area\FrontNameResolver */ protected $deploymentConfig; - /** @var ScopeConfigInterface */ + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface + */ private $scopeConfig; /** diff --git a/app/code/Magento/Backend/App/BackendApp.php b/app/code/Magento/Backend/App/BackendApp.php index 8c40b41ac35c7..5f8bf998cb12e 100644 --- a/app/code/Magento/Backend/App/BackendApp.php +++ b/app/code/Magento/Backend/App/BackendApp.php @@ -9,6 +9,7 @@ /** * Backend Application which uses Magento Backend authentication process * @api + * @since 100.0.2 */ class BackendApp { diff --git a/app/code/Magento/Backend/App/BackendAppList.php b/app/code/Magento/Backend/App/BackendAppList.php index ae5ec0284511f..01a36ce9b6b2b 100644 --- a/app/code/Magento/Backend/App/BackendAppList.php +++ b/app/code/Magento/Backend/App/BackendAppList.php @@ -9,6 +9,7 @@ /** * List of Backend Applications to allow injection of them through the DI * @api + * @since 100.0.2 */ class BackendAppList { diff --git a/app/code/Magento/Backend/App/ConfigInterface.php b/app/code/Magento/Backend/App/ConfigInterface.php index 375e14c723ac0..2c85a6fd052ad 100644 --- a/app/code/Magento/Backend/App/ConfigInterface.php +++ b/app/code/Magento/Backend/App/ConfigInterface.php @@ -10,6 +10,7 @@ /** * Backend config accessor * @api + * @since 100.0.2 */ interface ConfigInterface { @@ -27,7 +28,7 @@ public function getValue($path); /** * Set config value * - * @deprecated + * @deprecated 100.1.2 * @param string $path * @param mixed $value * @return void diff --git a/app/code/Magento/Backend/App/DefaultPath.php b/app/code/Magento/Backend/App/DefaultPath.php index a89ac8a024ab0..df8b718389741 100644 --- a/app/code/Magento/Backend/App/DefaultPath.php +++ b/app/code/Magento/Backend/App/DefaultPath.php @@ -9,6 +9,7 @@ /** * @api + * @since 100.0.2 */ class DefaultPath implements \Magento\Framework\App\DefaultPathInterface { diff --git a/app/code/Magento/Backend/App/Request/PathInfoProcessor.php b/app/code/Magento/Backend/App/Request/PathInfoProcessor.php index 782a4702c6981..9629b0e3128ad 100644 --- a/app/code/Magento/Backend/App/Request/PathInfoProcessor.php +++ b/app/code/Magento/Backend/App/Request/PathInfoProcessor.php @@ -9,6 +9,7 @@ /** * @api + * @since 100.0.2 */ class PathInfoProcessor implements \Magento\Framework\App\Request\PathInfoProcessorInterface { diff --git a/app/code/Magento/Backend/App/Response/Http/FileFactory.php b/app/code/Magento/Backend/App/Response/Http/FileFactory.php index fa4fb39330f9e..077c5a8090a6f 100644 --- a/app/code/Magento/Backend/App/Response/Http/FileFactory.php +++ b/app/code/Magento/Backend/App/Response/Http/FileFactory.php @@ -9,6 +9,7 @@ /** * @api + * @since 100.0.2 */ class FileFactory extends \Magento\Framework\App\Response\Http\FileFactory { diff --git a/app/code/Magento/Backend/App/Router.php b/app/code/Magento/Backend/App/Router.php index 040071ca572d5..98b75e5877d5b 100644 --- a/app/code/Magento/Backend/App/Router.php +++ b/app/code/Magento/Backend/App/Router.php @@ -10,6 +10,7 @@ /** * @api + * @since 100.0.2 */ class Router extends \Magento\Framework\App\Router\Base { diff --git a/app/code/Magento/Backend/App/Router/NoRouteHandler.php b/app/code/Magento/Backend/App/Router/NoRouteHandler.php index fc25c5adabeb0..e56a08b5226af 100644 --- a/app/code/Magento/Backend/App/Router/NoRouteHandler.php +++ b/app/code/Magento/Backend/App/Router/NoRouteHandler.php @@ -9,6 +9,7 @@ /** * @api + * @since 100.0.2 */ class NoRouteHandler implements \Magento\Framework\App\Router\NoRouteHandlerInterface { diff --git a/app/code/Magento/Backend/App/UserConfig.php b/app/code/Magento/Backend/App/UserConfig.php index 1a60c38d1783a..2b655a2ab2e95 100644 --- a/app/code/Magento/Backend/App/UserConfig.php +++ b/app/code/Magento/Backend/App/UserConfig.php @@ -14,6 +14,7 @@ /** * @api + * @since 100.0.2 */ class UserConfig implements AppInterface { diff --git a/app/code/Magento/Backend/Block/AbstractBlock.php b/app/code/Magento/Backend/Block/AbstractBlock.php index 51e1831b97aa2..2f029a3da2884 100644 --- a/app/code/Magento/Backend/Block/AbstractBlock.php +++ b/app/code/Magento/Backend/Block/AbstractBlock.php @@ -12,6 +12,7 @@ * * Marked as public API because it is actively used now. * @api + * @since 100.0.2 */ class AbstractBlock extends \Magento\Framework\View\Element\AbstractBlock { diff --git a/app/code/Magento/Backend/Block/Admin/Formkey.php b/app/code/Magento/Backend/Block/Admin/Formkey.php index 2e3474dac2498..078a756d40b59 100644 --- a/app/code/Magento/Backend/Block/Admin/Formkey.php +++ b/app/code/Magento/Backend/Block/Admin/Formkey.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class Formkey extends \Magento\Backend\Block\Template { diff --git a/app/code/Magento/Backend/Block/Cache.php b/app/code/Magento/Backend/Block/Cache.php index fa230c5a15236..e14358396aa70 100644 --- a/app/code/Magento/Backend/Block/Cache.php +++ b/app/code/Magento/Backend/Block/Cache.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Cache extends \Magento\Backend\Block\Widget\Grid\Container { diff --git a/app/code/Magento/Backend/Block/Cache/Additional.php b/app/code/Magento/Backend/Block/Cache/Additional.php index 52f41600f64f8..82cfe2a3c9e05 100644 --- a/app/code/Magento/Backend/Block/Cache/Additional.php +++ b/app/code/Magento/Backend/Block/Cache/Additional.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Additional extends \Magento\Backend\Block\Template { diff --git a/app/code/Magento/Backend/Block/Cache/Grid/Column/Statuses.php b/app/code/Magento/Backend/Block/Cache/Grid/Column/Statuses.php index 001bf2543c2e5..60f371cace9b6 100644 --- a/app/code/Magento/Backend/Block/Cache/Grid/Column/Statuses.php +++ b/app/code/Magento/Backend/Block/Cache/Grid/Column/Statuses.php @@ -9,6 +9,7 @@ /** * @api + * @since 100.0.2 */ class Statuses extends \Magento\Backend\Block\Widget\Grid\Column { diff --git a/app/code/Magento/Backend/Block/Catalog/Product/Tab/Container.php b/app/code/Magento/Backend/Block/Catalog/Product/Tab/Container.php index 0882facbeaca9..9524e1a63745c 100644 --- a/app/code/Magento/Backend/Block/Catalog/Product/Tab/Container.php +++ b/app/code/Magento/Backend/Block/Catalog/Product/Tab/Container.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Container extends \Magento\Backend\Block\Template implements \Magento\Backend\Block\Widget\Tab\TabInterface { diff --git a/app/code/Magento/Backend/Block/Context.php b/app/code/Magento/Backend/Block/Context.php index 060fb3eb0d762..d05cdc5fff5a3 100644 --- a/app/code/Magento/Backend/Block/Context.php +++ b/app/code/Magento/Backend/Block/Context.php @@ -18,6 +18,7 @@ * * @api * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class Context extends \Magento\Framework\View\Element\Context { diff --git a/app/code/Magento/Backend/Block/Dashboard.php b/app/code/Magento/Backend/Block/Dashboard.php index e3de182751cb7..8d0a061621fe3 100644 --- a/app/code/Magento/Backend/Block/Dashboard.php +++ b/app/code/Magento/Backend/Block/Dashboard.php @@ -8,6 +8,7 @@ /** * @api + * @since 100.0.2 */ class Dashboard extends \Magento\Backend\Block\Template { diff --git a/app/code/Magento/Backend/Block/Dashboard/Grid.php b/app/code/Magento/Backend/Block/Dashboard/Grid.php index fd9f2cf15babb..602b5e414d538 100644 --- a/app/code/Magento/Backend/Block/Dashboard/Grid.php +++ b/app/code/Magento/Backend/Block/Dashboard/Grid.php @@ -10,6 +10,7 @@ * * @author Magento Core Team * @api + * @since 100.0.2 */ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended { diff --git a/app/code/Magento/Backend/Block/Dashboard/Searches/Renderer/Searchquery.php b/app/code/Magento/Backend/Block/Dashboard/Searches/Renderer/Searchquery.php index 2f48a8ef0766d..d61c31dd6454c 100644 --- a/app/code/Magento/Backend/Block/Dashboard/Searches/Renderer/Searchquery.php +++ b/app/code/Magento/Backend/Block/Dashboard/Searches/Renderer/Searchquery.php @@ -8,6 +8,7 @@ /** * Dashboard search query column renderer * @api + * @since 100.0.2 */ class Searchquery extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { diff --git a/app/code/Magento/Backend/Block/Dashboard/Tab/Customers/Most.php b/app/code/Magento/Backend/Block/Dashboard/Tab/Customers/Most.php index f276831c76758..14033bde0ab36 100644 --- a/app/code/Magento/Backend/Block/Dashboard/Tab/Customers/Most.php +++ b/app/code/Magento/Backend/Block/Dashboard/Tab/Customers/Most.php @@ -10,6 +10,7 @@ * * @api * @SuppressWarnings(PHPMD.DepthOfInheritance) + * @since 100.0.2 */ class Most extends \Magento\Backend\Block\Dashboard\Grid { diff --git a/app/code/Magento/Backend/Block/Dashboard/Tab/Customers/Newest.php b/app/code/Magento/Backend/Block/Dashboard/Tab/Customers/Newest.php index 86590aa3b4aa3..711a67b6d8b1e 100644 --- a/app/code/Magento/Backend/Block/Dashboard/Tab/Customers/Newest.php +++ b/app/code/Magento/Backend/Block/Dashboard/Tab/Customers/Newest.php @@ -10,6 +10,7 @@ * * @SuppressWarnings(PHPMD.DepthOfInheritance) * @api + * @since 100.0.2 */ class Newest extends \Magento\Backend\Block\Dashboard\Grid { diff --git a/app/code/Magento/Backend/Block/Dashboard/Tab/Products/Viewed.php b/app/code/Magento/Backend/Block/Dashboard/Tab/Products/Viewed.php index 699c7274001d3..e79cbd53bef89 100644 --- a/app/code/Magento/Backend/Block/Dashboard/Tab/Products/Viewed.php +++ b/app/code/Magento/Backend/Block/Dashboard/Tab/Products/Viewed.php @@ -13,6 +13,7 @@ * * @api * @SuppressWarnings(PHPMD.DepthOfInheritance) + * @since 100.0.2 */ class Viewed extends \Magento\Backend\Block\Dashboard\Grid { diff --git a/app/code/Magento/Backend/Block/Denied.php b/app/code/Magento/Backend/Block/Denied.php index c3785a641ecd3..f3b50e9775d18 100644 --- a/app/code/Magento/Backend/Block/Denied.php +++ b/app/code/Magento/Backend/Block/Denied.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Denied extends \Magento\Backend\Block\Template { diff --git a/app/code/Magento/Backend/Block/GlobalSearch.php b/app/code/Magento/Backend/Block/GlobalSearch.php index d8098c1a3ce0b..f4a46283808f4 100644 --- a/app/code/Magento/Backend/Block/GlobalSearch.php +++ b/app/code/Magento/Backend/Block/GlobalSearch.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class GlobalSearch extends \Magento\Backend\Block\Template { diff --git a/app/code/Magento/Backend/Block/Media/Uploader.php b/app/code/Magento/Backend/Block/Media/Uploader.php index a078251420f60..4987cb248bd0b 100644 --- a/app/code/Magento/Backend/Block/Media/Uploader.php +++ b/app/code/Magento/Backend/Block/Media/Uploader.php @@ -8,6 +8,7 @@ /** * Adminhtml media library uploader * @api + * @since 100.0.2 */ class Uploader extends \Magento\Backend\Block\Widget { diff --git a/app/code/Magento/Backend/Block/Menu.php b/app/code/Magento/Backend/Block/Menu.php index 1b031f538c07d..bb239d31b1779 100644 --- a/app/code/Magento/Backend/Block/Menu.php +++ b/app/code/Magento/Backend/Block/Menu.php @@ -16,6 +16,7 @@ * @method array getAdditionalCacheKeyInfo() * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @api + * @since 100.0.2 */ class Menu extends \Magento\Backend\Block\Template { diff --git a/app/code/Magento/Backend/Block/Page.php b/app/code/Magento/Backend/Block/Page.php index 5a0b5b4405e82..6c9bb15417c90 100644 --- a/app/code/Magento/Backend/Block/Page.php +++ b/app/code/Magento/Backend/Block/Page.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class Page extends \Magento\Backend\Block\Template { diff --git a/app/code/Magento/Backend/Block/Page/Copyright.php b/app/code/Magento/Backend/Block/Page/Copyright.php index cb4af8b8208d5..062497d6a8304 100644 --- a/app/code/Magento/Backend/Block/Page/Copyright.php +++ b/app/code/Magento/Backend/Block/Page/Copyright.php @@ -9,6 +9,7 @@ * Copyright footer block * * @api + * @since 100.0.2 */ class Copyright extends \Magento\Backend\Block\Template { diff --git a/app/code/Magento/Backend/Block/Page/Footer.php b/app/code/Magento/Backend/Block/Page/Footer.php index b91e9156f1d20..368869b79e15c 100644 --- a/app/code/Magento/Backend/Block/Page/Footer.php +++ b/app/code/Magento/Backend/Block/Page/Footer.php @@ -10,6 +10,7 @@ * * @api * @author Magento Core Team + * @since 100.0.2 */ class Footer extends \Magento\Backend\Block\Template { @@ -20,6 +21,7 @@ class Footer extends \Magento\Backend\Block\Template /** * @var \Magento\Framework\App\ProductMetadataInterface + * @since 100.1.0 */ protected $productMetadata; @@ -49,6 +51,7 @@ protected function _construct() * Get product version * * @return string + * @since 100.1.0 */ public function getMagentoVersion() { diff --git a/app/code/Magento/Backend/Block/Page/Header.php b/app/code/Magento/Backend/Block/Page/Header.php index becbf29c924d9..b7ed05ce58e95 100644 --- a/app/code/Magento/Backend/Block/Page/Header.php +++ b/app/code/Magento/Backend/Block/Page/Header.php @@ -11,6 +11,7 @@ * * @api * @author Magento Core Team + * @since 100.0.2 */ class Header extends \Magento\Backend\Block\Template { diff --git a/app/code/Magento/Backend/Block/Page/Notices.php b/app/code/Magento/Backend/Block/Page/Notices.php index e8adb22247a27..d34b50d21f933 100644 --- a/app/code/Magento/Backend/Block/Page/Notices.php +++ b/app/code/Magento/Backend/Block/Page/Notices.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class Notices extends \Magento\Backend\Block\Template { diff --git a/app/code/Magento/Backend/Block/Page/RequireJs.php b/app/code/Magento/Backend/Block/Page/RequireJs.php index 99f211a9c00b0..0a8e9c11ec69f 100644 --- a/app/code/Magento/Backend/Block/Page/RequireJs.php +++ b/app/code/Magento/Backend/Block/Page/RequireJs.php @@ -10,6 +10,7 @@ * Require Js block * * @api + * @since 100.0.2 */ class RequireJs extends \Magento\Framework\View\Element\Template { diff --git a/app/code/Magento/Backend/Block/Page/System/Config/Robots/Reset.php b/app/code/Magento/Backend/Block/Page/System/Config/Robots/Reset.php index c837ad45ffeae..2abb987db0723 100644 --- a/app/code/Magento/Backend/Block/Page/System/Config/Robots/Reset.php +++ b/app/code/Magento/Backend/Block/Page/System/Config/Robots/Reset.php @@ -11,7 +11,7 @@ /** * "Reset to Defaults" button renderer * - * @deprecated + * @deprecated 100.2.0 * @author Magento Core Team */ class Reset extends \Magento\Config\Block\System\Config\Form\Field diff --git a/app/code/Magento/Backend/Block/Store/Switcher.php b/app/code/Magento/Backend/Block/Store/Switcher.php index 1b49a2ef0d590..1468df2b0b442 100644 --- a/app/code/Magento/Backend/Block/Store/Switcher.php +++ b/app/code/Magento/Backend/Block/Store/Switcher.php @@ -10,6 +10,7 @@ * Store switcher block * * @api + * @since 100.0.2 */ class Switcher extends \Magento\Backend\Block\Template { diff --git a/app/code/Magento/Backend/Block/Store/Switcher/Form/Renderer/Fieldset.php b/app/code/Magento/Backend/Block/Store/Switcher/Form/Renderer/Fieldset.php index 4274273e43160..2f9b73f0ae037 100644 --- a/app/code/Magento/Backend/Block/Store/Switcher/Form/Renderer/Fieldset.php +++ b/app/code/Magento/Backend/Block/Store/Switcher/Form/Renderer/Fieldset.php @@ -11,6 +11,7 @@ /** * Form fieldset renderer * @api + * @since 100.0.2 */ class Fieldset extends \Magento\Backend\Block\Template implements RendererInterface { diff --git a/app/code/Magento/Backend/Block/Store/Switcher/Form/Renderer/Fieldset/Element.php b/app/code/Magento/Backend/Block/Store/Switcher/Form/Renderer/Fieldset/Element.php index 90e539b57b4a0..ddd1f1a9178cd 100644 --- a/app/code/Magento/Backend/Block/Store/Switcher/Form/Renderer/Fieldset/Element.php +++ b/app/code/Magento/Backend/Block/Store/Switcher/Form/Renderer/Fieldset/Element.php @@ -8,6 +8,7 @@ /** * Form fieldset renderer * @api + * @since 100.0.2 */ class Element extends \Magento\Backend\Block\Widget\Form\Renderer\Fieldset\Element implements \Magento\Framework\Data\Form\Element\Renderer\RendererInterface diff --git a/app/code/Magento/Backend/Block/System/Account/Edit.php b/app/code/Magento/Backend/Block/System/Account/Edit.php index 40bf15892b208..f12c1f4211417 100644 --- a/app/code/Magento/Backend/Block/System/Account/Edit.php +++ b/app/code/Magento/Backend/Block/System/Account/Edit.php @@ -10,6 +10,7 @@ * * @api * @author Magento Core Team + * @since 100.0.2 */ class Edit extends \Magento\Backend\Block\Widget\Form\Container { diff --git a/app/code/Magento/Backend/Block/System/Design.php b/app/code/Magento/Backend/Block/System/Design.php index b21336866f972..0462bbe0899d3 100644 --- a/app/code/Magento/Backend/Block/System/Design.php +++ b/app/code/Magento/Backend/Block/System/Design.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Design extends \Magento\Backend\Block\Template { diff --git a/app/code/Magento/Backend/Block/System/Store/Edit.php b/app/code/Magento/Backend/Block/System/Store/Edit.php index c436c5377e1a9..82e1b23cbc49e 100644 --- a/app/code/Magento/Backend/Block/System/Store/Edit.php +++ b/app/code/Magento/Backend/Block/System/Store/Edit.php @@ -12,6 +12,7 @@ * @api * * Adminhtml store edit + * @since 100.0.2 */ class Edit extends \Magento\Backend\Block\Widget\Form\Container { @@ -145,6 +146,7 @@ protected function _buildFormClassName() * Get data for store edit * * @return string + * @since 100.2.0 */ public function getStoreData() { diff --git a/app/code/Magento/Backend/Block/System/Store/Store.php b/app/code/Magento/Backend/Block/System/Store/Store.php index c9f99ee605169..cdbf55426de39 100644 --- a/app/code/Magento/Backend/Block/System/Store/Store.php +++ b/app/code/Magento/Backend/Block/System/Store/Store.php @@ -11,6 +11,7 @@ * @api * @author Magento Core Team * @api + * @since 100.0.2 */ class Store extends \Magento\Backend\Block\Widget\Grid\Container { diff --git a/app/code/Magento/Backend/Block/Template.php b/app/code/Magento/Backend/Block/Template.php index cb48e6df7c5bf..d0f39b54c1492 100644 --- a/app/code/Magento/Backend/Block/Template.php +++ b/app/code/Magento/Backend/Block/Template.php @@ -23,6 +23,7 @@ * * @api * @SuppressWarnings(PHPMD.NumberOfChildren) + * @since 100.0.2 */ class Template extends \Magento\Framework\View\Element\Template { @@ -84,12 +85,22 @@ public function getFormKey() * * @param string $moduleName Full module name * @return boolean - * @deprecated Magento does not support custom disabling/enabling module output since 2.2.0 version - * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @deprecated 100.2.0 Magento does not support disabling/enabling modules output from the Admin Panel since 2.2.0 + * version. Module output can still be enabled/disabled in configuration files. However, this functionality should + * not be used in future development. Module design should explicitly state dependencies to avoid requiring output + * disabling. This functionality will temporarily be kept in Magento core, as there are unresolved modularity + * issues that will be addressed in future releases. */ public function isOutputEnabled($moduleName = null) { - return true; + if ($moduleName === null) { + $moduleName = $this->getModuleName(); + } + + return !$this->_scopeConfig->isSetFlag( + 'advanced/modules_disable_output/' . $moduleName, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); } /** diff --git a/app/code/Magento/Backend/Block/Template/Context.php b/app/code/Magento/Backend/Block/Template/Context.php index a25b04064a150..6efc8d86802ce 100644 --- a/app/code/Magento/Backend/Block/Template/Context.php +++ b/app/code/Magento/Backend/Block/Template/Context.php @@ -18,6 +18,7 @@ * * @api * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class Context extends \Magento\Framework\View\Element\Template\Context { diff --git a/app/code/Magento/Backend/Block/Text/ListText.php b/app/code/Magento/Backend/Block/Text/ListText.php index 71b6248059277..9f24239abdc88 100644 --- a/app/code/Magento/Backend/Block/Text/ListText.php +++ b/app/code/Magento/Backend/Block/Text/ListText.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class ListText extends \Magento\Framework\View\Element\Text\ListText { diff --git a/app/code/Magento/Backend/Block/Widget.php b/app/code/Magento/Backend/Block/Widget.php index b35f036257c9a..d2f9ac485b7c8 100644 --- a/app/code/Magento/Backend/Block/Widget.php +++ b/app/code/Magento/Backend/Block/Widget.php @@ -10,6 +10,7 @@ * * @api * @SuppressWarnings(PHPMD.NumberOfChildren) + * @since 100.0.2 */ class Widget extends \Magento\Backend\Block\Template { diff --git a/app/code/Magento/Backend/Block/Widget/Accordion.php b/app/code/Magento/Backend/Block/Widget/Accordion.php index 376276cb899c0..56883161c5a20 100644 --- a/app/code/Magento/Backend/Block/Widget/Accordion.php +++ b/app/code/Magento/Backend/Block/Widget/Accordion.php @@ -9,6 +9,7 @@ * Magento_Backend accordion widget * * @api + * @since 100.0.2 */ class Accordion extends \Magento\Backend\Block\Widget { diff --git a/app/code/Magento/Backend/Block/Widget/Breadcrumbs.php b/app/code/Magento/Backend/Block/Widget/Breadcrumbs.php index 3124a64f679f0..d85ee72365e32 100644 --- a/app/code/Magento/Backend/Block/Widget/Breadcrumbs.php +++ b/app/code/Magento/Backend/Block/Widget/Breadcrumbs.php @@ -10,6 +10,7 @@ * * @api * @author Magento Core Team + * @since 100.0.2 */ class Breadcrumbs extends \Magento\Backend\Block\Template { diff --git a/app/code/Magento/Backend/Block/Widget/Button.php b/app/code/Magento/Backend/Block/Widget/Button.php index 51457199b05a0..8385ecaa40a8b 100644 --- a/app/code/Magento/Backend/Block/Widget/Button.php +++ b/app/code/Magento/Backend/Block/Widget/Button.php @@ -11,6 +11,7 @@ * @api * @author Magento Core Team * @api + * @since 100.0.2 */ class Button extends \Magento\Backend\Block\Widget { diff --git a/app/code/Magento/Backend/Block/Widget/Button/ButtonList.php b/app/code/Magento/Backend/Block/Widget/Button/ButtonList.php index 08043c4e39790..94af9a1d7578f 100644 --- a/app/code/Magento/Backend/Block/Widget/Button/ButtonList.php +++ b/app/code/Magento/Backend/Block/Widget/Button/ButtonList.php @@ -8,6 +8,7 @@ /** * @api + * @since 100.0.2 */ class ButtonList { diff --git a/app/code/Magento/Backend/Block/Widget/Button/ContextInterface.php b/app/code/Magento/Backend/Block/Widget/Button/ContextInterface.php index 526a020b51d9d..14bd7112b20a0 100644 --- a/app/code/Magento/Backend/Block/Widget/Button/ContextInterface.php +++ b/app/code/Magento/Backend/Block/Widget/Button/ContextInterface.php @@ -6,6 +6,10 @@ namespace Magento\Backend\Block\Widget\Button; +/** + * Interface \Magento\Backend\Block\Widget\Button\ContextInterface + * + */ interface ContextInterface { /** diff --git a/app/code/Magento/Backend/Block/Widget/Button/Item.php b/app/code/Magento/Backend/Block/Widget/Button/Item.php index 94ac0368db25e..4c1232e48baab 100644 --- a/app/code/Magento/Backend/Block/Widget/Button/Item.php +++ b/app/code/Magento/Backend/Block/Widget/Button/Item.php @@ -14,6 +14,7 @@ * @method int getLevel() * @method int getSortOrder() * @method string getTitle() + * @since 100.0.2 */ class Item extends \Magento\Framework\DataObject { diff --git a/app/code/Magento/Backend/Block/Widget/Button/SplitButton.php b/app/code/Magento/Backend/Block/Widget/Button/SplitButton.php index f6c1795ca1e68..db3f5466fbacb 100644 --- a/app/code/Magento/Backend/Block/Widget/Button/SplitButton.php +++ b/app/code/Magento/Backend/Block/Widget/Button/SplitButton.php @@ -17,6 +17,7 @@ * @method string getStyle() * @method array getDataAttribute() * @api + * @since 100.0.2 */ class SplitButton extends \Magento\Backend\Block\Widget { diff --git a/app/code/Magento/Backend/Block/Widget/Button/Toolbar/Container.php b/app/code/Magento/Backend/Block/Widget/Button/Toolbar/Container.php index 23a4fe829b292..3a1a455a0e566 100644 --- a/app/code/Magento/Backend/Block/Widget/Button/Toolbar/Container.php +++ b/app/code/Magento/Backend/Block/Widget/Button/Toolbar/Container.php @@ -13,6 +13,7 @@ * @method ContextInterface getContext() * @method ContextInterface setContext(ContextInterface $context) * @api + * @since 100.0.2 */ class Container extends \Magento\Framework\View\Element\AbstractBlock { diff --git a/app/code/Magento/Backend/Block/Widget/Button/ToolbarInterface.php b/app/code/Magento/Backend/Block/Widget/Button/ToolbarInterface.php index f32958612d560..395fb1667fa39 100644 --- a/app/code/Magento/Backend/Block/Widget/Button/ToolbarInterface.php +++ b/app/code/Magento/Backend/Block/Widget/Button/ToolbarInterface.php @@ -6,6 +6,10 @@ namespace Magento\Backend\Block\Widget\Button; +/** + * Interface \Magento\Backend\Block\Widget\Button\ToolbarInterface + * + */ interface ToolbarInterface { /** diff --git a/app/code/Magento/Backend/Block/Widget/Container.php b/app/code/Magento/Backend/Block/Widget/Container.php index 52bc39f9c28cf..7d89430c26c7c 100644 --- a/app/code/Magento/Backend/Block/Widget/Container.php +++ b/app/code/Magento/Backend/Block/Widget/Container.php @@ -12,6 +12,7 @@ /** * @api + * @since 100.0.2 */ class Container extends \Magento\Backend\Block\Template implements ContainerInterface { @@ -24,11 +25,7 @@ class Container extends \Magento\Backend\Block\Template implements ContainerInte /**#@-*/ - /** - * So called "container controller" to specify group of blocks participating in some action - * - * @var string - */ + /**#@-*/ protected $_controller = 'empty'; /** diff --git a/app/code/Magento/Backend/Block/Widget/ContainerInterface.php b/app/code/Magento/Backend/Block/Widget/ContainerInterface.php index 2ce0b8e19e815..f8554063a75a8 100644 --- a/app/code/Magento/Backend/Block/Widget/ContainerInterface.php +++ b/app/code/Magento/Backend/Block/Widget/ContainerInterface.php @@ -8,6 +8,7 @@ /** * @api + * @since 100.0.2 */ interface ContainerInterface extends \Magento\Backend\Block\Widget\Button\ContextInterface { diff --git a/app/code/Magento/Backend/Block/Widget/Context.php b/app/code/Magento/Backend/Block/Widget/Context.php index ffa983a611623..bfeb86214d33e 100644 --- a/app/code/Magento/Backend/Block/Widget/Context.php +++ b/app/code/Magento/Backend/Block/Widget/Context.php @@ -18,6 +18,7 @@ * * @api * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class Context extends \Magento\Backend\Block\Template\Context { diff --git a/app/code/Magento/Backend/Block/Widget/Form.php b/app/code/Magento/Backend/Block/Widget/Form.php index 021a4b17ddd71..30221618edbed 100644 --- a/app/code/Magento/Backend/Block/Widget/Form.php +++ b/app/code/Magento/Backend/Block/Widget/Form.php @@ -9,8 +9,9 @@ * Backend form widget * * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation * @SuppressWarnings(PHPMD.NumberOfChildren) + * @since 100.0.2 */ class Form extends \Magento\Backend\Block\Widget { diff --git a/app/code/Magento/Backend/Block/Widget/Form/Container.php b/app/code/Magento/Backend/Block/Widget/Form/Container.php index 11f9139370859..8b7babc1bb9b6 100644 --- a/app/code/Magento/Backend/Block/Widget/Form/Container.php +++ b/app/code/Magento/Backend/Block/Widget/Form/Container.php @@ -9,8 +9,9 @@ * Backend form container block * * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation * @SuppressWarnings(PHPMD.NumberOfChildren) + * @since 100.0.2 */ class Container extends \Magento\Backend\Block\Widget\Container { diff --git a/app/code/Magento/Backend/Block/Widget/Form/Element/Dependence.php b/app/code/Magento/Backend/Block/Widget/Form/Element/Dependence.php index 23c5605f416c0..723deab1e9f7e 100644 --- a/app/code/Magento/Backend/Block/Widget/Form/Element/Dependence.php +++ b/app/code/Magento/Backend/Block/Widget/Form/Element/Dependence.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class Dependence extends \Magento\Backend\Block\AbstractBlock { diff --git a/app/code/Magento/Backend/Block/Widget/Form/Generic.php b/app/code/Magento/Backend/Block/Widget/Form/Generic.php index 0b476d28596c5..867fc62a1d033 100644 --- a/app/code/Magento/Backend/Block/Widget/Form/Generic.php +++ b/app/code/Magento/Backend/Block/Widget/Form/Generic.php @@ -7,8 +7,9 @@ /** * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation * @SuppressWarnings(PHPMD.NumberOfChildren) + * @since 100.0.2 */ class Generic extends \Magento\Backend\Block\Widget\Form { diff --git a/app/code/Magento/Backend/Block/Widget/Form/Renderer/Element.php b/app/code/Magento/Backend/Block/Widget/Form/Renderer/Element.php index 6912dfdda8ea1..5fc80514fac19 100644 --- a/app/code/Magento/Backend/Block/Widget/Form/Renderer/Element.php +++ b/app/code/Magento/Backend/Block/Widget/Form/Renderer/Element.php @@ -13,7 +13,8 @@ * Form element default renderer * * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation + * @since 100.0.2 */ class Element extends \Magento\Backend\Block\Template implements RendererInterface { diff --git a/app/code/Magento/Backend/Block/Widget/Form/Renderer/Fieldset.php b/app/code/Magento/Backend/Block/Widget/Form/Renderer/Fieldset.php index 464ec47abf6b3..8eda55b65035e 100644 --- a/app/code/Magento/Backend/Block/Widget/Form/Renderer/Fieldset.php +++ b/app/code/Magento/Backend/Block/Widget/Form/Renderer/Fieldset.php @@ -15,6 +15,7 @@ * @api * @author Magento Core Team * @api + * @since 100.0.2 */ class Fieldset extends \Magento\Backend\Block\Template implements RendererInterface { diff --git a/app/code/Magento/Backend/Block/Widget/Form/Renderer/Fieldset/Element.php b/app/code/Magento/Backend/Block/Widget/Form/Renderer/Fieldset/Element.php index f9ab06762b1d9..32cb9366c8bf8 100644 --- a/app/code/Magento/Backend/Block/Widget/Form/Renderer/Fieldset/Element.php +++ b/app/code/Magento/Backend/Block/Widget/Form/Renderer/Fieldset/Element.php @@ -13,7 +13,8 @@ * Fieldset element renderer * * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation + * @since 100.0.2 */ class Element extends \Magento\Backend\Block\Template implements RendererInterface { diff --git a/app/code/Magento/Backend/Block/Widget/Grid.php b/app/code/Magento/Backend/Block/Widget/Grid.php index 27f2be0ca9413..72ab5a265d808 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid.php +++ b/app/code/Magento/Backend/Block/Widget/Grid.php @@ -10,10 +10,11 @@ * Backend grid widget block * * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation * @method string getRowClickCallback() getRowClickCallback() * @method \Magento\Backend\Block\Widget\Grid setRowClickCallback() setRowClickCallback(string $value) * @SuppressWarnings(PHPMD.TooManyFields) + * @since 100.0.2 */ class Grid extends \Magento\Backend\Block\Widget { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column.php b/app/code/Magento/Backend/Block/Widget/Grid/Column.php index 860398fcab133..1ab88bf11031e 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column.php @@ -5,15 +5,17 @@ */ namespace Magento\Backend\Block\Widget\Grid; +use Magento\Backend\Block\Widget; use Magento\Backend\Block\Widget\Grid\Column\Filter\AbstractFilter; /** * Grid column block * * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation + * @since 100.0.2 */ -class Column extends \Magento\Backend\Block\Widget +class Column extends Widget { /** * Parent grid @@ -288,12 +290,30 @@ public function getRowField(\Magento\Framework\DataObject $row) */ $frameCallback = $this->getFrameCallback(); if (is_array($frameCallback)) { + $this->validateFrameCallback($frameCallback); $renderedValue = call_user_func($frameCallback, $renderedValue, $row, $this, false); } return $renderedValue; } + /** + * Validate frame callback + * + * @throws \InvalidArgumentException + * + * @param array $callback + * @return void + */ + private function validateFrameCallback(array $callback) + { + if (!is_object($callback[0]) || !$callback[0] instanceof Widget) { + throw new \InvalidArgumentException( + "Frame callback host must be instance of Magento\\Backend\\Block\\Widget" + ); + } + } + /** * Retrieve row column field value for export * @@ -313,6 +333,7 @@ public function getRowFieldExport(\Magento\Framework\DataObject $row) */ $frameCallback = $this->getFrameCallback(); if (is_array($frameCallback)) { + $this->validateFrameCallback($frameCallback); $renderedValue = call_user_func($frameCallback, $renderedValue, $row, $this, true); } diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Extended.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Extended.php index 86ea904604d38..effbd42e3fbf1 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Extended.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Extended.php @@ -7,7 +7,8 @@ /** * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation + * @since 100.0.2 */ class Extended extends \Magento\Backend\Block\Widget\Grid\Column { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/AbstractFilter.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/AbstractFilter.php index ebdaa2d74f020..cfb8bae56e450 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/AbstractFilter.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/AbstractFilter.php @@ -10,7 +10,8 @@ * Grid column filter block * * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation + * @since 100.0.2 */ class AbstractFilter extends \Magento\Backend\Block\AbstractBlock implements \Magento\Backend\Block\Widget\Grid\Column\Filter\FilterInterface diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Date.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Date.php index 8f0b9b993554b..40a5d92c56b6f 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Date.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Date.php @@ -11,6 +11,7 @@ /** * Date grid column filter * @api + * @since 100.0.2 */ class Date extends \Magento\Backend\Block\Widget\Grid\Column\Filter\AbstractFilter { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/FilterInterface.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/FilterInterface.php index 21e5d85df28f9..776fb51bf9295 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/FilterInterface.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/FilterInterface.php @@ -11,6 +11,7 @@ * Grid column filter interface * * @api + * @since 100.0.2 */ interface FilterInterface { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Range.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Range.php index 9aaeb26d9156b..5c7793b6312a7 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Range.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Range.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class Range extends \Magento\Backend\Block\Widget\Grid\Column\Filter\AbstractFilter { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Select.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Select.php index c2699d372ea2b..98e4a3310fac7 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Select.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Select.php @@ -9,7 +9,8 @@ * Select grid column filter * * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation + * @since 100.0.2 */ class Select extends \Magento\Backend\Block\Widget\Grid\Column\Filter\AbstractFilter { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Text.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Text.php index 3945ae26e7046..0cc6a852ef1e6 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Text.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Text.php @@ -10,6 +10,7 @@ * * @author Magento Core Team * @api + * @since 100.0.2 */ class Text extends \Magento\Backend\Block\Widget\Grid\Column\Filter\AbstractFilter { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Multistore.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Multistore.php index 8c66535b43362..c45a222d1eb9a 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Multistore.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Multistore.php @@ -9,7 +9,8 @@ * Grid column block that is displayed only in multistore mode * * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation + * @since 100.0.2 */ class Multistore extends \Magento\Backend\Block\Widget\Grid\Column { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/AbstractRenderer.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/AbstractRenderer.php index 94db53e15c7af..b8a2e283b29a0 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/AbstractRenderer.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/AbstractRenderer.php @@ -13,6 +13,7 @@ * @api * @SuppressWarnings(PHPMD.NumberOfChildren) * @api + * @since 100.0.2 */ abstract class AbstractRenderer extends \Magento\Backend\Block\AbstractBlock implements RendererInterface { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Action.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Action.php index 5d88115443549..f4558594332c3 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Action.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Action.php @@ -10,7 +10,8 @@ * Grid column widget for rendering action grid cells * * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation + * @since 100.0.2 */ class Action extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Text { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Button.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Button.php index bfaa9e0d1926b..54d4270324163 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Button.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Button.php @@ -8,6 +8,7 @@ /** * @api * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @since 100.0.2 */ class Button extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Checkbox.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Checkbox.php index b402be32c3a09..1297f5cd330b8 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Checkbox.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Checkbox.php @@ -9,7 +9,8 @@ * Grid checkbox column renderer * * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation + * @since 100.0.2 */ class Checkbox extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Concat.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Concat.php index 6dbba0592ab5a..af174163ee929 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Concat.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Concat.php @@ -9,7 +9,8 @@ * Backend grid item renderer concat * * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation + * @since 100.0.2 */ class Concat extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Country.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Country.php index 469dfa6b620e0..cb3fa6be77688 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Country.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Country.php @@ -9,7 +9,8 @@ * Country column type renderer * * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation + * @since 100.0.2 */ class Country extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Currency.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Currency.php index 2209ac616ec3e..ff0399e4f507f 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Currency.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Currency.php @@ -10,6 +10,7 @@ * Backend grid item renderer currency * * @api + * @since 100.0.2 */ class Currency extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Date.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Date.php index dd5ba298af2f3..184515f0f6085 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Date.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Date.php @@ -10,7 +10,8 @@ /** * Backend grid item renderer date * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation + * @since 100.0.2 */ class Date extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { @@ -49,7 +50,7 @@ public function __construct( * Retrieve date format * * @return string - * @deprecated + * @deprecated 100.1.0 */ protected function _getFormat() { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Datetime.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Datetime.php index 221125d7c9369..281066d3ceac4 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Datetime.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Datetime.php @@ -9,7 +9,8 @@ * Backend grid item renderer datetime * * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation + * @since 100.0.2 */ class Datetime extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/DraggableHandle.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/DraggableHandle.php index 24c9635c9acc9..c10db31f6316c 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/DraggableHandle.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/DraggableHandle.php @@ -7,7 +7,8 @@ /** * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation + * @since 100.0.2 */ class DraggableHandle extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Input.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Input.php index 29e39573bb530..ac1a125397138 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Input.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Input.php @@ -7,7 +7,8 @@ /** * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation + * @since 100.0.2 */ class Input extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Ip.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Ip.php index f54f165670bff..0aaf5c00bbb1b 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Ip.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Ip.php @@ -9,7 +9,8 @@ * Long INT to IP renderer * * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation + * @since 100.0.2 */ class Ip extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Longtext.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Longtext.php index 46337328ac098..d2f92ec46ce63 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Longtext.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Longtext.php @@ -7,7 +7,8 @@ /** * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation + * @since 100.0.2 */ class Longtext extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Massaction.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Massaction.php index 8f8a13a91ca84..320713f8b57c4 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Massaction.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Massaction.php @@ -9,7 +9,8 @@ * Grid widget column renderer massaction * * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation + * @since 100.0.2 */ class Massaction extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Checkbox { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Number.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Number.php index 1c075b5bd566b..9d27b692e6c81 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Number.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Number.php @@ -9,7 +9,8 @@ * Backend grid item renderer number * * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation + * @since 100.0.2 */ class Number extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Options.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Options.php index b8c6b31d49957..52cdcee5a37d1 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Options.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Options.php @@ -9,7 +9,8 @@ * Grid column widget for rendering grid cells that contains mapped values * * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation + * @since 100.0.2 */ class Options extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Text { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Options/Converter.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Options/Converter.php index 3a929bd644f3a..78c7b48d05dc7 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Options/Converter.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Options/Converter.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Converter { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Price.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Price.php index 2b6fee4cca885..e4300c63485f5 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Price.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Price.php @@ -9,7 +9,8 @@ * Backend grid item renderer currency * * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation + * @since 100.0.2 */ class Price extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Radio.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Radio.php index af34c6bf27825..4404dc5edfb25 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Radio.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Radio.php @@ -9,7 +9,8 @@ * Grid radiogroup column renderer * * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation + * @since 100.0.2 */ class Radio extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/RendererInterface.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/RendererInterface.php index 83378e30a6234..5020c75332587 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/RendererInterface.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/RendererInterface.php @@ -11,7 +11,8 @@ * Backend grid item renderer interface * * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation + * @since 100.0.2 */ interface RendererInterface { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Select.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Select.php index 13f3db0fa477b..1c66f514654e0 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Select.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Select.php @@ -9,6 +9,7 @@ * Grid select input column renderer * * @api + * @since 100.0.2 */ class Select extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Store.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Store.php index 5bb6b27bb4bfc..4054d121f8f9f 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Store.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Store.php @@ -8,7 +8,8 @@ /** * Store grid column filter * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation + * @since 100.0.2 */ class Store extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Text.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Text.php index 682c55b97939e..3866a0cb1e62d 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Text.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Text.php @@ -11,7 +11,8 @@ * Backend grid item renderer * * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation + * @since 100.0.2 */ class Text extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Wrapline.php b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Wrapline.php index 1eacbf87e428f..a8ddf8132d994 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Wrapline.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Wrapline.php @@ -9,6 +9,7 @@ * Backend grid item renderer line to wrap * * @api + * @since 100.0.2 */ class Wrapline extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/ColumnSet.php b/app/code/Magento/Backend/Block/Widget/Grid/ColumnSet.php index b6097dc47e62f..1a6f937f1171d 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/ColumnSet.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/ColumnSet.php @@ -7,8 +7,9 @@ /** * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class ColumnSet extends \Magento\Framework\View\Element\Template { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Container.php b/app/code/Magento/Backend/Block/Widget/Grid/Container.php index 5f5711d26db1e..61b294925520d 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Container.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Container.php @@ -11,7 +11,8 @@ * * @SuppressWarnings(PHPMD.NumberOfChildren) * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation + * @since 100.0.2 */ class Container extends \Magento\Backend\Block\Widget\Container { @@ -26,9 +27,7 @@ class Container extends \Magento\Backend\Block\Widget\Container /**#@-*/ - /** - * @var string - */ + /**#@-*/ protected $_addButtonLabel; /** diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Export.php b/app/code/Magento/Backend/Block/Widget/Grid/Export.php index 4d22490329a13..7b7f6cc14799c 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Export.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Export.php @@ -10,8 +10,9 @@ /** * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class Export extends \Magento\Backend\Block\Widget implements \Magento\Backend\Block\Widget\Grid\ExportInterface { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/ExportInterface.php b/app/code/Magento/Backend/Block/Widget/Grid/ExportInterface.php index f599d7ef43b07..8dc1cad9cf7dd 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/ExportInterface.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/ExportInterface.php @@ -9,7 +9,8 @@ * Interface ExportInterface * * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation + * @since 100.0.2 */ interface ExportInterface { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Extended.php b/app/code/Magento/Backend/Block/Widget/Grid/Extended.php index 7cfb49056eb7a..3c3398ff169f9 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Extended.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Extended.php @@ -9,12 +9,13 @@ /** * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation * @SuppressWarnings(PHPMD.ExcessivePublicCount) * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) * @SuppressWarnings(PHPMD.NumberOfChildren) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class Extended extends \Magento\Backend\Block\Widget\Grid implements \Magento\Backend\Block\Widget\Grid\ExportInterface { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Massaction.php b/app/code/Magento/Backend/Block/Widget/Grid/Massaction.php index 1726a2ba54526..d9b00d2ba2503 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Massaction.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Massaction.php @@ -9,7 +9,8 @@ * Grid widget massaction default block * * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation + * @since 100.0.2 */ class Massaction extends \Magento\Backend\Block\Widget\Grid\Massaction\AbstractMassaction { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php index 6635ccbc83fc9..8252ed1a1e2f8 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php @@ -14,7 +14,8 @@ * @api * @method \Magento\Quote\Model\Quote setHideFormElement(boolean $value) Hide Form element to prevent IE errors * @method boolean getHideFormElement() - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation + * @since 100.0.2 */ abstract class AbstractMassaction extends \Magento\Backend\Block\Widget { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Additional.php b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Additional.php index cde34f6de7ad0..abfb2b764d2bd 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Additional.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Additional.php @@ -9,7 +9,8 @@ * @api * @SuppressWarnings(PHPMD.DepthOfInheritance) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation + * @since 100.0.2 */ class Additional extends \Magento\Backend\Block\Widget\Form\Generic { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Extended.php b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Extended.php index ce46632cfba05..42f5e61bf5fa8 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Extended.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Extended.php @@ -9,11 +9,12 @@ * Grid widget massaction block * * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation * @method \Magento\Quote\Model\Quote setHideFormElement(boolean $value) Hide Form element to prevent IE errors * @method boolean getHideFormElement() * @author Magento Core Team * @TODO MAGETWO-31510: Remove deprecated class + * @since 100.0.2 */ class Extended extends \Magento\Backend\Block\Widget { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Item.php b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Item.php index 31f64c3e221b3..9efc9b335d0b3 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Item.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/Item.php @@ -9,7 +9,8 @@ * Grid widget massaction single action item * * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation + * @since 100.0.2 */ class Item extends \Magento\Backend\Block\Widget { diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/VisibilityCheckerInterface.php b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/VisibilityCheckerInterface.php index 06756cb2d3c8a..08bce36930b73 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/VisibilityCheckerInterface.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/VisibilityCheckerInterface.php @@ -9,6 +9,7 @@ /** * @api + * @since 100.2.0 */ interface VisibilityCheckerInterface extends ArgumentInterface { @@ -16,6 +17,7 @@ interface VisibilityCheckerInterface extends ArgumentInterface * Check that action can be displayed on massaction list * * @return bool + * @since 100.2.0 */ public function isVisible(); } diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Serializer.php b/app/code/Magento/Backend/Block/Widget/Grid/Serializer.php index 953a26260d529..3473d9198e90d 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Serializer.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Serializer.php @@ -7,8 +7,9 @@ /** * @api - * @deprecated in favour of UI component implementation + * @deprecated 100.2.0 in favour of UI component implementation * @method string|array getInputNames() + * @since 100.0.2 */ class Serializer extends \Magento\Framework\View\Element\Template { diff --git a/app/code/Magento/Backend/Block/Widget/Tab.php b/app/code/Magento/Backend/Block/Widget/Tab.php index 96d55e00261e9..1ae35f1a6993b 100644 --- a/app/code/Magento/Backend/Block/Widget/Tab.php +++ b/app/code/Magento/Backend/Block/Widget/Tab.php @@ -10,6 +10,7 @@ /** * @api + * @since 100.0.2 */ class Tab extends \Magento\Backend\Block\Template implements TabInterface { diff --git a/app/code/Magento/Backend/Block/Widget/Tab/TabInterface.php b/app/code/Magento/Backend/Block/Widget/Tab/TabInterface.php index bf55470ab5935..404e29611f731 100644 --- a/app/code/Magento/Backend/Block/Widget/Tab/TabInterface.php +++ b/app/code/Magento/Backend/Block/Widget/Tab/TabInterface.php @@ -9,6 +9,7 @@ * Backend Widget Tab Interface * * @api + * @since 100.0.2 */ interface TabInterface { diff --git a/app/code/Magento/Backend/Block/Widget/Tabs.php b/app/code/Magento/Backend/Block/Widget/Tabs.php index 111f1908674e0..ec3628d2fcb43 100644 --- a/app/code/Magento/Backend/Block/Widget/Tabs.php +++ b/app/code/Magento/Backend/Block/Widget/Tabs.php @@ -10,6 +10,7 @@ /** * @api * @SuppressWarnings(PHPMD.NumberOfChildren) + * @since 100.0.2 */ class Tabs extends \Magento\Backend\Block\Widget { @@ -34,7 +35,9 @@ class Tabs extends \Magento\Backend\Block\Widget */ protected $_destElementId = 'content'; - /** @var string */ + /** + * @var string + */ protected $_template = 'Magento_Backend::widget/tabs.phtml'; /** diff --git a/app/code/Magento/Backend/Console/Command/AbstractCacheCommand.php b/app/code/Magento/Backend/Console/Command/AbstractCacheCommand.php index 540f046a13af6..70b01046f6afe 100644 --- a/app/code/Magento/Backend/Console/Command/AbstractCacheCommand.php +++ b/app/code/Magento/Backend/Console/Command/AbstractCacheCommand.php @@ -12,6 +12,7 @@ /** * @api + * @since 100.0.2 */ abstract class AbstractCacheCommand extends Command { diff --git a/app/code/Magento/Backend/Console/Command/AbstractCacheManageCommand.php b/app/code/Magento/Backend/Console/Command/AbstractCacheManageCommand.php index 461e74e2e32cd..35da8eace1fe7 100644 --- a/app/code/Magento/Backend/Console/Command/AbstractCacheManageCommand.php +++ b/app/code/Magento/Backend/Console/Command/AbstractCacheManageCommand.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ abstract class AbstractCacheManageCommand extends AbstractCacheCommand { diff --git a/app/code/Magento/Backend/Console/Command/AbstractCacheSetCommand.php b/app/code/Magento/Backend/Console/Command/AbstractCacheSetCommand.php index 1e342ae4747f8..02390d03783df 100644 --- a/app/code/Magento/Backend/Console/Command/AbstractCacheSetCommand.php +++ b/app/code/Magento/Backend/Console/Command/AbstractCacheSetCommand.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ abstract class AbstractCacheSetCommand extends AbstractCacheManageCommand { diff --git a/app/code/Magento/Backend/Console/Command/AbstractCacheTypeManageCommand.php b/app/code/Magento/Backend/Console/Command/AbstractCacheTypeManageCommand.php index 715a31c8cfa02..2facdf165c5df 100644 --- a/app/code/Magento/Backend/Console/Command/AbstractCacheTypeManageCommand.php +++ b/app/code/Magento/Backend/Console/Command/AbstractCacheTypeManageCommand.php @@ -13,10 +13,13 @@ /** * @api + * @since 100.0.2 */ abstract class AbstractCacheTypeManageCommand extends AbstractCacheManageCommand { - /** @var EventManagerInterface */ + /** + * @var \Magento\Framework\Event\ManagerInterface + */ protected $eventManager; /** diff --git a/app/code/Magento/Backend/Console/Command/CacheCleanCommand.php b/app/code/Magento/Backend/Console/Command/CacheCleanCommand.php index 5b5294f3980bf..d2db9ddff2052 100644 --- a/app/code/Magento/Backend/Console/Command/CacheCleanCommand.php +++ b/app/code/Magento/Backend/Console/Command/CacheCleanCommand.php @@ -10,6 +10,7 @@ * Command for cleaning cache * * @api + * @since 100.0.2 */ class CacheCleanCommand extends AbstractCacheTypeManageCommand { diff --git a/app/code/Magento/Backend/Console/Command/CacheDisableCommand.php b/app/code/Magento/Backend/Console/Command/CacheDisableCommand.php index 3cd94b3167ca1..6e35ed5bd7143 100644 --- a/app/code/Magento/Backend/Console/Command/CacheDisableCommand.php +++ b/app/code/Magento/Backend/Console/Command/CacheDisableCommand.php @@ -10,6 +10,7 @@ * Command for disabling cache * * @api + * @since 100.0.2 */ class CacheDisableCommand extends AbstractCacheSetCommand { diff --git a/app/code/Magento/Backend/Console/Command/CacheEnableCommand.php b/app/code/Magento/Backend/Console/Command/CacheEnableCommand.php index b3e8318f46abe..4413e98c43144 100644 --- a/app/code/Magento/Backend/Console/Command/CacheEnableCommand.php +++ b/app/code/Magento/Backend/Console/Command/CacheEnableCommand.php @@ -10,6 +10,7 @@ * Command for enabling cache * * @api + * @since 100.0.2 */ class CacheEnableCommand extends AbstractCacheSetCommand { diff --git a/app/code/Magento/Backend/Console/Command/CacheFlushCommand.php b/app/code/Magento/Backend/Console/Command/CacheFlushCommand.php index 9780df970e070..6a1589891c1d2 100644 --- a/app/code/Magento/Backend/Console/Command/CacheFlushCommand.php +++ b/app/code/Magento/Backend/Console/Command/CacheFlushCommand.php @@ -10,6 +10,7 @@ * Command for flushing cache * * @api + * @since 100.0.2 */ class CacheFlushCommand extends AbstractCacheTypeManageCommand { diff --git a/app/code/Magento/Backend/Console/Command/CacheStatusCommand.php b/app/code/Magento/Backend/Console/Command/CacheStatusCommand.php index 93002cc0a8d4d..c2d2c6fe49d90 100644 --- a/app/code/Magento/Backend/Console/Command/CacheStatusCommand.php +++ b/app/code/Magento/Backend/Console/Command/CacheStatusCommand.php @@ -13,6 +13,7 @@ * Command for checking cache status * * @api + * @since 100.0.2 */ class CacheStatusCommand extends AbstractCacheCommand { diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Ajax/Translate.php b/app/code/Magento/Backend/Controller/Adminhtml/Ajax/Translate.php index 21c4efd246908..b7cb62c45e617 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Ajax/Translate.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Ajax/Translate.php @@ -20,6 +20,11 @@ class Translate extends \Magento\Backend\App\Action */ protected $resultJsonFactory; + /** + * Authorization level of a basic admin session + */ + const ADMIN_RESOURCE = 'Magento_Backend::content_translation'; + /** * @param Action\Context $context * @param \Magento\Framework\Translate\Inline\ParserInterface $inlineParser diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Auth/Login.php b/app/code/Magento/Backend/Controller/Adminhtml/Auth/Login.php index 6d89ded853557..b34e4d9c84939 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Auth/Login.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Auth/Login.php @@ -8,6 +8,7 @@ /** * @api + * @since 100.0.2 */ class Login extends \Magento\Backend\Controller\Adminhtml\Auth { diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassDisable.php b/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassDisable.php index 6e514357433d7..204105852b9f1 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassDisable.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassDisable.php @@ -73,7 +73,7 @@ private function disableCache() * Get State Instance * * @return State - * @deprecated + * @deprecated 100.2.0 */ private function getState() { diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassEnable.php b/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassEnable.php index 99997e916129d..32acf47887c44 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassEnable.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassEnable.php @@ -72,7 +72,7 @@ private function enableCache() * Get State Instance * * @return State - * @deprecated + * @deprecated 100.2.0 */ private function getState() { diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Index/GlobalSearch.php b/app/code/Magento/Backend/Controller/Adminhtml/Index/GlobalSearch.php index 985798c2aee69..9ca4021d08356 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Index/GlobalSearch.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Index/GlobalSearch.php @@ -8,6 +8,7 @@ /** * @api + * @since 100.0.2 */ class GlobalSearch extends \Magento\Backend\Controller\Adminhtml\Index { diff --git a/app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php b/app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php index 0e35e6ad55049..c9bce1cbf3888 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php @@ -26,7 +26,7 @@ class Save extends \Magento\Backend\Controller\Adminhtml\System\Account * Get security cookie * * @return SecurityCookie - * @deprecated + * @deprecated 100.1.0 */ private function getSecurityCookie() { diff --git a/app/code/Magento/Backend/Helper/Dashboard/AbstractDashboard.php b/app/code/Magento/Backend/Helper/Dashboard/AbstractDashboard.php index 4b630b5f05aca..6eb3ecb3049a9 100644 --- a/app/code/Magento/Backend/Helper/Dashboard/AbstractDashboard.php +++ b/app/code/Magento/Backend/Helper/Dashboard/AbstractDashboard.php @@ -9,6 +9,7 @@ * Adminhtml abstract dashboard helper. * * @api + * @since 100.0.2 */ abstract class AbstractDashboard extends \Magento\Framework\App\Helper\AbstractHelper { diff --git a/app/code/Magento/Backend/Helper/Dashboard/Data.php b/app/code/Magento/Backend/Helper/Dashboard/Data.php index 9ab7b8b9db615..29bffbd6a9dc2 100644 --- a/app/code/Magento/Backend/Helper/Dashboard/Data.php +++ b/app/code/Magento/Backend/Helper/Dashboard/Data.php @@ -12,6 +12,7 @@ * Data helper for dashboard * * @api + * @since 100.0.2 */ class Data extends \Magento\Framework\App\Helper\AbstractHelper { diff --git a/app/code/Magento/Backend/Helper/Dashboard/Order.php b/app/code/Magento/Backend/Helper/Dashboard/Order.php index 926a9206b3f83..9fc2c2cdb4e6f 100644 --- a/app/code/Magento/Backend/Helper/Dashboard/Order.php +++ b/app/code/Magento/Backend/Helper/Dashboard/Order.php @@ -11,6 +11,7 @@ * Adminhtml dashboard helper for orders * * @api + * @since 100.0.2 */ class Order extends \Magento\Backend\Helper\Dashboard\AbstractDashboard { @@ -21,6 +22,7 @@ class Order extends \Magento\Backend\Helper\Dashboard\AbstractDashboard /** * @var \Magento\Store\Model\StoreManagerInterface + * @since 100.0.6 */ protected $_storeManager; @@ -41,7 +43,7 @@ public function __construct( * * @return \Magento\Store\Model\StoreManagerInterface * - * @deprecated + * @deprecated 100.1.0 */ private function getStoreManager() { diff --git a/app/code/Magento/Backend/Helper/Data.php b/app/code/Magento/Backend/Helper/Data.php index f763ca3e6a155..c5de032809bf0 100644 --- a/app/code/Magento/Backend/Helper/Data.php +++ b/app/code/Magento/Backend/Helper/Data.php @@ -9,8 +9,9 @@ /** * @api - * @deprecated + * @deprecated 100.2.0 * @SuppressWarnings(PHPMD.LongVariable) + * @since 100.0.2 */ class Data extends AbstractHelper { diff --git a/app/code/Magento/Backend/Helper/Js.php b/app/code/Magento/Backend/Helper/Js.php index 77f6212536b3d..a71b9c6763383 100644 --- a/app/code/Magento/Backend/Helper/Js.php +++ b/app/code/Magento/Backend/Helper/Js.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class Js { diff --git a/app/code/Magento/Backend/Model/AdminPathConfig.php b/app/code/Magento/Backend/Model/AdminPathConfig.php index 1ec9284289fd7..e7338adca4a2a 100644 --- a/app/code/Magento/Backend/Model/AdminPathConfig.php +++ b/app/code/Magento/Backend/Model/AdminPathConfig.php @@ -11,6 +11,7 @@ /** * Path config to be used in adminhtml area * @api + * @since 100.0.2 */ class AdminPathConfig implements PathConfigInterface { diff --git a/app/code/Magento/Backend/Model/Auth.php b/app/code/Magento/Backend/Model/Auth.php index fb3fe06ca1278..08921d1615f87 100644 --- a/app/code/Magento/Backend/Model/Auth.php +++ b/app/code/Magento/Backend/Model/Auth.php @@ -13,6 +13,7 @@ * Backend Auth model * * @api + * @since 100.0.2 */ class Auth { diff --git a/app/code/Magento/Backend/Model/Auth/Credential/StorageInterface.php b/app/code/Magento/Backend/Model/Auth/Credential/StorageInterface.php index 3b55eb5241ecf..a303418cfe59b 100644 --- a/app/code/Magento/Backend/Model/Auth/Credential/StorageInterface.php +++ b/app/code/Magento/Backend/Model/Auth/Credential/StorageInterface.php @@ -10,6 +10,7 @@ * * @author Magento Core Team * @api + * @since 100.0.2 */ interface StorageInterface { diff --git a/app/code/Magento/Backend/Model/Auth/Session.php b/app/code/Magento/Backend/Model/Auth/Session.php index 098ffec7ea9fd..593b4219d45f0 100644 --- a/app/code/Magento/Backend/Model/Auth/Session.php +++ b/app/code/Magento/Backend/Model/Auth/Session.php @@ -22,6 +22,7 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @todo implement solution that keeps is_first_visit flag in session during redirects * @api + * @since 100.0.2 */ class Session extends \Magento\Framework\Session\SessionManager implements \Magento\Backend\Model\Auth\StorageInterface { diff --git a/app/code/Magento/Backend/Model/Auth/StorageInterface.php b/app/code/Magento/Backend/Model/Auth/StorageInterface.php index 60ed16a20848a..52b2b089c71e1 100644 --- a/app/code/Magento/Backend/Model/Auth/StorageInterface.php +++ b/app/code/Magento/Backend/Model/Auth/StorageInterface.php @@ -9,6 +9,7 @@ * Backend Auth Storage interface * * @api + * @since 100.0.2 */ interface StorageInterface { diff --git a/app/code/Magento/Backend/Model/Authorization/RoleLocator.php b/app/code/Magento/Backend/Model/Authorization/RoleLocator.php index 4af0a8b29db1d..5e76d09acd2ff 100644 --- a/app/code/Magento/Backend/Model/Authorization/RoleLocator.php +++ b/app/code/Magento/Backend/Model/Authorization/RoleLocator.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class RoleLocator implements \Magento\Framework\Authorization\RoleLocatorInterface { diff --git a/app/code/Magento/Backend/Model/Cache/ResourceModel/Grid/Collection.php b/app/code/Magento/Backend/Model/Cache/ResourceModel/Grid/Collection.php index 409c821b64ee2..50ad1976a379f 100644 --- a/app/code/Magento/Backend/Model/Cache/ResourceModel/Grid/Collection.php +++ b/app/code/Magento/Backend/Model/Cache/ResourceModel/Grid/Collection.php @@ -9,6 +9,7 @@ /** * @api + * @since 100.0.2 */ class Collection extends \Magento\Framework\Data\Collection { diff --git a/app/code/Magento/Backend/Model/Config/SessionLifetime/BackendModel.php b/app/code/Magento/Backend/Model/Config/SessionLifetime/BackendModel.php index 36a16ed986e11..09f33abd0d44d 100644 --- a/app/code/Magento/Backend/Model/Config/SessionLifetime/BackendModel.php +++ b/app/code/Magento/Backend/Model/Config/SessionLifetime/BackendModel.php @@ -11,6 +11,7 @@ /** * Backend model for the admin/security/session_lifetime configuration field. Validates session lifetime. * @api + * @since 100.1.0 */ class BackendModel extends Value { @@ -20,6 +21,9 @@ class BackendModel extends Value /** Minimum admin session lifetime */ const MIN_LIFETIME = 60; + /** + * @since 100.1.0 + */ public function beforeSave() { $value = (int) $this->getValue(); diff --git a/app/code/Magento/Backend/Model/Locale/Manager.php b/app/code/Magento/Backend/Model/Locale/Manager.php index 8af08444aa1b1..24adafc7635af 100644 --- a/app/code/Magento/Backend/Model/Locale/Manager.php +++ b/app/code/Magento/Backend/Model/Locale/Manager.php @@ -10,6 +10,7 @@ * * @author Magento Core Team * @api + * @since 100.0.2 */ class Manager { @@ -30,6 +31,7 @@ class Manager /** * @var \Magento\Backend\App\ConfigInterface + * @since 100.1.0 */ protected $_backendConfig; @@ -74,6 +76,7 @@ public function switchBackendInterfaceLocale($localeCode) * Get general interface locale * * @return string + * @since 100.1.0 */ public function getGeneralLocale() { diff --git a/app/code/Magento/Backend/Model/Locale/Resolver.php b/app/code/Magento/Backend/Model/Locale/Resolver.php index fd6589ebf5fc8..b9be471cd5990 100644 --- a/app/code/Magento/Backend/Model/Locale/Resolver.php +++ b/app/code/Magento/Backend/Model/Locale/Resolver.php @@ -8,6 +8,7 @@ /** * Backend locale model * @api + * @since 100.0.2 */ class Resolver extends \Magento\Framework\Locale\Resolver { diff --git a/app/code/Magento/Backend/Model/Menu.php b/app/code/Magento/Backend/Model/Menu.php index 1f199293ecfcf..22110cf52de2b 100644 --- a/app/code/Magento/Backend/Model/Menu.php +++ b/app/code/Magento/Backend/Model/Menu.php @@ -15,6 +15,7 @@ * Backend menu model * * @api + * @since 100.0.2 */ class Menu extends \ArrayObject { @@ -275,6 +276,7 @@ public function serialize() * Get menu data represented as an array * * @return array + * @since 100.2.0 */ public function toArray() { @@ -290,6 +292,7 @@ public function toArray() * * @param string $serialized * @return void + * @since 100.2.0 */ public function unserialize($serialized) { @@ -302,6 +305,7 @@ public function unserialize($serialized) * * @param array $data * @return void + * @since 100.2.0 */ public function populateFromArray(array $data) { diff --git a/app/code/Magento/Backend/Model/Menu/AbstractDirector.php b/app/code/Magento/Backend/Model/Menu/AbstractDirector.php index 9b70d3405d715..4bd96575f3080 100644 --- a/app/code/Magento/Backend/Model/Menu/AbstractDirector.php +++ b/app/code/Magento/Backend/Model/Menu/AbstractDirector.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ abstract class AbstractDirector { diff --git a/app/code/Magento/Backend/Model/Menu/Builder.php b/app/code/Magento/Backend/Model/Menu/Builder.php index 435f1014cf363..ae572deab53d9 100644 --- a/app/code/Magento/Backend/Model/Menu/Builder.php +++ b/app/code/Magento/Backend/Model/Menu/Builder.php @@ -9,6 +9,7 @@ * Menu builder object. Retrieves commands (\Magento\Backend\Model\Menu\Builder\AbstractCommand) * to build menu (\Magento\Backend\Model\Menu) * @api + * @since 100.0.2 */ class Builder { diff --git a/app/code/Magento/Backend/Model/Menu/Builder/AbstractCommand.php b/app/code/Magento/Backend/Model/Menu/Builder/AbstractCommand.php index 9a5bcf67162e0..720fe9b757004 100644 --- a/app/code/Magento/Backend/Model/Menu/Builder/AbstractCommand.php +++ b/app/code/Magento/Backend/Model/Menu/Builder/AbstractCommand.php @@ -8,6 +8,7 @@ /** * Menu builder command * @api + * @since 100.0.2 */ abstract class AbstractCommand { diff --git a/app/code/Magento/Backend/Model/Menu/Builder/Command/Add.php b/app/code/Magento/Backend/Model/Menu/Builder/Command/Add.php index ae9565be24297..b32df7dd9929a 100644 --- a/app/code/Magento/Backend/Model/Menu/Builder/Command/Add.php +++ b/app/code/Magento/Backend/Model/Menu/Builder/Command/Add.php @@ -8,6 +8,7 @@ /** * Builder command to add menu items * @api + * @since 100.0.2 */ class Add extends \Magento\Backend\Model\Menu\Builder\AbstractCommand { diff --git a/app/code/Magento/Backend/Model/Menu/Builder/Command/Remove.php b/app/code/Magento/Backend/Model/Menu/Builder/Command/Remove.php index 46cfa5fee1806..5ee81a06cddb2 100644 --- a/app/code/Magento/Backend/Model/Menu/Builder/Command/Remove.php +++ b/app/code/Magento/Backend/Model/Menu/Builder/Command/Remove.php @@ -8,6 +8,7 @@ /** * Command to remove menu item * @api + * @since 100.0.2 */ class Remove extends \Magento\Backend\Model\Menu\Builder\AbstractCommand { diff --git a/app/code/Magento/Backend/Model/Menu/Builder/Command/Update.php b/app/code/Magento/Backend/Model/Menu/Builder/Command/Update.php index abd03726f200e..eaaf947bcb2bc 100644 --- a/app/code/Magento/Backend/Model/Menu/Builder/Command/Update.php +++ b/app/code/Magento/Backend/Model/Menu/Builder/Command/Update.php @@ -8,6 +8,7 @@ /** * Command to update menu item data * @api + * @since 100.0.2 */ class Update extends \Magento\Backend\Model\Menu\Builder\AbstractCommand { diff --git a/app/code/Magento/Backend/Model/Menu/Builder/CommandFactory.php b/app/code/Magento/Backend/Model/Menu/Builder/CommandFactory.php index 337a3d583ca6e..5b2cfa584cc3a 100644 --- a/app/code/Magento/Backend/Model/Menu/Builder/CommandFactory.php +++ b/app/code/Magento/Backend/Model/Menu/Builder/CommandFactory.php @@ -8,6 +8,7 @@ /** * Menu builder command factory * @api + * @since 100.0.2 */ class CommandFactory { diff --git a/app/code/Magento/Backend/Model/Menu/Config.php b/app/code/Magento/Backend/Model/Menu/Config.php index 2386959417918..b268da43f6f7b 100644 --- a/app/code/Magento/Backend/Model/Menu/Config.php +++ b/app/code/Magento/Backend/Model/Menu/Config.php @@ -8,6 +8,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @api + * @since 100.0.2 */ class Config { diff --git a/app/code/Magento/Backend/Model/Menu/Config/Converter.php b/app/code/Magento/Backend/Model/Menu/Config/Converter.php index 1444ab3a21c36..26db8e3a505ce 100644 --- a/app/code/Magento/Backend/Model/Menu/Config/Converter.php +++ b/app/code/Magento/Backend/Model/Menu/Config/Converter.php @@ -8,6 +8,7 @@ /** * Class Converter converts xml to appropriate array * @api + * @since 100.0.2 */ class Converter implements \Magento\Framework\Config\ConverterInterface { diff --git a/app/code/Magento/Backend/Model/Menu/Config/Menu/Dom.php b/app/code/Magento/Backend/Model/Menu/Config/Menu/Dom.php index 30ba12dd04b15..4c8c66f785dce 100644 --- a/app/code/Magento/Backend/Model/Menu/Config/Menu/Dom.php +++ b/app/code/Magento/Backend/Model/Menu/Config/Menu/Dom.php @@ -8,6 +8,7 @@ /** * Menu configuration files handler * @api + * @since 100.0.2 */ class Dom extends \Magento\Framework\Config\Dom { diff --git a/app/code/Magento/Backend/Model/Menu/Config/Reader.php b/app/code/Magento/Backend/Model/Menu/Config/Reader.php index 9b1a3cde08b36..f94e1f57e2cb5 100644 --- a/app/code/Magento/Backend/Model/Menu/Config/Reader.php +++ b/app/code/Magento/Backend/Model/Menu/Config/Reader.php @@ -9,6 +9,7 @@ /** * @api + * @since 100.0.2 */ class Reader extends \Magento\Framework\Config\Reader\Filesystem { diff --git a/app/code/Magento/Backend/Model/Menu/Config/SchemaLocator.php b/app/code/Magento/Backend/Model/Menu/Config/SchemaLocator.php index 371f0443a1432..413060cbbcef2 100644 --- a/app/code/Magento/Backend/Model/Menu/Config/SchemaLocator.php +++ b/app/code/Magento/Backend/Model/Menu/Config/SchemaLocator.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class SchemaLocator implements \Magento\Framework\Config\SchemaLocatorInterface { diff --git a/app/code/Magento/Backend/Model/Menu/Director/Director.php b/app/code/Magento/Backend/Model/Menu/Director/Director.php index c7f7c2d322739..7821a4dbae00a 100644 --- a/app/code/Magento/Backend/Model/Menu/Director/Director.php +++ b/app/code/Magento/Backend/Model/Menu/Director/Director.php @@ -8,6 +8,7 @@ /** * @api + * @since 100.0.2 */ class Director extends \Magento\Backend\Model\Menu\AbstractDirector { diff --git a/app/code/Magento/Backend/Model/Menu/Filter/Iterator.php b/app/code/Magento/Backend/Model/Menu/Filter/Iterator.php index 712b2e9a28e97..b6c61a1362edd 100644 --- a/app/code/Magento/Backend/Model/Menu/Filter/Iterator.php +++ b/app/code/Magento/Backend/Model/Menu/Filter/Iterator.php @@ -8,6 +8,7 @@ /** * Menu filter iterator * @api + * @since 100.0.2 */ class Iterator extends \FilterIterator { diff --git a/app/code/Magento/Backend/Model/Menu/Item.php b/app/code/Magento/Backend/Model/Menu/Item.php index 57d9012d9a597..fe6564d24e891 100644 --- a/app/code/Magento/Backend/Model/Menu/Item.php +++ b/app/code/Magento/Backend/Model/Menu/Item.php @@ -14,6 +14,7 @@ * * @api * @SuppressWarnings(PHPMD.TooManyFields) + * @since 100.0.2 */ class Item { @@ -132,7 +133,7 @@ class Item * Serialized submenu string * * @var string - * @deprecated + * @deprecated 100.2.0 */ protected $_serializedSubmenu; @@ -213,6 +214,7 @@ public function getId() * Retrieve item target * * @return string|null + * @since 100.2.0 */ public function getTarget() { @@ -459,6 +461,7 @@ public function isAllowed() * Get menu item data represented as an array * * @return array + * @since 100.2.0 */ public function toArray() { @@ -484,6 +487,7 @@ public function toArray() * * @param array $data * @return void + * @since 100.2.0 */ public function populateFromArray(array $data) { diff --git a/app/code/Magento/Backend/Model/Menu/Item/Factory.php b/app/code/Magento/Backend/Model/Menu/Item/Factory.php index 2a1e179f3e00c..3ce056e2ede5a 100644 --- a/app/code/Magento/Backend/Model/Menu/Item/Factory.php +++ b/app/code/Magento/Backend/Model/Menu/Item/Factory.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Factory { diff --git a/app/code/Magento/Backend/Model/Menu/Item/Validator.php b/app/code/Magento/Backend/Model/Menu/Item/Validator.php index e383354231f76..d79752b296e5f 100644 --- a/app/code/Magento/Backend/Model/Menu/Item/Validator.php +++ b/app/code/Magento/Backend/Model/Menu/Item/Validator.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Validator { diff --git a/app/code/Magento/Backend/Model/Menu/Iterator.php b/app/code/Magento/Backend/Model/Menu/Iterator.php index 6bf295702a10f..7e98da0571263 100644 --- a/app/code/Magento/Backend/Model/Menu/Iterator.php +++ b/app/code/Magento/Backend/Model/Menu/Iterator.php @@ -8,6 +8,7 @@ /** * Menu iterator * @api + * @since 100.0.2 */ class Iterator extends \ArrayIterator { diff --git a/app/code/Magento/Backend/Model/ResourceModel/Translate.php b/app/code/Magento/Backend/Model/ResourceModel/Translate.php index ec9fd8bfa1768..46c3a0fc016b0 100644 --- a/app/code/Magento/Backend/Model/ResourceModel/Translate.php +++ b/app/code/Magento/Backend/Model/ResourceModel/Translate.php @@ -8,6 +8,7 @@ /** * Backend translate resource model * @api + * @since 100.0.2 */ class Translate extends \Magento\Translation\Model\ResourceModel\Translate { diff --git a/app/code/Magento/Backend/Model/Search/Customer.php b/app/code/Magento/Backend/Model/Search/Customer.php index 4ce437dc2617b..35a7359ce9980 100644 --- a/app/code/Magento/Backend/Model/Search/Customer.php +++ b/app/code/Magento/Backend/Model/Search/Customer.php @@ -20,6 +20,7 @@ * @method Customer setResults(array $results) * @method array getResults() * @api + * @since 100.0.2 */ class Customer extends \Magento\Framework\DataObject { diff --git a/app/code/Magento/Backend/Model/Search/Order.php b/app/code/Magento/Backend/Model/Search/Order.php index 5970e8b586e16..728cf7414f3d8 100644 --- a/app/code/Magento/Backend/Model/Search/Order.php +++ b/app/code/Magento/Backend/Model/Search/Order.php @@ -10,6 +10,7 @@ * * @author Magento Core Team * @api + * @since 100.0.2 */ class Order extends \Magento\Framework\DataObject { diff --git a/app/code/Magento/Backend/Model/Session.php b/app/code/Magento/Backend/Model/Session.php index 4f4e1e61db77e..8baee0bc5431a 100644 --- a/app/code/Magento/Backend/Model/Session.php +++ b/app/code/Magento/Backend/Model/Session.php @@ -9,6 +9,7 @@ * Backend user session * * @api + * @since 100.0.2 */ class Session extends \Magento\Framework\Session\SessionManager { diff --git a/app/code/Magento/Backend/Model/Session/AdminConfig.php b/app/code/Magento/Backend/Model/Session/AdminConfig.php index 7e48b54d7575a..2662d7a2d7eeb 100644 --- a/app/code/Magento/Backend/Model/Session/AdminConfig.php +++ b/app/code/Magento/Backend/Model/Session/AdminConfig.php @@ -15,6 +15,7 @@ /** * Magento Backend session configuration * @api + * @since 100.0.2 */ class AdminConfig extends Config { @@ -111,6 +112,7 @@ private function extractAdminPath() * Set session cookie lifetime to session duration * * @return $this + * @since 100.1.0 */ protected function configureCookieLifetime() { diff --git a/app/code/Magento/Backend/Model/Session/Quote.php b/app/code/Magento/Backend/Model/Session/Quote.php index 2c072c051388b..11edaa26f443f 100644 --- a/app/code/Magento/Backend/Model/Session/Quote.php +++ b/app/code/Magento/Backend/Model/Session/Quote.php @@ -24,6 +24,7 @@ * @method Quote setOrderId($orderId) * @method int getOrderId() * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class Quote extends \Magento\Framework\Session\SessionManager { diff --git a/app/code/Magento/Backend/Model/Setup/MenuBuilder.php b/app/code/Magento/Backend/Model/Setup/MenuBuilder.php index 4c43c95e11460..6bdb036d20ff9 100644 --- a/app/code/Magento/Backend/Model/Setup/MenuBuilder.php +++ b/app/code/Magento/Backend/Model/Setup/MenuBuilder.php @@ -12,11 +12,13 @@ /** * Plugin class to remove web setup wizard from menu if application root is pub/ and no setup url variable is specified. * @api + * @since 100.1.0 */ class MenuBuilder { /** * @var DocRootLocator + * @since 100.1.0 */ protected $docRootLocator; @@ -37,6 +39,7 @@ public function __construct(DocRootLocator $docRootLocator) * @param Menu $menu * @return Menu * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @since 100.1.0 */ public function afterGetResult(Builder $subject, Menu $menu) { diff --git a/app/code/Magento/Backend/Model/Translate/Inline/Config.php b/app/code/Magento/Backend/Model/Translate/Inline/Config.php index 93d44899705ce..838c32295c9f4 100644 --- a/app/code/Magento/Backend/Model/Translate/Inline/Config.php +++ b/app/code/Magento/Backend/Model/Translate/Inline/Config.php @@ -8,6 +8,7 @@ /** * Backend Inline Translation config * @api + * @since 100.0.2 */ class Config implements \Magento\Framework\Translate\Inline\ConfigInterface { diff --git a/app/code/Magento/Backend/Model/Url.php b/app/code/Magento/Backend/Model/Url.php index b2040c90493f2..48b443fe7ffd3 100644 --- a/app/code/Magento/Backend/Model/Url.php +++ b/app/code/Magento/Backend/Model/Url.php @@ -14,6 +14,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @api + * @since 100.0.2 */ class Url extends \Magento\Framework\Url implements \Magento\Backend\Model\UrlInterface { diff --git a/app/code/Magento/Backend/Model/Url/ScopeResolver.php b/app/code/Magento/Backend/Model/Url/ScopeResolver.php index 0d886f8f4547a..90bc18fe62833 100644 --- a/app/code/Magento/Backend/Model/Url/ScopeResolver.php +++ b/app/code/Magento/Backend/Model/Url/ScopeResolver.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class ScopeResolver extends \Magento\Framework\Url\ScopeResolver { diff --git a/app/code/Magento/Backend/Model/UrlInterface.php b/app/code/Magento/Backend/Model/UrlInterface.php index 3d75d617398c4..02c124d228c90 100644 --- a/app/code/Magento/Backend/Model/UrlInterface.php +++ b/app/code/Magento/Backend/Model/UrlInterface.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ interface UrlInterface extends \Magento\Framework\UrlInterface { diff --git a/app/code/Magento/Backend/Model/View/Layout/Builder.php b/app/code/Magento/Backend/Model/View/Layout/Builder.php index 9eaaf1a9f892a..c37630ca8f824 100644 --- a/app/code/Magento/Backend/Model/View/Layout/Builder.php +++ b/app/code/Magento/Backend/Model/View/Layout/Builder.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class Builder extends \Magento\Framework\View\Layout\Builder { diff --git a/app/code/Magento/Backend/Model/View/Layout/Reader/Block.php b/app/code/Magento/Backend/Model/View/Layout/Reader/Block.php index 80264b2f6a1ff..2b44c52895805 100644 --- a/app/code/Magento/Backend/Model/View/Layout/Reader/Block.php +++ b/app/code/Magento/Backend/Model/View/Layout/Reader/Block.php @@ -12,6 +12,7 @@ /** * Backend block structure reader with ACL support * @api + * @since 100.0.2 */ class Block extends Layout\Reader\Block { diff --git a/app/code/Magento/Backend/Model/View/Layout/StructureManager.php b/app/code/Magento/Backend/Model/View/Layout/StructureManager.php index 74d835ea08802..fdcbbeeed1e12 100644 --- a/app/code/Magento/Backend/Model/View/Layout/StructureManager.php +++ b/app/code/Magento/Backend/Model/View/Layout/StructureManager.php @@ -16,6 +16,7 @@ * By using this class developer can remove layout entities (block, uiComponent) from scheduled structure * Removed entities will not appear at rendered page * @api + * @since 100.2.0 */ class StructureManager { @@ -27,6 +28,7 @@ class StructureManager * @param string $elementName * @param bool $isChild * @return bool + * @since 100.2.0 */ public function removeElement( ScheduledStructure $scheduledStructure, diff --git a/app/code/Magento/Backend/Model/View/Page/Builder.php b/app/code/Magento/Backend/Model/View/Page/Builder.php index 53b6229f970c8..b0654472b1ae2 100644 --- a/app/code/Magento/Backend/Model/View/Page/Builder.php +++ b/app/code/Magento/Backend/Model/View/Page/Builder.php @@ -12,6 +12,7 @@ /** * @api + * @since 100.0.2 */ class Builder extends View\Page\Builder { diff --git a/app/code/Magento/Backend/Model/View/Result/Forward.php b/app/code/Magento/Backend/Model/View/Result/Forward.php index 426f743b32862..5d537647a79d4 100644 --- a/app/code/Magento/Backend/Model/View/Result/Forward.php +++ b/app/code/Magento/Backend/Model/View/Result/Forward.php @@ -12,6 +12,7 @@ /** * @api + * @since 100.0.2 */ class Forward extends \Magento\Framework\Controller\Result\Forward { diff --git a/app/code/Magento/Backend/Model/View/Result/Page.php b/app/code/Magento/Backend/Model/View/Result/Page.php index e59d062146968..2ea9cdf2ee7bd 100644 --- a/app/code/Magento/Backend/Model/View/Result/Page.php +++ b/app/code/Magento/Backend/Model/View/Result/Page.php @@ -10,6 +10,7 @@ /** * @api + * @since 100.0.2 */ class Page extends View\Result\Page { diff --git a/app/code/Magento/Backend/Model/View/Result/Redirect.php b/app/code/Magento/Backend/Model/View/Result/Redirect.php index fbb0f8bcd4694..e8e39cb64ea2b 100644 --- a/app/code/Magento/Backend/Model/View/Result/Redirect.php +++ b/app/code/Magento/Backend/Model/View/Result/Redirect.php @@ -14,6 +14,7 @@ /** * @api + * @since 100.0.2 */ class Redirect extends \Magento\Framework\Controller\Result\Redirect { diff --git a/app/code/Magento/Backend/Model/View/Result/RedirectFactory.php b/app/code/Magento/Backend/Model/View/Result/RedirectFactory.php index 73fe23c3f7166..3276b2692a638 100644 --- a/app/code/Magento/Backend/Model/View/Result/RedirectFactory.php +++ b/app/code/Magento/Backend/Model/View/Result/RedirectFactory.php @@ -10,6 +10,7 @@ /** * Factory class for \Magento\Backend\Model\View\Result\Redirect * @api + * @since 100.0.2 */ class RedirectFactory extends \Magento\Framework\Controller\Result\RedirectFactory { diff --git a/app/code/Magento/Backend/Model/Widget/Grid/AbstractTotals.php b/app/code/Magento/Backend/Model/Widget/Grid/AbstractTotals.php index b730ee5fd5ea1..bb68853dcc08d 100644 --- a/app/code/Magento/Backend/Model/Widget/Grid/AbstractTotals.php +++ b/app/code/Magento/Backend/Model/Widget/Grid/AbstractTotals.php @@ -8,6 +8,7 @@ /** * @api + * @since 100.0.2 */ abstract class AbstractTotals implements \Magento\Backend\Model\Widget\Grid\TotalsInterface { diff --git a/app/code/Magento/Backend/Model/Widget/Grid/Parser.php b/app/code/Magento/Backend/Model/Widget/Grid/Parser.php index 1976302f34cf7..e2b77fb471acd 100644 --- a/app/code/Magento/Backend/Model/Widget/Grid/Parser.php +++ b/app/code/Magento/Backend/Model/Widget/Grid/Parser.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Parser { diff --git a/app/code/Magento/Backend/Model/Widget/Grid/Row/GeneratorInterface.php b/app/code/Magento/Backend/Model/Widget/Grid/Row/GeneratorInterface.php index be36d90a61435..f150f8d7c30d4 100644 --- a/app/code/Magento/Backend/Model/Widget/Grid/Row/GeneratorInterface.php +++ b/app/code/Magento/Backend/Model/Widget/Grid/Row/GeneratorInterface.php @@ -9,6 +9,7 @@ /** * @api + * @since 100.0.2 */ interface GeneratorInterface { diff --git a/app/code/Magento/Backend/Model/Widget/Grid/Row/UrlGenerator.php b/app/code/Magento/Backend/Model/Widget/Grid/Row/UrlGenerator.php index c08982ffc798a..acdb1f0c8a35b 100644 --- a/app/code/Magento/Backend/Model/Widget/Grid/Row/UrlGenerator.php +++ b/app/code/Magento/Backend/Model/Widget/Grid/Row/UrlGenerator.php @@ -8,6 +8,7 @@ /** * Grid row url generator * @api + * @since 100.0.2 */ class UrlGenerator implements \Magento\Backend\Model\Widget\Grid\Row\GeneratorInterface { diff --git a/app/code/Magento/Backend/Model/Widget/Grid/Row/UrlGeneratorFactory.php b/app/code/Magento/Backend/Model/Widget/Grid/Row/UrlGeneratorFactory.php index 61030a3d94676..93ba6284c7ac8 100644 --- a/app/code/Magento/Backend/Model/Widget/Grid/Row/UrlGeneratorFactory.php +++ b/app/code/Magento/Backend/Model/Widget/Grid/Row/UrlGeneratorFactory.php @@ -9,6 +9,7 @@ * Grid row url generator factory * * @api + * @since 100.0.2 */ class UrlGeneratorFactory { diff --git a/app/code/Magento/Backend/Model/Widget/Grid/Row/UrlGeneratorId.php b/app/code/Magento/Backend/Model/Widget/Grid/Row/UrlGeneratorId.php index 8fb767a593796..99a640129cf1e 100644 --- a/app/code/Magento/Backend/Model/Widget/Grid/Row/UrlGeneratorId.php +++ b/app/code/Magento/Backend/Model/Widget/Grid/Row/UrlGeneratorId.php @@ -9,6 +9,7 @@ /** * @api + * @since 100.0.2 */ class UrlGeneratorId implements \Magento\Backend\Model\Widget\Grid\Row\GeneratorInterface { diff --git a/app/code/Magento/Backend/Model/Widget/Grid/SubTotals.php b/app/code/Magento/Backend/Model/Widget/Grid/SubTotals.php index db3d9eeefc30a..e36a6691a0dbd 100644 --- a/app/code/Magento/Backend/Model/Widget/Grid/SubTotals.php +++ b/app/code/Magento/Backend/Model/Widget/Grid/SubTotals.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class SubTotals extends \Magento\Backend\Model\Widget\Grid\AbstractTotals { diff --git a/app/code/Magento/Backend/Model/Widget/Grid/Totals.php b/app/code/Magento/Backend/Model/Widget/Grid/Totals.php index e77012bb52ee9..7a3c36f543c60 100644 --- a/app/code/Magento/Backend/Model/Widget/Grid/Totals.php +++ b/app/code/Magento/Backend/Model/Widget/Grid/Totals.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Totals extends \Magento\Backend\Model\Widget\Grid\AbstractTotals { diff --git a/app/code/Magento/Backend/Model/Widget/Grid/TotalsInterface.php b/app/code/Magento/Backend/Model/Widget/Grid/TotalsInterface.php index dae27b0767334..81441add35f59 100644 --- a/app/code/Magento/Backend/Model/Widget/Grid/TotalsInterface.php +++ b/app/code/Magento/Backend/Model/Widget/Grid/TotalsInterface.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ interface TotalsInterface { diff --git a/app/code/Magento/Backend/Service/V1/ModuleServiceInterface.php b/app/code/Magento/Backend/Service/V1/ModuleServiceInterface.php index c04ab23ab7486..d974bbfa31503 100644 --- a/app/code/Magento/Backend/Service/V1/ModuleServiceInterface.php +++ b/app/code/Magento/Backend/Service/V1/ModuleServiceInterface.php @@ -9,6 +9,7 @@ /** * Interface for module service. * @api + * @since 100.0.2 */ interface ModuleServiceInterface { diff --git a/app/code/Magento/Backend/Setup/ConfigOptionsList.php b/app/code/Magento/Backend/Setup/ConfigOptionsList.php index a840162cbd027..2d1723886b1dd 100644 --- a/app/code/Magento/Backend/Setup/ConfigOptionsList.php +++ b/app/code/Magento/Backend/Setup/ConfigOptionsList.php @@ -12,8 +12,9 @@ use Magento\Framework\App\DeploymentConfig; use \Magento\Framework\Setup\BackendFrontnameGenerator; -/* +/** * Deployment configuration options needed for Backend module + * */ class ConfigOptionsList implements ConfigOptionsListInterface { diff --git a/app/code/Magento/Backend/Test/Unit/App/Action/Plugin/AuthenticationTest.php b/app/code/Magento/Backend/Test/Unit/App/Action/Plugin/AuthenticationTest.php index e114fa7bb00e7..7e4c426de9452 100644 --- a/app/code/Magento/Backend/Test/Unit/App/Action/Plugin/AuthenticationTest.php +++ b/app/code/Magento/Backend/Test/Unit/App/Action/Plugin/AuthenticationTest.php @@ -11,7 +11,7 @@ /** * Class AuthenticationTest */ -class AuthenticationTest extends \PHPUnit_Framework_TestCase +class AuthenticationTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\Model\Auth | \PHPUnit_Framework_MockObject_MockObject @@ -25,12 +25,9 @@ class AuthenticationTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->auth = $this->getMock( + $this->auth = $this->createPartialMock( \Magento\Backend\Model\Auth::class, - ['getUser', 'isLoggedIn', 'getAuthStorage'], - [], - '', - false + ['getUser', 'isLoggedIn', 'getAuthStorage'] ); $objectManager = new ObjectManager($this); $this->plugin = $objectManager->getObject( @@ -47,10 +44,10 @@ protected function tearDown() public function testAroundDispatchProlongStorage() { - $subject = $this->getMock(\Magento\Backend\Controller\Adminhtml\Index::class, [], [], '', false); - $request = $this->getMock(\Magento\Framework\App\Request\Http::class, ['getActionName'], [], '', false); - $user = $this->getMock(\Magento\User\Model\User::class, ['reload', '__wakeup'], [], '', false); - $storage = $this->getMock(\Magento\Backend\Model\Auth\Session::class, ['prolong', 'refreshAcl'], [], '', false); + $subject = $this->createMock(\Magento\Backend\Controller\Adminhtml\Index::class); + $request = $this->createPartialMock(\Magento\Framework\App\Request\Http::class, ['getActionName']); + $user = $this->createPartialMock(\Magento\User\Model\User::class, ['reload', '__wakeup']); + $storage = $this->createPartialMock(\Magento\Backend\Model\Auth\Session::class, ['prolong', 'refreshAcl']); $expectedResult = 'expectedResult'; $action = 'index'; diff --git a/app/code/Magento/Backend/Test/Unit/App/Action/Plugin/MassactionKeyTest.php b/app/code/Magento/Backend/Test/Unit/App/Action/Plugin/MassactionKeyTest.php index 3c82b1ad8073e..2f808eaf2d1b8 100644 --- a/app/code/Magento/Backend/Test/Unit/App/Action/Plugin/MassactionKeyTest.php +++ b/app/code/Magento/Backend/Test/Unit/App/Action/Plugin/MassactionKeyTest.php @@ -9,7 +9,7 @@ use Magento\Backend\App\AbstractAction; use Magento\Framework\App\RequestInterface; -class MassactionKeyTest extends \PHPUnit_Framework_TestCase +class MassactionKeyTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\App\Action\Plugin\MassactionKey @@ -31,7 +31,7 @@ protected function setUp() $this->closureMock = function () { return 'Expected'; }; - $this->subjectMock = $this->getMock(\Magento\Backend\App\AbstractAction::class, [], [], '', false); + $this->subjectMock = $this->createMock(\Magento\Backend\App\AbstractAction::class); $this->requestMock = $this->getMockForAbstractClass( RequestInterface::class, [], diff --git a/app/code/Magento/Backend/Test/Unit/App/Area/FrontNameResolverTest.php b/app/code/Magento/Backend/Test/Unit/App/Area/FrontNameResolverTest.php index 2a9002bc9a39f..bc7dce6f20bac 100644 --- a/app/code/Magento/Backend/Test/Unit/App/Area/FrontNameResolverTest.php +++ b/app/code/Magento/Backend/Test/Unit/App/Area/FrontNameResolverTest.php @@ -11,7 +11,7 @@ use Magento\Store\Model\ScopeInterface; use Magento\Store\Model\Store; -class FrontNameResolverTest extends \PHPUnit_Framework_TestCase +class FrontNameResolverTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\App\Area\FrontNameResolver @@ -36,19 +36,13 @@ class FrontNameResolverTest extends \PHPUnit_Framework_TestCase protected function setUp() { /** @var \PHPUnit_Framework_MockObject_MockObject|DeploymentConfig $deploymentConfigMock */ - $deploymentConfigMock = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); + $deploymentConfigMock = $this->createMock(\Magento\Framework\App\DeploymentConfig::class); $deploymentConfigMock->expects($this->once()) ->method('get') ->with(ConfigOptionsList::CONFIG_PATH_BACKEND_FRONTNAME) ->will($this->returnValue($this->_defaultFrontName)); - $this->configMock = $this->getMock(\Magento\Backend\App\Config::class, [], [], '', false); - $this->scopeConfigMock = $this->getMock( - \Magento\Framework\App\Config\ScopeConfigInterface::class, - [], - [], - '', - false - ); + $this->configMock = $this->createMock(\Magento\Backend\App\Config::class); + $this->scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $this->model = new FrontNameResolver($this->configMock, $deploymentConfigMock, $this->scopeConfigMock); } diff --git a/app/code/Magento/Backend/Test/Unit/App/Area/Request/PathInfoProcessorTest.php b/app/code/Magento/Backend/Test/Unit/App/Area/Request/PathInfoProcessorTest.php index 11ff40f2095c7..f693a9f5f8c23 100644 --- a/app/code/Magento/Backend/Test/Unit/App/Area/Request/PathInfoProcessorTest.php +++ b/app/code/Magento/Backend/Test/Unit/App/Area/Request/PathInfoProcessorTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Backend\Test\Unit\App\Area\Request; -class PathInfoProcessorTest extends \PHPUnit_Framework_TestCase +class PathInfoProcessorTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\App\Request\PathInfoProcessor @@ -34,15 +34,9 @@ class PathInfoProcessorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_requestMock = $this->getMock(\Magento\Framework\App\RequestInterface::class); - $this->_subjectMock = $this->getMock( - \Magento\Store\App\Request\PathInfoProcessor::class, - [], - [], - '', - false - ); - $this->_backendHelperMock = $this->getMock(\Magento\Backend\Helper\Data::class, [], [], '', false); + $this->_requestMock = $this->createMock(\Magento\Framework\App\RequestInterface::class); + $this->_subjectMock = $this->createMock(\Magento\Store\App\Request\PathInfoProcessor::class); + $this->_backendHelperMock = $this->createMock(\Magento\Backend\Helper\Data::class); $this->_model = new \Magento\Backend\App\Request\PathInfoProcessor( $this->_subjectMock, $this->_backendHelperMock diff --git a/app/code/Magento/Backend/Test/Unit/App/ConfigTest.php b/app/code/Magento/Backend/Test/Unit/App/ConfigTest.php index 4626a4cdb1dfa..114c57867badf 100644 --- a/app/code/Magento/Backend/Test/Unit/App/ConfigTest.php +++ b/app/code/Magento/Backend/Test/Unit/App/ConfigTest.php @@ -13,7 +13,7 @@ * @see \Magento\Backend\App\Config * @package Magento\Backend\Test\Unit\App */ -class ConfigTest extends \PHPUnit_Framework_TestCase +class ConfigTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\App\Config|\PHPUnit_Framework_MockObject_MockObject @@ -27,13 +27,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->appConfig = $this->getMock( - \Magento\Framework\App\Config::class, - ['get'], - [], - '', - false - ); + $this->appConfig = $this->createPartialMock(\Magento\Framework\App\Config::class, ['get']); $this->model = new \Magento\Backend\App\Config($this->appConfig); } @@ -96,6 +90,6 @@ public function isSetFlagDataProvider() */ protected function getConfigDataMock($mockedMethod) { - return $this->getMock(\Magento\Framework\App\Config\Data::class, [$mockedMethod], [], '', false); + return $this->createPartialMock(\Magento\Framework\App\Config\Data::class, [$mockedMethod]); } } diff --git a/app/code/Magento/Backend/Test/Unit/App/Response/Http/FileFactoryTest.php b/app/code/Magento/Backend/Test/Unit/App/Response/Http/FileFactoryTest.php index 20974a8658021..d90730c6cf859 100644 --- a/app/code/Magento/Backend/Test/Unit/App/Response/Http/FileFactoryTest.php +++ b/app/code/Magento/Backend/Test/Unit/App/Response/Http/FileFactoryTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Backend\Test\Unit\App\Response\Http; -class FileFactoryTest extends \PHPUnit_Framework_TestCase +class FileFactoryTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\App\Response\Http\FileFactory @@ -35,12 +35,9 @@ class FileFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_responseMock = $this->getMock( + $this->_responseMock = $this->createPartialMock( \Magento\Framework\App\Response\Http::class, - ['setRedirect', '__wakeup'], - [], - '', - false + ['setRedirect', '__wakeup'] ); $this->_responseMock->expects( $this->any() @@ -49,15 +46,9 @@ protected function setUp() )->will( $this->returnValue($this->_responseMock) ); - $this->_sessionMock = $this->getMock( - \Magento\Backend\Model\Session::class, - ['setIsUrlNotice'], - [], - '', - false - ); - $this->_backendUrl = $this->getMock(\Magento\Backend\Model\Url::class, [], [], '', false); - $this->_authMock = $this->getMock(\Magento\Backend\Model\Auth::class, [], [], '', false); + $this->_sessionMock = $this->createPartialMock(\Magento\Backend\Model\Session::class, ['setIsUrlNotice']); + $this->_backendUrl = $this->createMock(\Magento\Backend\Model\Url::class); + $this->_authMock = $this->createMock(\Magento\Backend\Model\Auth::class); $this->_model = $helper->getObject( \Magento\Backend\App\Response\Http\FileFactory::class, [ @@ -71,12 +62,9 @@ protected function setUp() public function testCreate() { - $authStorageMock = $this->getMock( + $authStorageMock = $this->createPartialMock( \Magento\Backend\Model\Auth\Session::class, - ['isFirstPageAfterLogin', 'processLogout', 'processLogin'], - [], - '', - false + ['isFirstPageAfterLogin', 'processLogout', 'processLogin'] ); $this->_authMock->expects($this->once())->method('getAuthStorage')->will($this->returnValue($authStorageMock)); $authStorageMock->expects($this->once())->method('isFirstPageAfterLogin')->will($this->returnValue(true)); diff --git a/app/code/Magento/Backend/Test/Unit/App/Router/NoRouteHandlerTest.php b/app/code/Magento/Backend/Test/Unit/App/Router/NoRouteHandlerTest.php index b989bd1e3fcc5..236c91b34e389 100644 --- a/app/code/Magento/Backend/Test/Unit/App/Router/NoRouteHandlerTest.php +++ b/app/code/Magento/Backend/Test/Unit/App/Router/NoRouteHandlerTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Backend\Test\Unit\App\Router; -class NoRouteHandlerTest extends \PHPUnit_Framework_TestCase +class NoRouteHandlerTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -29,9 +29,9 @@ class NoRouteHandlerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); - $this->_routeConfigMock = $this->getMock(\Magento\Framework\App\Route\ConfigInterface::class); - $this->_helperMock = $this->getMock(\Magento\Backend\Helper\Data::class, [], [], '', false); + $this->_requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class); + $this->_routeConfigMock = $this->createMock(\Magento\Framework\App\Route\ConfigInterface::class); + $this->_helperMock = $this->createMock(\Magento\Backend\Helper\Data::class); $this->_helperMock->expects($this->any())->method('getAreaFrontName')->will($this->returnValue('backend')); $this->_model = new \Magento\Backend\App\Router\NoRouteHandler($this->_helperMock, $this->_routeConfigMock); } diff --git a/app/code/Magento/Backend/Test/Unit/App/UserConfigTest.php b/app/code/Magento/Backend/Test/Unit/App/UserConfigTest.php index 535027be74835..5b6df5be8c49b 100644 --- a/app/code/Magento/Backend/Test/Unit/App/UserConfigTest.php +++ b/app/code/Magento/Backend/Test/Unit/App/UserConfigTest.php @@ -6,13 +6,13 @@ namespace Magento\Backend\Test\Unit\App; -class UserConfigTest extends \PHPUnit_Framework_TestCase +class UserConfigTest extends \PHPUnit\Framework\TestCase { public function testUserRequestCreation() { - $factoryMock = $this->getMock(\Magento\Config\Model\Config\Factory::class, ['create'], [], '', false); - $responseMock = $this->getMock(\Magento\Framework\App\Console\Response::class, [], [], '', false); - $configMock = $this->getMock(\Magento\Config\Model\Config::class, [], [], '', false); + $factoryMock = $this->createPartialMock(\Magento\Config\Model\Config\Factory::class, ['create']); + $responseMock = $this->createMock(\Magento\Framework\App\Console\Response::class); + $configMock = $this->createMock(\Magento\Config\Model\Config::class); $key = 'key'; $value = 'value'; diff --git a/app/code/Magento/Backend/Test/Unit/Block/AnchorRendererTest.php b/app/code/Magento/Backend/Test/Unit/Block/AnchorRendererTest.php index 1bb8b15b5dc0b..f52f4ab337712 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/AnchorRendererTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/AnchorRendererTest.php @@ -11,7 +11,7 @@ use Magento\Framework\Escaper; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -class AnchorRendererTest extends \PHPUnit_Framework_TestCase +class AnchorRendererTest extends \PHPUnit\Framework\TestCase { /** * @var Item|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Backend/Test/Unit/Block/Cache/AdditionalTest.php b/app/code/Magento/Backend/Test/Unit/Block/Cache/AdditionalTest.php index 8c015bfbab09b..160cfe609f85f 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Cache/AdditionalTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Cache/AdditionalTest.php @@ -6,7 +6,7 @@ namespace Magento\Backend\Test\Unit\Block\Cache; -class AdditionalTest extends \PHPUnit_Framework_TestCase +class AdditionalTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\Block\Cache\Additional @@ -25,7 +25,7 @@ class AdditionalTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->urlBuilderMock = $this->getMock(\Magento\Framework\UrlInterface::class); + $this->urlBuilderMock = $this->createMock(\Magento\Framework\UrlInterface::class); $this->appStateMock = $this->getMockBuilder(\Magento\Framework\App\State::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Backend/Test/Unit/Block/MenuItemCheckerTest.php b/app/code/Magento/Backend/Test/Unit/Block/MenuItemCheckerTest.php index 5dd7deb6e0972..a79050faeb84a 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/MenuItemCheckerTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/MenuItemCheckerTest.php @@ -9,7 +9,7 @@ use Magento\Backend\Model\Menu; use Magento\Backend\Block\MenuItemChecker; -class MenuItemCheckerTest extends \PHPUnit_Framework_TestCase +class MenuItemCheckerTest extends \PHPUnit\Framework\TestCase { /** * @var Item|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Backend/Test/Unit/Block/MenuTest.php b/app/code/Magento/Backend/Test/Unit/Block/MenuTest.php index 03714795d97c1..f41447c608b10 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/MenuTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/MenuTest.php @@ -17,7 +17,7 @@ use Magento\Backend\Block\AnchorRenderer; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -class MenuTest extends \PHPUnit_Framework_TestCase +class MenuTest extends \PHPUnit\Framework\TestCase { /** * @var Item|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Backend/Test/Unit/Block/Page/System/Config/Robots/ResetTest.php b/app/code/Magento/Backend/Test/Unit/Block/Page/System/Config/Robots/ResetTest.php index 2996584bfc1ef..1c54d02378887 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Page/System/Config/Robots/ResetTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Page/System/Config/Robots/ResetTest.php @@ -14,7 +14,7 @@ * @deprecated * @package Magento\Backend\Test\Unit\Block\Page\System\Config\Robots */ -class ResetTest extends \PHPUnit_Framework_TestCase +class ResetTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\Block\Page\System\Config\Robots\Reset @@ -28,7 +28,7 @@ class ResetTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->configMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->configMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $context = $objectHelper->getObject( diff --git a/app/code/Magento/Backend/Test/Unit/Block/Store/SwitcherTest.php b/app/code/Magento/Backend/Test/Unit/Block/Store/SwitcherTest.php index d224651dd4270..39bf3be3007d8 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Store/SwitcherTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Store/SwitcherTest.php @@ -6,7 +6,7 @@ namespace Magento\Backend\Test\Unit\Block\Store; -class SwitcherTest extends \PHPUnit_Framework_TestCase +class SwitcherTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\Block\Store\Switcher @@ -17,7 +17,7 @@ class SwitcherTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); $objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $context = $objectHelper->getObject( \Magento\Backend\Block\Template\Context::class, @@ -34,7 +34,7 @@ protected function setUp() public function testGetWebsites() { - $websiteMock = $this->getMock(\Magento\Store\Model\Website::class, [], [], '', false); + $websiteMock = $this->createMock(\Magento\Store\Model\Website::class); $websites = [0 => $websiteMock, 1 => $websiteMock]; $this->storeManagerMock->expects($this->once())->method('getWebsites')->will($this->returnValue($websites)); $this->assertEquals($websites, $this->switcherBlock->getWebsites()); @@ -42,7 +42,7 @@ public function testGetWebsites() public function testGetWebsitesIfSetWebsiteIds() { - $websiteMock = $this->getMock(\Magento\Store\Model\Website::class, [], [], '', false); + $websiteMock = $this->createMock(\Magento\Store\Model\Website::class); $websites = [0 => $websiteMock, 1 => $websiteMock]; $this->storeManagerMock->expects($this->once())->method('getWebsites')->will($this->returnValue($websites)); diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/Button/SplitTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/Button/SplitTest.php index 1fbc832b8b155..69fa646a051f3 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/Button/SplitTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/Button/SplitTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Backend\Test\Unit\Block\Widget\Button; -class SplitTest extends \PHPUnit_Framework_TestCase +class SplitTest extends \PHPUnit\Framework\TestCase { public function testHasSplit() { diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/ButtonTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/ButtonTest.php index 34117cb9c82c6..bcf5d1adbc12b 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/ButtonTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/ButtonTest.php @@ -9,7 +9,7 @@ */ namespace Magento\Backend\Test\Unit\Block\Widget; -class ButtonTest extends \PHPUnit_Framework_TestCase +class ButtonTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -33,10 +33,10 @@ class ButtonTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_layoutMock = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false, false); + $this->_layoutMock = $this->createMock(\Magento\Framework\View\Layout::class); $arguments = [ - 'urlBuilder' => $this->getMock(\Magento\Backend\Model\Url::class, [], [], '', false, false), + 'urlBuilder' => $this->createMock(\Magento\Backend\Model\Url::class), 'layout' => $this->_layoutMock, ]; diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/Form/ContainerTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/Form/ContainerTest.php index d2c4e2e2c8ce0..ff0fb83961d8e 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/Form/ContainerTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/Form/ContainerTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Backend\Test\Unit\Block\Widget\Form; -class ContainerTest extends \PHPUnit_Framework_TestCase +class ContainerTest extends \PHPUnit\Framework\TestCase { public function testSetDataObject() { @@ -13,13 +13,7 @@ public function testSetDataObject() $dataObject = new \Magento\Framework\DataObject(); // _prepateLayout() is blocked, because it is used by block to instantly add 'form' child - $block = $this->getMock( - \Magento\Backend\Block\Widget\Form\Container::class, - ['getChildBlock'], - [], - '', - false - ); + $block = $this->createPartialMock(\Magento\Backend\Block\Widget\Form\Container::class, ['getChildBlock']); $block->expects($this->once())->method('getChildBlock')->with('form')->will($this->returnValue($form)); $block->setDataObject($dataObject); diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/FormTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/FormTest.php index 200e82323187a..011c61d2998a3 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/FormTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/FormTest.php @@ -10,7 +10,7 @@ use Magento\Framework\Data\Form as DataForm; use Magento\Framework\UrlInterface; -class FormTest extends \PHPUnit_Framework_TestCase +class FormTest extends \PHPUnit\Framework\TestCase { /** @var Form */ protected $model; diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Filter/DateTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Filter/DateTest.php index 593a3ed29f676..355d11b561317 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Filter/DateTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Filter/DateTest.php @@ -10,7 +10,7 @@ * Class DateTest to test Magento\Backend\Block\Widget\Grid\Column\Filter\Date * */ -class DateTest extends \PHPUnit_Framework_TestCase +class DateTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Backend\Block\Widget\Grid\Column\Filter\Date */ protected $model; diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Filter/DatetimeTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Filter/DatetimeTest.php index e648a1fa0673f..1e692f890a94e 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Filter/DatetimeTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Filter/DatetimeTest.php @@ -10,7 +10,7 @@ * Class DateTimeTest to test Magento\Backend\Block\Widget\Grid\Column\Filter\Date * */ -class DatetimeTest extends \PHPUnit_Framework_TestCase +class DatetimeTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Backend\Block\Widget\Grid\Column\Filter\Datetime */ protected $model; diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Filter/StoreTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Filter/StoreTest.php index 991abb3d6b399..a44f093776b02 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Filter/StoreTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Filter/StoreTest.php @@ -8,7 +8,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -class StoreTest extends \PHPUnit_Framework_TestCase +class StoreTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Backend\Block\Widget\Grid\Column\Filter\Store */ protected $object; @@ -27,9 +27,9 @@ class StoreTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->context = $this->getMock(\Magento\Backend\Block\Context::class, [], [], '', false); - $this->helper = $this->getMock(\Magento\Framework\DB\Helper::class, [], [], '', false); - $this->store = $this->getMock(\Magento\Store\Model\System\Store::class, [], [], '', false); + $this->context = $this->createMock(\Magento\Backend\Block\Context::class); + $this->helper = $this->createMock(\Magento\Framework\DB\Helper::class); + $this->store = $this->createMock(\Magento\Store\Model\System\Store::class); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->store = $this->objectManagerHelper->getObject( diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Filter/TextTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Filter/TextTest.php index f9c33b2bac5f3..1bf23649e2ea8 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Filter/TextTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Filter/TextTest.php @@ -8,7 +8,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -class TextTest extends \PHPUnit_Framework_TestCase +class TextTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Backend\Block\Widget\Grid\Column\Filter\Text*/ protected $block; @@ -31,8 +31,8 @@ protected function setUp() ->setMethods(['getEscaper']) ->disableOriginalConstructor() ->getMock(); - $this->escaper = $this->getMock(\Magento\Framework\Escaper::class, ['escapeHtml'], [], '', false); - $this->helper = $this->getMock(\Magento\Framework\DB\Helper::class, [], [], '', false); + $this->escaper = $this->createPartialMock(\Magento\Framework\Escaper::class, ['escapeHtml']); + $this->helper = $this->createMock(\Magento\Framework\DB\Helper::class); $this->context->expects($this->once())->method('getEscaper')->willReturn($this->escaper); diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/MultistoreTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/MultistoreTest.php index 6628482579b66..c6d05e91b71ab 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/MultistoreTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/MultistoreTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Backend\Test\Unit\Block\Widget\Grid\Column; -class MultistoreTest extends \PHPUnit_Framework_TestCase +class MultistoreTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\Block\Widget\Grid\Column\Multistore @@ -19,11 +19,11 @@ class MultistoreTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); + $this->_storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManager::class); $arguments = [ 'storeManager' => $this->_storeManagerMock, - 'urlBuilder' => $this->getMock(\Magento\Backend\Model\Url::class, [], [], '', false), + 'urlBuilder' => $this->createMock(\Magento\Backend\Model\Url::class), ]; $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Renderer/AbstractRendererTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Renderer/AbstractRendererTest.php index 09e173fb6c2a1..bcecc8259a1fa 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Renderer/AbstractRendererTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Renderer/AbstractRendererTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Backend\Test\Unit\Block\Widget\Grid\Column\Renderer; -class AbstractRendererTest extends \PHPUnit_Framework_TestCase +class AbstractRendererTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\Block\Widget\Grid\Column|\PHPUnit_Framework_MockObject_MockObject @@ -27,7 +27,7 @@ class AbstractRendererTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->dataObjectMock = $this->getMock(\Magento\Framework\DataObject::class, ['getData'], [], '', false); + $this->dataObjectMock = $this->createPartialMock(\Magento\Framework\DataObject::class, ['getData']); $this->columnMock = $this->getMockBuilder(\Magento\Backend\Block\Widget\Grid\Column::class) ->disableOriginalConstructor() ->setMethods(['getEditable', 'getIndex', 'getEditOnly', 'getId']) diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Renderer/ConcatTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Renderer/ConcatTest.php index 05d187a3867dc..f0877f8528de6 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Renderer/ConcatTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Renderer/ConcatTest.php @@ -7,7 +7,7 @@ use Magento\Framework\DataObject; -class ConcatTest extends \PHPUnit_Framework_TestCase +class ConcatTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager */ protected $objectManagerHelper; @@ -40,19 +40,18 @@ public function typeProvider() public function testRender($method, $getters) { $object = new DataObject(['test' => 'a', 'best' => 'b']); - $column = $this->getMockBuilder(\Magento\Backend\Block\Widget\Grid\Column::class) - ->disableOriginalConstructor() - ->setMethods([$method, 'getSeparator']) - ->getMock(); + $column = $this->createPartialMock(\Magento\Backend\Block\Widget\Grid\Column::class, [$method, 'getSeparator']); $column->expects($this->any()) ->method('getSeparator') ->will($this->returnValue('-')); $column->expects($this->any()) ->method($method) ->will($this->returnValue($getters)); - $column->expects($this->any()) - ->method('getGetter') - ->willReturn(['getTest', 'getBest']); + if ($method == 'getGetter') { + $column->expects($this->any()) + ->method('getGetter') + ->willReturn(['getTest', 'getBest']); + } $this->renderer->setColumn($column); $this->assertEquals('a-b', $this->renderer->render($object)); } diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Renderer/CurrencyTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Renderer/CurrencyTest.php index bc751a4aae726..02e81a236b6f7 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Renderer/CurrencyTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Renderer/CurrencyTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Backend\Test\Unit\Block\Widget\Grid\Column\Renderer; -class CurrencyTest extends \PHPUnit_Framework_TestCase +class CurrencyTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\Block\Widget\Grid\Column\Renderer\Currency @@ -49,35 +49,17 @@ class CurrencyTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); - $this->_localeMock = $this->getMock(\Magento\Framework\Locale\CurrencyInterface::class); - $this->_requestMock = $this->getMock(\Magento\Framework\App\RequestInterface::class); - - $this->_curLocatorMock = $this->getMock( - \Magento\Directory\Model\Currency\DefaultLocator::class, - [], - [], - '', - false - ); - $this->_columnMock = $this->getMock( - \Magento\Backend\Block\Widget\Grid\Column::class, - ['getIndex'], - [], - '', - false - ); + $this->_storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->_localeMock = $this->createMock(\Magento\Framework\Locale\CurrencyInterface::class); + $this->_requestMock = $this->createMock(\Magento\Framework\App\RequestInterface::class); + + $this->_curLocatorMock = $this->createMock(\Magento\Directory\Model\Currency\DefaultLocator::class); + $this->_columnMock = $this->createPartialMock(\Magento\Backend\Block\Widget\Grid\Column::class, ['getIndex']); $this->_columnMock->expects($this->any())->method('getIndex')->will($this->returnValue('columnIndex')); - $this->_currencyMock = $this->getMock(\Magento\Directory\Model\Currency::class, [], [], '', false); + $this->_currencyMock = $this->createMock(\Magento\Directory\Model\Currency::class); $this->_currencyMock->expects($this->any())->method('load')->will($this->returnSelf()); - $currencyFactoryMock = $this->getMock( - \Magento\Directory\Model\CurrencyFactory::class, - ['create'], - [], - '', - false - ); + $currencyFactoryMock = $this->createPartialMock(\Magento\Directory\Model\CurrencyFactory::class, ['create']); $currencyFactoryMock->expects($this->any())->method('create')->will($this->returnValue($this->_currencyMock)); $this->_row = new \Magento\Framework\DataObject(['columnIndex' => '10']); @@ -133,7 +115,7 @@ public function testRenderWithDefaultCurrency() $this->returnValue('defaultCurrency') ); - $currLocaleMock = $this->getMock(\Zend_Currency::class, [], [], '', false); + $currLocaleMock = $this->createMock(\Zend_Currency::class); $currLocaleMock->expects( $this->once() )->method( diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Renderer/Radio/ExtendedTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Renderer/Radio/ExtendedTest.php index fd2cc57d06ec9..35e21d7d194aa 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Renderer/Radio/ExtendedTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Renderer/Radio/ExtendedTest.php @@ -7,7 +7,7 @@ use Magento\Backend\Block\Widget\Grid\Column\Renderer\Radio\Extended; -class ExtendedTest extends \PHPUnit_Framework_TestCase +class ExtendedTest extends \PHPUnit\Framework\TestCase { /** * @var Extended @@ -26,20 +26,14 @@ class ExtendedTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $context = $this->getMock(\Magento\Backend\Block\Context::class, [], [], '', false); - $this->_converter = $this->getMock( + $context = $this->createMock(\Magento\Backend\Block\Context::class); + $this->_converter = $this->createPartialMock( \Magento\Backend\Block\Widget\Grid\Column\Renderer\Options\Converter::class, - ['toFlatArray'], - [], - '', - false + ['toFlatArray'] ); - $this->_column = $this->getMock( + $this->_column = $this->createPartialMock( \Magento\Backend\Block\Widget\Grid\Column::class, - ['getValues', 'getIndex', 'getHtmlName'], - [], - '', - false + ['getValues', 'getIndex', 'getHtmlName'] ); $this->_object = new Extended($context, $this->_converter); $this->_object->setColumn($this->_column); diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Renderer/RadioTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Renderer/RadioTest.php index 51978bc15a751..67ead0ddd8f35 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Renderer/RadioTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Renderer/RadioTest.php @@ -7,7 +7,7 @@ use Magento\Backend\Block\Widget\Grid\Column\Renderer\Radio; -class RadioTest extends \PHPUnit_Framework_TestCase +class RadioTest extends \PHPUnit\Framework\TestCase { /** * @var Radio @@ -26,20 +26,14 @@ class RadioTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $context = $this->getMock(\Magento\Backend\Block\Context::class, [], [], '', false); - $this->_converter = $this->getMock( + $context = $this->createMock(\Magento\Backend\Block\Context::class); + $this->_converter = $this->createPartialMock( \Magento\Backend\Block\Widget\Grid\Column\Renderer\Options\Converter::class, - ['toFlatArray'], - [], - '', - false + ['toFlatArray'] ); - $this->_column = $this->getMock( + $this->_column = $this->createPartialMock( \Magento\Backend\Block\Widget\Grid\Column::class, - ['getValues', 'getIndex', 'getHtmlName'], - [], - '', - false + ['getValues', 'getIndex', 'getHtmlName'] ); $this->_object = new \Magento\Backend\Block\Widget\Grid\Column\Renderer\Radio($context, $this->_converter); $this->_object->setColumn($this->_column); diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/ColumnSetTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/ColumnSetTest.php index a39d56df417ea..be171a8ed40bf 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/ColumnSetTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/ColumnSetTest.php @@ -9,7 +9,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ColumnSetTest extends \PHPUnit_Framework_TestCase +class ColumnSetTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\Block\Widget\Grid\ColumnSet @@ -48,14 +48,11 @@ class ColumnSetTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_columnMock = $this->getMock( + $this->_columnMock = $this->createPartialMock( \Magento\Backend\Block\Widget\Grid\Column::class, - ['setSortable', 'setRendererType', 'setFilterType'], - [], - '', - false + ['setSortable', 'setRendererType', 'setFilterType'] ); - $this->_layoutMock = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); + $this->_layoutMock = $this->createMock(\Magento\Framework\View\Layout::class); $this->_layoutMock->expects( $this->any() )->method( @@ -63,23 +60,11 @@ protected function setUp() )->will( $this->returnValue(['column' => $this->_columnMock]) ); - $this->_factoryMock = $this->getMock( - \Magento\Backend\Model\Widget\Grid\Row\UrlGeneratorFactory::class, - [], - [], - '', - false - ); + $this->_factoryMock = $this->createMock(\Magento\Backend\Model\Widget\Grid\Row\UrlGeneratorFactory::class); - $this->_subtotalsMock = $this->getMock( - \Magento\Backend\Model\Widget\Grid\SubTotals::class, - [], - [], - '', - false - ); + $this->_subtotalsMock = $this->createMock(\Magento\Backend\Model\Widget\Grid\SubTotals::class); - $this->_totalsMock = $this->getMock(\Magento\Backend\Model\Widget\Grid\Totals::class, [], [], '', false); + $this->_totalsMock = $this->createMock(\Magento\Backend\Model\Widget\Grid\Totals::class); $arguments = [ 'layout' => $this->_layoutMock, @@ -139,15 +124,10 @@ public function testGetRowUrl() { $generatorClass = \Magento\Backend\Model\Widget\Grid\Row\UrlGenerator::class; - $itemMock = $this->getMock(\Magento\Framework\DataObject::class, [], [], '', false); + $itemMock = $this->createMock(\Magento\Framework\DataObject::class); - $rowUrlGenerator = $this->getMock( - \Magento\Backend\Model\Widget\Grid\Row\UrlGenerator::class, - ['getUrl'], - [], - '', - false - ); + $rowUrlGenerator = + $this->createPartialMock(\Magento\Backend\Model\Widget\Grid\Row\UrlGenerator::class, ['getUrl']); $rowUrlGenerator->expects( $this->once() )->method( @@ -158,12 +138,9 @@ public function testGetRowUrl() $this->returnValue('http://localhost/mng/item/edit') ); - $factoryMock = $this->getMock( + $factoryMock = $this->createPartialMock( \Magento\Backend\Model\Widget\Grid\Row\UrlGeneratorFactory::class, - ['createUrlGenerator'], - [], - '', - false + ['createUrlGenerator'] ); $factoryMock->expects( $this->once() @@ -197,7 +174,7 @@ public function testItemHasMultipleRows() $item = new \Magento\Framework\DataObject(); // prepare sub-collection $subCollection = new \Magento\Framework\Data\Collection( - $this->getMock(\Magento\Framework\Data\Collection\EntityFactory::class, [], [], '', false) + $this->createMock(\Magento\Framework\Data\Collection\EntityFactory::class) ); $subCollection->addItem(new \Magento\Framework\DataObject(['test4' => '1', 'test5' => '2'])); $subCollection->addItem(new \Magento\Framework\DataObject(['test4' => '2', 'test5' => '2'])); @@ -219,7 +196,7 @@ public function testShouldRenderTotalWithEmptyCollection() $this->_prepareLayoutWithGrid( $this->_prepareGridMock( new \Magento\Framework\Data\Collection( - $this->getMock(\Magento\Framework\Data\Collection\EntityFactory::class, [], [], '', false) + $this->createMock(\Magento\Framework\Data\Collection\EntityFactory::class) ) ) ); @@ -251,7 +228,7 @@ public function testShouldRenderSubtotalWithNotEmptySubData() $item = new \Magento\Framework\DataObject(); // prepare sub-collection $subCollection = new \Magento\Framework\Data\Collection( - $this->getMock(\Magento\Framework\Data\Collection\EntityFactory::class, [], [], '', false) + $this->createMock(\Magento\Framework\Data\Collection\EntityFactory::class) ); $subCollection->addItem(new \Magento\Framework\DataObject(['test4' => '1', 'test5' => '2'])); $subCollection->addItem(new \Magento\Framework\DataObject(['test4' => '2', 'test5' => '2'])); @@ -266,7 +243,7 @@ public function testUpdateItemByFirstMultiRow() $item = new \Magento\Framework\DataObject(['test1' => '1']); // prepare sub-collection $subCollection = new \Magento\Framework\Data\Collection( - $this->getMock(\Magento\Framework\Data\Collection\EntityFactory::class, [], [], '', false) + $this->createMock(\Magento\Framework\Data\Collection\EntityFactory::class) ); $subCollection->addItem(new \Magento\Framework\DataObject(['test4' => '1', 'test5' => '2'])); $subCollection->addItem(new \Magento\Framework\DataObject(['test4' => '2', 'test5' => '2'])); @@ -284,7 +261,7 @@ public function testGetSubTotals() { // prepare sub-collection $subCollection = new \Magento\Framework\Data\Collection( - $this->getMock(\Magento\Framework\Data\Collection\EntityFactory::class, [], [], '', false) + $this->createMock(\Magento\Framework\Data\Collection\EntityFactory::class) ); $subCollection->addItem(new \Magento\Framework\DataObject(['column' => '1'])); $subCollection->addItem(new \Magento\Framework\DataObject(['column' => '1'])); @@ -336,7 +313,7 @@ public function testGetTotals() protected function _prepareGridMock($collection) { // prepare block grid - $gridMock = $this->getMock(\Magento\Backend\Block\Widget\Grid::class, ['getCollection'], [], '', false); + $gridMock = $this->createPartialMock(\Magento\Backend\Block\Widget\Grid::class, ['getCollection']); $gridMock->expects($this->any())->method('getCollection')->will($this->returnValue($collection)); return $gridMock; @@ -350,7 +327,7 @@ protected function _prepareGridMock($collection) protected function _getTestCollection() { $collection = new \Magento\Framework\Data\Collection( - $this->getMock(\Magento\Framework\Data\Collection\EntityFactory::class, [], [], '', false) + $this->createMock(\Magento\Framework\Data\Collection\EntityFactory::class) ); $items = [ new \Magento\Framework\DataObject(['test1' => '1', 'test2' => '2']), diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/ColumnTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/ColumnTest.php index e5d8273ca02f3..da13af87b71ea 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/ColumnTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/ColumnTest.php @@ -3,13 +3,12 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ - -/** - * Test class for \Magento\Backend\Block\Widget\Grid\Column - */ namespace Magento\Backend\Test\Unit\Block\Widget\Grid; -class ColumnTest extends \PHPUnit_Framework_TestCase +use Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer; +use Magento\Framework\DataObject; + +class ColumnTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\Block\Widget\Grid\Column @@ -28,19 +27,15 @@ class ColumnTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_layoutMock = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false, false); - $this->_blockMock = $this->getMock( + $this->_layoutMock = $this->createMock(\Magento\Framework\View\Layout::class); + $this->_blockMock = $this->createPartialMock( \Magento\Framework\View\Element\Template::class, - ['setColumn', 'getHtml'], - [], - '', - false, - false + ['setColumn', 'getHtml'] ); $arguments = [ 'layout' => $this->_layoutMock, - 'urlBuilder' => $this->getMock(\Magento\Backend\Model\Url::class, [], [], '', false), + 'urlBuilder' => $this->createMock(\Magento\Backend\Model\Url::class), ]; $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_block = $objectManagerHelper->getObject(\Magento\Backend\Block\Widget\Grid\Column::class, $arguments); @@ -370,7 +365,7 @@ public function testColumnIsGrouped($groupedData, $expected) { $arguments = [ 'layout' => $this->_layoutMock, - 'urlBuilder' => $this->getMock(\Magento\Backend\Model\Url::class, [], [], '', false), + 'urlBuilder' => $this->createMock(\Magento\Backend\Model\Url::class), 'data' => $groupedData, ]; @@ -383,4 +378,97 @@ public function columnGroupedDataProvider() { return [[[], false], [['grouped' => 0], false], [['grouped' => 1], true]]; } + + /** + * Testing row field export with valid frame callback + */ + public function testGetRowFieldAndExportWithFrameCallback() + { + $row = new DataObject(['id' => '2', 'title' => 'some item']); + /** @var $rendererMock */ + $rendererMock = $this->getMockBuilder(AbstractRenderer::class) + ->disableOriginalConstructor() + ->setMethods(['renderExport', 'render']) + ->getMock(); + + $rendererMock->expects($this->any())->method('renderExport')->willReturnCallback( + function (DataObject $row) { + return $row->getData('title'); + } + ); + + $rendererMock->expects($this->any())->method('render')->willReturnCallback( + function (DataObject $row) { + return $row->getData('title'); + } + ); + + $frameCallbackHostObject = $this->getMockBuilder(\Magento\Backend\Block\Widget::class) + ->disableOriginalConstructor() + ->setMethods(['decorate']) + ->getMock(); + + $frameCallbackHostObject->expects($this->any()) + ->method('decorate') + ->willReturnCallback( + function ($renderValue) { + return '__callback_decorated_' . $renderValue; + } + ); + + $this->_block->setRenderer($rendererMock); + $this->_block->setFrameCallback([$frameCallbackHostObject, 'decorate']); + $renderResult = $this->_block->getRowField($row); + $exportResult = $this->_block->getRowFieldExport($row); + $this->assertEquals('__callback_decorated_some item', $exportResult); + $this->assertEquals('__callback_decorated_some item', $renderResult); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Frame callback host must be instance of Magento\Backend\Block\Widget + */ + public function testGetRowFieldExportWithInvalidCallback() + { + $row = new DataObject(['id' => '2', 'title' => 'some item']); + /** @var $rendererMock */ + $rendererMock = $this->getMockBuilder(AbstractRenderer::class) + ->disableOriginalConstructor() + ->setMethods(['renderExport', 'render']) + ->getMock(); + + $rendererMock->expects($this->any())->method('renderExport')->willReturnCallback( + function (DataObject $row) { + return $row->getData('title'); + } + ); + + $this->_block->setRenderer($rendererMock); + $this->_block->setFrameCallback([$this, 'testGetRowFieldExportWithFrameCallback']); + $this->_block->getRowFieldExport($row); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Frame callback host must be instance of Magento\Backend\Block\Widget + */ + public function testGetRowFieldWithInvalidCallback() + { + $row = new DataObject(['id' => '2', 'title' => 'some item']); + /** @var $rendererMock */ + $rendererMock = $this->getMockBuilder(AbstractRenderer::class) + ->disableOriginalConstructor() + ->setMethods(['render']) + ->getMock(); + + $rendererMock->expects($this->any())->method('render')->willReturnCallback( + function (DataObject $row) { + return $row->getData('title'); + } + ); + + $this->_block->setRenderer($rendererMock); + $this->_block->setFrameCallback([$this, 'testGetRowFieldExportWithFrameCallback']); + $this->_block->getRowField($row); + } } diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/ExtendedTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/ExtendedTest.php index f0b23add52569..561244f77b3e9 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/ExtendedTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/ExtendedTest.php @@ -9,7 +9,7 @@ */ namespace Magento\Backend\Test\Unit\Block\Widget\Grid; -class ExtendedTest extends \PHPUnit_Framework_TestCase +class ExtendedTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager @@ -23,15 +23,15 @@ protected function setUp() public function testPrepareLoadedCollection() { - $request = $this->getMock(\Magento\Framework\App\Request\Http::class, ['has'], [], '', false); + $request = $this->createPartialMock(\Magento\Framework\App\Request\Http::class, ['has']); $request->expects($this->any())->method('has')->will($this->returnValue(null)); - $columnSet = $this->getMock(\Magento\Backend\Block\Widget\Grid\ColumnSet::class, [], [], '', false); - $layout = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); + $columnSet = $this->createMock(\Magento\Backend\Block\Widget\Grid\ColumnSet::class); + $layout = $this->createMock(\Magento\Framework\View\Layout::class); $layout->expects($this->any())->method('getChildName')->will($this->returnValue('grid.columnSet')); $layout->expects($this->any())->method('getBlock')->will($this->returnValue($columnSet)); - $collection = $this->getMock(\Magento\Framework\Data\Collection::class, [], [], '', false); + $collection = $this->createMock(\Magento\Framework\Data\Collection::class); $collection->expects($this->atLeastOnce())->method('isLoaded')->will($this->returnValue(true)); $collection->expects($this->atLeastOnce())->method('clear'); $collection->expects($this->atLeastOnce())->method('load'); diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Massaction/ExtendedTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Massaction/ExtendedTest.php index f42ec575fdcc3..4525de1fee542 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Massaction/ExtendedTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Massaction/ExtendedTest.php @@ -9,7 +9,7 @@ */ namespace Magento\Backend\Test\Unit\Block\Widget\Grid\Massaction; -class ExtendedTest extends \PHPUnit_Framework_TestCase +class ExtendedTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\Block\Widget\Grid\Massaction @@ -43,22 +43,15 @@ class ExtendedTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_gridMock = $this->getMock( + $this->_gridMock = $this->createPartialMock( \Magento\Backend\Block\Widget\Grid::class, - ['getId', 'getCollection'], - [], - '', - false + ['getId', 'getCollection'] ); $this->_gridMock->expects($this->any())->method('getId')->will($this->returnValue('test_grid')); - $this->_layoutMock = $this->getMock( + $this->_layoutMock = $this->createPartialMock( \Magento\Framework\View\Layout::class, - ['getParentName', 'getBlock', 'helper'], - [], - '', - false, - false + ['getParentName', 'getBlock', 'helper'] ); $this->_layoutMock->expects( @@ -80,9 +73,9 @@ protected function setUp() $this->returnValue($this->_gridMock) ); - $this->_requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); + $this->_requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class); - $this->_urlModelMock = $this->getMock(\Magento\Backend\Model\Url::class, [], [], '', false); + $this->_urlModelMock = $this->createMock(\Magento\Backend\Model\Url::class); $arguments = [ 'layout' => $this->_layoutMock, diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/MassactionTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/MassactionTest.php index 86ab5ebd7761b..bb389a996e1ed 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/MassactionTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/MassactionTest.php @@ -11,7 +11,7 @@ use Magento\Backend\Block\Widget\Grid\Massaction\VisibilityCheckerInterface as VisibilityChecker; -class MassactionTest extends \PHPUnit_Framework_TestCase +class MassactionTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\Block\Widget\Grid\Massaction diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/SerializerTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/SerializerTest.php index bc930522b5a1b..95a56e5b6761a 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/SerializerTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/SerializerTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Backend\Test\Unit\Block\Widget\Grid; -class SerializerTest extends \PHPUnit_Framework_TestCase +class SerializerTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\View\LayoutInterface @@ -23,12 +23,9 @@ public function testPrepareLayout() { $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $grid = $this->getMock( + $grid = $this->createPartialMock( \Magento\Catalog\Block\Adminhtml\Product\Widget\Chooser::class, - ['getSelectedProducts'], - [], - '', - false + ['getSelectedProducts'] ); $grid->expects($this->once())->method('getSelectedProducts')->will($this->returnValue(['product1'])); $arguments = [ diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/TabTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/TabTest.php index 6ae9fe8204182..1670233324f8e 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/TabTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/TabTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Backend\Test\Unit\Block\Widget; -class TabTest extends \PHPUnit_Framework_TestCase +class TabTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager diff --git a/app/code/Magento/Backend/Test/Unit/Console/Command/AbstractCacheCommandTest.php b/app/code/Magento/Backend/Test/Unit/Console/Command/AbstractCacheCommandTest.php index 489db33d607b6..a0f755634f3d0 100644 --- a/app/code/Magento/Backend/Test/Unit/Console/Command/AbstractCacheCommandTest.php +++ b/app/code/Magento/Backend/Test/Unit/Console/Command/AbstractCacheCommandTest.php @@ -8,7 +8,7 @@ use Magento\Backend\Console\Command\AbstractCacheManageCommand; -abstract class AbstractCacheCommandTest extends \PHPUnit_Framework_TestCase +abstract class AbstractCacheCommandTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\App\Cache\Manager|\PHPUnit_Framework_MockObject_MockObject @@ -22,7 +22,7 @@ abstract class AbstractCacheCommandTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->cacheManagerMock = $this->getMock(\Magento\Framework\App\Cache\Manager::class, [], [], '', false); + $this->cacheManagerMock = $this->createMock(\Magento\Framework\App\Cache\Manager::class); } /** diff --git a/app/code/Magento/Backend/Test/Unit/Console/Command/AbstractCacheManageCommandTest.php b/app/code/Magento/Backend/Test/Unit/Console/Command/AbstractCacheManageCommandTest.php index 604c9cc277b47..6af8f58b2403e 100644 --- a/app/code/Magento/Backend/Test/Unit/Console/Command/AbstractCacheManageCommandTest.php +++ b/app/code/Magento/Backend/Test/Unit/Console/Command/AbstractCacheManageCommandTest.php @@ -27,7 +27,7 @@ protected function setUp() /** * @return array */ - public function testExecuteDataProvider() + public function executeDataProvider() { return [ 'implicit all' => [ diff --git a/app/code/Magento/Backend/Test/Unit/Console/Command/AbstractCacheSetCommandTest.php b/app/code/Magento/Backend/Test/Unit/Console/Command/AbstractCacheSetCommandTest.php index 0ea80c61453bc..9f3df447b198c 100644 --- a/app/code/Magento/Backend/Test/Unit/Console/Command/AbstractCacheSetCommandTest.php +++ b/app/code/Magento/Backend/Test/Unit/Console/Command/AbstractCacheSetCommandTest.php @@ -11,7 +11,7 @@ abstract class AbstractCacheSetCommandTest extends AbstractCacheManageCommandTes /** * @return array */ - public function testExecuteDataProvider() + public function executeDataProvider() { return [ 'implicit all' => [ diff --git a/app/code/Magento/Backend/Test/Unit/Console/Command/CacheCleanCommandTest.php b/app/code/Magento/Backend/Test/Unit/Console/Command/CacheCleanCommandTest.php index 682657d62371e..e97abc884bf2e 100644 --- a/app/code/Magento/Backend/Test/Unit/Console/Command/CacheCleanCommandTest.php +++ b/app/code/Magento/Backend/Test/Unit/Console/Command/CacheCleanCommandTest.php @@ -22,7 +22,7 @@ protected function setUp() * @param array $param * @param array $types * @param string $output - * @dataProvider testExecuteDataProvider + * @dataProvider executeDataProvider */ public function testExecute($param, $types, $output) { diff --git a/app/code/Magento/Backend/Test/Unit/Console/Command/CacheDisableCommandTest.php b/app/code/Magento/Backend/Test/Unit/Console/Command/CacheDisableCommandTest.php index bad66ccb343e7..b6099148c8a7b 100644 --- a/app/code/Magento/Backend/Test/Unit/Console/Command/CacheDisableCommandTest.php +++ b/app/code/Magento/Backend/Test/Unit/Console/Command/CacheDisableCommandTest.php @@ -22,7 +22,7 @@ protected function setUp() * @param array $enable * @param array $result * @param string $output - * @dataProvider testExecuteDataProvider + * @dataProvider executeDataProvider */ public function testExecute($param, $enable, $result, $output) { diff --git a/app/code/Magento/Backend/Test/Unit/Console/Command/CacheEnableCommandTest.php b/app/code/Magento/Backend/Test/Unit/Console/Command/CacheEnableCommandTest.php index aa38cb7d95d60..86c4ac2449400 100644 --- a/app/code/Magento/Backend/Test/Unit/Console/Command/CacheEnableCommandTest.php +++ b/app/code/Magento/Backend/Test/Unit/Console/Command/CacheEnableCommandTest.php @@ -22,7 +22,7 @@ protected function setUp() * @param array $enable * @param array $result * @param string $output - * @dataProvider testExecuteDataProvider + * @dataProvider executeDataProvider */ public function testExecute($param, $enable, $result, $output) { diff --git a/app/code/Magento/Backend/Test/Unit/Console/Command/CacheFlushCommandTest.php b/app/code/Magento/Backend/Test/Unit/Console/Command/CacheFlushCommandTest.php index e494fb7ce2cb8..fd97f3ad43f8e 100644 --- a/app/code/Magento/Backend/Test/Unit/Console/Command/CacheFlushCommandTest.php +++ b/app/code/Magento/Backend/Test/Unit/Console/Command/CacheFlushCommandTest.php @@ -22,7 +22,7 @@ protected function setUp() * @param array $param * @param array $types * @param string $output - * @dataProvider testExecuteDataProvider + * @dataProvider executeDataProvider */ public function testExecute($param, $types, $output) { diff --git a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/CleanMediaTest.php b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/CleanMediaTest.php index 5ec23d9792f19..b1911da024227 100644 --- a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/CleanMediaTest.php +++ b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/CleanMediaTest.php @@ -9,23 +9,22 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class CleanMediaTest extends \PHPUnit_Framework_TestCase +class CleanMediaTest extends \PHPUnit\Framework\TestCase { public function testExecute() { // Wire object with mocks - $response = $this->getMock(\Magento\Framework\App\Response\Http::class, [], [], '', false); - $request = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); + $response = $this->createMock(\Magento\Framework\App\Response\Http::class); + $request = $this->createMock(\Magento\Framework\App\Request\Http::class); - $objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); - $backendHelper = $this->getMock(\Magento\Backend\Helper\Data::class, [], [], '', false); + $objectManager = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); + $backendHelper = $this->createMock(\Magento\Backend\Helper\Data::class); $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $session = $this->getMock( - \Magento\Backend\Model\Session::class, - ['setIsUrlNotice'], - $helper->getConstructArguments(\Magento\Backend\Model\Session::class) - ); + $session = $this->getMockBuilder(\Magento\Backend\Model\Session::class) + ->setMethods(['setIsUrlNotice']) + ->setConstructorArgs($helper->getConstructArguments(\Magento\Backend\Model\Session::class)) + ->getMock(); $exceptionMessageFactory = $this->getMockBuilder( \Magento\Framework\Message\ExceptionMessageLookupFactory::class @@ -37,30 +36,27 @@ public function testExecute() ->getMock(); $messageManagerParams = $helper->getConstructArguments(\Magento\Framework\Message\Manager::class); - $messageManagerParams['exceptionMessageFactory'] = $exceptionMessageFactory; + $messageManager = $this->getMockBuilder(\Magento\Framework\Message\Manager::class) + ->setMethods(['addSuccess']) + ->setConstructorArgs($messageManagerParams) + ->getMock(); - $messageManager = $this->getMock( - \Magento\Framework\Message\Manager::class, - ['addSuccess'], - $messageManagerParams - ); - - $context = $this->getMock( + $args = $helper->getConstructArguments( \Magento\Backend\App\Action\Context::class, - ['getRequest', 'getResponse', 'getMessageManager', 'getSession', 'getResultFactory'], - $helper->getConstructArguments( - \Magento\Backend\App\Action\Context::class, - [ - 'session' => $session, - 'response' => $response, - 'objectManager' => $objectManager, - 'helper' => $backendHelper, - 'request' => $request, - 'messageManager' => $messageManager - ] - ) + [ + 'session' => $session, + 'response' => $response, + 'objectManager' => $objectManager, + 'helper' => $backendHelper, + 'request' => $request, + 'messageManager' => $messageManager + ] ); + $context = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class) + ->setMethods(['getRequest', 'getResponse', 'getMessageManager', 'getSession', 'getResultFactory']) + ->setConstructorArgs($args) + ->getMock(); $resultFactory = $this->getMockBuilder(\Magento\Framework\Controller\ResultFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) @@ -86,7 +82,7 @@ public function testExecute() ); // Setup expectations - $mergeService = $this->getMock(\Magento\Framework\View\Asset\MergeService::class, [], [], '', false); + $mergeService = $this->createMock(\Magento\Framework\View\Asset\MergeService::class); $mergeService->expects($this->once())->method('cleanMergedJsCss'); $messageManager->expects($this->once()) diff --git a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/CleanStaticFilesTest.php b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/CleanStaticFilesTest.php index 8cdebc55fe210..40d9ca1aa8996 100644 --- a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/CleanStaticFilesTest.php +++ b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/CleanStaticFilesTest.php @@ -6,7 +6,7 @@ namespace Magento\Backend\Test\Unit\Controller\Adminhtml\Cache; -class CleanStaticFilesTest extends \PHPUnit_Framework_TestCase +class CleanStaticFilesTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\ObjectManagerInterface | \PHPUnit_Framework_MockObject_MockObject @@ -35,7 +35,7 @@ class CleanStaticFilesTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); $this->eventManagerMock = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/MassDisableTest.php b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/MassDisableTest.php index 73facfffc6429..556db311748bd 100644 --- a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/MassDisableTest.php +++ b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/MassDisableTest.php @@ -20,7 +20,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class MassDisableTest extends \PHPUnit_Framework_TestCase +class MassDisableTest extends \PHPUnit\Framework\TestCase { /** * @var MassDisable diff --git a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/MassEnableTest.php b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/MassEnableTest.php index b03e1eb805613..ad622ca69757a 100644 --- a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/MassEnableTest.php +++ b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/MassEnableTest.php @@ -20,7 +20,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class MassEnableTest extends \PHPUnit_Framework_TestCase +class MassEnableTest extends \PHPUnit\Framework\TestCase { /** * @var MassEnable diff --git a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Dashboard/AbstractTestCase.php b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Dashboard/AbstractTestCase.php index d55c27c30a1ac..dbd1cbe5ec8ec 100644 --- a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Dashboard/AbstractTestCase.php +++ b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Dashboard/AbstractTestCase.php @@ -9,7 +9,7 @@ /** * Abstract test class */ -class AbstractTestCase extends \PHPUnit_Framework_TestCase +class AbstractTestCase extends \PHPUnit\Framework\TestCase { /** * Assertions for controller execute method @@ -21,34 +21,12 @@ protected function assertExecute($controllerName, $blockName) { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $outPut = "data"; - $resultRawMock = $this->getMock( - \Magento\Framework\Controller\Result\Raw::class, - ['setContents'], - [], - '', - false - ); - $resultRawFactoryMock = $this->getMock( - \Magento\Framework\Controller\Result\RawFactory::class, - ['create'], - [], - '', - false - ); - $layoutFactoryMock = $this->getMock( - \Magento\Framework\View\LayoutFactory::class, - ['create'], - [], - '', - false - ); - $layoutMock = $this->getMock( - \Magento\Framework\View\Layout::class, - ['createBlock', 'toHtml'], - [], - '', - false - ); + $resultRawMock = $this->createPartialMock(\Magento\Framework\Controller\Result\Raw::class, ['setContents']) + ; + $resultRawFactoryMock = + $this->createPartialMock(\Magento\Framework\Controller\Result\RawFactory::class, ['create']); + $layoutFactoryMock = $this->createPartialMock(\Magento\Framework\View\LayoutFactory::class, ['create']); + $layoutMock = $this->createPartialMock(\Magento\Framework\View\Layout::class, ['createBlock', 'toHtml']); $layoutFactoryMock->expects($this->once())->method('create')->will($this->returnValue($layoutMock)); $layoutMock->expects($this->once())->method('createBlock')->with($blockName)->will($this->returnSelf()); $layoutMock->expects($this->once())->method('toHtml')->will($this->returnValue($outPut)); diff --git a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Dashboard/RefreshStatisticsTest.php b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Dashboard/RefreshStatisticsTest.php index ff82c6e65d2ae..e8dcc00345fc6 100644 --- a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Dashboard/RefreshStatisticsTest.php +++ b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Dashboard/RefreshStatisticsTest.php @@ -9,7 +9,7 @@ /** * Test for \Magento\Backend\Controller\Adminhtml\Dashboard\RefreshStatistics */ -class RefreshStatisticsTest extends \PHPUnit_Framework_TestCase +class RefreshStatisticsTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\Model\View\Result\Redirect|\PHPUnit_Framework_MockObject_MockObject @@ -64,31 +64,25 @@ protected function setUp() $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->resultRedirectFactory = $this->getMock( + $this->resultRedirectFactory = $this->createPartialMock( \Magento\Backend\Model\View\Result\RedirectFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->resultRedirect = $this->getMock(\Magento\Backend\Model\View\Result\Redirect::class, [], [], '', false); + $this->resultRedirect = $this->createMock(\Magento\Backend\Model\View\Result\Redirect::class); - $this->request = $this->getMock(\Magento\Framework\App\RequestInterface::class, [], [], '', false); - $this->response = $this->getMock( + $this->request = $this->createMock(\Magento\Framework\App\RequestInterface::class); + $this->response = $this->createPartialMock( \Magento\Framework\App\ResponseInterface::class, - ['setRedirect', 'sendResponse'], - [], - '', - false + ['setRedirect', 'sendResponse'] ); - $this->messageManager = $this->getMock(\Magento\Framework\Message\Manager::class, [], [], '', false); + $this->messageManager = $this->createMock(\Magento\Framework\Message\Manager::class); - $this->order = $this->getMock(\Magento\Sales\Model\ResourceModel\Report\Order::class, [], [], '', false); + $this->order = $this->createMock(\Magento\Sales\Model\ResourceModel\Report\Order::class); - $this->objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class, [], [], '', false); + $this->objectManager = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); - $this->context = $this->getMock(\Magento\Backend\App\Action\Context::class, [], [], '', false); + $this->context = $this->createMock(\Magento\Backend\App\Action\Context::class); $this->context->expects($this->once())->method('getRequest')->willReturn($this->request); $this->context->expects($this->once())->method('getResponse')->willReturn($this->response); $this->context->expects($this->once())->method('getMessageManager')->willReturn($this->messageManager); diff --git a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Dashboard/TunnelTest.php b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Dashboard/TunnelTest.php index 3bcf3cde5629f..b7713078863cb 100644 --- a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Dashboard/TunnelTest.php +++ b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Dashboard/TunnelTest.php @@ -8,7 +8,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class TunnelTest extends \PHPUnit_Framework_TestCase +class TunnelTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -32,9 +32,9 @@ class TunnelTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_request = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); - $this->_response = $this->getMock(\Magento\Framework\App\Response\Http::class, [], [], '', false); - $this->_objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->_request = $this->createMock(\Magento\Framework\App\Request\Http::class); + $this->_response = $this->createMock(\Magento\Framework\App\Response\Http::class); + $this->_objectManager = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); } protected function tearDown() @@ -52,20 +52,13 @@ public function testTunnelAction() ->with('ga') ->will($this->returnValue(urlencode(base64_encode(json_encode([1]))))); $this->_request->expects($this->at(1))->method('getParam')->with('h')->will($this->returnValue($fixture)); - $tunnelResponse = $this->getMock(\Magento\Framework\App\Response\Http::class, [], [], '', false); - $httpClient = $this->getMock( + $tunnelResponse = $this->createMock(\Magento\Framework\App\Response\Http::class); + $httpClient = $this->createPartialMock( \Magento\Framework\HTTP\ZendClient::class, ['setUri', 'setParameterGet', 'setConfig', 'request', 'getHeaders'] ); /** @var $helper \Magento\Backend\Helper\Dashboard\Data|\PHPUnit_Framework_MockObject_MockObject */ - $helper = $this->getMock( - \Magento\Backend\Helper\Dashboard\Data::class, - ['getChartDataHash'], - [], - '', - false, - false - ); + $helper = $this->createPartialMock(\Magento\Backend\Helper\Dashboard\Data::class, ['getChartDataHash']); $helper->expects($this->any())->method('getChartDataHash')->will($this->returnValue($fixture)); $this->_objectManager->expects($this->at(0)) @@ -127,14 +120,7 @@ public function testTunnelAction503() ->will($this->returnValue(urlencode(base64_encode(json_encode([1]))))); $this->_request->expects($this->at(1))->method('getParam')->with('h')->will($this->returnValue($fixture)); /** @var $helper \Magento\Backend\Helper\Dashboard\Data|\PHPUnit_Framework_MockObject_MockObject */ - $helper = $this->getMock( - \Magento\Backend\Helper\Dashboard\Data::class, - ['getChartDataHash'], - [], - '', - false, - false - ); + $helper = $this->createPartialMock(\Magento\Backend\Helper\Dashboard\Data::class, ['getChartDataHash']); $helper->expects($this->any())->method('getChartDataHash')->will($this->returnValue($fixture)); $this->_objectManager->expects($this->at(0)) @@ -146,7 +132,7 @@ public function testTunnelAction503() ->method('create') ->with(\Magento\Framework\HTTP\ZendClient::class) ->will($this->throwException($exceptionMock)); - $loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); + $loggerMock = $this->createMock(\Psr\Log\LoggerInterface::class); $loggerMock->expects($this->once())->method('critical')->with($exceptionMock); $this->_objectManager->expects($this->at(2)) ->method('get') @@ -181,7 +167,7 @@ protected function _factory($request, $response = null) { if (!$response) { /** @var $response \Magento\Framework\App\ResponseInterface|\PHPUnit_Framework_MockObject_MockObject */ - $response = $this->getMock(\Magento\Framework\App\Response\Http::class, [], [], '', false); + $response = $this->createMock(\Magento\Framework\App\Response\Http::class); $response->headersSentThrowsException = false; } $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); diff --git a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/System/Account/SaveTest.php b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/System/Account/SaveTest.php index 1fe8b80ab4ee9..844a821df1c20 100644 --- a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/System/Account/SaveTest.php +++ b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/System/Account/SaveTest.php @@ -10,7 +10,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class SaveTest extends \PHPUnit_Framework_TestCase +class SaveTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Backend\Controller\Adminhtml\System\Account */ protected $_controller; @@ -115,7 +115,19 @@ protected function setUp() ->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT) ->willReturn($resultRedirect); - $contextMock = $this->getMock(\Magento\Backend\App\Action\Context::class, [], [], '', false); + $contextMock = $this->createPartialMock( + \Magento\Backend\App\Action\Context::class, + [ + 'getRequest', + 'getResponse', + 'getObjectManager', + 'getFrontController', + 'getHelper', + 'getMessageManager', + 'getTranslator', + 'getResultFactory' + ] + ); $contextMock->expects($this->any())->method('getRequest')->willReturn($this->_requestMock); $contextMock->expects($this->any())->method('getResponse')->willReturn($this->_responseMock); $contextMock->expects($this->any())->method('getObjectManager')->willReturn($this->_objectManagerMock); diff --git a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/System/Store/IndexTest.php b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/System/Store/IndexTest.php index ab011aa157e45..1986c41e5cfb6 100644 --- a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/System/Store/IndexTest.php +++ b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/System/Store/IndexTest.php @@ -13,7 +13,7 @@ use Magento\Framework\View\Page\Config; use Magento\Framework\View\Page\Title; -class IndexTest extends \PHPUnit_Framework_TestCase +class IndexTest extends \PHPUnit\Framework\TestCase { /** * @var ObjectManagerHelper diff --git a/app/code/Magento/Backend/Test/Unit/Cron/CleanCacheTest.php b/app/code/Magento/Backend/Test/Unit/Cron/CleanCacheTest.php index 84007894ec26c..d7b13d897e07c 100644 --- a/app/code/Magento/Backend/Test/Unit/Cron/CleanCacheTest.php +++ b/app/code/Magento/Backend/Test/Unit/Cron/CleanCacheTest.php @@ -5,19 +5,13 @@ */ namespace Magento\Backend\Test\Unit\Cron; -class CleanCacheTest extends \PHPUnit_Framework_TestCase +class CleanCacheTest extends \PHPUnit\Framework\TestCase { public function testCleanCache() { $cacheBackendMock = $this->getMockForAbstractClass(\Zend_Cache_Backend_Interface::class); $cacheFrontendMock = $this->getMockForAbstractClass(\Magento\Framework\Cache\FrontendInterface::class); - $frontendPoolMock = $this->getMock( - \Magento\Framework\App\Cache\Frontend\Pool::class, - [], - [], - '', - false - ); + $frontendPoolMock = $this->createMock(\Magento\Framework\App\Cache\Frontend\Pool::class); $cacheBackendMock->expects( $this->once() diff --git a/app/code/Magento/Backend/Test/Unit/Helper/DataTest.php b/app/code/Magento/Backend/Test/Unit/Helper/DataTest.php index b52ee6f63a433..b7a33ab883b69 100644 --- a/app/code/Magento/Backend/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Backend/Test/Unit/Helper/DataTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Backend\Test\Unit\Helper; -class DataTest extends \PHPUnit_Framework_TestCase +class DataTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\Helper\Data @@ -19,22 +19,16 @@ class DataTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_frontResolverMock = $this->getMock( - \Magento\Backend\App\Area\FrontNameResolver::class, - [], - [], - '', - false - ); + $this->_frontResolverMock = $this->createMock(\Magento\Backend\App\Area\FrontNameResolver::class); $this->_helper = new \Magento\Backend\Helper\Data( - $this->getMock(\Magento\Framework\App\Helper\Context::class, [], [], '', false, false), - $this->getMock(\Magento\Framework\App\Route\Config::class, [], [], '', false), - $this->getMock(\Magento\Framework\Locale\ResolverInterface::class), - $this->getMock(\Magento\Backend\Model\Url::class, [], [], '', false), - $this->getMock(\Magento\Backend\Model\Auth::class, [], [], '', false), + $this->createMock(\Magento\Framework\App\Helper\Context::class), + $this->createMock(\Magento\Framework\App\Route\Config::class), + $this->createMock(\Magento\Framework\Locale\ResolverInterface::class), + $this->createMock(\Magento\Backend\Model\Url::class), + $this->createMock(\Magento\Backend\Model\Auth::class), $this->_frontResolverMock, - $this->getMock(\Magento\Framework\Math\Random::class, [], [], '', false), - $this->getMock(\Magento\Framework\App\RequestInterface::class) + $this->createMock(\Magento\Framework\Math\Random::class), + $this->createMock(\Magento\Framework\App\RequestInterface::class) ); } diff --git a/app/code/Magento/Backend/Test/Unit/Model/AdminPathConfigTest.php b/app/code/Magento/Backend/Test/Unit/Model/AdminPathConfigTest.php index cff8ba5a7e2e1..4911dc1e9968e 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/AdminPathConfigTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/AdminPathConfigTest.php @@ -8,7 +8,7 @@ use Magento\Backend\Model\AdminPathConfig; use Magento\Store\Model\Store; -class AdminPathConfigTest extends \PHPUnit_Framework_TestCase +class AdminPathConfigTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Backend/Test/Unit/Model/Auth/SessionTest.php b/app/code/Magento/Backend/Test/Unit/Model/Auth/SessionTest.php index 265717a05d22a..391deac5a1f4e 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Auth/SessionTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Auth/SessionTest.php @@ -13,7 +13,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class SessionTest extends \PHPUnit_Framework_TestCase +class SessionTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\App\Config | \PHPUnit_Framework_MockObject_MockObject @@ -52,35 +52,23 @@ class SessionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->cookieMetadataFactory = $this->getMock( + $this->cookieMetadataFactory = $this->createPartialMock( \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory::class, - ['createPublicCookieMetadata'], - [], - '', - false + ['createPublicCookieMetadata'] ); - $this->config = $this->getMock(\Magento\Backend\App\Config::class, ['getValue'], [], '', false); - $this->cookieManager = $this->getMock( + $this->config = $this->createPartialMock(\Magento\Backend\App\Config::class, ['getValue']); + $this->cookieManager = $this->createPartialMock( \Magento\Framework\Stdlib\Cookie\PhpCookieManager::class, - ['getCookie', 'setPublicCookie'], - [], - '', - false + ['getCookie', 'setPublicCookie'] ); - $this->storage = $this->getMock( + $this->storage = $this->createPartialMock( \Magento\Framework\Session\Storage::class, - ['getUser', 'getAcl', 'setAcl'], - [], - '', - false + ['getUser', 'getAcl', 'setAcl'] ); - $this->sessionConfig = $this->getMock( + $this->sessionConfig = $this->createPartialMock( \Magento\Framework\Session\Config::class, - ['getCookiePath', 'getCookieDomain', 'getCookieSecure', 'getCookieHttpOnly'], - [], - '', - false + ['getCookiePath', 'getCookieDomain', 'getCookieSecure', 'getCookieHttpOnly'] ); $this->aclBuilder = $this->getMockBuilder(\Magento\Framework\Acl\Builder::class) ->disableOriginalConstructor() @@ -142,7 +130,7 @@ public function refreshAclDataProvider() public function testIsLoggedInPositive() { - $user = $this->getMock(\Magento\User\Model\User::class, ['getId', '__wakeup'], [], '', false); + $user = $this->createPartialMock(\Magento\User\Model\User::class, ['getId', '__wakeup']); $user->expects($this->once()) ->method('getId') ->will($this->returnValue(1)); @@ -168,7 +156,7 @@ public function testProlong() ->method('getValue') ->with(\Magento\Backend\Model\Auth\Session::XML_PATH_SESSION_LIFETIME) ->willReturn($lifetime); - $cookieMetadata = $this->getMock(\Magento\Framework\Stdlib\Cookie\PublicCookieMetadata::class); + $cookieMetadata = $this->createMock(\Magento\Framework\Stdlib\Cookie\PublicCookieMetadata::class); $cookieMetadata->expects($this->once()) ->method('setDuration') ->with($lifetime) diff --git a/app/code/Magento/Backend/Test/Unit/Model/AuthTest.php b/app/code/Magento/Backend/Test/Unit/Model/AuthTest.php index ca3be4f153bf2..4b79d504dad91 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/AuthTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/AuthTest.php @@ -10,7 +10,7 @@ /** * Class AuthTest */ -class AuthTest extends \PHPUnit_Framework_TestCase +class AuthTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\Model\Auth @@ -34,15 +34,13 @@ class AuthTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); - $this->_credentialStorage = $this->getMock(\Magento\Backend\Model\Auth\Credential\StorageInterface::class); - $this->_modelFactoryMock = $this->getMock( - \Magento\Framework\Data\Collection\ModelFactory::class, - [], - [], - '', - false - ); + $this->_eventManagerMock = $this->createMock(\Magento\Framework\Event\ManagerInterface::class); + $this->_credentialStorage = $this->getMockBuilder( + \Magento\Backend\Model\Auth\Credential\StorageInterface::class + ) + ->setMethods(['getId']) + ->getMockForAbstractClass(); + $this->_modelFactoryMock = $this->createMock(\Magento\Framework\Data\Collection\ModelFactory::class); $objectManager = new ObjectManager($this); $this->_model = $objectManager->getObject( \Magento\Backend\Model\Auth::class, diff --git a/app/code/Magento/Backend/Test/Unit/Model/Authorization/RoleLocatorTest.php b/app/code/Magento/Backend/Test/Unit/Model/Authorization/RoleLocatorTest.php index 0789460cfc5da..5b3910e9445f8 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Authorization/RoleLocatorTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Authorization/RoleLocatorTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Backend\Test\Unit\Model\Authorization; -class RoleLocatorTest extends \PHPUnit_Framework_TestCase +class RoleLocatorTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\Model\Authorization\RoleLocator @@ -19,12 +19,9 @@ class RoleLocatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_sessionMock = $this->getMock( + $this->_sessionMock = $this->createPartialMock( \Magento\Backend\Model\Auth\Session::class, - ['getUser', 'getAclRole', 'hasUser'], - [], - '', - false + ['getUser', 'getAclRole', 'hasUser'] ); $this->_model = new \Magento\Backend\Model\Authorization\RoleLocator($this->_sessionMock); } diff --git a/app/code/Magento/Backend/Test/Unit/Model/Config/SessionLifetime/BackendModelTest.php b/app/code/Magento/Backend/Test/Unit/Model/Config/SessionLifetime/BackendModelTest.php index 57f8a157ab665..31a13191750a3 100755 --- a/app/code/Magento/Backend/Test/Unit/Model/Config/SessionLifetime/BackendModelTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Config/SessionLifetime/BackendModelTest.php @@ -8,7 +8,7 @@ use Magento\Backend\Model\Config\SessionLifetime\BackendModel; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class BackendModelTest extends \PHPUnit_Framework_TestCase +class BackendModelTest extends \PHPUnit\Framework\TestCase { /** * @dataProvider adminSessionLifetimeDataProvider @@ -20,10 +20,11 @@ public function testBeforeSave($value, $errorMessage = null) \Magento\Backend\Model\Config\SessionLifetime\BackendModel::class ); if ($errorMessage !== null) { - $this->setExpectedException(\Magento\Framework\Exception\LocalizedException::class, $errorMessage); + $this->expectException(\Magento\Framework\Exception\LocalizedException::class, $errorMessage); } $model->setValue($value); - $model->beforeSave(); + $object = $model->beforeSave(); + $this->assertEquals($model, $object); } public function adminSessionLifetimeDataProvider() diff --git a/app/code/Magento/Backend/Test/Unit/Model/Locale/ManagerTest.php b/app/code/Magento/Backend/Test/Unit/Model/Locale/ManagerTest.php index f48c1fdeb8922..77eb7cdb34d1f 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Locale/ManagerTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Locale/ManagerTest.php @@ -7,7 +7,7 @@ use Magento\Framework\Locale\Resolver; -class ManagerTest extends \PHPUnit_Framework_TestCase +class ManagerTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\Model\Locale\Manager @@ -36,15 +36,9 @@ class ManagerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_session = $this->getMock(\Magento\Backend\Model\Session::class, [], [], '', false); + $this->_session = $this->createMock(\Magento\Backend\Model\Session::class); - $this->_authSession = $this->getMock( - \Magento\Backend\Model\Auth\Session::class, - ['getUser'], - [], - '', - false - ); + $this->_authSession = $this->createPartialMock(\Magento\Backend\Model\Auth\Session::class, ['getUser']); $this->_backendConfig = $this->getMockForAbstractClass( \Magento\Backend\App\ConfigInterface::class, @@ -57,7 +51,9 @@ protected function setUp() $this->_authSession->expects($this->any())->method('getUser')->will($this->returnValue($userMock)); - $this->_translator = $this->getMock(\Magento\Framework\TranslateInterface::class, [], [], '', false); + $this->_translator = $this->getMockBuilder(\Magento\Framework\TranslateInterface::class) + ->setMethods(['init', 'setLocale']) + ->getMockForAbstractClass(); $this->_translator->expects($this->any())->method('setLocale')->will($this->returnValue($this->_translator)); diff --git a/app/code/Magento/Backend/Test/Unit/Model/Menu/Builder/AbstractCommandTest.php b/app/code/Magento/Backend/Test/Unit/Model/Menu/Builder/AbstractCommandTest.php index 112d7568e54af..208448776cf32 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Menu/Builder/AbstractCommandTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Menu/Builder/AbstractCommandTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Backend\Test\Unit\Model\Menu\Builder; -class AbstractCommandTest extends \PHPUnit_Framework_TestCase +class AbstractCommandTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\Model\Menu\Builder\AbstractCommand @@ -30,16 +30,12 @@ public function testConstructorRequiresObligatoryParams() public function testChainAddsNewCommandAsNextInChain() { - $command1 = $this->getMock( - \Magento\Backend\Model\Menu\Builder\Command\Update::class, - [], - [['id' => 1]] - ); - $command2 = $this->getMock( - \Magento\Backend\Model\Menu\Builder\Command\Remove::class, - [], - [['id' => 1]] - ); + $command1 = $this->getMockBuilder(\Magento\Backend\Model\Menu\Builder\Command\Update::class) + ->setConstructorArgs([['id' => 1]]) + ->getMock(); + $command2 = $this->getMockBuilder(\Magento\Backend\Model\Menu\Builder\Command\Remove::class) + ->setConstructorArgs([['id' => 1]]) + ->getMock(); $command1->expects($this->once())->method('chain')->with($this->equalTo($command2)); $this->_model->chain($command1); @@ -59,11 +55,10 @@ public function testExecuteCallsNextCommandInChain() $this->returnValue($itemParams) ); - $command1 = $this->getMock( - \Magento\Backend\Model\Menu\Builder\Command\Update::class, - [], - [['id' => 1]] - ); + $command1 = $this->getMockBuilder(\Magento\Backend\Model\Menu\Builder\Command\Update::class) + ->setConstructorArgs([['id' => 1]]) + ->getMock(); + $command1->expects( $this->once() )->method( diff --git a/app/code/Magento/Backend/Test/Unit/Model/Menu/Builder/Command/AddTest.php b/app/code/Magento/Backend/Test/Unit/Model/Menu/Builder/Command/AddTest.php index b5fc97c729ee7..e88b38245d5bd 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Menu/Builder/Command/AddTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Menu/Builder/Command/AddTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Backend\Test\Unit\Model\Menu\Builder\Command; -class AddTest extends \PHPUnit_Framework_TestCase +class AddTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\Model\Menu\Builder\Command\Add diff --git a/app/code/Magento/Backend/Test/Unit/Model/Menu/Builder/Command/RemoveTest.php b/app/code/Magento/Backend/Test/Unit/Model/Menu/Builder/Command/RemoveTest.php index 7953f6d56dc46..097390e7975ee 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Menu/Builder/Command/RemoveTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Menu/Builder/Command/RemoveTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Backend\Test\Unit\Model\Menu\Builder\Command; -class RemoveTest extends \PHPUnit_Framework_TestCase +class RemoveTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\Model\Menu\Builder\Command\Remove diff --git a/app/code/Magento/Backend/Test/Unit/Model/Menu/Builder/Command/UpdateTest.php b/app/code/Magento/Backend/Test/Unit/Model/Menu/Builder/Command/UpdateTest.php index 77fac32ec8827..8e88efadb2250 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Menu/Builder/Command/UpdateTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Menu/Builder/Command/UpdateTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Backend\Test\Unit\Model\Menu\Builder\Command; -class UpdateTest extends \PHPUnit_Framework_TestCase +class UpdateTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\Model\Menu\Builder\Command\Update diff --git a/app/code/Magento/Backend/Test/Unit/Model/Menu/BuilderTest.php b/app/code/Magento/Backend/Test/Unit/Model/Menu/BuilderTest.php index 1befeff7399af..0eac8b5926b5e 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Menu/BuilderTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Menu/BuilderTest.php @@ -7,7 +7,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class BuilderTest extends \PHPUnit_Framework_TestCase +class BuilderTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\Model\Menu\Builder @@ -26,8 +26,8 @@ class BuilderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->factoryMock = $this->getMock(\Magento\Backend\Model\Menu\Item\Factory::class, [], [], '', false); - $this->menuMock = $this->getMock(\Magento\Backend\Model\Menu::class, [], [], '', false); + $this->factoryMock = $this->createMock(\Magento\Backend\Model\Menu\Item\Factory::class); + $this->menuMock = $this->createPartialMock(\Magento\Backend\Model\Menu::class, ['addChild', 'add']); $this->model = (new ObjectManager($this))->getObject( \Magento\Backend\Model\Menu\Builder::class, @@ -39,9 +39,9 @@ protected function setUp() public function testProcessCommand() { - $command = $this->getMock(\Magento\Backend\Model\Menu\Builder\Command\Add::class, [], [], '', false); + $command = $this->createMock(\Magento\Backend\Model\Menu\Builder\Command\Add::class); $command->expects($this->any())->method('getId')->will($this->returnValue(1)); - $command2 = $this->getMock(\Magento\Backend\Model\Menu\Builder\Command\Update::class, [], [], '', false); + $command2 = $this->createMock(\Magento\Backend\Model\Menu\Builder\Command\Update::class); $command2->expects($this->any())->method('getId')->will($this->returnValue(1)); $command->expects($this->once())->method('chain')->with($this->equalTo($command2)); $this->model->processCommand($command); @@ -50,11 +50,11 @@ public function testProcessCommand() public function testGetResultBuildsTreeStructure() { - $item1 = $this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false); + $item1 = $this->createMock(\Magento\Backend\Model\Menu\Item::class); $item1->expects($this->once())->method('getChildren')->will($this->returnValue($this->menuMock)); $this->factoryMock->expects($this->any())->method('create')->will($this->returnValue($item1)); - $item2 = $this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false); + $item2 = $this->createMock(\Magento\Backend\Model\Menu\Item::class); $this->factoryMock->expects($this->at(1))->method('create')->will($this->returnValue($item2)); $this->menuMock->expects( @@ -128,7 +128,7 @@ public function testGetResultSkipsRemovedItems() */ public function testGetResultSkipItemsWithInvalidParent() { - $item1 = $this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false); + $item1 = $this->createMock(\Magento\Backend\Model\Menu\Item::class); $this->factoryMock->expects($this->any())->method('create')->will($this->returnValue($item1)); $this->model->processCommand( diff --git a/app/code/Magento/Backend/Test/Unit/Model/Menu/Config/ConverterTest.php b/app/code/Magento/Backend/Test/Unit/Model/Menu/Config/ConverterTest.php index 7e8b5134a4c65..861e978b1dc2a 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Menu/Config/ConverterTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Menu/Config/ConverterTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Backend\Test\Unit\Model\Menu\Config; -class ConverterTest extends \PHPUnit_Framework_TestCase +class ConverterTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\Model\Menu\Config\Converter diff --git a/app/code/Magento/Backend/Test/Unit/Model/Menu/Config/SchemaLocatorTest.php b/app/code/Magento/Backend/Test/Unit/Model/Menu/Config/SchemaLocatorTest.php index 235da8bcf6375..cc7eb7476ac13 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Menu/Config/SchemaLocatorTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Menu/Config/SchemaLocatorTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Backend\Test\Unit\Model\Menu\Config; -class SchemaLocatorTest extends \PHPUnit_Framework_TestCase +class SchemaLocatorTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -19,7 +19,7 @@ class SchemaLocatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_moduleReaderMock = $this->getMock(\Magento\Framework\Module\Dir\Reader::class, [], [], '', false); + $this->_moduleReaderMock = $this->createMock(\Magento\Framework\Module\Dir\Reader::class); $this->_moduleReaderMock->expects( $this->once() )->method( diff --git a/app/code/Magento/Backend/Test/Unit/Model/Menu/Config/XsdTest.php b/app/code/Magento/Backend/Test/Unit/Model/Menu/Config/XsdTest.php index 63c49146cc406..c5a2dd066e5a2 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Menu/Config/XsdTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Menu/Config/XsdTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Backend\Test\Unit\Model\Menu\Config; -class XsdTest extends \PHPUnit_Framework_TestCase +class XsdTest extends \PHPUnit\Framework\TestCase { /** * Path to xsd schema file diff --git a/app/code/Magento/Backend/Test/Unit/Model/Menu/ConfigTest.php b/app/code/Magento/Backend/Test/Unit/Model/Menu/ConfigTest.php index fdeb1d717b535..bc18bd44f4be4 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Menu/ConfigTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Menu/ConfigTest.php @@ -7,7 +7,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class ConfigTest extends \PHPUnit_Framework_TestCase +class ConfigTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\App\Cache\Type\Config|\PHPUnit_Framework_MockObject_MockObject @@ -41,41 +41,23 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->cacheInstanceMock = $this->getMock( - \Magento\Framework\App\Cache\Type\Config::class, - [], - [], - '', - false - ); + $this->cacheInstanceMock = $this->createMock(\Magento\Framework\App\Cache\Type\Config::class); - $menuFactoryMock = $this->getMock( - \Magento\Backend\Model\MenuFactory::class, - ['create'], - [], - '', - false - ); + $menuFactoryMock = $this->createPartialMock(\Magento\Backend\Model\MenuFactory::class, ['create']); - $this->configReaderMock = $this->getMock( - \Magento\Backend\Model\Menu\Config\Reader::class, - [], - [], - '', - false - ); + $this->configReaderMock = $this->createMock(\Magento\Backend\Model\Menu\Config\Reader::class); - $this->logger = $this->getMock(\Psr\Log\LoggerInterface::class); + $this->logger = $this->createMock(\Psr\Log\LoggerInterface::class); - $this->menuMock = $this->getMock(\Magento\Backend\Model\Menu::class, [], [], '', false); + $this->menuMock = $this->createMock(\Magento\Backend\Model\Menu::class); - $this->menuBuilderMock = $this->getMock(\Magento\Backend\Model\Menu\Builder::class, [], [], '', false); + $this->menuBuilderMock = $this->createMock(\Magento\Backend\Model\Menu\Builder::class); $menuFactoryMock->expects($this->any())->method('create')->will($this->returnValue($this->menuMock)); $this->configReaderMock->expects($this->any())->method('read')->will($this->returnValue([])); - $appState = $this->getMock(\Magento\Framework\App\State::class, ['getAreaCode'], [], '', false); + $appState = $this->createPartialMock(\Magento\Framework\App\State::class, ['getAreaCode']); $appState->expects( $this->any() )->method( @@ -146,7 +128,7 @@ public function testGetMenuWithNotCachedObjectBuidlsObject() */ public function testGetMenuExceptionLogged($expectedException) { - $this->setExpectedException($expectedException); + $this->expectException($expectedException); $this->menuBuilderMock->expects( $this->exactly(1) )->method( diff --git a/app/code/Magento/Backend/Test/Unit/Model/Menu/Director/DirectorTest.php b/app/code/Magento/Backend/Test/Unit/Model/Menu/Director/DirectorTest.php index ff462e570d776..ccf3010b42e0f 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Menu/Director/DirectorTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Menu/Director/DirectorTest.php @@ -9,7 +9,7 @@ */ namespace Magento\Backend\Test\Unit\Model\Menu\Director; -class DirectorTest extends \PHPUnit_Framework_TestCase +class DirectorTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\Model\Menu\Director\Director @@ -38,21 +38,15 @@ class DirectorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_builderMock = $this->getMock(\Magento\Backend\Model\Menu\Builder::class, [], [], '', false); - $this->_logger = $this->getMock(\Psr\Log\LoggerInterface::class); - $this->_commandMock = $this->getMock( + $this->_builderMock = $this->createMock(\Magento\Backend\Model\Menu\Builder::class); + $this->_logger = $this->createMock(\Psr\Log\LoggerInterface::class); + $this->_commandMock = $this->createPartialMock( \Magento\Backend\Model\Menu\Builder\AbstractCommand::class, - ['getId', '_execute', 'execute', 'chain'], - [], - '', - false + ['getId', '_execute', 'execute', 'chain'] ); - $this->_commandFactoryMock = $this->getMock( + $this->_commandFactoryMock = $this->createPartialMock( \Magento\Backend\Model\Menu\Builder\CommandFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->_commandFactoryMock->expects( $this->any() diff --git a/app/code/Magento/Backend/Test/Unit/Model/Menu/Filter/IteratorTest.php b/app/code/Magento/Backend/Test/Unit/Model/Menu/Filter/IteratorTest.php index 9f4d0a7043dd6..67f061f3fb2a2 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Menu/Filter/IteratorTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Menu/Filter/IteratorTest.php @@ -7,7 +7,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class IteratorTest extends \PHPUnit_Framework_TestCase +class IteratorTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\Model\Menu @@ -21,17 +21,17 @@ class IteratorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->items['item1'] = $this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false); + $this->items['item1'] = $this->createMock(\Magento\Backend\Model\Menu\Item::class); $this->items['item1']->expects($this->any())->method('getId')->will($this->returnValue('item1')); $this->items['item1']->expects($this->any())->method('isDisabled')->will($this->returnValue(false)); $this->items['item1']->expects($this->any())->method('isAllowed')->will($this->returnValue(true)); - $this->items['item2'] = $this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false); + $this->items['item2'] = $this->createMock(\Magento\Backend\Model\Menu\Item::class); $this->items['item2']->expects($this->any())->method('getId')->will($this->returnValue('item2')); $this->items['item2']->expects($this->any())->method('isDisabled')->will($this->returnValue(true)); $this->items['item2']->expects($this->any())->method('isAllowed')->will($this->returnValue(true)); - $this->items['item3'] = $this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false); + $this->items['item3'] = $this->createMock(\Magento\Backend\Model\Menu\Item::class); $this->items['item3']->expects($this->any())->method('getId')->will($this->returnValue('item3')); $this->items['item3']->expects($this->any())->method('isDisabled')->will($this->returnValue(false)); $this->items['item3']->expects($this->any())->method('isAllowed')->will($this->returnValue(false)); @@ -41,11 +41,11 @@ protected function setUp() public function testLoopWithAllItemsDisabledDoesntIterate() { - $this->menuModel->add($this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false)); - $this->menuModel->add($this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false)); - $this->menuModel->add($this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false)); - $this->menuModel->add($this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false)); - $this->menuModel->add($this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false)); + $this->menuModel->add($this->createMock(\Magento\Backend\Model\Menu\Item::class)); + $this->menuModel->add($this->createMock(\Magento\Backend\Model\Menu\Item::class)); + $this->menuModel->add($this->createMock(\Magento\Backend\Model\Menu\Item::class)); + $this->menuModel->add($this->createMock(\Magento\Backend\Model\Menu\Item::class)); + $this->menuModel->add($this->createMock(\Magento\Backend\Model\Menu\Item::class)); $filterIteratorModel = new \Magento\Backend\Model\Menu\Filter\Iterator( $this->menuModel->getIterator() ); @@ -59,13 +59,13 @@ public function testLoopWithAllItemsDisabledDoesntIterate() public function testLoopIteratesOnlyValidItems() { - $this->menuModel->add($this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false)); - $this->menuModel->add($this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false)); + $this->menuModel->add($this->createMock(\Magento\Backend\Model\Menu\Item::class)); + $this->menuModel->add($this->createMock(\Magento\Backend\Model\Menu\Item::class)); $this->menuModel->add($this->items['item1']); - $this->menuModel->add($this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false)); - $this->menuModel->add($this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false)); + $this->menuModel->add($this->createMock(\Magento\Backend\Model\Menu\Item::class)); + $this->menuModel->add($this->createMock(\Magento\Backend\Model\Menu\Item::class)); $filterIteratorModel = new \Magento\Backend\Model\Menu\Filter\Iterator( $this->menuModel->getIterator() ); @@ -79,14 +79,14 @@ public function testLoopIteratesOnlyValidItems() public function testLoopIteratesDosntIterateDisabledItems() { - $this->menuModel->add($this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false)); - $this->menuModel->add($this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false)); + $this->menuModel->add($this->createMock(\Magento\Backend\Model\Menu\Item::class)); + $this->menuModel->add($this->createMock(\Magento\Backend\Model\Menu\Item::class)); $this->menuModel->add($this->items['item1']); $this->menuModel->add($this->items['item2']); - $this->menuModel->add($this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false)); - $this->menuModel->add($this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false)); + $this->menuModel->add($this->createMock(\Magento\Backend\Model\Menu\Item::class)); + $this->menuModel->add($this->createMock(\Magento\Backend\Model\Menu\Item::class)); $filterIteratorModel = new \Magento\Backend\Model\Menu\Filter\Iterator( $this->menuModel->getIterator() ); @@ -100,14 +100,14 @@ public function testLoopIteratesDosntIterateDisabledItems() public function testLoopIteratesDosntIterateNotAllowedItems() { - $this->menuModel->add($this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false)); - $this->menuModel->add($this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false)); + $this->menuModel->add($this->createMock(\Magento\Backend\Model\Menu\Item::class)); + $this->menuModel->add($this->createMock(\Magento\Backend\Model\Menu\Item::class)); $this->menuModel->add($this->items['item1']); $this->menuModel->add($this->items['item3']); - $this->menuModel->add($this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false)); - $this->menuModel->add($this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false)); + $this->menuModel->add($this->createMock(\Magento\Backend\Model\Menu\Item::class)); + $this->menuModel->add($this->createMock(\Magento\Backend\Model\Menu\Item::class)); $filterIteratorModel = new \Magento\Backend\Model\Menu\Filter\Iterator( $this->menuModel->getIterator() ); @@ -121,15 +121,15 @@ public function testLoopIteratesDosntIterateNotAllowedItems() public function testLoopIteratesMixedItems() { - $this->menuModel->add($this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false)); - $this->menuModel->add($this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false)); + $this->menuModel->add($this->createMock(\Magento\Backend\Model\Menu\Item::class)); + $this->menuModel->add($this->createMock(\Magento\Backend\Model\Menu\Item::class)); $this->menuModel->add($this->items['item1']); $this->menuModel->add($this->items['item2']); $this->menuModel->add($this->items['item3']); - $this->menuModel->add($this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false)); - $this->menuModel->add($this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false)); + $this->menuModel->add($this->createMock(\Magento\Backend\Model\Menu\Item::class)); + $this->menuModel->add($this->createMock(\Magento\Backend\Model\Menu\Item::class)); $filterIteratorModel = new \Magento\Backend\Model\Menu\Filter\Iterator( $this->menuModel->getIterator() ); diff --git a/app/code/Magento/Backend/Test/Unit/Model/Menu/Item/ValidatorTest.php b/app/code/Magento/Backend/Test/Unit/Model/Menu/Item/ValidatorTest.php index 0b163718bfdfb..3c1f1e43900be 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Menu/Item/ValidatorTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Menu/Item/ValidatorTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Backend\Test\Unit\Model\Menu\Item; -class ValidatorTest extends \PHPUnit_Framework_TestCase +class ValidatorTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\Model\Menu\Item\Validator @@ -138,7 +138,8 @@ public function testValidateWithDuplicateIdsThrowsException($existedItems, $newI } $newItem = array_merge($newItem, $this->_params); - $this->_model->validate($newItem); + $result = $this->_model->validate($newItem); + $this->assertNull($result); } /** @@ -207,7 +208,8 @@ public function testValidateParamWithNullForRequiredParamThrowsException() public function testValidateParamWithNullForNonRequiredParamDoesntValidate() { try { - $this->_model->validateParam('toolTip', null); + $result = $this->_model->validateParam('toolTip', null); + $this->assertNull($result); } catch (\Exception $e) { $this->fail("Non required null values should not be validated"); } @@ -226,6 +228,7 @@ public function testValidateParamValidatesPrimitiveValues() */ public function testValidateParamResourceCompoundModuleNamespace() { - $this->_model->validateParam('resource', 'TheCompoundNamespace_TheCompoundModule::resource'); + $result = $this->_model->validateParam('resource', 'TheCompoundNamespace_TheCompoundModule::resource'); + $this->assertNull($result); } } diff --git a/app/code/Magento/Backend/Test/Unit/Model/Menu/ItemTest.php b/app/code/Magento/Backend/Test/Unit/Model/Menu/ItemTest.php index a98083a3b54b2..74368537c39c7 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Menu/ItemTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Menu/ItemTest.php @@ -8,7 +8,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ItemTest extends \PHPUnit_Framework_TestCase +class ItemTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\Model\Menu\Item @@ -63,20 +63,14 @@ class ItemTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_aclMock = $this->getMock(\Magento\Framework\AuthorizationInterface::class); - $this->_scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $this->_menuFactoryMock = $this->getMock( - \Magento\Backend\Model\MenuFactory::class, - ['create'], - [], - '', - false - ); - $this->_urlModelMock = $this->getMock(\Magento\Backend\Model\Url::class, [], [], '', false); - $this->_moduleManager = $this->getMock(\Magento\Framework\Module\Manager::class, [], [], '', false); - $validatorMock = $this->getMock(\Magento\Backend\Model\Menu\Item\Validator::class); + $this->_aclMock = $this->createMock(\Magento\Framework\AuthorizationInterface::class); + $this->_scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->_menuFactoryMock = $this->createPartialMock(\Magento\Backend\Model\MenuFactory::class, ['create']); + $this->_urlModelMock = $this->createMock(\Magento\Backend\Model\Url::class); + $this->_moduleManager = $this->createMock(\Magento\Framework\Module\Manager::class); + $validatorMock = $this->createMock(\Magento\Backend\Model\Menu\Item\Validator::class); $validatorMock->expects($this->any())->method('validate'); - $this->_moduleListMock = $this->getMock(\Magento\Framework\Module\ModuleListInterface::class); + $this->_moduleListMock = $this->createMock(\Magento\Framework\Module\ModuleListInterface::class); $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_model = $this->objectManager->getObject( @@ -213,7 +207,7 @@ public function testIsAllowedReturnsFalseIfResourceIsNotAvailable() public function testGetChildrenCreatesSubmenuOnFirstCall() { - $menuMock = $this->getMock(\Magento\Backend\Model\Menu::class, [], [], '', false); + $menuMock = $this->createMock(\Magento\Backend\Model\Menu::class); $this->_menuFactoryMock->expects($this->once())->method('create')->will($this->returnValue($menuMock)); @@ -228,7 +222,7 @@ public function testGetChildrenCreatesSubmenuOnFirstCall() */ public function testToArray(array $data, array $expected) { - $menuMock = $this->getMock(\Magento\Backend\Model\Menu::class, [], [], '', false); + $menuMock = $this->createMock(\Magento\Backend\Model\Menu::class); $this->_menuFactoryMock->method('create')->will($this->returnValue($menuMock)); $menuMock->method('toArray') ->willReturn($data['sub_menu']); @@ -267,7 +261,7 @@ public function testPopulateFromArray( array $populateFromData, array $expected ) { - $menuMock = $this->getMock(\Magento\Backend\Model\Menu::class, [], [], '', false); + $menuMock = $this->createMock(\Magento\Backend\Model\Menu::class); $this->_menuFactoryMock->method('create')->willReturn($menuMock); $menuMock->method('toArray') ->willReturn(['submenuArray']); diff --git a/app/code/Magento/Backend/Test/Unit/Model/MenuBuilderTest.php b/app/code/Magento/Backend/Test/Unit/Model/MenuBuilderTest.php index 4118edaca2218..23d1ed5da1425 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/MenuBuilderTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/MenuBuilderTest.php @@ -8,7 +8,7 @@ use Magento\Backend\Model\Setup\MenuBuilder; -class MenuBuilderTest extends \PHPUnit_Framework_TestCase +class MenuBuilderTest extends \PHPUnit\Framework\TestCase { /** * @dataProvider afterGetResultDataProvider @@ -19,15 +19,15 @@ class MenuBuilderTest extends \PHPUnit_Framework_TestCase */ public function testAfterGetResult($isPub, $times) { - $docRootLocator = $this->getMock(\Magento\Framework\App\DocRootLocator::class, [], [], '', false); + $docRootLocator = $this->createMock(\Magento\Framework\App\DocRootLocator::class); $docRootLocator->expects($this->once())->method('isPub')->willReturn($isPub); $model = new MenuBuilder($docRootLocator); /** @var \Magento\Backend\Model\Menu $menu */ - $menu = $this->getMock(\Magento\Backend\Model\Menu::class, [], [], '', false); + $menu = $this->createMock(\Magento\Backend\Model\Menu::class); $menu->expects($this->exactly($times))->method('remove')->willReturn(true); /** @var \Magento\Backend\Model\Menu\Builder $menuBuilder */ - $menuBuilder = $this->getMock(\Magento\Backend\Model\Menu\Builder::class, [], [], '', false); + $menuBuilder = $this->createMock(\Magento\Backend\Model\Menu\Builder::class); $this->assertInstanceOf( \Magento\Backend\Model\Menu::class, diff --git a/app/code/Magento/Backend/Test/Unit/Model/MenuTest.php b/app/code/Magento/Backend/Test/Unit/Model/MenuTest.php index 30ae58db3d550..737f76a7fda33 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/MenuTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/MenuTest.php @@ -9,7 +9,7 @@ use Magento\Backend\Model\Menu\Item\Factory; use Magento\Framework\Serialize\SerializerInterface; -class MenuTest extends \PHPUnit_Framework_TestCase +class MenuTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\Model\Menu @@ -34,16 +34,16 @@ class MenuTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_items['item1'] = $this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false); + $this->_items['item1'] = $this->createMock(\Magento\Backend\Model\Menu\Item::class); $this->_items['item1']->expects($this->any())->method('getId')->will($this->returnValue('item1')); - $this->_items['item2'] = $this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false); + $this->_items['item2'] = $this->createMock(\Magento\Backend\Model\Menu\Item::class); $this->_items['item2']->expects($this->any())->method('getId')->will($this->returnValue('item2')); - $this->_items['item3'] = $this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false); + $this->_items['item3'] = $this->createMock(\Magento\Backend\Model\Menu\Item::class); $this->_items['item3']->expects($this->any())->method('getId')->will($this->returnValue('item3')); - $this->_logger = $this->getMock(\Psr\Log\LoggerInterface::class); + $this->_logger = $this->createMock(\Psr\Log\LoggerInterface::class); $this->_model = $this->objectManagerHelper->getObject( \Magento\Backend\Model\Menu::class, @@ -55,7 +55,7 @@ protected function setUp() public function testAdd() { - $item = $this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false); + $item = $this->createMock(\Magento\Backend\Model\Menu\Item::class); $this->_model->add($item); $this->assertCount(1, $this->_model); $this->assertEquals($item, $this->_model[0]); @@ -63,7 +63,8 @@ public function testAdd() public function testAddDoLogAddAction() { - $this->_model->add($this->_items['item1']); + $result = $this->_model->add($this->_items['item1']); + $this->assertNull($result); } public function testAddToItem() @@ -79,9 +80,9 @@ public function testAddToItem() public function testAddWithSortIndexThatAlreadyExistsAddsItemOnNextAvailableIndex() { - $this->_model->add($this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false)); - $this->_model->add($this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false)); - $this->_model->add($this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false)); + $this->_model->add($this->createMock(\Magento\Backend\Model\Menu\Item::class)); + $this->_model->add($this->createMock(\Magento\Backend\Model\Menu\Item::class)); + $this->_model->add($this->createMock(\Magento\Backend\Model\Menu\Item::class)); $this->_model->add($this->_items['item1'], null, 2); $this->assertCount(4, $this->_model); @@ -207,13 +208,15 @@ public function testRemoveRemovesMenuItemRecursively() $this->_items['item1']->expects($this->any())->method('getChildren')->will($this->returnValue($menuMock)); $this->_model->add($this->_items['item1']); - $this->_model->remove('item2'); + $result = $this->_model->remove('item2'); + $this->assertNull($result); } public function testRemoveDoLogRemoveAction() { $this->_model->add($this->_items['item1']); - $this->_model->remove('item1'); + $result = $this->_model->remove('item1'); + $this->assertTrue($result); } public function testReorderReordersItemOnTopLevel() @@ -265,7 +268,7 @@ public function testIsLast() public function testGetFirstAvailableReturnsLeafNode() { - $item = $this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false); + $item = $this->createPartialMock(\Magento\Backend\Model\Menu\Item::class, ['getFirstAvailable', 'isAllowed']); $item->expects($this->never())->method('getFirstAvailable'); $this->_model->add($item); @@ -295,8 +298,8 @@ public function testGetFirstAvailableReturnsOnlyAllowedAndNotDisabledItem() public function testMultipleIterationsWorkProperly() { - $this->_model->add($this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false)); - $this->_model->add($this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false)); + $this->_model->add($this->createMock(\Magento\Backend\Model\Menu\Item::class)); + $this->_model->add($this->createMock(\Magento\Backend\Model\Menu\Item::class)); $this->_model->add($this->_items['item1']); $this->_model->add($this->_items['item2']); @@ -340,7 +343,7 @@ public function testNestedLoop() public function testSerialize() { - $serializerMock = $this->getMock(SerializerInterface::class); + $serializerMock = $this->createMock(SerializerInterface::class); $serializerMock->expects($this->once()) ->method('serialize') ->with([['arrayData']]) @@ -352,7 +355,7 @@ public function testSerialize() 'serializer' => $serializerMock, ] ); - $itemMock = $this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false); + $itemMock = $this->createMock(\Magento\Backend\Model\Menu\Item::class); $itemMock->expects($this->any())->method('getId')->will($this->returnValue('item1')); $itemMock->expects($this->once()) ->method('toArray') @@ -363,11 +366,11 @@ public function testSerialize() public function testUnserialize() { - $serializerMock = $this->getMock(SerializerInterface::class); + $serializerMock = $this->createMock(SerializerInterface::class); $serializerMock->expects($this->once()) ->method('unserialize') ->willReturn([['unserializedData']]); - $menuItemFactoryMock = $this->getMock(Factory::class, [], [], '', false); + $menuItemFactoryMock = $this->createMock(Factory::class); $menuItemFactoryMock->expects($this->once()) ->method('create') ->with(['unserializedData']); diff --git a/app/code/Magento/Backend/Test/Unit/Model/Session/AdminConfigTest.php b/app/code/Magento/Backend/Test/Unit/Model/Session/AdminConfigTest.php index af861165b4950..49fcdf4fc8770 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Session/AdminConfigTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Session/AdminConfigTest.php @@ -9,9 +9,7 @@ */ namespace Magento\Backend\Test\Unit\Model\Session; -use Magento\TestFramework\ObjectManager; - -class AdminConfigTest extends \PHPUnit_Framework_TestCase +class AdminConfigTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\App\RequestInterface | \PHPUnit_Framework_MockObject_MockObject @@ -40,13 +38,9 @@ class AdminConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->requestMock = $this->getMock( + $this->requestMock = $this->createPartialMock( \Magento\Framework\App\Request\Http::class, - ['getBasePath', 'isSecure', 'getHttpHost'], - [], - '', - false, - false + ['getBasePath', 'isSecure', 'getHttpHost'] ); $this->requestMock->expects($this->atLeastOnce())->method('getBasePath')->will($this->returnValue('/')); $this->requestMock->expects($this->atLeastOnce()) @@ -54,14 +48,15 @@ protected function setUp() ->will($this->returnValue('init.host')); $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->validatorFactory = $this->getMockBuilder(\Magento\Framework\ValidatorFactory::class) + ->setMethods(['setInstanceName', 'create']) ->disableOriginalConstructor() ->getMock(); - $backendUrl = $this->getMock(\Magento\Backend\Model\Url::class, [], [], '', false); + $backendUrl = $this->createMock(\Magento\Backend\Model\Url::class); $backendUrl->expects($this->once())->method('getBaseUrl')->will($this->returnValue('/')); - $this->backendUrlFactory = $this->getMock(\Magento\Backend\Model\UrlFactory::class, ['create'], [], '', false); + $this->backendUrlFactory = $this->createPartialMock(\Magento\Backend\Model\UrlFactory::class, ['create']); $this->backendUrlFactory->expects($this->any())->method('create')->willReturn($backendUrl); - $this->filesystemMock = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); + $this->filesystemMock = $this->createMock(\Magento\Framework\Filesystem::class); $dirMock = $this->getMockForAbstractClass(\Magento\Framework\Filesystem\Directory\WriteInterface::class); $this->filesystemMock->expects($this->any()) ->method('getDirectoryWrite') diff --git a/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php b/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php index bf67563ab6bd5..869d4ba3f45b1 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php @@ -10,7 +10,7 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.TooManyFields) */ -class QuoteTest extends \PHPUnit_Framework_TestCase +class QuoteTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager @@ -134,15 +134,9 @@ protected function setUp() true, ['getValue'] ); - $this->quoteRepositoryMock = $this->getMock(\Magento\Quote\Api\CartRepositoryInterface::class); + $this->quoteRepositoryMock = $this->createMock(\Magento\Quote\Api\CartRepositoryInterface::class); - $this->requestMock = $this->getMock( - \Magento\Framework\App\Request\Http::class, - [], - [], - '', - false - ); + $this->requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class); $this->sidResolverMock = $this->getMockForAbstractClass( \Magento\Framework\Session\SidResolverInterface::class, [], @@ -168,28 +162,12 @@ protected function setUp() false ); $this->storage = new \Magento\Framework\Session\Storage(); - $this->cookieManagerMock = $this->getMock(\Magento\Framework\Stdlib\CookieManagerInterface::class); - $this->cookieMetadataFactoryMock = $this->getMock( - \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory::class, - [], - [], - '', - false - ); - $this->orderFactoryMock = $this->getMock( - \Magento\Sales\Model\OrderFactory::class, - ['create'], - [], - '', - false - ); - $appStateMock = $this->getMock( - \Magento\Framework\App\State::class, - [], - [], - '', - false + $this->cookieManagerMock = $this->createMock(\Magento\Framework\Stdlib\CookieManagerInterface::class); + $this->cookieMetadataFactoryMock = $this->createMock( + \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory::class ); + $this->orderFactoryMock = $this->createPartialMock(\Magento\Sales\Model\OrderFactory::class, ['create']); + $appStateMock = $this->createMock(\Magento\Framework\App\State::class); $this->storeManagerMock = $this->getMockForAbstractClass( \Magento\Store\Model\StoreManagerInterface::class, [], @@ -197,29 +175,30 @@ protected function setUp() false ); - $this->quoteFactoryMock = $this->getMock(\Magento\Quote\Model\QuoteFactory::class, ['create'], [], '', false); - - $this->quote = $this->getMock( - \Magento\Backend\Model\Session\Quote::class, - ['getStoreId', 'getQuoteId', 'setQuoteId', 'hasCustomerId', 'getCustomerId'], - [ - 'request' => $this->requestMock, - 'sidResolver' => $this->sidResolverMock, - 'sessionConfig' => $this->sessionConfigMock, - 'saveHandler' => $this->saveHandlerMock, - 'validator' => $this->validatorMock, - 'storage' => $this->storage, - 'cookieManager' => $this->cookieManagerMock, - 'cookieMetadataFactory' => $this->cookieMetadataFactoryMock, - 'appState' => $appStateMock, - 'customerRepository' => $this->customerRepositoryMock, - 'quoteRepository' => $this->quoteRepositoryMock, - 'orderFactory' => $this->orderFactoryMock, - 'storeManager' => $this->storeManagerMock, - 'groupManagement' => $this->groupManagementMock, - 'quoteFactory' => $this->quoteFactoryMock - ] - ); + $this->quoteFactoryMock = $this->createPartialMock(\Magento\Quote\Model\QuoteFactory::class, ['create']); + + $this->quote = $this->getMockBuilder(\Magento\Backend\Model\Session\Quote::class) + ->setMethods(['getStoreId', 'getQuoteId', 'setQuoteId', 'hasCustomerId', 'getCustomerId']) + ->setConstructorArgs( + [ + 'request' => $this->requestMock, + 'sidResolver' => $this->sidResolverMock, + 'sessionConfig' => $this->sessionConfigMock, + 'saveHandler' => $this->saveHandlerMock, + 'validator' => $this->validatorMock, + 'storage' => $this->storage, + 'cookieManager' => $this->cookieManagerMock, + 'cookieMetadataFactory' => $this->cookieMetadataFactoryMock, + 'appState' => $appStateMock, + 'customerRepository' => $this->customerRepositoryMock, + 'quoteRepository' => $this->quoteRepositoryMock, + 'orderFactory' => $this->orderFactoryMock, + 'storeManager' => $this->storeManagerMock, + 'groupManagement' => $this->groupManagementMock, + 'quoteFactory' => $this->quoteFactoryMock + ] + ) + ->getMock(); } /** @@ -235,7 +214,7 @@ public function testGetQuoteWithoutQuoteId() $customerGroupId = 77; $this->quote->expects($this->any())->method('getQuoteId')->will($this->returnValue(null)); $this->quote->expects($this->any())->method('setQuoteId')->with($quoteId); - $cartInterfaceMock = $this->getMock( + $cartInterfaceMock = $this->createPartialMock( \Magento\Quote\Api\Data\CartInterface::class, [ 'getId', @@ -298,9 +277,7 @@ public function testGetQuoteWithoutQuoteId() ->with($customerId) ->willReturn($dataCustomerMock); - $quoteMock = $this->getMock( - \Magento\Quote\Model\Quote::class, - [ + $quoteMock = $this->createPartialMock(\Magento\Quote\Model\Quote::class, [ 'setStoreId', 'setCustomerGroupId', 'setIsActive', @@ -308,11 +285,7 @@ public function testGetQuoteWithoutQuoteId() 'setIgnoreOldQty', 'setIsSuperMode', '__wakeup' - ], - [], - '', - false - ); + ]); $this->quoteRepositoryMock->expects($this->once())->method('get')->willReturn($quoteMock); $cartInterfaceMock->expects($this->once())->method('setCustomerGroupId')->with($customerGroupId) @@ -355,9 +328,7 @@ public function testGetQuoteWithQuoteId($customerId, $quoteCustomerId, $expected ->with($customerId) ->willReturn($dataCustomerMock); - $quoteMock = $this->getMock( - \Magento\Quote\Model\Quote::class, - [ + $quoteMock = $this->createPartialMock(\Magento\Quote\Model\Quote::class, [ 'setStoreId', 'setCustomerGroupId', 'setIsActive', @@ -367,11 +338,7 @@ public function testGetQuoteWithQuoteId($customerId, $quoteCustomerId, $expected 'setIsSuperMode', 'getCustomerId', '__wakeup' - ], - [], - '', - false - ); + ]); $quoteMock->expects($this->once()) ->method('setStoreId') ->with($storeId); diff --git a/app/code/Magento/Backend/Test/Unit/Model/Translate/Inline/ConfigTest.php b/app/code/Magento/Backend/Test/Unit/Model/Translate/Inline/ConfigTest.php index 0e8c06ab8a0d5..d15d7a41f2460 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Translate/Inline/ConfigTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Translate/Inline/ConfigTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Backend\Test\Unit\Model\Translate\Inline; -class ConfigTest extends \PHPUnit_Framework_TestCase +class ConfigTest extends \PHPUnit\Framework\TestCase { public function testIsActive() { diff --git a/app/code/Magento/Backend/Test/Unit/Model/UrlTest.php b/app/code/Magento/Backend/Test/Unit/Model/UrlTest.php index 4edba05e29c33..9e2df1069617f 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/UrlTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/UrlTest.php @@ -12,7 +12,7 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @codingStandardsIgnoreFile */ -class UrlTest extends \PHPUnit_Framework_TestCase +class UrlTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\Model\Url @@ -81,20 +81,15 @@ class UrlTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_menuMock = $this->getMock(\Magento\Backend\Model\Menu::class, [], [], '', false); + $this->_menuMock = $this->createPartialMock(\Magento\Backend\Model\Menu::class, ['getFirstAvailableChild', 'get', 'getFirstAvailable']); - $this->_menuConfigMock = $this->getMock(\Magento\Backend\Model\Menu\Config::class, [], [], '', false); + $this->_menuConfigMock = $this->createMock(\Magento\Backend\Model\Menu\Config::class); $this->_menuConfigMock->expects($this->any())->method('getMenu')->will($this->returnValue($this->_menuMock)); - $this->_formKey = $this->getMock( - \Magento\Framework\Data\Form\FormKey::class, - ['getFormKey'], - [], - '', false - ); + $this->_formKey = $this->createPartialMock(\Magento\Framework\Data\Form\FormKey::class, ['getFormKey']); $this->_formKey->expects($this->any())->method('getFormKey')->will($this->returnValue('salt')); - $mockItem = $this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false); + $mockItem = $this->createMock(\Magento\Backend\Model\Menu\Item::class); $mockItem->expects($this->any())->method('isDisabled')->will($this->returnValue(false)); $mockItem->expects($this->any())->method('isAllowed')->will($this->returnValue(true)); $mockItem->expects( @@ -116,7 +111,7 @@ protected function setUp() $this->returnValue($mockItem) ); - $helperMock = $this->getMock(\Magento\Backend\Helper\Data::class, [], [], '', false); + $helperMock = $this->createMock(\Magento\Backend\Helper\Data::class); $helperMock->expects( $this->any() )->method( @@ -124,7 +119,7 @@ protected function setUp() )->will( $this->returnValue($this->_areaFrontName) ); - $this->_scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->_scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $this->_scopeConfigMock->expects( $this->any() )->method( @@ -135,28 +130,18 @@ protected function setUp() $this->returnValue('Magento_Backend::system_acl_roles') ); - $this->_authSessionMock = $this->getMock( - \Magento\Backend\Model\Auth\Session::class, - [], - [], - '', - false, - false - ); - $this->_encryptor = $this->getMock(\Magento\Framework\Encryption\Encryptor::class, null, [], '', false); - $routeParamsResolver = $this->getMock(\Magento\Framework\Url\RouteParamsResolver::class, [], [], '', false); - $this->routeParamsResolverFactoryMock = $this->getMock( - \Magento\Framework\Url\RouteParamsResolverFactory::class, - [], - [], - '', - false - ); + $this->_authSessionMock = $this->createMock(\Magento\Backend\Model\Auth\Session::class); + $this->_encryptor = $this->createPartialMock(\Magento\Framework\Encryption\Encryptor::class, ['getHash']); + $this->_encryptor->expects($this->any()) + ->method('getHash') + ->willReturnArgument(0); + $routeParamsResolver = $this->createMock(\Magento\Framework\Url\RouteParamsResolver::class); + $this->routeParamsResolverFactoryMock = $this->createMock(\Magento\Framework\Url\RouteParamsResolverFactory::class); $this->routeParamsResolverFactoryMock->expects($this->any()) ->method('create') ->willReturn($routeParamsResolver); /** @var HostChecker|\PHPUnit_Framework_MockObject_MockObject $hostCheckerMock */ - $hostCheckerMock = $this->getMock(HostChecker::class, [], [], '', false); + $hostCheckerMock = $this->createMock(HostChecker::class); $this->serializerMock = $this->getMockBuilder(Json::class) ->setMethods(['serialize']) ->disableOriginalConstructor() @@ -185,21 +170,15 @@ function ($value) { 'serializer' => $this->serializerMock ] ); - $this->_requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); + $this->_requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class); $this->_model->setRequest($this->_requestMock); } public function testFindFirstAvailableMenuDenied() { - $user = $this->getMock(\Magento\User\Model\User::class, [], [], '', false); + $user = $this->createMock(\Magento\User\Model\User::class); $user->expects($this->once())->method('setHasAvailableResources')->with($this->equalTo(false)); - $mockSession = $this->getMock( - \Magento\Backend\Model\Auth\Session::class, - ['getUser', 'isAllowed'], - [], - '', - false - ); + $mockSession = $this->createPartialMock(\Magento\Backend\Model\Auth\Session::class, ['getUser', 'isAllowed']); $mockSession->expects($this->any())->method('getUser')->will($this->returnValue($user)); @@ -212,20 +191,14 @@ public function testFindFirstAvailableMenuDenied() public function testFindFirstAvailableMenu() { - $user = $this->getMock(\Magento\User\Model\User::class, [], [], '', false); - $mockSession = $this->getMock( - \Magento\Backend\Model\Auth\Session::class, - ['getUser', 'isAllowed'], - [], - '', - false - ); + $user = $this->createMock(\Magento\User\Model\User::class); + $mockSession = $this->createPartialMock(\Magento\Backend\Model\Auth\Session::class, ['getUser', 'isAllowed']); $mockSession->expects($this->any())->method('getUser')->will($this->returnValue($user)); $this->_model->setSession($mockSession); - $itemMock = $this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false); + $itemMock = $this->createMock(\Magento\Backend\Model\Menu\Item::class); $itemMock->expects($this->once())->method('getAction')->will($this->returnValue('adminhtml/user')); $this->_menuMock->expects($this->any())->method('getFirstAvailable')->will($this->returnValue($itemMock)); @@ -239,7 +212,7 @@ public function testGetStartupPageUrl() public function testGetAreaFrontName() { - $helperMock = $this->getMock(\Magento\Backend\Helper\Data::class, [], [], '', false); + $helperMock = $this->createMock(\Magento\Backend\Helper\Data::class); $helperMock->expects( $this->once() )->method( diff --git a/app/code/Magento/Backend/Test/Unit/Model/View/Layout/StructureManagerTest.php b/app/code/Magento/Backend/Test/Unit/Model/View/Layout/StructureManagerTest.php index 52ae4177b5bfd..fecb6434da83a 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/View/Layout/StructureManagerTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/View/Layout/StructureManagerTest.php @@ -14,7 +14,7 @@ /** * Class StructureManagerTest */ -class StructureManagerTest extends \PHPUnit_Framework_TestCase +class StructureManagerTest extends \PHPUnit\Framework\TestCase { /** * @var Structure|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Backend/Test/Unit/Model/View/Result/PageTest.php b/app/code/Magento/Backend/Test/Unit/Model/View/Result/PageTest.php index 3f46d486e1ec6..987adbd0a027b 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/View/Result/PageTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/View/Result/PageTest.php @@ -7,7 +7,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -class PageTest extends \PHPUnit_Framework_TestCase +class PageTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\Model\View\Result\Page diff --git a/app/code/Magento/Backend/Test/Unit/Model/View/Result/RedirectTest.php b/app/code/Magento/Backend/Test/Unit/Model/View/Result/RedirectTest.php index 71a656108dfe0..0165ef52a56fd 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/View/Result/RedirectTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/View/Result/RedirectTest.php @@ -7,7 +7,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -class RedirectTest extends \PHPUnit_Framework_TestCase +class RedirectTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Backend\Model\View\Result\Redirect */ protected $action; @@ -31,16 +31,10 @@ class RedirectTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->session = $this->getMock(\Magento\Backend\Model\Session::class, [], [], '', false); - $this->actionFlag = $this->getMock(\Magento\Framework\App\ActionFlag::class, [], [], '', false); - $this->urlBuilder = $this->getMock(\Magento\Backend\Model\UrlInterface::class, [], [], '', false); - $this->redirect = $this->getMock( - \Magento\Framework\App\Response\RedirectInterface::class, - [], - [], - '', - false - ); + $this->session = $this->createMock(\Magento\Backend\Model\Session::class); + $this->actionFlag = $this->createMock(\Magento\Framework\App\ActionFlag::class); + $this->urlBuilder = $this->createMock(\Magento\Backend\Model\UrlInterface::class); + $this->redirect = $this->createMock(\Magento\Framework\App\Response\RedirectInterface::class); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->action = $this->objectManagerHelper->getObject( \Magento\Backend\Model\View\Result\Redirect::class, diff --git a/app/code/Magento/Backend/Test/Unit/Model/Widget/Grid/AbstractTotalsTest.php b/app/code/Magento/Backend/Test/Unit/Model/Widget/Grid/AbstractTotalsTest.php index 8c9a75883cedb..8e937cb18be58 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Widget/Grid/AbstractTotalsTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Widget/Grid/AbstractTotalsTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Backend\Test\Unit\Model\Widget\Grid; -class AbstractTotalsTest extends \PHPUnit_Framework_TestCase +class AbstractTotalsTest extends \PHPUnit\Framework\TestCase { /** * @var $_model \PHPUnit_Framework_MockObject_MockObject @@ -64,7 +64,7 @@ protected function tearDown() protected function _getTestCollection() { $collection = new \Magento\Framework\Data\Collection( - $this->getMock(\Magento\Framework\Data\Collection\EntityFactory::class, [], [], '', false) + $this->createMock(\Magento\Framework\Data\Collection\EntityFactory::class) ); $items = [new \Magento\Framework\DataObject(['test1' => '1', 'test2' => '2'])]; foreach ($items as $item) { @@ -99,7 +99,7 @@ protected function _setUpColumns() */ protected function _prepareParserMock() { - $this->_parserMock = $this->getMock( + $this->_parserMock = $this->createPartialMock( \Magento\Backend\Model\Widget\Grid\Parser::class, ['parseExpression', 'isOperation'] ); @@ -142,15 +142,7 @@ protected function _prepareParserMock() */ protected function _prepareFactoryMock() { - $this->_factoryMock = $this->getMock( - \Magento\Framework\DataObject\Factory::class, - ['create'], - [], - '', - false, - false, - false - ); + $this->_factoryMock = $this->createPartialMock(\Magento\Framework\DataObject\Factory::class, ['create']); $createValueMap = [ [ diff --git a/app/code/Magento/Backend/Test/Unit/Model/Widget/Grid/ParserTest.php b/app/code/Magento/Backend/Test/Unit/Model/Widget/Grid/ParserTest.php index a7617c2314707..569c5ffc16c9c 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Widget/Grid/ParserTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Widget/Grid/ParserTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Backend\Test\Unit\Model\Widget\Grid; -class ParserTest extends \PHPUnit_Framework_TestCase +class ParserTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\Model\Widget\Grid\Parser diff --git a/app/code/Magento/Backend/Test/Unit/Model/Widget/Grid/Row/UrlGeneratorTest.php b/app/code/Magento/Backend/Test/Unit/Model/Widget/Grid/Row/UrlGeneratorTest.php index 3e1b8e4badb0a..b7fe4c9c25f9d 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Widget/Grid/Row/UrlGeneratorTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Widget/Grid/Row/UrlGeneratorTest.php @@ -5,23 +5,17 @@ */ namespace Magento\Backend\Test\Unit\Model\Widget\Grid\Row; -class UrlGeneratorTest extends \PHPUnit_Framework_TestCase +class UrlGeneratorTest extends \PHPUnit\Framework\TestCase { public function testGetUrl() { $itemId = 3; $urlPath = 'mng/item/edit'; - $itemMock = $this->getMock(\Magento\Framework\DataObject::class, ['getItemId'], [], '', false); + $itemMock = $this->createPartialMock(\Magento\Framework\DataObject::class, ['getItemId']); $itemMock->expects($this->once())->method('getItemId')->will($this->returnValue($itemId)); - $urlModelMock = $this->getMock( - \Magento\Backend\Model\Url::class, - [], - [], - '', - false - ); + $urlModelMock = $this->createMock(\Magento\Backend\Model\Url::class); $urlModelMock->expects( $this->once() )->method( diff --git a/app/code/Magento/Backend/Test/Unit/Model/Widget/Grid/SubTotalsTest.php b/app/code/Magento/Backend/Test/Unit/Model/Widget/Grid/SubTotalsTest.php index 2c5f8f72a4139..767ed35f4dbd9 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Widget/Grid/SubTotalsTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Widget/Grid/SubTotalsTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Backend\Test\Unit\Model\Widget\Grid; -class SubTotalsTest extends \PHPUnit_Framework_TestCase +class SubTotalsTest extends \PHPUnit\Framework\TestCase { /** * @var $_model \Magento\Backend\Model\Widget\Grid\SubTotals @@ -24,25 +24,9 @@ class SubTotalsTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_parserMock = $this->getMock( - \Magento\Backend\Model\Widget\Grid\Parser::class, - [], - [], - '', - false, - false, - false - ); + $this->_parserMock = $this->createMock(\Magento\Backend\Model\Widget\Grid\Parser::class); - $this->_factoryMock = $this->getMock( - \Magento\Framework\DataObject\Factory::class, - ['create'], - [], - '', - false, - false, - false - ); + $this->_factoryMock = $this->createPartialMock(\Magento\Framework\DataObject\Factory::class, ['create']); $this->_factoryMock->expects( $this->any() )->method( @@ -88,7 +72,7 @@ public function testCountTotals() protected function _getTestCollection() { $collection = new \Magento\Framework\Data\Collection( - $this->getMock(\Magento\Framework\Data\Collection\EntityFactory::class, [], [], '', false) + $this->createMock(\Magento\Framework\Data\Collection\EntityFactory::class) ); $items = [ new \Magento\Framework\DataObject(['sub_test1' => '1', 'sub_test2' => '2']), diff --git a/app/code/Magento/Backend/Test/Unit/Model/Widget/Grid/TotalsTest.php b/app/code/Magento/Backend/Test/Unit/Model/Widget/Grid/TotalsTest.php index f479486995b05..862853dc30478 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Widget/Grid/TotalsTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Widget/Grid/TotalsTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Backend\Test\Unit\Model\Widget\Grid; -class TotalsTest extends \PHPUnit_Framework_TestCase +class TotalsTest extends \PHPUnit\Framework\TestCase { /** * @var $_model \Magento\Backend\Model\Widget\Grid\Totals @@ -25,25 +25,12 @@ class TotalsTest extends \PHPUnit_Framework_TestCase protected function setUp() { // prepare model - $this->_parserMock = $this->getMock( + $this->_parserMock = $this->createPartialMock( \Magento\Backend\Model\Widget\Grid\Parser::class, - ['parseExpression'], - [], - '', - false, - false, - false + ['parseExpression'] ); - $this->_factoryMock = $this->getMock( - \Magento\Framework\DataObject\Factory::class, - ['create'], - [], - '', - false, - false, - false - ); + $this->_factoryMock = $this->createPartialMock(\Magento\Framework\DataObject\Factory::class, ['create']); $createValueMap = [ [['test1' => 3, 'test2' => 2], new \Magento\Framework\DataObject(['test1' => 3, 'test2' => 2])], @@ -73,7 +60,7 @@ public function testCountTotals() { // prepare collection $collection = new \Magento\Framework\Data\Collection( - $this->getMock(\Magento\Framework\Data\Collection\EntityFactory::class, [], [], '', false) + $this->createMock(\Magento\Framework\Data\Collection\EntityFactory::class) ); $items = [ new \Magento\Framework\DataObject(['test1' => '1', 'test2' => '2']), @@ -96,7 +83,7 @@ public function testCountTotalsWithSubItems() // prepare collection $collection = new \Magento\Framework\Data\Collection( - $this->getMock(\Magento\Framework\Data\Collection\EntityFactory::class, [], [], '', false) + $this->createMock(\Magento\Framework\Data\Collection\EntityFactory::class) ); $items = [ new \Magento\Framework\DataObject( @@ -118,7 +105,7 @@ public function testCountTotalsWithSubItems() foreach ($items as $item) { // prepare sub-collection $subCollection = new \Magento\Framework\Data\Collection( - $this->getMock(\Magento\Framework\Data\Collection\EntityFactory::class, [], [], '', false) + $this->createMock(\Magento\Framework\Data\Collection\EntityFactory::class) ); $subCollection->addItem(new \Magento\Framework\DataObject(['test4' => '1', 'test5' => '2'])); $subCollection->addItem(new \Magento\Framework\DataObject(['test4' => '2', 'test5' => '2'])); diff --git a/app/code/Magento/Backend/Test/Unit/Setup/ConfigOptionsListTest.php b/app/code/Magento/Backend/Test/Unit/Setup/ConfigOptionsListTest.php index e7d72a32510fa..b1c8ddabcbd1c 100644 --- a/app/code/Magento/Backend/Test/Unit/Setup/ConfigOptionsListTest.php +++ b/app/code/Magento/Backend/Test/Unit/Setup/ConfigOptionsListTest.php @@ -8,7 +8,7 @@ use Magento\Backend\Setup\ConfigOptionsList; use Magento\Framework\Config\File\ConfigFilePool; -class ConfigOptionsListTest extends \PHPUnit_Framework_TestCase +class ConfigOptionsListTest extends \PHPUnit\Framework\TestCase { /** * @var ConfigOptionsList @@ -23,7 +23,7 @@ class ConfigOptionsListTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->object = new ConfigOptionsList(); - $this->deploymentConfig = $this->getMock(\Magento\Framework\App\DeploymentConfig::class, [], [], '', false); + $this->deploymentConfig = $this->createMock(\Magento\Framework\App\DeploymentConfig::class); } public function testGetOptions() diff --git a/app/code/Magento/Backend/etc/acl.xml b/app/code/Magento/Backend/etc/acl.xml index 433b3df6ccac4..af4ab5856e94c 100644 --- a/app/code/Magento/Backend/etc/acl.xml +++ b/app/code/Magento/Backend/etc/acl.xml @@ -22,6 +22,7 @@ + diff --git a/app/code/Magento/Backend/view/adminhtml/templates/widget/grid.phtml b/app/code/Magento/Backend/view/adminhtml/templates/widget/grid.phtml index 3c44f629cd8af..c99759a60d1bf 100644 --- a/app/code/Magento/Backend/view/adminhtml/templates/widget/grid.phtml +++ b/app/code/Magento/Backend/view/adminhtml/templates/widget/grid.phtml @@ -149,7 +149,8 @@ $numColumns = sizeof($block->getColumns()); getRowClickCallback(), 'order.') !== false): ?> - deps.push('Magento_Sales/order/create/form') + deps.push('Magento_Sales/order/create/form'); + deps.push('jquery'); deps.push('mage/adminhtml/grid'); diff --git a/app/code/Magento/Backup/Block/Adminhtml/Backup.php b/app/code/Magento/Backup/Block/Adminhtml/Backup.php index 459ef27bf6a15..2a41008055773 100644 --- a/app/code/Magento/Backup/Block/Adminhtml/Backup.php +++ b/app/code/Magento/Backup/Block/Adminhtml/Backup.php @@ -12,6 +12,7 @@ * * @api * @author Magento Core Team + * @since 100.0.2 */ class Backup extends \Magento\Backend\Block\Template { diff --git a/app/code/Magento/Backup/Block/Adminhtml/Grid/Column/Rollback.php b/app/code/Magento/Backup/Block/Adminhtml/Grid/Column/Rollback.php index bf7fe670039fa..b584794b0efee 100644 --- a/app/code/Magento/Backup/Block/Adminhtml/Grid/Column/Rollback.php +++ b/app/code/Magento/Backup/Block/Adminhtml/Grid/Column/Rollback.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class Rollback extends \Magento\Backend\Block\Widget\Grid\Column { diff --git a/app/code/Magento/Backup/Controller/Adminhtml/Index.php b/app/code/Magento/Backup/Controller/Adminhtml/Index.php index 3dda624564601..dcafbc7370d2d 100644 --- a/app/code/Magento/Backup/Controller/Adminhtml/Index.php +++ b/app/code/Magento/Backup/Controller/Adminhtml/Index.php @@ -10,6 +10,7 @@ * * @author Magento Core Team * @api + * @since 100.0.2 */ abstract class Index extends \Magento\Backend\App\Action { diff --git a/app/code/Magento/Backup/Helper/Data.php b/app/code/Magento/Backup/Helper/Data.php index ed032c13f8753..3d60bf9d9c9cf 100644 --- a/app/code/Magento/Backup/Helper/Data.php +++ b/app/code/Magento/Backup/Helper/Data.php @@ -12,6 +12,7 @@ /** * Backup data helper * @api + * @since 100.0.2 */ class Data extends \Magento\Framework\App\Helper\AbstractHelper { diff --git a/app/code/Magento/Backup/Model/Backup.php b/app/code/Magento/Backup/Model/Backup.php index 62ff1b1ccf2a3..3768f2bf8c8ce 100644 --- a/app/code/Magento/Backup/Model/Backup.php +++ b/app/code/Magento/Backup/Model/Backup.php @@ -16,6 +16,7 @@ * @method string getTime() * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @api + * @since 100.0.2 */ class Backup extends \Magento\Framework\DataObject implements \Magento\Framework\Backup\Db\BackupInterface { diff --git a/app/code/Magento/Backup/Model/BackupFactory.php b/app/code/Magento/Backup/Model/BackupFactory.php index c64f7ff02952e..c4e2be9758f72 100644 --- a/app/code/Magento/Backup/Model/BackupFactory.php +++ b/app/code/Magento/Backup/Model/BackupFactory.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class BackupFactory { diff --git a/app/code/Magento/Backup/Model/Config/Backend/Cron.php b/app/code/Magento/Backup/Model/Config/Backend/Cron.php index 18a28a8306fd9..4855ef1129502 100644 --- a/app/code/Magento/Backup/Model/Config/Backend/Cron.php +++ b/app/code/Magento/Backup/Model/Config/Backend/Cron.php @@ -8,6 +8,7 @@ /** * Backup by cron backend model * @api + * @since 100.0.2 */ class Cron extends \Magento\Framework\App\Config\Value { @@ -21,10 +22,14 @@ class Cron extends \Magento\Framework\App\Config\Value const XML_PATH_BACKUP_FREQUENCY = 'groups/backup/fields/frequency/value'; - /** @var \Magento\Framework\App\Config\ValueFactory */ + /** + * @var \Magento\Framework\App\Config\ValueFactory + */ protected $_configValueFactory; - /** @var string */ + /** + * @var string + */ protected $_runModelPath = ''; /** diff --git a/app/code/Magento/Backup/Model/Config/Source/Type.php b/app/code/Magento/Backup/Model/Config/Source/Type.php index efa6199c43581..d8a7f139a1710 100644 --- a/app/code/Magento/Backup/Model/Config/Source/Type.php +++ b/app/code/Magento/Backup/Model/Config/Source/Type.php @@ -10,6 +10,7 @@ * * @author Magento Core Team * @api + * @since 100.0.2 */ class Type implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Backup/Model/Db.php b/app/code/Magento/Backup/Model/Db.php index 4d542d9f222a5..776141249f92b 100644 --- a/app/code/Magento/Backup/Model/Db.php +++ b/app/code/Magento/Backup/Model/Db.php @@ -9,6 +9,7 @@ * Database backup model * * @api + * @since 100.0.2 */ class Db implements \Magento\Framework\Backup\Db\BackupDbInterface { diff --git a/app/code/Magento/Backup/Model/Fs/Collection.php b/app/code/Magento/Backup/Model/Fs/Collection.php index 0e5ba18c263e9..2d08ac04528ac 100644 --- a/app/code/Magento/Backup/Model/Fs/Collection.php +++ b/app/code/Magento/Backup/Model/Fs/Collection.php @@ -10,6 +10,7 @@ /** * Backup data collection * @api + * @since 100.0.2 */ class Collection extends \Magento\Framework\Data\Collection\Filesystem { diff --git a/app/code/Magento/Backup/Model/Grid/Options.php b/app/code/Magento/Backup/Model/Grid/Options.php index ba4cd66973a8a..762b8ddc3e518 100644 --- a/app/code/Magento/Backup/Model/Grid/Options.php +++ b/app/code/Magento/Backup/Model/Grid/Options.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class Options implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Backup/Model/ResourceModel/Db.php b/app/code/Magento/Backup/Model/ResourceModel/Db.php index 6198603c92508..3fbaf44ebb063 100644 --- a/app/code/Magento/Backup/Model/ResourceModel/Db.php +++ b/app/code/Magento/Backup/Model/ResourceModel/Db.php @@ -8,6 +8,7 @@ /** * Database backup resource model * @api + * @since 100.0.2 */ class Db { diff --git a/app/code/Magento/Backup/Model/ResourceModel/Helper.php b/app/code/Magento/Backup/Model/ResourceModel/Helper.php index 4078250c5afdd..b5418865339c3 100644 --- a/app/code/Magento/Backup/Model/ResourceModel/Helper.php +++ b/app/code/Magento/Backup/Model/ResourceModel/Helper.php @@ -8,6 +8,7 @@ /** * @api + * @since 100.0.2 */ class Helper extends \Magento\Framework\DB\Helper { diff --git a/app/code/Magento/Backup/Test/Unit/Controller/Adminhtml/Index/DownloadTest.php b/app/code/Magento/Backup/Test/Unit/Controller/Adminhtml/Index/DownloadTest.php index 7a36db627da73..8715d0046c1f2 100644 --- a/app/code/Magento/Backup/Test/Unit/Controller/Adminhtml/Index/DownloadTest.php +++ b/app/code/Magento/Backup/Test/Unit/Controller/Adminhtml/Index/DownloadTest.php @@ -12,7 +12,7 @@ * @covers \Magento\Backup\Controller\Adminhtml\Index\Download * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class DownloadTest extends \PHPUnit_Framework_TestCase +class DownloadTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager diff --git a/app/code/Magento/Backup/Test/Unit/Controller/Adminhtml/Index/RollbackTest.php b/app/code/Magento/Backup/Test/Unit/Controller/Adminhtml/Index/RollbackTest.php index 8d827a3f0da4d..726b1cc1e936c 100644 --- a/app/code/Magento/Backup/Test/Unit/Controller/Adminhtml/Index/RollbackTest.php +++ b/app/code/Magento/Backup/Test/Unit/Controller/Adminhtml/Index/RollbackTest.php @@ -11,7 +11,7 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.TooManyFields) */ -class RollbackTest extends \PHPUnit_Framework_TestCase +class RollbackTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager diff --git a/app/code/Magento/Backup/Test/Unit/Cron/SystemBackupTest.php b/app/code/Magento/Backup/Test/Unit/Cron/SystemBackupTest.php index a72db8f4cd81c..b7dfb30c0a1b3 100644 --- a/app/code/Magento/Backup/Test/Unit/Cron/SystemBackupTest.php +++ b/app/code/Magento/Backup/Test/Unit/Cron/SystemBackupTest.php @@ -7,7 +7,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class SystemBackupTest extends \PHPUnit_Framework_TestCase +class SystemBackupTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager diff --git a/app/code/Magento/Backup/Test/Unit/Helper/DataTest.php b/app/code/Magento/Backup/Test/Unit/Helper/DataTest.php index 356e954a02d6e..680788b73817f 100644 --- a/app/code/Magento/Backup/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Backup/Test/Unit/Helper/DataTest.php @@ -9,7 +9,7 @@ use Magento\Framework\App\MaintenanceMode; use Magento\Framework\Filesystem; -class DataTest extends \PHPUnit_Framework_TestCase +class DataTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backup\Helper\Data diff --git a/app/code/Magento/Backup/Test/Unit/Model/BackupFactoryTest.php b/app/code/Magento/Backup/Test/Unit/Model/BackupFactoryTest.php index 4ef3c01f996a6..dca65db48650f 100644 --- a/app/code/Magento/Backup/Test/Unit/Model/BackupFactoryTest.php +++ b/app/code/Magento/Backup/Test/Unit/Model/BackupFactoryTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Backup\Test\Unit\Model; -class BackupFactoryTest extends \PHPUnit_Framework_TestCase +class BackupFactoryTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backup\Model\BackupFactory @@ -41,7 +41,7 @@ protected function setUp() 'name' => '', 'type' => 'snapshot', ]; - $this->_fsCollection = $this->getMock(\Magento\Backup\Model\Fs\Collection::class, [], [], '', false); + $this->_fsCollection = $this->createMock(\Magento\Backup\Model\Fs\Collection::class); $this->_fsCollection->expects( $this->at(0) )->method( @@ -50,9 +50,9 @@ protected function setUp() $this->returnValue(new \ArrayIterator([new \Magento\Framework\DataObject($this->_data)])) ); - $this->_backupModel = $this->getMock(\Magento\Backup\Model\Backup::class, [], [], '', false); + $this->_backupModel = $this->createMock(\Magento\Backup\Model\Backup::class); - $this->_objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->_objectManager = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); $this->_objectManager->expects( $this->at(0) )->method( diff --git a/app/code/Magento/Backup/Test/Unit/Model/BackupTest.php b/app/code/Magento/Backup/Test/Unit/Model/BackupTest.php index 26b9822d720a9..c43456ce76de5 100644 --- a/app/code/Magento/Backup/Test/Unit/Model/BackupTest.php +++ b/app/code/Magento/Backup/Test/Unit/Model/BackupTest.php @@ -11,7 +11,7 @@ /** * @covers \Magento\Backup\Model\Backup */ -class BackupTest extends \PHPUnit_Framework_TestCase +class BackupTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager diff --git a/app/code/Magento/Backup/Test/Unit/Model/Fs/CollectionTest.php b/app/code/Magento/Backup/Test/Unit/Model/Fs/CollectionTest.php index eabf5b7328864..4a21e3256dfb7 100644 --- a/app/code/Magento/Backup/Test/Unit/Model/Fs/CollectionTest.php +++ b/app/code/Magento/Backup/Test/Unit/Model/Fs/CollectionTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Backup\Test\Unit\Model\Fs; -class CollectionTest extends \PHPUnit_Framework_TestCase +class CollectionTest extends \PHPUnit\Framework\TestCase { public function testConstructor() { @@ -26,9 +26,10 @@ public function testConstructor() $directoryWrite->expects($this->any())->method('create')->with('backups'); $directoryWrite->expects($this->any())->method('getAbsolutePath')->with('backups'); - $helper->getObject( + $classObject = $helper->getObject( \Magento\Backup\Model\Fs\Collection::class, ['filesystem' => $filesystem, 'backupData' => $backupData] ); + $this->assertNotNull($classObject); } } diff --git a/app/code/Magento/Braintree/Block/Customer/CardRenderer.php b/app/code/Magento/Braintree/Block/Customer/CardRenderer.php index d26c75ca30d0b..55ba049f72297 100644 --- a/app/code/Magento/Braintree/Block/Customer/CardRenderer.php +++ b/app/code/Magento/Braintree/Block/Customer/CardRenderer.php @@ -12,6 +12,7 @@ /** * @api + * @since 100.1.0 */ class CardRenderer extends AbstractCardRenderer { @@ -20,6 +21,7 @@ class CardRenderer extends AbstractCardRenderer * * @param PaymentTokenInterface $token * @return boolean + * @since 100.1.0 */ public function canRender(PaymentTokenInterface $token) { @@ -28,6 +30,7 @@ public function canRender(PaymentTokenInterface $token) /** * @return string + * @since 100.1.0 */ public function getNumberLast4Digits() { @@ -36,6 +39,7 @@ public function getNumberLast4Digits() /** * @return string + * @since 100.1.0 */ public function getExpDate() { @@ -44,6 +48,7 @@ public function getExpDate() /** * @return string + * @since 100.1.0 */ public function getIconUrl() { @@ -52,6 +57,7 @@ public function getIconUrl() /** * @return int + * @since 100.1.0 */ public function getIconHeight() { @@ -60,6 +66,7 @@ public function getIconHeight() /** * @return int + * @since 100.1.0 */ public function getIconWidth() { diff --git a/app/code/Magento/Braintree/Block/Customer/PayPal/VaultTokenRenderer.php b/app/code/Magento/Braintree/Block/Customer/PayPal/VaultTokenRenderer.php index ae4e58b2556e8..1405349e2d45f 100644 --- a/app/code/Magento/Braintree/Block/Customer/PayPal/VaultTokenRenderer.php +++ b/app/code/Magento/Braintree/Block/Customer/PayPal/VaultTokenRenderer.php @@ -15,6 +15,7 @@ * Class VaultTokenRenderer * * @api + * @since 100.1.3 */ class VaultTokenRenderer extends AbstractTokenRenderer { @@ -41,6 +42,7 @@ public function __construct( /** * @inheritdoc + * @since 100.1.3 */ public function getIconUrl() { @@ -49,6 +51,7 @@ public function getIconUrl() /** * @inheritdoc + * @since 100.1.3 */ public function getIconHeight() { @@ -57,6 +60,7 @@ public function getIconHeight() /** * @inheritdoc + * @since 100.1.3 */ public function getIconWidth() { @@ -68,6 +72,7 @@ public function getIconWidth() * * @param PaymentTokenInterface $token * @return boolean + * @since 100.1.3 */ public function canRender(PaymentTokenInterface $token) { @@ -77,6 +82,7 @@ public function canRender(PaymentTokenInterface $token) /** * Get email of PayPal payer * @return string + * @since 100.1.3 */ public function getPayerEmail() { diff --git a/app/code/Magento/Braintree/Block/Form.php b/app/code/Magento/Braintree/Block/Form.php index b197a3bffdf6e..f6cf62f5a2131 100644 --- a/app/code/Magento/Braintree/Block/Form.php +++ b/app/code/Magento/Braintree/Block/Form.php @@ -137,7 +137,7 @@ private function getVaultPayment() /** * Get payment data helper instance * @return Data - * @deprecated + * @deprecated 100.1.0 */ private function getPaymentDataHelper() { diff --git a/app/code/Magento/Braintree/Block/Payment.php b/app/code/Magento/Braintree/Block/Payment.php index c6638fc3ebdf3..8e05856d9b57a 100644 --- a/app/code/Magento/Braintree/Block/Payment.php +++ b/app/code/Magento/Braintree/Block/Payment.php @@ -14,6 +14,7 @@ * Class Payment * * @api + * @since 100.1.0 */ class Payment extends Template { @@ -40,6 +41,7 @@ public function __construct( /** * @return string + * @since 100.1.0 */ public function getPaymentConfig() { @@ -51,6 +53,7 @@ public function getPaymentConfig() /** * @return string + * @since 100.1.0 */ public function getCode() { diff --git a/app/code/Magento/Braintree/Block/Paypal/Checkout/Review.php b/app/code/Magento/Braintree/Block/Paypal/Checkout/Review.php index 0853bb96b9801..77625035a56ae 100644 --- a/app/code/Magento/Braintree/Block/Paypal/Checkout/Review.php +++ b/app/code/Magento/Braintree/Block/Paypal/Checkout/Review.php @@ -11,6 +11,7 @@ * Class Review * * @api + * @since 100.1.0 */ class Review extends Express\Review { @@ -18,6 +19,7 @@ class Review extends Express\Review * Controller path * * @var string + * @since 100.1.0 */ protected $_controllerPath = 'braintree/paypal'; @@ -26,6 +28,7 @@ class Review extends Express\Review * * @return null * @codeCoverageIgnore + * @since 100.1.0 */ public function getEditUrl() { diff --git a/app/code/Magento/Braintree/Model/Report/ConditionAppliers/AppliersPool.php b/app/code/Magento/Braintree/Model/Report/ConditionAppliers/AppliersPool.php index d8515394c6120..3f8af0c6c7cb5 100644 --- a/app/code/Magento/Braintree/Model/Report/ConditionAppliers/AppliersPool.php +++ b/app/code/Magento/Braintree/Model/Report/ConditionAppliers/AppliersPool.php @@ -10,7 +10,9 @@ */ class AppliersPool { - /** @var ApplierInterface[] */ + /** + * @var \Magento\Braintree\Model\Report\ConditionAppliers\ApplierInterface[] + */ private $appliersPool = []; /** diff --git a/app/code/Magento/Braintree/Model/Report/FilterMapper.php b/app/code/Magento/Braintree/Model/Report/FilterMapper.php index dcfa721bc6c0a..c9b17ae584231 100644 --- a/app/code/Magento/Braintree/Model/Report/FilterMapper.php +++ b/app/code/Magento/Braintree/Model/Report/FilterMapper.php @@ -18,12 +18,18 @@ class FilterMapper */ private $searchFieldsToFiltersMap = []; - /** @var AppliersPool */ + /** + * @var \Magento\Braintree\Model\Report\ConditionAppliers\AppliersPool + */ private $appliersPool; - /** @var BraintreeSearchAdapter */ + /** + * @var \Magento\Braintree\Model\Adapter\BraintreeSearchAdapter + */ private $braintreeSearchAdapter; + /** + */ public function __construct( AppliersPool $appliersPool, BraintreeSearchAdapter $braintreeSearchAdapter diff --git a/app/code/Magento/Braintree/Test/Unit/Block/FormTest.php b/app/code/Magento/Braintree/Test/Unit/Block/FormTest.php index ef5f6a0d9141e..5b28e6d8aedcd 100644 --- a/app/code/Magento/Braintree/Test/Unit/Block/FormTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Block/FormTest.php @@ -21,7 +21,7 @@ /** * Class FormTest */ -class FormTest extends \PHPUnit_Framework_TestCase +class FormTest extends \PHPUnit\Framework\TestCase { public static $baseCardTypes = [ 'AE' => 'American Express', diff --git a/app/code/Magento/Braintree/Test/Unit/Controller/Payment/GetNonceTest.php b/app/code/Magento/Braintree/Test/Unit/Controller/Payment/GetNonceTest.php index 31812a2f79fd5..e78e54f011d44 100644 --- a/app/code/Magento/Braintree/Test/Unit/Controller/Payment/GetNonceTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Controller/Payment/GetNonceTest.php @@ -22,7 +22,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class GetNonceTest extends \PHPUnit_Framework_TestCase +class GetNonceTest extends \PHPUnit\Framework\TestCase { /** * @var GetNonce @@ -87,7 +87,7 @@ protected function setUp() ->setMethods(['getCustomerId']) ->getMock(); - $this->logger = $this->getMock(LoggerInterface::class); + $this->logger = $this->createMock(LoggerInterface::class); $context = $this->getMockBuilder(Context::class) ->disableOriginalConstructor() diff --git a/app/code/Magento/Braintree/Test/Unit/Controller/Paypal/PlaceOrderTest.php b/app/code/Magento/Braintree/Test/Unit/Controller/Paypal/PlaceOrderTest.php index c4f76061850f8..5a10b4abb3fbc 100644 --- a/app/code/Magento/Braintree/Test/Unit/Controller/Paypal/PlaceOrderTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Controller/Paypal/PlaceOrderTest.php @@ -23,7 +23,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class PlaceOrderTest extends \PHPUnit_Framework_TestCase +class PlaceOrderTest extends \PHPUnit\Framework\TestCase { /** * @var OrderPlace|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Braintree/Test/Unit/Controller/Paypal/ReviewTest.php b/app/code/Magento/Braintree/Test/Unit/Controller/Paypal/ReviewTest.php index bc308fa864d2f..cb911a8396b36 100644 --- a/app/code/Magento/Braintree/Test/Unit/Controller/Paypal/ReviewTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Controller/Paypal/ReviewTest.php @@ -27,7 +27,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ReviewTest extends \PHPUnit_Framework_TestCase +class ReviewTest extends \PHPUnit\Framework\TestCase { /** * @var QuoteUpdater|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Braintree/Test/Unit/Controller/Paypal/SaveShippingMethodTest.php b/app/code/Magento/Braintree/Test/Unit/Controller/Paypal/SaveShippingMethodTest.php index dcc3c6cd7d2fd..5be5df0e33c49 100644 --- a/app/code/Magento/Braintree/Test/Unit/Controller/Paypal/SaveShippingMethodTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Controller/Paypal/SaveShippingMethodTest.php @@ -28,7 +28,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class SaveShippingMethodTest extends \PHPUnit_Framework_TestCase +class SaveShippingMethodTest extends \PHPUnit\Framework\TestCase { /** * @var ShippingMethodUpdater|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Command/CaptureStrategyCommandTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Command/CaptureStrategyCommandTest.php index 3a79d817e285d..56ea1f97fa165 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Command/CaptureStrategyCommandTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Command/CaptureStrategyCommandTest.php @@ -29,7 +29,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class CaptureStrategyCommandTest extends \PHPUnit_Framework_TestCase +class CaptureStrategyCommandTest extends \PHPUnit\Framework\TestCase { /** * @var CaptureStrategyCommand diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Command/GetPaymentNonceCommandTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Command/GetPaymentNonceCommandTest.php index 1acd8906e579b..333f29eb29136 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Command/GetPaymentNonceCommandTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Command/GetPaymentNonceCommandTest.php @@ -21,7 +21,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class GetPaymentNonceCommandTest extends \PHPUnit_Framework_TestCase +class GetPaymentNonceCommandTest extends \PHPUnit\Framework\TestCase { /** * @var GetPaymentNonceCommand diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Config/CanVoidHandlerTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Config/CanVoidHandlerTest.php index 5b7330537fdfb..793700ab1971f 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Config/CanVoidHandlerTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Config/CanVoidHandlerTest.php @@ -11,11 +11,11 @@ use Magento\Payment\Model\InfoInterface; use Magento\Sales\Model\Order\Payment; -class CanVoidHandlerTest extends \PHPUnit_Framework_TestCase +class CanVoidHandlerTest extends \PHPUnit\Framework\TestCase { public function testHandleNotOrderPayment() { - $paymentDO = $this->getMock(PaymentDataObjectInterface::class); + $paymentDO = $this->createMock(PaymentDataObjectInterface::class); $subject = [ 'payment' => $paymentDO ]; @@ -28,7 +28,7 @@ public function testHandleNotOrderPayment() ->method('readPayment') ->willReturn($paymentDO); - $paymentMock = $this->getMock(InfoInterface::class); + $paymentMock = $this->createMock(InfoInterface::class); $paymentDO->expects(static::once()) ->method('getPayment') @@ -41,7 +41,7 @@ public function testHandleNotOrderPayment() public function testHandleSomeAmoutWasPaid() { - $paymentDO = $this->getMock(PaymentDataObjectInterface::class); + $paymentDO = $this->createMock(PaymentDataObjectInterface::class); $subject = [ 'payment' => $paymentDO ]; diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Config/ConfigTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Config/ConfigTest.php index 46a1c6304e1de..7b9d59a5bc482 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Config/ConfigTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Config/ConfigTest.php @@ -9,13 +9,13 @@ use Magento\Braintree\Gateway\Config\Config; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\Serialize\Serializer\Json; -use Magento\Store\Model\ScopeInterface; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Store\Model\ScopeInterface; /** * Class ConfigTest */ -class ConfigTest extends \PHPUnit_Framework_TestCase +class ConfigTest extends \PHPUnit\Framework\TestCase { const METHOD_CODE = 'braintree'; @@ -36,8 +36,8 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->scopeConfigMock = $this->getMock(ScopeConfigInterface::class); - $this->serializerMock = $this->getMock(Json::class); + $this->scopeConfigMock = $this->createMock(ScopeConfigInterface::class); + $this->serializerMock = $this->createMock(Json::class); $objectManager = new ObjectManager($this); $this->model = $objectManager->getObject( @@ -190,6 +190,10 @@ public function testCountryAvailableCardTypes($encodedData, $data, array $countr $result = $this->model->getCountryAvailableCardTypes($countryId); static::assertEquals($types, $result); } + + if (empty($countryData)) { + static::assertEquals($data, ""); + } } /** diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Helper/SubjectReaderTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Helper/SubjectReaderTest.php index 3f8f273e1c5c0..b2207563b8b0f 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Helper/SubjectReaderTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Helper/SubjectReaderTest.php @@ -12,7 +12,7 @@ /** * Class SubjectReaderTest */ -class SubjectReaderTest extends \PHPUnit_Framework_TestCase +class SubjectReaderTest extends \PHPUnit\Framework\TestCase { /** * @var SubjectReader diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Http/Client/TransactionSaleTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Http/Client/TransactionSaleTest.php index 12a809da21476..5cbcfef8b6b9e 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Http/Client/TransactionSaleTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Http/Client/TransactionSaleTest.php @@ -14,7 +14,7 @@ /** * Class TransactionSaleTest */ -class TransactionSaleTest extends \PHPUnit_Framework_TestCase +class TransactionSaleTest extends \PHPUnit\Framework\TestCase { /** * @var TransactionSale @@ -114,7 +114,7 @@ public function testPlaceRequestSuccess() */ private function getTransferObjectMock() { - $transferObjectMock = $this->getMock(TransferInterface::class); + $transferObjectMock = $this->createMock(TransferInterface::class); $transferObjectMock->expects($this->once()) ->method('getBody') ->willReturn($this->getTransferData()); diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Http/Client/TransactionSubmitForSettlementTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Http/Client/TransactionSubmitForSettlementTest.php index 88af05f9fc434..86113c34ba218 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Http/Client/TransactionSubmitForSettlementTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Http/Client/TransactionSubmitForSettlementTest.php @@ -15,7 +15,7 @@ /** * Class TransactionSubmitForSettlementTest */ -class TransactionSubmitForSettlementTest extends \PHPUnit_Framework_TestCase +class TransactionSubmitForSettlementTest extends \PHPUnit\Framework\TestCase { /** * @var TransactionSubmitForSettlement @@ -90,7 +90,7 @@ public function testPlaceRequest() */ private function getTransferObjectMock() { - $mock = $this->getMock(TransferInterface::class); + $mock = $this->createMock(TransferInterface::class); $mock->expects($this->once()) ->method('getBody') ->willReturn([ diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Http/TransferFactoryTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Http/TransferFactoryTest.php index de342ea671b60..0caba742f9a06 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Http/TransferFactoryTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Http/TransferFactoryTest.php @@ -12,7 +12,7 @@ /** * Class TransferFactoryTest */ -class TransferFactoryTest extends \PHPUnit_Framework_TestCase +class TransferFactoryTest extends \PHPUnit\Framework\TestCase { /** * @var TransferFactory @@ -31,8 +31,8 @@ class TransferFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->transferBuilder = $this->getMock(TransferBuilder::class); - $this->transferMock = $this->getMock(TransferInterface::class); + $this->transferBuilder = $this->createMock(TransferBuilder::class); + $this->transferMock = $this->createMock(TransferInterface::class); $this->transferFactory = new TransferFactory( $this->transferBuilder diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Request/AddressDataBuilderTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Request/AddressDataBuilderTest.php index 35064a1b3920c..3f05aed45da60 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Request/AddressDataBuilderTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Request/AddressDataBuilderTest.php @@ -14,7 +14,7 @@ /** * Class AddressDataBuilderTest */ -class AddressDataBuilderTest extends \PHPUnit_Framework_TestCase +class AddressDataBuilderTest extends \PHPUnit\Framework\TestCase { /** * @var PaymentDataObjectInterface|\PHPUnit_Framework_MockObject_MockObject @@ -38,8 +38,8 @@ class AddressDataBuilderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->paymentDOMock = $this->getMock(PaymentDataObjectInterface::class); - $this->orderMock = $this->getMock(OrderAdapterInterface::class); + $this->paymentDOMock = $this->createMock(PaymentDataObjectInterface::class); + $this->orderMock = $this->createMock(OrderAdapterInterface::class); $this->subjectReaderMock = $this->getMockBuilder(SubjectReader::class) ->disableOriginalConstructor() ->getMock(); @@ -175,7 +175,7 @@ public function dataProviderBuild() */ private function getAddressMock($addressData) { - $addressMock = $this->getMock(AddressAdapterInterface::class); + $addressMock = $this->createMock(AddressAdapterInterface::class); $addressMock->expects(static::exactly(2)) ->method('getFirstname') diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Request/CaptureDataBuilderTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Request/CaptureDataBuilderTest.php index b52c6a07387cb..9799b6f18c639 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Request/CaptureDataBuilderTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Request/CaptureDataBuilderTest.php @@ -13,7 +13,7 @@ /** * Class CaptureDataBuilderTest */ -class CaptureDataBuilderTest extends \PHPUnit_Framework_TestCase +class CaptureDataBuilderTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Braintree\Gateway\Request\CaptureDataBuilder @@ -37,7 +37,7 @@ class CaptureDataBuilderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->paymentDO = $this->getMock(PaymentDataObjectInterface::class); + $this->paymentDO = $this->createMock(PaymentDataObjectInterface::class); $this->payment = $this->getMockBuilder(Payment::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Request/ChannelDataBuilderTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Request/ChannelDataBuilderTest.php index 77117b83d0a91..5769290c249aa 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Request/ChannelDataBuilderTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Request/ChannelDataBuilderTest.php @@ -15,7 +15,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ChannelDataBuilderTest extends \PHPUnit_Framework_TestCase +class ChannelDataBuilderTest extends \PHPUnit\Framework\TestCase { /** * @var ProductMetadataInterface|MockObject diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Request/CustomerDataBuilderTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Request/CustomerDataBuilderTest.php index 108565b532235..0f25b26fd2fa3 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Request/CustomerDataBuilderTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Request/CustomerDataBuilderTest.php @@ -14,7 +14,7 @@ /** * Class CustomerDataBuilderTest */ -class CustomerDataBuilderTest extends \PHPUnit_Framework_TestCase +class CustomerDataBuilderTest extends \PHPUnit\Framework\TestCase { /** * @var PaymentDataObjectInterface|\PHPUnit_Framework_MockObject_MockObject @@ -38,8 +38,8 @@ class CustomerDataBuilderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->paymentDOMock = $this->getMock(PaymentDataObjectInterface::class); - $this->orderMock = $this->getMock(OrderAdapterInterface::class); + $this->paymentDOMock = $this->createMock(PaymentDataObjectInterface::class); + $this->orderMock = $this->createMock(OrderAdapterInterface::class); $this->subjectReaderMock = $this->getMockBuilder(SubjectReader::class) ->disableOriginalConstructor() ->getMock(); @@ -126,7 +126,7 @@ public function dataProviderBuild() */ private function getBillingMock($billingData) { - $addressMock = $this->getMock(AddressAdapterInterface::class); + $addressMock = $this->createMock(AddressAdapterInterface::class); $addressMock->expects(static::once()) ->method('getFirstname') diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Request/DescriptorDataBuilderTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Request/DescriptorDataBuilderTest.php index a1af885a2c6d1..761d88b636ed7 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Request/DescriptorDataBuilderTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Request/DescriptorDataBuilderTest.php @@ -12,7 +12,7 @@ /** * Class DescriptorDataBuilderTest */ -class DescriptorDataBuilderTest extends \PHPUnit_Framework_TestCase +class DescriptorDataBuilderTest extends \PHPUnit\Framework\TestCase { /** * @var Config|MockObject diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Request/KountPaymentDataBuilderTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Request/KountPaymentDataBuilderTest.php index 483f1368b9c59..ee0907a1ddbbb 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Request/KountPaymentDataBuilderTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Request/KountPaymentDataBuilderTest.php @@ -17,7 +17,7 @@ * * @see \Magento\Braintree\Gateway\Request\KountPaymentDataBuilder */ -class KountPaymentDataBuilderTest extends \PHPUnit_Framework_TestCase +class KountPaymentDataBuilderTest extends \PHPUnit\Framework\TestCase { const DEVICE_DATA = '{"test": "test"}'; @@ -48,7 +48,7 @@ class KountPaymentDataBuilderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->paymentDO = $this->getMock(PaymentDataObjectInterface::class); + $this->paymentDO = $this->createMock(PaymentDataObjectInterface::class); $this->configMock = $this->getMockBuilder(Config::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Request/PayPal/DeviceDataBuilderTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Request/PayPal/DeviceDataBuilderTest.php index 3059f7b6a5a90..fba65354d6095 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Request/PayPal/DeviceDataBuilderTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Request/PayPal/DeviceDataBuilderTest.php @@ -14,7 +14,7 @@ /** * Class DeviceDataBuilderTest */ -class DeviceDataBuilderTest extends \PHPUnit_Framework_TestCase +class DeviceDataBuilderTest extends \PHPUnit\Framework\TestCase { /** * @var SubjectReader|MockObject @@ -43,9 +43,9 @@ protected function setUp() ->setMethods(['readPayment']) ->getMock(); - $this->paymentDataObject = $this->getMock(PaymentDataObjectInterface::class); + $this->paymentDataObject = $this->createMock(PaymentDataObjectInterface::class); - $this->paymentInfo = $this->getMock(InfoInterface::class); + $this->paymentInfo = $this->createMock(InfoInterface::class); $this->builder = new DeviceDataBuilder($this->subjectReader); } diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Request/PayPal/VaultDataBuilderTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Request/PayPal/VaultDataBuilderTest.php index 7e584a4ee995f..8e83254727bf7 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Request/PayPal/VaultDataBuilderTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Request/PayPal/VaultDataBuilderTest.php @@ -15,7 +15,7 @@ /** * Class VaultDataBuilderTest */ -class VaultDataBuilderTest extends \PHPUnit_Framework_TestCase +class VaultDataBuilderTest extends \PHPUnit\Framework\TestCase { /** * @var SubjectReader|MockObject @@ -39,9 +39,9 @@ class VaultDataBuilderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->paymentDataObject = $this->getMock(PaymentDataObjectInterface::class); + $this->paymentDataObject = $this->createMock(PaymentDataObjectInterface::class); - $this->paymentInfo = $this->getMock(InfoInterface::class); + $this->paymentInfo = $this->createMock(InfoInterface::class); $this->subjectReader = $this->getMockBuilder(SubjectReader::class) ->disableOriginalConstructor() diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Request/PaymentDataBuilderTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Request/PaymentDataBuilderTest.php index b3730a671a756..12c613b8f216b 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Request/PaymentDataBuilderTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Request/PaymentDataBuilderTest.php @@ -18,7 +18,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class PaymentDataBuilderTest extends \PHPUnit_Framework_TestCase +class PaymentDataBuilderTest extends \PHPUnit\Framework\TestCase { const PAYMENT_METHOD_NONCE = 'nonce'; const MERCHANT_ACCOUNT_ID = '245345'; @@ -55,7 +55,7 @@ class PaymentDataBuilderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->paymentDO = $this->getMock(PaymentDataObjectInterface::class); + $this->paymentDO = $this->createMock(PaymentDataObjectInterface::class); $this->configMock = $this->getMockBuilder(Config::class) ->disableOriginalConstructor() ->getMock(); @@ -65,7 +65,7 @@ protected function setUp() $this->subjectReaderMock = $this->getMockBuilder(SubjectReader::class) ->disableOriginalConstructor() ->getMock(); - $this->orderMock = $this->getMock(OrderAdapterInterface::class); + $this->orderMock = $this->createMock(OrderAdapterInterface::class); $this->builder = new PaymentDataBuilder($this->configMock, $this->subjectReaderMock); } diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Request/RefundDataBuilderTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Request/RefundDataBuilderTest.php index 44926ed5fdcf5..5aa383d095a1e 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Request/RefundDataBuilderTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Request/RefundDataBuilderTest.php @@ -12,7 +12,7 @@ use Magento\Sales\Api\Data\TransactionInterface; use Magento\Sales\Model\Order\Payment; -class RefundDataBuilderTest extends \PHPUnit_Framework_TestCase +class RefundDataBuilderTest extends \PHPUnit\Framework\TestCase { /** * @var SubjectReader | \PHPUnit_Framework_MockObject_MockObject @@ -36,7 +36,7 @@ public function setUp() public function testBuild() { - $paymentDO = $this->getMock(PaymentDataObjectInterface::class); + $paymentDO = $this->createMock(PaymentDataObjectInterface::class); $paymentModel = $this->getMockBuilder( Payment::class )->disableOriginalConstructor() @@ -71,7 +71,7 @@ public function testBuild() public function testBuildNullAmount() { - $paymentDO = $this->getMock(PaymentDataObjectInterface::class); + $paymentDO = $this->createMock(PaymentDataObjectInterface::class); $paymentModel = $this->getMockBuilder( Payment::class )->disableOriginalConstructor() @@ -106,7 +106,7 @@ public function testBuildNullAmount() public function testBuildCutOffLegacyTransactionIdPostfix() { - $paymentDO = $this->getMock(PaymentDataObjectInterface::class); + $paymentDO = $this->createMock(PaymentDataObjectInterface::class); $paymentModel = $this->getMockBuilder( Payment::class )->disableOriginalConstructor() diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Request/SettlementDataBuilderTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Request/SettlementDataBuilderTest.php index 53b42539d7a5e..2f8f954243749 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Request/SettlementDataBuilderTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Request/SettlementDataBuilderTest.php @@ -7,7 +7,7 @@ use Magento\Braintree\Gateway\Request\SettlementDataBuilder; -class SettlementDataBuilderTest extends \PHPUnit_Framework_TestCase +class SettlementDataBuilderTest extends \PHPUnit\Framework\TestCase { public function testBuild() { diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Request/ThreeDSecureDataBuilderTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Request/ThreeDSecureDataBuilderTest.php index 924ef6201f802..c28ac0c3ac372 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Request/ThreeDSecureDataBuilderTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Request/ThreeDSecureDataBuilderTest.php @@ -15,7 +15,7 @@ /** * Class ThreeDSecureDataBuilderTest */ -class ThreeDSecureDataBuilderTest extends \PHPUnit_Framework_TestCase +class ThreeDSecureDataBuilderTest extends \PHPUnit\Framework\TestCase { /** * @var ThreeDSecureDataBuilder diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Request/VaultCaptureDataBuilderTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Request/VaultCaptureDataBuilderTest.php index ce30019b4564d..df11938ddba70 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Request/VaultCaptureDataBuilderTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Request/VaultCaptureDataBuilderTest.php @@ -12,7 +12,7 @@ use Magento\Sales\Model\Order\Payment; use Magento\Vault\Model\PaymentToken; -class VaultCaptureDataBuilderTest extends \PHPUnit_Framework_TestCase +class VaultCaptureDataBuilderTest extends \PHPUnit\Framework\TestCase { /** * @var VaultCaptureDataBuilder @@ -36,7 +36,7 @@ class VaultCaptureDataBuilderTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->paymentDO = $this->getMock(PaymentDataObjectInterface::class); + $this->paymentDO = $this->createMock(PaymentDataObjectInterface::class); $this->payment = $this->getMockBuilder(Payment::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Request/VaultDataBuilderTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Request/VaultDataBuilderTest.php index b7220473602e7..08b5526daeb04 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Request/VaultDataBuilderTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Request/VaultDataBuilderTest.php @@ -7,7 +7,7 @@ use Magento\Braintree\Gateway\Request\VaultDataBuilder; -class VaultDataBuilderTest extends \PHPUnit_Framework_TestCase +class VaultDataBuilderTest extends \PHPUnit\Framework\TestCase { public function testBuild() { diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Response/CardDetailsHandlerTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Response/CardDetailsHandlerTest.php index 2157e15b37582..87e8e4e413c1b 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Response/CardDetailsHandlerTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Response/CardDetailsHandlerTest.php @@ -16,7 +16,7 @@ /** * Class CardDetailsHandlerTest */ -class CardDetailsHandlerTest extends \PHPUnit_Framework_TestCase +class CardDetailsHandlerTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Braintree\Gateway\Response\CardDetailsHandler diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Response/PayPal/VaultDetailsHandlerTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Response/PayPal/VaultDetailsHandlerTest.php index 24de1dfaef384..fdf3dc941bd77 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Response/PayPal/VaultDetailsHandlerTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Response/PayPal/VaultDetailsHandlerTest.php @@ -25,7 +25,7 @@ * Class VaultDetailsHandlerTest * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class VaultDetailsHandlerTest extends \PHPUnit_Framework_TestCase +class VaultDetailsHandlerTest extends \PHPUnit\Framework\TestCase { private static $transactionId = '1n2suy'; diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Response/PayPalDetailsHandlerTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Response/PayPalDetailsHandlerTest.php index a95ef1d97dc37..f1420ee895e5b 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Response/PayPalDetailsHandlerTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Response/PayPalDetailsHandlerTest.php @@ -16,7 +16,7 @@ /** * Class PayPalDetailsHandlerTest */ -class PayPalDetailsHandlerTest extends \PHPUnit_Framework_TestCase +class PayPalDetailsHandlerTest extends \PHPUnit\Framework\TestCase { /** * @var PayPalDetailsHandler|MockObject diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Response/PaymentDetailsHandlerTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Response/PaymentDetailsHandlerTest.php index b40457c86ba52..d90caa84b447b 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Response/PaymentDetailsHandlerTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Response/PaymentDetailsHandlerTest.php @@ -16,7 +16,7 @@ /** * Class PaymentDetailsHandlerTest */ -class PaymentDetailsHandlerTest extends \PHPUnit_Framework_TestCase +class PaymentDetailsHandlerTest extends \PHPUnit\Framework\TestCase { const TRANSACTION_ID = '432erwwe'; diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Response/RiskDataHandlerTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Response/RiskDataHandlerTest.php index 96708d0eb0d47..2365c396c2f4a 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Response/RiskDataHandlerTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Response/RiskDataHandlerTest.php @@ -17,7 +17,7 @@ * * @see \Magento\Braintree\Gateway\Response\RiskDataHandler */ -class RiskDataHandlerTest extends \PHPUnit_Framework_TestCase +class RiskDataHandlerTest extends \PHPUnit\Framework\TestCase { /** * @var RiskDataHandler @@ -57,7 +57,7 @@ public function testHandle($riskDecision, $isFraud) ->setMethods(['setAdditionalInformation', 'setIsFraudDetected']) ->getMock(); /** @var PaymentDataObjectInterface|MockObject $paymentDO */ - $paymentDO = $this->getMock(PaymentDataObjectInterface::class); + $paymentDO = $this->createMock(PaymentDataObjectInterface::class); $paymentDO->expects(self::once()) ->method('getPayment') ->willReturn($payment); diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Response/ThreeDSecureDetailsHandlerTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Response/ThreeDSecureDetailsHandlerTest.php index e90fa2d65a40c..9ca9ca6aa07ae 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Response/ThreeDSecureDetailsHandlerTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Response/ThreeDSecureDetailsHandlerTest.php @@ -16,7 +16,7 @@ /** * Class ThreeDSecureDetailsHandlerTest */ -class ThreeDSecureDetailsHandlerTest extends \PHPUnit_Framework_TestCase +class ThreeDSecureDetailsHandlerTest extends \PHPUnit\Framework\TestCase { const TRANSACTION_ID = '432er5ww3e'; diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Response/TransactionIdHandlerTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Response/TransactionIdHandlerTest.php index 5648ee4b298d4..3a2d2f7073573 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Response/TransactionIdHandlerTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Response/TransactionIdHandlerTest.php @@ -10,11 +10,11 @@ use Magento\Payment\Gateway\Data\PaymentDataObjectInterface; use Magento\Sales\Model\Order\Payment; -class TransactionIdHandlerTest extends \PHPUnit_Framework_TestCase +class TransactionIdHandlerTest extends \PHPUnit\Framework\TestCase { public function testHandle() { - $paymentDO = $this->getMock(PaymentDataObjectInterface::class); + $paymentDO = $this->createMock(PaymentDataObjectInterface::class); $paymentInfo = $this->getMockBuilder(Payment::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Response/VaultDetailsHandlerTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Response/VaultDetailsHandlerTest.php index 20743a0d43961..fb8f507bf1214 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Response/VaultDetailsHandlerTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Response/VaultDetailsHandlerTest.php @@ -25,7 +25,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class VaultDetailsHandlerTest extends \PHPUnit_Framework_TestCase +class VaultDetailsHandlerTest extends \PHPUnit\Framework\TestCase { const TRANSACTION_ID = '432erwwe'; @@ -71,7 +71,7 @@ class VaultDetailsHandlerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->paymentToken = $this->getMock(PaymentTokenInterface::class); + $this->paymentToken = $this->createMock(PaymentTokenInterface::class); $this->paymentTokenFactory = $this->getMockBuilder(CreditCardTokenFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() @@ -122,13 +122,7 @@ protected function setUp() ->method('getCctypesMapper') ->willReturn($mapperArray); - $this->serializer = $this->getMock( - \Magento\Framework\Serialize\Serializer\Json::class, - [], - [], - '', - false - ); + $this->serializer = $this->createMock(\Magento\Framework\Serialize\Serializer\Json::class); $this->paymentHandler = new VaultDetailsHandler( $this->paymentTokenFactory, diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Response/VoidHandlerTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Response/VoidHandlerTest.php index 2a718b8bb2e45..398349a9692b7 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Response/VoidHandlerTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Response/VoidHandlerTest.php @@ -10,11 +10,11 @@ use Magento\Payment\Gateway\Data\PaymentDataObjectInterface; use Magento\Sales\Model\Order\Payment; -class VoidHandlerTest extends \PHPUnit_Framework_TestCase +class VoidHandlerTest extends \PHPUnit\Framework\TestCase { public function testHandle() { - $paymentDO = $this->getMock(PaymentDataObjectInterface::class); + $paymentDO = $this->createMock(PaymentDataObjectInterface::class); $paymentInfo = $this->getMockBuilder(Payment::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Validator/GeneralResponseValidatorTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Validator/GeneralResponseValidatorTest.php index 52548ca900325..1a9e547e90636 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Validator/GeneralResponseValidatorTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Validator/GeneralResponseValidatorTest.php @@ -12,7 +12,7 @@ use Magento\Braintree\Gateway\Validator\GeneralResponseValidator; use Magento\Braintree\Gateway\Helper\SubjectReader; -class GeneralResponseValidatorTest extends \PHPUnit_Framework_TestCase +class GeneralResponseValidatorTest extends \PHPUnit\Framework\TestCase { /** * @var GeneralResponseValidator @@ -64,7 +64,7 @@ protected function setUp() public function testValidate(array $validationSubject, $isValid, $messages) { /** @var ResultInterface|\PHPUnit_Framework_MockObject_MockObject $resultMock */ - $resultMock = $this->getMock(ResultInterface::class); + $resultMock = $this->createMock(ResultInterface::class); $this->subjectReaderMock->expects(self::once()) ->method('readResponseObject') diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Validator/PaymentNonceResponseValidatorTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Validator/PaymentNonceResponseValidatorTest.php index 59c3d84dfc2b0..294226b1656ec 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Validator/PaymentNonceResponseValidatorTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Validator/PaymentNonceResponseValidatorTest.php @@ -14,7 +14,7 @@ /** * Class PaymentNonceResponseValidatorTest */ -class PaymentNonceResponseValidatorTest extends \PHPUnit_Framework_TestCase +class PaymentNonceResponseValidatorTest extends \PHPUnit\Framework\TestCase { /** * @var PaymentNonceResponseValidator @@ -65,7 +65,7 @@ public function testFailedValidate() ->method('readResponseObject') ->willReturn($obj); - $result = $this->getMock(ResultInterface::class); + $result = $this->createMock(ResultInterface::class); $this->resultInterfaceFactory->expects(self::once()) ->method('create') ->with([ @@ -97,7 +97,7 @@ public function testValidateSuccess() ->method('readResponseObject') ->willReturn($obj); - $result = $this->getMock(ResultInterface::class); + $result = $this->createMock(ResultInterface::class); $this->resultInterfaceFactory->expects(self::once()) ->method('create') ->with([ diff --git a/app/code/Magento/Braintree/Test/Unit/Gateway/Validator/ResponseValidatorTest.php b/app/code/Magento/Braintree/Test/Unit/Gateway/Validator/ResponseValidatorTest.php index 94f78b388176c..aeb9b4a83077c 100644 --- a/app/code/Magento/Braintree/Test/Unit/Gateway/Validator/ResponseValidatorTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Gateway/Validator/ResponseValidatorTest.php @@ -18,7 +18,7 @@ /** * Class ResponseValidatorTest */ -class ResponseValidatorTest extends \PHPUnit_Framework_TestCase +class ResponseValidatorTest extends \PHPUnit\Framework\TestCase { /** * @var ResponseValidator @@ -103,7 +103,7 @@ public function testValidateReadResponseObjectException() public function testValidate(array $validationSubject, $isValid, $messages) { /** @var ResultInterface|MockObject $result */ - $result = $this->getMock(ResultInterface::class); + $result = $this->createMock(ResultInterface::class); $this->subjectReader->expects(self::once()) ->method('readResponseObject') diff --git a/app/code/Magento/Braintree/Test/Unit/Helper/CcTypeTest.php b/app/code/Magento/Braintree/Test/Unit/Helper/CcTypeTest.php index 6da7cf2531392..6b1a38c61a5cd 100644 --- a/app/code/Magento/Braintree/Test/Unit/Helper/CcTypeTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Helper/CcTypeTest.php @@ -12,7 +12,7 @@ /** * Class CcTypeTest */ -class CcTypeTest extends \PHPUnit_Framework_TestCase +class CcTypeTest extends \PHPUnit\Framework\TestCase { /** diff --git a/app/code/Magento/Braintree/Test/Unit/Helper/CountryTest.php b/app/code/Magento/Braintree/Test/Unit/Helper/CountryTest.php index fcf1c4ed340c8..692eae643dc29 100644 --- a/app/code/Magento/Braintree/Test/Unit/Helper/CountryTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Helper/CountryTest.php @@ -13,7 +13,7 @@ /** * Class CountryTest */ -class CountryTest extends \PHPUnit_Framework_TestCase +class CountryTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Directory\Model\ResourceModel\Country\Collection|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Braintree/Test/Unit/Model/Adminhtml/System/Config/CountryCreditCardTest.php b/app/code/Magento/Braintree/Test/Unit/Model/Adminhtml/System/Config/CountryCreditCardTest.php index ff55af4861b3c..a1f67897d2c19 100644 --- a/app/code/Magento/Braintree/Test/Unit/Model/Adminhtml/System/Config/CountryCreditCardTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Model/Adminhtml/System/Config/CountryCreditCardTest.php @@ -15,7 +15,7 @@ * Class CountryCreditCardTest * */ -class CountryCreditCardTest extends \PHPUnit_Framework_TestCase +class CountryCreditCardTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Braintree\Model\Adminhtml\System\Config\CountryCreditCard @@ -48,7 +48,7 @@ protected function setUp() $this->mathRandomMock = $this->getMockBuilder(Random::class) ->disableOriginalConstructor() ->getMock(); - $this->serializerMock = $this->getMock(\Magento\Framework\Serialize\Serializer\Json::class); + $this->serializerMock = $this->createMock(\Magento\Framework\Serialize\Serializer\Json::class); $this->objectManager = new ObjectManager($this); $this->model = $this->objectManager->getObject( diff --git a/app/code/Magento/Braintree/Test/Unit/Model/Adminhtml/System/Config/CountryTest.php b/app/code/Magento/Braintree/Test/Unit/Model/Adminhtml/System/Config/CountryTest.php index ffe82dbc0856c..f8c6dcbda71df 100644 --- a/app/code/Magento/Braintree/Test/Unit/Model/Adminhtml/System/Config/CountryTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Model/Adminhtml/System/Config/CountryTest.php @@ -14,7 +14,7 @@ * Class CountryTest * */ -class CountryTest extends \PHPUnit_Framework_TestCase +class CountryTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Braintree\Model\Adminhtml\System\Config\Country diff --git a/app/code/Magento/Braintree/Test/Unit/Model/AvsEmsCodeMapperTest.php b/app/code/Magento/Braintree/Test/Unit/Model/AvsEmsCodeMapperTest.php index 1ff108f366647..9b80a2237a8fb 100644 --- a/app/code/Magento/Braintree/Test/Unit/Model/AvsEmsCodeMapperTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Model/AvsEmsCodeMapperTest.php @@ -10,7 +10,7 @@ use Magento\Sales\Api\Data\OrderPaymentInterface; use PHPUnit_Framework_MockObject_MockObject as MockObject; -class AvsEmsCodeMapperTest extends \PHPUnit_Framework_TestCase +class AvsEmsCodeMapperTest extends \PHPUnit\Framework\TestCase { /** * @var AvsEmsCodeMapper diff --git a/app/code/Magento/Braintree/Test/Unit/Model/CvvEmsCodeMapperTest.php b/app/code/Magento/Braintree/Test/Unit/Model/CvvEmsCodeMapperTest.php index 2d2874e4044c9..5f151de7f12e0 100644 --- a/app/code/Magento/Braintree/Test/Unit/Model/CvvEmsCodeMapperTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Model/CvvEmsCodeMapperTest.php @@ -10,7 +10,7 @@ use Magento\Sales\Api\Data\OrderPaymentInterface; use PHPUnit_Framework_MockObject_MockObject as MockObject; -class CvvEmsCodeMapperTest extends \PHPUnit_Framework_TestCase +class CvvEmsCodeMapperTest extends \PHPUnit\Framework\TestCase { /** * @var CvvEmsCodeMapper diff --git a/app/code/Magento/Braintree/Test/Unit/Model/Paypal/Helper/OrderPlaceTest.php b/app/code/Magento/Braintree/Test/Unit/Model/Paypal/Helper/OrderPlaceTest.php index 179cbf2a1e991..1aecba91b9afc 100644 --- a/app/code/Magento/Braintree/Test/Unit/Model/Paypal/Helper/OrderPlaceTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Model/Paypal/Helper/OrderPlaceTest.php @@ -22,7 +22,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class OrderPlaceTest extends \PHPUnit_Framework_TestCase +class OrderPlaceTest extends \PHPUnit\Framework\TestCase { const TEST_EMAIL = 'test@test.loc'; @@ -133,7 +133,7 @@ private function disabledQuoteAddressValidationStep(\PHPUnit_Framework_MockObjec ->with(true) ->willReturnSelf(); - $billingAddressMock->expects(self::at(1)) + $billingAddressMock->expects(self::any()) ->method('getEmail') ->willReturn(self::TEST_EMAIL); @@ -208,7 +208,7 @@ private function getBillingAddressMock(\PHPUnit_Framework_MockObject_MockObject { if (!isset($this->billingAddressMock)) { $this->billingAddressMock = $this->getMockBuilder(Address::class) - ->setMethods(['setShouldIgnoreValidation', 'getEmail']) + ->setMethods(['setShouldIgnoreValidation', 'getEmail', 'setSameAsBilling']) ->disableOriginalConstructor() ->getMock(); } diff --git a/app/code/Magento/Braintree/Test/Unit/Model/Paypal/Helper/QuoteUpdaterTest.php b/app/code/Magento/Braintree/Test/Unit/Model/Paypal/Helper/QuoteUpdaterTest.php index c5ec3d9c71d9b..39863e6561c43 100644 --- a/app/code/Magento/Braintree/Test/Unit/Model/Paypal/Helper/QuoteUpdaterTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Model/Paypal/Helper/QuoteUpdaterTest.php @@ -21,7 +21,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class QuoteUpdaterTest extends \PHPUnit_Framework_TestCase +class QuoteUpdaterTest extends \PHPUnit\Framework\TestCase { const TEST_NONCE = '3ede7045-2aea-463e-9754-cd658ffeeb48'; diff --git a/app/code/Magento/Braintree/Test/Unit/Model/Paypal/Helper/ShippingMethodUpdaterTest.php b/app/code/Magento/Braintree/Test/Unit/Model/Paypal/Helper/ShippingMethodUpdaterTest.php index e17e76d20d638..c850a34cbdb95 100644 --- a/app/code/Magento/Braintree/Test/Unit/Model/Paypal/Helper/ShippingMethodUpdaterTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Model/Paypal/Helper/ShippingMethodUpdaterTest.php @@ -16,7 +16,7 @@ * * @see \Magento\Braintree\Model\Paypal\Helper\ShippingMethodUpdater */ -class ShippingMethodUpdaterTest extends \PHPUnit_Framework_TestCase +class ShippingMethodUpdaterTest extends \PHPUnit\Framework\TestCase { const TEST_SHIPPING_METHOD = 'test-shipping-method'; @@ -146,7 +146,7 @@ private function getBillingAddressMock(\PHPUnit_Framework_MockObject_MockObject { if (!isset($this->billingAddressMock)) { $this->billingAddressMock = $this->getMockBuilder(Address::class) - ->setMethods(['setShouldIgnoreValidation', 'getEmail']) + ->setMethods(['setShouldIgnoreValidation', 'getEmail', 'setSameAsBilling']) ->disableOriginalConstructor() ->getMock(); } diff --git a/app/code/Magento/Braintree/Test/Unit/Model/Report/FilterMapperTest.php b/app/code/Magento/Braintree/Test/Unit/Model/Report/FilterMapperTest.php index 21cbc82442947..85fd6a135946e 100644 --- a/app/code/Magento/Braintree/Test/Unit/Model/Report/FilterMapperTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Model/Report/FilterMapperTest.php @@ -15,7 +15,7 @@ * * Test for class \Magento\Braintree\Model\Report\FilterMapper */ -class FilterMapperTest extends \PHPUnit_Framework_TestCase +class FilterMapperTest extends \PHPUnit\Framework\TestCase { /** * @var BraintreeSearchAdapter|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Braintree/Test/Unit/Model/Report/TransactionMapTest.php b/app/code/Magento/Braintree/Test/Unit/Model/Report/TransactionMapTest.php index 968177d09be8b..ee3114ae6da63 100644 --- a/app/code/Magento/Braintree/Test/Unit/Model/Report/TransactionMapTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Model/Report/TransactionMapTest.php @@ -20,7 +20,7 @@ * * Test for class \Magento\Braintree\Model\Report\\Row\TransactionMap */ -class TransactionMapTest extends \PHPUnit_Framework_TestCase +class TransactionMapTest extends \PHPUnit\Framework\TestCase { /** * @var Transaction|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Braintree/Test/Unit/Model/Report/TransactionsCollectionTest.php b/app/code/Magento/Braintree/Test/Unit/Model/Report/TransactionsCollectionTest.php index 2cdc7502f8f39..e43e67c18744f 100644 --- a/app/code/Magento/Braintree/Test/Unit/Model/Report/TransactionsCollectionTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Model/Report/TransactionsCollectionTest.php @@ -16,7 +16,7 @@ * * Test for class \Magento\Braintree\Model\Report\TransactionsCollection */ -class TransactionsCollectionTest extends \PHPUnit_Framework_TestCase +class TransactionsCollectionTest extends \PHPUnit\Framework\TestCase { /** * @var BraintreeAdapter|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Braintree/Test/Unit/Model/Ui/Adminhtml/PayPal/TokenUiComponentProviderTest.php b/app/code/Magento/Braintree/Test/Unit/Model/Ui/Adminhtml/PayPal/TokenUiComponentProviderTest.php index 8f600e131f7d7..499918d3d0119 100644 --- a/app/code/Magento/Braintree/Test/Unit/Model/Ui/Adminhtml/PayPal/TokenUiComponentProviderTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Model/Ui/Adminhtml/PayPal/TokenUiComponentProviderTest.php @@ -16,7 +16,7 @@ /** * Contains methods to test PayPal token Ui component provider */ -class TokenUiComponentProviderTest extends \PHPUnit_Framework_TestCase +class TokenUiComponentProviderTest extends \PHPUnit\Framework\TestCase { /** * @var TokenUiComponentInterfaceFactory|MockObject @@ -45,7 +45,7 @@ protected function setUp() ->setMethods(['create']) ->getMock(); - $this->urlBuilder = $this->getMock(UrlInterface::class); + $this->urlBuilder = $this->createMock(UrlInterface::class); $this->config = $this->getMockBuilder(Config::class) ->disableOriginalConstructor() @@ -86,7 +86,7 @@ public function testGetComponentForToken() ->method('getPayPalIcon') ->willReturn($icon); - $paymentToken = $this->getMock(PaymentTokenInterface::class); + $paymentToken = $this->createMock(PaymentTokenInterface::class); $paymentToken->expects(static::once()) ->method('getTokenDetails') ->willReturn('{"payerEmail":" ' . $payerEmail . '"}'); @@ -98,7 +98,7 @@ public function testGetComponentForToken() ->method('getUrl') ->willReturn($nonceUrl); - $tokenComponent = $this->getMock(TokenUiComponentInterface::class); + $tokenComponent = $this->createMock(TokenUiComponentInterface::class); $tokenComponent->expects(static::once()) ->method('getConfig') ->willReturn($expected); diff --git a/app/code/Magento/Braintree/Test/Unit/Model/Ui/Adminhtml/TokenUiComponentProviderTest.php b/app/code/Magento/Braintree/Test/Unit/Model/Ui/Adminhtml/TokenUiComponentProviderTest.php index 4bd469e2b97e3..192be9ccdb430 100644 --- a/app/code/Magento/Braintree/Test/Unit/Model/Ui/Adminhtml/TokenUiComponentProviderTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Model/Ui/Adminhtml/TokenUiComponentProviderTest.php @@ -15,7 +15,7 @@ /** * Class TokenUiComponentProviderTest */ -class TokenUiComponentProviderTest extends \PHPUnit_Framework_TestCase +class TokenUiComponentProviderTest extends \PHPUnit\Framework\TestCase { /** @@ -40,7 +40,7 @@ protected function setUp() ->setMethods(['create']) ->getMock(); - $this->urlBuilder = $this->getMock(UrlInterface::class); + $this->urlBuilder = $this->createMock(UrlInterface::class); $this->tokenUiComponentProvider = new TokenUiComponentProvider( $this->componentFactory, @@ -69,7 +69,7 @@ public function testGetComponentForToken() 'template' => 'vault.phtml' ]; - $paymentToken = $this->getMock(PaymentTokenInterface::class); + $paymentToken = $this->createMock(PaymentTokenInterface::class); $paymentToken->expects(static::once()) ->method('getTokenDetails') ->willReturn('{"type":"VI","maskedCC":"1111","expirationDate":"12\/2015"}'); @@ -81,7 +81,7 @@ public function testGetComponentForToken() ->method('getUrl') ->willReturn($nonceUrl); - $tokenComponent = $this->getMock(TokenUiComponentInterface::class); + $tokenComponent = $this->createMock(TokenUiComponentInterface::class); $tokenComponent->expects(static::once()) ->method('getConfig') ->willReturn($expected); diff --git a/app/code/Magento/Braintree/Test/Unit/Model/Ui/ConfigProviderTest.php b/app/code/Magento/Braintree/Test/Unit/Model/Ui/ConfigProviderTest.php index 6513641f61c00..6c85ae68eb7af 100644 --- a/app/code/Magento/Braintree/Test/Unit/Model/Ui/ConfigProviderTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Model/Ui/ConfigProviderTest.php @@ -15,7 +15,7 @@ * * Test for class \Magento\Braintree\Model\Ui\ConfigProvider */ -class ConfigProviderTest extends \PHPUnit_Framework_TestCase +class ConfigProviderTest extends \PHPUnit\Framework\TestCase { const SDK_URL = 'https://js.braintreegateway.com/v2/braintree.js'; const CLIENT_TOKEN = 'token'; diff --git a/app/code/Magento/Braintree/Test/Unit/Model/Ui/PayPal/ConfigProviderTest.php b/app/code/Magento/Braintree/Test/Unit/Model/Ui/PayPal/ConfigProviderTest.php index ea46d8ee77a8a..22f7f46bd98f1 100644 --- a/app/code/Magento/Braintree/Test/Unit/Model/Ui/PayPal/ConfigProviderTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Model/Ui/PayPal/ConfigProviderTest.php @@ -15,7 +15,7 @@ * * Test for class \Magento\Braintree\Model\Ui\PayPal\ConfigProvider */ -class ConfigProviderTest extends \PHPUnit_Framework_TestCase +class ConfigProviderTest extends \PHPUnit\Framework\TestCase { /** * @var Config|MockObject diff --git a/app/code/Magento/Braintree/Test/Unit/Model/Ui/PayPal/TokenUiComponentProviderTest.php b/app/code/Magento/Braintree/Test/Unit/Model/Ui/PayPal/TokenUiComponentProviderTest.php index f18c59fed7737..962cd56a7c5ac 100644 --- a/app/code/Magento/Braintree/Test/Unit/Model/Ui/PayPal/TokenUiComponentProviderTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Model/Ui/PayPal/TokenUiComponentProviderTest.php @@ -15,7 +15,7 @@ /** * Class TokenUiComponentProviderTest */ -class TokenUiComponentProviderTest extends \PHPUnit_Framework_TestCase +class TokenUiComponentProviderTest extends \PHPUnit\Framework\TestCase { /** * @var UrlInterface|MockObject diff --git a/app/code/Magento/Braintree/Test/Unit/Observer/AddPaypalShortcutsTest.php b/app/code/Magento/Braintree/Test/Unit/Observer/AddPaypalShortcutsTest.php index 6cf9cfb760d77..377b4d3c650ae 100644 --- a/app/code/Magento/Braintree/Test/Unit/Observer/AddPaypalShortcutsTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Observer/AddPaypalShortcutsTest.php @@ -17,7 +17,7 @@ * * @see \Magento\Braintree\Observer\AddPaypalShortcuts */ -class AddPaypalShortcutsTest extends \PHPUnit_Framework_TestCase +class AddPaypalShortcutsTest extends \PHPUnit\Framework\TestCase { public function testExecute() { diff --git a/app/code/Magento/Braintree/Test/Unit/Observer/DataAssignObserverTest.php b/app/code/Magento/Braintree/Test/Unit/Observer/DataAssignObserverTest.php index 057dde90f04a6..d4c7a3e19656e 100644 --- a/app/code/Magento/Braintree/Test/Unit/Observer/DataAssignObserverTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Observer/DataAssignObserverTest.php @@ -15,7 +15,7 @@ /** * Class DataAssignObserverTest */ -class DataAssignObserverTest extends \PHPUnit_Framework_TestCase +class DataAssignObserverTest extends \PHPUnit\Framework\TestCase { const PAYMENT_METHOD_NONCE = 'nonce'; const DEVICE_DATA = '{"test": "test"}'; @@ -28,7 +28,7 @@ public function testExecute() $event = $this->getMockBuilder(Event::class) ->disableOriginalConstructor() ->getMock(); - $paymentInfoModel = $this->getMock(InfoInterface::class); + $paymentInfoModel = $this->createMock(InfoInterface::class); $dataObject = new DataObject( [ PaymentInterface::KEY_ADDITIONAL_DATA => [ diff --git a/app/code/Magento/Braintree/Test/Unit/Ui/Component/Report/Filters/Type/DateRangeTest.php b/app/code/Magento/Braintree/Test/Unit/Ui/Component/Report/Filters/Type/DateRangeTest.php index fe30a1ce7d538..8e463aa75d7aa 100644 --- a/app/code/Magento/Braintree/Test/Unit/Ui/Component/Report/Filters/Type/DateRangeTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Ui/Component/Report/Filters/Type/DateRangeTest.php @@ -17,7 +17,7 @@ /** * Class DateRangeTest */ -class DateRangeTest extends \PHPUnit_Framework_TestCase +class DateRangeTest extends \PHPUnit\Framework\TestCase { /** * @var ContextInterface|\PHPUnit_Framework_MockObject_MockObject @@ -202,7 +202,7 @@ private function getFilterMock($name, $expectedType, $expectedDate, &$i) ->with($expectedDate) ->willReturnSelf(); - $filterMock = $this->getMock(Filter::class); + $filterMock = $this->createMock(Filter::class); $this->filterBuilderMock->expects(static::at($i++)) ->method('create') ->willReturn($filterMock); diff --git a/app/code/Magento/Braintree/Test/Unit/Ui/Component/Report/Listing/Column/CheckColumnOptionSourceTest.php b/app/code/Magento/Braintree/Test/Unit/Ui/Component/Report/Listing/Column/CheckColumnOptionSourceTest.php index bbacd35012c28..988b1658f3032 100644 --- a/app/code/Magento/Braintree/Test/Unit/Ui/Component/Report/Listing/Column/CheckColumnOptionSourceTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Ui/Component/Report/Listing/Column/CheckColumnOptionSourceTest.php @@ -12,7 +12,7 @@ /** * Class CheckColumnOptionSourceTest */ -class CheckColumnOptionSourceTest extends \PHPUnit_Framework_TestCase +class CheckColumnOptionSourceTest extends \PHPUnit\Framework\TestCase { public function testPaymentTypeSource() { diff --git a/app/code/Magento/Braintree/view/adminhtml/ui_component/braintree_report.xml b/app/code/Magento/Braintree/view/adminhtml/ui_component/braintree_report.xml index fbb2a24fb9d86..f039fe51a4ee0 100644 --- a/app/code/Magento/Braintree/view/adminhtml/ui_component/braintree_report.xml +++ b/app/code/Magento/Braintree/view/adminhtml/ui_component/braintree_report.xml @@ -26,6 +26,7 @@ + Magento_Braintree::settlement_report id diff --git a/app/code/Magento/Braintree/view/adminhtml/web/js/vault.js b/app/code/Magento/Braintree/view/adminhtml/web/js/vault.js index b88a61db30cfa..a1a1c81d27c3d 100644 --- a/app/code/Magento/Braintree/view/adminhtml/web/js/vault.js +++ b/app/code/Magento/Braintree/view/adminhtml/web/js/vault.js @@ -109,7 +109,7 @@ define([ $('body').trigger('processStart'); - $.get(self.nonceUrl, { + $.getJSON(self.nonceUrl, { 'public_hash': self.publicHash }).done(function (response) { self.setPaymentDetails(response.paymentMethodNonce); diff --git a/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/hosted-fields.js b/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/hosted-fields.js index 4e8f0cc4651e4..bfdc2974dd4b0 100644 --- a/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/hosted-fields.js +++ b/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/hosted-fields.js @@ -61,7 +61,7 @@ define([ }, /** - * @returns {Bool} + * @returns {Boolean} */ isVaultEnabled: function () { return this.vaultEnabler.isVaultEnabled(); @@ -144,10 +144,19 @@ define([ }, /** - * Trigger order placing + * Returns state of place order button + * @returns {Boolean} + */ + isButtonActive: function () { + return this.isActive() && this.isPlaceOrderActionAllowed(); + }, + + /** + * Triggers order placing */ placeOrderClick: function () { if (this.validateCardType()) { + this.isPlaceOrderActionAllowed(false); $(this.getSelector('submit')).trigger('click'); } }, diff --git a/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/paypal-vault.js b/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/paypal-vault.js index 5868236ef94ca..933f20867168c 100644 --- a/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/paypal-vault.js +++ b/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/paypal-vault.js @@ -49,7 +49,7 @@ define([ var self = this; fullScreenLoader.startLoader(); - $.get(self.nonceUrl, { + $.getJSON(self.nonceUrl, { 'public_hash': self.publicHash }) .done(function (response) { diff --git a/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/vault.js b/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/vault.js index 84f5657b9d540..85e531706d62e 100644 --- a/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/vault.js +++ b/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/vault.js @@ -69,7 +69,7 @@ define([ var self = this; fullScreenLoader.startLoader(); - $.get(self.nonceUrl, { + $.getJSON(self.nonceUrl, { 'public_hash': self.publicHash }) .done(function (response) { diff --git a/app/code/Magento/Braintree/view/frontend/web/template/payment/form.html b/app/code/Magento/Braintree/view/frontend/web/template/payment/form.html index d30186c8fb309..819b06ca75788 100644 --- a/app/code/Magento/Braintree/view/frontend/web/template/payment/form.html +++ b/app/code/Magento/Braintree/view/frontend/web/template/payment/form.html @@ -141,8 +141,7 @@ data-bind=" click: placeOrderClick, attr: {title: $t('Place Order')}, - css: {disabled: !isPlaceOrderActionAllowed()}, - enable: isActive() + enable: isButtonActive() " disabled> diff --git a/app/code/Magento/Bundle/Api/Data/BundleOptionInterface.php b/app/code/Magento/Bundle/Api/Data/BundleOptionInterface.php index f8051bb7895e4..aff0e15a1ab4e 100644 --- a/app/code/Magento/Bundle/Api/Data/BundleOptionInterface.php +++ b/app/code/Magento/Bundle/Api/Data/BundleOptionInterface.php @@ -9,6 +9,7 @@ /** * Interface BundleOptionInterface * @api + * @since 100.0.2 */ interface BundleOptionInterface extends \Magento\Framework\Api\ExtensibleDataInterface { diff --git a/app/code/Magento/Bundle/Api/Data/LinkInterface.php b/app/code/Magento/Bundle/Api/Data/LinkInterface.php index b68317cb3b420..fb9704535c414 100644 --- a/app/code/Magento/Bundle/Api/Data/LinkInterface.php +++ b/app/code/Magento/Bundle/Api/Data/LinkInterface.php @@ -10,6 +10,7 @@ /** * Interface LinkInterface * @api + * @since 100.0.2 */ interface LinkInterface extends \Magento\Framework\Api\ExtensibleDataInterface { diff --git a/app/code/Magento/Bundle/Api/Data/OptionInterface.php b/app/code/Magento/Bundle/Api/Data/OptionInterface.php index 65c7111abf997..b0bad624623a7 100644 --- a/app/code/Magento/Bundle/Api/Data/OptionInterface.php +++ b/app/code/Magento/Bundle/Api/Data/OptionInterface.php @@ -10,6 +10,7 @@ /** * Interface OptionInterface * @api + * @since 100.0.2 */ interface OptionInterface extends \Magento\Framework\Api\ExtensibleDataInterface { diff --git a/app/code/Magento/Bundle/Api/Data/OptionTypeInterface.php b/app/code/Magento/Bundle/Api/Data/OptionTypeInterface.php index 0325f3f653193..ca37ae7285887 100644 --- a/app/code/Magento/Bundle/Api/Data/OptionTypeInterface.php +++ b/app/code/Magento/Bundle/Api/Data/OptionTypeInterface.php @@ -9,6 +9,7 @@ /** * Interface OptionTypeInterface * @api + * @since 100.0.2 */ interface OptionTypeInterface extends \Magento\Framework\Api\ExtensibleDataInterface { diff --git a/app/code/Magento/Bundle/Api/ProductLinkManagementInterface.php b/app/code/Magento/Bundle/Api/ProductLinkManagementInterface.php index 686da4d78c9d7..01943ea1c95ba 100644 --- a/app/code/Magento/Bundle/Api/ProductLinkManagementInterface.php +++ b/app/code/Magento/Bundle/Api/ProductLinkManagementInterface.php @@ -9,6 +9,7 @@ /** * Interface for Management of ProductLink * @api + * @since 100.0.2 */ interface ProductLinkManagementInterface { diff --git a/app/code/Magento/Bundle/Api/ProductOptionManagementInterface.php b/app/code/Magento/Bundle/Api/ProductOptionManagementInterface.php index 94c54c3dabf2a..48a8c97a1786b 100644 --- a/app/code/Magento/Bundle/Api/ProductOptionManagementInterface.php +++ b/app/code/Magento/Bundle/Api/ProductOptionManagementInterface.php @@ -10,6 +10,7 @@ * Option manager for bundle products * * @api + * @since 100.0.2 */ interface ProductOptionManagementInterface { diff --git a/app/code/Magento/Bundle/Api/ProductOptionRepositoryInterface.php b/app/code/Magento/Bundle/Api/ProductOptionRepositoryInterface.php index af470c93c0f36..d4a279856c6e0 100644 --- a/app/code/Magento/Bundle/Api/ProductOptionRepositoryInterface.php +++ b/app/code/Magento/Bundle/Api/ProductOptionRepositoryInterface.php @@ -9,6 +9,7 @@ /** * Interface ProductOptionRepositoryInterface * @api + * @since 100.0.2 */ interface ProductOptionRepositoryInterface { diff --git a/app/code/Magento/Bundle/Api/ProductOptionTypeListInterface.php b/app/code/Magento/Bundle/Api/ProductOptionTypeListInterface.php index af1293fb5c9fb..f9b9c57079ddb 100644 --- a/app/code/Magento/Bundle/Api/ProductOptionTypeListInterface.php +++ b/app/code/Magento/Bundle/Api/ProductOptionTypeListInterface.php @@ -9,6 +9,7 @@ /** * Interface ProductOptionTypeListInterface * @api + * @since 100.0.2 */ interface ProductOptionTypeListInterface { diff --git a/app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Bundle.php b/app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Bundle.php index 9e3ddd49db009..1764fb16c0c1e 100644 --- a/app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Bundle.php +++ b/app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Bundle.php @@ -9,6 +9,7 @@ * Adminhtml block for fieldset of bundle product * * @api + * @since 100.0.2 */ class Bundle extends \Magento\Bundle\Block\Catalog\Product\View\Type\Bundle { diff --git a/app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/Checkbox.php b/app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/Checkbox.php index 38305edce241a..0b3a938255de1 100644 --- a/app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/Checkbox.php +++ b/app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/Checkbox.php @@ -10,6 +10,7 @@ * * @api * @author Magento Core Team + * @since 100.0.2 */ class Checkbox extends \Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Option\Checkbox { diff --git a/app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/Multi.php b/app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/Multi.php index 1391e18d9d4fd..304b3a5cf34ed 100644 --- a/app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/Multi.php +++ b/app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/Multi.php @@ -10,6 +10,7 @@ * * @api * @author Magento Core Team + * @since 100.0.2 */ class Multi extends \Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Option\Multi { diff --git a/app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/Radio.php b/app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/Radio.php index 7ae5611ef59ba..e011ab36e8029 100644 --- a/app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/Radio.php +++ b/app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/Radio.php @@ -10,6 +10,7 @@ * * @api * @author Magento Core Team + * @since 100.0.2 */ class Radio extends \Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Option\Radio { diff --git a/app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/Select.php b/app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/Select.php index 9f618cb0c56ab..f1206db359b5c 100644 --- a/app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/Select.php +++ b/app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/Select.php @@ -10,6 +10,7 @@ * * @api * @author Magento Core Team + * @since 100.0.2 */ class Select extends \Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Option\Select { diff --git a/app/code/Magento/Bundle/Block/Adminhtml/Sales/Order/Items/Renderer.php b/app/code/Magento/Bundle/Block/Adminhtml/Sales/Order/Items/Renderer.php index 6740f48890682..4cb087df0e1a6 100644 --- a/app/code/Magento/Bundle/Block/Adminhtml/Sales/Order/Items/Renderer.php +++ b/app/code/Magento/Bundle/Block/Adminhtml/Sales/Order/Items/Renderer.php @@ -12,6 +12,7 @@ * Adminhtml sales order item renderer * * @api + * @since 100.0.2 */ class Renderer extends \Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer { diff --git a/app/code/Magento/Bundle/Block/Adminhtml/Sales/Order/View/Items/Renderer.php b/app/code/Magento/Bundle/Block/Adminhtml/Sales/Order/View/Items/Renderer.php index eaedfc1ff31a6..9fe8891254a5a 100644 --- a/app/code/Magento/Bundle/Block/Adminhtml/Sales/Order/View/Items/Renderer.php +++ b/app/code/Magento/Bundle/Block/Adminhtml/Sales/Order/View/Items/Renderer.php @@ -12,6 +12,7 @@ * Adminhtml sales order item renderer * * @api + * @since 100.0.2 */ class Renderer extends \Magento\Sales\Block\Adminhtml\Order\View\Items\Renderer\DefaultRenderer { diff --git a/app/code/Magento/Bundle/Block/Catalog/Product/Price.php b/app/code/Magento/Bundle/Block/Catalog/Product/Price.php index 6096575eca56b..4ccf0ac7e0ebd 100644 --- a/app/code/Magento/Bundle/Block/Catalog/Product/Price.php +++ b/app/code/Magento/Bundle/Block/Catalog/Product/Price.php @@ -8,6 +8,7 @@ /** * Bundle product price block * @api + * @since 100.0.2 */ class Price extends \Magento\Catalog\Block\Product\Price { diff --git a/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle.php b/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle.php index e27bf2f263a1a..6cb103fc86789 100644 --- a/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle.php +++ b/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle.php @@ -14,6 +14,7 @@ * @api * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @api + * @since 100.0.2 */ class Bundle extends \Magento\Catalog\Block\Product\View\AbstractView { @@ -85,7 +86,7 @@ public function __construct( } /** - * @deprecated + * @deprecated 100.2.0 * @return \Magento\CatalogRule\Model\ResourceModel\Product\CollectionProcessor */ private function getCatalogRuleProcessor() diff --git a/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle/Option.php b/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle/Option.php index 872d0956f7d16..62a895ae8445b 100644 --- a/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle/Option.php +++ b/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle/Option.php @@ -11,6 +11,7 @@ /** * Bundle option renderer * @api + * @since 100.0.2 */ class Option extends \Magento\Bundle\Block\Catalog\Product\Price { @@ -141,7 +142,7 @@ public function getDefaultValues() */ protected function _getSelectedOptions() { - if (is_null($this->_selectedOptions)) { + if ($this->_selectedOptions === null) { $this->_selectedOptions = []; /** @var \Magento\Bundle\Model\Option $option */ @@ -151,17 +152,29 @@ protected function _getSelectedOptions() $selectionId = $this->getProduct()->getPreconfiguredValues()->getData( 'bundle_option/' . $option->getId() ); - if ($selectionId && $option->getSelectionById($selectionId)) { - $this->_selectedOptions = $selectionId; - } elseif (!$option->getRequired()) { - $this->_selectedOptions = 'None'; - } + $this->assignSelection($option, $selectionId); } } return $this->_selectedOptions; } + /** + * Set selected options. + * + * @param \Magento\Bundle\Model\Option $option + * @param mixed $selectionId + * @return void + */ + protected function assignSelection(\Magento\Bundle\Model\Option $option, $selectionId) + { + if ($selectionId && $option->getSelectionById($selectionId)) { + $this->_selectedOptions = $selectionId; + } elseif (!$option->getRequired()) { + $this->_selectedOptions = 'None'; + } + } + /** * Define if selection is selected * diff --git a/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle/Option/Checkbox.php b/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle/Option/Checkbox.php index 549466b5dd985..8ca0cf8a5159e 100644 --- a/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle/Option/Checkbox.php +++ b/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle/Option/Checkbox.php @@ -9,6 +9,7 @@ * Bundle option checkbox type renderer * * @api + * @since 100.0.2 */ class Checkbox extends \Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Option { diff --git a/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle/Option/Multi.php b/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle/Option/Multi.php index 2b386ab2be5d0..2942b479cbabf 100644 --- a/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle/Option/Multi.php +++ b/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle/Option/Multi.php @@ -9,6 +9,7 @@ * Bundle option multi select type renderer * * @api + * @since 100.0.2 */ class Multi extends \Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Option { @@ -16,4 +17,20 @@ class Multi extends \Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Optio * @var string */ protected $_template = 'catalog/product/view/type/bundle/option/multi.phtml'; + + /** + * @inheritdoc + */ + protected function assignSelection(\Magento\Bundle\Model\Option $option, $selectionId) + { + if (is_array($selectionId)) { + foreach ($selectionId as $id) { + if ($id && $option->getSelectionById($id)) { + $this->_selectedOptions[] = $id; + } + } + } else { + parent::assignSelection($option, $selectionId); + } + } } diff --git a/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle/Option/Radio.php b/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle/Option/Radio.php index 625bc260dcc56..84a619dafab52 100644 --- a/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle/Option/Radio.php +++ b/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle/Option/Radio.php @@ -9,6 +9,7 @@ * Bundle option radiobox type renderer * * @api + * @since 100.0.2 */ class Radio extends \Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Option { diff --git a/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle/Option/Select.php b/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle/Option/Select.php index 7d705257ae318..d7f1cf41057a8 100644 --- a/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle/Option/Select.php +++ b/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle/Option/Select.php @@ -9,6 +9,7 @@ * Bundle option dropdown type renderer * * @api + * @since 100.0.2 */ class Select extends \Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Option { diff --git a/app/code/Magento/Bundle/Block/Checkout/Cart/Item/Renderer.php b/app/code/Magento/Bundle/Block/Checkout/Cart/Item/Renderer.php index 7cdd88b52056e..c75ebc700603b 100644 --- a/app/code/Magento/Bundle/Block/Checkout/Cart/Item/Renderer.php +++ b/app/code/Magento/Bundle/Block/Checkout/Cart/Item/Renderer.php @@ -13,6 +13,7 @@ * Shopping cart item render block * * @api + * @since 100.0.2 */ class Renderer extends \Magento\Checkout\Block\Cart\Item\Renderer { diff --git a/app/code/Magento/Bundle/Block/Sales/Order/Items/Renderer.php b/app/code/Magento/Bundle/Block/Sales/Order/Items/Renderer.php index dc5a0c289895a..a29c93fc4e139 100644 --- a/app/code/Magento/Bundle/Block/Sales/Order/Items/Renderer.php +++ b/app/code/Magento/Bundle/Block/Sales/Order/Items/Renderer.php @@ -11,6 +11,7 @@ /** * Order item render block * @api + * @since 100.0.2 */ class Renderer extends \Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer { diff --git a/app/code/Magento/Bundle/Controller/Adminhtml/Bundle/Selection/Grid.php b/app/code/Magento/Bundle/Controller/Adminhtml/Bundle/Selection/Grid.php index b86ad1a3f3174..c9ddd677e2b46 100644 --- a/app/code/Magento/Bundle/Controller/Adminhtml/Bundle/Selection/Grid.php +++ b/app/code/Magento/Bundle/Controller/Adminhtml/Bundle/Selection/Grid.php @@ -6,7 +6,9 @@ */ namespace Magento\Bundle\Controller\Adminhtml\Bundle\Selection; -class Grid extends \Magento\Backend\App\Action +use Magento\Catalog\Controller\Adminhtml\Product; + +class Grid extends Product { /** * @return mixed diff --git a/app/code/Magento/Bundle/Controller/Adminhtml/Bundle/Selection/Search.php b/app/code/Magento/Bundle/Controller/Adminhtml/Bundle/Selection/Search.php index e2d863b4a28e0..28257ca4894b2 100644 --- a/app/code/Magento/Bundle/Controller/Adminhtml/Bundle/Selection/Search.php +++ b/app/code/Magento/Bundle/Controller/Adminhtml/Bundle/Selection/Search.php @@ -6,7 +6,9 @@ */ namespace Magento\Bundle\Controller\Adminhtml\Bundle\Selection; -class Search extends \Magento\Backend\App\Action +use Magento\Catalog\Controller\Adminhtml\Product; + +class Search extends Product { /** * @return mixed diff --git a/app/code/Magento/Bundle/Helper/Catalog/Product/Configuration.php b/app/code/Magento/Bundle/Helper/Catalog/Product/Configuration.php index 551c4ba5fb866..d657da6cbfe33 100644 --- a/app/code/Magento/Bundle/Helper/Catalog/Product/Configuration.php +++ b/app/code/Magento/Bundle/Helper/Catalog/Product/Configuration.php @@ -12,6 +12,7 @@ /** * Helper for fetching properties by product configuration item * @api + * @since 100.0.2 */ class Configuration extends AbstractHelper implements ConfigurationInterface { diff --git a/app/code/Magento/Bundle/Model/Option.php b/app/code/Magento/Bundle/Model/Option.php index f19682688fb5c..61fd631b8e443 100644 --- a/app/code/Magento/Bundle/Model/Option.php +++ b/app/code/Magento/Bundle/Model/Option.php @@ -12,6 +12,7 @@ * @method int getParentId() * @method null|\Magento\Catalog\Model\Product[] getSelections() * @method Option setParentId(int $value) + * @since 100.0.2 */ class Option extends \Magento\Framework\Model\AbstractExtensibleModel implements \Magento\Bundle\Api\Data\OptionInterface @@ -28,11 +29,7 @@ class Option extends \Magento\Framework\Model\AbstractExtensibleModel implements const KEY_PRODUCT_LINKS = 'product_links'; /**#@-*/ - /** - * Default selection object - * - * @var \Magento\Catalog\Model\Product|null - */ + /**#@-*/ protected $defaultSelection = null; /** diff --git a/app/code/Magento/Bundle/Model/Product/Attribute/Source/Price/View.php b/app/code/Magento/Bundle/Model/Product/Attribute/Source/Price/View.php index 874fb8cbb5e6f..6e1070b8f22f0 100644 --- a/app/code/Magento/Bundle/Model/Product/Attribute/Source/Price/View.php +++ b/app/code/Magento/Bundle/Model/Product/Attribute/Source/Price/View.php @@ -12,6 +12,7 @@ * Bundle Price View Attribute Renderer * * @api + * @since 100.0.2 */ class View extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource { diff --git a/app/code/Magento/Bundle/Model/Product/Attribute/Source/Shipment/Type.php b/app/code/Magento/Bundle/Model/Product/Attribute/Source/Shipment/Type.php index 5e12d73685c5d..baa227be8f6cb 100644 --- a/app/code/Magento/Bundle/Model/Product/Attribute/Source/Shipment/Type.php +++ b/app/code/Magento/Bundle/Model/Product/Attribute/Source/Shipment/Type.php @@ -8,11 +8,13 @@ /** * Bundle Shipment Type Attribute Renderer * @api + * @since 100.1.0 */ class Type extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource { /** * {@inheritdoc} + * @since 100.1.0 */ public function getAllOptions() { @@ -27,6 +29,7 @@ public function getAllOptions() /** * {@inheritdoc} + * @since 100.1.0 */ public function getOptionText($value) { diff --git a/app/code/Magento/Bundle/Model/Product/Price.php b/app/code/Magento/Bundle/Model/Product/Price.php index 4c0aed6f350a6..00b6b2d7a3f5a 100644 --- a/app/code/Magento/Bundle/Model/Product/Price.php +++ b/app/code/Magento/Bundle/Model/Product/Price.php @@ -13,6 +13,7 @@ /** * @api * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class Price extends \Magento\Catalog\Model\Product\Type\Price { diff --git a/app/code/Magento/Bundle/Model/Product/Type.php b/app/code/Magento/Bundle/Model/Product/Type.php index af26a56ad2a3d..bd261d287273e 100644 --- a/app/code/Magento/Bundle/Model/Product/Type.php +++ b/app/code/Magento/Bundle/Model/Product/Type.php @@ -21,6 +21,7 @@ * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @api + * @since 100.0.2 */ class Type extends \Magento\Catalog\Model\Product\Type\AbstractType { @@ -47,7 +48,7 @@ class Type extends \Magento\Catalog\Model\Product\Type\AbstractType * Cache key for Selections Collection * * @var string - * @deprecated + * @deprecated 100.2.0 */ protected $_keySelectionsCollection = '_cache_instance_selections_collection'; @@ -686,7 +687,7 @@ protected function _prepareProduct(\Magento\Framework\DataObject $buyRequest, $p $options ); - $optionsCollection->appendSelections($selections, false, $_appendAllSelections); + $optionsCollection->appendSelections($selections, true, $_appendAllSelections); $selections = $selections->getItems(); } else { @@ -703,7 +704,7 @@ protected function _prepareProduct(\Magento\Framework\DataObject $buyRequest, $p ->getOptionsIds($product); $selectionCollection = $product->getTypeInstance() ->getSelectionsCollection($optionIds, $product); - $options = $optionCollection->appendSelections($selectionCollection, false, $_appendAllSelections); + $options = $optionCollection->appendSelections($selectionCollection, true, $_appendAllSelections); $selections = $this->mergeSelectionsWithOptions($options, $selections); } diff --git a/app/code/Magento/Bundle/Model/ResourceModel/Bundle.php b/app/code/Magento/Bundle/Model/ResourceModel/Bundle.php index e16e13c0fb200..05008092c229a 100644 --- a/app/code/Magento/Bundle/Model/ResourceModel/Bundle.php +++ b/app/code/Magento/Bundle/Model/ResourceModel/Bundle.php @@ -9,6 +9,7 @@ * Bundle Resource Model * * @api + * @since 100.0.2 */ class Bundle extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { @@ -149,6 +150,7 @@ public function saveProductRelations($parentId, $childIds) * @param int $parentId * @param int $childId * @return $this + * @since 100.1.0 */ public function addProductRelation($parentId, $childId) { diff --git a/app/code/Magento/Bundle/Model/ResourceModel/Option/Collection.php b/app/code/Magento/Bundle/Model/ResourceModel/Option/Collection.php index f8e5ef63aee72..e701b4cf9cc1d 100644 --- a/app/code/Magento/Bundle/Model/ResourceModel/Option/Collection.php +++ b/app/code/Magento/Bundle/Model/ResourceModel/Option/Collection.php @@ -8,6 +8,7 @@ /** * Bundle Options Resource Collection * @api + * @since 100.0.2 */ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { @@ -113,6 +114,7 @@ public function setProductIdFilter($productId) * @param int $productLinkFieldValue * * @return $this + * @since 100.1.0 */ public function setProductLinkFilter($productLinkFieldValue) { diff --git a/app/code/Magento/Bundle/Model/ResourceModel/Selection.php b/app/code/Magento/Bundle/Model/ResourceModel/Selection.php index d8d76ce0bb020..ead687faff7bc 100644 --- a/app/code/Magento/Bundle/Model/ResourceModel/Selection.php +++ b/app/code/Magento/Bundle/Model/ResourceModel/Selection.php @@ -15,11 +15,13 @@ * Bundle Selection Resource Model * * @api + * @since 100.0.2 */ class Selection extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * @var MetadataPool + * @since 100.1.0 */ protected $metadataPool; @@ -185,6 +187,7 @@ public function saveSelectionPrice($item) /** * {@inheritdoc} + * @since 100.2.0 */ public function save(\Magento\Framework\Model\AbstractModel $object) { diff --git a/app/code/Magento/Bundle/Model/ResourceModel/Selection/Collection.php b/app/code/Magento/Bundle/Model/ResourceModel/Selection/Collection.php index 7c5289785cebb..0216812199b50 100644 --- a/app/code/Magento/Bundle/Model/ResourceModel/Selection/Collection.php +++ b/app/code/Magento/Bundle/Model/ResourceModel/Selection/Collection.php @@ -17,6 +17,7 @@ * * @api * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection { @@ -165,6 +166,7 @@ public function setPositionOrder() * Add filtering of product then havent enoght stock * * @return $this + * @since 100.2.0 */ public function addQuantityFilter() { @@ -182,6 +184,7 @@ public function addQuantityFilter() /** * @inheritDoc + * @since 100.2.0 */ public function getNewEmptyItem() { @@ -199,6 +202,7 @@ public function getNewEmptyItem() * @param bool $useRegularPrice * * @return $this + * @since 100.2.0 */ public function addPriceFilter($product, $searchMin, $useRegularPrice = false) { @@ -250,7 +254,7 @@ public function addPriceFilter($product, $searchMin, $useRegularPrice = false) /** * @return \Magento\CatalogRule\Model\ResourceModel\Product\CollectionProcessor - * @deprecated + * @deprecated 100.2.0 */ private function getCatalogRuleProcessor() { diff --git a/app/code/Magento/Bundle/Model/Selection.php b/app/code/Magento/Bundle/Model/Selection.php index c8d5ba86e8804..f8e3d05fd9809 100644 --- a/app/code/Magento/Bundle/Model/Selection.php +++ b/app/code/Magento/Bundle/Model/Selection.php @@ -29,6 +29,7 @@ * @method int getSelectionCanChangeQty() * @method \Magento\Bundle\Model\Selection setSelectionCanChangeQty(int $value) * @api + * @since 100.0.2 */ class Selection extends \Magento\Framework\Model\AbstractModel { diff --git a/app/code/Magento/Bundle/Model/Source/Option/Selection/Price/Type.php b/app/code/Magento/Bundle/Model/Source/Option/Selection/Price/Type.php index 987597196f054..2f7182db84d8e 100644 --- a/app/code/Magento/Bundle/Model/Source/Option/Selection/Price/Type.php +++ b/app/code/Magento/Bundle/Model/Source/Option/Selection/Price/Type.php @@ -11,6 +11,7 @@ * Extended Attributes Source Model * * @api + * @since 100.0.2 */ class Type implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Bundle/Model/Source/Option/Type.php b/app/code/Magento/Bundle/Model/Source/Option/Type.php index c76356944a920..f129d24ade671 100644 --- a/app/code/Magento/Bundle/Model/Source/Option/Type.php +++ b/app/code/Magento/Bundle/Model/Source/Option/Type.php @@ -26,9 +26,7 @@ class Type extends \Magento\Framework\Model\AbstractExtensibleModel implements const KEY_CODE = 'code'; /**#@-*/ - /** - * @var array - */ + /**#@-*/ protected $options = []; /** diff --git a/app/code/Magento/Bundle/Pricing/Adjustment/Calculator.php b/app/code/Magento/Bundle/Pricing/Adjustment/Calculator.php index 6b3f180935556..9d035aece57bc 100644 --- a/app/code/Magento/Bundle/Pricing/Adjustment/Calculator.php +++ b/app/code/Magento/Bundle/Pricing/Adjustment/Calculator.php @@ -199,7 +199,7 @@ protected function getSelectionAmounts(Product $bundleProduct, $searchMin, $useR /** * @return SelectionPriceListProviderInterface - * @deprecated + * @deprecated 100.2.0 */ private function getSelectionPriceListProvider() { @@ -217,7 +217,7 @@ private function getSelectionPriceListProvider() * @param \Magento\Bundle\Model\Option $option * @param bool $canSkipRequiredOption * @return bool - * @deprecated + * @deprecated 100.2.0 */ protected function canSkipOption($option, $canSkipRequiredOption) { @@ -229,7 +229,7 @@ protected function canSkipOption($option, $canSkipRequiredOption) * * @param Product $bundleProduct * @return bool - * @deprecated + * @deprecated 100.2.0 */ protected function hasRequiredOption($bundleProduct) { @@ -247,7 +247,7 @@ function ($item) { * * @param Product $saleableItem * @return \Magento\Bundle\Model\ResourceModel\Option\Collection - * @deprecated + * @deprecated 100.2.0 */ protected function getBundleOptions(Product $saleableItem) { diff --git a/app/code/Magento/Bundle/Pricing/Adjustment/SelectionPriceListProviderInterface.php b/app/code/Magento/Bundle/Pricing/Adjustment/SelectionPriceListProviderInterface.php index 4b862bf35dfe4..4310c0e292ced 100644 --- a/app/code/Magento/Bundle/Pricing/Adjustment/SelectionPriceListProviderInterface.php +++ b/app/code/Magento/Bundle/Pricing/Adjustment/SelectionPriceListProviderInterface.php @@ -11,6 +11,7 @@ /** * Provide list of bundle selection prices * @api + * @since 100.2.0 */ interface SelectionPriceListProviderInterface { @@ -19,6 +20,7 @@ interface SelectionPriceListProviderInterface * @param boolean $searchMin * @param boolean $useRegularPrice * @return \Magento\Bundle\Pricing\Price\BundleSelectionPrice[] + * @since 100.2.0 */ public function getPriceList(Product $bundleProduct, $searchMin, $useRegularPrice); } diff --git a/app/code/Magento/Bundle/Pricing/Price/BundleOptionPriceInterface.php b/app/code/Magento/Bundle/Pricing/Price/BundleOptionPriceInterface.php index 0e47ec0be23a9..1fa8a9710beb8 100644 --- a/app/code/Magento/Bundle/Pricing/Price/BundleOptionPriceInterface.php +++ b/app/code/Magento/Bundle/Pricing/Price/BundleOptionPriceInterface.php @@ -8,6 +8,7 @@ /** * Option price interface * @api + * @since 100.0.2 */ interface BundleOptionPriceInterface { diff --git a/app/code/Magento/Bundle/Pricing/Price/BundleSelectionFactory.php b/app/code/Magento/Bundle/Pricing/Price/BundleSelectionFactory.php index 12e3e27d74057..927b8fbff8d85 100644 --- a/app/code/Magento/Bundle/Pricing/Price/BundleSelectionFactory.php +++ b/app/code/Magento/Bundle/Pricing/Price/BundleSelectionFactory.php @@ -11,6 +11,7 @@ /** * Bundle selection price factory * @api + * @since 100.0.2 */ class BundleSelectionFactory { diff --git a/app/code/Magento/Bundle/Pricing/Price/BundleSelectionPrice.php b/app/code/Magento/Bundle/Pricing/Price/BundleSelectionPrice.php index 2eea5190fece5..71c1b5c5e98cb 100644 --- a/app/code/Magento/Bundle/Pricing/Price/BundleSelectionPrice.php +++ b/app/code/Magento/Bundle/Pricing/Price/BundleSelectionPrice.php @@ -18,6 +18,7 @@ * Bundle option price * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @api + * @since 100.0.2 */ class BundleSelectionPrice extends AbstractPrice { diff --git a/app/code/Magento/Bundle/Pricing/Price/ConfiguredPrice.php b/app/code/Magento/Bundle/Pricing/Price/ConfiguredPrice.php index 9f5b113fa13f5..274ea95474120 100644 --- a/app/code/Magento/Bundle/Pricing/Price/ConfiguredPrice.php +++ b/app/code/Magento/Bundle/Pricing/Price/ConfiguredPrice.php @@ -15,6 +15,7 @@ /** * Configured price model * @api + * @since 100.0.2 */ class ConfiguredPrice extends CatalogPrice\FinalPrice implements ConfiguredPriceInterface { diff --git a/app/code/Magento/Bundle/Pricing/Price/DiscountProviderInterface.php b/app/code/Magento/Bundle/Pricing/Price/DiscountProviderInterface.php index 99a5c3eee269b..2d4c0f0dc6bc2 100644 --- a/app/code/Magento/Bundle/Pricing/Price/DiscountProviderInterface.php +++ b/app/code/Magento/Bundle/Pricing/Price/DiscountProviderInterface.php @@ -9,6 +9,7 @@ /** * Interface DiscountProviderInterface * @api + * @since 100.0.2 */ interface DiscountProviderInterface { diff --git a/app/code/Magento/Bundle/Pricing/Price/FinalPrice.php b/app/code/Magento/Bundle/Pricing/Price/FinalPrice.php index 8aa3d3065f092..c41f6a4868ab1 100644 --- a/app/code/Magento/Bundle/Pricing/Price/FinalPrice.php +++ b/app/code/Magento/Bundle/Pricing/Price/FinalPrice.php @@ -92,7 +92,7 @@ public function getMaximalPrice() * Return ProductCustomOptionRepository * * @return ProductCustomOptionRepositoryInterface - * @deprecated + * @deprecated 100.1.0 */ private function getProductOptionRepository() { diff --git a/app/code/Magento/Bundle/Pricing/Price/FinalPriceInterface.php b/app/code/Magento/Bundle/Pricing/Price/FinalPriceInterface.php index cbb2232db300a..eda0a963625ac 100644 --- a/app/code/Magento/Bundle/Pricing/Price/FinalPriceInterface.php +++ b/app/code/Magento/Bundle/Pricing/Price/FinalPriceInterface.php @@ -9,6 +9,7 @@ /** * Interface FinalPriceInterface * @api + * @since 100.0.2 */ interface FinalPriceInterface extends \Magento\Catalog\Pricing\Price\FinalPriceInterface { diff --git a/app/code/Magento/Bundle/Pricing/Price/RegularPriceInterface.php b/app/code/Magento/Bundle/Pricing/Price/RegularPriceInterface.php index ab6305c1d5132..dd81754df441f 100644 --- a/app/code/Magento/Bundle/Pricing/Price/RegularPriceInterface.php +++ b/app/code/Magento/Bundle/Pricing/Price/RegularPriceInterface.php @@ -9,6 +9,7 @@ /** * Regular price interface * @api + * @since 100.0.2 */ interface RegularPriceInterface extends \Magento\Framework\Pricing\Price\BasePriceProviderInterface { diff --git a/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/CheckboxTest.php b/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/CheckboxTest.php index 3adf5ad9d2ee7..58c0436b5bf7c 100644 --- a/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/CheckboxTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/CheckboxTest.php @@ -7,7 +7,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class CheckboxTest extends \PHPUnit_Framework_TestCase +class CheckboxTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Bundle\Block\Adminhtml\Catalog\Product\Composite\Fieldset\Options\Type\Checkbox diff --git a/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/MultiTest.php b/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/MultiTest.php index ad04f05f2e3af..69a1901d89b06 100644 --- a/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/MultiTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/MultiTest.php @@ -7,7 +7,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class MultiTest extends \PHPUnit_Framework_TestCase +class MultiTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Bundle\Block\Adminhtml\Catalog\Product\Composite\Fieldset\Options\Type\Multi diff --git a/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/RadioTest.php b/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/RadioTest.php index cc30028b302aa..81b8a6a3161a1 100644 --- a/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/RadioTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/RadioTest.php @@ -7,7 +7,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class RadioTest extends \PHPUnit_Framework_TestCase +class RadioTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Bundle\Block\Adminhtml\Catalog\Product\Composite\Fieldset\Options\Type\Radio diff --git a/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/SelectTest.php b/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/SelectTest.php index 79f28832da4ff..1eba793b6f592 100644 --- a/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/SelectTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Options/Type/SelectTest.php @@ -7,7 +7,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class SelectTest extends \PHPUnit_Framework_TestCase +class SelectTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Bundle\Block\Adminhtml\Catalog\Product\Composite\Fieldset\Options\Type\Select diff --git a/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Catalog/Product/Edit/Tab/Attributes/ExtendTest.php b/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Catalog/Product/Edit/Tab/Attributes/ExtendTest.php index 16f8f6b9d7099..9c91742db41c8 100644 --- a/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Catalog/Product/Edit/Tab/Attributes/ExtendTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Catalog/Product/Edit/Tab/Attributes/ExtendTest.php @@ -7,7 +7,7 @@ use Magento\Catalog\Model\Product; -class ExtendTest extends \PHPUnit_Framework_TestCase +class ExtendTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject */ protected $registry; @@ -55,16 +55,11 @@ public function testGetExtendedElement() { $switchAttributeCode = 'test_code'; $form = $this->getMockBuilder(\Magento\Framework\Data\Form::class)->disableOriginalConstructor()->getMock(); - $and = new \PHPUnit_Framework_Constraint_And(); - $and->setConstraints( - [ - new \PHPUnit_Framework_Constraint_ArrayHasKey('value') - ] - ); + $hasKey = new \PHPUnit\Framework\Constraint\ArrayHasKey('value'); $form->expects($this->once())->method('addField')->with( $switchAttributeCode, 'select', - $and + $hasKey ); $this->formFactory->expects($this->once())->method('create')->with()->will($this->returnValue($form)); diff --git a/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/OptionTest.php b/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/OptionTest.php index d3a3b8bf184cb..63c10d718842b 100644 --- a/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/OptionTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/OptionTest.php @@ -5,13 +5,13 @@ */ namespace Magento\Bundle\Test\Unit\Block\Adminhtml\Catalog\Product\Edit\Tab\Bundle; -class OptionTest extends \PHPUnit_Framework_TestCase +class OptionTest extends \PHPUnit\Framework\TestCase { public function testGetAddButtonId() { $button = new \Magento\Framework\DataObject(); - $itemsBlock = $this->getMock(\Magento\Framework\DataObject::class, ['getChildBlock']); + $itemsBlock = $this->createPartialMock(\Magento\Framework\DataObject::class, ['getChildBlock']); $itemsBlock->expects( $this->atLeastOnce() )->method( @@ -22,7 +22,7 @@ public function testGetAddButtonId() $this->returnValue($button) ); - $layout = $this->getMock(\Magento\Framework\DataObject::class, ['getBlock']); + $layout = $this->createPartialMock(\Magento\Framework\DataObject::class, ['getBlock']); $layout->expects( $this->atLeastOnce() )->method( @@ -33,12 +33,9 @@ public function testGetAddButtonId() $this->returnValue($itemsBlock) ); - $block = $this->getMock( + $block = $this->createPartialMock( \Magento\Bundle\Block\Adminhtml\Catalog\Product\Edit\Tab\Bundle\Option::class, - ['getLayout'], - [], - '', - false + ['getLayout'] ); $block->expects($this->atLeastOnce())->method('getLayout')->will($this->returnValue($layout)); diff --git a/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Sales/Order/Items/RendererTest.php b/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Sales/Order/Items/RendererTest.php index c85e3bc3cc3e4..414b460a1b81d 100644 --- a/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Sales/Order/Items/RendererTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Sales/Order/Items/RendererTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Bundle\Test\Unit\Block\Adminhtml\Sales\Order\Items; -class RendererTest extends \PHPUnit_Framework_TestCase +class RendererTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Sales\Model\Order\Item|\PHPUnit_Framework_MockObject_MockObject */ protected $orderItem; @@ -18,14 +18,11 @@ class RendererTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->orderItem = $this->getMock( + $this->orderItem = $this->createPartialMock( \Magento\Sales\Model\Order\Item::class, - ['getProductOptions', '__wakeup', 'getParentItem', 'getOrderItem', 'getOrderItemId', 'getId'], - [], - '', - false + ['getProductOptions', '__wakeup', 'getParentItem', 'getOrderItem', 'getOrderItemId', 'getId'] ); - $this->serializer = $this->getMock(\Magento\Framework\Serialize\Serializer\Json::class); + $this->serializer = $this->createMock(\Magento\Framework\Serialize\Serializer\Json::class); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManager->getObject( \Magento\Bundle\Block\Adminhtml\Sales\Order\Items\Renderer::class, @@ -38,10 +35,10 @@ protected function setUp() */ public function testGetChildrenEmptyItems($class, $method, $returnClass) { - $salesModel = $this->getMock($returnClass, ['getAllItems', '__wakeup'], [], '', false); + $salesModel = $this->createPartialMock($returnClass, ['getAllItems', '__wakeup']); $salesModel->expects($this->once())->method('getAllItems')->will($this->returnValue([])); - $item = $this->getMock($class, [$method, 'getOrderItem', '__wakeup'], [], '', false); + $item = $this->createPartialMock($class, [$method, 'getOrderItem', '__wakeup']); $item->expects($this->once())->method($method)->will($this->returnValue($salesModel)); $item->expects($this->once())->method('getOrderItem')->will($this->returnValue($this->orderItem)); $this->orderItem->expects($this->any())->method('getId')->will($this->returnValue(1)); @@ -76,7 +73,7 @@ public function getChildrenEmptyItemsDataProvider() public function testGetChildren($parentItem) { if ($parentItem) { - $parentItem = $this->getMock(\Magento\Sales\Model\Order\Item::class, ['getId', '__wakeup'], [], '', false); + $parentItem = $this->createPartialMock(\Magento\Sales\Model\Order\Item::class, ['getId', '__wakeup']); $parentItem->expects($this->any())->method('getId')->will($this->returnValue(1)); } $this->orderItem->expects($this->any())->method('getOrderItem')->will($this->returnSelf()); @@ -84,22 +81,15 @@ public function testGetChildren($parentItem) $this->orderItem->expects($this->any())->method('getOrderItemId')->will($this->returnValue(2)); $this->orderItem->expects($this->any())->method('getId')->will($this->returnValue(1)); - $salesModel = $this->getMock( + $salesModel = $this->createPartialMock( \Magento\Sales\Model\Order\Invoice::class, - ['getAllItems', - '__wakeup'], - [], - '', - false + ['getAllItems', '__wakeup'] ); $salesModel->expects($this->once())->method('getAllItems')->will($this->returnValue([$this->orderItem])); - $item = $this->getMock( + $item = $this->createPartialMock( \Magento\Sales\Model\Order\Invoice\Item::class, - ['getInvoice', 'getOrderItem', '__wakeup'], - [], - '', - false + ['getInvoice', 'getOrderItem', '__wakeup'] ); $item->expects($this->once())->method('getInvoice')->will($this->returnValue($salesModel)); $item->expects($this->any())->method('getOrderItem')->will($this->returnValue($this->orderItem)); @@ -142,14 +132,8 @@ public function testIsShipmentSeparatelyWithItem($productOptions, $result, $pare { if ($parentItem) { $parentItem = - $this->getMock( - \Magento\Sales\Model\Order\Item::class, - ['getProductOptions', - '__wakeup'], - [], - '', - false - ); + $this->createPartialMock(\Magento\Sales\Model\Order\Item::class, ['getProductOptions', + '__wakeup']); $parentItem->expects($this->any())->method('getProductOptions')->will($this->returnValue($productOptions)); } else { $this->orderItem->expects($this->any())->method('getProductOptions') @@ -198,14 +182,8 @@ public function testIsChildCalculatedWithItem($productOptions, $result, $parentI { if ($parentItem) { $parentItem = - $this->getMock( - \Magento\Sales\Model\Order\Item::class, - ['getProductOptions', - '__wakeup'], - [], - '', - false - ); + $this->createPartialMock(\Magento\Sales\Model\Order\Item::class, ['getProductOptions', + '__wakeup']); $parentItem->expects($this->any())->method('getProductOptions')->will($this->returnValue($productOptions)); } else { $this->orderItem->expects($this->any())->method('getProductOptions') diff --git a/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Sales/Order/View/Items/RendererTest.php b/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Sales/Order/View/Items/RendererTest.php index 974c46a20dc0d..95dcb48f84be1 100644 --- a/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Sales/Order/View/Items/RendererTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Sales/Order/View/Items/RendererTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Bundle\Test\Unit\Block\Adminhtml\Sales\Order\View\Items; -class RendererTest extends \PHPUnit_Framework_TestCase +class RendererTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Sales\Model\Order\Item|\PHPUnit_Framework_MockObject_MockObject */ protected $orderItem; @@ -18,14 +18,11 @@ class RendererTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->orderItem = $this->getMock( + $this->orderItem = $this->createPartialMock( \Magento\Sales\Model\Order\Item::class, - ['getProductOptions', '__wakeup', 'getParentItem', 'getOrderItem'], - [], - '', - false + ['getProductOptions', '__wakeup', 'getParentItem', 'getOrderItem'] ); - $this->serializer = $this->getMock(\Magento\Framework\Serialize\Serializer\Json::class); + $this->serializer = $this->createMock(\Magento\Framework\Serialize\Serializer\Json::class); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManager->getObject( \Magento\Bundle\Block\Adminhtml\Sales\Order\View\Items\Renderer::class, @@ -60,14 +57,8 @@ public function testIsShipmentSeparatelyWithItem($productOptions, $result, $pare { if ($parentItem) { $parentItem = - $this->getMock( - \Magento\Sales\Model\Order\Item::class, - ['getProductOptions', - '__wakeup'], - [], - '', - false - ); + $this->createPartialMock(\Magento\Sales\Model\Order\Item::class, ['getProductOptions', + '__wakeup']); $parentItem->expects($this->any())->method('getProductOptions')->will($this->returnValue($productOptions)); } else { $this->orderItem->expects($this->any())->method('getProductOptions') @@ -116,14 +107,8 @@ public function testIsChildCalculatedWithItem($productOptions, $result, $parentI { if ($parentItem) { $parentItem = - $this->getMock( - \Magento\Sales\Model\Order\Item::class, - ['getProductOptions', - '__wakeup'], - [], - '', - false - ); + $this->createPartialMock(\Magento\Sales\Model\Order\Item::class, ['getProductOptions', + '__wakeup']); $parentItem->expects($this->any())->method('getProductOptions')->will($this->returnValue($productOptions)); } else { $this->orderItem->expects($this->any())->method('getProductOptions') diff --git a/app/code/Magento/Bundle/Test/Unit/Block/Catalog/Product/View/Type/Bundle/OptionTest.php b/app/code/Magento/Bundle/Test/Unit/Block/Catalog/Product/View/Type/Bundle/OptionTest.php index 4e7f936b0f02d..5e0349e88e095 100644 --- a/app/code/Magento/Bundle/Test/Unit/Block/Catalog/Product/View/Type/Bundle/OptionTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Block/Catalog/Product/View/Type/Bundle/OptionTest.php @@ -8,7 +8,7 @@ namespace Magento\Bundle\Test\Unit\Block\Catalog\Product\View\Type\Bundle; -class OptionTest extends \PHPUnit_Framework_TestCase +class OptionTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Option @@ -41,7 +41,7 @@ protected function setUp() ->with('current_product') ->will($this->returnValue($this->product)); - $this->layout = $this->getMock(\Magento\Framework\View\LayoutInterface::class); + $this->layout = $this->createMock(\Magento\Framework\View\LayoutInterface::class); $context = $this->getMockBuilder(\Magento\Framework\View\Element\Template\Context::class) ->disableOriginalConstructor() @@ -69,7 +69,7 @@ public function testSetOption() new \Magento\Framework\DataObject(['bundle_option' => [15 => 315, 16 => 316]])) ); - $option = $this->getMock(\Magento\Bundle\Model\Option::class, [], [], '', false); + $option = $this->createMock(\Magento\Bundle\Model\Option::class); $option->expects($this->any())->method('getId')->will($this->returnValue(15)); $otherOption = $this->getMockBuilder(\Magento\Bundle\Model\Option::class) @@ -77,19 +77,13 @@ public function testSetOption() ->getMock(); $otherOption->expects($this->any())->method('getId')->will($this->returnValue(16)); - $selection = $this->getMock( + $selection = $this->createPartialMock( \Magento\Catalog\Model\Product::class, - ['getSelectionId', '__wakeup'], - [], - '', - false + ['getSelectionId', '__wakeup'] ); - $otherSelection = $this->getMock( + $otherSelection = $this->createPartialMock( \Magento\Catalog\Model\Product::class, - ['getSelectionId', '__wakeup'], - [], - '', - false + ['getSelectionId', '__wakeup'] ); $otherOption->expects($this->any())->method('getSelectionById')->willReturn($selection); $selection->expects($this->atLeastOnce())->method('getSelectionId')->willReturn($selectionId); @@ -117,8 +111,8 @@ public function testRenderPriceString() ->disableOriginalConstructor() ->getMock(); - $priceInfo = $this->getMock(\Magento\Framework\Pricing\PriceInfo\Base::class, [], [], '', false); - $amount = $this->getMock(\Magento\Framework\Pricing\Amount\AmountInterface::class); + $priceInfo = $this->createMock(\Magento\Framework\Pricing\PriceInfo\Base::class); + $amount = $this->createMock(\Magento\Framework\Pricing\Amount\AmountInterface::class); $priceRenderBlock = $this->getMockBuilder(\Magento\Framework\Pricing\Render::class) ->disableOriginalConstructor() diff --git a/app/code/Magento/Bundle/Test/Unit/Block/Catalog/Product/View/Type/BundleTest.php b/app/code/Magento/Bundle/Test/Unit/Block/Catalog/Product/View/Type/BundleTest.php index 659bfb8e3ce2b..97e8098b8181e 100644 --- a/app/code/Magento/Bundle/Test/Unit/Block/Catalog/Product/View/Type/BundleTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Block/Catalog/Product/View/Type/BundleTest.php @@ -10,7 +10,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class BundleTest extends \PHPUnit_Framework_TestCase +class BundleTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Bundle\Model\Product\PriceFactory|\PHPUnit_Framework_MockObject_MockObject @@ -461,6 +461,17 @@ private function createOptionSelection( $isSalable = true ) { $selection = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) + ->setMethods( + [ + 'getSelectionId', + 'getName', + 'getSelectionQty', + 'getPriceInfo', + 'getSelectionCanChangeQty', + 'getIsDefault', + 'isSalable' + ] + ) ->disableOriginalConstructor() ->getMock(); $tierPrice = $this->getMockBuilder(\Magento\Bundle\Pricing\Price\TierPrice::class) @@ -514,7 +525,7 @@ public function testGetOptions($stripSelection) ->willReturn($selectionConnection); $this->product->expects($this->any()) ->method('getTypeInstance')->willReturn($typeInstance); - $this->product->expects($this->any())->method('getStoreId') ->willReturn(0); + $this->product->expects($this->any())->method('getStoreId')->willReturn(0); $this->catalogProduct->expects($this->once())->method('getSkipSaleableCheck')->willReturn(true); $this->assertEquals($newOptions, $this->bundleBlock->getOptions($stripSelection)); diff --git a/app/code/Magento/Bundle/Test/Unit/Block/Sales/Order/Items/RendererTest.php b/app/code/Magento/Bundle/Test/Unit/Block/Sales/Order/Items/RendererTest.php index 7af948c119ef1..d79afdddfb7ae 100644 --- a/app/code/Magento/Bundle/Test/Unit/Block/Sales/Order/Items/RendererTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Block/Sales/Order/Items/RendererTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Bundle\Test\Unit\Block\Sales\Order\Items; -class RendererTest extends \PHPUnit_Framework_TestCase +class RendererTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Sales\Model\Order\Item|\PHPUnit_Framework_MockObject_MockObject */ protected $orderItem; @@ -18,15 +18,12 @@ class RendererTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->orderItem = $this->getMock( + $this->orderItem = $this->createPartialMock( \Magento\Sales\Model\Order\Item::class, - ['getProductOptions', '__wakeup', 'getParentItem', 'getOrderItem', 'getOrderItemId', 'getId'], - [], - '', - false + ['getProductOptions', '__wakeup', 'getParentItem', 'getOrderItem', 'getOrderItemId', 'getId'] ); - $this->serializer = $this->getMock(\Magento\Framework\Serialize\Serializer\Json::class); + $this->serializer = $this->createMock(\Magento\Framework\Serialize\Serializer\Json::class); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManager->getObject( \Magento\Bundle\Block\Sales\Order\Items\Renderer::class, @@ -39,10 +36,10 @@ protected function setUp() */ public function testGetChildrenEmptyItems($class, $method, $returnClass) { - $salesModel = $this->getMock($returnClass, ['getAllItems', '__wakeup'], [], '', false); + $salesModel = $this->createPartialMock($returnClass, ['getAllItems', '__wakeup']); $salesModel->expects($this->once())->method('getAllItems')->will($this->returnValue([])); - $item = $this->getMock($class, [$method, 'getOrderItem', '__wakeup'], [], '', false); + $item = $this->createPartialMock($class, [$method, 'getOrderItem', '__wakeup']); $item->expects($this->once())->method($method)->will($this->returnValue($salesModel)); $item->expects($this->once())->method('getOrderItem')->will($this->returnValue($this->orderItem)); $this->orderItem->expects($this->any())->method('getId')->will($this->returnValue(1)); @@ -77,7 +74,7 @@ public function getChildrenEmptyItemsDataProvider() public function testGetChildren($parentItem) { if ($parentItem) { - $parentItem = $this->getMock(\Magento\Sales\Model\Order\Item::class, ['getId', '__wakeup'], [], '', false); + $parentItem = $this->createPartialMock(\Magento\Sales\Model\Order\Item::class, ['getId', '__wakeup']); $parentItem->expects($this->any())->method('getId')->will($this->returnValue(1)); } $this->orderItem->expects($this->any())->method('getOrderItem')->will($this->returnSelf()); @@ -85,22 +82,13 @@ public function testGetChildren($parentItem) $this->orderItem->expects($this->any())->method('getOrderItemId')->will($this->returnValue(2)); $this->orderItem->expects($this->any())->method('getId')->will($this->returnValue(1)); - $salesModel = $this->getMock( - \Magento\Sales\Model\Order\Invoice::class, - ['getAllItems', - '__wakeup'], - [], - '', - false - ); + $salesModel = $this->createPartialMock(\Magento\Sales\Model\Order\Invoice::class, ['getAllItems', + '__wakeup']); $salesModel->expects($this->once())->method('getAllItems')->will($this->returnValue([$this->orderItem])); - $item = $this->getMock( + $item = $this->createPartialMock( \Magento\Sales\Model\Order\Invoice\Item::class, - ['getInvoice', 'getOrderItem', '__wakeup'], - [], - '', - false + ['getInvoice', 'getOrderItem', '__wakeup'] ); $item->expects($this->once())->method('getInvoice')->will($this->returnValue($salesModel)); $item->expects($this->any())->method('getOrderItem')->will($this->returnValue($this->orderItem)); @@ -143,14 +131,8 @@ public function testIsShipmentSeparatelyWithItem($productOptions, $result, $pare { if ($parentItem) { $parentItem = - $this->getMock( - \Magento\Sales\Model\Order\Item::class, - ['getProductOptions', - '__wakeup'], - [], - '', - false - ); + $this->createPartialMock(\Magento\Sales\Model\Order\Item::class, ['getProductOptions', + '__wakeup']); $parentItem->expects($this->any())->method('getProductOptions')->will($this->returnValue($productOptions)); } else { $this->orderItem->expects($this->any())->method('getProductOptions') @@ -199,14 +181,8 @@ public function testIsChildCalculatedWithItem($productOptions, $result, $parentI { if ($parentItem) { $parentItem = - $this->getMock( - \Magento\Sales\Model\Order\Item::class, - ['getProductOptions', - '__wakeup'], - [], - '', - false - ); + $this->createPartialMock(\Magento\Sales\Model\Order\Item::class, ['getProductOptions', + '__wakeup']); $parentItem->expects($this->any())->method('getProductOptions')->will($this->returnValue($productOptions)); } else { $this->orderItem->expects($this->any())->method('getProductOptions') diff --git a/app/code/Magento/Bundle/Test/Unit/Controller/Adminhtml/Bundle/Product/Edit/FormTest.php b/app/code/Magento/Bundle/Test/Unit/Controller/Adminhtml/Bundle/Product/Edit/FormTest.php index 580043b845b85..e2a1b70729700 100644 --- a/app/code/Magento/Bundle/Test/Unit/Controller/Adminhtml/Bundle/Product/Edit/FormTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Controller/Adminhtml/Bundle/Product/Edit/FormTest.php @@ -11,7 +11,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class FormTest extends \PHPUnit_Framework_TestCase +class FormTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Bundle\Controller\Adminhtml\Bundle\Product\Edit\Form */ protected $controller; @@ -56,8 +56,8 @@ protected function setUp() $this->context = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class) ->disableOriginalConstructor() ->getMock(); - $this->request = $this->getMock(\Magento\Framework\App\RequestInterface::class); - $this->response = $this->getMock( + $this->request = $this->createMock(\Magento\Framework\App\RequestInterface::class); + $this->response = $this->createPartialMock( \Magento\Framework\App\ResponseInterface::class, [ 'sendResponse', @@ -74,7 +74,7 @@ protected function setUp() ->disableOriginalConstructor() ->setMethods(['initialize']) ->getMock(); - $this->view = $this->getMock(\Magento\Framework\App\ViewInterface::class); + $this->view = $this->createMock(\Magento\Framework\App\ViewInterface::class); $this->context->expects($this->any()) ->method('getRequest') @@ -102,7 +102,7 @@ public function testExecute() ->disableOriginalConstructor() ->setMethods(['_wakeup', 'getId']) ->getMock(); - $layout = $this->getMock(\Magento\Framework\View\LayoutInterface::class); + $layout = $this->createMock(\Magento\Framework\View\LayoutInterface::class); $block = $this->getMockBuilder(\Magento\Bundle\Block\Adminhtml\Catalog\Product\Edit\Tab\Bundle::class) ->disableOriginalConstructor() ->setMethods(['setIndex', 'toHtml']) diff --git a/app/code/Magento/Bundle/Test/Unit/Controller/Adminhtml/Bundle/Selection/GridTest.php b/app/code/Magento/Bundle/Test/Unit/Controller/Adminhtml/Bundle/Selection/GridTest.php index bcba32cb80491..19ef3151491ad 100644 --- a/app/code/Magento/Bundle/Test/Unit/Controller/Adminhtml/Bundle/Selection/GridTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Controller/Adminhtml/Bundle/Selection/GridTest.php @@ -8,7 +8,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -class GridTest extends \PHPUnit_Framework_TestCase +class GridTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Bundle\Controller\Adminhtml\Bundle\Selection\Grid */ protected $controller; @@ -43,15 +43,15 @@ protected function setUp() $this->context = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class) ->disableOriginalConstructor() ->getMock(); - $this->request = $this->getMock(\Magento\Framework\App\RequestInterface::class); - $this->response = $this->getMock( + $this->request = $this->createMock(\Magento\Framework\App\RequestInterface::class); + $this->response = $this->createPartialMock( \Magento\Framework\App\ResponseInterface::class, [ 'sendResponse', 'setBody' ] ); - $this->view = $this->getMock(\Magento\Framework\App\ViewInterface::class); + $this->view = $this->createMock(\Magento\Framework\App\ViewInterface::class); $this->context->expects($this->any()) ->method('getRequest') @@ -73,7 +73,7 @@ protected function setUp() public function testExecute() { - $layout = $this->getMock(\Magento\Framework\View\LayoutInterface::class); + $layout = $this->createMock(\Magento\Framework\View\LayoutInterface::class); $block = $this->getMockBuilder( \Magento\Bundle\Block\Adminhtml\Catalog\Product\Edit\Tab\Bundle\Option\Search\Grid::class ) diff --git a/app/code/Magento/Bundle/Test/Unit/Controller/Adminhtml/Bundle/Selection/SearchTest.php b/app/code/Magento/Bundle/Test/Unit/Controller/Adminhtml/Bundle/Selection/SearchTest.php index 6175a916eb642..baef6996df500 100644 --- a/app/code/Magento/Bundle/Test/Unit/Controller/Adminhtml/Bundle/Selection/SearchTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Controller/Adminhtml/Bundle/Selection/SearchTest.php @@ -8,7 +8,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -class SearchTest extends \PHPUnit_Framework_TestCase +class SearchTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Bundle\Controller\Adminhtml\Bundle\Selection\Search */ protected $controller; @@ -43,15 +43,15 @@ protected function setUp() $this->context = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class) ->disableOriginalConstructor() ->getMock(); - $this->request = $this->getMock(\Magento\Framework\App\RequestInterface::class); - $this->response = $this->getMock( + $this->request = $this->createMock(\Magento\Framework\App\RequestInterface::class); + $this->response = $this->createPartialMock( \Magento\Framework\App\ResponseInterface::class, [ 'sendResponse', 'setBody' ] ); - $this->view = $this->getMock(\Magento\Framework\App\ViewInterface::class); + $this->view = $this->createMock(\Magento\Framework\App\ViewInterface::class); $this->context->expects($this->any()) ->method('getRequest') @@ -73,7 +73,7 @@ protected function setUp() public function testExecute() { - $layout = $this->getMock(\Magento\Framework\View\LayoutInterface::class); + $layout = $this->createMock(\Magento\Framework\View\LayoutInterface::class); $block = $this->getMockBuilder( \Magento\Bundle\Block\Adminhtml\Catalog\Product\Edit\Tab\Bundle\Option\Search::class )->disableOriginalConstructor() diff --git a/app/code/Magento/Bundle/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/BundleTest.php b/app/code/Magento/Bundle/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/BundleTest.php index 29069d0d952e7..1de5db9d25a23 100644 --- a/app/code/Magento/Bundle/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/BundleTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/BundleTest.php @@ -7,7 +7,7 @@ */ namespace Magento\Bundle\Test\Unit\Controller\Adminhtml\Product\Initialization\Helper\Plugin; -class BundleTest extends \PHPUnit_Framework_TestCase +class BundleTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Bundle\Controller\Adminhtml\Product\Initialization\Helper\Plugin\Bundle @@ -46,7 +46,7 @@ class BundleTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); + $this->requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class); $methods = [ 'getCompositeReadonly', 'setBundleOptionsData', @@ -57,8 +57,9 @@ protected function setUp() 'setOptions', 'setCanSaveBundleSelections', '__wakeup', + 'getOptionsReadonly' ]; - $this->productMock = $this->getMock(\Magento\Catalog\Model\Product::class, $methods, [], '', false); + $this->productMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, $methods); $optionInterfaceFactory = $this->getMockBuilder(\Magento\Bundle\Api\Data\OptionInterfaceFactory::class) ->disableOriginalConstructor() ->getMock(); @@ -74,12 +75,8 @@ protected function setUp() $customOptionFactory = $this->getMockBuilder( \Magento\Catalog\Api\Data\ProductCustomOptionInterfaceFactory::class )->disableOriginalConstructor()->getMock(); - $this->subjectMock = $this->getMock( - \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper::class, - [], - [], - '', - false + $this->subjectMock = $this->createMock( + \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper::class ); $this->model = new \Magento\Bundle\Controller\Adminhtml\Product\Initialization\Helper\Plugin\Bundle( $this->requestMock, diff --git a/app/code/Magento/Bundle/Test/Unit/Helper/Catalog/Product/ConfigurationTest.php b/app/code/Magento/Bundle/Test/Unit/Helper/Catalog/Product/ConfigurationTest.php index ee96bbd0fb79a..79226f77c576c 100644 --- a/app/code/Magento/Bundle/Test/Unit/Helper/Catalog/Product/ConfigurationTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Helper/Catalog/Product/ConfigurationTest.php @@ -10,7 +10,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ConfigurationTest extends \PHPUnit_Framework_TestCase +class ConfigurationTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\Pricing\Helper\Data|\PHPUnit_Framework_MockObject_MockObject @@ -44,32 +44,15 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->pricingHelper = $this->getMock( - \Magento\Framework\Pricing\Helper\Data::class, - ['currency'], - [], - '', - false - ); - $this->productConfiguration = $this->getMock( - \Magento\Catalog\Helper\Product\Configuration::class, - [], - [], - '', - false - ); - $this->escaper = $this->getMock( - \Magento\Framework\Escaper::class, - ['escapeHtml'], - [], - '', - false - ); - $this->item = $this->getMock( + $this->pricingHelper = $this->createPartialMock(\Magento\Framework\Pricing\Helper\Data::class, ['currency']); + $this->productConfiguration = $this->createMock(\Magento\Catalog\Helper\Product\Configuration::class); + $this->escaper = $this->createPartialMock(\Magento\Framework\Escaper::class, ['escapeHtml']); + $this->item = $this->createPartialMock( \Magento\Catalog\Model\Product\Configuration\Item\ItemInterface::class, ['getQty', 'getProduct', 'getOptionByCode', 'getFileDownloadParams'] ); $this->serializer = $this->getMockBuilder(\Magento\Framework\Serialize\Serializer\Json::class) + ->setMethods(['unserialize']) ->getMockForAbstractClass(); $this->serializer->expects($this->any()) @@ -95,20 +78,8 @@ public function testGetSelectionQty() { $selectionId = 15; $selectionQty = 35; - $product = $this->getMock( - \Magento\Catalog\Model\Product::class, - [], - [], - '', - false - ); - $option = $this->getMock( - \Magento\Catalog\Model\Product\Option::class, - ['__wakeup', 'getValue'], - [], - '', - false - ); + $product = $this->createMock(\Magento\Catalog\Model\Product::class); + $option = $this->createPartialMock(\Magento\Catalog\Model\Product\Option::class, ['__wakeup', 'getValue']); $product->expects($this->once()) ->method('getCustomOption') @@ -124,7 +95,7 @@ public function testGetSelectionQty() public function testGetSelectionQtyIfCustomOptionIsNotSet() { $selectionId = 15; - $product = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $product = $this->createMock(\Magento\Catalog\Model\Product::class); $product->expects($this->once())->method('getCustomOption')->with('selection_qty_' . $selectionId) ->will($this->returnValue(null)); @@ -136,9 +107,9 @@ public function testGetSelectionFinalPrice() { $itemQty = 2; - $product = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); - $price = $this->getMock(\Magento\Bundle\Model\Product\Price::class, [], [], '', false); - $selectionProduct = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $product = $this->createMock(\Magento\Catalog\Model\Product::class); + $price = $this->createMock(\Magento\Bundle\Model\Product\Price::class); + $selectionProduct = $this->createMock(\Magento\Catalog\Model\Product::class); $selectionProduct->expects($this->once())->method('unsetData')->with('final_price'); $this->item->expects($this->once())->method('getProduct')->will($this->returnValue($product)); @@ -152,15 +123,9 @@ public function testGetSelectionFinalPrice() public function testGetBundleOptionsEmptyBundleOptionsIds() { - $typeInstance = $this->getMock(\Magento\Bundle\Model\Product\Type::class, [], [], '', false); - $product = $this->getMock( - \Magento\Catalog\Model\Product::class, - ['getTypeInstance', - '__wakeup'], - [], - '', - false - ); + $typeInstance = $this->createMock(\Magento\Bundle\Model\Product\Type::class); + $product = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['getTypeInstance', + '__wakeup']); $product->expects($this->once())->method('getTypeInstance')->will($this->returnValue($typeInstance)); $this->item->expects($this->once())->method('getProduct')->will($this->returnValue($product)); @@ -173,33 +138,15 @@ public function testGetBundleOptionsEmptyBundleOptionsIds() public function testGetBundleOptionsEmptyBundleSelectionIds() { $optionIds = '{"0":"1"}'; - $collection = $this->getMock( - \Magento\Bundle\Model\ResourceModel\Option\Collection::class, - [], - [], - '', - false - ); - $product = $this->getMock( - \Magento\Catalog\Model\Product::class, - ['getTypeInstance', - '__wakeup'], - [], - '', - false - ); - $typeInstance = $this->getMock( - \Magento\Bundle\Model\Product\Type::class, - ['getOptionsByIds'], - [], - '', - false - ); - $selectionOption = $this->getMock( + $collection = $this->createMock(\Magento\Bundle\Model\ResourceModel\Option\Collection::class); + $product = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['getTypeInstance', + '__wakeup']); + $typeInstance = $this->createPartialMock(\Magento\Bundle\Model\Product\Type::class, ['getOptionsByIds']); + $selectionOption = $this->createPartialMock( \Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface::class, ['getValue'] ); - $itemOption = $this->getMock( + $itemOption = $this->createPartialMock( \Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface::class, ['getValue'] ); @@ -243,65 +190,43 @@ public function testGetOptions() $optionIds = '{"0":"1"}'; $selectionIds = '{"0":"2"}'; $selectionId = '2'; - $product = $this->getMock( + $product = $this->createPartialMock( \Magento\Catalog\Model\Product::class, - ['getTypeInstance', '__wakeup', 'getCustomOption', 'getSelectionId', 'getName', 'getPriceModel'], - [], - '', - false + ['getTypeInstance', '__wakeup', 'getCustomOption', 'getSelectionId', 'getName', 'getPriceModel'] ); - $typeInstance = $this->getMock( + $typeInstance = $this->createPartialMock( \Magento\Bundle\Model\Product\Type::class, - ['getOptionsByIds', 'getSelectionsByIds'], - [], - '', - false + ['getOptionsByIds', 'getSelectionsByIds'] ); - $priceModel = $this->getMock( + $priceModel = $this->createPartialMock( \Magento\Bundle\Model\Product\Price::class, - ['getSelectionFinalTotalPrice'], - [], - '', - false + ['getSelectionFinalTotalPrice'] ); - $selectionQty = $this->getMock( + $selectionQty = $this->createPartialMock( \Magento\Quote\Model\Quote\Item\Option::class, - ['getValue', '__wakeup'], - [], - '', - false + ['getValue', '__wakeup'] ); - $bundleOption = $this->getMock( + $bundleOption = $this->createPartialMock( \Magento\Bundle\Model\Option::class, - ['getSelections', - 'getTitle', - '__wakeup'], - [], - '', - false + [ + 'getSelections', + 'getTitle', + '__wakeup' + ] ); - $selectionOption = $this->getMock( + $selectionOption = $this->createPartialMock( \Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface::class, ['getValue'] ); - $collection = $this->getMock( + $collection = $this->createPartialMock( \Magento\Bundle\Model\ResourceModel\Option\Collection::class, - ['appendSelections'], - [], - '', - false + ['appendSelections'] ); - $itemOption = $this->getMock( + $itemOption = $this->createPartialMock( \Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface::class, ['getValue'] ); - $collection2 = $this->getMock( - \Magento\Bundle\Model\ResourceModel\Selection\Collection::class, - [], - [], - '', - false - ); + $collection2 = $this->createMock(\Magento\Bundle\Model\ResourceModel\Selection\Collection::class); $this->escaper->expects($this->once()) ->method('escapeHtml') diff --git a/app/code/Magento/Bundle/Test/Unit/Helper/DataTest.php b/app/code/Magento/Bundle/Test/Unit/Helper/DataTest.php index 1eed58b66c58e..48e574aebc205 100644 --- a/app/code/Magento/Bundle/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Helper/DataTest.php @@ -7,7 +7,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class DataTest extends \PHPUnit_Framework_TestCase +class DataTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Catalog\Model\ProductTypes\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject @@ -21,7 +21,7 @@ class DataTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->config = $this->getMock(\Magento\Catalog\Model\ProductTypes\ConfigInterface::class); + $this->config = $this->createMock(\Magento\Catalog\Model\ProductTypes\ConfigInterface::class); $this->helper = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject( \Magento\Bundle\Helper\Data::class, ['config' => $this->config] diff --git a/app/code/Magento/Bundle/Test/Unit/Model/CartItemProcessorTest.php b/app/code/Magento/Bundle/Test/Unit/Model/CartItemProcessorTest.php index 4668eb135da52..a8616df0b1149 100644 --- a/app/code/Magento/Bundle/Test/Unit/Model/CartItemProcessorTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Model/CartItemProcessorTest.php @@ -7,7 +7,7 @@ use Magento\Catalog\Model\Product\Type; -class CartItemProcessorTest extends \PHPUnit_Framework_TestCase +class CartItemProcessorTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -36,33 +36,20 @@ class CartItemProcessorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectFactoryMock = $this->getMock( - \Magento\Framework\DataObject\Factory::class, - ['create'], - [], - '', - false - ); - $this->productOptionExtensionMock = $this->getMock( - \Magento\Quote\Api\Data\ProductOptionExtensionFactory::class, - ['create'], - [], - '', - false - ); - $this->bundleOptionFactoryMock = $this->getMock( + $this->objectFactoryMock = $this->createPartialMock(\Magento\Framework\DataObject\Factory::class, ['create']); + $this->productOptionExtensionMock = $this->getMockBuilder( + \Magento\Quote\Api\Data\ProductOptionExtensionFactory::class + ) + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $this->bundleOptionFactoryMock = $this->createPartialMock( \Magento\Bundle\Api\Data\BundleOptionInterfaceFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->productOptionFactoryMock = $this->getMock( + $this->productOptionFactoryMock = $this->createPartialMock( \Magento\Quote\Api\Data\ProductOptionInterfaceFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->model = new \Magento\Bundle\Model\CartItemProcessor( @@ -79,26 +66,24 @@ public function testConvertToBuyRequest() $optionQty = 1; $optionId = 4; - $bundleOptionMock = $this->getMock(\Magento\Bundle\Model\BundleOption::class, [], [], '', false); - $cartItemMock = $this->getMock(\Magento\Quote\Model\Quote\Item::class, [], [], '', false); - $productOptionMock = $this->getMock(\Magento\Quote\Model\Quote\ProductOption::class, [], [], '', false); - $dataObjectMock = $this->getMock(\Magento\Framework\DataObject::class); - $optionExtensionMock = $this->getMock( - \Magento\Quote\Api\Data\ProductOptionExtensionInterface::class, - [ - 'getBundleOptions', - 'getCustomOptions', - 'setCustomOptions', - 'setBundleOptions', - 'getDownloadableOption', - 'setDownloadableOption', - 'getConfigurableItemOptions', - 'setConfigurableItemOptions' - ], - [], - '', - false - ); + $bundleOptionMock = $this->createMock(\Magento\Bundle\Model\BundleOption::class); + $cartItemMock = $this->createMock(\Magento\Quote\Model\Quote\Item::class); + $productOptionMock = $this->createMock(\Magento\Quote\Model\Quote\ProductOption::class); + $dataObjectMock = $this->createMock(\Magento\Framework\DataObject::class); + $optionExtensionMock = $this->getMockBuilder(\Magento\Quote\Api\Data\ProductOptionExtensionInterface::class) + ->setMethods( + [ + 'getBundleOptions', + 'getCustomOptions', + 'setCustomOptions', + 'setBundleOptions', + 'getDownloadableOption', + 'setDownloadableOption', + 'getConfigurableItemOptions', + 'setConfigurableItemOptions' + ] + ) + ->getMockForAbstractClass(); $requestDataMock = [ 'bundle_option' => [$optionId => $optionSelections], 'bundle_option_qty' => [$optionId => $optionQty] @@ -120,7 +105,7 @@ public function testConvertToBuyRequest() public function testConvertToBuyRequestInvalidData() { - $cartItemMock = $this->getMock(\Magento\Quote\Model\Quote\Item::class, [], [], '', false); + $cartItemMock = $this->createMock(\Magento\Quote\Model\Quote\Item::class); $this->assertNull($this->model->convertToBuyRequest($cartItemMock)); } @@ -138,25 +123,23 @@ public function testProcessProductOptions() 'bundle_option_qty' => $bundleOptionQty ] ); - $cartItemMock = $this->getMock(\Magento\Quote\Model\Quote\Item::class, [], [], '', false); - $bundleOptionMock = $this->getMock(\Magento\Bundle\Model\BundleOption::class, [], [], '', false); - $productOptionMock = $this->getMock(\Magento\Quote\Model\Quote\ProductOption::class, [], [], '', false); - $optionExtensionMock = $this->getMock( - \Magento\Quote\Api\Data\ProductOptionExtensionInterface::class, - [ - 'getBundleOptions', - 'getCustomOptions', - 'setCustomOptions', - 'setBundleOptions', - 'getDownloadableOption', - 'setDownloadableOption', - 'getConfigurableItemOptions', - 'setConfigurableItemOptions' - ], - [], - '', - false - ); + $cartItemMock = $this->createMock(\Magento\Quote\Model\Quote\Item::class); + $bundleOptionMock = $this->createMock(\Magento\Bundle\Model\BundleOption::class); + $productOptionMock = $this->createMock(\Magento\Quote\Model\Quote\ProductOption::class); + $optionExtensionMock = $this->getMockBuilder(\Magento\Quote\Api\Data\ProductOptionExtensionInterface::class) + ->setMethods( + [ + 'getBundleOptions', + 'getCustomOptions', + 'setCustomOptions', + 'setBundleOptions', + 'getDownloadableOption', + 'setDownloadableOption', + 'getConfigurableItemOptions', + 'setConfigurableItemOptions' + ] + ) + ->getMockForAbstractClass(); $cartItemMock->expects($this->once())->method('getProductType')->willReturn(Type::TYPE_BUNDLE); $cartItemMock->expects($this->atLeastOnce())->method('getBuyRequest')->willReturn($buyRequestMock); @@ -176,7 +159,7 @@ public function testProcessProductOptions() public function testProcessProductOptionsInvalidType() { - $cartItemMock = $this->getMock(\Magento\Quote\Model\Quote\Item::class, ['getProductType'], [], '', false); + $cartItemMock = $this->createPartialMock(\Magento\Quote\Model\Quote\Item::class, ['getProductType']); $cartItemMock->expects($this->once())->method('getProductType')->willReturn(Type::TYPE_SIMPLE); $this->assertSame($cartItemMock, $this->model->processOptions($cartItemMock)); } @@ -187,12 +170,9 @@ public function testProcessProductOptionsifBundleOptionsNotExists() [] ); $methods = ['getProductType', 'getBuyRequest']; - $cartItemMock = $this->getMock( + $cartItemMock = $this->createPartialMock( \Magento\Quote\Model\Quote\Item::class, - $methods, - [], - '', - false + $methods ); $cartItemMock->expects($this->once())->method('getProductType')->willReturn(Type::TYPE_BUNDLE); $cartItemMock->expects($this->exactly(2))->method('getBuyRequest')->willReturn($buyRequestMock); diff --git a/app/code/Magento/Bundle/Test/Unit/Model/LinkManagementTest.php b/app/code/Magento/Bundle/Test/Unit/Model/LinkManagementTest.php index fb03dd50525ad..c4f05e9f32461 100644 --- a/app/code/Magento/Bundle/Test/Unit/Model/LinkManagementTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Model/LinkManagementTest.php @@ -18,7 +18,7 @@ * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class LinkManagementTest extends \PHPUnit_Framework_TestCase +class LinkManagementTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Bundle\Model\LinkManagement @@ -150,16 +150,10 @@ protected function setUp() ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $this->bundleSelectionMock = $this->getMock( - \Magento\Bundle\Model\SelectionFactory::class, ['create'], [], '', false - ); - $this->bundleFactoryMock = $this->getMock( - \Magento\Bundle\Model\ResourceModel\BundleFactory::class, ['create'], [], '', false - ); - $this->optionCollectionFactoryMock = $this->getMock( - \Magento\Bundle\Model\ResourceModel\Option\CollectionFactory::class, ['create'], [], '', false - ); - $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class, [], [], '', false); + $this->bundleSelectionMock = $this->createPartialMock(\Magento\Bundle\Model\SelectionFactory::class, ['create']); + $this->bundleFactoryMock = $this->createPartialMock(\Magento\Bundle\Model\ResourceModel\BundleFactory::class, ['create']); + $this->optionCollectionFactoryMock = $this->createPartialMock(\Magento\Bundle\Model\ResourceModel\Option\CollectionFactory::class, ['create']); + $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); $this->metadataPoolMock = $this->getMockBuilder(\Magento\Framework\EntityManager\MetadataPool::class) ->disableOriginalConstructor() ->getMock(); @@ -288,10 +282,10 @@ public function testGetChildrenException() */ public function testAddChildToNotBundleProduct() { - $productLink = $this->getMock(\Magento\Bundle\Api\Data\LinkInterface::class); + $productLink = $this->createMock(\Magento\Bundle\Api\Data\LinkInterface::class); $productLink->expects($this->any())->method('getOptionId')->will($this->returnValue(1)); - $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $productMock = $this->createMock(\Magento\Catalog\Model\Product::class); $productMock->expects($this->once())->method('getTypeId')->will($this->returnValue( \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE )); @@ -303,15 +297,15 @@ public function testAddChildToNotBundleProduct() */ public function testAddChildNonExistingOption() { - $productLink = $this->getMock(\Magento\Bundle\Api\Data\LinkInterface::class); + $productLink = $this->createMock(\Magento\Bundle\Api\Data\LinkInterface::class); $productLink->expects($this->any())->method('getOptionId')->will($this->returnValue(1)); - $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $productMock = $this->createMock(\Magento\Catalog\Model\Product::class); $productMock->expects($this->once())->method('getTypeId')->will($this->returnValue( \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE )); - $store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $store = $this->createMock(\Magento\Store\Model\Store::class); $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($store)); $store->expects($this->any())->method('getId')->will($this->returnValue(0)); @@ -322,9 +316,7 @@ public function testAddChildNonExistingOption() ->method('getId') ->will($this->returnValue(null)); - $optionsCollectionMock = $this->getMock( - \Magento\Bundle\Model\ResourceModel\Option\Collection::class, [], [], '', false - ); + $optionsCollectionMock = $this->createMock(\Magento\Bundle\Model\ResourceModel\Option\Collection::class); $optionsCollectionMock->expects($this->once()) ->method('setIdFilter') ->with($this->equalTo(1)) @@ -345,12 +337,12 @@ public function testAddChildNonExistingOption() */ public function testAddChildLinkedProductIsComposite() { - $productLink = $this->getMock(\Magento\Bundle\Api\Data\LinkInterface::class); + $productLink = $this->createMock(\Magento\Bundle\Api\Data\LinkInterface::class); $productLink->expects($this->any())->method('getSku')->will($this->returnValue('linked_product_sku')); $productLink->expects($this->any())->method('getOptionId')->will($this->returnValue(1)); $this->metadataMock->expects($this->once())->method('getLinkField')->willReturn($this->linkField); - $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $productMock = $this->createMock(\Magento\Catalog\Model\Product::class); $productMock->expects($this->once())->method('getTypeId')->will($this->returnValue( \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE )); @@ -359,7 +351,7 @@ public function testAddChildLinkedProductIsComposite() ->with($this->linkField) ->willReturn($this->linkField); - $linkedProductMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $linkedProductMock = $this->createMock(\Magento\Catalog\Model\Product::class); $linkedProductMock->expects($this->any())->method('getId')->will($this->returnValue(13)); $linkedProductMock->expects($this->once())->method('isComposite')->will($this->returnValue(true)); $this->productRepository @@ -368,7 +360,7 @@ public function testAddChildLinkedProductIsComposite() ->with('linked_product_sku') ->will($this->returnValue($linkedProductMock)); - $store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $store = $this->createMock(\Magento\Store\Model\Store::class); $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($store)); $store->expects($this->any())->method('getId')->will($this->returnValue(0)); @@ -377,13 +369,7 @@ public function testAddChildLinkedProductIsComposite() ->getMock(); $option->expects($this->once())->method('getId')->will($this->returnValue(1)); - $optionsCollectionMock = $this->getMock( - \Magento\Bundle\Model\ResourceModel\Option\Collection::class, - [], - [], - '', - false - ); + $optionsCollectionMock = $this->createMock(\Magento\Bundle\Model\ResourceModel\Option\Collection::class); $optionsCollectionMock->expects($this->once()) ->method('setIdFilter') ->with($this->equalTo('1')) @@ -395,7 +381,7 @@ public function testAddChildLinkedProductIsComposite() $this->returnValue($optionsCollectionMock) ); - $bundle = $this->getMock(\Magento\Bundle\Model\ResourceModel\Bundle::class, [], [], '', false); + $bundle = $this->createMock(\Magento\Bundle\Model\ResourceModel\Bundle::class); $bundle->expects($this->once())->method('getSelectionsData')->with($this->linkField)->willReturn([]); $this->bundleFactoryMock->expects($this->once())->method('create')->will($this->returnValue($bundle)); $this->model->addChild($productMock, 1, $productLink); @@ -415,17 +401,21 @@ public function testAddChildProductAlreadyExistsInOption() $productLink->expects($this->any())->method('getSelectionId')->will($this->returnValue(1)); $this->metadataMock->expects($this->once())->method('getLinkField')->willReturn($this->linkField); - $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); - $productMock->expects($this->once())->method('getTypeId')->will($this->returnValue( + $productMock = $this->createPartialMock( + \Magento\Catalog\Model\Product::class, + ['getTypeId', 'getCopyFromView', 'getData', 'getTypeInstance', 'getSku'] + ); + $productMock->expects($this->once())->method('getTypeId')->willReturn( \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE - )); + ); + $productMock->expects($this->any()) ->method('getData') ->with($this->linkField) ->willReturn($this->linkField); $productMock->expects($this->any())->method('getCopyFromView')->will($this->returnValue(false)); - $linkedProductMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $linkedProductMock = $this->createMock(\Magento\Catalog\Model\Product::class); $linkedProductMock->expects($this->any())->method('getEntityId')->will($this->returnValue(13)); $linkedProductMock->expects($this->once())->method('isComposite')->will($this->returnValue(false)); $this->productRepository @@ -434,7 +424,7 @@ public function testAddChildProductAlreadyExistsInOption() ->with('linked_product_sku') ->will($this->returnValue($linkedProductMock)); - $store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $store = $this->createMock(\Magento\Store\Model\Store::class); $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($store)); $store->expects($this->any())->method('getId')->will($this->returnValue(0)); @@ -443,13 +433,7 @@ public function testAddChildProductAlreadyExistsInOption() ->getMock(); $option->expects($this->once())->method('getId')->will($this->returnValue(1)); - $optionsCollectionMock = $this->getMock( - \Magento\Bundle\Model\ResourceModel\Option\Collection::class, - [], - [], - '', - false - ); + $optionsCollectionMock = $this->createMock(\Magento\Bundle\Model\ResourceModel\Option\Collection::class); $optionsCollectionMock->expects($this->once()) ->method('setIdFilter') ->with($this->equalTo(1)) @@ -465,7 +449,7 @@ public function testAddChildProductAlreadyExistsInOption() ['option_id' => 1, 'product_id' => 12, 'parent_product_id' => 'product_id'], ['option_id' => 1, 'product_id' => 13, 'parent_product_id' => 'product_id'], ]; - $bundle = $this->getMock(\Magento\Bundle\Model\ResourceModel\Bundle::class, [], [], '', false); + $bundle = $this->createMock(\Magento\Bundle\Model\ResourceModel\Bundle::class); $bundle->expects($this->once())->method('getSelectionsData') ->with($this->linkField) ->will($this->returnValue($selections)); @@ -487,7 +471,7 @@ public function testAddChildCouldNotSave() $productLink->expects($this->any())->method('getSelectionId')->will($this->returnValue(1)); $this->metadataMock->expects($this->once())->method('getLinkField')->willReturn($this->linkField); - $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $productMock = $this->createMock(\Magento\Catalog\Model\Product::class); $productMock->expects($this->once())->method('getTypeId')->will($this->returnValue( \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE )); @@ -496,7 +480,7 @@ public function testAddChildCouldNotSave() ->with($this->linkField) ->willReturn($this->linkField); - $linkedProductMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $linkedProductMock = $this->createMock(\Magento\Catalog\Model\Product::class); $linkedProductMock->expects($this->any())->method('getId')->will($this->returnValue(13)); $linkedProductMock->expects($this->once())->method('isComposite')->will($this->returnValue(false)); $this->productRepository @@ -505,7 +489,7 @@ public function testAddChildCouldNotSave() ->with('linked_product_sku') ->will($this->returnValue($linkedProductMock)); - $store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $store = $this->createMock(\Magento\Store\Model\Store::class); $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($store)); $store->expects($this->any())->method('getId')->will($this->returnValue(0)); @@ -514,9 +498,7 @@ public function testAddChildCouldNotSave() ->getMock(); $option->expects($this->once())->method('getId')->will($this->returnValue(1)); - $optionsCollectionMock = $this->getMock( - \Magento\Bundle\Model\ResourceModel\Option\Collection::class, [], [], '', false - ); + $optionsCollectionMock = $this->createMock(\Magento\Bundle\Model\ResourceModel\Option\Collection::class); $optionsCollectionMock->expects($this->once()) ->method('setIdFilter') ->with($this->equalTo(1)) @@ -532,13 +514,13 @@ public function testAddChildCouldNotSave() ['option_id' => 1, 'product_id' => 11], ['option_id' => 1, 'product_id' => 12], ]; - $bundle = $this->getMock(\Magento\Bundle\Model\ResourceModel\Bundle::class, [], [], '', false); + $bundle = $this->createMock(\Magento\Bundle\Model\ResourceModel\Bundle::class); $bundle->expects($this->once())->method('getSelectionsData') ->with($this->linkField) ->will($this->returnValue($selections)); $this->bundleFactoryMock->expects($this->once())->method('create')->will($this->returnValue($bundle)); - $selection = $this->getMock(\Magento\Bundle\Model\Selection::class, ['save'], [], '', false); + $selection = $this->createPartialMock(\Magento\Bundle\Model\Selection::class, ['save']); $selection->expects($this->once())->method('save') ->will( $this->returnCallback( @@ -562,7 +544,7 @@ public function testAddChild() $productLink->expects($this->any())->method('getSelectionId')->will($this->returnValue(1)); $this->metadataMock->expects($this->once())->method('getLinkField')->willReturn($this->linkField); - $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $productMock = $this->createMock(\Magento\Catalog\Model\Product::class); $productMock->expects($this->once())->method('getTypeId')->will($this->returnValue( \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE )); @@ -571,7 +553,7 @@ public function testAddChild() ->with($this->linkField) ->willReturn($this->linkField); - $linkedProductMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $linkedProductMock = $this->createMock(\Magento\Catalog\Model\Product::class); $linkedProductMock->expects($this->any())->method('getId')->will($this->returnValue(13)); $linkedProductMock->expects($this->once())->method('isComposite')->will($this->returnValue(false)); $this->productRepository @@ -580,7 +562,7 @@ public function testAddChild() ->with('linked_product_sku') ->will($this->returnValue($linkedProductMock)); - $store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $store = $this->createMock(\Magento\Store\Model\Store::class); $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($store)); $store->expects($this->any())->method('getId')->will($this->returnValue(0)); @@ -589,9 +571,7 @@ public function testAddChild() ->getMock(); $option->expects($this->once())->method('getId')->will($this->returnValue(1)); - $optionsCollectionMock = $this->getMock( - \Magento\Bundle\Model\ResourceModel\Option\Collection::class, [], [], '', false - ); + $optionsCollectionMock = $this->createMock(\Magento\Bundle\Model\ResourceModel\Option\Collection::class); $optionsCollectionMock->expects($this->once()) ->method('setIdFilter') ->with($this->equalTo(1)) @@ -607,13 +587,13 @@ public function testAddChild() ['option_id' => 1, 'product_id' => 11], ['option_id' => 1, 'product_id' => 12], ]; - $bundle = $this->getMock(\Magento\Bundle\Model\ResourceModel\Bundle::class, [], [], '', false); + $bundle = $this->createMock(\Magento\Bundle\Model\ResourceModel\Bundle::class); $bundle->expects($this->once())->method('getSelectionsData') ->with($this->linkField) ->will($this->returnValue($selections)); $this->bundleFactoryMock->expects($this->once())->method('create')->will($this->returnValue($bundle)); - $selection = $this->getMock(\Magento\Bundle\Model\Selection::class, ['save', 'getId'], [], '', false); + $selection = $this->createPartialMock(\Magento\Bundle\Model\Selection::class, ['save', 'getId']); $selection->expects($this->once())->method('save'); $selection->expects($this->once())->method('getId')->will($this->returnValue(42)); $this->bundleSelectionMock->expects($this->once())->method('create')->will($this->returnValue($selection)); @@ -651,7 +631,7 @@ public function testSaveChild() $productLink->expects($this->any())->method('getSelectionId')->will($this->returnValue($optionId)); $this->metadataMock->expects($this->once())->method('getLinkField')->willReturn($this->linkField); - $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $productMock = $this->createMock(\Magento\Catalog\Model\Product::class); $productMock->expects($this->once())->method('getTypeId')->will($this->returnValue( \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE )); @@ -660,7 +640,7 @@ public function testSaveChild() ->with($this->linkField) ->willReturn($parentProductId); - $linkedProductMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $linkedProductMock = $this->createMock(\Magento\Catalog\Model\Product::class); $linkedProductMock->expects($this->any())->method('getId')->will($this->returnValue($linkProductId)); $linkedProductMock->expects($this->once())->method('isComposite')->will($this->returnValue(false)); $this->productRepository @@ -674,13 +654,11 @@ public function testSaveChild() ->with('linked_product_sku') ->will($this->returnValue($linkedProductMock)); - $store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $store = $this->createMock(\Magento\Store\Model\Store::class); $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($store)); $store->expects($this->any())->method('getId')->will($this->returnValue(0)); - $selection = $this->getMock( - \Magento\Bundle\Model\Selection::class, - [ + $selection = $this->createPartialMock(\Magento\Bundle\Model\Selection::class, [ 'save', 'getId', 'load', @@ -693,11 +671,7 @@ public function testSaveChild() 'setSelectionPriceValue', 'setSelectionCanChangeQty', 'setIsDefault' - ], - [], - '', - false - ); + ]); $selection->expects($this->once())->method('save'); $selection->expects($this->once())->method('load')->with($id)->will($this->returnSelf()); $selection->expects($this->any())->method('getId')->will($this->returnValue($id)); @@ -723,6 +697,7 @@ public function testSaveChildFailedToSave() $id = 12; $linkProductId = 45; $parentProductId = 32; + $productLink = $this->getMockBuilder(\Magento\Bundle\Api\Data\LinkInterface::class) ->setMethods(['getSku', 'getOptionId', 'getSelectionId']) ->disableOriginalConstructor() @@ -732,13 +707,13 @@ public function testSaveChildFailedToSave() $productLink->expects($this->any())->method('getSelectionId')->will($this->returnValue(1)); $bundleProductSku = 'bundleProductSku'; - $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $productMock = $this->createMock(\Magento\Catalog\Model\Product::class); $productMock->expects($this->once())->method('getTypeId')->will($this->returnValue( \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE )); $productMock->expects($this->any())->method('getId')->will($this->returnValue($parentProductId)); - $linkedProductMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $linkedProductMock = $this->createMock(\Magento\Catalog\Model\Product::class); $linkedProductMock->expects($this->any())->method('getId')->will($this->returnValue($linkProductId)); $linkedProductMock->expects($this->once())->method('isComposite')->will($this->returnValue(false)); $this->productRepository @@ -752,13 +727,11 @@ public function testSaveChildFailedToSave() ->with('linked_product_sku') ->will($this->returnValue($linkedProductMock)); - $store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $store = $this->createMock(\Magento\Store\Model\Store::class); $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($store)); $store->expects($this->any())->method('getId')->will($this->returnValue(0)); - $selection = $this->getMock( - \Magento\Bundle\Model\Selection::class, - [ + $selection = $this->createPartialMock(\Magento\Bundle\Model\Selection::class, [ 'save', 'getId', 'load', @@ -772,12 +745,8 @@ public function testSaveChildFailedToSave() 'setSelectionPriceValue', 'setSelectionCanChangeQty', 'setIsDefault' - ], - [], - '', - false - ); - $mockException = $this->getMock(\Exception::class); + ]); + $mockException = $this->createMock(\Exception::class); $selection->expects($this->once())->method('save')->will($this->throwException($mockException)); $selection->expects($this->once())->method('load')->with($id)->will($this->returnSelf()); $selection->expects($this->any())->method('getId')->will($this->returnValue($id)); @@ -794,16 +763,16 @@ public function testSaveChildWithoutId() { $bundleProductSku = "bundleSku"; $linkedProductSku = 'simple'; - $productLink = $this->getMock(\Magento\Bundle\Api\Data\LinkInterface::class); + $productLink = $this->createMock(\Magento\Bundle\Api\Data\LinkInterface::class); $productLink->expects($this->any())->method('getId')->will($this->returnValue(null)); $productLink->expects($this->any())->method('getSku')->will($this->returnValue($linkedProductSku)); - $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $productMock = $this->createMock(\Magento\Catalog\Model\Product::class); $productMock->expects($this->once())->method('getTypeId')->will($this->returnValue( \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE )); - $linkedProductMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $linkedProductMock = $this->createMock(\Magento\Catalog\Model\Product::class); $linkedProductMock->expects($this->once())->method('isComposite')->will($this->returnValue(false)); $this->productRepository ->expects($this->at(0)) @@ -828,16 +797,16 @@ public function testSaveChildWithInvalidId() $id = 12345; $linkedProductSku = 'simple'; $bundleProductSku = "bundleProductSku"; - $productLink = $this->getMock(\Magento\Bundle\Api\Data\LinkInterface::class); + $productLink = $this->createMock(\Magento\Bundle\Api\Data\LinkInterface::class); $productLink->expects($this->any())->method('getId')->will($this->returnValue($id)); $productLink->expects($this->any())->method('getSku')->will($this->returnValue($linkedProductSku)); - $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $productMock = $this->createMock(\Magento\Catalog\Model\Product::class); $productMock->expects($this->once())->method('getTypeId')->will($this->returnValue( \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE )); - $linkedProductMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $linkedProductMock = $this->createMock(\Magento\Catalog\Model\Product::class); $linkedProductMock->expects($this->once())->method('isComposite')->will($this->returnValue(false)); $this->productRepository ->expects($this->at(0)) @@ -850,16 +819,10 @@ public function testSaveChildWithInvalidId() ->with($linkedProductSku) ->will($this->returnValue($linkedProductMock)); - $selection = $this->getMock( - \Magento\Bundle\Model\Selection::class, - [ + $selection = $this->createPartialMock(\Magento\Bundle\Model\Selection::class, [ 'getId', 'load', - ], - [], - '', - false - ); + ]); $selection->expects($this->once())->method('load')->with($id)->will($this->returnSelf()); $selection->expects($this->any())->method('getId')->will($this->returnValue(null)); @@ -876,16 +839,16 @@ public function testSaveChildWithCompositeProductLink() $bundleProductSku = "bundleProductSku"; $id = 12; $linkedProductSku = 'simple'; - $productLink = $this->getMock(\Magento\Bundle\Api\Data\LinkInterface::class); + $productLink = $this->createMock(\Magento\Bundle\Api\Data\LinkInterface::class); $productLink->expects($this->any())->method('getId')->will($this->returnValue($id)); $productLink->expects($this->any())->method('getSku')->will($this->returnValue($linkedProductSku)); - $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $productMock = $this->createMock(\Magento\Catalog\Model\Product::class); $productMock->expects($this->once())->method('getTypeId')->will($this->returnValue( \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE )); - $linkedProductMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $linkedProductMock = $this->createMock(\Magento\Catalog\Model\Product::class); $linkedProductMock->expects($this->once())->method('isComposite')->will($this->returnValue(true)); $this->productRepository ->expects($this->at(0)) @@ -910,11 +873,11 @@ public function testSaveChildWithSimpleProduct() $linkedProductSku = 'simple'; $bundleProductSku = "bundleProductSku"; - $productLink = $this->getMock(\Magento\Bundle\Api\Data\LinkInterface::class); + $productLink = $this->createMock(\Magento\Bundle\Api\Data\LinkInterface::class); $productLink->expects($this->any())->method('getId')->will($this->returnValue($id)); $productLink->expects($this->any())->method('getSku')->will($this->returnValue($linkedProductSku)); - $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $productMock = $this->createMock(\Magento\Catalog\Model\Product::class); $productMock->expects($this->once())->method('getTypeId')->will($this->returnValue( \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE )); @@ -928,7 +891,7 @@ public function testSaveChildWithSimpleProduct() public function testRemoveChild() { $this->productRepository->expects($this->any())->method('get')->will($this->returnValue($this->product)); - $bundle = $this->getMock(\Magento\Bundle\Model\ResourceModel\Bundle::class, [], [], '', false); + $bundle = $this->createMock(\Magento\Bundle\Model\ResourceModel\Bundle::class); $this->bundleFactoryMock->expects($this->once())->method('create')->will($this->returnValue($bundle)); $productSku = 'productSku'; $optionId = 1; diff --git a/app/code/Magento/Bundle/Test/Unit/Model/Option/ValidatorTest.php b/app/code/Magento/Bundle/Test/Unit/Model/Option/ValidatorTest.php index f833259cd7cdf..f47c978190a2c 100644 --- a/app/code/Magento/Bundle/Test/Unit/Model/Option/ValidatorTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Model/Option/ValidatorTest.php @@ -8,7 +8,7 @@ use Magento\Framework\Validator\NotEmpty; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class ValidatorTest extends \PHPUnit_Framework_TestCase +class ValidatorTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Bundle\Model\Option\Validator diff --git a/app/code/Magento/Bundle/Test/Unit/Model/OptionManagementTest.php b/app/code/Magento/Bundle/Test/Unit/Model/OptionManagementTest.php index e585cc9edbea3..f0a69bd4fb28b 100644 --- a/app/code/Magento/Bundle/Test/Unit/Model/OptionManagementTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Model/OptionManagementTest.php @@ -9,7 +9,7 @@ use \Magento\Bundle\Model\OptionManagement; -class OptionManagementTest extends \PHPUnit_Framework_TestCase +class OptionManagementTest extends \PHPUnit\Framework\TestCase { /** * @var OptionManagement @@ -39,11 +39,11 @@ class OptionManagementTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->optionRepositoryMock = - $this->getMock(\Magento\Bundle\Api\ProductOptionRepositoryInterface::class, [], [], '', false); + $this->createMock(\Magento\Bundle\Api\ProductOptionRepositoryInterface::class); $this->productRepositoryMock = - $this->getMock(\Magento\Catalog\Api\ProductRepositoryInterface::class, [], [], '', false); - $this->optionMock = $this->getMock(\Magento\Bundle\Api\Data\OptionInterface::class, [], [], '', false); - $this->productMock = $this->getMock(\Magento\Catalog\Api\Data\ProductInterface::class, [], [], '', false); + $this->createMock(\Magento\Catalog\Api\ProductRepositoryInterface::class); + $this->optionMock = $this->createMock(\Magento\Bundle\Api\Data\OptionInterface::class); + $this->productMock = $this->createMock(\Magento\Catalog\Api\Data\ProductInterface::class); $this->model = new OptionManagement($this->optionRepositoryMock, $this->productRepositoryMock); } diff --git a/app/code/Magento/Bundle/Test/Unit/Model/OptionRepositoryTest.php b/app/code/Magento/Bundle/Test/Unit/Model/OptionRepositoryTest.php index 0bc0f04214667..45d0208c1d575 100644 --- a/app/code/Magento/Bundle/Test/Unit/Model/OptionRepositoryTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Model/OptionRepositoryTest.php @@ -14,7 +14,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class OptionRepositoryTest extends \PHPUnit_Framework_TestCase +class OptionRepositoryTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -79,8 +79,8 @@ class OptionRepositoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->productRepositoryMock = $this->getMock(\Magento\Catalog\Api\ProductRepositoryInterface::class); - $this->typeMock = $this->getMock(\Magento\Bundle\Model\Product\Type::class, [], [], '', false); + $this->productRepositoryMock = $this->createMock(\Magento\Catalog\Api\ProductRepositoryInterface::class); + $this->typeMock = $this->createMock(\Magento\Bundle\Model\Product\Type::class); $this->optionFactoryMock = $this->getMockBuilder(\Magento\Bundle\Api\Data\OptionInterfaceFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) @@ -89,24 +89,12 @@ protected function setUp() $this->dataObjectHelperMock = $this->getMockBuilder(\Magento\Framework\Api\DataObjectHelper::class) ->disableOriginalConstructor() ->getMock(); - $this->optionResourceMock = $this->getMock( - \Magento\Bundle\Model\ResourceModel\Option::class, - ['delete', '__wakeup', 'save', 'removeOptionSelections'], - [], - '', - false - ); - $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); - $this->linkManagementMock = $this->getMock(\Magento\Bundle\Api\ProductLinkManagementInterface::class); - $this->optionListMock = $this->getMock(\Magento\Bundle\Model\Product\OptionList::class, [], [], '', false); - $this->linkListMock = $this->getMock(\Magento\Bundle\Model\Product\LinksList::class, [], [], '', false); - $this->metadataPoolMock = $this->getMock( - \Magento\Framework\EntityManager\MetadataPool::class, - [], - [], - '', - false - ); + $this->optionResourceMock = $this->createPartialMock(\Magento\Bundle\Model\ResourceModel\Option::class, ['delete', '__wakeup', 'save', 'removeOptionSelections']); + $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->linkManagementMock = $this->createMock(\Magento\Bundle\Api\ProductLinkManagementInterface::class); + $this->optionListMock = $this->createMock(\Magento\Bundle\Model\Product\OptionList::class); + $this->linkListMock = $this->createMock(\Magento\Bundle\Model\Product\LinksList::class); + $this->metadataPoolMock = $this->createMock(\Magento\Framework\EntityManager\MetadataPool::class); $this->model = new OptionRepository( $this->productRepositoryMock, @@ -132,7 +120,7 @@ protected function setUp() public function testGetThrowsExceptionIfProductIsSimple() { $productSku = 'sku'; - $productMock = $this->getMock(\Magento\Catalog\Api\Data\ProductInterface::class); + $productMock = $this->createMock(\Magento\Catalog\Api\Data\ProductInterface::class); $productMock->expects($this->once()) ->method('getTypeId') ->willReturn(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE); @@ -151,7 +139,7 @@ public function testGetThrowsExceptionIfOptionDoesNotExist() { $productSku = 'sku'; $optionId = 100; - $productMock = $this->getMock(\Magento\Catalog\Api\Data\ProductInterface::class); + $productMock = $this->createMock(\Magento\Catalog\Api\Data\ProductInterface::class); $productMock->expects($this->once()) ->method('getTypeId') ->willReturn(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE); @@ -160,18 +148,12 @@ public function testGetThrowsExceptionIfOptionDoesNotExist() ->with($productSku) ->willReturn($productMock); - $optCollectionMock = $this->getMock( - \Magento\Bundle\Model\ResourceModel\Option\Collection::class, - [], - [], - '', - false - ); + $optCollectionMock = $this->createMock(\Magento\Bundle\Model\ResourceModel\Option\Collection::class); $this->typeMock->expects($this->once()) ->method('getOptionsCollection') ->with($productMock) ->willReturn($optCollectionMock); - $optionMock = $this->getMock(\Magento\Bundle\Model\Option::class, [], [], '', false); + $optionMock = $this->createMock(\Magento\Bundle\Model\Option::class); $optCollectionMock->expects($this->once())->method('getItemById')->with($optionId)->willReturn($optionMock); $optionMock->expects($this->once())->method('getId')->willReturn(null); @@ -184,13 +166,7 @@ public function testGet() $optionId = 100; $optionData = ['title' => 'option title']; - $productMock = $this->getMock( - \Magento\Catalog\Model\Product::class, - ['getTypeId', 'getTypeInstance', 'getStoreId', 'getPriceType', '__wakeup', 'getSku'], - [], - '', - false - ); + $productMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['getTypeId', 'getTypeInstance', 'getStoreId', 'getPriceType', '__wakeup', 'getSku']); $productMock->expects($this->once()) ->method('getTypeId') ->willReturn(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE); @@ -201,18 +177,12 @@ public function testGet() ->with($productSku) ->willReturn($productMock); - $optCollectionMock = $this->getMock( - \Magento\Bundle\Model\ResourceModel\Option\Collection::class, - [], - [], - '', - false - ); + $optCollectionMock = $this->createMock(\Magento\Bundle\Model\ResourceModel\Option\Collection::class); $this->typeMock->expects($this->once()) ->method('getOptionsCollection') ->with($productMock) ->willReturn($optCollectionMock); - $optionMock = $this->getMock(\Magento\Bundle\Model\Option::class, [], [], '', false); + $optionMock = $this->createMock(\Magento\Bundle\Model\Option::class); $optCollectionMock->expects($this->once())->method('getItemById')->with($optionId)->willReturn($optionMock); $optionMock->expects($this->exactly(2))->method('getId')->willReturn(1); @@ -222,7 +192,7 @@ public function testGet() $linkMock = ['item']; $this->linkListMock->expects($this->once())->method('getItems')->with($productMock, 100)->willReturn($linkMock); - $newOptionMock = $this->getMock(\Magento\Bundle\Api\Data\OptionInterface::class); + $newOptionMock = $this->createMock(\Magento\Bundle\Api\Data\OptionInterface::class); $this->dataObjectHelperMock->expects($this->once()) ->method('populateWithArray') ->with($newOptionMock, $optionData, \Magento\Bundle\Api\Data\OptionInterface::class) @@ -245,7 +215,7 @@ public function testGet() public function testDelete() { - $optionMock = $this->getMock(\Magento\Bundle\Model\Option::class, [], [], '', false); + $optionMock = $this->createMock(\Magento\Bundle\Model\Option::class); $this->optionResourceMock->expects($this->once())->method('delete')->with($optionMock)->willReturnSelf(); $this->assertTrue($this->model->delete($optionMock)); } @@ -256,7 +226,7 @@ public function testDelete() */ public function testDeleteThrowsExceptionIfCannotDelete() { - $optionMock = $this->getMock(\Magento\Bundle\Model\Option::class, [], [], '', false); + $optionMock = $this->createMock(\Magento\Bundle\Model\Option::class); $optionMock->expects($this->once())->method('getOptionId')->willReturn(1); $this->optionResourceMock->expects($this->once()) ->method('delete') @@ -269,7 +239,7 @@ public function testDeleteById() { $productSku = 'sku'; $optionId = 100; - $productMock = $this->getMock(\Magento\Catalog\Api\Data\ProductInterface::class); + $productMock = $this->createMock(\Magento\Catalog\Api\Data\ProductInterface::class); $productMock->expects($this->once()) ->method('getTypeId') ->willReturn(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE); @@ -278,15 +248,9 @@ public function testDeleteById() ->with($productSku) ->willReturn($productMock); - $optionMock = $this->getMock(\Magento\Bundle\Model\Option::class, [], [], '', false); + $optionMock = $this->createMock(\Magento\Bundle\Model\Option::class); - $optCollectionMock = $this->getMock( - \Magento\Bundle\Model\ResourceModel\Option\Collection::class, - [], - [], - '', - false - ); + $optCollectionMock = $this->createMock(\Magento\Bundle\Model\ResourceModel\Option\Collection::class); $this->typeMock->expects($this->once()) ->method('getOptionsCollection') ->with($productMock) @@ -310,7 +274,7 @@ public function testSaveExistingOption() $optionId = 5; $existingLinkToUpdateId = '23'; - $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $productMock = $this->createMock(\Magento\Catalog\Model\Product::class); $productMock->expects($this->once())->method('getData')->willReturn($productId); $productMock->expects($this->once())->method('getStoreId')->willReturn($storeId); $optionCollectionMock = $this->getMockBuilder(\Magento\Bundle\Model\ResourceModel\Option\Collection::class) @@ -322,18 +286,14 @@ public function testSaveExistingOption() ->willReturn($optionCollectionMock); $optionCollectionMock->expects($this->once())->method('setIdFilter')->with($optionId)->willReturnSelf(); - $optionMock = $this->getMockBuilder(\Magento\Bundle\Model\Option::class) - ->disableOriginalConstructor() - ->getMock(); + $optionMock = $this->createPartialMock( + \Magento\Bundle\Model\Option::class, + ['setStoreId', 'setParentId', 'getProductLinks', 'getOptionId', 'getResource'] + ); $optionCollectionMock->expects($this->once())->method('getFirstItem')->willReturn($optionMock); - $metadataMock = $this->getMock( - \Magento\Framework\EntityManager\EntityMetadata::class, - [], - [], - '', - false - ); + + $metadataMock = $this->createMock(\Magento\Framework\EntityManager\EntityMetadata::class); $metadataMock->expects($this->once())->method('getLinkField')->willReturn('product_option'); $this->metadataPoolMock->expects($this->once())->method('getMetadata') @@ -341,9 +301,9 @@ public function testSaveExistingOption() ->willReturn($metadataMock); $optionMock->expects($this->atLeastOnce())->method('getOptionId')->willReturn($optionId); - $productLinkUpdate = $this->getMock(\Magento\Bundle\Api\Data\LinkInterface::class); + $productLinkUpdate = $this->createMock(\Magento\Bundle\Api\Data\LinkInterface::class); $productLinkUpdate->expects($this->any())->method('getId')->willReturn($existingLinkToUpdateId); - $productLinkNew = $this->getMock(\Magento\Bundle\Api\Data\LinkInterface::class); + $productLinkNew = $this->createMock(\Magento\Bundle\Api\Data\LinkInterface::class); $productLinkNew->expects($this->any())->method('getId')->willReturn(null); $optionMock->expects($this->exactly(2)) ->method('getProductLinks') @@ -362,7 +322,7 @@ public function testSaveNewOption() $storeId = 2; $optionId = 5; - $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $productMock = $this->createMock(\Magento\Catalog\Model\Product::class); $productMock->expects($this->once())->method('getData')->willReturn($productId); $productMock->expects($this->once())->method('getStoreId')->willReturn($storeId); $productMock->expects($this->any())->method('getSku')->willReturn($productSku); @@ -376,16 +336,22 @@ public function testSaveNewOption() ->willReturn($optionCollectionMock); $optionCollectionMock->expects($this->once())->method('setIdFilter')->with($optionId)->willReturnSelf(); - $optionMock = $this->getMockBuilder(\Magento\Bundle\Model\Option::class) - ->disableOriginalConstructor() - ->getMock(); + $optionMock = $this->createPartialMock( + \Magento\Bundle\Model\Option::class, + [ + 'setStoreId', + 'setParentId', + 'getProductLinks', + 'getOptionId', + 'setOptionId', + 'setDefaultTitle', + 'getTitle', + 'getResource' + ] + ); $optionCollectionMock->expects($this->once())->method('getFirstItem')->willReturn($optionMock); - $metadataMock = $this->getMock( - \Magento\Framework\EntityManager\EntityMetadata::class, - [], - [], - '', - false + $metadataMock = $this->createMock( + \Magento\Framework\EntityManager\EntityMetadata::class ); $metadataMock->expects($this->once())->method('getLinkField')->willReturn('product_option'); @@ -395,8 +361,8 @@ public function testSaveNewOption() $optionMock->method('getOptionId') ->willReturn($optionId); - $productLink1 = $this->getMock(\Magento\Bundle\Api\Data\LinkInterface::class); - $productLink2 = $this->getMock(\Magento\Bundle\Api\Data\LinkInterface::class); + $productLink1 = $this->createMock(\Magento\Bundle\Api\Data\LinkInterface::class); + $productLink2 = $this->createMock(\Magento\Bundle\Api\Data\LinkInterface::class); $optionMock->expects($this->exactly(2)) ->method('getProductLinks') ->willReturn([$productLink1, $productLink2]); @@ -422,7 +388,7 @@ public function testSaveCanNotSave() $storeId = 2; $optionId = 5; - $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $productMock = $this->createMock(\Magento\Catalog\Model\Product::class); $productMock->expects($this->once())->method('getData')->willReturn($productId); $productMock->expects($this->once())->method('getStoreId')->willReturn($storeId); $productMock->expects($this->any())->method('getSku')->willReturn($productSku); @@ -436,16 +402,22 @@ public function testSaveCanNotSave() ->willReturn($optionCollectionMock); $optionCollectionMock->expects($this->once())->method('setIdFilter')->with($optionId)->willReturnSelf(); - $optionMock = $this->getMockBuilder(\Magento\Bundle\Model\Option::class) - ->disableOriginalConstructor() - ->getMock(); + $optionMock = $this->createPartialMock( + \Magento\Bundle\Model\Option::class, + [ + 'setStoreId', + 'setParentId', + 'getProductLinks', + 'getOptionId', + 'setOptionId', + 'setDefaultTitle', + 'getTitle', + 'getResource' + ] + ); $optionCollectionMock->expects($this->once())->method('getFirstItem')->willReturn($optionMock); - $metadataMock = $this->getMock( - \Magento\Framework\EntityManager\EntityMetadata::class, - [], - [], - '', - false + $metadataMock = $this->createMock( + \Magento\Framework\EntityManager\EntityMetadata::class ); $metadataMock->expects($this->once())->method('getLinkField')->willReturn('product_option'); @@ -454,21 +426,21 @@ public function testSaveCanNotSave() ->willReturn($metadataMock); $optionMock->method('getOptionId')->willReturn($optionId); - $productLink1 = $this->getMock(\Magento\Bundle\Api\Data\LinkInterface::class); - $productLink2 = $this->getMock(\Magento\Bundle\Api\Data\LinkInterface::class); + $productLink1 = $this->createMock(\Magento\Bundle\Api\Data\LinkInterface::class); + $productLink2 = $this->createMock(\Magento\Bundle\Api\Data\LinkInterface::class); $optionMock->expects($this->exactly(2)) ->method('getProductLinks') ->willReturn([$productLink1, $productLink2]); $this->optionResourceMock->expects($this->once())->method('save')->with($optionMock) - ->willThrowException($this->getMock(\Exception::class)); + ->willThrowException($this->createMock(\Exception::class)); $this->model->save($productMock, $optionMock); } public function testGetList() { $productSku = 'simple'; - $productMock = $this->getMock(\Magento\Catalog\Api\Data\ProductInterface::class); + $productMock = $this->createMock(\Magento\Catalog\Api\Data\ProductInterface::class); $productMock->expects($this->once())->method('getTypeId')->willReturn('bundle'); $this->productRepositoryMock ->expects($this->once()) @@ -486,7 +458,7 @@ public function testGetList() public function testGetListException() { $productSku = 'simple'; - $productMock = $this->getMock(\Magento\Catalog\Api\Data\ProductInterface::class); + $productMock = $this->createMock(\Magento\Catalog\Api\Data\ProductInterface::class); $productMock->expects($this->once())->method('getTypeId')->willReturn('simple'); $this->productRepositoryMock ->expects($this->once()) diff --git a/app/code/Magento/Bundle/Test/Unit/Model/OptionTest.php b/app/code/Magento/Bundle/Test/Unit/Model/OptionTest.php index b211ad500a448..1cacece47d6f2 100644 --- a/app/code/Magento/Bundle/Test/Unit/Model/OptionTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Model/OptionTest.php @@ -7,7 +7,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class OptionTest extends \PHPUnit_Framework_TestCase +class OptionTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject @@ -31,32 +31,20 @@ class OptionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->selectionFirst = $this->getMock( + $this->selectionFirst = $this->createPartialMock( \Magento\Catalog\Model\Product::class, - ['__wakeup', 'isSaleable', 'getIsDefault', 'getSelectionId'], - [], - '', - false + ['__wakeup', 'isSaleable', 'getIsDefault', 'getSelectionId'] ); - $this->selectionSecond = $this->getMock( + $this->selectionSecond = $this->createPartialMock( \Magento\Catalog\Model\Product::class, - ['__wakeup', 'isSaleable', 'getIsDefault', 'getSelectionId'], - [], - '', - false + ['__wakeup', 'isSaleable', 'getIsDefault', 'getSelectionId'] ); - $this->resource = $this->getMock( - \Magento\Framework\Model\ResourceModel\AbstractResource::class, - [ + $this->resource = $this->createPartialMock(\Magento\Framework\Model\ResourceModel\AbstractResource::class, [ '_construct', 'getConnection', 'getIdFieldName', 'getSearchableData', - ], - [], - '', - false - ); + ]); $this->model = (new ObjectManager($this))->getObject(\Magento\Bundle\Model\Option::class, [ 'resource' => $this->resource, ]); diff --git a/app/code/Magento/Bundle/Test/Unit/Model/OptionTypeListTest.php b/app/code/Magento/Bundle/Test/Unit/Model/OptionTypeListTest.php index f83cf4a5173b0..d8e77b3efb9d5 100644 --- a/app/code/Magento/Bundle/Test/Unit/Model/OptionTypeListTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Model/OptionTypeListTest.php @@ -6,7 +6,7 @@ */ namespace Magento\Bundle\Test\Unit\Model; -class OptionTypeListTest extends \PHPUnit_Framework_TestCase +class OptionTypeListTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Bundle\Model\OptionTypeList @@ -25,13 +25,10 @@ class OptionTypeListTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->typeMock = $this->getMock(\Magento\Bundle\Model\Source\Option\Type::class, [], [], '', false); - $this->typeFactoryMock = $this->getMock( + $this->typeMock = $this->createMock(\Magento\Bundle\Model\Source\Option\Type::class); + $this->typeFactoryMock = $this->createPartialMock( \Magento\Bundle\Api\Data\OptionTypeInterfaceFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->model = new \Magento\Bundle\Model\OptionTypeList( $this->typeMock, @@ -45,7 +42,7 @@ public function testGetItems() ->method('toOptionArray') ->willReturn([['value' => 'value', 'label' => 'label']]); - $typeMock = $this->getMock(\Magento\Bundle\Api\Data\OptionTypeInterface::class); + $typeMock = $this->createMock(\Magento\Bundle\Api\Data\OptionTypeInterface::class); $typeMock->expects($this->once())->method('setCode')->with('value')->willReturnSelf(); $typeMock->expects($this->once())->method('setLabel')->with('label')->willReturnSelf(); $this->typeFactoryMock->expects($this->once())->method('create')->willReturn($typeMock); diff --git a/app/code/Magento/Bundle/Test/Unit/Model/Plugin/PriceBackendTest.php b/app/code/Magento/Bundle/Test/Unit/Model/Plugin/PriceBackendTest.php index 2d498499955d1..4ffcca954c6b9 100644 --- a/app/code/Magento/Bundle/Test/Unit/Model/Plugin/PriceBackendTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Model/Plugin/PriceBackendTest.php @@ -12,7 +12,7 @@ use Magento\Catalog\Model\Product\Type; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class PriceBackendTest extends \PHPUnit_Framework_TestCase +class PriceBackendTest extends \PHPUnit\Framework\TestCase { const CLOSURE_VALUE = 'CLOSURE'; diff --git a/app/code/Magento/Bundle/Test/Unit/Model/Plugin/ProductTest.php b/app/code/Magento/Bundle/Test/Unit/Model/Plugin/ProductTest.php index 859c40ed9439e..98e3b7282ce56 100644 --- a/app/code/Magento/Bundle/Test/Unit/Model/Plugin/ProductTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Model/Plugin/ProductTest.php @@ -10,7 +10,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use PHPUnit_Framework_MockObject_MockObject as MockObject; -class ProductTest extends \PHPUnit_Framework_TestCase +class ProductTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Bundle\Model\Plugin\Product */ private $plugin; diff --git a/app/code/Magento/Bundle/Test/Unit/Model/Plugin/QuoteItemTest.php b/app/code/Magento/Bundle/Test/Unit/Model/Plugin/QuoteItemTest.php index 8b00df77fb65b..8e08a6845198f 100644 --- a/app/code/Magento/Bundle/Test/Unit/Model/Plugin/QuoteItemTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Model/Plugin/QuoteItemTest.php @@ -10,7 +10,7 @@ use Magento\Quote\Model\Quote\Item\AbstractItem; use Magento\Catalog\Model\Product; -class QuoteItemTest extends \PHPUnit_Framework_TestCase +class QuoteItemTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject|Product @@ -51,8 +51,8 @@ protected function setUp() true, ['getProduct'] ); - $this->subjectMock = $this->getMock(ToOrderItem::class, [], [], '', false); - $this->productMock = $this->getMock(Product::class, [], [], '', false); + $this->subjectMock = $this->createMock(ToOrderItem::class); + $this->productMock = $this->createMock(Product::class); $this->model = new \Magento\Bundle\Model\Plugin\QuoteItem(); } @@ -65,13 +65,7 @@ public function testAroundItemToOrderItemPositive() ]; $expectedOptions = $productOptions + ['bundle_selection_attributes' => $attributeValue]; - $bundleAttribute = $this->getMock( - \Magento\Catalog\Model\Product\Configuration\Item\Option::class, - [], - [], - '', - false - ); + $bundleAttribute = $this->createMock(\Magento\Catalog\Model\Product\Configuration\Item\Option::class); $bundleAttribute->expects($this->once()) ->method('getValue') ->willReturn($attributeValue); diff --git a/app/code/Magento/Bundle/Test/Unit/Model/Product/Attribute/Source/Price/ViewTest.php b/app/code/Magento/Bundle/Test/Unit/Model/Product/Attribute/Source/Price/ViewTest.php index c7d21152538ce..423018392b18f 100644 --- a/app/code/Magento/Bundle/Test/Unit/Model/Product/Attribute/Source/Price/ViewTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Model/Product/Attribute/Source/Price/ViewTest.php @@ -7,7 +7,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class ViewTest extends \PHPUnit_Framework_TestCase +class ViewTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Bundle\Model\Product\Attribute\Source\Price\View @@ -31,30 +31,15 @@ class ViewTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->option = $this->getMock( - \Magento\Eav\Model\ResourceModel\Entity\Attribute\Option::class, - [], - [], - '', - false - ); - $this->optionFactory = $this->getMock( + $this->option = $this->createMock(\Magento\Eav\Model\ResourceModel\Entity\Attribute\Option::class); + $this->optionFactory = $this->createPartialMock( \Magento\Eav\Model\ResourceModel\Entity\Attribute\OptionFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->optionFactory->expects($this->any()) ->method('create') ->will($this->returnValue($this->option)); - $this->attribute = $this->getMock( - \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class, - [], - [], - '', - false - ); + $this->attribute = $this->createMock(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class); $this->model = (new ObjectManager($this)) ->getObject( diff --git a/app/code/Magento/Bundle/Test/Unit/Model/Product/CatalogPriceTest.php b/app/code/Magento/Bundle/Test/Unit/Model/Product/CatalogPriceTest.php index 020c7134daf08..07d235cda2c96 100644 --- a/app/code/Magento/Bundle/Test/Unit/Model/Product/CatalogPriceTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Model/Product/CatalogPriceTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Bundle\Test\Unit\Model\Product; -class CatalogPriceTest extends \PHPUnit_Framework_TestCase +class CatalogPriceTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Bundle\Model\Product\CatalogPrice @@ -39,23 +39,14 @@ class CatalogPriceTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); - $this->commonPriceMock = $this->getMock( - \Magento\Catalog\Model\Product\CatalogPrice::class, - [], - [], - '', - false - ); - $this->coreRegistryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); + $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->commonPriceMock = $this->createMock(\Magento\Catalog\Model\Product\CatalogPrice::class); + $this->coreRegistryMock = $this->createMock(\Magento\Framework\Registry::class); $methods = ['getStoreId', 'getWebsiteId', 'getCustomerGroupId', 'getPriceModel', '__wakeup']; - $this->productMock = $this->getMock(\Magento\Catalog\Model\Product::class, $methods, [], '', false); - $this->priceModelMock = $this->getMock( + $this->productMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, $methods); + $this->priceModelMock = $this->createPartialMock( \Magento\Catalog\Model\Product\Type\Price::class, - ['getTotalPrices'], - [], - '', - false + ['getTotalPrices'] ); $this->catalogPrice = new \Magento\Bundle\Model\Product\CatalogPrice( $this->storeManagerMock, @@ -96,9 +87,9 @@ public function testGetCatalogPriceWithCurrentStore() public function testGetCatalogPriceWithCustomStore() { - $storeMock = $this->getMock(\Magento\Store\Api\Data\StoreInterface::class); + $storeMock = $this->createMock(\Magento\Store\Api\Data\StoreInterface::class); $storeMock->expects($this->once())->method('getId')->willReturn('store_id'); - $currentStoreMock = $this->getMock(\Magento\Store\Api\Data\StoreInterface::class); + $currentStoreMock = $this->createMock(\Magento\Store\Api\Data\StoreInterface::class); $currentStoreMock->expects($this->once())->method('getId')->willReturn('current_store_id'); $this->coreRegistryMock->expects($this->once())->method('unregister')->with('rule_data'); diff --git a/app/code/Magento/Bundle/Test/Unit/Model/Product/CopyConstructor/BundleTest.php b/app/code/Magento/Bundle/Test/Unit/Model/Product/CopyConstructor/BundleTest.php index 2f414455af4da..831098cc44c38 100644 --- a/app/code/Magento/Bundle/Test/Unit/Model/Product/CopyConstructor/BundleTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Model/Product/CopyConstructor/BundleTest.php @@ -12,7 +12,7 @@ use Magento\Catalog\Model\Product\Type; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class BundleTest extends \PHPUnit_Framework_TestCase +class BundleTest extends \PHPUnit\Framework\TestCase { /** * @var Bundle diff --git a/app/code/Magento/Bundle/Test/Unit/Model/Product/LinksListTest.php b/app/code/Magento/Bundle/Test/Unit/Model/Product/LinksListTest.php index 4cb64c76c610d..6ac3cc11957a6 100644 --- a/app/code/Magento/Bundle/Test/Unit/Model/Product/LinksListTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Model/Product/LinksListTest.php @@ -9,7 +9,7 @@ use \Magento\Bundle\Model\Product\LinksList; -class LinksListTest extends \PHPUnit_Framework_TestCase +class LinksListTest extends \PHPUnit\Framework\TestCase { /** * @var LinksList @@ -43,21 +43,13 @@ class LinksListTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->linkFactoryMock = $this->getMock( - \Magento\Bundle\Api\Data\LinkInterfaceFactory::class, - [ + $this->linkFactoryMock = $this->createPartialMock(\Magento\Bundle\Api\Data\LinkInterfaceFactory::class, [ 'create', - ], - [], - '', - false - ); + ]); $this->dataObjectHelperMock = $this->getMockBuilder(\Magento\Framework\Api\DataObjectHelper::class) ->disableOriginalConstructor() ->getMock(); - $this->selectionMock = $this->getMock( - \Magento\Catalog\Model\Product::class, - [ + $this->selectionMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, [ 'getSelectionPriceType', 'getSelectionPriceValue', 'getData', @@ -66,24 +58,14 @@ protected function setUp() 'getSelectionCanChangeQty', 'getSelectionId', '__wakeup' - ], - [], - '', - false - ); - $this->productMock = $this->getMock( - \Magento\Catalog\Model\Product::class, - [ + ]); + $this->productMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, [ 'getTypeInstance', 'getStoreId', 'getPriceType', '__wakeup' - ], - [], - '', - false - ); - $this->productTypeMock = $this->getMock(\Magento\Bundle\Model\Product\Type::class, [], [], '', false); + ]); + $this->productTypeMock = $this->createMock(\Magento\Bundle\Model\Product\Type::class); $this->model = new LinksList($this->linkFactoryMock, $this->productTypeMock, $this->dataObjectHelperMock); } @@ -105,7 +87,7 @@ public function testLinksList() $this->selectionMock->expects($this->once())->method('getIsDefault')->willReturn(true); $this->selectionMock->expects($this->once())->method('getSelectionQty')->willReturn(66); $this->selectionMock->expects($this->once())->method('getSelectionCanChangeQty')->willReturn(22); - $linkMock = $this->getMock(\Magento\Bundle\Api\Data\LinkInterface::class); + $linkMock = $this->createMock(\Magento\Bundle\Api\Data\LinkInterface::class); $this->dataObjectHelperMock->expects($this->once()) ->method('populateWithArray') ->with($linkMock, ['some data'], \Magento\Bundle\Api\Data\LinkInterface::class)->willReturnSelf(); diff --git a/app/code/Magento/Bundle/Test/Unit/Model/Product/OptionListTest.php b/app/code/Magento/Bundle/Test/Unit/Model/Product/OptionListTest.php index 8cf294e3593b4..47a18f9544c91 100644 --- a/app/code/Magento/Bundle/Test/Unit/Model/Product/OptionListTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Model/Product/OptionListTest.php @@ -9,7 +9,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class OptionListTest extends \PHPUnit_Framework_TestCase +class OptionListTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Bundle\Model\Product\OptionList @@ -48,22 +48,15 @@ class OptionListTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->typeMock = $this->getMock(\Magento\Bundle\Model\Product\Type::class, [], [], '', false); - $this->optionFactoryMock = $this->getMock( + $this->typeMock = $this->createMock(\Magento\Bundle\Model\Product\Type::class); + $this->optionFactoryMock = $this->createPartialMock( \Magento\Bundle\Api\Data\OptionInterfaceFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->dataObjectHelperMock = $this->getMock(\Magento\Framework\Api\DataObjectHelper::class, [], [], '', false); - $this->linkListMock = $this->getMock(\Magento\Bundle\Model\Product\LinksList::class, [], [], '', false); - $this->extensionAttributesFactoryMock = $this->getMock( - \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface::class, - [], - [], - '', - false + $this->dataObjectHelperMock = $this->createMock(\Magento\Framework\Api\DataObjectHelper::class); + $this->linkListMock = $this->createMock(\Magento\Bundle\Model\Product\LinksList::class); + $this->extensionAttributesFactoryMock = $this->createMock( + \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface::class ); $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); @@ -85,20 +78,19 @@ public function testGetItems() $optionData = ['title' => 'test title']; $productSku = 'product_sku'; - $productMock = $this->getMock(\Magento\Catalog\Api\Data\ProductInterface::class); + $productMock = $this->createMock(\Magento\Catalog\Api\Data\ProductInterface::class); $productMock->expects($this->once())->method('getSku')->willReturn($productSku); - $optionMock = $this->getMock( + $optionMock = $this->createPartialMock( \Magento\Bundle\Model\Option::class, - ['getOptionId', 'getData', 'getTitle', 'getDefaultTitle'], - [], - '', - false - ); - $optionsCollMock = $this->objectManager->getCollectionMock( - \Magento\Bundle\Model\ResourceModel\Option\Collection::class, - [$optionMock] + ['getOptionId', 'getData', 'getTitle', 'getDefaultTitle'] ); + $optionsCollMock = $this->getMockBuilder(\Magento\Bundle\Model\ResourceModel\Option\Collection::class) + ->disableOriginalConstructor() + ->getMock(); + $optionsCollMock->expects($this->any()) + ->method('getIterator') + ->willReturn(new \ArrayIterator([$optionMock])); $this->typeMock->expects($this->once()) ->method('getOptionsCollection') ->with($productMock) @@ -109,7 +101,7 @@ public function testGetItems() $optionMock->expects($this->once())->method('getTitle')->willReturn(null); $optionMock->expects($this->exactly(2))->method('getDefaultTitle')->willReturn($optionData['title']); - $linkMock = $this->getMock(\Magento\Bundle\Api\Data\LinkInterface::class); + $linkMock = $this->createMock(\Magento\Bundle\Api\Data\LinkInterface::class); $this->linkListMock->expects($this->once()) ->method('getItems') ->with($productMock, $optionId) diff --git a/app/code/Magento/Bundle/Test/Unit/Model/Product/PriceTest.php b/app/code/Magento/Bundle/Test/Unit/Model/Product/PriceTest.php index cf7d266bcb8db..760fac6dfa4ab 100644 --- a/app/code/Magento/Bundle/Test/Unit/Model/Product/PriceTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Model/Product/PriceTest.php @@ -5,13 +5,13 @@ */ namespace Magento\Bundle\Test\Unit\Model\Product; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; use Magento\Catalog\Api\Data\ProductTierPriceExtensionFactory; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class PriceTest extends \PHPUnit_Framework_TestCase +class PriceTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogRule\Model\ResourceModel\RuleFactory|\PHPUnit_Framework_MockObject_MockObject @@ -77,32 +77,26 @@ class PriceTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->ruleFactoryMock = $this->getMock( + $this->ruleFactoryMock = $this->createPartialMock( \Magento\CatalogRule\Model\ResourceModel\RuleFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); - $this->localeDateMock = $this->getMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); - $this->customerSessionMock = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); - $this->eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); - $this->catalogHelperMock = $this->getMock(\Magento\Catalog\Helper\Data::class, [], [], '', false); - $this->storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->localeDateMock = $this->createMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); + $this->customerSessionMock = $this->createMock(\Magento\Customer\Model\Session::class); + $this->eventManagerMock = $this->createMock(\Magento\Framework\Event\ManagerInterface::class); + $this->catalogHelperMock = $this->createMock(\Magento\Catalog\Helper\Data::class); + $this->storeMock = $this->createPartialMock(\Magento\Store\Model\Store::class, ['roundPrice']); $this->priceCurrency = $this->getMockBuilder( \Magento\Framework\Pricing\PriceCurrencyInterface::class )->getMock(); $this->groupManagement = $this->getMockBuilder(\Magento\Customer\Api\GroupManagementInterface::class) ->getMockForAbstractClass(); - $tpFactory = $this->getMock( + $tpFactory = $this->createPartialMock( \Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $scopeConfig = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $scopeConfig = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $this->serializer = $this->getMockBuilder(\Magento\Framework\Serialize\Serializer\Json::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php b/app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php index 4c1825b9422c3..d5a11e0310d35 100644 --- a/app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php @@ -20,7 +20,7 @@ * Class TypeTest * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class TypeTest extends \PHPUnit_Framework_TestCase +class TypeTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Bundle\Model\ResourceModel\BundleFactory|\PHPUnit_Framework_MockObject_MockObject @@ -249,6 +249,7 @@ public function testPrepareForCartAdvancedWithoutOptions() ->willReturn($productType); $optionCollection->expects($this->any()) ->method('appendSelections') + ->with($selectionCollection, true, true) ->willReturn([$option]); $productType->expects($this->once()) ->method('setStoreFilter'); @@ -433,7 +434,8 @@ function ($key) use ($optionCollection, $selectionCollection) { ->method('getItemById') ->willReturn($option); $optionCollection->expects($this->once()) - ->method('appendSelections'); + ->method('appendSelections') + ->with($selectionCollection, true, true); $productType->expects($this->once()) ->method('setStoreFilter'); $buyRequest->expects($this->once()) @@ -668,7 +670,8 @@ function ($key) use ($optionCollection, $selectionCollection) { ->method('getItemById') ->willReturn($option); $optionCollection->expects($this->once()) - ->method('appendSelections'); + ->method('appendSelections') + ->with($selectionCollection, true, true); $productType->expects($this->once()) ->method('setStoreFilter'); $buyRequest->expects($this->once()) @@ -891,7 +894,8 @@ function ($key) use ($optionCollection, $selectionCollection) { ->method('getItemById') ->willReturn($option); $optionCollection->expects($this->once()) - ->method('appendSelections'); + ->method('appendSelections') + ->with($selectionCollection, true, true); $productType->expects($this->once()) ->method('setStoreFilter'); $buyRequest->expects($this->once()) @@ -1169,7 +1173,8 @@ function ($key) use ($optionCollection, $selectionCollection) { } ); $optionCollection->expects($this->once()) - ->method('appendSelections'); + ->method('appendSelections') + ->with($selectionCollection, true, true); $productType->expects($this->once()) ->method('setStoreFilter'); $buyRequest->expects($this->once()) @@ -1525,21 +1530,9 @@ public function testHasWeightTrue() public function testGetIdentities() { $identities = ['id1', 'id2']; - $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); - $optionMock = $this->getMock( - \Magento\Bundle\Model\Option::class, - ['getSelections', '__wakeup'], - [], - '', - false - ); - $optionCollectionMock = $this->getMock( - \Magento\Bundle\Model\ResourceModel\Option\Collection::class, - [], - [], - '', - false - ); + $productMock = $this->createMock(\Magento\Catalog\Model\Product::class); + $optionMock = $this->createPartialMock(\Magento\Bundle\Model\Option::class, ['getSelections', '__wakeup']); + $optionCollectionMock = $this->createMock(\Magento\Bundle\Model\ResourceModel\Option\Collection::class); $cacheKey = '_cache_instance_options_collection'; $productMock->expects($this->once()) ->method('getIdentities') diff --git a/app/code/Magento/Bundle/Test/Unit/Model/ProductOptionProcessorTest.php b/app/code/Magento/Bundle/Test/Unit/Model/ProductOptionProcessorTest.php index cd68b7e73e664..0bd9a668102e7 100644 --- a/app/code/Magento/Bundle/Test/Unit/Model/ProductOptionProcessorTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Model/ProductOptionProcessorTest.php @@ -12,7 +12,7 @@ use Magento\Framework\DataObject\Factory as DataObjectFactory; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class ProductOptionProcessorTest extends \PHPUnit_Framework_TestCase +class ProductOptionProcessorTest extends \PHPUnit\Framework\TestCase { /** * @var ProductOptionProcessor @@ -46,6 +46,7 @@ protected function setUp() 'getBundleOption', 'getBundleOptionQty', 'create', + 'addData' ]) ->disableOriginalConstructor() ->getMock(); @@ -184,6 +185,8 @@ public function testConvertToProductOption( if (!empty($expected)) { $this->assertArrayHasKey($expected, $result); $this->assertTrue(is_array($result[$expected])); + } else { + $this->assertEmpty($result); } } diff --git a/app/code/Magento/Bundle/Test/Unit/Model/ResourceModel/Selection/CollectionTest.php b/app/code/Magento/Bundle/Test/Unit/Model/ResourceModel/Selection/CollectionTest.php index 7c4c2f3056757..cbe34639e8267 100644 --- a/app/code/Magento/Bundle/Test/Unit/Model/ResourceModel/Selection/CollectionTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Model/ResourceModel/Selection/CollectionTest.php @@ -17,7 +17,7 @@ /** * Class CollectionTest. */ -class CollectionTest extends \PHPUnit_Framework_TestCase +class CollectionTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Bundle/Test/Unit/Model/Sales/Order/Pdf/Items/AbstractItemsTest.php b/app/code/Magento/Bundle/Test/Unit/Model/Sales/Order/Pdf/Items/AbstractItemsTest.php index 69aaa0ed2bea8..ecce34363819e 100644 --- a/app/code/Magento/Bundle/Test/Unit/Model/Sales/Order/Pdf/Items/AbstractItemsTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Model/Sales/Order/Pdf/Items/AbstractItemsTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Bundle\Test\Unit\Model\Sales\Order\Pdf\Items; -class AbstractItemsTest extends \PHPUnit_Framework_TestCase +class AbstractItemsTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Sales\Model\Order\Item|\PHPUnit_Framework_MockObject_MockObject */ protected $orderItem; @@ -18,16 +18,13 @@ class AbstractItemsTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->orderItem = $this->getMock( + $this->orderItem = $this->createPartialMock( \Magento\Sales\Model\Order\Item::class, - ['getProductOptions', '__wakeup', 'getParentItem', 'getOrderItem', 'getOrderItemId', 'getId'], - [], - '', - false + ['getProductOptions', '__wakeup', 'getParentItem', 'getOrderItem', 'getOrderItemId', 'getId'] ); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->serializer = $this->getMock(\Magento\Framework\Serialize\Serializer\Json::class); + $this->serializer = $this->createMock(\Magento\Framework\Serialize\Serializer\Json::class); $this->model = $objectManager->getObject( \Magento\Bundle\Model\Sales\Order\Pdf\Items\Shipment::class, [ @@ -41,10 +38,10 @@ protected function setUp() */ public function testGetChildrenEmptyItems($class, $method, $returnClass) { - $salesModel = $this->getMock($returnClass, ['getAllItems', '__wakeup'], [], '', false); + $salesModel = $this->createPartialMock($returnClass, ['getAllItems', '__wakeup']); $salesModel->expects($this->once())->method('getAllItems')->will($this->returnValue([])); - $item = $this->getMock($class, [$method, 'getOrderItem', '__wakeup'], [], '', false); + $item = $this->createPartialMock($class, [$method, 'getOrderItem', '__wakeup']); $item->expects($this->once())->method($method)->will($this->returnValue($salesModel)); $item->expects($this->once())->method('getOrderItem')->will($this->returnValue($this->orderItem)); $this->orderItem->expects($this->any())->method('getId')->will($this->returnValue(1)); @@ -79,7 +76,7 @@ public function getChildrenEmptyItemsDataProvider() public function testGetChildren($parentItem) { if ($parentItem) { - $parentItem = $this->getMock(\Magento\Sales\Model\Order\Item::class, ['getId', '__wakeup'], [], '', false); + $parentItem = $this->createPartialMock(\Magento\Sales\Model\Order\Item::class, ['getId', '__wakeup']); $parentItem->expects($this->any())->method('getId')->will($this->returnValue(1)); } $this->orderItem->expects($this->any())->method('getOrderItem')->will($this->returnSelf()); @@ -87,21 +84,12 @@ public function testGetChildren($parentItem) $this->orderItem->expects($this->any())->method('getOrderItemId')->will($this->returnValue(2)); $this->orderItem->expects($this->any())->method('getId')->will($this->returnValue(1)); - $salesModel = $this->getMock( - \Magento\Sales\Model\Order\Invoice::class, - ['getAllItems', '__wakeup'], - [], - '', - false - ); + $salesModel = $this->createPartialMock(\Magento\Sales\Model\Order\Invoice::class, ['getAllItems', '__wakeup']); $salesModel->expects($this->once())->method('getAllItems')->will($this->returnValue([$this->orderItem])); - $item = $this->getMock( + $item = $this->createPartialMock( \Magento\Sales\Model\Order\Invoice\Item::class, - ['getInvoice', 'getOrderItem', '__wakeup'], - [], - '', - false + ['getInvoice', 'getOrderItem', '__wakeup'] ); $item->expects($this->once())->method('getInvoice')->will($this->returnValue($salesModel)); $item->expects($this->any())->method('getOrderItem')->will($this->returnValue($this->orderItem)); @@ -143,12 +131,9 @@ public function isShipmentSeparatelyWithoutItemDataProvider() public function testIsShipmentSeparatelyWithItem($productOptions, $result, $parentItem) { if ($parentItem) { - $parentItem = $this->getMock( + $parentItem = $this->createPartialMock( \Magento\Sales\Model\Order\Item::class, - ['getProductOptions', '__wakeup'], - [], - '', - false + ['getProductOptions', '__wakeup'] ); $parentItem->expects($this->any())->method('getProductOptions')->will($this->returnValue($productOptions)); } else { @@ -197,12 +182,9 @@ public function isChildCalculatedWithoutItemDataProvider() public function testIsChildCalculatedWithItem($productOptions, $result, $parentItem) { if ($parentItem) { - $parentItem = $this->getMock( + $parentItem = $this->createPartialMock( \Magento\Sales\Model\Order\Item::class, - ['getProductOptions', '__wakeup'], - [], - '', - false + ['getProductOptions', '__wakeup'] ); $parentItem->expects($this->any())->method('getProductOptions')->will($this->returnValue($productOptions)); } else { diff --git a/app/code/Magento/Bundle/Test/Unit/Model/Sales/Order/Plugin/ItemTest.php b/app/code/Magento/Bundle/Test/Unit/Model/Sales/Order/Plugin/ItemTest.php index 432009ca1d620..151fbfc6ee46a 100644 --- a/app/code/Magento/Bundle/Test/Unit/Model/Sales/Order/Plugin/ItemTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Model/Sales/Order/Plugin/ItemTest.php @@ -6,7 +6,7 @@ namespace Magento\Bundle\Test\Unit\Model\Sales\Order\Plugin; -class ItemTest extends \PHPUnit_Framework_TestCase +class ItemTest extends \PHPUnit\Framework\TestCase { private $plugin; diff --git a/app/code/Magento/Bundle/Test/Unit/Pricing/Adjustment/CalculatorTest.php b/app/code/Magento/Bundle/Test/Unit/Pricing/Adjustment/CalculatorTest.php index 7abfb92842b10..f7f6b30daa300 100644 --- a/app/code/Magento/Bundle/Test/Unit/Pricing/Adjustment/CalculatorTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Pricing/Adjustment/CalculatorTest.php @@ -19,7 +19,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class CalculatorTest extends \PHPUnit_Framework_TestCase +class CalculatorTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\Pricing\SaleableInterface|\PHPUnit_Framework_MockObject_MockObject @@ -74,12 +74,12 @@ protected function setUp() ->getMock(); $priceCurrency = $this->getMockBuilder(\Magento\Framework\Pricing\PriceCurrencyInterface::class)->getMock(); - $priceInfo = $this->getMock(\Magento\Framework\Pricing\PriceInfo\Base::class, [], [], '', false); + $priceInfo = $this->createMock(\Magento\Framework\Pricing\PriceInfo\Base::class); $priceInfo->expects($this->any())->method('getPrice')->will( $this->returnCallback( function ($type) { if (!isset($this->priceMocks[$type])) { - throw new \PHPUnit_Framework_ExpectationFailedException('Unexpected type of price model'); + throw new \PHPUnit\Framework\ExpectationFailedException('Unexpected type of price model'); } return $this->priceMocks[$type]; } @@ -94,20 +94,8 @@ function ($type) { $this->saleableItem->expects($this->any())->method('getStore')->will($this->returnValue($store)); - $this->baseCalculator = $this->getMock( - \Magento\Framework\Pricing\Adjustment\Calculator::class, - [], - [], - '', - false - ); - $this->amountFactory = $this->getMock( - \Magento\Framework\Pricing\Amount\AmountFactory::class, - [], - [], - '', - false - ); + $this->baseCalculator = $this->createMock(\Magento\Framework\Pricing\Adjustment\Calculator::class); + $this->amountFactory = $this->createMock(\Magento\Framework\Pricing\Amount\AmountFactory::class); $this->selectionFactory = $this->getMockBuilder(\Magento\Bundle\Pricing\Price\BundleSelectionFactory::class) ->disableOriginalConstructor() @@ -136,10 +124,10 @@ function ($type) { public function testEmptySelectionPriceList() { - $option = $this->getMock(\Magento\Bundle\Model\Option::class, ['getSelections', '__wakeup'], [], '', false); + $option = $this->createPartialMock(\Magento\Bundle\Model\Option::class, ['getSelections', '__wakeup']); $option->expects($this->any())->method('getSelections') ->will($this->returnValue(null)); - $bundleProduct = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $bundleProduct = $this->createMock(\Magento\Catalog\Model\Product::class); $this->assertSame([], $this->model->createSelectionPriceList($option, $bundleProduct)); } @@ -164,7 +152,7 @@ public function testGetterAmount($amountForBundle, $optionList, $expectedResult) } $this->selectionPriceListProvider->expects($this->any())->method('getPriceList')->willReturn($optionSelections); - $price = $this->getMock(\Magento\Bundle\Pricing\Price\BundleOptionPrice::class, [], [], '', false); + $price = $this->createMock(\Magento\Bundle\Pricing\Price\BundleOptionPrice::class); $this->priceMocks[Price\BundleOptionPrice::PRICE_CODE] = $price; // Price type of saleable items @@ -233,7 +221,7 @@ protected function createAmountMock($amountData) protected function createOptionMock($optionData) { /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Bundle\Model\Option $option */ - $option = $this->getMock(\Magento\Bundle\Model\Option::class, ['isMultiSelection', '__wakeup'], [], '', false); + $option = $this->createPartialMock(\Magento\Bundle\Model\Option::class, ['isMultiSelection', '__wakeup']); $option->expects($this->any())->method('isMultiSelection') ->will($this->returnValue($optionData['isMultiSelection'])); $selections = []; diff --git a/app/code/Magento/Bundle/Test/Unit/Pricing/Price/BundleOptionPriceTest.php b/app/code/Magento/Bundle/Test/Unit/Pricing/Price/BundleOptionPriceTest.php index 9681134cd7626..b6485d0e441e9 100644 --- a/app/code/Magento/Bundle/Test/Unit/Pricing/Price/BundleOptionPriceTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Pricing/Price/BundleOptionPriceTest.php @@ -11,7 +11,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class BundleOptionPriceTest extends \PHPUnit_Framework_TestCase +class BundleOptionPriceTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Bundle\Pricing\Price\BundleOptionPrice @@ -55,8 +55,8 @@ class BundleOptionPriceTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->priceInfoMock = $this->getMock(\Magento\Framework\Pricing\PriceInfo\Base::class, [], [], '', false); - $this->saleableItemMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $this->priceInfoMock = $this->createMock(\Magento\Framework\Pricing\PriceInfo\Base::class); + $this->saleableItemMock = $this->createMock(\Magento\Catalog\Model\Product::class); $priceCurrency = $this->getMockBuilder(\Magento\Framework\Pricing\PriceCurrencyInterface::class)->getMock(); $this->saleableItemMock->expects($this->once()) ->method('getPriceInfo') @@ -78,26 +78,14 @@ protected function setUp() $this->selectionFactoryMock = $this->getMockBuilder(\Magento\Bundle\Pricing\Price\BundleSelectionFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->amountFactory = $this->getMock( - \Magento\Framework\Pricing\Amount\AmountFactory::class, - [], - [], - '', - false - ); + $this->amountFactory = $this->createMock(\Magento\Framework\Pricing\Amount\AmountFactory::class); $factoryCallback = $this->returnCallback( function ($fullAmount, $adjustments) { return $this->createAmountMock(['amount' => $fullAmount, 'adjustmentAmounts' => $adjustments]); } ); $this->amountFactory->expects($this->any())->method('create')->will($factoryCallback); - $this->baseCalculator = $this->getMock( - \Magento\Framework\Pricing\Adjustment\Calculator::class, - [], - [], - '', - false - ); + $this->baseCalculator = $this->createMock(\Magento\Framework\Pricing\Adjustment\Calculator::class); $taxData = $this->getMockBuilder(\Magento\Tax\Helper\Data::class) ->disableOriginalConstructor() @@ -141,7 +129,7 @@ protected function prepareOptionMocks($selectionCollection) ->method('getStoreId') ->will($this->returnValue(1)); - $priceTypeMock = $this->getMock(\Magento\Bundle\Model\Product\Type::class, [], [], '', false); + $priceTypeMock = $this->createMock(\Magento\Bundle\Model\Product\Type::class); $priceTypeMock->expects($this->atLeastOnce()) ->method('setStoreFilter') ->with($this->equalTo(1), $this->equalTo($this->saleableItemMock)) @@ -158,7 +146,7 @@ protected function prepareOptionMocks($selectionCollection) ->with($this->equalTo($optionIds), $this->equalTo($this->saleableItemMock)) ->will($this->returnValue($selectionCollection)); - $collection = $this->getMock(\Magento\Bundle\Model\ResourceModel\Option\Collection::class, [], [], '', false); + $collection = $this->createMock(\Magento\Bundle\Model\ResourceModel\Option\Collection::class); $collection->expects($this->atLeastOnce()) ->method('appendSelections') ->with($this->equalTo($selectionCollection), $this->equalTo(true), $this->equalTo(false)) @@ -188,17 +176,11 @@ public function getOptionsDataProvider() */ public function testGetOptionSelectionAmount($selectionQty, $selectionAmount) { - $selection = $this->getMock( - \Magento\Catalog\Model\Product::class, - ['getSelectionQty', '__wakeup'], - [], - '', - false - ); + $selection = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['getSelectionQty', '__wakeup']); $selection->expects($this->once()) ->method('getSelectionQty') ->will($this->returnValue($selectionQty)); - $priceMock = $this->getMock(\Magento\Bundle\Pricing\Price\BundleSelectionPrice::class, [], [], '', false); + $priceMock = $this->createMock(\Magento\Bundle\Pricing\Price\BundleSelectionPrice::class); $priceMock->expects($this->once()) ->method('getAmount') ->will($this->returnValue($selectionAmount)); @@ -222,7 +204,7 @@ public function selectionAmountDataProvider() public function testGetAmount() { - $amountMock = $this->getMock(\Magento\Framework\Pricing\Amount\AmountInterface::class); + $amountMock = $this->createMock(\Magento\Framework\Pricing\Amount\AmountInterface::class); $this->bundleCalculatorMock->expects($this->once()) ->method('getOptionsAmount') ->with($this->equalTo($this->saleableItemMock)) @@ -239,7 +221,7 @@ public function testGetAmount() protected function createAmountMock($amountData) { /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Pricing\Amount\Base $amount */ - $amount = $this->getMock(\Magento\Framework\Pricing\Amount\Base::class, [], [], '', false); + $amount = $this->createMock(\Magento\Framework\Pricing\Amount\Base::class); $amount->expects($this->any())->method('getAdjustmentAmounts')->will( $this->returnValue(isset($amountData['adjustmentAmounts']) ? $amountData['adjustmentAmounts'] : []) ); @@ -256,7 +238,7 @@ protected function createAmountMock($amountData) protected function createOptionMock($optionData) { /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Bundle\Model\Option $option */ - $option = $this->getMock(\Magento\Bundle\Model\Option::class, ['isMultiSelection', '__wakeup'], [], '', false); + $option = $this->createPartialMock(\Magento\Bundle\Model\Option::class, ['isMultiSelection', '__wakeup']); $option->expects($this->any())->method('isMultiSelection') ->will($this->returnValue($optionData['isMultiSelection'])); $selections = []; @@ -319,19 +301,13 @@ public function testCalculation($optionList, $expected) $options[] = $this->createOptionMock($optionData); } /** @var \PHPUnit_Framework_MockObject_MockObject $optionsCollection */ - $optionsCollection = $this->getMock( - \Magento\Bundle\Model\ResourceModel\Option\Collection::class, - [], - [], - '', - false - ); + $optionsCollection = $this->createMock(\Magento\Bundle\Model\ResourceModel\Option\Collection::class); $optionsCollection->expects($this->atLeastOnce())->method('appendSelections')->will($this->returnSelf()); $optionsCollection->expects($this->atLeastOnce())->method('getIterator') ->will($this->returnValue(new \ArrayIterator($options))); /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Product\Type\AbstractType $typeMock */ - $typeMock = $this->getMock(\Magento\Bundle\Model\Product\Type::class, [], [], '', false); + $typeMock = $this->createMock(\Magento\Bundle\Model\Product\Type::class); $typeMock->expects($this->any())->method('setStoreFilter')->with($storeId, $this->saleableItemMock); $typeMock->expects($this->any())->method('getOptionsCollection')->with($this->saleableItemMock) ->will($this->returnValue($optionsCollection)); diff --git a/app/code/Magento/Bundle/Test/Unit/Pricing/Price/BundleRegularPriceTest.php b/app/code/Magento/Bundle/Test/Unit/Pricing/Price/BundleRegularPriceTest.php index 7b13f8932c36f..0b81b83bcb0f3 100644 --- a/app/code/Magento/Bundle/Test/Unit/Pricing/Price/BundleRegularPriceTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Pricing/Price/BundleRegularPriceTest.php @@ -10,7 +10,7 @@ use Magento\Catalog\Pricing\Price\CustomOptionPrice; use Magento\Bundle\Model\Product\Price; -class BundleRegularPriceTest extends \PHPUnit_Framework_TestCase +class BundleRegularPriceTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Bundle\Pricing\Price\BundleRegularPrice */ protected $regularPrice; @@ -49,11 +49,11 @@ protected function setUp() ->disableOriginalConstructor() ->setMethods(['getPriceInfo', 'getPriceType', 'getPrice']) ->getMock(); - $this->bundleCalculatorMock = $this->getMock( + $this->bundleCalculatorMock = $this->createMock( \Magento\Bundle\Pricing\Adjustment\BundleCalculatorInterface::class ); - $this->priceInfoMock = $this->getMock(\Magento\Framework\Pricing\PriceInfo\Base::class, [], [], '', false); + $this->priceInfoMock = $this->createMock(\Magento\Framework\Pricing\PriceInfo\Base::class); $this->customOptionPriceMock = $this->getMockBuilder(\Magento\Catalog\Pricing\Price\CustomOptionPrice::class) ->disableOriginalConstructor() @@ -63,7 +63,7 @@ protected function setUp() ->method('getPriceInfo') ->will($this->returnValue($this->priceInfoMock)); - $this->priceCurrencyMock = $this->getMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class); + $this->priceCurrencyMock = $this->createMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->regularPrice = new \Magento\Bundle\Pricing\Price\BundleRegularPrice( diff --git a/app/code/Magento/Bundle/Test/Unit/Pricing/Price/BundleSelectionFactoryTest.php b/app/code/Magento/Bundle/Test/Unit/Pricing/Price/BundleSelectionFactoryTest.php index 06d393619f321..c836a733286e4 100644 --- a/app/code/Magento/Bundle/Test/Unit/Pricing/Price/BundleSelectionFactoryTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Pricing/Price/BundleSelectionFactoryTest.php @@ -10,7 +10,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -class BundleSelectionFactoryTest extends \PHPUnit_Framework_TestCase +class BundleSelectionFactoryTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Bundle\Pricing\Price\BundleSelectionFactory */ protected $bundleSelectionFactory; @@ -29,10 +29,10 @@ class BundleSelectionFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->bundleMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); - $this->selectionMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $this->bundleMock = $this->createMock(\Magento\Catalog\Model\Product::class); + $this->selectionMock = $this->createMock(\Magento\Catalog\Model\Product::class); - $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->bundleSelectionFactory = $this->objectManagerHelper->getObject( @@ -45,7 +45,7 @@ protected function setUp() public function testCreate() { - $result = $this->getMock(\Magento\Bundle\Pricing\Price\BundleSelectionPrice::class, [], [], '', false); + $result = $this->createMock(\Magento\Bundle\Pricing\Price\BundleSelectionPrice::class); $this->objectManagerMock->expects($this->once()) ->method('create') ->with( diff --git a/app/code/Magento/Bundle/Test/Unit/Pricing/Price/BundleSelectionPriceTest.php b/app/code/Magento/Bundle/Test/Unit/Pricing/Price/BundleSelectionPriceTest.php index 296676dd9d079..64140ef920cbe 100644 --- a/app/code/Magento/Bundle/Test/Unit/Pricing/Price/BundleSelectionPriceTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Pricing/Price/BundleSelectionPriceTest.php @@ -14,7 +14,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class BundleSelectionPriceTest extends \PHPUnit_Framework_TestCase +class BundleSelectionPriceTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Bundle\Pricing\Price\BundleSelectionPrice @@ -76,63 +76,27 @@ class BundleSelectionPriceTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->productMock = $this->getMock( + $this->productMock = $this->createPartialMock( \Magento\Catalog\Model\Product::class, - ['__wakeup', 'getPriceInfo', 'getSelectionPriceType', 'getSelectionPriceValue'], - [], - '', - false + ['__wakeup', 'getPriceInfo', 'getSelectionPriceType', 'getSelectionPriceValue'] ); - $this->bundleMock = $this->getMock( + $this->bundleMock = $this->createPartialMock( \Magento\Catalog\Model\Product::class, - ['__wakeup', 'getPriceType', 'getPriceInfo', 'setFinalPrice', 'getData'], - [], - '', - false + ['__wakeup', 'getPriceType', 'getPriceInfo', 'setFinalPrice', 'getData'] ); $this->calculatorMock = $this->getMockBuilder(\Magento\Framework\Pricing\Adjustment\CalculatorInterface::class) ->getMockForAbstractClass(); - $this->eventManagerMock = $this->getMock( - \Magento\Framework\Event\Manager::class, - ['dispatch'], - [], - '', - false - ); - $this->priceInfoMock = $this->getMock( - \Magento\Framework\Pricing\PriceInfo\Base::class, - ['getPrice'], - [], - '', - false - ); - $this->discountCalculatorMock = $this->getMock( - \Magento\Bundle\Pricing\Price\DiscountCalculator::class, - [], - [], - '', - false - ); - $this->finalPriceMock = $this->getMock( - \Magento\Catalog\Pricing\Price\FinalPrice::class, - [], - [], - '', - false - ); - $this->regularPriceMock = $this->getMock( - \Magento\Catalog\Pricing\Price\RegularPrice::class, - [], - [], - '', - false - ); + $this->eventManagerMock = $this->createPartialMock(\Magento\Framework\Event\Manager::class, ['dispatch']); + $this->priceInfoMock = $this->createPartialMock(\Magento\Framework\Pricing\PriceInfo\Base::class, ['getPrice']); + $this->discountCalculatorMock = $this->createMock(\Magento\Bundle\Pricing\Price\DiscountCalculator::class); + $this->finalPriceMock = $this->createMock(\Magento\Catalog\Pricing\Price\FinalPrice::class); + $this->regularPriceMock = $this->createMock(\Magento\Catalog\Pricing\Price\RegularPrice::class); $this->productMock->expects($this->atLeastOnce()) ->method('getPriceInfo') ->will($this->returnValue($this->priceInfoMock)); - $this->priceCurrencyMock = $this->getMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class); + $this->priceCurrencyMock = $this->createMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class); $this->quantity = 1; diff --git a/app/code/Magento/Bundle/Test/Unit/Pricing/Price/DiscountCalculatorTest.php b/app/code/Magento/Bundle/Test/Unit/Pricing/Price/DiscountCalculatorTest.php index 034947f27b313..b4d5029dc6386 100644 --- a/app/code/Magento/Bundle/Test/Unit/Pricing/Price/DiscountCalculatorTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Pricing/Price/DiscountCalculatorTest.php @@ -11,7 +11,7 @@ /** * Class DiscountCalculatorTest */ -class DiscountCalculatorTest extends \PHPUnit_Framework_TestCase +class DiscountCalculatorTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Bundle\Pricing\Price\DiscountCalculator @@ -43,27 +43,9 @@ class DiscountCalculatorTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->productMock = $this->getMock( - \Magento\Catalog\Model\Product::class, - [], - [], - '', - false - ); - $this->priceInfoMock = $this->getMock( - \Magento\Framework\Pricing\PriceInfo\Base::class, - ['getPrice', 'getPrices'], - [], - '', - false - ); - $this->finalPriceMock = $this->getMock( - \Magento\Catalog\Pricing\Price\FinalPrice::class, - [], - [], - '', - false - ); + $this->productMock = $this->createMock(\Magento\Catalog\Model\Product::class); + $this->priceInfoMock = $this->createPartialMock(\Magento\Framework\Pricing\PriceInfo\Base::class, ['getPrice', 'getPrices']); + $this->finalPriceMock = $this->createMock(\Magento\Catalog\Pricing\Price\FinalPrice::class); $this->priceMock = $this->getMockForAbstractClass( \Magento\Bundle\Pricing\Price\DiscountProviderInterface::class ); diff --git a/app/code/Magento/Bundle/Test/Unit/Pricing/Price/FinalPriceTest.php b/app/code/Magento/Bundle/Test/Unit/Pricing/Price/FinalPriceTest.php index bb65d39eee956..4463709391102 100644 --- a/app/code/Magento/Bundle/Test/Unit/Pricing/Price/FinalPriceTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Pricing/Price/FinalPriceTest.php @@ -16,7 +16,7 @@ /** * @SuppressWarnings(PHPMD) */ -class FinalPriceTest extends \PHPUnit_Framework_TestCase +class FinalPriceTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Bundle\Pricing\Price\FinalPrice */ protected $finalPrice; @@ -67,11 +67,11 @@ protected function prepareMock() ->disableOriginalConstructor() ->setMethods(['getPriceType', 'getPriceInfo']) ->getMock(); - $this->bundleCalculatorMock = $this->getMock( + $this->bundleCalculatorMock = $this->createMock( \Magento\Bundle\Pricing\Adjustment\BundleCalculatorInterface::class ); - $this->basePriceMock = $this->getMock(\Magento\Catalog\Pricing\Price\BasePrice::class, [], [], '', false); + $this->basePriceMock = $this->createMock(\Magento\Catalog\Pricing\Price\BasePrice::class); $this->basePriceMock->expects($this->any()) ->method('getValue') ->will($this->returnValue($this->baseAmount)); @@ -84,7 +84,7 @@ protected function prepareMock() ->disableOriginalConstructor() ->getMock(); - $this->priceInfoMock = $this->getMock(\Magento\Framework\Pricing\PriceInfo\Base::class, [], [], '', false); + $this->priceInfoMock = $this->createMock(\Magento\Framework\Pricing\PriceInfo\Base::class); $this->priceInfoMock->expects($this->atLeastOnce()) ->method('getPrice') @@ -98,7 +98,7 @@ protected function prepareMock() ->method('getPriceInfo') ->will($this->returnValue($this->priceInfoMock)); - $this->priceCurrencyMock = $this->getMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class); + $this->priceCurrencyMock = $this->createMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->finalPrice = new \Magento\Bundle\Pricing\Price\FinalPrice( diff --git a/app/code/Magento/Bundle/Test/Unit/Pricing/Price/SpecialPriceTest.php b/app/code/Magento/Bundle/Test/Unit/Pricing/Price/SpecialPriceTest.php index b006110a16ae9..f38dfc5538cf3 100644 --- a/app/code/Magento/Bundle/Test/Unit/Pricing/Price/SpecialPriceTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Pricing/Price/SpecialPriceTest.php @@ -7,7 +7,7 @@ use \Magento\Bundle\Pricing\Price\SpecialPrice; -class SpecialPriceTest extends \PHPUnit_Framework_TestCase +class SpecialPriceTest extends \PHPUnit\Framework\TestCase { /** * @var SpecialPrice @@ -40,14 +40,14 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); - $this->localeDate = $this->getMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); - $this->priceInfo = $this->getMock(\Magento\Framework\Pricing\PriceInfo\Base::class, [], [], '', false); + $this->localeDate = $this->createMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); + $this->priceInfo = $this->createMock(\Magento\Framework\Pricing\PriceInfo\Base::class); $this->saleable->expects($this->once()) ->method('getPriceInfo') ->will($this->returnValue($this->priceInfo)); - $this->priceCurrencyMock = $this->getMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class); + $this->priceCurrencyMock = $this->createMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class); $objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectHelper->getObject( @@ -99,7 +99,7 @@ public function testGetValue($regularPrice, $specialPrice, $isScopeDateInInterva ->method('convertAndRound'); if ($isScopeDateInInterval) { - $price = $this->getMock(\Magento\Framework\Pricing\Price\PriceInterface::class); + $price = $this->createMock(\Magento\Framework\Pricing\Price\PriceInterface::class); $this->priceInfo->expects($this->once()) ->method('getPrice') ->with(\Magento\Catalog\Pricing\Price\RegularPrice::PRICE_CODE) diff --git a/app/code/Magento/Bundle/Test/Unit/Pricing/Price/TierPriceTest.php b/app/code/Magento/Bundle/Test/Unit/Pricing/Price/TierPriceTest.php index 1cc8f190f1850..8d7b7c68ff279 100644 --- a/app/code/Magento/Bundle/Test/Unit/Pricing/Price/TierPriceTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Pricing/Price/TierPriceTest.php @@ -13,7 +13,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class TierPriceTest extends \PHPUnit_Framework_TestCase +class TierPriceTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -50,7 +50,7 @@ class TierPriceTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->priceInfo = $this->getMock(\Magento\Framework\Pricing\PriceInfo\Base::class, [], [], '', false); + $this->priceInfo = $this->createMock(\Magento\Framework\Pricing\PriceInfo\Base::class); $this->product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->setMethods(['getPriceInfo', 'hasCustomerGroupId', 'getCustomerGroupId', 'getResource', '__wakeup']) @@ -61,11 +61,11 @@ protected function setUp() ->method('getPriceInfo') ->will($this->returnValue($this->priceInfo)); - $this->calculator = $this->getMock(\Magento\Framework\Pricing\Adjustment\Calculator::class, [], [], '', false); + $this->calculator = $this->createMock(\Magento\Framework\Pricing\Adjustment\Calculator::class); $this->groupManagement = $this - ->getMock(\Magento\Customer\Api\GroupManagementInterface::class, [], [], '', false); + ->createMock(\Magento\Customer\Api\GroupManagementInterface::class); - $this->priceCurrencyMock = $this->getMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class); + $this->priceCurrencyMock = $this->createMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class); $objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectHelper->getObject( @@ -87,7 +87,7 @@ public function testGetterTierPriceList($tierPrices, $basePrice, $expectedResult { $this->product->setData(TierPrice::PRICE_CODE, $tierPrices); - $price = $this->getMock(\Magento\Framework\Pricing\Price\PriceInterface::class); + $price = $this->createMock(\Magento\Framework\Pricing\Price\PriceInterface::class); $price->expects($this->any()) ->method('getValue') ->will($this->returnValue($basePrice)); @@ -102,13 +102,7 @@ public function testGetterTierPriceList($tierPrices, $basePrice, $expectedResult $this->priceCurrencyMock->expects($this->never())->method('convertAndRound'); - $group = $this->getMock( - \Magento\Customer\Model\Data\Group::class, - [], - [], - '', - false - ); + $group = $this->createMock(\Magento\Customer\Model\Data\Group::class); $group->expects($this->any()) ->method('getId') ->willReturn(\Magento\Customer\Model\GroupManagement::CUST_GROUP_ALL); @@ -186,19 +180,28 @@ public function providerForGetterTierPriceList() /** * @dataProvider providerForTestGetSavePercent */ - public function testGetSavePercent($baseAmount, $savePercent) + public function testGetSavePercent($baseAmount, $tierPrice, $savePercent) { - $basePrice = 10.; + /** @var \Magento\Framework\Pricing\Amount\AmountInterface|\PHPUnit_Framework_MockObject_MockObject $amount */ $amount = $this->getMockForAbstractClass(\Magento\Framework\Pricing\Amount\AmountInterface::class); - $amount->expects($this->once())->method('getBaseAmount')->willReturn($baseAmount); - $price = $this->getMock(\Magento\Framework\Pricing\Price\PriceInterface::class); - $price->expects($this->any()) + $amount->expects($this->any()) ->method('getValue') - ->will($this->returnValue($basePrice)); + ->will($this->returnValue($tierPrice)); + + $priceAmount = $this->getMockForAbstractClass(\Magento\Framework\Pricing\Amount\AmountInterface::class); + $priceAmount->expects($this->any()) + ->method('getValue') + ->will($this->returnValue($baseAmount)); + + $price = $this->createMock(\Magento\Framework\Pricing\Price\PriceInterface::class); + $price->expects($this->any()) + ->method('getAmount') + ->will($this->returnValue($priceAmount)); $this->priceInfo->expects($this->any()) ->method('getPrice') ->will($this->returnValue($price)); + $this->assertEquals($savePercent, $this->model->getSavePercent($amount)); } @@ -208,8 +211,8 @@ public function testGetSavePercent($baseAmount, $savePercent) public function providerForTestGetSavePercent() { return [ - 'no fraction' => [9.0000, 10], - 'lower half' => [9.1234, 9], + 'no fraction' => [9.0000, 8.1, 10], + 'lower half' => [9.1234, 8.3, 9], ]; } } diff --git a/app/code/Magento/Bundle/Test/Unit/Pricing/Render/FinalPriceBoxTest.php b/app/code/Magento/Bundle/Test/Unit/Pricing/Render/FinalPriceBoxTest.php index fdd243be6ac03..abeb127413a11 100644 --- a/app/code/Magento/Bundle/Test/Unit/Pricing/Render/FinalPriceBoxTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Pricing/Render/FinalPriceBoxTest.php @@ -8,7 +8,7 @@ use Magento\Bundle\Pricing\Render\FinalPriceBox; use Magento\Catalog\Pricing\Price\CustomOptionPrice; -class FinalPriceBoxTest extends \PHPUnit_Framework_TestCase +class FinalPriceBoxTest extends \PHPUnit\Framework\TestCase { /** * @var FinalPriceBox @@ -22,7 +22,7 @@ class FinalPriceBoxTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->saleableItem = $this->getMock(\Magento\Framework\Pricing\SaleableInterface::class); + $this->saleableItem = $this->createMock(\Magento\Framework\Pricing\SaleableInterface::class); $objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectHelper->getObject( @@ -38,7 +38,7 @@ public function testShowRangePrice($optMinValue, $optMaxValue, $custMinValue, $c { $enableCustomOptionMocks = ($optMinValue == $optMaxValue); - $priceInfo = $this->getMock(\Magento\Framework\Pricing\PriceInfo\Base::class, [], [], '', false); + $priceInfo = $this->createMock(\Magento\Framework\Pricing\PriceInfo\Base::class); $bundlePrice = $this->getMockBuilder(\Magento\Bundle\Pricing\Price\FinalPrice::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/BundleDataProviderTest.php b/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/BundleDataProviderTest.php index d7a5c8c9a4b73..7b4d42568f686 100644 --- a/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/BundleDataProviderTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/BundleDataProviderTest.php @@ -12,7 +12,7 @@ use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory; use Magento\Bundle\Helper\Data; -class BundleDataProviderTest extends \PHPUnit_Framework_TestCase +class BundleDataProviderTest extends \PHPUnit\Framework\TestCase { const ALLOWED_TYPE = 'simple'; diff --git a/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AbstractModifierTest.php b/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AbstractModifierTest.php index 67ed4d121b7bc..ccb6226ccd833 100644 --- a/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AbstractModifierTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AbstractModifierTest.php @@ -12,7 +12,7 @@ use Magento\Framework\Stdlib\ArrayManager; use PHPUnit_Framework_MockObject_MockObject as MockObject; -abstract class AbstractModifierTest extends \PHPUnit_Framework_TestCase +abstract class AbstractModifierTest extends \PHPUnit\Framework\TestCase { /** * @var ModifierInterface diff --git a/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CompositeTest.php b/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CompositeTest.php index 86c6cc5a27ade..a76b53bf6c71b 100644 --- a/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CompositeTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CompositeTest.php @@ -9,7 +9,7 @@ use Magento\Bundle\Model\Product\Type; use PHPUnit_Framework_MockObject_MockObject as MockObject; -class CompositeTest extends \PHPUnit_Framework_TestCase +class CompositeTest extends \PHPUnit\Framework\TestCase { /** * @var ObjectManagerHelper @@ -60,9 +60,9 @@ protected function setUp() $this->modifiedMeta = ['modified_meta']; $this->modifierClass = 'SomeClass'; $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); - $this->locatorMock = $this->getMock(\Magento\Catalog\Model\Locator\LocatorInterface::class); - $this->productMock = $this->getMock(\Magento\Catalog\Api\Data\ProductInterface::class); + $this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); + $this->locatorMock = $this->createMock(\Magento\Catalog\Model\Locator\LocatorInterface::class); + $this->productMock = $this->createMock(\Magento\Catalog\Api\Data\ProductInterface::class); $this->locatorMock->expects($this->once()) ->method('getProduct') @@ -106,7 +106,7 @@ public function testModifyMetaWithoutModifiers() public function testModifyMetaBundleProduct() { /** @var \Magento\Ui\DataProvider\Modifier\ModifierInterface|MockObject $modifierMock */ - $modifierMock = $this->getMock(\Magento\Ui\DataProvider\Modifier\ModifierInterface::class); + $modifierMock = $this->createMock(\Magento\Ui\DataProvider\Modifier\ModifierInterface::class); $modifierMock->expects($this->once()) ->method('modifyMeta') ->with($this->meta) @@ -129,7 +129,7 @@ public function testModifyMetaBundleProduct() public function testModifyMetaNonBundleProduct() { /** @var \Magento\Ui\DataProvider\Modifier\ModifierInterface|MockObject $modifierMock */ - $modifierMock = $this->getMock(\Magento\Ui\DataProvider\Modifier\ModifierInterface::class); + $modifierMock = $this->createMock(\Magento\Ui\DataProvider\Modifier\ModifierInterface::class); $modifierMock->expects($this->never()) ->method('modifyMeta'); @@ -151,7 +151,7 @@ public function testModifyMetaNonBundleProduct() public function testModifyMetaWithException() { /** @var \Exception|MockObject $modifierMock */ - $modifierMock = $this->getMock(\Exception::class); + $modifierMock = $this->createPartialMock(\Exception::class, ['modifyMeta']); $modifierMock->expects($this->never()) ->method('modifyMeta'); diff --git a/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Listing/Collector/BundlePriceTest.php b/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Listing/Collector/BundlePriceTest.php index 2e2fc1b742bc4..8b12dbfa1af15 100644 --- a/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Listing/Collector/BundlePriceTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Listing/Collector/BundlePriceTest.php @@ -15,7 +15,7 @@ use Magento\Framework\Pricing\Amount\AmountInterface; use Magento\Framework\Pricing\PriceCurrencyInterface; -class BundlePriceTest extends \PHPUnit_Framework_TestCase +class BundlePriceTest extends \PHPUnit\Framework\TestCase { /** * @var BundlePrice diff --git a/app/code/Magento/Bundle/etc/di.xml b/app/code/Magento/Bundle/etc/di.xml index 9842b28efaa1c..287a6c8bfdbc0 100644 --- a/app/code/Magento/Bundle/etc/di.xml +++ b/app/code/Magento/Bundle/etc/di.xml @@ -160,6 +160,9 @@ Magento\Catalog\Model\Indexer\Price\CompositeProductBatchSizeManagement + + Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\CompositeProductBatchSizeAdjuster + diff --git a/app/code/Magento/Bundle/view/adminhtml/ui_component/bundle_product_listing.xml b/app/code/Magento/Bundle/view/adminhtml/ui_component/bundle_product_listing.xml index 22758cf16ce32..b259e3280bfd5 100644 --- a/app/code/Magento/Bundle/view/adminhtml/ui_component/bundle_product_listing.xml +++ b/app/code/Magento/Bundle/view/adminhtml/ui_component/bundle_product_listing.xml @@ -24,6 +24,7 @@ + Magento_Catalog::products id diff --git a/app/code/Magento/Bundle/view/adminhtml/web/js/bundle-type-handler.js b/app/code/Magento/Bundle/view/adminhtml/web/js/bundle-type-handler.js index c65ff76c8db94..90a5c5d8b4959 100644 --- a/app/code/Magento/Bundle/view/adminhtml/web/js/bundle-type-handler.js +++ b/app/code/Magento/Bundle/view/adminhtml/web/js/bundle-type-handler.js @@ -2,7 +2,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ -/*jshint browser:true jquery:true expr:true*/ + define([ 'jquery', 'Magento_Catalog/catalog/type-events', diff --git a/app/code/Magento/Bundle/view/frontend/templates/catalog/product/view/type/bundle/options.phtml b/app/code/Magento/Bundle/view/frontend/templates/catalog/product/view/type/bundle/options.phtml index 0d01afb664bd0..157e2d959720b 100644 --- a/app/code/Magento/Bundle/view/frontend/templates/catalog/product/view/type/bundle/options.phtml +++ b/app/code/Magento/Bundle/view/frontend/templates/catalog/product/view/type/bundle/options.phtml @@ -11,8 +11,9 @@ getProduct(); $helper = $this->helper('Magento\Catalog\Helper\Output'); +$stripSelection = $product->getConfigureMode() ? true : false; +$options = $block->decorateArray($block->getOptions($stripSelection)); ?> -decorateArray($block->getOptions()); ?> isSaleable()):?> diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/view/attribute.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/view/attribute.phtml index 2f62315830308..4ea207dffae7f 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/view/attribute.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/view/attribute.phtml @@ -22,6 +22,12 @@ $_attributeLabel = $block->getAtLabel(); $_attributeType = $block->getAtType(); $_attributeAddAttribute = $block->getAddAttribute(); +$renderLabel = true; +// if defined as 'none' in layout, do not render +if ($_attributeLabel == 'none') { + $renderLabel = false; +} + if ($_attributeLabel && $_attributeLabel == 'default') { $_attributeLabel = $_product->getResource()->getAttribute($_code)->getStoreLabel(); } @@ -31,10 +37,9 @@ if ($_attributeType && $_attributeType == 'text') { $_attributeValue = $_helper->productAttribute($_product, $_product->$_call(), $_code); } ?> -
- +
>
diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml index bfc90bd8ca0ea..c8c915a3140da 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml @@ -16,7 +16,8 @@ getProduct(); ?>
-
getOptions()): ?> enctype="multipart/form-data"> diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/widget/viewed/sidebar.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/widget/viewed/sidebar.phtml index 456032ebcbc24..1c4ad3105a2b5 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/widget/viewed/sidebar.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/widget/viewed/sidebar.phtml @@ -17,10 +17,8 @@ 'listing' => [ 'displayMode' => 'grid' ], - 'column' => [ - 'image' => [ - 'imageCode' => 'recently_viewed_products_images_names_widget' - ] + 'image' => [ + 'imageCode' => 'recently_viewed_products_images_names_widget' ] ] ); diff --git a/app/code/Magento/Catalog/view/frontend/web/js/catalog-add-to-cart.js b/app/code/Magento/Catalog/view/frontend/web/js/catalog-add-to-cart.js index c6021e860c6c2..7686de1d45c5d 100644 --- a/app/code/Magento/Catalog/view/frontend/web/js/catalog-add-to-cart.js +++ b/app/code/Magento/Catalog/view/frontend/web/js/catalog-add-to-cart.js @@ -97,6 +97,8 @@ define([ success: function (res) { var eventData, parameters; + $(document).trigger('ajax:addToCart', form.data().productSku); + if (self.isLoaderEnabled()) { $('body').trigger(self.options.processStop); } diff --git a/app/code/Magento/Catalog/view/frontend/web/js/storage-manager.js b/app/code/Magento/Catalog/view/frontend/web/js/storage-manager.js index 458526aa2d669..fcba9e8dcf468 100644 --- a/app/code/Magento/Catalog/view/frontend/web/js/storage-manager.js +++ b/app/code/Magento/Catalog/view/frontend/web/js/storage-manager.js @@ -66,7 +66,12 @@ define([ 'product_data_storage': { namespace: 'product_data_storage', className: 'DataStorage', - allowToSendRequest: 0 + allowToSendRequest: 0, + updateRequestConfig: { + url: '', + method: 'GET', + dataType: 'json' + } } }, requestConfig: { diff --git a/app/code/Magento/Catalog/view/frontend/web/js/zoom.js b/app/code/Magento/Catalog/view/frontend/web/js/zoom.js index 771b471537ec2..f6444223e2c54 100644 --- a/app/code/Magento/Catalog/view/frontend/web/js/zoom.js +++ b/app/code/Magento/Catalog/view/frontend/web/js/zoom.js @@ -3,6 +3,9 @@ * See COPYING.txt for license details. */ +/** + * @deprecated since version 2.2.0 + */ define([ 'jquery', 'jquery/ui' diff --git a/app/code/Magento/CatalogAnalytics/LICENSE.txt b/app/code/Magento/CatalogAnalytics/LICENSE.txt deleted file mode 100644 index 49525fd99da9c..0000000000000 --- a/app/code/Magento/CatalogAnalytics/LICENSE.txt +++ /dev/null @@ -1,48 +0,0 @@ - -Open Software License ("OSL") v. 3.0 - -This Open Software License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: - -Licensed under the Open Software License version 3.0 - - 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: - - 1. to reproduce the Original Work in copies, either alone or as part of a collective work; - - 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; - - 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Open Software License; - - 4. to perform the Original Work publicly; and - - 5. to display the Original Work publicly. - - 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. - - 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. - - 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. - - 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). - - 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. - - 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. - - 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. - - 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including 'fair use' or 'fair dealing'). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). - - 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. - - 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. - - 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. - - 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. - - 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. - - 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. - - 16. Modification of This License. This License is Copyright (C) 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. \ No newline at end of file diff --git a/app/code/Magento/CatalogAnalytics/LICENSE_AFL.txt b/app/code/Magento/CatalogAnalytics/LICENSE_AFL.txt deleted file mode 100644 index f39d641b18a19..0000000000000 --- a/app/code/Magento/CatalogAnalytics/LICENSE_AFL.txt +++ /dev/null @@ -1,48 +0,0 @@ - -Academic Free License ("AFL") v. 3.0 - -This Academic Free License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: - -Licensed under the Academic Free License version 3.0 - - 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: - - 1. to reproduce the Original Work in copies, either alone or as part of a collective work; - - 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; - - 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, under any license of your choice that does not contradict the terms and conditions, including Licensor's reserved rights and remedies, in this Academic Free License; - - 4. to perform the Original Work publicly; and - - 5. to display the Original Work publicly. - - 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. - - 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. - - 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. - - 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). - - 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. - - 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. - - 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. - - 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including "fair use" or "fair dealing"). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). - - 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. - - 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. - - 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. - - 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. - - 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. - - 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. - - 16. Modification of This License. This License is Copyright © 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Academic Free License" or "AFL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. diff --git a/app/code/Magento/CatalogAnalytics/README.md b/app/code/Magento/CatalogAnalytics/README.md deleted file mode 100644 index df125446117a3..0000000000000 --- a/app/code/Magento/CatalogAnalytics/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Magento_CatalogAnalytics module - -The Magento_CatalogAnalytics module configures data definitions for a data collection related to the Catalog module entities to be used in [Advanced Reporting](http://devdocs.magento.com/guides/v2.2/advanced-reporting/modules.html). diff --git a/app/code/Magento/CatalogAnalytics/composer.json b/app/code/Magento/CatalogAnalytics/composer.json deleted file mode 100644 index 6cda52197f80a..0000000000000 --- a/app/code/Magento/CatalogAnalytics/composer.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "magento/module-catalog-analytics", - "description": "N/A", - "require": { - "php": "7.0.2|7.0.4|~7.0.6|~7.1.0", - "magento/framework": "100.2.*", - "magento/module-catalog": "101.1.*" - }, - "type": "magento2-module", - "version": "100.2.0-dev", - "license": [ - "OSL-3.0", - "AFL-3.0" - ], - "autoload": { - "files": [ - "registration.php" - ], - "psr-4": { - "Magento\\CatalogAnalytics\\": "" - } - } -} diff --git a/app/code/Magento/CatalogAnalytics/etc/analytics.xml b/app/code/Magento/CatalogAnalytics/etc/analytics.xml deleted file mode 100644 index 22d1f2c7d7776..0000000000000 --- a/app/code/Magento/CatalogAnalytics/etc/analytics.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - products - - - - - diff --git a/app/code/Magento/CatalogAnalytics/etc/module.xml b/app/code/Magento/CatalogAnalytics/etc/module.xml deleted file mode 100644 index 7974598e17a59..0000000000000 --- a/app/code/Magento/CatalogAnalytics/etc/module.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - diff --git a/app/code/Magento/CatalogAnalytics/etc/reports.xml b/app/code/Magento/CatalogAnalytics/etc/reports.xml deleted file mode 100644 index 5dae3ef90d7b2..0000000000000 --- a/app/code/Magento/CatalogAnalytics/etc/reports.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - diff --git a/app/code/Magento/CatalogAnalytics/registration.php b/app/code/Magento/CatalogAnalytics/registration.php deleted file mode 100644 index 77d6ce154b658..0000000000000 --- a/app/code/Magento/CatalogAnalytics/registration.php +++ /dev/null @@ -1,11 +0,0 @@ - 'base_image', 'image_label' => "base_image_label", - 'image' => 'base_image', - 'image_label' => 'base_image_label', 'thumbnail' => 'thumbnail_image', 'thumbnail_label' => 'thumbnail_image_label', self::COL_MEDIA_IMAGE => 'additional_images', '_media_image_label' => 'additional_image_labels', - Product::COL_STORE => 'store_view_code', - Product::COL_ATTR_SET => 'attribute_set_code', - Product::COL_TYPE => 'product_type', - Product::COL_CATEGORY => 'categories', - Product::COL_PRODUCT_WEBSITES => 'product_websites', + self::COL_STORE => 'store_view_code', + self::COL_ATTR_SET => 'attribute_set_code', + self::COL_TYPE => 'product_type', + self::COL_CATEGORY => 'categories', + self::COL_PRODUCT_WEBSITES => 'product_websites', 'status' => 'product_online', 'news_from_date' => 'new_from_date', 'news_to_date' => 'new_to_date', @@ -266,6 +266,7 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity * Attributes codes which shows as date * * @var array + * @since 100.1.2 */ protected $dateAttrCodes = [ 'special_from_date', @@ -333,6 +334,7 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity /** * @var \Magento\Framework\EntityManager\MetadataPool + * @since 100.1.0 */ protected $metadataPool; @@ -688,7 +690,7 @@ protected function updateDataWithCategoryColumns(&$dataRow, &$rowCategories, $pr */ public function _getHeaderColumns() { - return $this->_customHeadersMapping($this->_headerColumns); + return $this->_customHeadersMapping($this->rowCustomizer->addHeaderColumns($this->_headerColumns)); } /** @@ -697,13 +699,13 @@ public function _getHeaderColumns() * @param array $customOptionsData * @param array $stockItemRows * @return void + * @deprecated Logic will be moved to _getHeaderColumns in future release + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ protected function setHeaderColumns($customOptionsData, $stockItemRows) { if (!$this->_headerColumns) { - $customOptCols = [ - 'custom_options', - ]; $this->_headerColumns = array_merge( [ self::COL_SKU, @@ -716,21 +718,19 @@ protected function setHeaderColumns($customOptionsData, $stockItemRows) $this->_getExportMainAttrCodes(), [self::COL_ADDITIONAL_ATTRIBUTES], reset($stockItemRows) ? array_keys(end($stockItemRows)) : [], - [], [ 'related_skus', 'related_position', 'crosssell_skus', 'crosssell_position', 'upsell_skus', - 'upsell_position' - ], - ['additional_images', 'additional_image_labels', 'hide_from_product_page'] + 'upsell_position', + 'additional_images', + 'additional_image_labels', + 'hide_from_product_page', + 'custom_options' + ] ); - // have we merge custom options columns - if ($customOptionsData) { - $this->_headerColumns = array_merge($this->_headerColumns, $customOptCols); - } } } @@ -782,7 +782,7 @@ protected function getItemsPerPage() } // Tested one product to have up to such size - $memoryPerProduct = 100000; + $memoryPerProduct = 500000; // Decrease memory limit to have supply $memoryUsagePercent = 0.8; // Minimum Products limit @@ -853,6 +853,7 @@ public function export() /** * {@inheritdoc} + * @since 100.2.0 */ protected function _prepareEntityCollection(\Magento\Eav\Model\Entity\Collection\AbstractCollection $collection) { @@ -888,10 +889,12 @@ protected function getExportData() $productIds = array_keys($rawData); $stockItemRows = $this->prepareCatalogInventory($productIds); - $this->rowCustomizer->prepareData($this->_getEntityCollection(), $productIds); + $this->rowCustomizer->prepareData( + $this->_prepareEntityCollection($this->_entityCollectionFactory->create()), + $productIds + ); $this->setHeaderColumns($multirawData['customOptionsData'], $stockItemRows); - $this->_headerColumns = $this->rowCustomizer->addHeaderColumns($this->_headerColumns); foreach ($rawData as $productId => $productData) { foreach ($productData as $storeId => $dataRow) { @@ -1227,16 +1230,13 @@ private function appendMultirowData(&$dataRow, &$multiRawData) return null; } elseif ($storeId != Store::DEFAULT_STORE_ID) { $dataRow[self::COL_STORE] = $this->_storeIdToCode[$storeId]; - if (isset($productData[Store::DEFAULT_STORE_ID][self::COL_VISIBILITY])) { - $dataRow[self::COL_VISIBILITY] = $productData[Store::DEFAULT_STORE_ID][self::COL_VISIBILITY]; - } } $dataRow[self::COL_SKU] = $sku; return $dataRow; } /** - * @deprecated + * @deprecated 100.1.0 * @param array $dataRow * @param array $multiRawData * @return array @@ -1459,6 +1459,7 @@ private function getMetadataPool() * Get product entity link field * * @return string + * @since 100.1.0 */ protected function getProductEntityLinkField() { diff --git a/app/code/Magento/CatalogImportExport/Model/Export/Product/Type/AbstractType.php b/app/code/Magento/CatalogImportExport/Model/Export/Product/Type/AbstractType.php index 67ae877f7a620..7ca95c0ec5e9f 100644 --- a/app/code/Magento/CatalogImportExport/Model/Export/Product/Type/AbstractType.php +++ b/app/code/Magento/CatalogImportExport/Model/Export/Product/Type/AbstractType.php @@ -11,6 +11,7 @@ * Export entity product type abstract model * * @api + * @since 100.0.2 */ abstract class AbstractType { diff --git a/app/code/Magento/CatalogImportExport/Model/Export/Product/Type/Simple.php b/app/code/Magento/CatalogImportExport/Model/Export/Product/Type/Simple.php index a0a0c68042f35..c89f4bf530c70 100644 --- a/app/code/Magento/CatalogImportExport/Model/Export/Product/Type/Simple.php +++ b/app/code/Magento/CatalogImportExport/Model/Export/Product/Type/Simple.php @@ -9,6 +9,7 @@ * Export entity product type simple model * * @api + * @since 100.0.2 */ class Simple extends \Magento\CatalogImportExport\Model\Export\Product\Type\AbstractType { diff --git a/app/code/Magento/CatalogImportExport/Model/Export/RowCustomizer/Composite.php b/app/code/Magento/CatalogImportExport/Model/Export/RowCustomizer/Composite.php index 17e2a7e857529..8034d7375b10b 100644 --- a/app/code/Magento/CatalogImportExport/Model/Export/RowCustomizer/Composite.php +++ b/app/code/Magento/CatalogImportExport/Model/Export/RowCustomizer/Composite.php @@ -12,6 +12,7 @@ * Class Composite * * @api + * @since 100.0.2 */ class Composite implements RowCustomizerInterface { diff --git a/app/code/Magento/CatalogImportExport/Model/Export/RowCustomizerInterface.php b/app/code/Magento/CatalogImportExport/Model/Export/RowCustomizerInterface.php index 2720281ab7304..b541bc78f9d76 100644 --- a/app/code/Magento/CatalogImportExport/Model/Export/RowCustomizerInterface.php +++ b/app/code/Magento/CatalogImportExport/Model/Export/RowCustomizerInterface.php @@ -9,6 +9,7 @@ * Interface RowCustomizerInterface * * @api + * @since 100.0.2 */ interface RowCustomizerInterface { diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product.php b/app/code/Magento/CatalogImportExport/Model/Import/Product.php index 55988dfd82fdb..a0f1e25cf6512 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product.php @@ -28,6 +28,7 @@ * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @codingStandardsIgnoreFile + * @since 100.0.2 */ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity { @@ -176,20 +177,24 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity /** * @var string + * @since 100.0.4 */ protected $mediaGalleryTableName; /** * @var string + * @since 100.0.4 */ protected $mediaGalleryValueTableName; /** * @var string + * @since 100.0.4 */ protected $mediaGalleryEntityToValueTableName; /** * @var string + * @since 100.0.4 */ protected $productEntityTableName; @@ -218,6 +223,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity * Attributes codes which shows as date * * @var array + * @since 100.1.2 */ protected $dateAttrCodes = [ 'special_from_date', @@ -557,24 +563,38 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity */ protected $categoryProcessor; - /** @var \Magento\Framework\App\Config\ScopeConfigInterface */ + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface + * @since 100.0.3 + */ protected $scopeConfig; - /** @var \Magento\Catalog\Model\Product\Url */ + /** + * @var \Magento\Catalog\Model\Product\Url + * @since 100.0.3 + */ protected $productUrl; - /** @var array */ + /** + * @var array + */ protected $websitesCache = []; - /** @var array */ + /** + * @var array + */ protected $categoriesCache = []; - /** @var array */ + /** + * @var array + * @since 100.0.3 + */ protected $productUrlSuffix = []; /** * @var array - * @deprecated + * @deprecated 100.1.5 + * @since 100.0.3 */ protected $productUrlKeys = []; @@ -631,10 +651,16 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity */ protected $cachedImages = null; - /** @var array */ + /** + * @var array + * @since 100.0.3 + */ protected $urlKeys = []; - /** @var array */ + /** + * @var array + * @since 100.0.3 + */ protected $rowNumbers = []; /** @@ -1337,6 +1363,7 @@ protected function _saveProductCategories(array $categoriesData) * @param array $entityRowsIn Row for insert * @param array $entityRowsUp Row for update * @return $this + * @since 100.1.0 */ public function saveProductEntity(array $entityRowsIn, array $entityRowsUp) { @@ -1423,6 +1450,7 @@ private function getNewSkuFieldsForSelect() /** * Init media gallery resources * @return void + * @since 100.0.4 */ protected function initMediaGalleryResources() { @@ -2644,6 +2672,7 @@ private function parseAttributesWithWrappedValues($attributesData) * @param string $values * @param string $delimiter * @return array + * @since 100.1.2 */ public function parseMultiselectValues($values, $delimiter = self::PSEUDO_MULTI_LINE_SEPARATOR) { @@ -2762,6 +2791,7 @@ protected function _saveValidatedBunches() * Check that url_keys are not assigned to other products in DB * * @return void + * @since 100.0.3 */ protected function checkUrlKeyDuplicates() { @@ -2790,6 +2820,7 @@ protected function checkUrlKeyDuplicates() * * @param int $storeId * @return string + * @since 100.0.3 */ protected function getProductUrlSuffix($storeId = null) { @@ -2806,6 +2837,7 @@ protected function getProductUrlSuffix($storeId = null) /** * @param array $rowData * @return string + * @since 100.0.3 */ protected function getUrlKey($rowData) { @@ -2822,6 +2854,7 @@ protected function getUrlKey($rowData) /** * @return Proxy\Product\ResourceModel + * @since 100.0.3 */ protected function getResource() { diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product/CategoryProcessor.php b/app/code/Magento/CatalogImportExport/Model/Import/Product/CategoryProcessor.php index ebaa9feb33cac..81c83c38bb546 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product/CategoryProcessor.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product/CategoryProcessor.php @@ -9,6 +9,7 @@ * Class CategoryProcessor * * @api + * @since 100.0.2 */ class CategoryProcessor { @@ -47,6 +48,7 @@ class CategoryProcessor * Failed categories during creation * * @var array + * @since 100.1.0 */ protected $failedCategories = []; @@ -198,6 +200,7 @@ private function addFailedCategory($category, $exception) * Return failed categories * * @return array + * @since 100.1.0 */ public function getFailedCategories() { @@ -208,6 +211,7 @@ public function getFailedCategories() * Resets failed categories' array * * @return $this + * @since 100.2.0 */ public function clearFailedCategories() { diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php b/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php index 60effb7489ba4..aa3f46a433a4d 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php @@ -12,6 +12,8 @@ use Magento\Framework\App\ResourceConnection; use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface; use Magento\Catalog\Api\Data\ProductInterface; +use Magento\Catalog\Model\ResourceModel\Product\Option\Value\Collection as ProductOptionValueCollection; +use Magento\Catalog\Model\ResourceModel\Product\Option\Value\CollectionFactory as ProductOptionValueCollectionFactory; /** * Entity class which provide possibility to import product custom options @@ -21,6 +23,7 @@ * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class Option extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity { @@ -247,11 +250,7 @@ class Option extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity /**#@-*/ - /** - * Collection by pages iterator - * - * @var \Magento\ImportExport\Model\ResourceModel\CollectionByPagesIterator - */ + /**#@-*/ protected $_byPagesIterator; /** @@ -324,6 +323,16 @@ class Option extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity */ private $productEntityIdentifierField; + /** + * @var ProductOptionValueCollectionFactory + */ + private $productOptionValueCollectionFactory; + + /** + * @var array + */ + private $optionTypeTitles; + /** * @param \Magento\ImportExport\Model\ResourceModel\Import\Data $importData * @param ResourceConnection $resource @@ -337,6 +346,7 @@ class Option extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $dateTime * @param ProcessingErrorAggregatorInterface $errorAggregator * @param array $data + * @param ProductOptionValueCollectionFactory $productOptionValueCollectionFactory * @throws \Magento\Framework\Exception\LocalizedException * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -353,7 +363,8 @@ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $dateTime, ProcessingErrorAggregatorInterface $errorAggregator, - array $data = [] + array $data = [], + ProductOptionValueCollectionFactory $productOptionValueCollectionFactory = null ) { $this->_resource = $resource; $this->_catalogData = $catalogData; @@ -364,6 +375,8 @@ public function __construct( $this->_colIteratorFactory = $colIteratorFactory; $this->_scopeConfig = $scopeConfig; $this->dateTime = $dateTime; + $this->productOptionValueCollectionFactory = $productOptionValueCollectionFactory + ?: \Magento\Framework\App\ObjectManager::getInstance()->get(ProductOptionValueCollectionFactory::class); if (isset($data['connection'])) { $this->_connection = $data['connection']; @@ -1125,7 +1138,7 @@ private function processOptionRow($name, $optionRow) if (isset($optionRow['price'])) { $percent_suffix = ''; if (isset($optionRow['price_type']) && $optionRow['price_type'] == 'percent') { - $percent_suffix = '%'; + $percent_suffix = '%'; } $result[self::COLUMN_ROW_PRICE] = $optionRow['price'] . $percent_suffix; } @@ -1234,6 +1247,7 @@ protected function _importData() if ($this->_isReadyForSaving($options, $titles, $typeValues)) { if ($this->getBehavior() == \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND) { $this->_compareOptionsWithExisting($options, $titles, $prices, $typeValues); + $this->restoreOriginalOptionTypeIds($typeValues, $typePrices, $typeTitles); } $this->_saveOptions( @@ -1300,12 +1314,12 @@ protected function _collectOptionMainData( $optionData = $this->_getOptionData($rowData, $this->_rowProductId, $nextOptionId, $this->_rowType); if (!$this->_isRowHasSpecificType( - $this->_rowType - ) && ($priceData = $this->_getPriceData( - $rowData, - $nextOptionId, - $this->_rowType - )) + $this->_rowType + ) && ($priceData = $this->_getPriceData( + $rowData, + $nextOptionId, + $this->_rowType + )) ) { $prices[$nextOptionId] = $priceData; } @@ -1438,6 +1452,68 @@ protected function _compareOptionsWithExisting(array &$options, array &$titles, return $this; } + /** + * Restore original IDs for existing option types. + * + * Warning: arguments are modified by reference + * + * @param array $typeValues + * @param array $typePrices + * @param array $typeTitles + * @return void + */ + private function restoreOriginalOptionTypeIds(array &$typeValues, array &$typePrices, array &$typeTitles) + { + foreach ($typeValues as $optionId => &$optionTypes) { + foreach ($optionTypes as &$optionType) { + $optionTypeId = $optionType['option_type_id']; + foreach ($typeTitles[$optionTypeId] as $storeId => $optionTypeTitle) { + $existingTypeId = $this->getExistingOptionTypeId($optionId, $storeId, $optionTypeTitle); + if ($existingTypeId) { + $optionType['option_type_id'] = $existingTypeId; + $typeTitles[$existingTypeId] = $typeTitles[$optionTypeId]; + unset($typeTitles[$optionTypeId]); + $typePrices[$existingTypeId] = $typePrices[$optionTypeId]; + unset($typePrices[$optionTypeId]); + // If option type titles match at least in one store, consider current option type as existing + break; + } + } + } + } + } + + /** + * Identify ID of the provided option type by its title in the specified store. + * + * @param int $optionId + * @param int $storeId + * @param string $optionTypeTitle + * @return int|null + */ + private function getExistingOptionTypeId($optionId, $storeId, $optionTypeTitle) + { + if (!isset($this->optionTypeTitles[$storeId])) { + /** @var ProductOptionValueCollection $optionTypeCollection */ + $optionTypeCollection = $this->productOptionValueCollectionFactory->create(); + $optionTypeCollection->addTitleToResult($storeId); + /** @var \Magento\Catalog\Model\Product\Option\Value $type */ + foreach ($optionTypeCollection as $type) { + $this->optionTypeTitles[$storeId][$type->getOptionId()][$type->getId()] = $type->getTitle(); + } + } + if (isset($this->optionTypeTitles[$storeId][$optionId]) + && is_array($this->optionTypeTitles[$storeId][$optionId]) + ) { + foreach ($this->optionTypeTitles[$storeId][$optionId] as $optionTypeId => $currentTypeTitle) { + if ($optionTypeTitle === $currentTypeTitle) { + return $optionTypeId; + } + } + } + return null; + } + /** * Parse required data from current row and store to class internal variables some data * for underlying dependent rows @@ -1569,13 +1645,13 @@ protected function _getOptionData(array $rowData, $productId, $optionId, $type) protected function _getPriceData(array $rowData, $optionId, $type) { if (in_array( - 'price', - $this->_specificTypes[$type] - ) && isset( - $rowData[self::COLUMN_PREFIX . 'price'] - ) && strlen( - $rowData[self::COLUMN_PREFIX . 'price'] - ) > 0 + 'price', + $this->_specificTypes[$type] + ) && isset( + $rowData[self::COLUMN_PREFIX . 'price'] + ) && strlen( + $rowData[self::COLUMN_PREFIX . 'price'] + ) > 0 ) { $priceData = [ 'option_id' => $optionId, @@ -1825,13 +1901,17 @@ protected function _updateProducts(array $data) * @return array * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ - protected function _parseCustomOptions($rowData) + protected function _parseCustomOptions($rowData) { $beforeOptionValueSkuDelimiter = ';'; if (empty($rowData['custom_options'])) { return $rowData; } - $rowData['custom_options'] = str_replace($beforeOptionValueSkuDelimiter, $this->_productEntity->getMultipleValueSeparator(), $rowData['custom_options']); + $rowData['custom_options'] = str_replace( + $beforeOptionValueSkuDelimiter, + $this->_productEntity->getMultipleValueSeparator(), + $rowData['custom_options'] + ); $options = []; $optionValues = explode(Product::PSEUDO_MULTI_LINE_SEPARATOR, $rowData['custom_options']); $k = 0; @@ -1843,7 +1923,7 @@ protected function _parseCustomOptions($rowData) if (!empty($nameAndValue)) { $value = isset($nameAndValue[1]) ? $nameAndValue[1] : ''; $value = trim($value); - $fieldName = trim($nameAndValue[0]); + $fieldName = trim($nameAndValue[0]); if ($value && ($fieldName == 'name')) { if ($name != $value) { $name = $value; @@ -1882,7 +1962,7 @@ private function getProductEntityLinkField() { if (!$this->productEntityLinkField) { $this->productEntityLinkField = $this->getMetadataPool() - ->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class) + ->getMetadata(ProductInterface::class) ->getLinkField(); } return $this->productEntityLinkField; @@ -1897,7 +1977,7 @@ private function getProductIdentifierField() { if (!$this->productEntityIdentifierField) { $this->productEntityIdentifierField = $this->getMetadataPool() - ->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class) + ->getMetadata(ProductInterface::class) ->getIdentifierField(); } return $this->productEntityIdentifierField; diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product/RowValidatorInterface.php b/app/code/Magento/CatalogImportExport/Model/Import/Product/RowValidatorInterface.php index 8cd3d168c771a..17f7fae28ba75 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product/RowValidatorInterface.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product/RowValidatorInterface.php @@ -9,6 +9,7 @@ * Interface RowValidatorInterface * * @api + * @since 100.0.2 */ interface RowValidatorInterface extends \Magento\Framework\Validator\ValidatorInterface { diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product/SkuProcessor.php b/app/code/Magento/CatalogImportExport/Model/Import/Product/SkuProcessor.php index bafcdf10b3b22..addd1523f87a0 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product/SkuProcessor.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product/SkuProcessor.php @@ -9,6 +9,7 @@ * Class SkuProcessor * * @api + * @since 100.0.2 */ class SkuProcessor { diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/AbstractType.php b/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/AbstractType.php index e521f1fa8797c..5681b1aa6607d 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/AbstractType.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/AbstractType.php @@ -17,6 +17,7 @@ * * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ abstract class AbstractType { @@ -134,6 +135,7 @@ abstract class AbstractType * Product metadata pool * * @var \Magento\Framework\EntityManager\MetadataPool + * @since 100.1.0 */ protected $metadataPool; @@ -553,6 +555,7 @@ public function saveData() * Get product metadata pool * * @return \Magento\Framework\EntityManager\MetadataPool + * @since 100.1.0 */ protected function getMetadataPool() { @@ -567,6 +570,7 @@ protected function getMetadataPool() * Get product entity link field * * @return string + * @since 100.1.0 */ protected function getProductEntityLinkField() { @@ -580,6 +584,7 @@ protected function getProductEntityLinkField() /** * Clean cached values + * @since 100.2.0 */ public function __destruct() { diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/Simple.php b/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/Simple.php index 66bd323182a06..6e836284d013d 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/Simple.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/Simple.php @@ -9,6 +9,7 @@ * Import entity simple product type * * @api + * @since 100.0.2 */ class Simple extends \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType { diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/Virtual.php b/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/Virtual.php index adeae073fa229..b827b2c6a5339 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/Virtual.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/Virtual.php @@ -9,6 +9,7 @@ * Import entity virtual product type * * @api + * @since 100.0.2 */ class Virtual extends \Magento\CatalogImportExport\Model\Import\Product\Type\Simple { diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product/Validator.php b/app/code/Magento/CatalogImportExport/Model/Import/Product/Validator.php index 18288d85dcaf9..60bfdd56a718e 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product/Validator.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product/Validator.php @@ -12,6 +12,7 @@ * Class Validator * * @api + * @since 100.0.2 */ class Validator extends AbstractValidator implements RowValidatorInterface { @@ -40,8 +41,9 @@ class Validator extends AbstractValidator implements RowValidatorInterface */ protected $_rowData; - /* + /** * @var string|null + * @since 100.1.0 */ protected $invalidAttribute; @@ -239,6 +241,7 @@ public function isAttributeValid($attrCode, array $attrParams, array $rowData) /** * @param string|null $attribute * @return void + * @since 100.1.0 */ protected function setInvalidAttribute($attribute) { @@ -247,6 +250,7 @@ protected function setInvalidAttribute($attribute) /** * @return string + * @since 100.1.0 */ public function getInvalidAttribute() { diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product/Validator/Media.php b/app/code/Magento/CatalogImportExport/Model/Import/Product/Validator/Media.php index b444d746f8d0f..d1fe1eee80e19 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product/Validator/Media.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product/Validator/Media.php @@ -42,13 +42,15 @@ public function __construct(Validator $validator = null) */ const ADDITIONAL_IMAGES_DELIMITER = ','; - /** @var array */ + /** + * @var array + */ protected $mediaAttributes = ['image', 'small_image', 'thumbnail']; /** * @param string $string * @return bool - * @deprecated As this method doesn't give guarantee of correct url validation. + * @deprecated 100.2.0 As this method doesn't give guarantee of correct url validation. * @see \Magento\Framework\Url\Validator::isValid() It provides better url validation. */ protected function checkValidUrl($string) diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Uploader.php b/app/code/Magento/CatalogImportExport/Model/Import/Uploader.php index e2d2b8244262a..6ae553b028a98 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Uploader.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Uploader.php @@ -12,6 +12,7 @@ * Import entity product model * * @api + * @since 100.0.2 */ class Uploader extends \Magento\MediaStorage\Model\File\Uploader { @@ -171,6 +172,7 @@ public function move($fileName, $renameFileOff = false) $this->_setUploadFile($filePath); $destDir = $this->_directory->getAbsolutePath($this->getDestDir()); $result = $this->save($destDir); + unset($result['path']); $result['name'] = self::getCorrectFileName($result['name']); return $result; } diff --git a/app/code/Magento/CatalogImportExport/Model/Indexer/Product/Price/Plugin/Import.php b/app/code/Magento/CatalogImportExport/Model/Indexer/Product/Price/Plugin/Import.php index 0c97bb82603e0..87020be7cd30d 100644 --- a/app/code/Magento/CatalogImportExport/Model/Indexer/Product/Price/Plugin/Import.php +++ b/app/code/Magento/CatalogImportExport/Model/Indexer/Product/Price/Plugin/Import.php @@ -5,32 +5,35 @@ */ namespace Magento\CatalogImportExport\Model\Indexer\Product\Price\Plugin; -class Import extends \Magento\Catalog\Model\Indexer\Product\Price\Plugin\AbstractPlugin +class Import { + /** + * @var \Magento\Framework\Indexer\IndexerRegistry + */ + private $indexerRegistry; + + /** + * @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry + */ + public function __construct(\Magento\Framework\Indexer\IndexerRegistry $indexerRegistry) + { + $this->indexerRegistry = $indexerRegistry; + } + /** * After import handler * * @param \Magento\ImportExport\Model\Import $subject * @param bool $result * @return bool - * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function afterImportSource(\Magento\ImportExport\Model\Import $subject, $result) { - if (!$this->getPriceIndexer()->isScheduled()) { - $this->invalidateIndexer(); + $priceIndexer = $this->indexerRegistry->get(\Magento\Catalog\Model\Indexer\Product\Price\Processor::INDEXER_ID); + if (!$priceIndexer->isScheduled()) { + $priceIndexer->invalidate(); } return $result; } - - /** - * Get price indexer - * - * @return \Magento\Framework\Indexer\IndexerInterface - */ - protected function getPriceIndexer() - { - return $this->indexerRegistry->get(\Magento\Catalog\Model\Indexer\Product\Price\Processor::INDEXER_ID); - } } diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Export/ProductTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Export/ProductTest.php index c434e70d12329..a02ea21d51232 100644 --- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Export/ProductTest.php +++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Export/ProductTest.php @@ -5,13 +5,12 @@ */ namespace Magento\CatalogImportExport\Test\Unit\Model\Export; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -use \Magento\Store\Model\Store; +use Magento\Store\Model\Store; /** * @SuppressWarnings(PHPMD) */ -class ProductTest extends \PHPUnit_Framework_TestCase +class ProductTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\Stdlib\DateTime\Timezone|\PHPUnit_Framework_MockObject_MockObject @@ -120,60 +119,18 @@ class ProductTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->localeDate = $this->getMock( - \Magento\Framework\Stdlib\DateTime\Timezone::class, - [], - [], - '', - false - ); + $this->localeDate = $this->createMock(\Magento\Framework\Stdlib\DateTime\Timezone::class); - $this->config = $this->getMock( - \Magento\Eav\Model\Config::class, - ['getEntityType'], - [], - '', - false - ); - $type = $this->getMock( - \Magento\Eav\Model\Entity\Type::class, - [], - [], - '', - false - ); + $this->config = $this->createPartialMock(\Magento\Eav\Model\Config::class, ['getEntityType']); + $type = $this->createMock(\Magento\Eav\Model\Entity\Type::class); $this->config->expects($this->once())->method('getEntityType')->willReturn($type); - $this->resource = $this->getMock( - \Magento\Framework\App\ResourceConnection::class, - [], - [], - '', - false - ); + $this->resource = $this->createMock(\Magento\Framework\App\ResourceConnection::class); - $this->storeManager = $this->getMock( - \Magento\Store\Model\StoreManager::class, - [], - [], - '', - false - ); - $this->logger = $this->getMock( - \Magento\Framework\Logger\Monolog::class, - [], - [], - '', - false - ); + $this->storeManager = $this->createMock(\Magento\Store\Model\StoreManager::class); + $this->logger = $this->createMock(\Magento\Framework\Logger\Monolog::class); - $this->collection = $this->getMock( - \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::class, - [], - [], - '', - false - ); + $this->collection = $this->createMock(\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::class); $this->abstractCollection = $this->getMockForAbstractClass( \Magento\Eav\Model\Entity\Collection\AbstractCollection::class, [], @@ -189,110 +146,50 @@ protected function setUp() 'getLastPageNumber', ] ); - $this->exportConfig = $this->getMock( - \Magento\ImportExport\Model\Export\Config::class, - [], - [], - '', - false - ); + $this->exportConfig = $this->createMock(\Magento\ImportExport\Model\Export\Config::class); - $this->productFactory = $this->getMock( - \Magento\Catalog\Model\ResourceModel\ProductFactory::class, - [ + $this->productFactory = $this->createPartialMock(\Magento\Catalog\Model\ResourceModel\ProductFactory::class, [ 'create', 'getTypeId', - ], - [], - '', - false - ); + ]); - $this->attrSetColFactory = $this->getMock( + $this->attrSetColFactory = $this->createPartialMock( \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory::class, [ 'create', 'setEntityTypeFilter', - ], - [], - '', - false + ] ); - $this->categoryColFactory = $this->getMock( + $this->categoryColFactory = $this->createPartialMock( \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory::class, [ 'create', 'addNameToResult', - ], - [], - '', - false + ] ); - $this->itemFactory = $this->getMock( - \Magento\CatalogInventory\Model\ResourceModel\Stock\ItemFactory::class, - [], - [], - '', - false - ); - $this->optionColFactory = $this->getMock( - \Magento\Catalog\Model\ResourceModel\Product\Option\CollectionFactory::class, - [], - [], - '', - false + $this->itemFactory = $this->createMock(\Magento\CatalogInventory\Model\ResourceModel\Stock\ItemFactory::class); + $this->optionColFactory = $this->createMock( + \Magento\Catalog\Model\ResourceModel\Product\Option\CollectionFactory::class ); - $this->attributeColFactory = $this->getMock( - \Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory::class, - [], - [], - '', - false - ); - $this->typeFactory = $this->getMock( - \Magento\CatalogImportExport\Model\Export\Product\Type\Factory::class, - [], - [], - '', - false + $this->attributeColFactory = $this->createMock( + \Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory::class ); + $this->typeFactory = $this->createMock(\Magento\CatalogImportExport\Model\Export\Product\Type\Factory::class); - $this->linkTypeProvider = $this->getMock( - \Magento\Catalog\Model\Product\LinkTypeProvider::class, - [], - [], - '', - false - ); - $this->rowCustomizer = $this->getMock( - \Magento\CatalogImportExport\Model\Export\RowCustomizer\Composite::class, - [], - [], - '', - false - ); - $this->metadataPool = $this->getMock( - \Magento\Framework\EntityManager\MetadataPool::class, - [], - [], - '', - false + $this->linkTypeProvider = $this->createMock(\Magento\Catalog\Model\Product\LinkTypeProvider::class); + $this->rowCustomizer = $this->createMock( + \Magento\CatalogImportExport\Model\Export\RowCustomizer\Composite::class ); + $this->metadataPool = $this->createMock(\Magento\Framework\EntityManager\MetadataPool::class); - $this->writer = $this->getMock( - \Magento\ImportExport\Model\Export\Adapter\AbstractAdapter::class, - [ + $this->writer = $this->createPartialMock(\Magento\ImportExport\Model\Export\Adapter\AbstractAdapter::class, [ 'setHeaderCols', 'writeRow', 'getContents', - ], - [], - '', - false - ); + ]); $constructorMethods = [ 'initTypeModels', @@ -315,12 +212,9 @@ protected function setUp() 'paginateCollection', '_getHeaderColumns', ]); - $this->product = $this->getMock( + $this->product = $this->createPartialMock( \Magento\CatalogImportExport\Model\Export\Product::class, - $mockMethods, - [], - '', - false + $mockMethods ); foreach ($constructorMethods as $method) { @@ -369,21 +263,22 @@ public function testUpdateDataWithCategoryColumnsNoCategoriesAssigned() public function testGetHeaderColumns() { - $product = $this->getMock( + $product = $this->createPartialMock( \Magento\CatalogImportExport\Model\Export\Product::class, - ['_customHeadersMapping'], - [], - '', - false + ['_customHeadersMapping'] ); $headerColumnsValue = ['headerColumns value']; $expectedResult = 'result'; $this->setPropertyValue($product, '_headerColumns', $headerColumnsValue); - $product - ->expects($this->once()) + $this->setPropertyValue($product, 'rowCustomizer', $this->rowCustomizer); + $product->expects($this->once()) ->method('_customHeadersMapping') ->with($headerColumnsValue) ->willReturn($expectedResult); + $this->rowCustomizer->expects($this->once()) + ->method('addHeaderColumns') + ->with($headerColumnsValue) + ->willReturn($headerColumnsValue); $result = $product->_getHeaderColumns(); diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/CategoryProcessorTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/CategoryProcessorTest.php index ec4b2b0974b14..bf47ec4f9da13 100644 --- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/CategoryProcessorTest.php +++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/CategoryProcessorTest.php @@ -5,11 +5,10 @@ */ namespace Magento\CatalogImportExport\Test\Unit\Model\Import\Product; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -use Magento\CatalogImportExport\Model\Import\Product\Validator; use Magento\CatalogImportExport\Model\Import\Product\CategoryProcessor; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -class CategoryProcessorTest extends \PHPUnit_Framework_TestCase +class CategoryProcessorTest extends \PHPUnit\Framework\TestCase { const PARENT_CATEGORY_ID = 1; @@ -81,23 +80,14 @@ protected function setUp() ) ->will($this->returnSelf()); - $categoryColFactory = $this->getMock( + $categoryColFactory = $this->createPartialMock( \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory::class, - ['create'], - [], - '', - false + ['create'] ); $categoryColFactory->method('create')->will($this->returnValue($categoryCollection)); - $categoryFactory = $this->getMock( - \Magento\Catalog\Model\CategoryFactory::class, - ['create'], - [], - '', - false - ); + $categoryFactory = $this->createPartialMock(\Magento\Catalog\Model\CategoryFactory::class, ['create']); $categoryFactory->method('create')->will($this->returnValue($childCategory)); diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/SkuProcessorTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/SkuProcessorTest.php index 4a8d5ce3c56db..24c5b05ab9312 100644 --- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/SkuProcessorTest.php +++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/SkuProcessorTest.php @@ -7,7 +7,7 @@ use Magento\CatalogImportExport\Model\Import\Product\SkuProcessor as SkuProcessor; -class SkuProcessorTest extends \PHPUnit_Framework_TestCase +class SkuProcessorTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Catalog\Model\ProductFactory|\PHPUnit_Framework_MockObject_MockObject @@ -21,15 +21,13 @@ class SkuProcessorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->productFactory = $this->getMock(\Magento\Catalog\Model\ProductFactory::class, [], [], '', false); - $this->skuProcessor = $this->getMock( - \Magento\CatalogImportExport\Model\Import\Product\SkuProcessor::class, - ['_getSkus'], - [ - $this->productFactory, - ], - '' - ); + $this->productFactory = $this->createMock(\Magento\Catalog\Model\ProductFactory::class); + $this->skuProcessor = $this->getMockBuilder( + \Magento\CatalogImportExport\Model\Import\Product\SkuProcessor::class + ) + ->setMethods(['_getSkus']) + ->setConstructorArgs([$this->productFactory]) + ->getMock(); } public function testReloadOldSkus() diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/TaxClassProcessorTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/TaxClassProcessorTest.php index 2c72320d725f4..106942bf9b87f 100644 --- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/TaxClassProcessorTest.php +++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/TaxClassProcessorTest.php @@ -6,9 +6,8 @@ namespace Magento\CatalogImportExport\Test\Unit\Model\Import\Product; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -use Magento\CatalogImportExport\Model\Import\Product\Validator; -class TaxClassProcessorTest extends \PHPUnit_Framework_TestCase +class TaxClassProcessorTest extends \PHPUnit\Framework\TestCase { const TEST_TAX_CLASS_NAME = 'className'; @@ -51,12 +50,9 @@ protected function setUp() [$taxClass] ); - $taxClassCollectionFactory = $this->getMock( + $taxClassCollectionFactory = $this->createPartialMock( \Magento\Tax\Model\ResourceModel\TaxClass\CollectionFactory::class, - ['create'], - [], - '', - false + ['create'] ); $taxClassCollectionFactory->method('create')->will($this->returnValue($taxClassCollection)); @@ -67,13 +63,7 @@ protected function setUp() $anotherTaxClass->method('getClassName')->will($this->returnValue(self::TEST_TAX_CLASS_NAME)); $anotherTaxClass->method('getId')->will($this->returnValue(self::TEST_JUST_CREATED_TAX_CLASS_ID)); - $taxClassFactory = $this->getMock( - \Magento\Tax\Model\ClassModelFactory::class, - ['create'], - [], - '', - false - ); + $taxClassFactory = $this->createPartialMock(\Magento\Tax\Model\ClassModelFactory::class, ['create']); $taxClassFactory->method('create')->will($this->returnValue($anotherTaxClass)); diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/AbstractTypeTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/AbstractTypeTest.php index 59c46f095986e..e24b4e1948149 100644 --- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/AbstractTypeTest.php +++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/AbstractTypeTest.php @@ -6,8 +6,8 @@ */ namespace Magento\CatalogImportExport\Test\Unit\Model\Import\Product\Type; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; use Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType as AbstractType; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; /** * Test class for import product AbstractType class @@ -15,7 +15,7 @@ * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class AbstractTypeTest extends \PHPUnit_Framework_TestCase +class AbstractTypeTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogImportExport\Model\Import\Product|\PHPUnit_Framework_MockObject_MockObject @@ -54,53 +54,25 @@ class AbstractTypeTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->entityModel = $this->getMock( - \Magento\CatalogImportExport\Model\Import\Product::class, - [], - [], - '', - false - ); - $attrSetColFactory = $this->getMock( + $this->entityModel = $this->createMock(\Magento\CatalogImportExport\Model\Import\Product::class); + $attrSetColFactory = $this->createPartialMock( \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $attrSetCollection = $this->getMock( - \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection::class, - [], - [], - '', - false - ); - $attrColFactory = $this->getMock( + $attrSetCollection = $this->createMock(\Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection::class); + $attrColFactory = $this->createPartialMock( \Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory::class, - ['create'], - [], - '', - false - ); - $attributeSet = $this->getMock( - \Magento\Eav\Model\Entity\Attribute\Set::class, - [], - [], - '', - false + ['create'] ); - $attrCollection = $this->getMock( + $attributeSet = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Set::class); + $attrCollection = $this->createPartialMock( \Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection::class, [ 'addFieldToFilter', - ], - [], - '', - false + 'setAttributeSetFilter' + ] ); - $attribute = $this->getMock( - \Magento\Eav\Model\Entity\Attribute::class, - [ + $attribute = $this->createPartialMock(\Magento\Eav\Model\Entity\Attribute::class, [ 'getAttributeCode', 'getId', 'getIsVisible', @@ -113,11 +85,7 @@ protected function setUp() 'getDefaultValue', 'usesSource', 'getFrontendInput', - ], - [], - '', - false - ); + ]); $attribute->expects($this->any())->method('getIsVisible')->willReturn(true); $attribute->expects($this->any())->method('getIsGlobal')->willReturn(true); $attribute->expects($this->any())->method('getIsRequired')->willReturn(true); @@ -171,9 +139,7 @@ protected function setUp() ) ->willReturn([$attribute1, $attribute2]); - $this->connection = $this->getMock( - \Magento\Framework\DB\Adapter\Pdo\Mysql::class, - [ + $this->connection = $this->createPartialMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, [ 'select', 'fetchAll', 'fetchPairs', @@ -181,28 +147,18 @@ protected function setUp() 'insertOnDuplicate', 'delete', 'quoteInto' - ], - [], - '', - false - ); - $this->select = $this->getMock( - \Magento\Framework\DB\Select::class, - [ + ]); + $this->select = $this->createPartialMock(\Magento\Framework\DB\Select::class, [ 'from', 'where', 'joinLeft', 'getConnection', - ], - [], - '', - false - ); + ]); $this->select->expects($this->any())->method('from')->will($this->returnSelf()); $this->select->expects($this->any())->method('where')->will($this->returnSelf()); $this->select->expects($this->any())->method('joinLeft')->will($this->returnSelf()); $this->connection->expects($this->any())->method('select')->will($this->returnValue($this->select)); - $connection = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false); + $connection = $this->createMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class); $connection->expects($this->any())->method('quoteInto')->will($this->returnValue('query')); $this->select->expects($this->any())->method('getConnection')->willReturn($connection); $this->connection->expects($this->any())->method('insertOnDuplicate')->willReturnSelf(); @@ -213,16 +169,10 @@ protected function setUp() ->method('fetchAll') ->will($this->returnValue($entityAttributes)); - $this->resource = $this->getMock( - \Magento\Framework\App\ResourceConnection::class, - [ + $this->resource = $this->createPartialMock(\Magento\Framework\App\ResourceConnection::class, [ 'getConnection', 'getTableName', - ], - [], - '', - false - ); + ]); $this->resource->expects($this->any())->method('getConnection')->will( $this->returnValue($this->connection) ); diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/OptionTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/OptionTest.php index 31e026c2088af..6d16f3da9e703 100644 --- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/OptionTest.php +++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/OptionTest.php @@ -215,6 +215,8 @@ class OptionTest extends \Magento\ImportExport\Test\Unit\Model\Import\AbstractIm /** * Init entity adapter model + * + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ protected function setUp() { @@ -233,21 +235,15 @@ protected function setUp() $doubleOptions = true; } - $catalogDataMock = $this->getMock(\Magento\Catalog\Helper\Data::class, ['__construct'], [], '', false); + $catalogDataMock = $this->createPartialMock(\Magento\Catalog\Helper\Data::class, ['__construct']); - $scopeConfig = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $scopeConfig = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $timezoneInterface = $this->getMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); + $timezoneInterface = $this->createMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); $date = new \DateTime(); $timezoneInterface->expects($this->any())->method('date')->willReturn($date); - $this->metadataPoolMock = $this->getMock( - \Magento\Framework\EntityManager\MetadataPool::class, - [], - [], - '', - false - ); - $entityMetadataMock = $this->getMock(\Magento\Framework\EntityManager\EntityMetadata::class, [], [], '', false); + $this->metadataPoolMock = $this->createMock(\Magento\Framework\EntityManager\MetadataPool::class); + $entityMetadataMock = $this->createMock(\Magento\Framework\EntityManager\EntityMetadata::class); $this->metadataPoolMock->expects($this->any()) ->method('getMetadata') ->with(\Magento\Catalog\Api\Data\ProductInterface::class) @@ -255,37 +251,33 @@ protected function setUp() $entityMetadataMock->expects($this->any()) ->method('getLinkField') ->willReturn('entity_id'); + $optionValueCollectionFactoryMock = $this->createMock( + \Magento\Catalog\Model\ResourceModel\Product\Option\Value\CollectionFactory::class + ); + $optionValueCollectionMock = $this->createPartialMock( + \Magento\Catalog\Model\ResourceModel\Product\Option\Value\Collection::class, + ['getIterator', 'addTitleToResult'] + ); + $optionValueCollectionMock->expects($this->any())->method('getIterator') + ->willReturn($this->createMock(\Traversable::class)); + $optionValueCollectionFactoryMock->expects($this->any()) + ->method('create')->willReturn($optionValueCollectionMock); $modelClassArgs = [ - $this->getMock(\Magento\ImportExport\Model\ResourceModel\Import\Data::class, [], [], '', false), - $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false), - $this->getMock(\Magento\ImportExport\Model\ResourceModel\Helper::class, [], [], '', false), - $this->getMock(\Magento\Store\Model\StoreManagerInterface::class, [], [], '', false), - $this->getMock(\Magento\Catalog\Model\ProductFactory::class, [], [], '', false), - $this->getMock( - \Magento\Catalog\Model\ResourceModel\Product\Option\CollectionFactory::class, - [], - [], - '', - false - ), - $this->getMock( - \Magento\ImportExport\Model\ResourceModel\CollectionByPagesIteratorFactory::class, - [], - [], - '', - false - ), + $this->createMock(\Magento\ImportExport\Model\ResourceModel\Import\Data::class), + $this->createMock(\Magento\Framework\App\ResourceConnection::class), + $this->createMock(\Magento\ImportExport\Model\ResourceModel\Helper::class), + $this->createMock(\Magento\Store\Model\StoreManagerInterface::class), + $this->createMock(\Magento\Catalog\Model\ProductFactory::class), + $this->createMock(\Magento\Catalog\Model\ResourceModel\Product\Option\CollectionFactory::class), + $this->createMock(\Magento\ImportExport\Model\ResourceModel\CollectionByPagesIteratorFactory::class), $catalogDataMock, $scopeConfig, $timezoneInterface, - $this->getMock( - \Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface::class, - [], - [], - '', - false + $this->createMock( + \Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface::class ), - $this->_getModelDependencies($addExpectations, $deleteBehavior, $doubleOptions) + $this->_getModelDependencies($addExpectations, $deleteBehavior, $doubleOptions), + $optionValueCollectionFactoryMock ]; $modelClassName = \Magento\CatalogImportExport\Model\Import\Product\Option::class; @@ -320,7 +312,10 @@ protected function tearDown() */ protected function _getModelDependencies($addExpectations = false, $deleteBehavior = false, $doubleOptions = false) { - $connection = $this->getMock(\stdClass::class, ['delete', 'quoteInto', 'insertMultiple', 'insertOnDuplicate']); + $connection = $this->createPartialMock( + \stdClass::class, + ['delete', 'quoteInto', 'insertMultiple', 'insertOnDuplicate'] + ); if ($addExpectations) { if ($deleteBehavior) { $connection->expects( @@ -355,7 +350,7 @@ protected function _getModelDependencies($addExpectations = false, $deleteBehavi } } - $resourceHelper = $this->getMock(\stdClass::class, ['getNextAutoincrement']); + $resourceHelper = $this->createPartialMock(\stdClass::class, ['getNextAutoincrement']); if ($addExpectations) { $resourceHelper->expects($this->any())->method('getNextAutoincrement')->will($this->returnValue(2)); } @@ -385,7 +380,7 @@ protected function _getSourceDataMocks($addExpectations, $doubleOptions) { $csvData = $this->_loadCsvFile(); - $dataSourceModel = $this->getMock(\stdClass::class, ['getNextBunch']); + $dataSourceModel = $this->createPartialMock(\stdClass::class, ['getNextBunch']); if ($addExpectations) { $dataSourceModel->expects( $this->at(0) @@ -413,12 +408,9 @@ protected function _getSourceDataMocks($addExpectations, $doubleOptions) } } - $this->productEntity = $this->getMock( + $this->productEntity = $this->createPartialMock( \Magento\CatalogImportExport\Model\Import\Product::class, - ['getErrorAggregator'], - [], - '', - false + ['getErrorAggregator'] ); $this->productEntity->method('getErrorAggregator')->willReturn($this->getErrorAggregatorObject()); $reflection = new \ReflectionClass(\Magento\CatalogImportExport\Model\Import\Product::class); @@ -426,7 +418,7 @@ protected function _getSourceDataMocks($addExpectations, $doubleOptions) $reflectionProperty->setAccessible(true); $reflectionProperty->setValue($this->productEntity, $this->metadataPoolMock); - $productModelMock = $this->getMock(\stdClass::class, ['getProductEntitiesInfo']); + $productModelMock = $this->createPartialMock(\stdClass::class, ['getProductEntitiesInfo']); $productModelMock->expects( $this->any() )->method( @@ -439,15 +431,15 @@ protected function _getSourceDataMocks($addExpectations, $doubleOptions) \Magento\Framework\Data\Collection\Db\FetchStrategyInterface::class, ['fetchAll'] ); - $logger = $this->getMock(\Psr\Log\LoggerInterface::class); - $entityFactory = $this->getMock(\Magento\Framework\Data\Collection\EntityFactory::class, [], [], '', false); + $logger = $this->createMock(\Psr\Log\LoggerInterface::class); + $entityFactory = $this->createMock(\Magento\Framework\Data\Collection\EntityFactory::class); $optionCollection = $this->getMockBuilder(\Magento\Framework\Data\Collection\AbstractDb::class) ->setConstructorArgs([$entityFactory, $logger, $fetchStrategy]) ->setMethods(['reset', 'addProductToFilter', 'getSelect', 'getNewEmptyItem']) ->getMockForAbstractClass(); - $select = $this->getMock(\Magento\Framework\DB\Select::class, ['join', 'where'], [], '', false); + $select = $this->createPartialMock(\Magento\Framework\DB\Select::class, ['join', 'where']); $select->expects($this->any())->method('join')->will($this->returnSelf()); $select->expects($this->any())->method('where')->will($this->returnSelf()); @@ -473,7 +465,7 @@ protected function _getSourceDataMocks($addExpectations, $doubleOptions) $fetchStrategy->expects($this->any())->method('fetchAll')->will($this->returnValue($optionsData)); - $collectionIterator = $this->getMock(\stdClass::class, ['iterate']); + $collectionIterator = $this->createPartialMock(\stdClass::class, ['iterate']); $collectionIterator->expects( $this->any() )->method( @@ -518,7 +510,7 @@ public function iterate(\Magento\Framework\Data\Collection\AbstractDb $collectio */ public function getNewOptionMock() { - return $this->getMock(\Magento\Catalog\Model\Product\Option::class, ['__wakeup'], [], '', false); + return $this->createPartialMock(\Magento\Catalog\Model\Product\Option::class, ['__wakeup']); } /** @@ -917,7 +909,7 @@ public function validateAmbiguousDataDataProvider() public function testParseRequiredData() { - $modelData = $this->getMock(\stdClass::class, ['getNextBunch']); + $modelData = $this->createPartialMock(\stdClass::class, ['getNextBunch']); $modelData->expects( $this->at(0) )->method( @@ -929,17 +921,11 @@ public function testParseRequiredData() ); $modelData->expects($this->at(1))->method('getNextBunch')->will($this->returnValue(null)); - $productModel = $this->getMock(\stdClass::class, ['getProductEntitiesInfo']); + $productModel = $this->createPartialMock(\stdClass::class, ['getProductEntitiesInfo']); $productModel->expects($this->any())->method('getProductEntitiesInfo')->will($this->returnValue([])); /** @var \Magento\CatalogImportExport\Model\Import\Product $productEntityMock */ - $productEntityMock = $this->getMock( - \Magento\CatalogImportExport\Model\Import\Product::class, - [], - [], - '', - false - ); + $productEntityMock = $this->createMock(\Magento\CatalogImportExport\Model\Import\Product::class); $reflection = new \ReflectionClass(\Magento\CatalogImportExport\Model\Import\Product::class); $reflectionProperty = $reflection->getProperty('metadataPool'); $reflectionProperty->setAccessible(true); diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/VirtualTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/VirtualTest.php index 04ab6143b6df0..7f5a856dde758 100644 --- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/VirtualTest.php +++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/VirtualTest.php @@ -6,19 +6,16 @@ namespace Magento\CatalogImportExport\Test\Unit\Model\Import\Product\Type; -class VirtualTest extends \PHPUnit_Framework_TestCase +class VirtualTest extends \PHPUnit\Framework\TestCase { /** * Test for method prepareAttributesWithDefaultValueForSave */ public function testPrepareAttributesWithDefaultValueForSave() { - $virtualModelMock = $this->getMock( + $virtualModelMock = $this->createPartialMock( \Magento\CatalogImportExport\Model\Import\Product\Type\Virtual::class, - null, - [], - '', - false + [] ); $this->setPropertyValue( @@ -69,7 +66,7 @@ public function testPrepareAttributesWithDefaultValueForSave() ]; $result = $virtualModelMock->prepareAttributesWithDefaultValueForSave($rowData); - $this->assertEquals($result, $expectedResult); + $this->assertEquals($expectedResult, $result); } /** diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/MediaTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/MediaTest.php index 209d999320906..439ffb99190bc 100644 --- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/MediaTest.php +++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/MediaTest.php @@ -13,7 +13,7 @@ use Magento\Framework\Url\Validator; use PHPUnit_Framework_MockObject_MockObject as MockObject; -class MediaTest extends \PHPUnit_Framework_TestCase +class MediaTest extends \PHPUnit\Framework\TestCase { /** @var Media */ protected $media; @@ -76,13 +76,7 @@ public function testIsValid($data, $expected) public function testIsValidClearMessagesCall() { - $media = $this->getMock( - Media::class, - ['_clearMessages'], - [], - '', - false - ); + $media = $this->createPartialMock(Media::class, ['_clearMessages']); $media->expects($this->once())->method('_clearMessages'); $media->isValid([]); diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/QuantityTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/QuantityTest.php index 5e437e0f7d67e..144214fd6e318 100644 --- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/QuantityTest.php +++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/QuantityTest.php @@ -11,7 +11,7 @@ /** * Class QuantityTest */ -class QuantityTest extends \PHPUnit_Framework_TestCase +class QuantityTest extends \PHPUnit\Framework\TestCase { /** * @var Quantity diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/SuperProductsSkuTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/SuperProductsSkuTest.php index ab0109406338e..8294f82f35a39 100644 --- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/SuperProductsSkuTest.php +++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/SuperProductsSkuTest.php @@ -14,7 +14,7 @@ * * @see SuperProductsSku */ -class SuperProductsSkuTest extends \PHPUnit_Framework_TestCase +class SuperProductsSkuTest extends \PHPUnit\Framework\TestCase { /** * @var SkuProcessor|Mock diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/TierPriceTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/TierPriceTest.php index 8443a25716752..4e902024769f7 100644 --- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/TierPriceTest.php +++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/TierPriceTest.php @@ -8,7 +8,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -class TierPriceTest extends \PHPUnit_Framework_TestCase +class TierPriceTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\CatalogImportExport\Model\Import\Product\Validator\TierPrice */ protected $tierPrice; @@ -27,28 +27,14 @@ class TierPriceTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->groupRepositoryInterface = $this->getMock( - \Magento\Customer\Model\ResourceModel\GroupRepository::class, - [], - [], - '', - false - ); - $this->searchCriteriaSearch = $this->getMock(\Magento\Framework\Api\SearchCriteria::class, [], [], '', false); - $this->searchCriteriaBuilder = $this->getMock( - \Magento\Framework\Api\SearchCriteriaBuilder::class, - [], - [], - '', - false + $this->groupRepositoryInterface = $this->createMock( + \Magento\Customer\Model\ResourceModel\GroupRepository::class ); + $this->searchCriteriaSearch = $this->createMock(\Magento\Framework\Api\SearchCriteria::class); + $this->searchCriteriaBuilder = $this->createMock(\Magento\Framework\Api\SearchCriteriaBuilder::class); $this->searchCriteriaBuilder->expects($this->any())->method('create')->willReturn($this->searchCriteriaSearch); - $this->storeResolver = $this->getMock( - \Magento\CatalogImportExport\Model\Import\Product\StoreResolver::class, - [], - [], - '', - false + $this->storeResolver = $this->createMock( + \Magento\CatalogImportExport\Model\Import\Product\StoreResolver::class ); $this->objectManagerHelper = new ObjectManagerHelper($this); @@ -64,15 +50,9 @@ protected function setUp() protected function processInit($groupId) { - $searchResult = $this->getMock( - \Magento\Customer\Api\Data\GroupSearchResultsInterface::class, - [], - [], - '', - false - ); + $searchResult = $this->createMock(\Magento\Customer\Api\Data\GroupSearchResultsInterface::class); $this->groupRepositoryInterface->expects($this->once())->method('getList')->willReturn($searchResult); - $group = $this->getMock(\Magento\Customer\Model\Data\Group::class, [], [], '', false); + $group = $this->createMock(\Magento\Customer\Model\Data\Group::class); $group->expects($this->once())->method('getId')->willReturn($groupId); $searchResult->expects($this->once())->method('getItems')->willReturn([$group]); return $this->tierPrice->init(null); diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/ValidatorTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/ValidatorTest.php index 00580ed73755b..1179783fdd3f9 100644 --- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/ValidatorTest.php +++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/ValidatorTest.php @@ -6,11 +6,11 @@ namespace Magento\CatalogImportExport\Test\Unit\Model\Import\Product; use Magento\CatalogImportExport\Model\Import\Product; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; use Magento\CatalogImportExport\Model\Import\Product\Validator; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; use Magento\ImportExport\Model\Import; -class ValidatorTest extends \PHPUnit_Framework_TestCase +class ValidatorTest extends \PHPUnit\Framework\TestCase { /** @var Validator */ protected $validator; @@ -32,37 +32,25 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $entityTypeModel = $this->getMock( + $entityTypeModel = $this->createPartialMock( \Magento\CatalogImportExport\Model\Import\Product\Type\Simple::class, - ['retrieveAttributeFromCache'], - [], - '', - false + ['retrieveAttributeFromCache'] ); $entityTypeModel->expects($this->any())->method('retrieveAttributeFromCache')->willReturn([]); - $this->context = $this->getMock( + $this->context = $this->createPartialMock( \Magento\CatalogImportExport\Model\Import\Product::class, - ['retrieveProductTypeByName', 'retrieveMessageTemplate'], - [], - '', - false + ['retrieveProductTypeByName', 'retrieveMessageTemplate', 'getBehavior'] ); $this->context->expects($this->any())->method('retrieveProductTypeByName')->willReturn($entityTypeModel); $this->context->expects($this->any())->method('retrieveMessageTemplate')->willReturn('error message'); - $this->validatorOne = $this->getMock( + $this->validatorOne = $this->createPartialMock( \Magento\CatalogImportExport\Model\Import\Product\Validator\Media::class, - [], - [], - '', - false + ['init', 'isValid'] ); - $this->validatorTwo = $this->getMock( + $this->validatorTwo = $this->createPartialMock( \Magento\CatalogImportExport\Model\Import\Product\Validator\Website::class, - [], - [], - '', - false + ['init', 'isValid', 'getMessages'] ); $this->validators = [$this->validatorOne, $this->validatorTwo]; diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/ProductTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/ProductTest.php index 3dc1ae63b2bad..862276d35bac5 100644 --- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/ProductTest.php +++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/ProductTest.php @@ -166,8 +166,8 @@ protected function setUp() { parent::setUp(); - $metadataPoolMock = $this->getMock(\Magento\Framework\EntityManager\MetadataPool::class, [], [], '', false); - $entityMetadataMock = $this->getMock(\Magento\Framework\EntityManager\EntityMetadata::class, [], [], '', false); + $metadataPoolMock = $this->createMock(\Magento\Framework\EntityManager\MetadataPool::class); + $entityMetadataMock = $this->createMock(\Magento\Framework\EntityManager\EntityMetadata::class); $metadataPoolMock->expects($this->any()) ->method('getMetadata') ->with(\Magento\Catalog\Api\Data\ProductInterface::class) @@ -227,47 +227,29 @@ protected function setUp() $this->getMockBuilder(\Magento\ImportExport\Model\Import\Config::class) ->disableOriginalConstructor() ->getMock(); - $this->_resourceFactory = $this->getMock( + $this->_resourceFactory = $this->createPartialMock( \Magento\CatalogImportExport\Model\Import\Proxy\Product\ResourceModelFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->_setColFactory = $this->getMock( + $this->_setColFactory = $this->createPartialMock( \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->_productTypeFactory = $this->getMock( + $this->_productTypeFactory = $this->createPartialMock( \Magento\CatalogImportExport\Model\Import\Product\Type\Factory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->_linkFactory = $this->getMock( + $this->_linkFactory = $this->createPartialMock( \Magento\Catalog\Model\ResourceModel\Product\LinkFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->_proxyProdFactory = $this->getMock( + $this->_proxyProdFactory = $this->createPartialMock( \Magento\CatalogImportExport\Model\Import\Proxy\ProductFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->_uploaderFactory = $this->getMock( + $this->_uploaderFactory = $this->createPartialMock( \Magento\CatalogImportExport\Model\Import\UploaderFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->_filesystem = $this->getMockBuilder(\Magento\Framework\Filesystem::class) @@ -276,12 +258,9 @@ protected function setUp() $this->_mediaDirectory = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\WriteInterface::class) ->getMock(); - $this->_stockResItemFac = $this->getMock( + $this->_stockResItemFac = $this->createPartialMock( \Magento\CatalogInventory\Model\ResourceModel\Stock\ItemFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->_localeDate = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class) @@ -319,7 +298,7 @@ protected function setUp() ->getMock(); $this->validator = $this->getMockBuilder(\Magento\CatalogImportExport\Model\Import\Product\Validator::class) - ->setMethods(['isAttributeValid', 'getMessages', 'isValid']) + ->setMethods(['isAttributeValid', 'getMessages', 'isValid', 'init']) ->disableOriginalConstructor() ->getMock(); $this->objectRelationProcessor = @@ -408,12 +387,9 @@ protected function setUp() */ protected function _objectConstructor() { - $this->optionFactory = $this->getMock( + $this->optionFactory = $this->createPartialMock( \Magento\CatalogImportExport\Model\Import\Product\OptionFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->optionEntity = $this->getMockBuilder(\Magento\CatalogImportExport\Model\Import\Product\Option::class) ->disableOriginalConstructor()->getMock(); @@ -437,7 +413,7 @@ protected function _parentObjectConstructor() $type->expects($this->any())->method('getEntityTypeId')->will($this->returnValue(self::ENTITY_TYPE_ID)); $this->config->expects($this->any())->method('getEntityType')->with(self::ENTITY_TYPE_CODE)->willReturn($type); - $this->_connection = $this->getMock(\Magento\Framework\DB\Adapter\AdapterInterface::class); + $this->_connection = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class); $this->resource->expects($this->any())->method('getConnection')->willReturn($this->_connection); return $this; } @@ -1033,8 +1009,11 @@ public function testValidateRowValidateNewProductTypeGetNewSkuCall() 'entity_id' => null, 'type_id' => $rowData[\Magento\CatalogImportExport\Model\Import\Product::COL_TYPE],//value //attr_set_id_val - 'attr_set_id' => - $_attrSetNameToId[$rowData[\Magento\CatalogImportExport\Model\Import\Product::COL_ATTR_SET]], + 'attr_set_id' => $_attrSetNameToId[ + $rowData[ + \Magento\CatalogImportExport\Model\Import\Product::COL_ATTR_SET + ] + ], 'attr_set_code' => $rowData[\Magento\CatalogImportExport\Model\Import\Product::COL_ATTR_SET],//value 'row_id' => null ]; diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/UploaderTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/UploaderTest.php index 1c7ea5df50bbf..e28c2e1f3c01d 100644 --- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/UploaderTest.php +++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/UploaderTest.php @@ -6,7 +6,7 @@ */ namespace Magento\CatalogImportExport\Test\Unit\Model\Import; -class UploaderTest extends \PHPUnit_Framework_TestCase +class UploaderTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\MediaStorage\Helper\File\Storage\Database|\PHPUnit_Framework_MockObject_MockObject @@ -127,10 +127,12 @@ public function testMoveFileUrl($fileUrl, $expectedHost, $expectedFileName) $this->uploader->expects($this->any())->method('getTmpDir')->will($this->returnValue('')); $this->uploader->expects($this->once())->method('_setUploadFile')->will($this->returnSelf()); $this->uploader->expects($this->once())->method('save')->with($destDir . '/' . $expectedFileName) - ->willReturn(['name' => $expectedFileName]); + ->willReturn(['name' => $expectedFileName, 'path' => 'absPath']); $this->uploader->setDestDir($destDir); - $this->assertEquals(['name' => $expectedFileName], $this->uploader->move($fileUrl)); + $result = $this->uploader->move($fileUrl); + $this->assertEquals(['name' => $expectedFileName], $result); + $this->assertArrayNotHasKey('path', $result); } public function testMoveFileName() @@ -157,8 +159,8 @@ public function testMoveFileName() */ public function testMoveFileUrlDrivePool($fileUrl, $expectedHost, $expectedDriverPool, $expectedScheme) { - $driverPool = $this->getMock(\Magento\Framework\Filesystem\DriverPool::class, ['getDriver']); - $driverMock = $this->getMock($expectedDriverPool, ['readAll']); + $driverPool = $this->createPartialMock(\Magento\Framework\Filesystem\DriverPool::class, ['getDriver']); + $driverMock = $this->createPartialMock($expectedDriverPool, ['readAll', 'isExists']); $driverMock->expects($this->any())->method('isExists')->willReturn(true); $driverMock->expects($this->any())->method('readAll')->willReturn(null); $driverPool->expects($this->any())->method('getDriver')->willReturn($driverMock); @@ -187,7 +189,8 @@ public function testMoveFileUrlDrivePool($fileUrl, $expectedHost, $expectedDrive ]) ->getMock(); - $uploaderMock->move($fileUrl); + $result = $uploaderMock->move($fileUrl); + $this->assertNull($result); } public function moveFileUrlDriverPoolDataProvider() diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Indexer/Product/Flat/Plugin/ImportTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Indexer/Product/Flat/Plugin/ImportTest.php index e5242a6c98465..d40327f097c5b 100644 --- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Indexer/Product/Flat/Plugin/ImportTest.php +++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Indexer/Product/Flat/Plugin/ImportTest.php @@ -5,7 +5,7 @@ */ namespace Magento\CatalogImportExport\Test\Unit\Model\Indexer\Product\Flat\Plugin; -class ImportTest extends \PHPUnit_Framework_TestCase +class ImportTest extends \PHPUnit\Framework\TestCase { public function testAfterImportSource() { @@ -13,15 +13,12 @@ public function testAfterImportSource() * @var \Magento\Catalog\Model\Indexer\Product\Flat\Processor| * \PHPUnit_Framework_MockObject_MockObject $processorMock */ - $processorMock = $this->getMock( + $processorMock = $this->createPartialMock( \Magento\Catalog\Model\Indexer\Product\Flat\Processor::class, - ['markIndexerAsInvalid'], - [], - '', - false + ['markIndexerAsInvalid'] ); - $subjectMock = $this->getMock(\Magento\ImportExport\Model\Import::class, [], [], '', false); + $subjectMock = $this->createMock(\Magento\ImportExport\Model\Import::class); $processorMock->expects($this->once())->method('markIndexerAsInvalid'); $someData = [1, 2, 3]; diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Indexer/Product/Price/Plugin/ImportTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Indexer/Product/Price/Plugin/ImportTest.php index cb3935bcf7a31..74aac0c264bdf 100644 --- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Indexer/Product/Price/Plugin/ImportTest.php +++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Indexer/Product/Price/Plugin/ImportTest.php @@ -5,7 +5,7 @@ */ namespace Magento\CatalogImportExport\Test\Unit\Model\Indexer\Product\Price\Plugin; -class ImportTest extends \PHPUnit_Framework_TestCase +class ImportTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager @@ -31,19 +31,13 @@ protected function setUp() { $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_indexerMock = $this->getMock( + $this->_indexerMock = $this->createPartialMock( \Magento\Indexer\Model\Indexer::class, - ['getId', 'invalidate', 'getPriceIndexer', 'isScheduled'], - [], - '', - false + ['getId', 'invalidate', 'getPriceIndexer', 'isScheduled'] ); - $this->indexerRegistryMock = $this->getMock( + $this->indexerRegistryMock = $this->createPartialMock( \Magento\Framework\Indexer\IndexerRegistry::class, - ['get'], - [], - '', - false + ['get'] ); $this->_model = $this->_objectManager->getObject( @@ -66,7 +60,7 @@ public function testAfterImportSource() ->method('isScheduled') ->will($this->returnValue(false)); - $importMock = $this->getMock(\Magento\ImportExport\Model\Import::class, [], [], '', false); + $importMock = $this->createMock(\Magento\ImportExport\Model\Import::class); $this->assertEquals('return_value', $this->_model->afterImportSource($importMock, 'return_value')); } } diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Indexer/Stock/Plugin/ImportTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Indexer/Stock/Plugin/ImportTest.php index 59bb3d5fc1c31..9de2d5cd00837 100644 --- a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Indexer/Stock/Plugin/ImportTest.php +++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Indexer/Stock/Plugin/ImportTest.php @@ -5,7 +5,7 @@ */ namespace Magento\CatalogImportExport\Test\Unit\Model\Indexer\Stock\Plugin; -class ImportTest extends \PHPUnit_Framework_TestCase +class ImportTest extends \PHPUnit\Framework\TestCase { public function testAfterImportSource() { @@ -13,15 +13,12 @@ public function testAfterImportSource() * @var \Magento\Catalog\Model\Indexer\Product\Flat\Processor| * \PHPUnit_Framework_MockObject_MockObject $processorMock */ - $processorMock = $this->getMock( + $processorMock = $this->createPartialMock( \Magento\CatalogInventory\Model\Indexer\Stock\Processor::class, - ['markIndexerAsInvalid', 'isIndexerScheduled'], - [], - '', - false + ['markIndexerAsInvalid', 'isIndexerScheduled'] ); - $subjectMock = $this->getMock(\Magento\ImportExport\Model\Import::class, [], [], '', false); + $subjectMock = $this->createMock(\Magento\ImportExport\Model\Import::class); $processorMock->expects($this->any())->method('markIndexerAsInvalid'); $processorMock->expects($this->any())->method('isIndexerScheduled')->willReturn(false); diff --git a/app/code/Magento/CatalogInventory/Api/Data/StockCollectionInterface.php b/app/code/Magento/CatalogInventory/Api/Data/StockCollectionInterface.php index 9249da56d8186..c2521f77ca24a 100644 --- a/app/code/Magento/CatalogInventory/Api/Data/StockCollectionInterface.php +++ b/app/code/Magento/CatalogInventory/Api/Data/StockCollectionInterface.php @@ -14,6 +14,7 @@ /** * Interface StockCollectionInterface * @api + * @since 100.0.2 */ interface StockCollectionInterface extends SearchResultsInterface { diff --git a/app/code/Magento/CatalogInventory/Api/Data/StockInterface.php b/app/code/Magento/CatalogInventory/Api/Data/StockInterface.php index f3288d632cfb1..53e95921ea955 100644 --- a/app/code/Magento/CatalogInventory/Api/Data/StockInterface.php +++ b/app/code/Magento/CatalogInventory/Api/Data/StockInterface.php @@ -10,6 +10,7 @@ /** * Interface Stock * @api + * @since 100.0.2 */ interface StockInterface extends ExtensibleDataInterface { diff --git a/app/code/Magento/CatalogInventory/Api/Data/StockItemCollectionInterface.php b/app/code/Magento/CatalogInventory/Api/Data/StockItemCollectionInterface.php index 9a36d0caa0bd2..038174c8e52be 100644 --- a/app/code/Magento/CatalogInventory/Api/Data/StockItemCollectionInterface.php +++ b/app/code/Magento/CatalogInventory/Api/Data/StockItemCollectionInterface.php @@ -14,6 +14,7 @@ /** * Interface StockItemCollectionInterface * @api + * @since 100.0.2 */ interface StockItemCollectionInterface extends SearchResultsInterface { diff --git a/app/code/Magento/CatalogInventory/Api/Data/StockItemInterface.php b/app/code/Magento/CatalogInventory/Api/Data/StockItemInterface.php index 63dc05ec57c0a..b876615468ba9 100644 --- a/app/code/Magento/CatalogInventory/Api/Data/StockItemInterface.php +++ b/app/code/Magento/CatalogInventory/Api/Data/StockItemInterface.php @@ -10,6 +10,7 @@ /** * Interface StockItem * @api + * @since 100.0.2 */ interface StockItemInterface extends ExtensibleDataInterface { diff --git a/app/code/Magento/CatalogInventory/Api/Data/StockStatusCollectionInterface.php b/app/code/Magento/CatalogInventory/Api/Data/StockStatusCollectionInterface.php index b7535645e117f..70a2c29ff9a6e 100644 --- a/app/code/Magento/CatalogInventory/Api/Data/StockStatusCollectionInterface.php +++ b/app/code/Magento/CatalogInventory/Api/Data/StockStatusCollectionInterface.php @@ -10,6 +10,7 @@ /** * Stock Status collection interface * @api + * @since 100.0.2 */ interface StockStatusCollectionInterface extends SearchResultsInterface { diff --git a/app/code/Magento/CatalogInventory/Api/Data/StockStatusInterface.php b/app/code/Magento/CatalogInventory/Api/Data/StockStatusInterface.php index 4282d6b238854..83defa64df250 100644 --- a/app/code/Magento/CatalogInventory/Api/Data/StockStatusInterface.php +++ b/app/code/Magento/CatalogInventory/Api/Data/StockStatusInterface.php @@ -10,6 +10,7 @@ /** * Interface StockStatusInterface * @api + * @since 100.0.2 */ interface StockStatusInterface extends ExtensibleDataInterface { diff --git a/app/code/Magento/CatalogInventory/Api/StockConfigurationInterface.php b/app/code/Magento/CatalogInventory/Api/StockConfigurationInterface.php index 7f4afea26d437..767625e9f3489 100644 --- a/app/code/Magento/CatalogInventory/Api/StockConfigurationInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockConfigurationInterface.php @@ -8,6 +8,7 @@ /** * Interface StockConfigurationInterface * @api + * @since 100.0.2 */ interface StockConfigurationInterface { diff --git a/app/code/Magento/CatalogInventory/Api/StockCriteriaInterface.php b/app/code/Magento/CatalogInventory/Api/StockCriteriaInterface.php index a838901f77dbc..969af6481cb4a 100644 --- a/app/code/Magento/CatalogInventory/Api/StockCriteriaInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockCriteriaInterface.php @@ -8,6 +8,7 @@ /** * Interface StockCriteriaInterface * @api + * @since 100.0.2 */ interface StockCriteriaInterface extends \Magento\Framework\Api\CriteriaInterface { diff --git a/app/code/Magento/CatalogInventory/Api/StockIndexInterface.php b/app/code/Magento/CatalogInventory/Api/StockIndexInterface.php index 13ffb054d925e..1521b34c715b0 100644 --- a/app/code/Magento/CatalogInventory/Api/StockIndexInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockIndexInterface.php @@ -8,6 +8,7 @@ /** * Interface StockIndexInterface * @api + * @since 100.0.2 */ interface StockIndexInterface { diff --git a/app/code/Magento/CatalogInventory/Api/StockItemCriteriaInterface.php b/app/code/Magento/CatalogInventory/Api/StockItemCriteriaInterface.php index 3d5041f26d49e..a2fc7801b1d13 100644 --- a/app/code/Magento/CatalogInventory/Api/StockItemCriteriaInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockItemCriteriaInterface.php @@ -8,6 +8,7 @@ /** * Interface StockItemCriteriaInterface * @api + * @since 100.0.2 */ interface StockItemCriteriaInterface extends \Magento\Framework\Api\CriteriaInterface { diff --git a/app/code/Magento/CatalogInventory/Api/StockItemRepositoryInterface.php b/app/code/Magento/CatalogInventory/Api/StockItemRepositoryInterface.php index 98627910d9669..2732048d1445f 100644 --- a/app/code/Magento/CatalogInventory/Api/StockItemRepositoryInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockItemRepositoryInterface.php @@ -8,6 +8,7 @@ /** * Interface StockItemRepository * @api + * @since 100.0.2 */ interface StockItemRepositoryInterface { diff --git a/app/code/Magento/CatalogInventory/Api/StockManagementInterface.php b/app/code/Magento/CatalogInventory/Api/StockManagementInterface.php index ef4df59671c86..ddb84abf3d1a5 100644 --- a/app/code/Magento/CatalogInventory/Api/StockManagementInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockManagementInterface.php @@ -8,6 +8,7 @@ /** * Interface StockManagementInterface * @api + * @since 100.0.2 */ interface StockManagementInterface { diff --git a/app/code/Magento/CatalogInventory/Api/StockRegistryInterface.php b/app/code/Magento/CatalogInventory/Api/StockRegistryInterface.php index db70ae18c3c32..c9b6abeb72e23 100644 --- a/app/code/Magento/CatalogInventory/Api/StockRegistryInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockRegistryInterface.php @@ -8,6 +8,7 @@ /** * Interface StockRegistryInterface * @api + * @since 100.0.2 */ interface StockRegistryInterface { diff --git a/app/code/Magento/CatalogInventory/Api/StockRepositoryInterface.php b/app/code/Magento/CatalogInventory/Api/StockRepositoryInterface.php index 2cb94a8a29b6c..80a7e79289cff 100644 --- a/app/code/Magento/CatalogInventory/Api/StockRepositoryInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockRepositoryInterface.php @@ -8,6 +8,7 @@ /** * Interface StockRepositoryInterface * @api + * @since 100.0.2 */ interface StockRepositoryInterface { diff --git a/app/code/Magento/CatalogInventory/Api/StockStateInterface.php b/app/code/Magento/CatalogInventory/Api/StockStateInterface.php index eb45b96fcb9e7..8a1f7da5158ed 100644 --- a/app/code/Magento/CatalogInventory/Api/StockStateInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockStateInterface.php @@ -8,6 +8,7 @@ /** * Interface StockStateInterface * @api + * @since 100.0.2 */ interface StockStateInterface { diff --git a/app/code/Magento/CatalogInventory/Api/StockStatusCriteriaInterface.php b/app/code/Magento/CatalogInventory/Api/StockStatusCriteriaInterface.php index 5c2cc18061f36..e504e6355a15a 100644 --- a/app/code/Magento/CatalogInventory/Api/StockStatusCriteriaInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockStatusCriteriaInterface.php @@ -8,6 +8,7 @@ /** * Interface StockStatusCriteriaInterface * @api + * @since 100.0.2 */ interface StockStatusCriteriaInterface extends \Magento\Framework\Api\CriteriaInterface { diff --git a/app/code/Magento/CatalogInventory/Api/StockStatusRepositoryInterface.php b/app/code/Magento/CatalogInventory/Api/StockStatusRepositoryInterface.php index 2219e73a187b5..94d4998c1e318 100644 --- a/app/code/Magento/CatalogInventory/Api/StockStatusRepositoryInterface.php +++ b/app/code/Magento/CatalogInventory/Api/StockStatusRepositoryInterface.php @@ -8,6 +8,7 @@ /** * Interface StockStatusRepositoryInterface * @api + * @since 100.0.2 */ interface StockStatusRepositoryInterface { diff --git a/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Minsaleqty.php b/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Minsaleqty.php index e2dcd0a0a33b0..15dfbd122e950 100644 --- a/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Minsaleqty.php +++ b/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Minsaleqty.php @@ -9,6 +9,7 @@ * Adminhtml catalog inventory "Minimum Qty Allowed in Shopping Cart" field * * @api + * @since 100.0.2 */ class Minsaleqty extends \Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray { diff --git a/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Stock.php b/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Stock.php index 89bb921c84e21..2c41e1798921a 100644 --- a/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Stock.php +++ b/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Stock.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class Stock extends \Magento\Framework\Data\Form\Element\Select { diff --git a/app/code/Magento/CatalogInventory/Block/Qtyincrements.php b/app/code/Magento/CatalogInventory/Block/Qtyincrements.php index 9efdf4d673c21..adaa762f3279b 100644 --- a/app/code/Magento/CatalogInventory/Block/Qtyincrements.php +++ b/app/code/Magento/CatalogInventory/Block/Qtyincrements.php @@ -13,6 +13,7 @@ * Product qty increments block * * @api + * @since 100.0.2 */ class Qtyincrements extends Template implements IdentityInterface { diff --git a/app/code/Magento/CatalogInventory/Block/Stockqty/DefaultStockqty.php b/app/code/Magento/CatalogInventory/Block/Stockqty/DefaultStockqty.php index ebb6b03c11f4f..c315338be0de0 100644 --- a/app/code/Magento/CatalogInventory/Block/Stockqty/DefaultStockqty.php +++ b/app/code/Magento/CatalogInventory/Block/Stockqty/DefaultStockqty.php @@ -10,6 +10,7 @@ * Product stock qty default block * * @api + * @since 100.0.2 */ class DefaultStockqty extends AbstractStockqty implements \Magento\Framework\DataObject\IdentityInterface { diff --git a/app/code/Magento/CatalogInventory/Helper/Stock.php b/app/code/Magento/CatalogInventory/Helper/Stock.php index ea0dfc8ed4c18..410e35096ee58 100644 --- a/app/code/Magento/CatalogInventory/Helper/Stock.php +++ b/app/code/Magento/CatalogInventory/Helper/Stock.php @@ -93,7 +93,7 @@ public function assignStatusToProduct(Product $product, $status = null) * Add stock status information to products * * @param AbstractCollection $productCollection - * @deprecated Use Stock::addIsInStockFilterToCollection instead + * @deprecated 100.1.0 Use Stock::addIsInStockFilterToCollection instead * @return void */ public function addStockStatusToProducts(AbstractCollection $productCollection) @@ -176,7 +176,7 @@ protected function getStockStatusResource() /** * @return StockConfigurationInterface * - * @deprecated + * @deprecated 100.1.0 */ private function getStockConfiguration() { diff --git a/app/code/Magento/CatalogInventory/Model/Adminhtml/Stock/Item.php b/app/code/Magento/CatalogInventory/Model/Adminhtml/Stock/Item.php index da496f7a3d258..36721db874887 100644 --- a/app/code/Magento/CatalogInventory/Model/Adminhtml/Stock/Item.php +++ b/app/code/Magento/CatalogInventory/Model/Adminhtml/Stock/Item.php @@ -19,6 +19,7 @@ * @method \Magento\CatalogInventory\Api\Data\StockItemExtensionInterface getExtensionAttributes() * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @api + * @since 100.0.2 */ class Item extends \Magento\CatalogInventory\Model\Stock\Item implements IdentityInterface { diff --git a/app/code/Magento/CatalogInventory/Model/Indexer/Stock.php b/app/code/Magento/CatalogInventory/Model/Indexer/Stock.php index e471d3eef442b..4b35bfdc7ab1e 100644 --- a/app/code/Magento/CatalogInventory/Model/Indexer/Stock.php +++ b/app/code/Magento/CatalogInventory/Model/Indexer/Stock.php @@ -101,7 +101,7 @@ public function executeRow($id) * Get cache context * * @return \Magento\Framework\Indexer\CacheContext - * @deprecated + * @deprecated 100.0.7 */ protected function getCacheContext() { diff --git a/app/code/Magento/CatalogInventory/Model/Plugin/AfterProductLoad.php b/app/code/Magento/CatalogInventory/Model/Plugin/AfterProductLoad.php index 64609da69d48b..1495037c37471 100644 --- a/app/code/Magento/CatalogInventory/Model/Plugin/AfterProductLoad.php +++ b/app/code/Magento/CatalogInventory/Model/Plugin/AfterProductLoad.php @@ -7,7 +7,7 @@ namespace Magento\CatalogInventory\Model\Plugin; /** - * @deprecated Stock Item as a part of ExtensionAttributes is deprecated + * @deprecated 100.2.0 Stock Item as a part of ExtensionAttributes is deprecated * @see StockItemInterface when you want to change the stock data * @see StockStatusInterface when you want to read the stock data for representation layer (storefront) * @see StockItemRepositoryInterface::save as extension point for customization of saving process diff --git a/app/code/Magento/CatalogInventory/Model/Plugin/AroundProductRepositorySave.php b/app/code/Magento/CatalogInventory/Model/Plugin/AroundProductRepositorySave.php deleted file mode 100644 index a48be126d8eee..0000000000000 --- a/app/code/Magento/CatalogInventory/Model/Plugin/AroundProductRepositorySave.php +++ /dev/null @@ -1,44 +0,0 @@ -get($product->getSku(), false, $product->getStoreId()); - } -} diff --git a/app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator.php b/app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator.php index 1f1bfef677358..3fb0790640ffc 100644 --- a/app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator.php +++ b/app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator.php @@ -19,6 +19,7 @@ /** * @api + * @since 100.0.2 */ class QuantityValidator { diff --git a/app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator/Initializer/QtyProcessor.php b/app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator/Initializer/QtyProcessor.php index b3d74ab8115ad..6ba35d4d170ea 100644 --- a/app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator/Initializer/QtyProcessor.php +++ b/app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator/Initializer/QtyProcessor.php @@ -9,7 +9,7 @@ use Magento\Quote\Model\Quote\Item; /** - * @deprecated No more used + * @deprecated 100.2.0 No more used */ class QtyProcessor { @@ -34,7 +34,7 @@ public function __construct(QuoteItemQtyList $quoteItemQtyList) /** * @param Item $quoteItem * @return $this - * @deprecated No more used + * @deprecated 100.2.0 No more used */ public function setItem(Item $quoteItem) { @@ -45,7 +45,7 @@ public function setItem(Item $quoteItem) /** * @param float $qty * @return float|int - * @deprecated No more used + * @deprecated 100.2.0 No more used */ public function getRowQty($qty) { @@ -59,7 +59,7 @@ public function getRowQty($qty) /** * @param int $qty * @return int - * @deprecated No more used + * @deprecated 100.2.0 No more used */ public function getQtyForCheck($qty) { diff --git a/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php b/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php index c8ad1b516fec8..366cb1c3902a3 100644 --- a/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php +++ b/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php @@ -17,6 +17,7 @@ * CatalogInventory Default Stock Status Indexer Resource Model * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @api + * @since 100.0.2 */ class DefaultStock extends AbstractIndexer implements StockInterface { @@ -48,6 +49,7 @@ class DefaultStock extends AbstractIndexer implements StockInterface /** * @var StockConfigurationInterface + * @since 100.1.0 */ protected $stockConfiguration; @@ -130,6 +132,7 @@ public function reindexEntity($entityIds) * Returns action run type * * @return string + * @since 100.2.0 */ public function getActionType() { @@ -141,6 +144,7 @@ public function getActionType() * * @param string $type * @return $this + * @since 100.2.0 */ public function setActionType($type) { @@ -361,6 +365,7 @@ public function getIdxTable($table = null) * @param AdapterInterface $connection * @param bool $isAggregate * @return mixed + * @since 100.1.0 */ protected function getStatusExpression(AdapterInterface $connection, $isAggregate = false) { @@ -384,7 +389,8 @@ protected function getStatusExpression(AdapterInterface $connection, $isAggregat /** * @return StockConfigurationInterface * - * @deprecated + * @deprecated 100.1.0 + * @since 100.1.0 */ protected function getStockConfiguration() { diff --git a/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/QueryProcessorInterface.php b/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/QueryProcessorInterface.php index ad3d2100bf4a5..abe473bd9682b 100644 --- a/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/QueryProcessorInterface.php +++ b/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/QueryProcessorInterface.php @@ -10,6 +10,7 @@ /** * @api + * @since 100.1.0 */ interface QueryProcessorInterface { @@ -18,6 +19,7 @@ interface QueryProcessorInterface * @param null|array $entityIds * @param bool $usePrimaryTable * @return Select + * @since 100.1.0 */ public function processQuery(Select $select, $entityIds = null, $usePrimaryTable = false); } diff --git a/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/StockInterface.php b/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/StockInterface.php index 40bdc6b7809d9..5ced55edf208b 100644 --- a/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/StockInterface.php +++ b/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/StockInterface.php @@ -8,6 +8,7 @@ /** * CatalogInventory Stock Indexer Interface * @api + * @since 100.0.2 */ interface StockInterface { diff --git a/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/StockFactory.php b/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/StockFactory.php index 016e7a17eb2ac..f9738484766b9 100644 --- a/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/StockFactory.php +++ b/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/StockFactory.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class StockFactory { diff --git a/app/code/Magento/CatalogInventory/Model/ResourceModel/Stock.php b/app/code/Magento/CatalogInventory/Model/ResourceModel/Stock.php index 78a60e29e444e..9223fd32e3567 100644 --- a/app/code/Magento/CatalogInventory/Model/ResourceModel/Stock.php +++ b/app/code/Magento/CatalogInventory/Model/ResourceModel/Stock.php @@ -75,7 +75,7 @@ class Stock extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb impleme /** * @var StoreManagerInterface - * @deprecated + * @deprecated 100.1.0 */ protected $storeManager; diff --git a/app/code/Magento/CatalogInventory/Model/ResourceModel/Stock/Item/StockItemCriteriaMapper.php b/app/code/Magento/CatalogInventory/Model/ResourceModel/Stock/Item/StockItemCriteriaMapper.php index d54328cebcda5..21b6dfefeb1f5 100644 --- a/app/code/Magento/CatalogInventory/Model/ResourceModel/Stock/Item/StockItemCriteriaMapper.php +++ b/app/code/Magento/CatalogInventory/Model/ResourceModel/Stock/Item/StockItemCriteriaMapper.php @@ -29,7 +29,7 @@ class StockItemCriteriaMapper extends GenericMapper /** * @var StoreManagerInterface - * @deprecated + * @deprecated 100.1.0 */ private $storeManager; @@ -167,7 +167,7 @@ public function mapQtyFilter($comparisonMethod, $qty) /** * @return StockConfigurationInterface * - * @deprecated + * @deprecated 100.1.0 */ private function getStockConfiguration() { diff --git a/app/code/Magento/CatalogInventory/Model/ResourceModel/Stock/Status.php b/app/code/Magento/CatalogInventory/Model/ResourceModel/Stock/Status.php index a3095f51216a1..e9f3cd59af0bb 100644 --- a/app/code/Magento/CatalogInventory/Model/ResourceModel/Stock/Status.php +++ b/app/code/Magento/CatalogInventory/Model/ResourceModel/Stock/Status.php @@ -19,7 +19,7 @@ class Status extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb * Store model manager * * @var \Magento\Store\Model\StoreManagerInterface - * @deprecated + * @deprecated 100.1.0 */ protected $_storeManager; @@ -339,7 +339,7 @@ public function getProductStatus($productIds, $storeId = null) /** * @return StockConfigurationInterface * - * @deprecated + * @deprecated 100.1.0 */ private function getStockConfiguration() { diff --git a/app/code/Magento/CatalogInventory/Model/Source/Backorders.php b/app/code/Magento/CatalogInventory/Model/Source/Backorders.php index 4bdedac279b67..1d200d27a4445 100644 --- a/app/code/Magento/CatalogInventory/Model/Source/Backorders.php +++ b/app/code/Magento/CatalogInventory/Model/Source/Backorders.php @@ -8,6 +8,7 @@ /** * Back orders source class * @api + * @since 100.0.2 */ class Backorders implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/CatalogInventory/Model/Source/Stock.php b/app/code/Magento/CatalogInventory/Model/Source/Stock.php index 0a3e8db196567..f64026cce23a5 100644 --- a/app/code/Magento/CatalogInventory/Model/Source/Stock.php +++ b/app/code/Magento/CatalogInventory/Model/Source/Stock.php @@ -10,6 +10,7 @@ /** * CatalogInventory Stock source model * @api + * @since 100.0.2 */ class Stock extends AbstractSource { diff --git a/app/code/Magento/CatalogInventory/Model/Stock/StockItemRepository.php b/app/code/Magento/CatalogInventory/Model/Stock/StockItemRepository.php index 04e15cf07c2ce..2cdf12bef8b22 100644 --- a/app/code/Magento/CatalogInventory/Model/Stock/StockItemRepository.php +++ b/app/code/Magento/CatalogInventory/Model/Stock/StockItemRepository.php @@ -77,6 +77,7 @@ class StockItemRepository implements StockItemRepositoryInterface /** * @var Processor + * @deprecated */ protected $indexProcessor; @@ -181,8 +182,6 @@ public function save(\Magento\CatalogInventory\Api\Data\StockItemInterface $stoc $stockItem->setStockId($stockItem->getStockId()); $this->resource->save($stockItem); - - $this->indexProcessor->reindexRow($stockItem->getProductId()); } catch (\Exception $exception) { throw new CouldNotSaveException(__('Unable to save Stock Item'), $exception); } diff --git a/app/code/Magento/CatalogInventory/Model/StockIndex.php b/app/code/Magento/CatalogInventory/Model/StockIndex.php index d74add9577505..6081ef20efd64 100644 --- a/app/code/Magento/CatalogInventory/Model/StockIndex.php +++ b/app/code/Magento/CatalogInventory/Model/StockIndex.php @@ -78,7 +78,7 @@ public function __construct( * * @param int $productId * @param int $scopeId - * @deprecated + * @deprecated 100.1.0 * @return true * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ @@ -109,7 +109,7 @@ public function rebuild($productId = null, $scopeId = null) * * @param int $productId * @param int $websiteId - * @deprecated + * @deprecated 100.1.0 * @return void */ public function updateProductStockStatus($productId, $websiteId) diff --git a/app/code/Magento/CatalogInventory/Observer/ProcessInventoryDataObserver.php b/app/code/Magento/CatalogInventory/Observer/ProcessInventoryDataObserver.php index 4d4628e25efff..e473f714bd21d 100644 --- a/app/code/Magento/CatalogInventory/Observer/ProcessInventoryDataObserver.php +++ b/app/code/Magento/CatalogInventory/Observer/ProcessInventoryDataObserver.php @@ -15,7 +15,7 @@ * This observer prepares stock data for saving by combining stock data from the stock data property * and quantity_and_stock_status attribute and setting it to the single point represented by stock data property. * - * @deprecated Stock data should be processed using the module API + * @deprecated 100.2.0 Stock data should be processed using the module API * @see StockItemInterface when you want to change the stock data * @see StockStatusInterface when you want to read the stock data for representation layer (storefront) * @see StockItemRepositoryInterface::save as extension point for customization of saving process diff --git a/app/code/Magento/CatalogInventory/Observer/SaveInventoryDataObserver.php b/app/code/Magento/CatalogInventory/Observer/SaveInventoryDataObserver.php index 5f1c4f4350b12..03ba58d3f4987 100644 --- a/app/code/Magento/CatalogInventory/Observer/SaveInventoryDataObserver.php +++ b/app/code/Magento/CatalogInventory/Observer/SaveInventoryDataObserver.php @@ -17,7 +17,7 @@ /** * Saves stock data from a product to the Stock Item * - * @deprecated Stock data should be processed using the module API + * @deprecated 100.2.0 Stock data should be processed using the module API * @see StockItemInterface when you want to change the stock data * @see StockStatusInterface when you want to read the stock data for representation layer (storefront) * @see StockItemRepositoryInterface::save as extension point for customization of saving process diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Api/StockConfigurationTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Api/StockConfigurationTest.php index 71fe4b81ef506..191869ccf6932 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Api/StockConfigurationTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Api/StockConfigurationTest.php @@ -11,7 +11,7 @@ /** * Class StockConfigurationTest */ -class StockConfigurationTest extends \PHPUnit_Framework_TestCase +class StockConfigurationTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\CatalogInventory\Api\StockConfigurationInterface */ protected $stockConfiguration; @@ -49,13 +49,7 @@ protected function setUp() false ); - $this->minsaleqtyHelper = $this->getMock( - \Magento\CatalogInventory\Helper\Minsaleqty::class, - [], - [], - '', - false - ); + $this->minsaleqtyHelper = $this->createMock(\Magento\CatalogInventory\Helper\Minsaleqty::class); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->stockConfiguration = $this->objectManagerHelper->getObject( diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Api/StockRegistryTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Api/StockRegistryTest.php index b8e5765d7d8a5..faf91c2b62273 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Api/StockRegistryTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Api/StockRegistryTest.php @@ -12,7 +12,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class StockRegistryTest extends \PHPUnit_Framework_TestCase +class StockRegistryTest extends \PHPUnit\Framework\TestCase { /** @var ObjectManagerHelper */ protected $objectManagerHelper; @@ -65,18 +65,12 @@ protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->product = $this->getMock( - \Magento\Catalog\Model\Product::class, - ['__wakeup', 'getIdBySku'], - [], - '', - false - ); + $this->product = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['__wakeup', 'getIdBySku']); $this->product->expects($this->any()) ->method('getIdBySku') ->willReturn($this->productId); //getIdBySku - $this->productFactory = $this->getMock(\Magento\Catalog\Model\ProductFactory::class, ['create'], [], '', false); + $this->productFactory = $this->createPartialMock(\Magento\Catalog\Model\ProductFactory::class, ['create']); $this->productFactory->expects($this->any()) ->method('create') ->will($this->returnValue($this->product)); diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Api/StockStateTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Api/StockStateTest.php index a5ebf15d2433b..124a423481106 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Api/StockStateTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Api/StockStateTest.php @@ -12,7 +12,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class StockStateTest extends \PHPUnit_Framework_TestCase +class StockStateTest extends \PHPUnit\Framework\TestCase { /** @var ObjectManagerHelper */ protected $objectManagerHelper; @@ -60,36 +60,12 @@ protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->stock = $this->getMock( - \Magento\CatalogInventory\Api\Data\StockInterface::class, - [], - [], - '', - false - ); - $this->stockItem = $this->getMock( - \Magento\CatalogInventory\Api\Data\StockItemInterface::class, - [], - [], - '', - false - ); - $this->stockStatus = $this->getMock( - \Magento\CatalogInventory\Api\Data\StockStatusInterface::class, - [], - [], - '', - false - ); - $this->objectResult = $this->getMock( - \Magento\Framework\DataObject::class, - [], - [], - '', - false - ); + $this->stock = $this->createMock(\Magento\CatalogInventory\Api\Data\StockInterface::class); + $this->stockItem = $this->createMock(\Magento\CatalogInventory\Api\Data\StockItemInterface::class); + $this->stockStatus = $this->createMock(\Magento\CatalogInventory\Api\Data\StockStatusInterface::class); + $this->objectResult = $this->createMock(\Magento\Framework\DataObject::class); - $this->stockStateProvider = $this->getMock( + $this->stockStateProvider = $this->createPartialMock( \Magento\CatalogInventory\Model\Spi\StockStateProviderInterface::class, [ 'verifyStock', @@ -99,10 +75,7 @@ protected function setUp() 'getStockQty', 'checkQtyIncrements', 'checkQuoteItemQty' - ], - [], - '', - false + ] ); $this->stockStateProvider->expects($this->any())->method('verifyStock')->willReturn(true); $this->stockStateProvider->expects($this->any())->method('verifyNotification')->willReturn(true); @@ -112,12 +85,9 @@ protected function setUp() $this->stockStateProvider->expects($this->any())->method('checkQtyIncrements')->willReturn($this->objectResult); $this->stockStateProvider->expects($this->any())->method('checkQuoteItemQty')->willReturn($this->objectResult); - $this->stockRegistryProvider = $this->getMock( + $this->stockRegistryProvider = $this->createPartialMock( \Magento\CatalogInventory\Model\Spi\StockRegistryProviderInterface::class, - ['getStock', 'getStockItem', 'getStockStatus'], - [], - '', - false + ['getStock', 'getStockItem', 'getStockStatus'] ); $this->stockRegistryProvider->expects($this->any()) ->method('getStock') diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Block/Adminhtml/Form/Field/StockTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Block/Adminhtml/Form/Field/StockTest.php index ab509617b9b8f..7e8dbe4726f55 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Block/Adminhtml/Form/Field/StockTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Block/Adminhtml/Form/Field/StockTest.php @@ -8,7 +8,7 @@ /** * @SuppressWarnings(PHPMD.LongVariable) */ -class StockTest extends \PHPUnit_Framework_TestCase +class StockTest extends \PHPUnit\Framework\TestCase { const ATTRIBUTE_NAME = 'quantity_and_stock_status'; @@ -39,34 +39,15 @@ class StockTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_factoryElementMock = $this->getMock( - \Magento\Framework\Data\Form\Element\Factory::class, - [], - [], - '', - false + $this->_factoryElementMock = $this->createMock(\Magento\Framework\Data\Form\Element\Factory::class); + $this->_collectionFactoryMock = $this->createMock( + \Magento\Framework\Data\Form\Element\CollectionFactory::class ); - $this->_collectionFactoryMock = $this->getMock( - \Magento\Framework\Data\Form\Element\CollectionFactory::class, - [], - [], - '', - false - ); - $this->_qtyMock = $this->getMock( + $this->_qtyMock = $this->createPartialMock( \Magento\Framework\Data\Form\Element\Text::class, - ['setForm', 'setValue', 'setName'], - [], - '', - false - ); - $this->_factoryTextMock = $this->getMock( - \Magento\Framework\Data\Form\Element\TextFactory::class, - [], - [], - '', - false + ['setForm', 'setValue', 'setName'] ); + $this->_factoryTextMock = $this->createMock(\Magento\Framework\Data\Form\Element\TextFactory::class); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_block = $objectManagerHelper->getObject( diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Block/Plugin/ProductViewTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Block/Plugin/ProductViewTest.php index 7eac0f50ae38d..4ef2e78e590fb 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Block/Plugin/ProductViewTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Block/Plugin/ProductViewTest.php @@ -5,7 +5,7 @@ */ namespace Magento\CatalogInventory\Test\Unit\Block\Plugin; -class ProductViewTest extends \PHPUnit_Framework_TestCase +class ProductViewTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogInventory\Block\Plugin\ProductView diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Block/QtyincrementsTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Block/QtyincrementsTest.php index 2e14e28a9d925..1ea3fd376bdc8 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Block/QtyincrementsTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Block/QtyincrementsTest.php @@ -8,7 +8,7 @@ /** * Unit test for Qtyincrements block */ -class QtyincrementsTest extends \PHPUnit_Framework_TestCase +class QtyincrementsTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogInventory\Block\Qtyincrements @@ -33,13 +33,10 @@ class QtyincrementsTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->registryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); - $this->stockItem = $this->getMockForAbstractClass( - \Magento\CatalogInventory\Api\Data\StockItemInterface::class, - ['getQtyIncrements'], - '', - false - ); + $this->registryMock = $this->createMock(\Magento\Framework\Registry::class); + $this->stockItem = $this->getMockBuilder(\Magento\CatalogInventory\Api\Data\StockItemInterface::class) + ->setMethods(['getQtyIncrements', 'getStockItem']) + ->getMockForAbstractClass(); $this->stockItem->expects($this->any())->method('getStockItem')->willReturn(1); $this->stockRegistry = $this->getMockForAbstractClass( \Magento\CatalogInventory\Api\StockRegistryInterface::class, @@ -66,9 +63,9 @@ protected function tearDown() public function testGetIdentities() { $productTags = ['catalog_product_1']; - $product = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $product = $this->createMock(\Magento\Catalog\Model\Product::class); $product->expects($this->once())->method('getIdentities')->will($this->returnValue($productTags)); - $store = $this->getMock(\Magento\Store\Model\Store::class, ['getWebsiteId', '__wakeup'], [], '', false); + $store = $this->createPartialMock(\Magento\Store\Model\Store::class, ['getWebsiteId', '__wakeup']); $store->expects($this->any())->method('getWebsiteId')->willReturn(0); $product->expects($this->any())->method('getStore')->will($this->returnValue($store)); $this->registryMock->expects($this->once()) @@ -91,10 +88,10 @@ public function testGetProductQtyIncrements($productId, $qtyInc, $isSaleable, $r ->method('getQtyIncrements') ->will($this->returnValue($qtyInc)); - $product = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $product = $this->createMock(\Magento\Catalog\Model\Product::class); $product->expects($this->once())->method('getId')->will($this->returnValue($productId)); $product->expects($this->once())->method('isSaleable')->will($this->returnValue($isSaleable)); - $store = $this->getMock(\Magento\Store\Model\Store::class, ['getWebsiteId', '__wakeup'], [], '', false); + $store = $this->createPartialMock(\Magento\Store\Model\Store::class, ['getWebsiteId', '__wakeup']); $store->expects($this->any())->method('getWebsiteId')->willReturn(0); $product->expects($this->any())->method('getStore')->will($this->returnValue($store)); diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Block/Stockqty/DefaultStockqtyTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Block/Stockqty/DefaultStockqtyTest.php index 54f82333921c3..296931ba53b89 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Block/Stockqty/DefaultStockqtyTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Block/Stockqty/DefaultStockqtyTest.php @@ -8,7 +8,7 @@ /** * Unit test for DefaultStockqty */ -class DefaultStockqtyTest extends \PHPUnit_Framework_TestCase +class DefaultStockqtyTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogInventory\Block\Stockqty\DefaultStockqty @@ -33,7 +33,7 @@ class DefaultStockqtyTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->registryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); + $this->registryMock = $this->createMock(\Magento\Framework\Registry::class); $this->stockRegistryMock = $this->getMockBuilder(\Magento\CatalogInventory\Api\StockRegistryInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -58,7 +58,7 @@ protected function tearDown() public function testGetIdentities() { $productTags = ['catalog_product_1']; - $product = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $product = $this->createMock(\Magento\Catalog\Model\Product::class); $product->expects($this->once())->method('getIdentities')->will($this->returnValue($productTags)); $this->registryMock->expects($this->once()) ->method('registry') @@ -81,15 +81,12 @@ public function testGetStockQty($productStockQty, $productId, $websiteId, $dataQ if ($dataQty) { $this->setDataArrayValue('product_stock_qty', $dataQty); } else { - $product = $this->getMock( + $product = $this->createPartialMock( \Magento\Catalog\Model\Product::class, - ['getId', 'getStore', '__wakeup'], - [], - '', - false + ['getId', 'getStore', '__wakeup'] ); $product->expects($this->any())->method('getId')->will($this->returnValue($productId)); - $store = $this->getMock(\Magento\Store\Model\Store::class, ['getWebsiteId', '__wakeup'], [], '', false); + $store = $this->createPartialMock(\Magento\Store\Model\Store::class, ['getWebsiteId', '__wakeup']); $store->expects($this->any())->method('getWebsiteId')->willReturn($websiteId); $product->expects($this->any())->method('getStore')->will($this->returnValue($store)); @@ -125,7 +122,7 @@ public function te1stGetStockQtyLeft() $storeMock->expects($this->once()) ->method('getWebsiteId') ->willReturn($websiteId); - $product = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $product = $this->createMock(\Magento\Catalog\Model\Product::class); $product->expects($this->any()) ->method('getId') ->willReturn($productId); diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Helper/MinsaleqtyTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Helper/MinsaleqtyTest.php index 0612cd6cc7146..f008ed7d9d694 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Helper/MinsaleqtyTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Helper/MinsaleqtyTest.php @@ -11,7 +11,7 @@ /** * Class MinsaleqtyTest */ -class MinsaleqtyTest extends \PHPUnit_Framework_TestCase +class MinsaleqtyTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\CatalogInventory\Helper\Minsaleqty */ protected $minsaleqty; @@ -30,8 +30,8 @@ class MinsaleqtyTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $this->randomMock = $this->getMock(\Magento\Framework\Math\Random::class); + $this->scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->randomMock = $this->createMock(\Magento\Framework\Math\Random::class); $this->randomMock->expects($this->any()) ->method('getUniqueHash') ->with($this->equalTo('_')) @@ -53,7 +53,7 @@ protected function setUp() ->method('getAllCustomersGroup') ->will($this->returnValue($allGroup)); - $this->serializerMock = $this->getMock(\Magento\Framework\Serialize\Serializer\Json::class); + $this->serializerMock = $this->createMock(\Magento\Framework\Serialize\Serializer\Json::class); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->minsaleqty = $this->objectManagerHelper->getObject( diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Helper/StockTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Helper/StockTest.php index d8ec7b0b15015..2fe40c118b06a 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Helper/StockTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Helper/StockTest.php @@ -12,7 +12,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class StockTest extends \PHPUnit_Framework_TestCase +class StockTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogInventory\Helper\Stock diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/AddStockStatusToCollectionTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/AddStockStatusToCollectionTest.php index fcfa4bcae2d27..af35666ced3e5 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/AddStockStatusToCollectionTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/AddStockStatusToCollectionTest.php @@ -7,7 +7,7 @@ use Magento\CatalogInventory\Model\AddStockStatusToCollection; -class AddStockStatusToCollectionTest extends \PHPUnit_Framework_TestCase +class AddStockStatusToCollectionTest extends \PHPUnit\Framework\TestCase { /** * @var AddStockStatusToCollection @@ -21,7 +21,7 @@ class AddStockStatusToCollectionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->stockHelper = $this->getMock(\Magento\CatalogInventory\Helper\Stock::class, [], [], '', false); + $this->stockHelper = $this->createMock(\Magento\CatalogInventory\Helper\Stock::class); $this->plugin = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject( \Magento\CatalogInventory\Model\AddStockStatusToCollection::class, [ diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Adminhtml/Stock/ItemTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Adminhtml/Stock/ItemTest.php index 80e213b6d0f5f..25e4863b0fe2c 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Adminhtml/Stock/ItemTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Adminhtml/Stock/ItemTest.php @@ -5,7 +5,7 @@ */ namespace Magento\CatalogInventory\Test\Unit\Model\Adminhtml\Stock; -class ItemTest extends \PHPUnit_Framework_TestCase +class ItemTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogInventory\Model\Adminhtml\Stock\Item|PHPUnit_Framework_MockObject_MockObject @@ -17,12 +17,9 @@ class ItemTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $resourceMock = $this->getMock( + $resourceMock = $this->createPartialMock( \Magento\Framework\Model\ResourceModel\AbstractResource::class, - ['_construct', 'getConnection', 'getIdFieldName'], - [], - '', - false + ['_construct', 'getConnection', 'getIdFieldName'] ); $objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Config/Backend/ManagestockTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Config/Backend/ManagestockTest.php index c4556f4b708fb..522bd90d71993 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Config/Backend/ManagestockTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Config/Backend/ManagestockTest.php @@ -5,7 +5,7 @@ */ namespace Magento\CatalogInventory\Test\Unit\Model\Config\Backend; -class ManagestockTest extends \PHPUnit_Framework_TestCase +class ManagestockTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\CatalogInventory\Model\Indexer\Stock\Processor|\PHPUnit_Framework_MockObject_MockObject */ protected $stockIndexerProcessor; diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/ConfigurationTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/ConfigurationTest.php index 3915f7bfdbc7b..d2779b79b30d7 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/ConfigurationTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/ConfigurationTest.php @@ -10,7 +10,7 @@ /** * Class ConfigurationTest */ -class ConfigurationTest extends \PHPUnit_Framework_TestCase +class ConfigurationTest extends \PHPUnit\Framework\TestCase { /** * @var Configuration diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/Stock/Action/FullTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/Stock/Action/FullTest.php index 00365b6a7c7b9..e1a19bf10ecd4 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/Stock/Action/FullTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/Stock/Action/FullTest.php @@ -9,20 +9,16 @@ namespace Magento\CatalogInventory\Test\Unit\Model\Indexer\Stock\Action; -class FullTest extends \PHPUnit_Framework_TestCase +class FullTest extends \PHPUnit\Framework\TestCase { public function testExecuteWithAdapterErrorThrowsException() { - $indexerFactoryMock = $this->getMock( - \Magento\CatalogInventory\Model\ResourceModel\Indexer\StockFactory::class, - [], - [], - '', - false + $indexerFactoryMock = $this->createMock( + \Magento\CatalogInventory\Model\ResourceModel\Indexer\StockFactory::class ); - $resourceMock = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); - $productTypeMock = $this->getMock(\Magento\Catalog\Model\Product\Type::class, [], [], '', false); - $connectionMock = $this->getMock(\Magento\Framework\DB\Adapter\AdapterInterface::class); + $resourceMock = $this->createMock(\Magento\Framework\App\ResourceConnection::class); + $productTypeMock = $this->createMock(\Magento\Catalog\Model\Product\Type::class); + $connectionMock = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class); $productTypeMock ->method('getTypesByPriority') @@ -48,7 +44,7 @@ public function testExecuteWithAdapterErrorThrowsException() ] ); - $this->setExpectedException(\Magento\Framework\Exception\LocalizedException::class, $exceptionMessage); + $this->expectException(\Magento\Framework\Exception\LocalizedException::class, $exceptionMessage); $model->execute(); } diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/Stock/Action/RowTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/Stock/Action/RowTest.php index 6da05d3f8dedd..d5ebeb15128ca 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/Stock/Action/RowTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/Stock/Action/RowTest.php @@ -11,7 +11,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class RowTest extends \PHPUnit_Framework_TestCase +class RowTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogInventory\Model\Indexer\Stock\Action\Rows diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/Stock/Action/RowsTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/Stock/Action/RowsTest.php index 9ed0397a4e1ee..f3a7f377af61d 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/Stock/Action/RowsTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/Stock/Action/RowsTest.php @@ -11,7 +11,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class RowsTest extends \PHPUnit_Framework_TestCase +class RowsTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogInventory\Model\Indexer\Stock\Action\Rows diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/Stock/CacheCleanerTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/Stock/CacheCleanerTest.php index 0f7c108ba1940..5e4249685f8d3 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/Stock/CacheCleanerTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/Stock/CacheCleanerTest.php @@ -16,7 +16,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Catalog\Model\Product; -class CacheCleanerTest extends \PHPUnit_Framework_TestCase +class CacheCleanerTest extends \PHPUnit\Framework\TestCase { /** * @var CacheCleaner diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/Stock/Plugin/StoreGroupTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/Stock/Plugin/StoreGroupTest.php index f93fae147fb2e..b7f063196b72e 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/Stock/Plugin/StoreGroupTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/Stock/Plugin/StoreGroupTest.php @@ -9,7 +9,7 @@ namespace Magento\CatalogInventory\Test\Unit\Model\Indexer\Stock\Plugin; -class StoreGroupTest extends \PHPUnit_Framework_TestCase +class StoreGroupTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogInventory\Model\Indexer\Stock\Plugin\StoreGroup @@ -23,13 +23,7 @@ class StoreGroupTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_indexerMock = $this->getMock( - \Magento\CatalogInventory\Model\Indexer\Stock\Processor::class, - [], - [], - '', - false - ); + $this->_indexerMock = $this->createMock(\Magento\CatalogInventory\Model\Indexer\Stock\Processor::class); $this->_model = new \Magento\CatalogInventory\Model\Indexer\Stock\Plugin\StoreGroup($this->_indexerMock); } @@ -39,13 +33,10 @@ protected function setUp() */ public function testBeforeSave(array $data) { - $subjectMock = $this->getMock(\Magento\Store\Model\ResourceModel\Group::class, [], [], '', false); - $objectMock = $this->getMock( + $subjectMock = $this->createMock(\Magento\Store\Model\ResourceModel\Group::class); + $objectMock = $this->createPartialMock( \Magento\Framework\Model\AbstractModel::class, - ['getId', 'dataHasChangedFor', '__wakeup'], - [], - '', - false + ['getId', 'dataHasChangedFor', '__wakeup'] ); $objectMock->expects($this->once()) ->method('getId') diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Plugin/AfterProductLoadTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Plugin/AfterProductLoadTest.php index 408802d80bd57..6f02c27ca1dff 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Plugin/AfterProductLoadTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Plugin/AfterProductLoadTest.php @@ -9,7 +9,7 @@ namespace Magento\CatalogInventory\Test\Unit\Model\Plugin; -class AfterProductLoadTest extends \PHPUnit_Framework_TestCase +class AfterProductLoadTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogInventory\Model\Plugin\AfterProductLoad @@ -33,7 +33,7 @@ class AfterProductLoadTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $stockRegistryMock = $this->getMock(\Magento\CatalogInventory\Api\StockRegistryInterface::class); + $stockRegistryMock = $this->createMock(\Magento\CatalogInventory\Api\StockRegistryInterface::class); $this->productExtensionFactoryMock = $this->getMockBuilder( \Magento\Catalog\Api\Data\ProductExtensionFactory::class) ->setMethods(['create']) @@ -46,7 +46,7 @@ protected function setUp() ); $productId = 5494; - $stockItemMock = $this->getMock(\Magento\CatalogInventory\Api\Data\StockItemInterface::class); + $stockItemMock = $this->createMock(\Magento\CatalogInventory\Api\Data\StockItemInterface::class); $stockRegistryMock->expects($this->once()) ->method('getStockItem') @@ -55,7 +55,7 @@ protected function setUp() $this->productExtensionMock = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductExtensionInterface::class) ->setMethods(['setStockItem']) - ->getMock(); + ->getMockForAbstractClass(); $this->productExtensionMock->expects($this->once()) ->method('setStockItem') ->with($stockItemMock) diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Plugin/LayerTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Plugin/LayerTest.php index 1b440338dcb77..287459bd8cbc8 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Plugin/LayerTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Plugin/LayerTest.php @@ -5,7 +5,7 @@ */ namespace Magento\CatalogInventory\Test\Unit\Model\Plugin; -class LayerTest extends \PHPUnit_Framework_TestCase +class LayerTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogInventory\Model\Plugin\Layer @@ -24,14 +24,8 @@ class LayerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $this->_stockHelperMock = $this->getMock( - \Magento\CatalogInventory\Helper\Stock::class, - [], - [], - '', - false - ); + $this->_scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->_stockHelperMock = $this->createMock(\Magento\CatalogInventory\Helper\Stock::class); $this->_model = new \Magento\CatalogInventory\Model\Plugin\Layer( $this->_stockHelperMock, @@ -54,16 +48,10 @@ public function testAddStockStatusDisabledShow() $this->returnValue(true) ); /** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $collectionMock */ - $collectionMock = $this->getMock( - \Magento\Catalog\Model\ResourceModel\Product\Collection::class, - [], - [], - '', - false - ); + $collectionMock = $this->createMock(\Magento\Catalog\Model\ResourceModel\Product\Collection::class); $this->_stockHelperMock->expects($this->never())->method('addIsInStockFilterToCollection'); /** @var \Magento\Catalog\Model\Layer $subjectMock */ - $subjectMock = $this->getMock(\Magento\Catalog\Model\Layer::class, [], [], '', false); + $subjectMock = $this->createMock(\Magento\Catalog\Model\Layer::class); $this->_model->beforePrepareProductCollection($subjectMock, $collectionMock); } @@ -82,13 +70,7 @@ public function testAddStockStatusEnabledShow() $this->returnValue(false) ); - $collectionMock = $this->getMock( - \Magento\Catalog\Model\ResourceModel\Product\Collection::class, - [], - [], - '', - false - ); + $collectionMock = $this->createMock(\Magento\Catalog\Model\ResourceModel\Product\Collection::class); $this->_stockHelperMock->expects( $this->once() @@ -98,7 +80,7 @@ public function testAddStockStatusEnabledShow() $collectionMock ); - $subjectMock = $this->getMock(\Magento\Catalog\Model\Layer::class, [], [], '', false); + $subjectMock = $this->createMock(\Magento\Catalog\Model\Layer::class); $this->_model->beforePrepareProductCollection($subjectMock, $collectionMock); } } diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Plugin/ProductLinksTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Plugin/ProductLinksTest.php index 6d4e18eb8a8a7..ea562da2f01c0 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Plugin/ProductLinksTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Plugin/ProductLinksTest.php @@ -5,7 +5,7 @@ */ namespace Magento\CatalogInventory\Test\Unit\Model\Plugin; -class ProductLinksTest extends \PHPUnit_Framework_TestCase +class ProductLinksTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogInventory\Model\Plugin\ProductLinks @@ -24,20 +24,8 @@ class ProductLinksTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->configMock = $this->getMock( - \Magento\CatalogInventory\Model\Configuration::class, - [], - [], - '', - false - ); - $this->stockHelperMock = $this->getMock( - \Magento\CatalogInventory\Helper\Stock::class, - [], - [], - '', - false - ); + $this->configMock = $this->createMock(\Magento\CatalogInventory\Model\Configuration::class); + $this->stockHelperMock = $this->createMock(\Magento\CatalogInventory\Helper\Stock::class); $this->model = new \Magento\CatalogInventory\Model\Plugin\ProductLinks( $this->configMock, @@ -63,16 +51,12 @@ public function testAfterGetProductCollectionShow($status, $callCount) private function buildMocks() { /** @var \Magento\Catalog\Model\ResourceModel\Product\Link\Product\Collection $collectionMock */ - $collectionMock = $this->getMock( - \Magento\Catalog\Model\ResourceModel\Product\Link\Product\Collection::class, - [], - [], - '', - false + $collectionMock = $this->createMock( + \Magento\Catalog\Model\ResourceModel\Product\Link\Product\Collection::class ); /** @var \Magento\Catalog\Model\Product\Link $subjectMock */ - $subjectMock = $this->getMock(\Magento\Catalog\Model\Product\Link::class, [], [], '', false); + $subjectMock = $this->createMock(\Magento\Catalog\Model\Product\Link::class); return [$collectionMock, $subjectMock]; } diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Product/CopyConstructor/CatalogInventoryTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Product/CopyConstructor/CatalogInventoryTest.php index 0267f3df0d822..75d148495d00a 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Product/CopyConstructor/CatalogInventoryTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Product/CopyConstructor/CatalogInventoryTest.php @@ -5,7 +5,7 @@ */ namespace Magento\CatalogInventory\Test\Unit\Model\Product\CopyConstructor; -class CatalogInventoryTest extends \PHPUnit_Framework_TestCase +class CatalogInventoryTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogInventory\Model\Product\CopyConstructor\CatalogInventory @@ -39,29 +39,14 @@ class CatalogInventoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->productMock = $this->getMock( - \Magento\Catalog\Model\Product::class, - ['__wakeup', 'getStore'], - [], - '', - false - ); - $store = $this->getMock( - \Magento\Store\Model\Store::class, - ['getWebsiteId', '__wakeup'], - [], - '', - false - ); + $this->productMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['__wakeup', 'getStore']); + $store = $this->createPartialMock(\Magento\Store\Model\Store::class, ['getWebsiteId', '__wakeup']); $store->expects($this->any())->method('getWebsiteId')->willReturn(0); $this->productMock->expects($this->any())->method('getStore')->willReturn($store); - $this->duplicateMock = $this->getMock( + $this->duplicateMock = $this->createPartialMock( \Magento\Catalog\Model\Product::class, - ['setStockData', '__wakeup'], - [], - '', - false + ['setStockData', '__wakeup'] ); $this->stockItemDoMock = $this->getMockForAbstractClass( diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/OptionTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/OptionTest.php index 0fdb74437e526..eb32c30ab4f86 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/OptionTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/OptionTest.php @@ -5,7 +5,7 @@ */ namespace Magento\CatalogInventory\Test\Unit\Model\Quote\Item\QuantityValidator\Initializer; -class OptionTest extends \PHPUnit_Framework_TestCase +class OptionTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogInventory\Model\Quote\Item\QuantityValidator\Initializer\Option @@ -79,25 +79,13 @@ protected function setUp() 'setBackorders', '__wakeup', ]; - $this->optionMock = $this->getMock( - \Magento\Quote\Model\Quote\Item\Option::class, - $optionMethods, - [], - '', - false - ); + $this->optionMock = $this->createPartialMock(\Magento\Quote\Model\Quote\Item\Option::class, $optionMethods); - $store = $this->getMock( - \Magento\Store\Model\Store::class, - ['getWebsiteId', '__wakeup'], - [], - '', - false - ); + $store = $this->createPartialMock(\Magento\Store\Model\Store::class, ['getWebsiteId', '__wakeup']); $store->expects($this->any())->method('getWebsiteId')->willReturn($this->websiteId); $methods = ['getQtyToAdd', '__wakeup', 'getId', 'updateQtyOption', 'setData', 'getQuoteId', 'getStore']; - $this->quoteItemMock = $this->getMock(\Magento\Quote\Model\Quote\Item::class, $methods, [], '', false); + $this->quoteItemMock = $this->createPartialMock(\Magento\Quote\Model\Quote\Item::class, $methods); $this->quoteItemMock->expects($this->any())->method('getStore')->willReturn($store); $stockItemMethods = [ @@ -109,31 +97,17 @@ protected function setUp() 'setProductName' ]; - $this->stockItemMock = $this->getMock( - \Magento\CatalogInventory\Api\Data\StockItem::class, - $stockItemMethods, - [], - '', - false - ); + $this->stockItemMock = $this->getMockBuilder(\Magento\CatalogInventory\Api\Data\StockItemInterface::class) + ->setMethods($stockItemMethods) + ->getMockForAbstractClass(); $productMethods = ['getId', '__wakeup', 'getStore']; - $this->productMock = $this->getMock(\Magento\Catalog\Model\Product::class, $productMethods, [], '', false); - $store = $this->getMock( - \Magento\Store\Model\Store::class, - ['getWebsiteId', '__wakeup'], - [], - '', - false - ); + $this->productMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, $productMethods, []); + $store = $this->createPartialMock(\Magento\Store\Model\Store::class, ['getWebsiteId', '__wakeup']); $store->expects($this->any())->method('getWebsiteId')->willReturn($this->websiteId); $this->productMock->expects($this->any())->method('getStore')->willReturn($store); - $this->qtyItemListMock = $this->getMock( - \Magento\CatalogInventory\Model\Quote\Item\QuantityValidator\QuoteItemQtyList::class, - [], - [], - '', - false + $this->qtyItemListMock = $this->createMock( + \Magento\CatalogInventory\Model\Quote\Item\QuantityValidator\QuoteItemQtyList::class ); $resultMethods = [ 'getItemIsQtyDecimal', @@ -143,7 +117,7 @@ protected function setUp() 'getItemBackorders', '__wakeup', ]; - $this->resultMock = $this->getMock(\Magento\Framework\DataObject::class, $resultMethods, [], '', false); + $this->resultMock = $this->createPartialMock(\Magento\Framework\DataObject::class, $resultMethods); $this->stockRegistry = $this->getMockForAbstractClass( \Magento\CatalogInventory\Api\StockRegistryInterface::class, diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/QtyProcessorTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/QtyProcessorTest.php index efdc9355a3793..ea36283fabe46 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/QtyProcessorTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/QtyProcessorTest.php @@ -7,7 +7,7 @@ use \Magento\CatalogInventory\Model\Quote\Item\QuantityValidator\Initializer\QtyProcessor; -class QtyProcessorTest extends \PHPUnit_Framework_TestCase +class QtyProcessorTest extends \PHPUnit\Framework\TestCase { /** * @var QtyProcessor diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/QuantityValidatorTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/QuantityValidatorTest.php index e6ef50978bf53..86a021768a6b3 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/QuantityValidatorTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/QuantityValidatorTest.php @@ -32,7 +32,7 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.TooManyFields) */ -class QuantityValidatorTest extends \PHPUnit_Framework_TestCase +class QuantityValidatorTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogInventory\Model\Quote\Item\QuantityValidator @@ -123,19 +123,13 @@ protected function setUp() { $objectManagerHelper = new ObjectManager($this); - $this->stockRegistryMock = $this->getMock( - StockRegistry::class, - [], - [], - '', - false - ); + $this->stockRegistryMock = $this->createMock(StockRegistry::class); - $this->stockStatusMock = $this->getMock(Status::class, [], [], '', false); + $this->stockStatusMock = $this->createMock(Status::class); - $this->optionInitializer = $this->getMock(Option::class, [], [], '', false); - $this->stockItemInitializer = $this->getMock(StockItem::class, [], [], '', false); - $this->stockState = $this->getMock(StockState::class, [], [], '', false); + $this->optionInitializer = $this->createMock(Option::class); + $this->stockItemInitializer = $this->createMock(StockItem::class); + $this->stockState = $this->createMock(StockState::class); $this->quantityValidator = $objectManagerHelper->getObject( QuantityValidator::class, [ @@ -145,43 +139,45 @@ protected function setUp() 'stockState' => $this->stockState ] ); - $this->observerMock = $this->getMock(Observer::class, [], [], '', false); - $this->eventMock = $this->getMock(Event::class, ['getItem'], [], '', false); - $this->quoteMock = $this->getMock( + $this->observerMock = $this->createMock(Observer::class); + $this->eventMock = $this->createPartialMock(Event::class, ['getItem']); + $this->quoteMock = $this->createPartialMock( Quote::class, - ['getHasError', 'getItemsCollection', 'removeErrorInfosByParams', 'addErrorInfo'], - [], - '', - false - ); - $this->storeMock = $this->getMock(Store::class, [], [], '', false); - $this->quoteItemMock = $this->getMock( - Item::class, - ['getProductId', 'getQuote', 'getQty', 'getProduct', 'getParentItem', - 'addErrorInfo', 'setData', 'getQtyOptions', 'getItemId'], - [], - '', - false + [ + 'getHasError', + 'getItemsCollection', + 'removeErrorInfosByParams', + 'addErrorInfo', + 'getIsSuperMode', + 'getQuote' + ] ); - $this->parentItemMock = $this->getMock( + $this->storeMock = $this->createMock(Store::class); + $this->quoteItemMock = $this->createPartialMock( Item::class, - ['getProduct', 'getId', 'getStore'], - [], - '', - false + [ + 'getProductId', + 'getQuote', + 'getQty', + 'getProduct', + 'getParentItem', + 'addErrorInfo', + 'setData', + 'getQtyOptions', + 'getItemId', + 'getHasError' + ] ); - $this->productMock = $this->getMock(Product::class, [], [], '', false); - $this->stockItemMock = $this->getMock(StockMock::class, [], [], '', false); - $this->parentStockItemMock = $this->getMock(StockMock::class, ['getStockStatus'], [], '', false); + $this->parentItemMock = $this->createPartialMock(Item::class, ['getProduct', 'getId', 'getStore']); + $this->productMock = $this->createMock(Product::class); + $this->stockItemMock = $this->createMock(StockMock::class); + $this->parentStockItemMock = $this->createPartialMock(StockMock::class, ['getStockStatus', 'getIsInStock']); - $this->typeInstanceMock = $this->getMock(Type::class, [], [], '', false); + $this->typeInstanceMock = $this->createMock(Type::class); - $this->resultMock = $this->getMock( + $this->resultMock = $this->createPartialMock( DataObject::class, - ['checkQtyIncrements', 'getMessage', 'getQuoteMessage', 'getHasError'], - [], - '', - false + ['checkQtyIncrements', 'getMessage', 'getQuoteMessage', 'getHasError', 'getQuoteMessageIndex'] ); } @@ -441,7 +437,7 @@ public function testException() $this->stockRegistryMock->expects($this->at(0)) ->method('getStockItem') ->willReturn(null); - $this->setExpectedException(LocalizedException::class); + $this->expectException(LocalizedException::class); $this->quantityValidator->validate($this->observerMock); } diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/StockItemTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/StockItemTest.php index d3ae3b4e35fce..d60a1f3e400dd 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/StockItemTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/StockItemTest.php @@ -10,7 +10,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class StockItemTest extends \PHPUnit_Framework_TestCase +class StockItemTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogInventory\Model\Quote\Item\QuantityValidator\Initializer\StockItem @@ -67,12 +67,9 @@ public function testInitializeWithSubitem() $parentItemQty = 3; $websiteId = 1; - $stockItem = $this->getMock( + $stockItem = $this->createPartialMock( \Magento\CatalogInventory\Model\Stock\Item::class, - ['checkQuoteItemQty', 'setProductName', 'setIsChildItem', 'hasIsChildItem', 'unsIsChildItem', '__wakeup'], - [], - '', - false + ['checkQuoteItemQty', 'setProductName', 'setIsChildItem', 'hasIsChildItem', 'unsIsChildItem', '__wakeup'] ); $quoteItem = $this->getMockBuilder(\Magento\Quote\Model\Quote\Item::class) ->setMethods( diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/ResourceModel/Product/StockStatusBaseSelectProcessorTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/ResourceModel/Product/StockStatusBaseSelectProcessorTest.php index 55c68911d9399..9a46dc99ee008 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/ResourceModel/Product/StockStatusBaseSelectProcessorTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/ResourceModel/Product/StockStatusBaseSelectProcessorTest.php @@ -12,7 +12,7 @@ use Magento\Framework\DB\Select; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class StockStatusBaseSelectProcessorTest extends \PHPUnit_Framework_TestCase +class StockStatusBaseSelectProcessorTest extends \PHPUnit\Framework\TestCase { /** * @var ResourceConnection|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/ResourceModel/StockTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/ResourceModel/StockTest.php deleted file mode 100644 index 3ca3c24e41bdb..0000000000000 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/ResourceModel/StockTest.php +++ /dev/null @@ -1,99 +0,0 @@ -contextMock = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock(); - $this->resourceMock = $this->getMockBuilder(ResourceConnection::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->contextMock->expects($this->once())->method('getResources')->willReturn($this->resourceMock); - - $this->stockModel = (new ObjectManager($this))->getObject( - Stock::class, - [ - 'context' => $this->contextMock - ] - ); - } - - public function testLockProductsStock() - { - $productIds = [1, 2]; - $websiteId = 1; - $itemTable = 'item_table'; - $productTable = 'product_table'; - - $connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class)->getMock(); - $this->resourceMock->method('getConnection')->will($this->returnValue($connectionMock)); - - $this->resourceMock->method('getTableName') - ->withConsecutive(['cataloginventory_stock_item'], ['catalog_product_entity']) - ->willReturnOnConsecutiveCalls($itemTable, $productTable); - - $selectMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class) - ->disableOriginalConstructor() - ->getMock(); - - $selectProductsMock = clone $selectMock; - - $selectMock->expects($this->once())->method('forUpdate')->with(true)->willReturnSelf(); - $selectMock->expects($this->once())->method('from')->with(['si' => $itemTable])->willReturnSelf(); - $selectMock->expects($this->exactly(2)) - ->method('where') - ->withConsecutive(['website_id=?', $websiteId], ['product_id IN(?)', $productIds]) - ->willReturnSelf(); - $connectionMock->expects($this->exactly(2)) - ->method('select') - ->willReturnOnConsecutiveCalls($selectMock, $selectProductsMock); - - $selectProductsMock->expects($this->once())->method('from')->with(['p' => $productTable], [])->willReturnSelf(); - $selectProductsMock->expects($this->once())->method('where') - ->with('entity_id IN (?)', $productIds) - ->willReturnSelf(); - $selectProductsMock->expects($this->once())->method('columns')->willReturnSelf(); - - $connectionMock->expects($this->once())->method('query')->with($selectMock); - $connectionMock->expects($this->once())->method('fetchAll')->with($selectProductsMock)->willReturn([]); - - $this->assertEquals([], $this->stockModel->lockProductsStock($productIds, $websiteId)); - } - - public function testLockNoProductsStock() - { - $productIds = []; - $websiteId = 1; - - $this->assertEquals([], $this->stockModel->lockProductsStock($productIds, $websiteId)); - } -} diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Spi/StockRegistryProviderTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Spi/StockRegistryProviderTest.php index b72aa8ea8bb03..d75795ce3da2a 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Spi/StockRegistryProviderTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Spi/StockRegistryProviderTest.php @@ -13,7 +13,7 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.TooManyFields) */ -class StockRegistryProviderTest extends \PHPUnit_Framework_TestCase +class StockRegistryProviderTest extends \PHPUnit\Framework\TestCase { /** @var ObjectManagerHelper */ protected $objectManagerHelper; @@ -128,30 +128,21 @@ protected function setUp() false ); - $this->stockFactory = $this->getMock( + $this->stockFactory = $this->createPartialMock( \Magento\CatalogInventory\Api\Data\StockInterfaceFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->stockFactory->expects($this->any())->method('create')->willReturn($this->stock); - $this->stockItemFactory = $this->getMock( + $this->stockItemFactory = $this->createPartialMock( \Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->stockItemFactory->expects($this->any())->method('create')->willReturn($this->stockItem); - $this->stockStatusFactory = $this->getMock( + $this->stockStatusFactory = $this->createPartialMock( \Magento\CatalogInventory\Api\Data\StockStatusInterfaceFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->stockStatusFactory->expects($this->any())->method('create')->willReturn($this->stockStatus); @@ -171,12 +162,9 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); - $this->stockCriteriaFactory = $this->getMock( + $this->stockCriteriaFactory = $this->createPartialMock( \Magento\CatalogInventory\Api\StockCriteriaInterfaceFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->stockCriteria = $this->getMockForAbstractClass( \Magento\CatalogInventory\Api\StockCriteriaInterface::class, @@ -185,12 +173,9 @@ protected function setUp() false ); - $this->stockItemCriteriaFactory = $this->getMock( + $this->stockItemCriteriaFactory = $this->createPartialMock( \Magento\CatalogInventory\Api\StockItemCriteriaInterfaceFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->stockItemCriteria = $this->getMockForAbstractClass( \Magento\CatalogInventory\Api\StockItemCriteriaInterface::class, @@ -199,12 +184,9 @@ protected function setUp() false ); - $this->stockStatusCriteriaFactory = $this->getMock( + $this->stockStatusCriteriaFactory = $this->createPartialMock( \Magento\CatalogInventory\Api\StockStatusCriteriaInterfaceFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->stockStatusCriteria = $this->getMockForAbstractClass( \Magento\CatalogInventory\Api\StockStatusCriteriaInterface::class, @@ -226,7 +208,7 @@ protected function setUp() 'stockCriteriaFactory' => $this->stockCriteriaFactory, 'stockItemCriteriaFactory' => $this->stockItemCriteriaFactory, 'stockStatusCriteriaFactory' => $this->stockStatusCriteriaFactory, - 'stockRegistryStorage' => $this->getMock(\Magento\CatalogInventory\Model\StockRegistryStorage::class) + 'stockRegistryStorage' => $this->createMock(\Magento\CatalogInventory\Model\StockRegistryStorage::class) ] ); } @@ -240,12 +222,9 @@ public function testGetStock() { $this->stockCriteriaFactory->expects($this->once())->method('create')->willReturn($this->stockCriteria); $this->stockCriteria->expects($this->once())->method('setScopeFilter')->willReturn(null); - $stockCollection = $this->getMock( + $stockCollection = $this->createPartialMock( \Magento\CatalogInventory\Model\ResourceModel\Stock\Collection::class, - ['getFirstItem', '__wakeup', 'getItems'], - [], - '', - false + ['getFirstItem', '__wakeup', 'getItems'] ); $stockCollection->expects($this->once())->method('getItems')->willReturn([$this->stock]); $this->stockRepository->expects($this->once())->method('getList')->willReturn($stockCollection); @@ -257,12 +236,9 @@ public function testGetStockItem() { $this->stockItemCriteriaFactory->expects($this->once())->method('create')->willReturn($this->stockItemCriteria); $this->stockItemCriteria->expects($this->once())->method('setProductsFilter')->willReturn(null); - $stockItemCollection = $this->getMock( + $stockItemCollection = $this->createPartialMock( \Magento\CatalogInventory\Model\ResourceModel\Stock\Item\Collection::class, - ['getFirstItem', '__wakeup', 'getItems'], - [], - '', - false + ['getFirstItem', '__wakeup', 'getItems'] ); $stockItemCollection->expects($this->once())->method('getItems')->willReturn([$this->stockItem]); $this->stockItemRepository->expects($this->once())->method('getList')->willReturn($stockItemCollection); @@ -280,12 +256,9 @@ public function testGetStockStatus() ->willReturn($this->stockStatusCriteria); $this->stockStatusCriteria->expects($this->once())->method('setScopeFilter')->willReturn(null); $this->stockStatusCriteria->expects($this->once())->method('setProductsFilter')->willReturn(null); - $stockStatusCollection = $this->getMock( + $stockStatusCollection = $this->createPartialMock( \Magento\CatalogInventory\Model\ResourceModel\Stock\Status\Collection::class, - ['getFirstItem', '__wakeup', 'getItems'], - [], - '', - false + ['getFirstItem', '__wakeup', 'getItems'] ); $stockStatusCollection->expects($this->once())->method('getItems')->willReturn([$this->stockStatus]); $this->stockStatusRepository->expects($this->once())->method('getList')->willReturn($stockStatusCollection); diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Spi/StockStateProviderTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Spi/StockStateProviderTest.php index 59a360d0d0711..5c75249b7cbf8 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Spi/StockStateProviderTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Spi/StockStateProviderTest.php @@ -13,7 +13,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class StockStateProviderTest extends \PHPUnit_Framework_TestCase +class StockStateProviderTest extends \PHPUnit\Framework\TestCase { /** @var ObjectManagerHelper */ protected $objectManagerHelper; @@ -109,13 +109,7 @@ protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->mathDivision = $this->getMock( - \Magento\Framework\Math\Division::class, - ['getExactDivision'], - [], - '', - false - ); + $this->mathDivision = $this->createPartialMock(\Magento\Framework\Math\Division::class, ['getExactDivision']); $this->localeFormat = $this->getMockForAbstractClass( \Magento\Framework\Locale\FormatInterface::class, @@ -126,17 +120,14 @@ protected function setUp() ->willReturn($this->qty); $this->object = $this->objectManagerHelper->getObject(\Magento\Framework\DataObject::class); - $this->objectFactory = $this->getMock(\Magento\Framework\DataObject\Factory::class, ['create'], [], '', false); + $this->objectFactory = $this->createPartialMock(\Magento\Framework\DataObject\Factory::class, ['create']); $this->objectFactory->expects($this->any())->method('create')->willReturn($this->object); - $this->product = $this->getMock( + $this->product = $this->createPartialMock( \Magento\Catalog\Model\Product::class, - ['load', 'isComposite', '__wakeup', 'isSaleable'], - [], - '', - false + ['load', 'isComposite', '__wakeup', 'isSaleable'] ); - $this->productFactory = $this->getMock(\Magento\Catalog\Model\ProductFactory::class, ['create'], [], '', false); + $this->productFactory = $this->createPartialMock(\Magento\Catalog\Model\ProductFactory::class, ['create']); $this->productFactory->expects($this->any())->method('create')->willReturn($this->product); $this->stockStateProvider = $this->objectManagerHelper->getObject( diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/ItemTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/ItemTest.php index 65a7f5fc6c40e..bbc7823b13e01 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/ItemTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/ItemTest.php @@ -12,7 +12,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ItemTest extends \PHPUnit_Framework_TestCase +class ItemTest extends \PHPUnit\Framework\TestCase { /** @var ObjectManagerHelper */ protected $objectManagerHelper; @@ -84,26 +84,14 @@ protected function setUp() ->setMethods(['dispatch']) ->getMock(); - $this->context = $this->getMock( - \Magento\Framework\Model\Context::class, - ['getEventDispatcher'], - [], - '', - false - ); + $this->context = $this->createPartialMock(\Magento\Framework\Model\Context::class, ['getEventDispatcher']); $this->context->expects($this->any())->method('getEventDispatcher')->willReturn($this->eventDispatcher); - $this->registry = $this->getMock( - \Magento\Framework\Registry::class, - [], - [], - '', - false - ); + $this->registry = $this->createMock(\Magento\Framework\Registry::class); - $this->customerSession = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); + $this->customerSession = $this->createMock(\Magento\Customer\Model\Session::class); - $store = $this->getMock(\Magento\Store\Model\Store::class, ['getId', '__wakeup'], [], '', false); + $store = $this->createPartialMock(\Magento\Store\Model\Store::class, ['getId', '__wakeup']); $store->expects($this->any())->method('getId')->willReturn($this->storeId); $this->storeManager = $this->getMockForAbstractClass( \Magento\Store\Model\StoreManagerInterface::class, @@ -111,32 +99,16 @@ protected function setUp() ); $this->storeManager->expects($this->any())->method('getStore')->willReturn($store); - $this->stockConfiguration = $this->getMock( - \Magento\CatalogInventory\Api\StockConfigurationInterface::class, - [], - [], - '', - false - ); + $this->stockConfiguration = $this->createMock(\Magento\CatalogInventory\Api\StockConfigurationInterface::class); $this->stockItemRepository = $this->getMockForAbstractClass( \Magento\CatalogInventory\Api\StockItemRepositoryInterface::class ); - $this->resource = $this->getMock( - \Magento\CatalogInventory\Model\ResourceModel\Stock\Item::class, - [], - [], - '', - false - ); + $this->resource = $this->createMock(\Magento\CatalogInventory\Model\ResourceModel\Stock\Item::class); - $this->resourceCollection = $this->getMock( - \Magento\CatalogInventory\Model\ResourceModel\Stock\Item\Collection::class, - [], - [], - '', - false + $this->resourceCollection = $this->createMock( + \Magento\CatalogInventory\Model\ResourceModel\Stock\Item\Collection::class ); $this->objectManagerHelper = new ObjectManagerHelper($this); @@ -184,20 +156,14 @@ protected function setDataArrayValue($key, $value) public function testSetProduct() { - $product = $this->getMock( - \Magento\Catalog\Model\Product::class, - [ + $product = $this->createPartialMock(\Magento\Catalog\Model\Product::class, [ 'getId', 'getName', 'getStoreId', 'getTypeId', 'dataHasChangedFor', 'getIsChangedWebsites', - '__wakeup'], - [], - '', - false - ); + '__wakeup']); $productId = 2; $productName = 'Some Name'; $storeId = 3; diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/StockItemRepositoryTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/StockItemRepositoryTest.php index 5a667d8760d10..293874bb32b9f 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/StockItemRepositoryTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/StockItemRepositoryTest.php @@ -5,17 +5,16 @@ */ namespace Magento\CatalogInventory\Test\Unit\Model\Stock; -use Magento\Catalog\Model\ResourceModel\Product\Collection; use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory; -use Magento\CatalogInventory\Model\Stock\StockItemRepository; use Magento\CatalogInventory\Api\Data as InventoryApiData; +use Magento\CatalogInventory\Model\Stock\StockItemRepository; use Magento\CatalogInventory\Model\StockRegistryStorage; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class StockItemRepositoryTest extends \PHPUnit_Framework_TestCase +class StockItemRepositoryTest extends \PHPUnit\Framework\TestCase { /** * @var StockItemRepository @@ -166,20 +165,11 @@ protected function setUp() $this->localeDateMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->indexProcessorMock = $this->getMock( + $this->indexProcessorMock = $this->createPartialMock( \Magento\CatalogInventory\Model\Indexer\Stock\Processor::class, - ['reindexRow'], - [], - '', - false - ); - $this->dateTime = $this->getMock( - \Magento\Framework\Stdlib\DateTime\DateTime::class, - ['gmtDate'], - [], - '', - false + ['reindexRow'] ); + $this->dateTime = $this->createPartialMock(\Magento\Framework\Stdlib\DateTime\DateTime::class, ['gmtDate']); $this->stockRegistryStorage = $this->getMockBuilder(StockRegistryStorage::class) ->disableOriginalConstructor() ->getMock(); @@ -314,7 +304,6 @@ public function testSave() ->method('save') ->with($this->stockItemMock) ->willReturnSelf(); - $this->indexProcessorMock->expects($this->once())->method('reindexRow')->with($productId); $this->assertEquals($this->stockItemMock, $this->model->save($this->stockItemMock)); } diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/StockRepositoryTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/StockRepositoryTest.php index 3ace070d9c863..e10fe1288b827 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/StockRepositoryTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/StockRepositoryTest.php @@ -14,7 +14,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class StockRepositoryTest extends \PHPUnit_Framework_TestCase +class StockRepositoryTest extends \PHPUnit\Framework\TestCase { /** * @var StockRepository diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/StockStatusRepositoryTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/StockStatusRepositoryTest.php index fa7c77eb9fc1c..b8616e37a31c8 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/StockStatusRepositoryTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/StockStatusRepositoryTest.php @@ -15,7 +15,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class StockStatusRepositoryTest extends \PHPUnit_Framework_TestCase +class StockStatusRepositoryTest extends \PHPUnit\Framework\TestCase { /** * @var StockStatusRepository diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/StockRegistryTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/StockRegistryTest.php index 61ea20eedf193..c04bd1e9e4402 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/StockRegistryTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/StockRegistryTest.php @@ -8,7 +8,7 @@ /** * Class StockRegistryTest */ -class StockRegistryTest extends \PHPUnit_Framework_TestCase +class StockRegistryTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogInventory\Model\StockRegistry diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/StockTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/StockTest.php index b1eca1fdc7549..c3abad50ef9f4 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/StockTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/StockTest.php @@ -8,7 +8,7 @@ /** * Class StockTest */ -class StockTest extends \PHPUnit_Framework_TestCase +class StockTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\Model\Context diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Observer/AddInventoryDataObserverTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Observer/AddInventoryDataObserverTest.php index 5694ffddd126f..5f24f6e9728a9 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Observer/AddInventoryDataObserverTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Observer/AddInventoryDataObserverTest.php @@ -7,7 +7,7 @@ use Magento\CatalogInventory\Observer\AddInventoryDataObserver; -class AddInventoryDataObserverTest extends \PHPUnit_Framework_TestCase +class AddInventoryDataObserverTest extends \PHPUnit\Framework\TestCase { /** * @var AddInventoryDataObserver @@ -31,7 +31,7 @@ class AddInventoryDataObserverTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->stockHelper = $this->getMock(\Magento\CatalogInventory\Helper\Stock::class, [], [], '', false); + $this->stockHelper = $this->createMock(\Magento\CatalogInventory\Helper\Stock::class); $this->event = $this->getMockBuilder(\Magento\Framework\Event::class) ->disableOriginalConstructor() diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Observer/CheckoutAllSubmitAfterObserverTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Observer/CheckoutAllSubmitAfterObserverTest.php index a8a188e175aa5..80470ca2a8b48 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Observer/CheckoutAllSubmitAfterObserverTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Observer/CheckoutAllSubmitAfterObserverTest.php @@ -7,7 +7,7 @@ use Magento\CatalogInventory\Observer\CheckoutAllSubmitAfterObserver; -class CheckoutAllSubmitAfterObserverTest extends \PHPUnit_Framework_TestCase +class CheckoutAllSubmitAfterObserverTest extends \PHPUnit\Framework\TestCase { /** * @var CheckoutAllSubmitAfterObserver @@ -36,20 +36,12 @@ class CheckoutAllSubmitAfterObserverTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->subtractQuoteInventoryObserver = $this->getMock( - \Magento\CatalogInventory\Observer\SubtractQuoteInventoryObserver::class, - [], - [], - '', - false + $this->subtractQuoteInventoryObserver = $this->createMock( + \Magento\CatalogInventory\Observer\SubtractQuoteInventoryObserver::class ); - $this->reindexQuoteInventoryObserver = $this->getMock( - \Magento\CatalogInventory\Observer\ReindexQuoteInventoryObserver::class, - [], - [], - '', - false + $this->reindexQuoteInventoryObserver = $this->createMock( + \Magento\CatalogInventory\Observer\ReindexQuoteInventoryObserver::class ); $this->event = $this->getMockBuilder(\Magento\Framework\Event::class) @@ -77,7 +69,7 @@ protected function setUp() public function testCheckoutAllSubmitAfter() { - $quote = $this->getMock(\Magento\Quote\Model\Quote::class, ['getInventoryProcessed'], [], '', false); + $quote = $this->createPartialMock(\Magento\Quote\Model\Quote::class, ['getInventoryProcessed']); $quote->expects($this->once()) ->method('getInventoryProcessed') ->will($this->returnValue(false)); diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Observer/UpdateItemsStockUponConfigChangeObserverTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Observer/UpdateItemsStockUponConfigChangeObserverTest.php index d3febc6e26552..70a179b484379 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Observer/UpdateItemsStockUponConfigChangeObserverTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Observer/UpdateItemsStockUponConfigChangeObserverTest.php @@ -7,7 +7,7 @@ use Magento\CatalogInventory\Observer\UpdateItemsStockUponConfigChangeObserver; -class UpdateItemsStockUponConfigChangeObserverTest extends \PHPUnit_Framework_TestCase +class UpdateItemsStockUponConfigChangeObserverTest extends \PHPUnit\Framework\TestCase { /** * @var UpdateItemsStockUponConfigChangeObserver @@ -31,13 +31,7 @@ class UpdateItemsStockUponConfigChangeObserverTest extends \PHPUnit_Framework_Te protected function setUp() { - $this->resourceStock = $this->getMock( - \Magento\CatalogInventory\Model\ResourceModel\Stock::class, - [], - [], - '', - false - ); + $this->resourceStock = $this->createMock(\Magento\CatalogInventory\Model\ResourceModel\Stock::class); $this->event = $this->getMockBuilder(\Magento\Framework\Event::class) ->disableOriginalConstructor() diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Ui/Component/Product/Form/Element/UseConfigSettingsTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Ui/Component/Product/Form/Element/UseConfigSettingsTest.php index 258f56c2e462e..db183ae5c0da0 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Ui/Component/Product/Form/Element/UseConfigSettingsTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Ui/Component/Product/Form/Element/UseConfigSettingsTest.php @@ -11,7 +11,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; use Magento\Framework\View\Element\UiComponent\ContextInterface; -class UseConfigSettingsTest extends \PHPUnit_Framework_TestCase +class UseConfigSettingsTest extends \PHPUnit\Framework\TestCase { /** * @var ObjectManagerHelper @@ -41,8 +41,8 @@ class UseConfigSettingsTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->contextMock = $this->getMock(\Magento\Framework\View\Element\UiComponent\ContextInterface::class); - $this->serializerMock = $this->getMock(Json::class); + $this->contextMock = $this->createMock(\Magento\Framework\View\Element\UiComponent\ContextInterface::class); + $this->serializerMock = $this->createMock(Json::class); $this->jsonValidatorMock = $this->getMockBuilder(\Magento\Framework\Serialize\JsonValidator::class) ->disableOriginalConstructor() ->getMock(); @@ -58,14 +58,7 @@ protected function setUp() public function testPrepare() { - $processorMock = $this->getMock( - \Magento\Framework\View\Element\UiComponent\Processor::class, - [], - [], - '', - false, - false - ); + $processorMock = $this->createMock(\Magento\Framework\View\Element\UiComponent\Processor::class); $processorMock->expects($this->atLeastOnce())->method('register'); $this->contextMock->expects($this->atLeastOnce())->method('getProcessor')->willReturn($processorMock); $config = ['valueFromConfig' => 123]; @@ -87,18 +80,11 @@ public function testPrepareSource( $serializedCalledNum = 0, $isValidCalledNum = 0 ) { - $processorMock = $this->getMock( - \Magento\Framework\View\Element\UiComponent\Processor::class, - [], - [], - '', - false, - false - ); + $processorMock = $this->createMock(\Magento\Framework\View\Element\UiComponent\Processor::class); $processorMock->expects($this->atLeastOnce())->method('register'); $this->contextMock->expects($this->atLeastOnce())->method('getProcessor')->willReturn($processorMock); /** @var ValueSourceInterface|\PHPUnit_Framework_MockObject_MockObject $source */ - $source = $this->getMock(ValueSourceInterface::class); + $source = $this->createMock(ValueSourceInterface::class); $source->expects($this->once()) ->method('getValue') ->with($expectedResult['keyInConfiguration']) diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AdvancedInventoryTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AdvancedInventoryTest.php index b22d84d1fc1dd..15a16ef09378f 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AdvancedInventoryTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AdvancedInventoryTest.php @@ -65,7 +65,7 @@ protected function setUp() $this->productMock->expects($this->any()) ->method('getStore') ->willReturn($this->storeMock); - $this->serializerMock = $this->getMock(Json::class); + $this->serializerMock = $this->createMock(Json::class); $this->jsonValidatorMock = $this->getMockBuilder(\Magento\Framework\Serialize\JsonValidator::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/CatalogInventory/etc/di.xml b/app/code/Magento/CatalogInventory/etc/di.xml index e62470b3ae0fb..04935b11ce02b 100644 --- a/app/code/Magento/CatalogInventory/etc/di.xml +++ b/app/code/Magento/CatalogInventory/etc/di.xml @@ -60,6 +60,13 @@ + + + + Magento\CatalogInventory\Model\Indexer\Stock\Processor::INDEXER_ID + + + @@ -71,9 +78,6 @@ - - - Magento\CatalogInventory\Model\Indexer\Stock\Processor diff --git a/app/code/Magento/CatalogRule/Api/CatalogRuleRepositoryInterface.php b/app/code/Magento/CatalogRule/Api/CatalogRuleRepositoryInterface.php index 7b903dee29c62..9a2b702e8c02c 100644 --- a/app/code/Magento/CatalogRule/Api/CatalogRuleRepositoryInterface.php +++ b/app/code/Magento/CatalogRule/Api/CatalogRuleRepositoryInterface.php @@ -8,6 +8,7 @@ /** * Interface CatalogRuleRepositoryInterface * @api + * @since 100.1.0 */ interface CatalogRuleRepositoryInterface { @@ -15,6 +16,7 @@ interface CatalogRuleRepositoryInterface * @param \Magento\CatalogRule\Api\Data\RuleInterface $rule * @return \Magento\CatalogRule\Api\Data\RuleInterface * @throws \Magento\Framework\Exception\CouldNotSaveException + * @since 100.1.0 */ public function save(\Magento\CatalogRule\Api\Data\RuleInterface $rule); @@ -22,6 +24,7 @@ public function save(\Magento\CatalogRule\Api\Data\RuleInterface $rule); * @param int $ruleId * @return \Magento\CatalogRule\Api\Data\RuleInterface * @throws \Magento\Framework\Exception\NoSuchEntityException + * @since 100.1.0 */ public function get($ruleId); @@ -29,6 +32,7 @@ public function get($ruleId); * @param \Magento\CatalogRule\Api\Data\RuleInterface $rule * @return bool * @throws \Magento\Framework\Exception\CouldNotDeleteException + * @since 100.1.0 */ public function delete(\Magento\CatalogRule\Api\Data\RuleInterface $rule); @@ -36,6 +40,7 @@ public function delete(\Magento\CatalogRule\Api\Data\RuleInterface $rule); * @param int $ruleId * @return bool * @throws \Magento\Framework\Exception\CouldNotDeleteException + * @since 100.1.0 */ public function deleteById($ruleId); } diff --git a/app/code/Magento/CatalogRule/Api/Data/ConditionInterface.php b/app/code/Magento/CatalogRule/Api/Data/ConditionInterface.php index 36d822aec32b5..bf476a3049914 100644 --- a/app/code/Magento/CatalogRule/Api/Data/ConditionInterface.php +++ b/app/code/Magento/CatalogRule/Api/Data/ConditionInterface.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.1.0 */ interface ConditionInterface extends \Magento\Framework\Api\CustomAttributesDataInterface { @@ -31,78 +32,92 @@ interface ConditionInterface extends \Magento\Framework\Api\CustomAttributesData /** * @param string $type * @return $this + * @since 100.1.0 */ public function setType($type); /** * @return string + * @since 100.1.0 */ public function getType(); /** * @param string $attribute * @return $this + * @since 100.1.0 */ public function setAttribute($attribute); /** * @return string + * @since 100.1.0 */ public function getAttribute(); /** * @param string $operator * @return $this + * @since 100.1.0 */ public function setOperator($operator); /** * @return string + * @since 100.1.0 */ public function getOperator(); /** * @param string $value * @return $this + * @since 100.1.0 */ public function setValue($value); /** * @return string + * @since 100.1.0 */ public function getValue(); /** * @param bool $isValueParsed * @return $this + * @since 100.1.0 */ public function setIsValueParsed($isValueParsed); /** * @return bool|null * @SuppressWarnings(PHPMD.BooleanGetMethodName) + * @since 100.1.0 */ public function getIsValueParsed(); /** * @param string $aggregator * @return $this + * @since 100.1.0 */ public function setAggregator($aggregator); /** * @return string + * @since 100.1.0 */ public function getAggregator(); /** * @param \Magento\CatalogRule\Api\Data\ConditionInterface[] $conditions * @return $this + * @since 100.1.0 */ public function setConditions($conditions); /** * @return \Magento\CatalogRule\Api\Data\ConditionInterface[]|null + * @since 100.1.0 */ public function getConditions(); @@ -110,6 +125,7 @@ public function getConditions(); * Retrieve existing extension attributes object or create a new one. * * @return \Magento\CatalogRule\Api\Data\ConditionExtensionInterface|null + * @since 100.1.0 */ public function getExtensionAttributes(); @@ -118,6 +134,7 @@ public function getExtensionAttributes(); * * @param \Magento\CatalogRule\Api\Data\ConditionExtensionInterface $extensionAttributes * @return $this + * @since 100.1.0 */ public function setExtensionAttributes( \Magento\CatalogRule\Api\Data\ConditionExtensionInterface $extensionAttributes diff --git a/app/code/Magento/CatalogRule/Api/Data/RuleInterface.php b/app/code/Magento/CatalogRule/Api/Data/RuleInterface.php index aca2254e728ed..723cce82b1cac 100644 --- a/app/code/Magento/CatalogRule/Api/Data/RuleInterface.php +++ b/app/code/Magento/CatalogRule/Api/Data/RuleInterface.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.1.0 */ interface RuleInterface extends \Magento\Framework\Api\CustomAttributesDataInterface { @@ -35,12 +36,14 @@ interface RuleInterface extends \Magento\Framework\Api\CustomAttributesDataInter * Returns rule id field * * @return int|null + * @since 100.1.0 */ public function getRuleId(); /** * @param int $ruleId * @return $this + * @since 100.1.0 */ public function setRuleId($ruleId); @@ -48,12 +51,14 @@ public function setRuleId($ruleId); * Returns rule name * * @return string + * @since 100.1.0 */ public function getName(); /** * @param string $name * @return $this + * @since 100.1.0 */ public function setName($name); @@ -61,12 +66,14 @@ public function setName($name); * Returns rule description * * @return string|null + * @since 100.1.0 */ public function getDescription(); /** * @param string $description * @return $this + * @since 100.1.0 */ public function setDescription($description); @@ -74,12 +81,14 @@ public function setDescription($description); * Returns rule activity flag * * @return int + * @since 100.1.0 */ public function getIsActive(); /** * @param int $isActive * @return $this + * @since 100.1.0 */ public function setIsActive($isActive); @@ -87,12 +96,14 @@ public function setIsActive($isActive); * Returns rule condition * * @return \Magento\CatalogRule\Api\Data\ConditionInterface|null + * @since 100.1.0 */ public function getRuleCondition(); /** * @param \Magento\CatalogRule\Api\Data\ConditionInterface $condition * @return $this + * @since 100.1.0 */ public function setRuleCondition($condition); @@ -100,12 +111,14 @@ public function setRuleCondition($condition); * Returns stop rule processing flag * * @return int|null + * @since 100.1.0 */ public function getStopRulesProcessing(); /** * @param int $isStopProcessing * @return $this + * @since 100.1.0 */ public function setStopRulesProcessing($isStopProcessing); @@ -113,12 +126,14 @@ public function setStopRulesProcessing($isStopProcessing); * Returns rule sort order * * @return int|null + * @since 100.1.0 */ public function getSortOrder(); /** * @param int $sortOrder * @return $this + * @since 100.1.0 */ public function setSortOrder($sortOrder); @@ -126,12 +141,14 @@ public function setSortOrder($sortOrder); * Returns rule simple action * * @return string + * @since 100.1.0 */ public function getSimpleAction(); /** * @param string $action * @return $this + * @since 100.1.0 */ public function setSimpleAction($action); @@ -139,12 +156,14 @@ public function setSimpleAction($action); * Returns discount amount * * @return float + * @since 100.1.0 */ public function getDiscountAmount(); /** * @param float $amount * @return $this + * @since 100.1.0 */ public function setDiscountAmount($amount); @@ -152,6 +171,7 @@ public function setDiscountAmount($amount); * Retrieve existing extension attributes object or create a new one. * * @return \Magento\CatalogRule\Api\Data\RuleExtensionInterface|null + * @since 100.1.0 */ public function getExtensionAttributes(); @@ -160,6 +180,7 @@ public function getExtensionAttributes(); * * @param \Magento\CatalogRule\Api\Data\RuleExtensionInterface $extensionAttributes * @return $this + * @since 100.1.0 */ public function setExtensionAttributes(\Magento\CatalogRule\Api\Data\RuleExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog.php b/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog.php index ba0ac0f53a430..71563c62d79e1 100644 --- a/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog.php +++ b/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class Catalog extends \Magento\Backend\Block\Widget\Grid\Container { diff --git a/app/code/Magento/CatalogRule/Model/Indexer/AbstractIndexer.php b/app/code/Magento/CatalogRule/Model/Indexer/AbstractIndexer.php index b66c5179bd66b..5d93e6f216866 100644 --- a/app/code/Magento/CatalogRule/Model/Indexer/AbstractIndexer.php +++ b/app/code/Magento/CatalogRule/Model/Indexer/AbstractIndexer.php @@ -139,7 +139,7 @@ abstract protected function doExecuteRow($id); /** * @return \Magento\Framework\App\CacheInterface|mixed * - * @deprecated + * @deprecated 100.0.7 */ private function getCacheManager() { @@ -155,7 +155,7 @@ private function getCacheManager() * Get cache context * * @return \Magento\Framework\Indexer\CacheContext - * @deprecated + * @deprecated 100.0.7 */ protected function getCacheContext() { diff --git a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php index 6c9a4ecdce1cb..34b4bff5a060e 100644 --- a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php +++ b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php @@ -17,6 +17,7 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) * @SuppressWarnings(PHPMD.TooManyFields) + * @since 100.0.2 */ class IndexBuilder { @@ -24,7 +25,8 @@ class IndexBuilder /** * @var \Magento\Framework\EntityManager\MetadataPool - * @deprecated + * @deprecated 100.2.0 + * @since 100.1.0 */ protected $metadataPool; @@ -34,7 +36,7 @@ class IndexBuilder * This array contain list of CatalogRuleGroupWebsite table columns * * @var array - * @deprecated + * @deprecated 100.2.0 */ protected $_catalogRuleGroupWebsiteColumnsList = ['rule_id', 'customer_group_id', 'website_id']; @@ -417,7 +419,7 @@ protected function getTable($tableName) /** * @param Rule $rule * @return $this - * @deprecated + * @deprecated 100.2.0 * @see \Magento\CatalogRule\Model\Indexer\ReindexRuleProduct::execute */ protected function updateRuleProductData(Rule $rule) @@ -443,7 +445,7 @@ protected function updateRuleProductData(Rule $rule) * @param Product|null $product * @throws \Exception * @return $this - * @deprecated + * @deprecated 100.2.0 * @see \Magento\CatalogRule\Model\Indexer\ReindexRuleProductPrice::execute * @see \Magento\CatalogRule\Model\Indexer\ReindexRuleGroupWebsite::execute */ @@ -458,7 +460,7 @@ protected function applyAllRules(Product $product = null) * Update CatalogRuleGroupWebsite data * * @return $this - * @deprecated + * @deprecated 100.2.0 * @see \Magento\CatalogRule\Model\Indexer\ReindexRuleGroupWebsite::execute */ protected function updateCatalogRuleGroupWebsiteData() @@ -482,7 +484,7 @@ protected function deleteOldData() * @param array $ruleData * @param null $productData * @return float - * @deprecated + * @deprecated 100.2.0 * @see \Magento\CatalogRule\Model\Indexer\ProductPriceCalculator::calculate */ protected function calcRuleProductPrice($ruleData, $productData = null) @@ -495,7 +497,7 @@ protected function calcRuleProductPrice($ruleData, $productData = null) * @param Product|null $product * @return \Zend_Db_Statement_Interface * @throws \Magento\Framework\Exception\LocalizedException - * @deprecated + * @deprecated 100.2.0 * @see \Magento\CatalogRule\Model\Indexer\RuleProductsSelectBuilder::build */ protected function getRuleProductsStmt($websiteId, Product $product = null) @@ -507,7 +509,7 @@ protected function getRuleProductsStmt($websiteId, Product $product = null) * @param array $arrData * @return $this * @throws \Exception - * @deprecated + * @deprecated 100.2.0 * @see \Magento\CatalogRule\Model\Indexer\RuleProductPricesPersistor::execute */ protected function saveRuleProductPrices($arrData) diff --git a/app/code/Magento/CatalogRule/Model/ResourceModel/Rule.php b/app/code/Magento/CatalogRule/Model/ResourceModel/Rule.php index 4d37625533f3c..662cdede84ede 100644 --- a/app/code/Magento/CatalogRule/Model/ResourceModel/Rule.php +++ b/app/code/Magento/CatalogRule/Model/ResourceModel/Rule.php @@ -257,7 +257,7 @@ public function delete(AbstractModel $object) /** * @return array - * @deprecated + * @deprecated 100.1.0 */ private function getAssociatedEntitiesMap() { @@ -271,7 +271,7 @@ private function getAssociatedEntitiesMap() /** * @return \Magento\Framework\EntityManager\EntityManager - * @deprecated + * @deprecated 100.1.0 */ private function getEntityManager() { diff --git a/app/code/Magento/CatalogRule/Model/ResourceModel/Rule/Collection.php b/app/code/Magento/CatalogRule/Model/ResourceModel/Rule/Collection.php index 020e14cf7ab9c..fdc039067cc3d 100644 --- a/app/code/Magento/CatalogRule/Model/ResourceModel/Rule/Collection.php +++ b/app/code/Magento/CatalogRule/Model/ResourceModel/Rule/Collection.php @@ -142,7 +142,7 @@ public function addCustomerGroupFilter($customerGroupId) /** * @return array - * @deprecated + * @deprecated 100.1.0 */ private function getAssociatedEntitiesMap() { diff --git a/app/code/Magento/CatalogRule/Model/Rule.php b/app/code/Magento/CatalogRule/Model/Rule.php index c3cf0a2aed49c..715b7a2f3903b 100644 --- a/app/code/Magento/CatalogRule/Model/Rule.php +++ b/app/code/Magento/CatalogRule/Model/Rule.php @@ -14,8 +14,6 @@ /** * Catalog Rule data model * - * @method \Magento\CatalogRule\Model\ResourceModel\Rule _getResource() - * @method \Magento\CatalogRule\Model\ResourceModel\Rule getResource() * @method \Magento\CatalogRule\Model\Rule setFromDate(string $value) * @method \Magento\CatalogRule\Model\Rule setToDate(string $value) * @method \Magento\CatalogRule\Model\Rule setCustomerGroupIds(string $value) @@ -787,7 +785,7 @@ public function setExtensionAttributes(\Magento\CatalogRule\Api\Data\RuleExtensi /** * @return Data\Condition\Converter - * @deprecated + * @deprecated 100.1.0 */ private function getRuleConditionConverter() { diff --git a/app/code/Magento/CatalogRule/Model/Rule/Action/Collection.php b/app/code/Magento/CatalogRule/Model/Rule/Action/Collection.php index 9237ba54d3efc..df53b68a8a694 100644 --- a/app/code/Magento/CatalogRule/Model/Rule/Action/Collection.php +++ b/app/code/Magento/CatalogRule/Model/Rule/Action/Collection.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Collection extends \Magento\Rule\Model\Action\Collection { diff --git a/app/code/Magento/CatalogRule/Model/Rule/Job.php b/app/code/Magento/CatalogRule/Model/Rule/Job.php index ecc7a0f6db0dd..63ff98d4ca5b7 100644 --- a/app/code/Magento/CatalogRule/Model/Rule/Job.php +++ b/app/code/Magento/CatalogRule/Model/Rule/Job.php @@ -26,6 +26,7 @@ /** * @api + * @since 100.0.2 */ class Job extends \Magento\Framework\DataObject { diff --git a/app/code/Magento/CatalogRule/Model/Rule/Product/Price.php b/app/code/Magento/CatalogRule/Model/Rule/Product/Price.php index 07afca0e6dbac..2d55189017be3 100644 --- a/app/code/Magento/CatalogRule/Model/Rule/Product/Price.php +++ b/app/code/Magento/CatalogRule/Model/Rule/Product/Price.php @@ -7,8 +7,6 @@ /** * Catalog Rule Product Aggregated Price per date Model * - * @method \Magento\CatalogRule\Model\ResourceModel\Rule\Product\Price _getResource() - * @method \Magento\CatalogRule\Model\ResourceModel\Rule\Product\Price getResource() * @method string getRuleDate() * @method \Magento\CatalogRule\Model\Rule\Product\Price setRuleDate(string $value) * @method int getCustomerGroupId() diff --git a/app/code/Magento/CatalogRule/Observer/PrepareCatalogProductCollectionPricesObserver.php b/app/code/Magento/CatalogRule/Observer/PrepareCatalogProductCollectionPricesObserver.php index 0444bbdcece8f..75a208e87100b 100644 --- a/app/code/Magento/CatalogRule/Observer/PrepareCatalogProductCollectionPricesObserver.php +++ b/app/code/Magento/CatalogRule/Observer/PrepareCatalogProductCollectionPricesObserver.php @@ -43,7 +43,9 @@ class PrepareCatalogProductCollectionPricesObserver implements ObserverInterface */ protected $resourceRuleFactory; - /** @var RulePricesStorage */ + /** + * @var \Magento\CatalogRule\Observer\RulePricesStorage + */ protected $rulePricesStorage; /** diff --git a/app/code/Magento/CatalogRule/Observer/ProcessAdminFinalPriceObserver.php b/app/code/Magento/CatalogRule/Observer/ProcessAdminFinalPriceObserver.php index 6c65f9eea0178..2dce2cb2f5b1c 100644 --- a/app/code/Magento/CatalogRule/Observer/ProcessAdminFinalPriceObserver.php +++ b/app/code/Magento/CatalogRule/Observer/ProcessAdminFinalPriceObserver.php @@ -36,7 +36,9 @@ class ProcessAdminFinalPriceObserver implements ObserverInterface */ protected $resourceRuleFactory; - /** @var RulePricesStorage */ + /** + * @var \Magento\CatalogRule\Observer\RulePricesStorage + */ protected $rulePricesStorage; /** diff --git a/app/code/Magento/CatalogRule/Observer/ProcessFrontFinalPriceObserver.php b/app/code/Magento/CatalogRule/Observer/ProcessFrontFinalPriceObserver.php index 4e7bffb624660..2d4042f691502 100644 --- a/app/code/Magento/CatalogRule/Observer/ProcessFrontFinalPriceObserver.php +++ b/app/code/Magento/CatalogRule/Observer/ProcessFrontFinalPriceObserver.php @@ -39,7 +39,9 @@ class ProcessFrontFinalPriceObserver implements ObserverInterface */ protected $resourceRuleFactory; - /** @var RulePricesStorage */ + /** + * @var \Magento\CatalogRule\Observer\RulePricesStorage + */ protected $rulePricesStorage; /** diff --git a/app/code/Magento/CatalogRule/Pricing/Price/CatalogRulePrice.php b/app/code/Magento/CatalogRule/Pricing/Price/CatalogRulePrice.php index 07b950bc0f024..a45a548264a4c 100644 --- a/app/code/Magento/CatalogRule/Pricing/Price/CatalogRulePrice.php +++ b/app/code/Magento/CatalogRule/Pricing/Price/CatalogRulePrice.php @@ -44,7 +44,7 @@ class CatalogRulePrice extends AbstractPrice implements BasePriceProviderInterfa /** * @var \Magento\CatalogRule\Model\ResourceModel\RuleFactory - * @deprecated + * @deprecated 100.1.1 */ protected $resourceRuleFactory; @@ -110,7 +110,7 @@ public function getValue() /** * @return Rule - * @deprecated + * @deprecated 100.1.1 */ private function getRuleResource() { diff --git a/app/code/Magento/CatalogRule/Test/Unit/Block/Adminhtml/Edit/DeleteButtonTest.php b/app/code/Magento/CatalogRule/Test/Unit/Block/Adminhtml/Edit/DeleteButtonTest.php index 16b6e79cf4e72..6178d51644fde 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Block/Adminhtml/Edit/DeleteButtonTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Block/Adminhtml/Edit/DeleteButtonTest.php @@ -7,7 +7,7 @@ use Magento\CatalogRule\Controller\RegistryConstants; -class DeleteButtonTest extends \PHPUnit_Framework_TestCase +class DeleteButtonTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogRule\Block\Adminhtml\Edit\DeleteButton @@ -26,9 +26,9 @@ class DeleteButtonTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->urlBuilderMock = $this->getMock(\Magento\Framework\UrlInterface::class, [], [], '', false); - $this->registryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); - $contextMock = $this->getMock(\Magento\Backend\Block\Widget\Context::class, [], [], '', false); + $this->urlBuilderMock = $this->createMock(\Magento\Framework\UrlInterface::class); + $this->registryMock = $this->createMock(\Magento\Framework\Registry::class); + $contextMock = $this->createMock(\Magento\Backend\Block\Widget\Context::class); $contextMock->expects($this->once())->method('getUrlBuilder')->willReturn($this->urlBuilderMock); diff --git a/app/code/Magento/CatalogRule/Test/Unit/Block/Adminhtml/Edit/GenericButtonTest.php b/app/code/Magento/CatalogRule/Test/Unit/Block/Adminhtml/Edit/GenericButtonTest.php index 7581439fab3b9..0e9179d12d120 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Block/Adminhtml/Edit/GenericButtonTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Block/Adminhtml/Edit/GenericButtonTest.php @@ -7,7 +7,7 @@ use Magento\CatalogRule\Controller\RegistryConstants; -class GenericButtonTest extends \PHPUnit_Framework_TestCase +class GenericButtonTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogRule\Block\Adminhtml\Edit\GenericButton @@ -26,9 +26,9 @@ class GenericButtonTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->urlBuilderMock = $this->getMock(\Magento\Framework\UrlInterface::class, [], [], '', false); - $this->registryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); - $contextMock = $this->getMock(\Magento\Backend\Block\Widget\Context::class, [], [], '', false); + $this->urlBuilderMock = $this->createMock(\Magento\Framework\UrlInterface::class); + $this->registryMock = $this->createMock(\Magento\Framework\Registry::class); + $contextMock = $this->createMock(\Magento\Backend\Block\Widget\Context::class); $contextMock->expects($this->once())->method('getUrlBuilder')->willReturn($this->urlBuilderMock); diff --git a/app/code/Magento/CatalogRule/Test/Unit/Cron/DailyCatalogUpdateTest.php b/app/code/Magento/CatalogRule/Test/Unit/Cron/DailyCatalogUpdateTest.php index 1973fc34d8079..ab0519e81fb73 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Cron/DailyCatalogUpdateTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Cron/DailyCatalogUpdateTest.php @@ -8,7 +8,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class DailyCatalogUpdateTest extends \PHPUnit_Framework_TestCase +class DailyCatalogUpdateTest extends \PHPUnit\Framework\TestCase { /** * Processor @@ -26,12 +26,8 @@ class DailyCatalogUpdateTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->ruleProductProcessor = $this->getMock( - \Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor::class, - [], - [], - '', - false + $this->ruleProductProcessor = $this->createMock( + \Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor::class ); $this->cron = (new ObjectManager($this))->getObject( diff --git a/app/code/Magento/CatalogRule/Test/Unit/Helper/DataTest.php b/app/code/Magento/CatalogRule/Test/Unit/Helper/DataTest.php index cf6dc2c4a8a09..d774380b1ecca 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Helper/DataTest.php @@ -8,7 +8,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class DataTest extends \PHPUnit_Framework_TestCase +class DataTest extends \PHPUnit\Framework\TestCase { /** * Helper object diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/CatalogRuleRepositoryTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/CatalogRuleRepositoryTest.php index 7300a06525cfe..32c6896625a1f 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Model/CatalogRuleRepositoryTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Model/CatalogRuleRepositoryTest.php @@ -6,7 +6,7 @@ namespace Magento\CatalogRule\Test\Unit\Model; -class CatalogRuleRepositoryTest extends \PHPUnit_Framework_TestCase +class CatalogRuleRepositoryTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogRule\Model\CatalogRuleRepository @@ -30,21 +30,9 @@ class CatalogRuleRepositoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->ruleResourceMock = $this->getMock( - \Magento\CatalogRule\Model\ResourceModel\Rule::class, - [], - [], - '', - false - ); - $this->ruleFactoryMock = $this->getMock( - \Magento\CatalogRule\Model\RuleFactory::class, - ['create'], - [], - '', - false - ); - $this->ruleMock = $this->getMock(\Magento\CatalogRule\Model\Rule::class, [], [], '', false); + $this->ruleResourceMock = $this->createMock(\Magento\CatalogRule\Model\ResourceModel\Rule::class); + $this->ruleFactoryMock = $this->createPartialMock(\Magento\CatalogRule\Model\RuleFactory::class, ['create']); + $this->ruleMock = $this->createMock(\Magento\CatalogRule\Model\Rule::class); $this->repository = new \Magento\CatalogRule\Model\CatalogRuleRepository( $this->ruleResourceMock, $this->ruleFactoryMock @@ -64,7 +52,7 @@ public function testEditRule() $ruleId = 1; $ruleData = ['id' => $ruleId]; $this->ruleMock->expects($this->once())->method('getData')->willReturn($ruleData); - $ruleMock = $this->getMock(\Magento\CatalogRule\Model\Rule::class, [], [], '', false); + $ruleMock = $this->createMock(\Magento\CatalogRule\Model\Rule::class); $this->ruleMock->expects($this->exactly(2))->method('getRuleId')->willReturn($ruleId); $ruleMock->expects($this->once())->method('addData')->with($ruleData)->willReturn($ruleMock); $this->ruleFactoryMock->expects($this->once())->method('create')->willReturn($ruleMock); @@ -104,7 +92,7 @@ public function testDeleteRule() public function testDeleteRuleById() { $ruleId = 1; - $ruleMock = $this->getMock(\Magento\CatalogRule\Model\Rule::class, [], [], '', false); + $ruleMock = $this->createMock(\Magento\CatalogRule\Model\Rule::class); $this->ruleFactoryMock->expects($this->once())->method('create')->willReturn($ruleMock); $ruleMock->expects($this->once())->method('getRuleId')->willReturn($ruleId); $ruleMock->expects($this->once())->method('load')->with($ruleId)->willReturn($ruleMock); @@ -133,7 +121,7 @@ public function testUnableDeleteRule() public function testGetRule() { $ruleId = 1; - $ruleMock = $this->getMock(\Magento\CatalogRule\Model\Rule::class, [], [], '', false); + $ruleMock = $this->createMock(\Magento\CatalogRule\Model\Rule::class); $this->ruleFactoryMock->expects($this->once())->method('create')->willReturn($ruleMock); $ruleMock->expects($this->once())->method('load')->with($ruleId)->willReturn($ruleMock); $ruleMock->expects($this->once())->method('getRuleId')->willReturn($ruleId); @@ -149,7 +137,7 @@ public function testGetRule() public function testGetNonExistentRule() { $ruleId = 1; - $ruleMock = $this->getMock(\Magento\CatalogRule\Model\Rule::class, [], [], '', false); + $ruleMock = $this->createMock(\Magento\CatalogRule\Model\Rule::class); $this->ruleFactoryMock->expects($this->once())->method('create')->willReturn($ruleMock); $ruleMock->expects($this->once())->method('load')->with($ruleId)->willReturn($ruleMock); $ruleMock->expects($this->once())->method('getRuleId')->willReturn(null); diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/Data/Condition/ConverterTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/Data/Condition/ConverterTest.php index deb866d334c1a..a49109971c38e 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Model/Data/Condition/ConverterTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Model/Data/Condition/ConverterTest.php @@ -5,7 +5,7 @@ */ namespace Magento\CatalogRule\Test\Unit\Model\Data\Condition; -class ConverterTest extends \PHPUnit_Framework_TestCase +class ConverterTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\CatalogRule\Api\Data\ConditionInterfaceFactory @@ -19,19 +19,16 @@ class ConverterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->conditionFactoryMock = $this->getMock( + $this->conditionFactoryMock = $this->createPartialMock( \Magento\CatalogRule\Api\Data\ConditionInterfaceFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->model = new \Magento\CatalogRule\Model\Data\Condition\Converter($this->conditionFactoryMock); } public function testDataModelToArray() { - $childConditionMock = $this->getMock(\Magento\CatalogRule\Api\Data\ConditionInterface::class); + $childConditionMock = $this->createMock(\Magento\CatalogRule\Api\Data\ConditionInterface::class); $childConditionMock->expects($this->once())->method('getType')->willReturn('child-type'); $childConditionMock->expects($this->once())->method('getAttribute')->willReturn('child-attr'); $childConditionMock->expects($this->once())->method('getOperator')->willReturn('child-operator'); @@ -40,7 +37,7 @@ public function testDataModelToArray() $childConditionMock->expects($this->once())->method('getAggregator')->willReturn('all'); $childConditionMock->expects($this->once())->method('getConditions')->willReturn([]); - $dataModelMock = $this->getMock(\Magento\CatalogRule\Api\Data\ConditionInterface::class); + $dataModelMock = $this->createMock(\Magento\CatalogRule\Api\Data\ConditionInterface::class); $dataModelMock->expects($this->once())->method('getType')->willReturn('type'); $dataModelMock->expects($this->once())->method('getAttribute')->willReturn('attr'); $dataModelMock->expects($this->once())->method('getOperator')->willReturn('operator'); @@ -91,8 +88,8 @@ public function testArrayToDataModel() ] ]; - $conditionMock = $this->getMock(\Magento\CatalogRule\Api\Data\ConditionInterface::class); - $conditionChildMock = $this->getMock(\Magento\CatalogRule\Api\Data\ConditionInterface::class); + $conditionMock = $this->createMock(\Magento\CatalogRule\Api\Data\ConditionInterface::class); + $conditionChildMock = $this->createMock(\Magento\CatalogRule\Api\Data\ConditionInterface::class); $this->conditionFactoryMock->expects($this->at(0))->method('create')->willReturn($conditionMock); $this->conditionFactoryMock->expects($this->at(1))->method('create')->willReturn($conditionChildMock); diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/AbstractIndexerTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/AbstractIndexerTest.php index d3aeb0783b365..f274b4f50dbd7 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/AbstractIndexerTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/AbstractIndexerTest.php @@ -8,7 +8,7 @@ use Magento\CatalogRule\Model\Indexer\AbstractIndexer; -class AbstractIndexerTest extends \PHPUnit_Framework_TestCase +class AbstractIndexerTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogRule\Model\Indexer\IndexBuilder|\PHPUnit_Framework_MockObject_MockObject @@ -32,8 +32,8 @@ class AbstractIndexerTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->_eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); - $this->indexBuilder = $this->getMock(\Magento\CatalogRule\Model\Indexer\IndexBuilder::class, [], [], '', false); + $this->_eventManagerMock = $this->createMock(\Magento\Framework\Event\ManagerInterface::class); + $this->indexBuilder = $this->createMock(\Magento\CatalogRule\Model\Indexer\IndexBuilder::class); $this->indexer = $this->getMockForAbstractClass( AbstractIndexer::class, @@ -42,7 +42,7 @@ protected function setUp() $this->_eventManagerMock ] ); - $cacheMock = $this->getMock(\Magento\Framework\App\CacheInterface::class); + $cacheMock = $this->createMock(\Magento\Framework\App\CacheInterface::class); $reflection = new \ReflectionClass(AbstractIndexer::class); $reflectionProperty = $reflection->getProperty('cacheManager'); $reflectionProperty->setAccessible(true); diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/IndexBuilderTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/IndexBuilderTest.php index 4f967b02b99ca..997cf704a8657 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/IndexBuilderTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/IndexBuilderTest.php @@ -10,7 +10,7 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.TooManyFields) */ -class IndexBuilderTest extends \PHPUnit_Framework_TestCase +class IndexBuilderTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogRule\Model\Indexer\IndexBuilder @@ -129,53 +129,35 @@ class IndexBuilderTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->resource = $this->getMock( + $this->resource = $this->createPartialMock( \Magento\Framework\App\ResourceConnection::class, - ['getConnection', 'getTableName'], - [], - '', - false + ['getConnection', 'getTableName'] ); - $this->ruleCollectionFactory = $this->getMock( + $this->ruleCollectionFactory = $this->createPartialMock( \Magento\CatalogRule\Model\ResourceModel\Rule\CollectionFactory::class, - ['create', 'addFieldToFilter'], - [], - '', - false + ['create', 'addFieldToFilter'] ); - $this->backend = $this->getMock( - \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend::class, - [], - [], - '', - false - ); - $this->select = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); - $this->metadataPool = $this->getMock(\Magento\Framework\EntityManager\MetadataPool::class, [], [], '', false); + $this->backend = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend::class); + $this->select = $this->createMock(\Magento\Framework\DB\Select::class); + $this->metadataPool = $this->createMock(\Magento\Framework\EntityManager\MetadataPool::class); $metadata = $this->getMockBuilder(\Magento\Framework\EntityManager\EntityMetadata::class) ->disableOriginalConstructor() ->getMock(); $this->metadataPool->expects($this->any())->method('getMetadata')->willReturn($metadata); - $this->connection = $this->getMock(\Magento\Framework\DB\Adapter\AdapterInterface::class); - $this->db = $this->getMock(\Zend_Db_Statement_Interface::class, [], [], '', false); - $this->website = $this->getMock(\Magento\Store\Model\Website::class, [], [], '', false); - $this->storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class, [], [], '', false); - $this->combine = $this->getMock(\Magento\Rule\Model\Condition\Combine::class, [], [], '', false); - $this->rules = $this->getMock(\Magento\CatalogRule\Model\Rule::class, [], [], '', false); - $this->logger = $this->getMock(\Psr\Log\LoggerInterface::class, [], [], '', false); - $this->attribute = $this->getMock( - \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class, - [], - [], - '', - false - ); - $this->priceCurrency = $this->getMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class); - $this->dateFormat = $this->getMock(\Magento\Framework\Stdlib\DateTime::class, [], [], '', false); - $this->dateTime = $this->getMock(\Magento\Framework\Stdlib\DateTime\DateTime::class, [], [], '', false); - $this->eavConfig = $this->getMock(\Magento\Eav\Model\Config::class, ['getAttribute'], [], '', false); - $this->product = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); - $this->productFactory = $this->getMock(\Magento\Catalog\Model\ProductFactory::class, ['create'], [], '', false); + $this->connection = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class); + $this->db = $this->createMock(\Zend_Db_Statement_Interface::class); + $this->website = $this->createMock(\Magento\Store\Model\Website::class); + $this->storeManager = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->combine = $this->createMock(\Magento\Rule\Model\Condition\Combine::class); + $this->rules = $this->createMock(\Magento\CatalogRule\Model\Rule::class); + $this->logger = $this->createMock(\Psr\Log\LoggerInterface::class); + $this->attribute = $this->createMock(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class); + $this->priceCurrency = $this->createMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class); + $this->dateFormat = $this->createMock(\Magento\Framework\Stdlib\DateTime::class); + $this->dateTime = $this->createMock(\Magento\Framework\Stdlib\DateTime\DateTime::class); + $this->eavConfig = $this->createPartialMock(\Magento\Eav\Model\Config::class, ['getAttribute']); + $this->product = $this->createMock(\Magento\Catalog\Model\Product::class); + $this->productFactory = $this->createPartialMock(\Magento\Catalog\Model\ProductFactory::class, ['create']); $this->connection->expects($this->any())->method('select')->will($this->returnValue($this->select)); $this->connection->expects($this->any())->method('query')->will($this->returnValue($this->db)); $this->select->expects($this->any())->method('distinct')->will($this->returnSelf()); @@ -234,26 +216,14 @@ protected function setUp() */ public function testUpdateCatalogRuleGroupWebsiteData() { - $priceAttrMock = $this->getMock( - \Magento\Catalog\Model\Entity\Attribute::class, - ['getBackend'], - [], - '', - false - ); - $backendModelMock = $this->getMock( + $priceAttrMock = $this->createPartialMock(\Magento\Catalog\Model\Entity\Attribute::class, ['getBackend']); + $backendModelMock = $this->createPartialMock( \Magento\Catalog\Model\Product\Attribute\Backend\Tierprice::class, - ['getResource'], - [], - '', - false + ['getResource'] ); - $resourceMock = $this->getMock( + $resourceMock = $this->createPartialMock( \Magento\Catalog\Model\ResourceModel\Product\Attribute\Backend\Tierprice::class, - ['getMainTable'], - [], - '', - false + ['getMainTable'] ); $resourceMock->expects($this->any()) ->method('getMainTable') diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/Product/ProductRuleIndexerTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/Product/ProductRuleIndexerTest.php index 8195c16c605a2..b99894f826ad2 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/Product/ProductRuleIndexerTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/Product/ProductRuleIndexerTest.php @@ -7,7 +7,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class ProductRuleIndexerTest extends \PHPUnit_Framework_TestCase +class ProductRuleIndexerTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogRule\Model\Indexer\IndexBuilder|\PHPUnit_Framework_MockObject_MockObject @@ -26,7 +26,7 @@ class ProductRuleIndexerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->indexBuilder = $this->getMock(\Magento\CatalogRule\Model\Indexer\IndexBuilder::class, [], [], '', false); + $this->indexBuilder = $this->createMock(\Magento\CatalogRule\Model\Indexer\IndexBuilder::class); $this->indexer = (new ObjectManager($this))->getObject( \Magento\CatalogRule\Model\Indexer\Product\ProductRuleIndexer::class, @@ -35,7 +35,7 @@ protected function setUp() ] ); - $this->cacheContextMock = $this->getMock(\Magento\Framework\Indexer\CacheContext::class, [], [], '', false); + $this->cacheContextMock = $this->createMock(\Magento\Framework\Indexer\CacheContext::class); $cacheContextProperty = new \ReflectionProperty( \Magento\CatalogRule\Model\Indexer\Product\ProductRuleIndexer::class, diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/ProductPriceCalculatorTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/ProductPriceCalculatorTest.php index 18b3fccfaa87c..51ad73202cdf4 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/ProductPriceCalculatorTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/ProductPriceCalculatorTest.php @@ -6,7 +6,7 @@ namespace Magento\CatalogRule\Test\Unit\Model\Indexer; -class ProductPriceCalculatorTest extends \PHPUnit_Framework_TestCase +class ProductPriceCalculatorTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogRule\Model\Indexer\ProductPriceCalculator diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/ReindexRuleGroupWebsiteTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/ReindexRuleGroupWebsiteTest.php index a9f9d2b0c4b11..d60a662193e54 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/ReindexRuleGroupWebsiteTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/ReindexRuleGroupWebsiteTest.php @@ -6,7 +6,7 @@ namespace Magento\CatalogRule\Test\Unit\Model\Indexer; -class ReindexRuleGroupWebsiteTest extends \PHPUnit_Framework_TestCase +class ReindexRuleGroupWebsiteTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogRule\Model\Indexer\ReindexRuleGroupWebsite diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/ReindexRuleProductPriceTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/ReindexRuleProductPriceTest.php index 99d66c20291dd..6d7f0673ed281 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/ReindexRuleProductPriceTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/ReindexRuleProductPriceTest.php @@ -8,7 +8,7 @@ use Magento\CatalogRule\Model\Indexer\IndexBuilder; -class ReindexRuleProductPriceTest extends \PHPUnit_Framework_TestCase +class ReindexRuleProductPriceTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogRule\Model\Indexer\ReindexRuleProductPrice diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/ReindexRuleProductTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/ReindexRuleProductTest.php index 76c1e42b39ba1..b829468396bf0 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/ReindexRuleProductTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/ReindexRuleProductTest.php @@ -6,7 +6,7 @@ namespace Magento\CatalogRule\Test\Unit\Model\Indexer; -class ReindexRuleProductTest extends \PHPUnit_Framework_TestCase +class ReindexRuleProductTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogRule\Model\Indexer\ReindexRuleProduct diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/Rule/RuleProductIndexerTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/Rule/RuleProductIndexerTest.php index 0299301ccfbfe..f11b8bff188bd 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/Rule/RuleProductIndexerTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/Rule/RuleProductIndexerTest.php @@ -8,7 +8,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class RuleProductIndexerTest extends \PHPUnit_Framework_TestCase +class RuleProductIndexerTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogRule\Model\Indexer\IndexBuilder|\PHPUnit_Framework_MockObject_MockObject @@ -27,7 +27,7 @@ class RuleProductIndexerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->indexBuilder = $this->getMock(\Magento\CatalogRule\Model\Indexer\IndexBuilder::class, [], [], '', false); + $this->indexBuilder = $this->createMock(\Magento\CatalogRule\Model\Indexer\IndexBuilder::class); $this->indexer = (new ObjectManager($this))->getObject( \Magento\CatalogRule\Model\Indexer\Rule\RuleProductIndexer::class, @@ -36,7 +36,7 @@ protected function setUp() ] ); - $this->cacheContextMock = $this->getMock(\Magento\Framework\Indexer\CacheContext::class, [], [], '', false); + $this->cacheContextMock = $this->createMock(\Magento\Framework\Indexer\CacheContext::class); $cacheContextProperty = new \ReflectionProperty( \Magento\CatalogRule\Model\Indexer\Rule\RuleProductIndexer::class, diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/RuleProductPricesPersistorTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/RuleProductPricesPersistorTest.php index 989d71bb086c4..3efe26971627e 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/RuleProductPricesPersistorTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/RuleProductPricesPersistorTest.php @@ -6,7 +6,7 @@ namespace Magento\CatalogRule\Test\Unit\Model\Indexer; -class RuleProductPricesPersistorTest extends \PHPUnit_Framework_TestCase +class RuleProductPricesPersistorTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogRule\Model\Indexer\RuleProductPricesPersistor diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/RuleProductsSelectBuilderTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/RuleProductsSelectBuilderTest.php index 05f10633fba4c..92b4bb353f046 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/RuleProductsSelectBuilderTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/RuleProductsSelectBuilderTest.php @@ -17,7 +17,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class RuleProductsSelectBuilderTest extends \PHPUnit_Framework_TestCase +class RuleProductsSelectBuilderTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogRule\Model\Indexer\RuleProductsSelectBuilder diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/Product/PriceModifierTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/Product/PriceModifierTest.php index 09e210d54b63d..b1e27bf973404 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Model/Product/PriceModifierTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Model/Product/PriceModifierTest.php @@ -5,7 +5,7 @@ */ namespace Magento\CatalogRule\Test\Unit\Model\Product; -class PriceModifierTest extends \PHPUnit_Framework_TestCase +class PriceModifierTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogRule\Model\Product\PriceModifier @@ -29,15 +29,9 @@ class PriceModifierTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->ruleFactoryMock = $this->getMock( - \Magento\CatalogRule\Model\RuleFactory::class, - ['create'], - [], - '', - false - ); - $this->productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); - $this->ruleMock = $this->getMock(\Magento\CatalogRule\Model\Rule::class, [], [], '', false); + $this->ruleFactoryMock = $this->createPartialMock(\Magento\CatalogRule\Model\RuleFactory::class, ['create']); + $this->productMock = $this->createMock(\Magento\Catalog\Model\Product::class); + $this->ruleMock = $this->createMock(\Magento\CatalogRule\Model\Rule::class); $this->priceModifier = new \Magento\CatalogRule\Model\Product\PriceModifier($this->ruleFactoryMock); } diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/ResourceModel/ReadHandlerTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/ResourceModel/ReadHandlerTest.php index 6ad22b919cc73..0b0fee8da6d55 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Model/ResourceModel/ReadHandlerTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Model/ResourceModel/ReadHandlerTest.php @@ -5,7 +5,7 @@ */ namespace Magento\CatalogRule\Test\Unit\Model\ResourceModel; -class ReadHandlerTest extends \PHPUnit_Framework_TestCase +class ReadHandlerTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogRule\Model\ResourceModel\ReadHandler @@ -24,8 +24,8 @@ class ReadHandlerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->resourceMock = $this->getMock(\Magento\CatalogRule\Model\ResourceModel\Rule::class, [], [], '', false); - $this->metadataMock = $this->getMock(\Magento\Framework\EntityManager\MetadataPool::class, [], [], '', false); + $this->resourceMock = $this->createMock(\Magento\CatalogRule\Model\ResourceModel\Rule::class); + $this->metadataMock = $this->createMock(\Magento\Framework\EntityManager\MetadataPool::class); $this->subject = new \Magento\CatalogRule\Model\ResourceModel\ReadHandler( $this->resourceMock, $this->metadataMock @@ -44,12 +44,9 @@ public function testExecute() $customerGroupIds = [1, 2, 3]; $websiteIds = [4, 5, 6]; - $metadataMock = $this->getMock( + $metadataMock = $this->createPartialMock( \Magento\Framework\EntityManager\EntityMetadata::class, - ['getLinkField'], - [], - '', - false + ['getLinkField'] ); $this->metadataMock->expects($this->once()) ->method('getMetadata') diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/ResourceModel/SaveHandlerTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/ResourceModel/SaveHandlerTest.php index 5fcf662cd3c09..820d4dea3e950 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Model/ResourceModel/SaveHandlerTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Model/ResourceModel/SaveHandlerTest.php @@ -5,7 +5,7 @@ */ namespace Magento\CatalogRule\Test\Unit\Model\ResourceModel; -class SaveHandlerTest extends \PHPUnit_Framework_TestCase +class SaveHandlerTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogRule\Model\ResourceModel\SaveHandler @@ -24,8 +24,8 @@ class SaveHandlerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->resourceMock = $this->getMock(\Magento\CatalogRule\Model\ResourceModel\Rule::class, [], [], '', false); - $this->metadataMock = $this->getMock(\Magento\Framework\EntityManager\MetadataPool::class, [], [], '', false); + $this->resourceMock = $this->createMock(\Magento\CatalogRule\Model\ResourceModel\Rule::class); + $this->metadataMock = $this->createMock(\Magento\Framework\EntityManager\MetadataPool::class); $this->subject = new \Magento\CatalogRule\Model\ResourceModel\SaveHandler( $this->resourceMock, $this->metadataMock @@ -46,12 +46,9 @@ public function testExecute() 'customer_group_ids' => $customerGroupIds ]; - $metadataMock = $this->getMock( + $metadataMock = $this->createPartialMock( \Magento\Framework\EntityManager\EntityMetadata::class, - ['getLinkField'], - [], - '', - false + ['getLinkField'] ); $this->metadataMock->expects($this->once()) ->method('getMetadata') diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/Rule/Condition/ProductTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/Rule/Condition/ProductTest.php index 373c01851cbad..8b9c052037f3b 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Model/Rule/Condition/ProductTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Model/Rule/Condition/ProductTest.php @@ -8,7 +8,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -class ProductTest extends \PHPUnit_Framework_TestCase +class ProductTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\CatalogRule\Model\Rule\Condition\Product */ protected $product; @@ -33,10 +33,8 @@ class ProductTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->config = $this->getMock(\Magento\Eav\Model\Config::class, ['getAttribute'], [], '', false); - $this->productModel = $this->getMock( - \Magento\Catalog\Model\Product::class, - [ + $this->config = $this->createPartialMock(\Magento\Eav\Model\Config::class, ['getAttribute']); + $this->productModel = $this->createPartialMock(\Magento\Catalog\Model\Product::class, [ '__wakeup', 'hasData', 'getData', @@ -44,11 +42,8 @@ protected function setUp() 'getStoreId', 'getResource', 'addAttributeToSelect', - ], - [], - '', - false - ); + 'getAttributesByCode' + ]); $this->productCategoryList = $this->getMockBuilder(\Magento\Catalog\Model\ProductCategoryList::class) ->disableOriginalConstructor() @@ -59,7 +54,7 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); - $this->eavAttributeResource = $this->getMock( + $this->eavAttributeResource = $this->createPartialMock( \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, [ '__wakeup', @@ -69,11 +64,9 @@ protected function setUp() 'getFrontendLabel', 'isScopeGlobal', 'getBackendType', - 'getFrontendInput' - ], - [], - '', - false + 'getFrontendInput', + 'getAttributesByCode' + ] ); $this->productResource->expects($this->any())->method('loadAllAttributes') diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/Rule/CustomerGroupsOptionsProviderTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/Rule/CustomerGroupsOptionsProviderTest.php index 6476fd26e7344..2ee6032813658 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Model/Rule/CustomerGroupsOptionsProviderTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Model/Rule/CustomerGroupsOptionsProviderTest.php @@ -5,7 +5,7 @@ */ namespace Magento\CatalogRule\Test\Unit\Model\Rule; -class CustomerGroupsOptionsProviderTest extends \PHPUnit_Framework_TestCase +class CustomerGroupsOptionsProviderTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogRule\Model\Rule\CustomerGroupsOptionsProvider @@ -29,15 +29,9 @@ class CustomerGroupsOptionsProviderTest extends \PHPUnit_Framework_TestCase protected function setup() { - $this->groupRepositoryMock = $this->getMock(\Magento\Customer\Api\GroupRepositoryInterface::class); - $this->searchCriteriaBuilderMock = $this->getMock( - \Magento\Framework\Api\SearchCriteriaBuilder::class, - [], - [], - '', - false - ); - $this->objectConverterMock = $this->getMock(\Magento\Framework\Convert\DataObject::class, [], [], '', false); + $this->groupRepositoryMock = $this->createMock(\Magento\Customer\Api\GroupRepositoryInterface::class); + $this->searchCriteriaBuilderMock = $this->createMock(\Magento\Framework\Api\SearchCriteriaBuilder::class); + $this->objectConverterMock = $this->createMock(\Magento\Framework\Convert\DataObject::class); $this->model = new \Magento\CatalogRule\Model\Rule\CustomerGroupsOptionsProvider( $this->groupRepositoryMock, $this->searchCriteriaBuilderMock, @@ -53,8 +47,8 @@ public function testToOptionArray() ['label' => 'label', 'value' => 'value'] ]; - $searchCriteriaMock = $this->getMock(\Magento\Framework\Api\SearchCriteria::class, [], [], '', false); - $searchResultMock = $this->getMock(\Magento\Customer\Api\Data\GroupSearchResultsInterface::class); + $searchCriteriaMock = $this->createMock(\Magento\Framework\Api\SearchCriteria::class); + $searchResultMock = $this->createMock(\Magento\Customer\Api\Data\GroupSearchResultsInterface::class); $this->searchCriteriaBuilderMock->expects($this->once())->method('create')->willReturn($searchCriteriaMock); $this->groupRepositoryMock->expects($this->once()) diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/Rule/DataProviderTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/Rule/DataProviderTest.php index b5e6bdcb3c06f..c41db66fd07e2 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Model/Rule/DataProviderTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Model/Rule/DataProviderTest.php @@ -5,7 +5,7 @@ */ namespace Magento\CatalogRule\Test\Unit\Model\Rule; -class DataProviderTest extends \PHPUnit_Framework_TestCase +class DataProviderTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogRule\Model\Rule\DataProvider @@ -29,22 +29,13 @@ class DataProviderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->collectionFactoryMock = $this->getMock( + $this->collectionFactoryMock = $this->createPartialMock( \Magento\CatalogRule\Model\ResourceModel\Rule\CollectionFactory::class, - ['create'], - [], - '', - false - ); - $this->collectionMock = $this->getMock( - \Magento\CatalogRule\Model\ResourceModel\Rule\Collection::class, - [], - [], - '', - false + ['create'] ); + $this->collectionMock = $this->createMock(\Magento\CatalogRule\Model\ResourceModel\Rule\Collection::class); $this->collectionFactoryMock->expects($this->once())->method('create')->willReturn($this->collectionMock); - $this->dataPersistorMock = $this->getMock(\Magento\Framework\App\Request\DataPersistorInterface::class); + $this->dataPersistorMock = $this->createMock(\Magento\Framework\App\Request\DataPersistorInterface::class); $this->model = new \Magento\CatalogRule\Model\Rule\DataProvider( 'Name', @@ -60,7 +51,7 @@ public function testGetData() $ruleId = 42; $ruleData = ['name' => 'Catalog Price Rule']; - $ruleMock = $this->getMock(\Magento\CatalogRule\Model\Rule::class, [], [], '', false); + $ruleMock = $this->createMock(\Magento\CatalogRule\Model\Rule::class); $this->collectionMock->expects($this->once())->method('getItems')->willReturn([$ruleMock]); $ruleMock->expects($this->atLeastOnce())->method('getId')->willReturn($ruleId); @@ -88,7 +79,7 @@ public function testGetDataIfRulePersisted() ->method('clear') ->with('catalog_rule'); - $newRuleMock = $this->getMock(\Magento\CatalogRule\Model\Rule::class, [], [], '', false); + $newRuleMock = $this->createMock(\Magento\CatalogRule\Model\Rule::class); $newRuleMock->expects($this->atLeastOnce())->method('setData')->with($persistedData)->willReturnSelf(); $newRuleMock->expects($this->atLeastOnce())->method('getId')->willReturn($ruleId); $newRuleMock->expects($this->once())->method('getData')->willReturn($ruleData); diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/Rule/JobTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/Rule/JobTest.php index 3cf4b5fb6e791..11e40b744347f 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Model/Rule/JobTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Model/Rule/JobTest.php @@ -5,9 +5,9 @@ */ namespace Magento\CatalogRule\Test\Unit\Model\Rule; -use \Magento\CatalogRule\Model\Rule\Job; +use Magento\CatalogRule\Model\Rule\Job; -class JobTest extends \PHPUnit_Framework_TestCase +class JobTest extends \PHPUnit\Framework\TestCase { /** * Test for method applyAll @@ -18,12 +18,9 @@ class JobTest extends \PHPUnit_Framework_TestCase */ public function testApplyAll() { - $ruleProcessorMock = $this->getMock( + $ruleProcessorMock = $this->createPartialMock( \Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor::class, - ['markIndexerAsInvalid'], - [], - '', - false + ['markIndexerAsInvalid'] ); $ruleProcessorMock->expects($this->once())->method('markIndexerAsInvalid'); $jobModel = new Job($ruleProcessorMock); @@ -35,12 +32,9 @@ public function testApplyAll() */ public function testExceptionApplyAll() { - $ruleProcessorMock = $this->getMock( + $ruleProcessorMock = $this->createPartialMock( \Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor::class, - ['markIndexerAsInvalid'], - [], - '', - false + ['markIndexerAsInvalid'] ); $exceptionMessage = 'Test exception message'; $exceptionCallback = function () use ($exceptionMessage) { diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/Rule/WebsitesOptionsProviderTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/Rule/WebsitesOptionsProviderTest.php index 697faa9bab540..607237b6557b6 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Model/Rule/WebsitesOptionsProviderTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Model/Rule/WebsitesOptionsProviderTest.php @@ -5,7 +5,7 @@ */ namespace Magento\CatalogRule\Test\Unit\Model\Rule; -class WebsitesOptionsProviderTest extends \PHPUnit_Framework_TestCase +class WebsitesOptionsProviderTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogRule\Model\Rule\WebsitesOptionsProvider @@ -19,7 +19,7 @@ class WebsitesOptionsProviderTest extends \PHPUnit_Framework_TestCase protected function setup() { - $this->storeMock = $this->getMock(\Magento\Store\Model\System\Store::class, [], [], '', false); + $this->storeMock = $this->createMock(\Magento\Store\Model\System\Store::class); $this->model = new \Magento\CatalogRule\Model\Rule\WebsitesOptionsProvider($this->storeMock); } diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/RuleTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/RuleTest.php index 2f790db15aebe..d03517ba04137 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Model/RuleTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Model/RuleTest.php @@ -8,7 +8,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class RuleTest extends \PHPUnit_Framework_TestCase +class RuleTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\CatalogRule\Model\Rule */ protected $rule; @@ -59,85 +59,53 @@ class RuleTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); - $this->storeModel = $this->getMock(\Magento\Store\Model\Store::class, ['__wakeup', 'getId'], [], '', false); - $this->combineFactory = $this->getMock( + $this->storeManager = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->storeModel = $this->createPartialMock(\Magento\Store\Model\Store::class, ['__wakeup', 'getId']); + $this->combineFactory = $this->createPartialMock( \Magento\CatalogRule\Model\Rule\Condition\CombineFactory::class, [ 'create' - ], - [], - '', - false + ] ); - $this->productModel = $this->getMock( + $this->productModel = $this->createPartialMock( \Magento\Catalog\Model\Product::class, [ - '__wakeup', 'getId', 'setData' - ], - [], - '', - false + '__wakeup', + 'getId', + 'setData' + ] ); - $this->condition = $this->getMock( + $this->condition = $this->createPartialMock( \Magento\Rule\Model\Condition\Combine::class, [ 'setRule', 'validate' - ], - [], - '', - false + ] ); - $this->websiteModel = $this->getMock( + $this->websiteModel = $this->createPartialMock( \Magento\Store\Model\Website::class, [ '__wakeup', 'getId', 'getDefaultStore' - ], - [], - '', - false + ] ); - $this->_ruleProductProcessor = $this->getMock( - \Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor::class, - [], - [], - '', - false + $this->_ruleProductProcessor = $this->createMock( + \Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor::class ); - $this->_productCollectionFactory = $this->getMock( + $this->_productCollectionFactory = $this->createPartialMock( \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->_resourceIterator = $this->getMock( + $this->_resourceIterator = $this->createPartialMock( \Magento\Framework\Model\ResourceModel\Iterator::class, - ['walk'], - [], - '', - false + ['walk'] ); - $extensionFactoryMock = $this->getMock( - \Magento\Framework\Api\ExtensionAttributesFactory::class, - [], - [], - '', - false - ); - $attributeValueFactoryMock = $this->getMock( - \Magento\Framework\Api\AttributeValueFactory::class, - [], - [], - '', - false - ); + $extensionFactoryMock = $this->createMock(\Magento\Framework\Api\ExtensionAttributesFactory::class); + $attributeValueFactoryMock = $this->createMock(\Magento\Framework\Api\AttributeValueFactory::class); $this->rule = $this->objectManager->getObject( \Magento\CatalogRule\Model\Rule::class, @@ -336,7 +304,7 @@ public function validateDataDataProvider() */ public function testAfterDelete() { - $indexer = $this->getMock(\Magento\Framework\Indexer\IndexerInterface::class); + $indexer = $this->createMock(\Magento\Framework\Indexer\IndexerInterface::class); $indexer->expects($this->once())->method('invalidate'); $this->_ruleProductProcessor->expects($this->once())->method('getIndexer')->will($this->returnValue($indexer)); $this->rule->afterDelete(); @@ -350,7 +318,7 @@ public function testAfterDelete() public function testAfterUpdate() { $this->rule->isObjectNew(false); - $indexer = $this->getMock(\Magento\Framework\Indexer\IndexerInterface::class); + $indexer = $this->createMock(\Magento\Framework\Indexer\IndexerInterface::class); $indexer->expects($this->once())->method('invalidate'); $this->_ruleProductProcessor->expects($this->once())->method('getIndexer')->will($this->returnValue($indexer)); $this->rule->afterSave(); @@ -372,7 +340,7 @@ public function testIsRuleBehaviorChanged($dataArray, $originDataArray, $isObjec { $this->rule->setData('website_ids', []); $this->rule->isObjectNew($isObjectNew); - $indexer = $this->getMock(\Magento\Framework\Indexer\IndexerInterface::class); + $indexer = $this->createMock(\Magento\Framework\Indexer\IndexerInterface::class); $indexer->expects($this->any())->method('invalidate'); $this->_ruleProductProcessor->expects($this->any())->method('getIndexer')->will($this->returnValue($indexer)); diff --git a/app/code/Magento/CatalogRule/Test/Unit/Observer/AddDirtyRulesNoticeTest.php b/app/code/Magento/CatalogRule/Test/Unit/Observer/AddDirtyRulesNoticeTest.php index ae9b67f279e11..b052ccddbf6b4 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Observer/AddDirtyRulesNoticeTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Observer/AddDirtyRulesNoticeTest.php @@ -10,7 +10,7 @@ /** * Class AddDirtyRulesNoticeTest */ -class AddDirtyRulesNoticeTest extends \PHPUnit_Framework_TestCase +class AddDirtyRulesNoticeTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogRule\Observer\AddDirtyRulesNotice diff --git a/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/CategoryTest.php b/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/CategoryTest.php index 280fc79171c0c..5822e01853deb 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/CategoryTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/CategoryTest.php @@ -8,7 +8,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class CategoryTest extends \PHPUnit_Framework_TestCase +class CategoryTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogRule\Model\Indexer\Product\ProductRuleProcessor|\PHPUnit_Framework_MockObject_MockObject @@ -27,19 +27,12 @@ class CategoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->productRuleProcessor = $this->getMock( - \Magento\CatalogRule\Model\Indexer\Product\ProductRuleProcessor::class, - [], - [], - '', - false + $this->productRuleProcessor = $this->createMock( + \Magento\CatalogRule\Model\Indexer\Product\ProductRuleProcessor::class ); - $this->subject = $this->getMock( + $this->subject = $this->createPartialMock( \Magento\Catalog\Model\Category::class, - ['getAffectedProductIds', '__wakeUp'], - [], - '', - false + ['getAffectedProductIds', '__wakeUp'] ); $this->plugin = (new ObjectManager($this))->getObject( diff --git a/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/CustomerGroupTest.php b/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/CustomerGroupTest.php index e85d853a1897a..1a9707c8c2803 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/CustomerGroupTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/CustomerGroupTest.php @@ -8,7 +8,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class CustomerGroupTest extends \PHPUnit_Framework_TestCase +class CustomerGroupTest extends \PHPUnit\Framework\TestCase { /** * Rule processor mock @@ -33,20 +33,10 @@ class CustomerGroupTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->ruleProductProcessor = $this->getMock( - \Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor::class, - [], - [], - '', - false - ); - $this->subject = $this->getMock( - \Magento\Customer\Model\Group::class, - [], - [], - '', - false + $this->ruleProductProcessor = $this->createMock( + \Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor::class ); + $this->subject = $this->createMock(\Magento\Customer\Model\Group::class); $this->plugin = (new ObjectManager($this))->getObject( \Magento\CatalogRule\Plugin\Indexer\CustomerGroup::class, diff --git a/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/ImportExportTest.php b/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/ImportExportTest.php index 1e37cc0681457..68322d2a6e59f 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/ImportExportTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/ImportExportTest.php @@ -8,7 +8,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class ImportExportTest extends \PHPUnit_Framework_TestCase +class ImportExportTest extends \PHPUnit\Framework\TestCase { /** * Indexer processor mock @@ -33,15 +33,12 @@ class ImportExportTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->ruleProductProcessor = $this->getMock( + $this->ruleProductProcessor = $this->createPartialMock( \Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor::class, - ['isIndexerScheduled', 'markIndexerAsInvalid'], - [], - '', - false + ['isIndexerScheduled', 'markIndexerAsInvalid'] ); $this->ruleProductProcessor->expects($this->once())->method('isIndexerScheduled')->willReturn(false); - $this->subject = $this->getMock(\Magento\ImportExport\Model\Import::class, [], [], '', false); + $this->subject = $this->createMock(\Magento\ImportExport\Model\Import::class); $this->plugin = (new ObjectManager($this))->getObject( \Magento\CatalogRule\Plugin\Indexer\ImportExport::class, diff --git a/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/Product/Save/ApplyRulesAfterReindexTest.php b/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/Product/Save/ApplyRulesAfterReindexTest.php index ab9203be9c0fe..fe79c455ec1cd 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/Product/Save/ApplyRulesAfterReindexTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/Product/Save/ApplyRulesAfterReindexTest.php @@ -10,7 +10,7 @@ use Magento\CatalogRule\Model\Indexer\Product\ProductRuleProcessor; use Magento\Catalog\Model\Product; -class ApplyRulesAfterReindexTest extends \PHPUnit_Framework_TestCase +class ApplyRulesAfterReindexTest extends \PHPUnit\Framework\TestCase { /** * @var ApplyRulesAfterReindex diff --git a/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/Product/Save/ApplyRulesTest.php b/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/Product/Save/ApplyRulesTest.php index c9b301cbc0c54..fce5745100b93 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/Product/Save/ApplyRulesTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/Product/Save/ApplyRulesTest.php @@ -7,7 +7,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class ApplyRulesTest extends \PHPUnit_Framework_TestCase +class ApplyRulesTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogRule\Model\Indexer\Product\ProductRuleProcessor|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/WebsiteTest.php b/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/WebsiteTest.php index a55d67b44e9eb..94599b12b6fd8 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/WebsiteTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Plugin/Indexer/WebsiteTest.php @@ -8,7 +8,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class WebsiteTest extends \PHPUnit_Framework_TestCase +class WebsiteTest extends \PHPUnit\Framework\TestCase { /** * Indexer processor mock @@ -33,14 +33,10 @@ class WebsiteTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->ruleProductProcessor = $this->getMock( - \Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor::class, - [], - [], - '', - false + $this->ruleProductProcessor = $this->createMock( + \Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor::class ); - $this->subject = $this->getMock(\Magento\Store\Model\Website::class, [], [], '', false); + $this->subject = $this->createMock(\Magento\Store\Model\Website::class); $this->plugin = (new ObjectManager($this))->getObject( \Magento\CatalogRule\Plugin\Indexer\Website::class, diff --git a/app/code/Magento/CatalogRule/Test/Unit/Plugin/Model/Product/ActionTest.php b/app/code/Magento/CatalogRule/Test/Unit/Plugin/Model/Product/ActionTest.php index 824967f555655..549d3e493d121 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Plugin/Model/Product/ActionTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Plugin/Model/Product/ActionTest.php @@ -8,7 +8,7 @@ use \Magento\CatalogRule\Plugin\Model\Product\Action; -class ActionTest extends \PHPUnit_Framework_TestCase +class ActionTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\CatalogRule\Plugin\Model\Product\Action */ protected $action; diff --git a/app/code/Magento/CatalogRule/Test/Unit/Pricing/Price/CatalogRulePriceTest.php b/app/code/Magento/CatalogRule/Test/Unit/Pricing/Price/CatalogRulePriceTest.php index 2347577856fbc..797097f8a5346 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Pricing/Price/CatalogRulePriceTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Pricing/Price/CatalogRulePriceTest.php @@ -14,7 +14,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class CatalogRulePriceTest extends \PHPUnit_Framework_TestCase +class CatalogRulePriceTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogRule\Pricing\Price\CatalogRulePrice @@ -81,12 +81,9 @@ class CatalogRulePriceTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->saleableItemMock = $this->getMock( + $this->saleableItemMock = $this->createPartialMock( \Magento\Catalog\Model\Product::class, - ['getId', '__wakeup', 'getPriceInfo', 'hasData', 'getData'], - [], - '', - false + ['getId', '__wakeup', 'getPriceInfo', 'hasData', 'getData'] ); $this->dataTimeMock = $this->getMockForAbstractClass( \Magento\Framework\Stdlib\DateTime\TimezoneInterface::class, @@ -98,36 +95,24 @@ protected function setUp() [] ); - $this->coreStoreMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); - $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); + $this->coreStoreMock = $this->createMock(\Magento\Store\Model\Store::class); + $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManager::class); $this->storeManagerMock->expects($this->any()) ->method('getStore') ->will($this->returnValue($this->coreStoreMock)); - $this->customerSessionMock = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); - $this->priceInfoMock = $this->getMock( - \Magento\Framework\Pricing\PriceInfo::class, - ['getAdjustments'], - [], - '', - false - ); - $this->catalogRuleResourceFactoryMock = $this->getMock( + $this->customerSessionMock = $this->createMock(\Magento\Customer\Model\Session::class); + $this->priceInfoMock = $this->getMockBuilder(\Magento\Framework\Pricing\PriceInfo::class) + ->setMethods(['getAdjustments']) + ->disableOriginalConstructor() + ->getMock(); + $this->catalogRuleResourceFactoryMock = $this->createPartialMock( \Magento\CatalogRule\Model\ResourceModel\RuleFactory::class, - ['create'], - [], - '', - false - ); - $this->catalogRuleResourceMock = $this->getMock( - \Magento\CatalogRule\Model\ResourceModel\Rule::class, - [], - [], - '', - false + ['create'] ); + $this->catalogRuleResourceMock = $this->createMock(\Magento\CatalogRule\Model\ResourceModel\Rule::class); - $this->coreWebsiteMock = $this->getMock(\Magento\Store\Model\Website::class, [], [], '', false); + $this->coreWebsiteMock = $this->createMock(\Magento\Store\Model\Website::class); $this->priceInfoMock->expects($this->any()) ->method('getAdjustments') @@ -145,7 +130,7 @@ protected function setUp() ->getMock(); $qty = 1; - $this->priceCurrencyMock = $this->getMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class); + $this->priceCurrencyMock = $this->createMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class); $this->object = new CatalogRulePrice( $this->saleableItemMock, diff --git a/app/code/Magento/CatalogRuleConfigurable/Plugin/CatalogRule/Model/ConfigurableProductsProvider.php b/app/code/Magento/CatalogRuleConfigurable/Plugin/CatalogRule/Model/ConfigurableProductsProvider.php index 5e8706be18666..dd020114b03ab 100644 --- a/app/code/Magento/CatalogRuleConfigurable/Plugin/CatalogRule/Model/ConfigurableProductsProvider.php +++ b/app/code/Magento/CatalogRuleConfigurable/Plugin/CatalogRule/Model/ConfigurableProductsProvider.php @@ -8,7 +8,9 @@ class ConfigurableProductsProvider { - /** @var \Magento\Framework\App\ResourceConnection */ + /** + * @var \Magento\Framework\App\ResourceConnection + */ private $resource; /** diff --git a/app/code/Magento/CatalogRuleConfigurable/Plugin/CatalogRule/Model/Indexer/ProductRuleReindex.php b/app/code/Magento/CatalogRuleConfigurable/Plugin/CatalogRule/Model/Indexer/ProductRuleReindex.php index 32b56d1b20785..9c66719334639 100644 --- a/app/code/Magento/CatalogRuleConfigurable/Plugin/CatalogRule/Model/Indexer/ProductRuleReindex.php +++ b/app/code/Magento/CatalogRuleConfigurable/Plugin/CatalogRule/Model/Indexer/ProductRuleReindex.php @@ -14,10 +14,14 @@ */ class ProductRuleReindex { - /** @var Configurable */ + /** + * @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable + */ private $configurable; - /** @var ConfigurableProductsProvider */ + /** + * @var \Magento\CatalogRuleConfigurable\Plugin\CatalogRule\Model\ConfigurableProductsProvider + */ private $configurableProductsProvider; /** diff --git a/app/code/Magento/CatalogRuleConfigurable/Plugin/CatalogRule/Model/Rule/ConfigurableProductHandler.php b/app/code/Magento/CatalogRuleConfigurable/Plugin/CatalogRule/Model/Rule/ConfigurableProductHandler.php index ed2cd37273087..d27c424ed9ea3 100644 --- a/app/code/Magento/CatalogRuleConfigurable/Plugin/CatalogRule/Model/Rule/ConfigurableProductHandler.php +++ b/app/code/Magento/CatalogRuleConfigurable/Plugin/CatalogRule/Model/Rule/ConfigurableProductHandler.php @@ -14,10 +14,14 @@ */ class ConfigurableProductHandler { - /** @var \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable */ + /** + * @var \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable + */ private $configurable; - /** @var ConfigurableProductsProvider */ + /** + * @var \Magento\CatalogRuleConfigurable\Plugin\CatalogRule\Model\ConfigurableProductsProvider + */ private $configurableProductsProvider; /** diff --git a/app/code/Magento/CatalogRuleConfigurable/Test/Unit/Plugin/CatalogRule/Model/Rule/ConfigurableProductHandlerTest.php b/app/code/Magento/CatalogRuleConfigurable/Test/Unit/Plugin/CatalogRule/Model/Rule/ConfigurableProductHandlerTest.php index 5f3684fcb4faf..664d9c22c7a1b 100644 --- a/app/code/Magento/CatalogRuleConfigurable/Test/Unit/Plugin/CatalogRule/Model/Rule/ConfigurableProductHandlerTest.php +++ b/app/code/Magento/CatalogRuleConfigurable/Test/Unit/Plugin/CatalogRule/Model/Rule/ConfigurableProductHandlerTest.php @@ -6,14 +6,14 @@ namespace Magento\CatalogRuleConfigurable\Test\Unit\Plugin\CatalogRule\Model\Rule; +use Magento\CatalogRuleConfigurable\Plugin\CatalogRule\Model\ConfigurableProductsProvider; use Magento\CatalogRuleConfigurable\Plugin\CatalogRule\Model\Rule\ConfigurableProductHandler; use Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable; -use Magento\CatalogRuleConfigurable\Plugin\CatalogRule\Model\ConfigurableProductsProvider; /** * Unit test for Magento\CatalogRuleConfigurable\Plugin\CatalogRule\Model\Rule\ConfigurableProductHandler */ -class ConfigurableProductHandlerTest extends \PHPUnit_Framework_TestCase +class ConfigurableProductHandlerTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogRuleConfigurable\Plugin\CatalogRule\Model\Rule\ConfigurableProductHandler @@ -38,21 +38,15 @@ class ConfigurableProductHandlerTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->configurableMock = $this->getMock( + $this->configurableMock = $this->createPartialMock( \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable::class, - ['getChildrenIds'], - [], - '', - false + ['getChildrenIds'] ); - $this->configurableProductsProviderMock = $this->getMock( + $this->configurableProductsProviderMock = $this->createPartialMock( \Magento\CatalogRuleConfigurable\Plugin\CatalogRule\Model\ConfigurableProductsProvider::class, - ['getIds'], - [], - '', - false + ['getIds'] ); - $this->ruleMock = $this->getMock(\Magento\CatalogRule\Model\Rule::class, [], [], '', false); + $this->ruleMock = $this->createMock(\Magento\CatalogRule\Model\Rule::class); $this->configurableProductHandler = new ConfigurableProductHandler( $this->configurableMock, diff --git a/app/code/Magento/CatalogRuleConfigurable/Test/Unit/Plugin/CatalogRule/Model/Rule/ValidationTest.php b/app/code/Magento/CatalogRuleConfigurable/Test/Unit/Plugin/CatalogRule/Model/Rule/ValidationTest.php index fb2eb2ce2a9b3..8404dce909c59 100644 --- a/app/code/Magento/CatalogRuleConfigurable/Test/Unit/Plugin/CatalogRule/Model/Rule/ValidationTest.php +++ b/app/code/Magento/CatalogRuleConfigurable/Test/Unit/Plugin/CatalogRule/Model/Rule/ValidationTest.php @@ -11,7 +11,7 @@ /** * Unit test for Magento\CatalogRuleConfigurable\Plugin\CatalogRule\Model\Rule\Validation */ -class ValidationTest extends \PHPUnit_Framework_TestCase +class ValidationTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogRuleConfigurable\Plugin\CatalogRule\Model\Rule\Validation @@ -37,17 +37,14 @@ class ValidationTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->configurableMock = $this->getMock( + $this->configurableMock = $this->createPartialMock( \Magento\ConfigurableProduct\Model\Product\Type\Configurable::class, - ['getParentIdsByChild'], - [], - '', - false + ['getParentIdsByChild'] ); - $this->ruleMock = $this->getMock(\Magento\CatalogRule\Model\Rule::class, [], [], '', false); - $this->ruleConditionsMock = $this->getMock(\Magento\Rule\Model\Condition\Combine::class, [], [], '', false); - $this->productMock = $this->getMock(\Magento\Framework\DataObject::class, ['getId']); + $this->ruleMock = $this->createMock(\Magento\CatalogRule\Model\Rule::class); + $this->ruleConditionsMock = $this->createMock(\Magento\Rule\Model\Condition\Combine::class); + $this->productMock = $this->createPartialMock(\Magento\Framework\DataObject::class, ['getId']); $this->validation = new Validation( $this->configurableMock diff --git a/app/code/Magento/CatalogSearch/Block/Advanced/Form.php b/app/code/Magento/CatalogSearch/Block/Advanced/Form.php index 574f0ed264c5d..59d33ddbfd60b 100644 --- a/app/code/Magento/CatalogSearch/Block/Advanced/Form.php +++ b/app/code/Magento/CatalogSearch/Block/Advanced/Form.php @@ -22,6 +22,7 @@ /** * @api + * @since 100.0.2 */ class Form extends Template { diff --git a/app/code/Magento/CatalogSearch/Block/Advanced/Result.php b/app/code/Magento/CatalogSearch/Block/Advanced/Result.php index 0e88d01e2349c..7c8e65b249139 100644 --- a/app/code/Magento/CatalogSearch/Block/Advanced/Result.php +++ b/app/code/Magento/CatalogSearch/Block/Advanced/Result.php @@ -17,6 +17,7 @@ * Advanced search result * * @api + * @since 100.0.2 */ class Result extends Template { diff --git a/app/code/Magento/CatalogSearch/Block/Result.php b/app/code/Magento/CatalogSearch/Block/Result.php index 2a4e38038fb88..f0d899b678c78 100644 --- a/app/code/Magento/CatalogSearch/Block/Result.php +++ b/app/code/Magento/CatalogSearch/Block/Result.php @@ -17,6 +17,7 @@ * Product search result block * * @api + * @since 100.0.2 */ class Result extends Template { diff --git a/app/code/Magento/CatalogSearch/Helper/Data.php b/app/code/Magento/CatalogSearch/Helper/Data.php index 4f14edc8c772d..6898e33d49f1d 100644 --- a/app/code/Magento/CatalogSearch/Helper/Data.php +++ b/app/code/Magento/CatalogSearch/Helper/Data.php @@ -9,6 +9,7 @@ * Catalog search helper * * @api + * @since 100.0.2 */ class Data extends \Magento\Search\Helper\Data { diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Filter/AliasResolver.php b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Filter/AliasResolver.php index ed5719dd42e2c..547122125b1d0 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Filter/AliasResolver.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Filter/AliasResolver.php @@ -11,6 +11,7 @@ /** * Purpose of class is to resolve table alias for Search Request filter * @api + * @since 100.1.6 */ class AliasResolver { @@ -23,6 +24,7 @@ class AliasResolver /** * @param \Magento\Framework\Search\Request\FilterInterface $filter * @return string alias of the filter in database + * @since 100.1.6 */ public function getAlias(\Magento\Framework\Search\Request\FilterInterface $filter) { diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Options.php b/app/code/Magento/CatalogSearch/Model/Adapter/Options.php index 0e8cb32b4c6cd..425e6c0041616 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Options.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Options.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class Options implements OptionsInterface { diff --git a/app/code/Magento/CatalogSearch/Model/Adminhtml/System/Config/Backend/Engine.php b/app/code/Magento/CatalogSearch/Model/Adminhtml/System/Config/Backend/Engine.php index 14ecee3486360..2964f836ab9d6 100644 --- a/app/code/Magento/CatalogSearch/Model/Adminhtml/System/Config/Backend/Engine.php +++ b/app/code/Magento/CatalogSearch/Model/Adminhtml/System/Config/Backend/Engine.php @@ -8,10 +8,13 @@ /** * @author Magento Core Team * @api + * @since 100.0.2 */ class Engine extends \Magento\Framework\App\Config\Value { - /** @var \Magento\Framework\Indexer\IndexerRegistry */ + /** + * @var \Magento\Framework\Indexer\IndexerRegistry + */ protected $indexerRegistry; /** diff --git a/app/code/Magento/CatalogSearch/Model/Advanced.php b/app/code/Magento/CatalogSearch/Model/Advanced.php index 6598c6e76609c..d158bdf40b421 100644 --- a/app/code/Magento/CatalogSearch/Model/Advanced.php +++ b/app/code/Magento/CatalogSearch/Model/Advanced.php @@ -22,7 +22,6 @@ /** * Catalog advanced search model - * @method \Magento\CatalogSearch\Model\ResourceModel\Advanced getResource() * @method int getEntityTypeId() * @method \Magento\CatalogSearch\Model\Advanced setEntityTypeId(int $value) * @method int getAttributeSetId() @@ -43,6 +42,7 @@ * @author Magento Core Team * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @api + * @since 100.0.2 */ class Advanced extends \Magento\Framework\Model\AbstractModel { diff --git a/app/code/Magento/CatalogSearch/Model/Advanced/Request/Builder.php b/app/code/Magento/CatalogSearch/Model/Advanced/Request/Builder.php index 2bc63d30fa5e6..429c29fd3d2e6 100644 --- a/app/code/Magento/CatalogSearch/Model/Advanced/Request/Builder.php +++ b/app/code/Magento/CatalogSearch/Model/Advanced/Request/Builder.php @@ -9,6 +9,7 @@ /** * @api + * @since 100.0.2 */ class Builder extends RequestBuilder { diff --git a/app/code/Magento/CatalogSearch/Model/Fulltext.php b/app/code/Magento/CatalogSearch/Model/Fulltext.php index c7943508df17c..838d0aa906730 100644 --- a/app/code/Magento/CatalogSearch/Model/Fulltext.php +++ b/app/code/Magento/CatalogSearch/Model/Fulltext.php @@ -15,8 +15,6 @@ /** * Catalog advanced search model * - * @method \Magento\CatalogSearch\Model\ResourceModel\Fulltext _getResource() - * @method \Magento\CatalogSearch\Model\ResourceModel\Fulltext getResource() * @method int getProductId() * @method \Magento\CatalogSearch\Model\Fulltext setProductId(int $value) * @method int getStoreId() diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext.php index a515b0b0cb02c..9009a40c19dff 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext.php @@ -17,6 +17,7 @@ * Provide functionality for Fulltext Search indexing. * * @api + * @since 100.0.2 */ class Fulltext implements \Magento\Framework\Indexer\ActionInterface, \Magento\Framework\Mview\ActionInterface { diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/DataProvider.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/DataProvider.php index 7db1273915090..f61ec7ce56f81 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/DataProvider.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/DataProvider.php @@ -11,6 +11,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @api + * @since 100.0.3 */ class DataProvider { @@ -151,6 +152,7 @@ private function getTable($table) * @param int $lastProductId * @param int $limit * @return array + * @since 100.0.3 */ public function getSearchableProducts( $storeId, @@ -188,6 +190,7 @@ public function getSearchableProducts( * * @param string $backendType * @return \Magento\Eav\Model\Entity\Attribute[] + * @since 100.0.3 */ public function getSearchableAttributes($backendType = null) { @@ -234,6 +237,7 @@ public function getSearchableAttributes($backendType = null) * * @param int|string $attribute * @return \Magento\Eav\Model\Entity\Attribute + * @since 100.0.3 */ public function getSearchableAttribute($attribute) { @@ -277,6 +281,7 @@ private function unifyField($field, $backendType = 'varchar') * @param array $productIds * @param array $attributeTypes * @return array + * @since 100.0.3 */ public function getProductAttributes($storeId, array $productIds, array $attributeTypes) { @@ -355,6 +360,7 @@ private function getProductTypeInstance($typeId) * @param int $productId Product Entity Id * @param string $typeId Super Product Link Type * @return array|null + * @since 100.0.3 */ public function getProductChildIds($productId, $typeId) { @@ -409,6 +415,7 @@ private function getProductEmulator($typeId) * @param int $storeId * @return string * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @since 100.0.3 */ public function prepareProductIndex($indexData, $productData, $storeId) { diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/Full.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/Full.php index 16ee3fadcf446..639c0e8ca66f0 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/Full.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/Full.php @@ -20,6 +20,7 @@ * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @api + * @since 100.0.2 */ class Full { @@ -39,7 +40,7 @@ class Full * Index values separator * * @var string - * @deprecated Moved to \Magento\CatalogSearch\Model\Indexer\Fulltext\Action\DataProvider + * @deprecated 100.1.6 Moved to \Magento\CatalogSearch\Model\Indexer\Fulltext\Action\DataProvider * @see \Magento\CatalogSearch\Model\Indexer\Fulltext\Action\DataProvider::$separator */ protected $separator = ' | '; @@ -48,7 +49,7 @@ class Full * Array of \DateTime objects per store * * @var \DateTime[] - * @deprecated Not used anymore + * @deprecated 100.1.6 Not used anymore */ protected $dates = []; @@ -56,7 +57,7 @@ class Full * Product Type Instances cache * * @var array - * @deprecated Moved to \Magento\CatalogSearch\Model\Indexer\Fulltext\Action\DataProvider + * @deprecated 100.1.6 Moved to \Magento\CatalogSearch\Model\Indexer\Fulltext\Action\DataProvider * @see \Magento\CatalogSearch\Model\Indexer\Fulltext\Action\DataProvider::$productTypes */ protected $productTypes = []; @@ -65,7 +66,7 @@ class Full * Product Emulators cache * * @var array - * @deprecated Moved to \Magento\CatalogSearch\Model\Indexer\Fulltext\Action\DataProvider + * @deprecated 100.1.6 Moved to \Magento\CatalogSearch\Model\Indexer\Fulltext\Action\DataProvider * @see \Magento\CatalogSearch\Model\Indexer\Fulltext\Action\DataProvider::$productEmulators */ protected $productEmulators = []; @@ -93,7 +94,7 @@ class Full * Catalog product type * * @var \Magento\Catalog\Model\Product\Type - * @deprecated Moved to \Magento\CatalogSearch\Model\Indexer\Fulltext\Action\DataProvider + * @deprecated 100.1.6 Moved to \Magento\CatalogSearch\Model\Indexer\Fulltext\Action\DataProvider * @see \Magento\CatalogSearch\Model\Indexer\Fulltext\Action\DataProvider::$catalogProductType */ protected $catalogProductType; @@ -109,7 +110,7 @@ class Full * Core store config * * @var \Magento\Framework\App\Config\ScopeConfigInterface - * @deprecated Not used anymore + * @deprecated 100.1.6 Not used anymore */ protected $scopeConfig; @@ -117,7 +118,7 @@ class Full * Store manager * * @var \Magento\Store\Model\StoreManagerInterface - * @deprecated Moved to \Magento\CatalogSearch\Model\Indexer\Fulltext\Action\DataProvider + * @deprecated 100.1.6 Moved to \Magento\CatalogSearch\Model\Indexer\Fulltext\Action\DataProvider * @see \Magento\CatalogSearch\Model\Indexer\Fulltext\Action\DataProvider::$storeManager */ protected $storeManager; @@ -129,25 +130,25 @@ class Full /** * @var \Magento\Framework\Indexer\SaveHandler\IndexerInterface - * @deprecated As part of self::cleanIndex() + * @deprecated 100.1.6 As part of self::cleanIndex() */ protected $indexHandler; /** * @var \Magento\Framework\Stdlib\DateTime - * @deprecated Not used anymore + * @deprecated 100.1.6 Not used anymore */ protected $dateTime; /** * @var \Magento\Framework\Locale\ResolverInterface - * @deprecated Not used anymore + * @deprecated 100.1.6 Not used anymore */ protected $localeResolver; /** * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface - * @deprecated Not used anymore + * @deprecated 100.1.6 Not used anymore */ protected $localeDate; @@ -158,19 +159,19 @@ class Full /** * @var \Magento\CatalogSearch\Model\ResourceModel\Fulltext - * @deprecated Not used anymore + * @deprecated 100.1.6 Not used anymore */ protected $fulltextResource; /** * @var \Magento\Framework\Search\Request\Config - * @deprecated As part of self::reindexAll() + * @deprecated 100.1.6 As part of self::reindexAll() */ protected $searchRequestConfig; /** * @var \Magento\Framework\Search\Request\DimensionFactory - * @deprecated As part of self::cleanIndex() + * @deprecated 100.1.6 As part of self::cleanIndex() */ private $dimensionFactory; @@ -181,7 +182,7 @@ class Full /** * @var \Magento\CatalogSearch\Model\Indexer\Fulltext\Action\IndexIteratorFactory - * @deprecated DataProvider used directly without IndexIterator + * @deprecated 100.1.6 DataProvider used directly without IndexIterator * @see self::$dataProvider */ private $iteratorFactory; @@ -268,7 +269,7 @@ public function __construct( /** * Rebuild whole fulltext index for all stores * - * @deprecated Please use \Magento\CatalogSearch\Model\Indexer\Fulltext::executeFull instead + * @deprecated 100.1.6 Please use \Magento\CatalogSearch\Model\Indexer\Fulltext::executeFull instead * @see \Magento\CatalogSearch\Model\Indexer\Fulltext::executeFull * @return void */ @@ -474,7 +475,7 @@ private function getChildProductsIndex($parentId, array $relatedProducts, array /** * Clean search index data for store * - * @deprecated As part of self::reindexAll() + * @deprecated 100.1.6 As part of self::reindexAll() * @param int $storeId * @return void */ @@ -488,7 +489,7 @@ protected function cleanIndex($storeId) * Retrieve EAV Config Singleton * * @return \Magento\Eav\Model\Config - * @deprecated Use $self::$eavConfig directly + * @deprecated 100.1.6 Use $self::$eavConfig directly */ protected function getEavConfig() { @@ -499,7 +500,7 @@ protected function getEavConfig() * Retrieve searchable attributes * * @param string $backendType - * @deprecated see DataProvider::getSearchableAttributes() + * @deprecated 100.2.0 see DataProvider::getSearchableAttributes() * @return \Magento\Eav\Model\Entity\Attribute[] */ protected function getSearchableAttributes($backendType = null) @@ -511,7 +512,7 @@ protected function getSearchableAttributes($backendType = null) * Retrieve searchable attribute by Id or code * * @param int|string $attribute - * @deprecated see DataProvider::getSearchableAttributes() + * @deprecated 100.2.0 see DataProvider::getSearchableAttributes() * @return \Magento\Eav\Model\Entity\Attribute */ protected function getSearchableAttribute($attribute) @@ -522,7 +523,7 @@ protected function getSearchableAttribute($attribute) /** * Returns expression for field unification * - * @deprecated Moved to \Magento\CatalogSearch\Model\Indexer\Fulltext\Action\DataProvider + * @deprecated 100.1.6 Moved to \Magento\CatalogSearch\Model\Indexer\Fulltext\Action\DataProvider * @see \Magento\CatalogSearch\Model\Indexer\Fulltext\Action\DataProvider::unifyField() * @param string $field * @param string $backendType @@ -541,7 +542,7 @@ protected function unifyField($field, $backendType = 'varchar') /** * Retrieve Product Type Instance * - * @deprecated Moved to \Magento\CatalogSearch\Model\Indexer\Fulltext\Action\DataProvider + * @deprecated 100.1.6 Moved to \Magento\CatalogSearch\Model\Indexer\Fulltext\Action\DataProvider * @see \Magento\CatalogSearch\Model\Indexer\Fulltext\Action\DataProvider::getProductTypeInstance() * @param string $typeId * @return \Magento\Catalog\Model\Product\Type\AbstractType @@ -559,7 +560,7 @@ protected function getProductTypeInstance($typeId) /** * Retrieve Product Emulator (Magento Object) * - * @deprecated Moved to \Magento\CatalogSearch\Model\Indexer\Fulltext\Action\DataProvider + * @deprecated 100.1.6 Moved to \Magento\CatalogSearch\Model\Indexer\Fulltext\Action\DataProvider * @see \Magento\CatalogSearch\Model\Indexer\Fulltext\Action\DataProvider::getProductEmulator() * @param string $typeId * @return \Magento\Framework\DataObject diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/IndexIterator.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/IndexIterator.php index 419062656a1d4..abd65c71cad62 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/IndexIterator.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/IndexIterator.php @@ -10,9 +10,10 @@ * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) - * @deprecated No more used + * @deprecated 100.1.6 No more used * @see \Magento\CatalogSearch\Model\Indexer\Fulltext\Action\Full * @api + * @since 100.0.3 */ class IndexIterator implements \Iterator { @@ -136,7 +137,8 @@ public function __construct( /** * {@inheritDoc} * - * @deprecated Since class is deprecated + * @deprecated 100.1.6 Since class is deprecated + * @since 100.0.3 */ public function current() { @@ -146,7 +148,8 @@ public function current() /** * {@inheritDoc} * - * @deprecated Since class is deprecated + * @deprecated 100.1.6 Since class is deprecated + * @since 100.0.3 */ public function next() { @@ -244,7 +247,8 @@ public function next() /** * {@inheritDoc} * - * @deprecated Since class is deprecated + * @deprecated 100.1.6 Since class is deprecated + * @since 100.0.3 */ public function key() { @@ -254,7 +258,8 @@ public function key() /** * {@inheritDoc} * - * @deprecated Since class is deprecated + * @deprecated 100.1.6 Since class is deprecated + * @since 100.0.3 */ public function valid() { @@ -264,7 +269,8 @@ public function valid() /** * {@inheritDoc} * - * @deprecated Since class is deprecated + * @deprecated 100.1.6 Since class is deprecated + * @since 100.0.3 */ public function rewind() { diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Attribute.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Attribute.php index d148ad8c3e536..83ad7acca84dc 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Attribute.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Attribute.php @@ -56,10 +56,10 @@ public function beforeSave( ) { $this->saveIsNew = $attribute->isObjectNew(); $this->saveNeedInvalidation = ( - $attribute->dataHasChangedFor('is_searchable') - || $attribute->dataHasChangedFor('is_filterable') - || $attribute->dataHasChangedFor('is_visible_in_advanced_search') - ) && ! $this->saveIsNew; + $attribute->dataHasChangedFor('is_searchable') + || $attribute->dataHasChangedFor('is_filterable') + || $attribute->dataHasChangedFor('is_visible_in_advanced_search') + ); } /** diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Processor.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Processor.php index 3889e317c5016..cd3ff62d53682 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Processor.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Processor.php @@ -11,6 +11,7 @@ /** * Class Processor * @api + * @since 100.1.0 */ class Processor extends AbstractProcessor { diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/IndexStructure.php b/app/code/Magento/CatalogSearch/Model/Indexer/IndexStructure.php index f08dc7f558f93..c46f062c1e6d8 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/IndexStructure.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/IndexStructure.php @@ -16,6 +16,7 @@ /** * @api + * @since 100.0.2 */ class IndexStructure implements IndexStructureInterface { diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/IndexStructureFactory.php b/app/code/Magento/CatalogSearch/Model/Indexer/IndexStructureFactory.php index 8e2b5a1603e32..c3c979433b273 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/IndexStructureFactory.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/IndexStructureFactory.php @@ -12,6 +12,7 @@ /** * @api + * @since 100.1.0 */ class IndexStructureFactory { @@ -19,6 +20,7 @@ class IndexStructureFactory * Object Manager instance * * @var ObjectManagerInterface + * @since 100.1.0 */ protected $objectManager = null; @@ -26,6 +28,7 @@ class IndexStructureFactory * Instance name to create * * @var string + * @since 100.1.0 */ protected $structures = null; @@ -66,6 +69,7 @@ public function __construct( * * @param array $data * @return IndexStructureInterface + * @since 100.1.0 */ public function create(array $data = []) { diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/IndexSwitcherInterface.php b/app/code/Magento/CatalogSearch/Model/Indexer/IndexSwitcherInterface.php index c44ad052aa1ac..bdb663a0b616d 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/IndexSwitcherInterface.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/IndexSwitcherInterface.php @@ -8,6 +8,7 @@ /** * Provides a functionality to replace main index with its temporary representation * @api + * @since 100.2.0 */ interface IndexSwitcherInterface { @@ -18,6 +19,7 @@ interface IndexSwitcherInterface * * @param array $dimensions * @return void + * @since 100.2.0 */ public function switchIndex(array $dimensions); } diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/IndexerHandler.php b/app/code/Magento/CatalogSearch/Model/Indexer/IndexerHandler.php index 607197b11a609..ea5bb8be17c74 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/IndexerHandler.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/IndexerHandler.php @@ -15,6 +15,7 @@ /** * @api + * @since 100.0.2 */ class IndexerHandler implements IndexerInterface { diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/IndexerHandlerFactory.php b/app/code/Magento/CatalogSearch/Model/Indexer/IndexerHandlerFactory.php index 4c613e64dd75b..9b0a37bbc7152 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/IndexerHandlerFactory.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/IndexerHandlerFactory.php @@ -12,6 +12,7 @@ /** * @api + * @since 100.0.2 */ class IndexerHandlerFactory { diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/ProductFieldset.php b/app/code/Magento/CatalogSearch/Model/Indexer/ProductFieldset.php index e2806a7aaf31b..343dc50d604bc 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/ProductFieldset.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/ProductFieldset.php @@ -12,6 +12,7 @@ /** * @api + * @since 100.0.2 */ class ProductFieldset implements \Magento\Framework\Indexer\FieldsetInterface { diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Scope/IndexTableNotExistException.php b/app/code/Magento/CatalogSearch/Model/Indexer/Scope/IndexTableNotExistException.php index 62ddd76b422c4..a386b74084af3 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Scope/IndexTableNotExistException.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Scope/IndexTableNotExistException.php @@ -13,6 +13,7 @@ * but it does not exist in a database * * @api + * @since 100.2.0 */ class IndexTableNotExistException extends LocalizedException { diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Scope/UnknownStateException.php b/app/code/Magento/CatalogSearch/Model/Indexer/Scope/UnknownStateException.php index 728342ce29986..b44a2d220545c 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Scope/UnknownStateException.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Scope/UnknownStateException.php @@ -12,6 +12,7 @@ * Exception for situation where used state which is not defined in configuration * * @api + * @since 100.2.0 */ class UnknownStateException extends LocalizedException { diff --git a/app/code/Magento/CatalogSearch/Model/Layer/Filter/Price.php b/app/code/Magento/CatalogSearch/Model/Layer/Filter/Price.php index 9f54bd279d906..108f1b9f4fd8d 100644 --- a/app/code/Magento/CatalogSearch/Model/Layer/Filter/Price.php +++ b/app/code/Magento/CatalogSearch/Model/Layer/Filter/Price.php @@ -175,6 +175,9 @@ public function getCurrencyRate() */ protected function _renderRangeLabel($fromPrice, $toPrice) { + $fromPrice = empty($fromPrice) ? 0 : $fromPrice * $this->getCurrencyRate(); + $toPrice = empty($toPrice) ? $toPrice : $toPrice * $this->getCurrencyRate(); + $formattedFromPrice = $this->priceCurrency->format($fromPrice); if ($toPrice === '') { return __('%1 and above', $formattedFromPrice); @@ -261,10 +264,7 @@ private function prepareData($key, $count) if ($to == '*') { $to = $this->getTo($to); } - $label = $this->_renderRangeLabel( - empty($from) ? 0 : $from * $this->getCurrencyRate(), - empty($to) ? $to : $to * $this->getCurrencyRate() - ); + $label = $this->_renderRangeLabel($from, $to); $value = $from . '-' . $to . $this->dataProvider->getAdditionalRequestData(); $data = [ diff --git a/app/code/Magento/CatalogSearch/Model/ResourceModel/Advanced.php b/app/code/Magento/CatalogSearch/Model/ResourceModel/Advanced.php index 9d1908404230b..8a5a6372bb22f 100644 --- a/app/code/Magento/CatalogSearch/Model/ResourceModel/Advanced.php +++ b/app/code/Magento/CatalogSearch/Model/ResourceModel/Advanced.php @@ -10,6 +10,7 @@ * * @author Magento Core Team * @api + * @since 100.0.2 */ class Advanced extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { diff --git a/app/code/Magento/CatalogSearch/Model/ResourceModel/Advanced/Collection.php b/app/code/Magento/CatalogSearch/Model/ResourceModel/Advanced/Collection.php index 0388b724da89e..02bc3e2bc2400 100644 --- a/app/code/Magento/CatalogSearch/Model/ResourceModel/Advanced/Collection.php +++ b/app/code/Magento/CatalogSearch/Model/ResourceModel/Advanced/Collection.php @@ -22,6 +22,7 @@ * @author Magento Core Team * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @api + * @since 100.0.2 */ class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection { diff --git a/app/code/Magento/CatalogSearch/Model/ResourceModel/EngineInterface.php b/app/code/Magento/CatalogSearch/Model/ResourceModel/EngineInterface.php index 57ee65ae239c4..df1f9c89791f6 100644 --- a/app/code/Magento/CatalogSearch/Model/ResourceModel/EngineInterface.php +++ b/app/code/Magento/CatalogSearch/Model/ResourceModel/EngineInterface.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ interface EngineInterface { diff --git a/app/code/Magento/CatalogSearch/Model/ResourceModel/EngineProvider.php b/app/code/Magento/CatalogSearch/Model/ResourceModel/EngineProvider.php index 1940b7590ea2e..6b0ac40ee9d22 100644 --- a/app/code/Magento/CatalogSearch/Model/ResourceModel/EngineProvider.php +++ b/app/code/Magento/CatalogSearch/Model/ResourceModel/EngineProvider.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class EngineProvider { diff --git a/app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext.php b/app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext.php index 2137d0e3daad8..15349e91c3fe9 100644 --- a/app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext.php +++ b/app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext.php @@ -13,6 +13,7 @@ * CatalogSearch Fulltext Index resource model * * @api + * @since 100.0.2 */ class Fulltext extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { @@ -75,6 +76,7 @@ public function resetSearchResults() * * @param int|array $childIds * @return array + * @since 100.2.0 */ public function getRelationsByChild($childIds) { diff --git a/app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext/Collection.php b/app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext/Collection.php index 4ca0debbcab74..fce0eb3871d63 100644 --- a/app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext/Collection.php +++ b/app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext/Collection.php @@ -23,12 +23,13 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * * @api + * @since 100.0.2 */ class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection { /** * @var QueryResponse - * @deprecated + * @deprecated 100.1.0 */ protected $queryResponse; @@ -36,19 +37,19 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection * Catalog search data * * @var \Magento\Search\Model\QueryFactory - * @deprecated + * @deprecated 100.1.0 */ protected $queryFactory = null; /** * @var \Magento\Framework\Search\Request\Builder - * @deprecated + * @deprecated 100.1.0 */ private $requestBuilder; /** * @var \Magento\Search\Model\SearchEngine - * @deprecated + * @deprecated 100.1.0 */ private $searchEngine; @@ -197,7 +198,7 @@ public function __construct( } /** - * @deprecated + * @deprecated 100.1.0 * @return \Magento\Search\Api\SearchInterface */ private function getSearch() @@ -209,9 +210,10 @@ private function getSearch() } /** - * @deprecated + * @deprecated 100.1.0 * @param \Magento\Search\Api\SearchInterface $object * @return void + * @since 100.1.0 */ public function setSearch(\Magento\Search\Api\SearchInterface $object) { @@ -219,7 +221,7 @@ public function setSearch(\Magento\Search\Api\SearchInterface $object) } /** - * @deprecated + * @deprecated 100.1.0 * @return \Magento\Framework\Api\Search\SearchCriteriaBuilder */ private function getSearchCriteriaBuilder() @@ -232,9 +234,10 @@ private function getSearchCriteriaBuilder() } /** - * @deprecated + * @deprecated 100.1.0 * @param \Magento\Framework\Api\Search\SearchCriteriaBuilder $object * @return void + * @since 100.1.0 */ public function setSearchCriteriaBuilder(\Magento\Framework\Api\Search\SearchCriteriaBuilder $object) { @@ -242,7 +245,7 @@ public function setSearchCriteriaBuilder(\Magento\Framework\Api\Search\SearchCri } /** - * @deprecated + * @deprecated 100.1.0 * @return \Magento\Framework\Api\FilterBuilder */ private function getFilterBuilder() @@ -254,9 +257,10 @@ private function getFilterBuilder() } /** - * @deprecated + * @deprecated 100.1.0 * @param \Magento\Framework\Api\FilterBuilder $object * @return void + * @since 100.1.0 */ public function setFilterBuilder(\Magento\Framework\Api\FilterBuilder $object) { diff --git a/app/code/Magento/CatalogSearch/Model/ResourceModel/Search/Collection.php b/app/code/Magento/CatalogSearch/Model/ResourceModel/Search/Collection.php index 3caf275ebfbff..ae9311b452627 100644 --- a/app/code/Magento/CatalogSearch/Model/ResourceModel/Search/Collection.php +++ b/app/code/Magento/CatalogSearch/Model/ResourceModel/Search/Collection.php @@ -13,6 +13,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @api + * @since 100.0.2 */ class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection implements \Magento\Search\Model\SearchCollectionInterface { diff --git a/app/code/Magento/CatalogSearch/Model/Search/Catalog.php b/app/code/Magento/CatalogSearch/Model/Search/Catalog.php index 6589ffc76691b..4572336d761ed 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/Catalog.php +++ b/app/code/Magento/CatalogSearch/Model/Search/Catalog.php @@ -10,7 +10,7 @@ /** * Search model for backend search * - * @deprecated + * @deprecated 100.2.0 */ class Catalog extends \Magento\Framework\DataObject { diff --git a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/FilterStrategyInterface.php b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/FilterStrategyInterface.php index 4d96f92397e8a..b59f7eeec9773 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/FilterStrategyInterface.php +++ b/app/code/Magento/CatalogSearch/Model/Search/FilterMapper/FilterStrategyInterface.php @@ -9,6 +9,7 @@ /** * FilterStrategyInterface provides the interface to work with strategies * @api + * @since 100.1.6 */ interface FilterStrategyInterface { @@ -16,6 +17,7 @@ interface FilterStrategyInterface * @param \Magento\Framework\Search\Request\FilterInterface $filter * @param \Magento\Framework\DB\Select $select * @return bool is filter was applied + * @since 100.1.6 */ public function apply( \Magento\Framework\Search\Request\FilterInterface $filter, diff --git a/app/code/Magento/CatalogSearch/Model/Search/RequestGenerator.php b/app/code/Magento/CatalogSearch/Model/Search/RequestGenerator.php index c84209ec2a41f..6f6a5eed642e7 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/RequestGenerator.php +++ b/app/code/Magento/CatalogSearch/Model/Search/RequestGenerator.php @@ -15,6 +15,7 @@ /** * @api + * @since 100.0.2 */ class RequestGenerator { diff --git a/app/code/Magento/CatalogSearch/Model/Search/RequestGenerator/GeneratorInterface.php b/app/code/Magento/CatalogSearch/Model/Search/RequestGenerator/GeneratorInterface.php index 17799465f1305..a7379eaa0bd29 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/RequestGenerator/GeneratorInterface.php +++ b/app/code/Magento/CatalogSearch/Model/Search/RequestGenerator/GeneratorInterface.php @@ -10,6 +10,7 @@ /** * @api + * @since 100.1.6 */ interface GeneratorInterface { @@ -18,6 +19,7 @@ interface GeneratorInterface * @param Attribute $attribute * @param string $filterName * @return array + * @since 100.1.6 */ public function getFilterData(Attribute $attribute, $filterName); @@ -26,6 +28,7 @@ public function getFilterData(Attribute $attribute, $filterName); * @param Attribute $attribute * @param string $bucketName * @return array + * @since 100.1.6 */ public function getAggregationData(Attribute $attribute, $bucketName); } diff --git a/app/code/Magento/CatalogSearch/Model/Search/RequestGenerator/GeneratorResolver.php b/app/code/Magento/CatalogSearch/Model/Search/RequestGenerator/GeneratorResolver.php index 5bf27308a770d..d2841e5cdf321 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/RequestGenerator/GeneratorResolver.php +++ b/app/code/Magento/CatalogSearch/Model/Search/RequestGenerator/GeneratorResolver.php @@ -8,6 +8,7 @@ /** * @api + * @since 100.1.6 */ class GeneratorResolver { @@ -35,6 +36,7 @@ public function __construct(GeneratorInterface $defaultGenerator, array $generat * @param string $type * @return GeneratorInterface * @throws \InvalidArgumentException + * @since 100.1.6 */ public function getGeneratorForType($type) { diff --git a/app/code/Magento/CatalogSearch/Model/Search/TableMapper.php b/app/code/Magento/CatalogSearch/Model/Search/TableMapper.php index b44c1325ef3df..eab79c22309f0 100644 --- a/app/code/Magento/CatalogSearch/Model/Search/TableMapper.php +++ b/app/code/Magento/CatalogSearch/Model/Search/TableMapper.php @@ -24,6 +24,7 @@ * which will apply them to the Select * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @api + * @since 100.0.2 */ class TableMapper { @@ -105,7 +106,7 @@ public function addTables(Select $select, RequestInterface $request) * This method is deprecated. * Please use \Magento\CatalogSearch\Model\Adapter\Mysql\Filter\AliasResolver::getAlias() instead. * - * @deprecated + * @deprecated 100.1.6 * @see AliasResolver::getAlias() * * @param FilterInterface $filter diff --git a/app/code/Magento/CatalogSearch/Model/Source/Weight.php b/app/code/Magento/CatalogSearch/Model/Source/Weight.php index b3976c370bee5..495e1a4567d63 100644 --- a/app/code/Magento/CatalogSearch/Model/Source/Weight.php +++ b/app/code/Magento/CatalogSearch/Model/Source/Weight.php @@ -8,6 +8,7 @@ /** * Attribute weight options * @api + * @since 100.0.2 */ class Weight implements \Magento\Framework\Data\OptionSourceInterface { @@ -15,6 +16,7 @@ class Weight implements \Magento\Framework\Data\OptionSourceInterface * Quick search weights * * @var int[] + * @since 100.1.0 */ protected $weights = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']; @@ -46,6 +48,7 @@ public function getValues() * Return array of options as value-label pairs * * @return array Format: array(array('value' => '', 'label' => ' + + + + Magento\CatalogSearch\Model\Indexer\Fulltext::INDEXER_ID + + + diff --git a/app/code/Magento/CatalogUrlRewrite/Model/Category/CanonicalUrlRewriteGenerator.php b/app/code/Magento/CatalogUrlRewrite/Model/Category/CanonicalUrlRewriteGenerator.php index 02bc6c36cced6..b21968945a4d6 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/Category/CanonicalUrlRewriteGenerator.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/Category/CanonicalUrlRewriteGenerator.php @@ -12,10 +12,14 @@ class CanonicalUrlRewriteGenerator { - /** @var \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator */ + /** + * @var \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator + */ protected $categoryUrlPathGenerator; - /** @var \Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory */ + /** + * @var \Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory + */ protected $urlRewriteFactory; /** diff --git a/app/code/Magento/CatalogUrlRewrite/Model/Category/ChildrenCategoriesProvider.php b/app/code/Magento/CatalogUrlRewrite/Model/Category/ChildrenCategoriesProvider.php index 9bd138e43bccf..569de155c6e3a 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/Category/ChildrenCategoriesProvider.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/Category/ChildrenCategoriesProvider.php @@ -9,7 +9,9 @@ class ChildrenCategoriesProvider { - /** @var array */ + /** + * @var array + */ protected $childrenIds = []; /** diff --git a/app/code/Magento/CatalogUrlRewrite/Model/Category/ChildrenUrlRewriteGenerator.php b/app/code/Magento/CatalogUrlRewrite/Model/Category/ChildrenUrlRewriteGenerator.php index 9a2a6633ca349..6aa33f37cd31f 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/Category/ChildrenUrlRewriteGenerator.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/Category/ChildrenUrlRewriteGenerator.php @@ -13,13 +13,19 @@ class ChildrenUrlRewriteGenerator { - /** @var \Magento\CatalogUrlRewrite\Model\Category\ChildrenCategoriesProvider */ + /** + * @var \Magento\CatalogUrlRewrite\Model\Category\ChildrenCategoriesProvider + */ protected $childrenCategoriesProvider; - /** @var \Magento\CatalogUrlRewrite\Model\CategoryUrlRewriteGeneratorFactory */ + /** + * @var \Magento\CatalogUrlRewrite\Model\CategoryUrlRewriteGeneratorFactory + */ protected $categoryUrlRewriteGeneratorFactory; - /** @var \Magento\UrlRewrite\Model\MergeDataProvider */ + /** + * @var \Magento\UrlRewrite\Model\MergeDataProvider + */ private $mergeDataProviderPrototype; /** diff --git a/app/code/Magento/CatalogUrlRewrite/Model/Category/CurrentUrlRewritesRegenerator.php b/app/code/Magento/CatalogUrlRewrite/Model/Category/CurrentUrlRewritesRegenerator.php index 98f6b463c5576..f8d9ddf0c4ad9 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/Category/CurrentUrlRewritesRegenerator.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/Category/CurrentUrlRewritesRegenerator.php @@ -10,31 +10,41 @@ class CurrentUrlRewritesRegenerator { - /** @var \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator */ + /** + * @var \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator + */ protected $categoryUrlPathGenerator; - /** @var \Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory */ + /** + * @var \Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory + */ protected $urlRewriteFactory; - /** @var \Magento\UrlRewrite\Service\V1\Data\UrlRewrite */ + /** + * @var \Magento\UrlRewrite\Service\V1\Data\UrlRewrite + */ private $urlRewritePrototype; /** * @var \Magento\Catalog\Model\Category - * @deprecated + * @deprecated 100.1.4 */ protected $category; /** * @var \Magento\UrlRewrite\Model\UrlFinderInterface - * @deprecated + * @deprecated 100.1.4 */ protected $urlFinder; - /** @var \Magento\CatalogUrlRewrite\Model\Map\UrlRewriteFinder */ + /** + * @var \Magento\CatalogUrlRewrite\Model\Map\UrlRewriteFinder + */ private $urlRewriteFinder; - /** @var \Magento\UrlRewrite\Model\MergeDataProvider */ + /** + * @var \Magento\UrlRewrite\Model\MergeDataProvider + */ private $mergeDataProviderPrototype; /** diff --git a/app/code/Magento/CatalogUrlRewrite/Model/Category/Plugin/Category/Move.php b/app/code/Magento/CatalogUrlRewrite/Model/Category/Plugin/Category/Move.php index a5d4f124c6772..17d12ba563ebd 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/Category/Plugin/Category/Move.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/Category/Plugin/Category/Move.php @@ -11,7 +11,9 @@ class Move { - /** @var CategoryUrlPathGenerator */ + /** + * @var \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator + */ protected $categoryUrlPathGenerator; /** diff --git a/app/code/Magento/CatalogUrlRewrite/Model/Category/Plugin/Category/Remove.php b/app/code/Magento/CatalogUrlRewrite/Model/Category/Plugin/Category/Remove.php index 99728cbb7bf20..d02351acae31b 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/Category/Plugin/Category/Remove.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/Category/Plugin/Category/Remove.php @@ -9,16 +9,24 @@ class Remove { - /** @var \Magento\UrlRewrite\Model\UrlPersistInterface */ + /** + * @var \Magento\UrlRewrite\Model\UrlPersistInterface + */ protected $urlPersist; - /** @var \Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator */ + /** + * @var \Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator + */ protected $productUrlRewriteGenerator; - /** @var \Magento\CatalogUrlRewrite\Model\Category\ChildrenCategoriesProvider */ + /** + * @var \Magento\CatalogUrlRewrite\Model\Category\ChildrenCategoriesProvider + */ protected $childrenCategoriesProvider; - /** @var \Magento\Framework\Serialize\Serializer\Json */ + /** + * @var \Magento\Framework\Serialize\Serializer\Json + */ private $serializer; /** diff --git a/app/code/Magento/CatalogUrlRewrite/Model/Category/Plugin/Storage.php b/app/code/Magento/CatalogUrlRewrite/Model/Category/Plugin/Storage.php index db24b485b0383..572152e84b2d7 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/Category/Plugin/Storage.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/Category/Plugin/Storage.php @@ -13,10 +13,14 @@ class Storage { - /** @var UrlFinderInterface */ + /** + * @var \Magento\UrlRewrite\Model\UrlFinderInterface + */ private $urlFinder; - /** @var Product */ + /** + * @var \Magento\CatalogUrlRewrite\Model\ResourceModel\Category\Product + */ private $productResource; /** diff --git a/app/code/Magento/CatalogUrlRewrite/Model/Category/Plugin/Store/Group.php b/app/code/Magento/CatalogUrlRewrite/Model/Category/Plugin/Store/Group.php index 58c747fb30d6b..1dbfad6cf5219 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/Category/Plugin/Store/Group.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/Category/Plugin/Store/Group.php @@ -20,22 +20,34 @@ */ class Group { - /** @var UrlPersistInterface */ + /** + * @var \Magento\UrlRewrite\Model\UrlPersistInterface + */ protected $urlPersist; - /** @var CategoryFactory */ + /** + * @var \Magento\Catalog\Model\CategoryFactory + */ protected $categoryFactory; - /** @var ProductFactory */ + /** + * @var \Magento\Catalog\Model\ProductFactory + */ protected $productFactory; - /** @var CategoryUrlRewriteGenerator */ + /** + * @var \Magento\CatalogUrlRewrite\Model\CategoryUrlRewriteGenerator + */ protected $categoryUrlRewriteGenerator; - /** @var ProductUrlRewriteGenerator */ + /** + * @var \Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator + */ protected $productUrlRewriteGenerator; - /** @var StoreManagerInterface */ + /** + * @var \Magento\Store\Model\StoreManagerInterface + */ protected $storeManager; /** diff --git a/app/code/Magento/CatalogUrlRewrite/Model/Category/Plugin/Store/View.php b/app/code/Magento/CatalogUrlRewrite/Model/Category/Plugin/Store/View.php index 8ac98ee34161f..f8bf00b16cf37 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/Category/Plugin/Store/View.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/Category/Plugin/Store/View.php @@ -23,19 +23,29 @@ */ class View { - /** @var UrlPersistInterface */ + /** + * @var \Magento\UrlRewrite\Model\UrlPersistInterface + */ protected $urlPersist; - /** @var CategoryFactory */ + /** + * @var \Magento\Catalog\Model\CategoryFactory + */ protected $categoryFactory; - /** @var ProductFactory */ + /** + * @var \Magento\Catalog\Model\ProductFactory + */ protected $productFactory; - /** @var CategoryUrlRewriteGenerator */ + /** + * @var \Magento\CatalogUrlRewrite\Model\CategoryUrlRewriteGenerator + */ protected $categoryUrlRewriteGenerator; - /** @var ProductUrlRewriteGenerator */ + /** + * @var \Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator + */ protected $productUrlRewriteGenerator; /** diff --git a/app/code/Magento/CatalogUrlRewrite/Model/CategoryUrlPathGenerator.php b/app/code/Magento/CatalogUrlRewrite/Model/CategoryUrlPathGenerator.php index 8e36cc9bf1566..ee20b0e934b5d 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/CategoryUrlPathGenerator.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/CategoryUrlPathGenerator.php @@ -27,10 +27,14 @@ class CategoryUrlPathGenerator */ protected $categoryUrlSuffix = []; - /** @var \Magento\Framework\App\Config\ScopeConfigInterface */ + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface + */ protected $scopeConfig; - /** @var \Magento\Store\Model\StoreManagerInterface */ + /** + * @var \Magento\Store\Model\StoreManagerInterface + */ protected $storeManager; /** diff --git a/app/code/Magento/CatalogUrlRewrite/Model/CategoryUrlRewriteGenerator.php b/app/code/Magento/CatalogUrlRewrite/Model/CategoryUrlRewriteGenerator.php index cfb01b774102e..b2da0ab39f31f 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/CategoryUrlRewriteGenerator.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/CategoryUrlRewriteGenerator.php @@ -20,25 +20,35 @@ class CategoryUrlRewriteGenerator /** Entity type code */ const ENTITY_TYPE = 'category'; - /** @var StoreViewService */ + /** + * @var \Magento\CatalogUrlRewrite\Service\V1\StoreViewService + */ protected $storeViewService; /** * @var \Magento\Catalog\Model\Category - * @deprecated + * @deprecated 100.1.4 */ protected $category; - /** @var \Magento\CatalogUrlRewrite\Model\Category\CanonicalUrlRewriteGenerator */ + /** + * @var \Magento\CatalogUrlRewrite\Model\Category\CanonicalUrlRewriteGenerator + */ protected $canonicalUrlRewriteGenerator; - /** @var \Magento\CatalogUrlRewrite\Model\Category\CurrentUrlRewritesRegenerator */ + /** + * @var \Magento\CatalogUrlRewrite\Model\Category\CurrentUrlRewritesRegenerator + */ protected $currentUrlRewritesRegenerator; - /** @var \Magento\CatalogUrlRewrite\Model\Category\ChildrenUrlRewriteGenerator */ + /** + * @var \Magento\CatalogUrlRewrite\Model\Category\ChildrenUrlRewriteGenerator + */ protected $childrenUrlRewriteGenerator; - /** @var \Magento\UrlRewrite\Model\MergeDataProvider */ + /** + * @var \Magento\UrlRewrite\Model\MergeDataProvider + */ private $mergeDataProviderPrototype; /** diff --git a/app/code/Magento/CatalogUrlRewrite/Model/Map/DataCategoryHashMap.php b/app/code/Magento/CatalogUrlRewrite/Model/Map/DataCategoryHashMap.php index 5e78d9030a3b1..cb9f3fecb4bca 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/Map/DataCategoryHashMap.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/Map/DataCategoryHashMap.php @@ -14,13 +14,19 @@ */ class DataCategoryHashMap implements HashMapInterface { - /** @var int[] */ + /** + * @var int[] + */ private $hashMap = []; - /** @var CategoryRepository */ + /** + * @var \Magento\Catalog\Model\CategoryRepository + */ private $categoryRepository; - /** @var CategoryFactory */ + /** + * @var \Magento\Catalog\Model\ResourceModel\CategoryFactory + */ private $categoryResourceFactory; /** diff --git a/app/code/Magento/CatalogUrlRewrite/Model/Map/DataCategoryUrlRewriteDatabaseMap.php b/app/code/Magento/CatalogUrlRewrite/Model/Map/DataCategoryUrlRewriteDatabaseMap.php index 0ecd1d4a72da9..6e28b831e1059 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/Map/DataCategoryUrlRewriteDatabaseMap.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/Map/DataCategoryUrlRewriteDatabaseMap.php @@ -17,16 +17,24 @@ class DataCategoryUrlRewriteDatabaseMap implements DatabaseMapInterface { const ENTITY_TYPE = 'category'; - /** @var string[] */ + /** + * @var string[] + */ private $createdTableAdapters = []; - /** @var HashMapPool */ + /** + * @var \Magento\CatalogUrlRewrite\Model\Map\HashMapPool + */ private $hashMapPool; - /** @var ResourceConnection */ + /** + * @var \Magento\Framework\App\ResourceConnection + */ private $connection; - /** @var TemporaryTableService */ + /** + * @var \Magento\Framework\DB\TemporaryTableService + */ private $temporaryTableService; /** diff --git a/app/code/Magento/CatalogUrlRewrite/Model/Map/DataCategoryUsedInProductsHashMap.php b/app/code/Magento/CatalogUrlRewrite/Model/Map/DataCategoryUsedInProductsHashMap.php index 703c1b86d2a0d..a70f533fbe5ba 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/Map/DataCategoryUsedInProductsHashMap.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/Map/DataCategoryUsedInProductsHashMap.php @@ -12,13 +12,19 @@ */ class DataCategoryUsedInProductsHashMap implements HashMapInterface { - /** @var int[] */ + /** + * @var int[] + */ private $hashMap = []; - /** @var HashMapPool */ + /** + * @var \Magento\CatalogUrlRewrite\Model\Map\HashMapPool + */ private $hashMapPool; - /** @var ResourceConnection */ + /** + * @var \Magento\Framework\App\ResourceConnection + */ private $connection; /** diff --git a/app/code/Magento/CatalogUrlRewrite/Model/Map/DataProductHashMap.php b/app/code/Magento/CatalogUrlRewrite/Model/Map/DataProductHashMap.php index acec1675bdf5c..39e4c1f0f2012 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/Map/DataProductHashMap.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/Map/DataProductHashMap.php @@ -13,16 +13,24 @@ */ class DataProductHashMap implements HashMapInterface { - /** @var int[] */ + /** + * @var int[] + */ private $hashMap = []; - /** @var CollectionFactory */ + /** + * @var \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory + */ private $collectionFactory; - /** @var HashMapPool */ + /** + * @var \Magento\CatalogUrlRewrite\Model\Map\HashMapPool + */ private $hashMapPool; - /** @var ResourceConnection */ + /** + * @var \Magento\Framework\App\ResourceConnection + */ private $connection; /** diff --git a/app/code/Magento/CatalogUrlRewrite/Model/Map/DataProductUrlRewriteDatabaseMap.php b/app/code/Magento/CatalogUrlRewrite/Model/Map/DataProductUrlRewriteDatabaseMap.php index 1d74b77c520ae..fe6bb065b0808 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/Map/DataProductUrlRewriteDatabaseMap.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/Map/DataProductUrlRewriteDatabaseMap.php @@ -17,16 +17,24 @@ class DataProductUrlRewriteDatabaseMap implements DatabaseMapInterface { const ENTITY_TYPE = 'product'; - /** @var string[] */ + /** + * @var string[] + */ private $createdTableAdapters = []; - /** @var HashMapPool */ + /** + * @var \Magento\CatalogUrlRewrite\Model\Map\HashMapPool + */ private $hashMapPool; - /** @var ResourceConnection */ + /** + * @var \Magento\Framework\App\ResourceConnection + */ private $connection; - /** @var TemporaryTableService */ + /** + * @var \Magento\Framework\DB\TemporaryTableService + */ private $temporaryTableService; /** diff --git a/app/code/Magento/CatalogUrlRewrite/Model/Map/UrlRewriteFinder.php b/app/code/Magento/CatalogUrlRewrite/Model/Map/UrlRewriteFinder.php index 864e4a6b98e67..1f7af490c029d 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/Map/UrlRewriteFinder.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/Map/UrlRewriteFinder.php @@ -22,16 +22,24 @@ class UrlRewriteFinder const ENTITY_TYPE_CATEGORY = 'category'; const ENTITY_TYPE_PRODUCT = 'product'; - /** @var DatabaseMapPool */ + /** + * @var \Magento\CatalogUrlRewrite\Model\Map\DatabaseMapPool + */ private $databaseMapPool; - /** @var UrlFinderInterface */ + /** + * @var \Magento\UrlRewrite\Model\UrlFinderInterface + */ private $urlFinder; - /** @var UrlRewrite */ + /** + * @var \Magento\UrlRewrite\Service\V1\Data\UrlRewrite + */ private $urlRewritePrototype; - /** @var array */ + /** + * @var array + */ private $urlRewriteClassNames = []; /** diff --git a/app/code/Magento/CatalogUrlRewrite/Model/Product/AnchorUrlRewriteGenerator.php b/app/code/Magento/CatalogUrlRewrite/Model/Product/AnchorUrlRewriteGenerator.php index 77ea3e1c312e1..a7cc894c9a022 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/Product/AnchorUrlRewriteGenerator.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/Product/AnchorUrlRewriteGenerator.php @@ -16,13 +16,19 @@ class AnchorUrlRewriteGenerator { - /** @var ProductUrlPathGenerator */ + /** + * @var \Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator + */ protected $urlPathGenerator; - /** @var UrlRewriteFactory */ + /** + * @var \Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory + */ protected $urlRewriteFactory; - /** @var CategoryRepositoryInterface */ + /** + * @var \Magento\Catalog\Api\CategoryRepositoryInterface + */ private $categoryRepository; /** diff --git a/app/code/Magento/CatalogUrlRewrite/Model/Product/CanonicalUrlRewriteGenerator.php b/app/code/Magento/CatalogUrlRewrite/Model/Product/CanonicalUrlRewriteGenerator.php index 41e1a880d7ad7..1622824d15680 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/Product/CanonicalUrlRewriteGenerator.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/Product/CanonicalUrlRewriteGenerator.php @@ -13,10 +13,14 @@ class CanonicalUrlRewriteGenerator { - /** @var ProductUrlPathGenerator */ + /** + * @var \Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator + */ protected $productUrlPathGenerator; - /** @var UrlRewriteFactory */ + /** + * @var \Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory + */ protected $urlRewriteFactory; /** diff --git a/app/code/Magento/CatalogUrlRewrite/Model/Product/CategoriesUrlRewriteGenerator.php b/app/code/Magento/CatalogUrlRewrite/Model/Product/CategoriesUrlRewriteGenerator.php index ddad00b42a1da..9e787e74ae073 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/Product/CategoriesUrlRewriteGenerator.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/Product/CategoriesUrlRewriteGenerator.php @@ -14,10 +14,14 @@ class CategoriesUrlRewriteGenerator { - /** @var ProductUrlPathGenerator */ + /** + * @var \Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator + */ protected $productUrlPathGenerator; - /** @var UrlRewriteFactory */ + /** + * @var \Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory + */ protected $urlRewriteFactory; /** diff --git a/app/code/Magento/CatalogUrlRewrite/Model/Product/CurrentUrlRewritesRegenerator.php b/app/code/Magento/CatalogUrlRewrite/Model/Product/CurrentUrlRewritesRegenerator.php index d163ef8f067f3..42d3fd9cb40e1 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/Product/CurrentUrlRewritesRegenerator.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/Product/CurrentUrlRewritesRegenerator.php @@ -26,38 +26,50 @@ class CurrentUrlRewritesRegenerator { /** * @var Product - * @deprecated + * @deprecated 100.1.4 */ protected $product; /** * @var ObjectRegistry - * @deprecated + * @deprecated 100.1.4 */ protected $productCategories; /** * @var UrlFinderInterface - * @deprecated + * @deprecated 100.1.4 */ protected $urlFinder; - /** @var ProductUrlPathGenerator */ + /** + * @var \Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator + */ protected $productUrlPathGenerator; - /** @var UrlRewriteFactory */ + /** + * @var \Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory + */ protected $urlRewriteFactory; - /** @var UrlRewrite */ + /** + * @var \Magento\UrlRewrite\Service\V1\Data\UrlRewrite + */ private $urlRewritePrototype; - /** @var UrlRewriteFinder */ + /** + * @var \Magento\CatalogUrlRewrite\Model\Map\UrlRewriteFinder + */ private $urlRewriteFinder; - /** @var \Magento\UrlRewrite\Model\MergeDataProvider */ + /** + * @var \Magento\UrlRewrite\Model\MergeDataProvider + */ private $mergeDataProviderPrototype; - /** @var CategoryRepository */ + /** + * @var \Magento\Catalog\Model\CategoryRepository + */ private $categoryRepository; /** diff --git a/app/code/Magento/CatalogUrlRewrite/Model/ProductScopeRewriteGenerator.php b/app/code/Magento/CatalogUrlRewrite/Model/ProductScopeRewriteGenerator.php index 2795bb02e9612..81bbb08b0f39e 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/ProductScopeRewriteGenerator.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/ProductScopeRewriteGenerator.php @@ -5,17 +5,18 @@ */ namespace Magento\CatalogUrlRewrite\Model; +use Magento\Catalog\Api\CategoryRepositoryInterface; use Magento\Catalog\Model\Category; use Magento\Catalog\Model\Product; +use Magento\CatalogUrlRewrite\Model\Product\AnchorUrlRewriteGenerator; use Magento\CatalogUrlRewrite\Model\Product\CanonicalUrlRewriteGenerator; use Magento\CatalogUrlRewrite\Model\Product\CategoriesUrlRewriteGenerator; use Magento\CatalogUrlRewrite\Model\Product\CurrentUrlRewritesRegenerator; -use Magento\CatalogUrlRewrite\Model\Product\AnchorUrlRewriteGenerator; use Magento\CatalogUrlRewrite\Service\V1\StoreViewService; +use Magento\Framework\App\ObjectManager; use Magento\Store\Model\Store; use Magento\Store\Model\StoreManagerInterface; use Magento\UrlRewrite\Model\MergeDataProviderFactory; -use Magento\Framework\App\ObjectManager; /** * Class ProductScopeRewriteGenerator @@ -58,9 +59,16 @@ class ProductScopeRewriteGenerator */ private $canonicalUrlRewriteGenerator; - /** @var \Magento\UrlRewrite\Model\MergeDataProvider */ + /** + * @var \Magento\UrlRewrite\Model\MergeDataProvider + */ private $mergeDataProviderPrototype; + /** + * @var CategoryRepositoryInterface + */ + private $categoryRepository; + /** * @param StoreViewService $storeViewService * @param StoreManagerInterface $storeManager @@ -70,6 +78,7 @@ class ProductScopeRewriteGenerator * @param CurrentUrlRewritesRegenerator $currentUrlRewritesRegenerator * @param AnchorUrlRewriteGenerator $anchorUrlRewriteGenerator * @param \Magento\UrlRewrite\Model\MergeDataProviderFactory|null $mergeDataProviderFactory + * @param CategoryRepositoryInterface|null $categoryRepository */ public function __construct( StoreViewService $storeViewService, @@ -79,7 +88,8 @@ public function __construct( CategoriesUrlRewriteGenerator $categoriesUrlRewriteGenerator, CurrentUrlRewritesRegenerator $currentUrlRewritesRegenerator, AnchorUrlRewriteGenerator $anchorUrlRewriteGenerator, - MergeDataProviderFactory $mergeDataProviderFactory = null + MergeDataProviderFactory $mergeDataProviderFactory = null, + CategoryRepositoryInterface $categoryRepository = null ) { $this->storeViewService = $storeViewService; $this->storeManager = $storeManager; @@ -92,6 +102,8 @@ public function __construct( $mergeDataProviderFactory = ObjectManager::getInstance()->get(MergeDataProviderFactory::class); } $this->mergeDataProviderPrototype = $mergeDataProviderFactory->create(); + $this->categoryRepository = $categoryRepository ?: + ObjectManager::getInstance()->get(CategoryRepositoryInterface::class); } /** @@ -148,10 +160,14 @@ public function generateForSpecificStoreView($storeId, $productCategories, Produ $mergeDataProvider = clone $this->mergeDataProviderPrototype; $categories = []; foreach ($productCategories as $category) { - if ($this->isCategoryProperForGenerating($category, $storeId)) { - $categories[] = $category; + if (!$this->isCategoryProperForGenerating($category, $storeId)) { + continue; } + + // category should be loaded per appropriate store if category's URL key has been changed + $categories[] = $this->getCategoryWithOverriddenUrlKey($storeId, $category); } + $productCategories = $this->objectRegistryFactory->create(['entities' => $categories]); $mergeDataProvider->merge( @@ -197,4 +213,26 @@ public function isCategoryProperForGenerating(Category $category, $storeId) } return false; } + + /** + * Checks if URL key has been changed for provided category and returns reloaded category, + * in other case - returns provided category. + * + * @param $storeId + * @param Category $category + * @return Category + */ + private function getCategoryWithOverriddenUrlKey($storeId, Category $category) + { + $isUrlKeyOverridden = $this->storeViewService->doesEntityHaveOverriddenUrlKeyForStore( + $storeId, + $category->getEntityId(), + Category::ENTITY + ); + + if (!$isUrlKeyOverridden) { + return $category; + } + return $this->categoryRepository->get($category->getEntityId(), $storeId); + } } diff --git a/app/code/Magento/CatalogUrlRewrite/Model/ProductUrlPathGenerator.php b/app/code/Magento/CatalogUrlRewrite/Model/ProductUrlPathGenerator.php index 45a4f5f1eefd9..2e192d895c6d5 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/ProductUrlPathGenerator.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/ProductUrlPathGenerator.php @@ -18,16 +18,24 @@ class ProductUrlPathGenerator */ protected $productUrlSuffix = []; - /** @var \Magento\Store\Model\StoreManagerInterface */ + /** + * @var \Magento\Store\Model\StoreManagerInterface + */ protected $storeManager; - /** @var \Magento\Framework\App\Config\ScopeConfigInterface */ + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface + */ protected $scopeConfig; - /** @var \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator */ + /** + * @var \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator + */ protected $categoryUrlPathGenerator; - /** @var \Magento\Catalog\Api\ProductRepositoryInterface */ + /** + * @var \Magento\Catalog\Api\ProductRepositoryInterface + */ protected $productRepository; /** diff --git a/app/code/Magento/CatalogUrlRewrite/Model/ProductUrlRewriteGenerator.php b/app/code/Magento/CatalogUrlRewrite/Model/ProductUrlRewriteGenerator.php index fe25657239800..868c417b5ff52 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/ProductUrlRewriteGenerator.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/ProductUrlRewriteGenerator.php @@ -26,49 +26,49 @@ class ProductUrlRewriteGenerator const ENTITY_TYPE = 'product'; /** - * @deprecated + * @deprecated 100.1.4 * @var \Magento\CatalogUrlRewrite\Service\V1\StoreViewService */ protected $storeViewService; /** * @var \Magento\Catalog\Model\Product - * @deprecated + * @deprecated 100.1.4 */ protected $product; /** - * @deprecated + * @deprecated 100.1.4 * @var \Magento\CatalogUrlRewrite\Model\Product\CurrentUrlRewritesRegenerator */ protected $currentUrlRewritesRegenerator; /** - * @deprecated + * @deprecated 100.1.4 * @var \Magento\CatalogUrlRewrite\Model\Product\CategoriesUrlRewriteGenerator */ protected $categoriesUrlRewriteGenerator; /** - * @deprecated + * @deprecated 100.1.4 * @var \Magento\CatalogUrlRewrite\Model\Product\CanonicalUrlRewriteGenerator */ protected $canonicalUrlRewriteGenerator; /** - * @deprecated + * @deprecated 100.1.4 * @var \Magento\CatalogUrlRewrite\Model\ObjectRegistryFactory */ protected $objectRegistryFactory; /** - * @deprecated + * @deprecated 100.1.4 * @var \Magento\CatalogUrlRewrite\Model\ObjectRegistry */ protected $productCategories; /** - * @deprecated + * @deprecated 100.1.4 * @var \Magento\Store\Model\StoreManagerInterface */ protected $storeManager; @@ -105,7 +105,7 @@ public function __construct( /** * Retrieve Delegator for generation rewrites in different scopes * - * @deprecated + * @deprecated 100.1.4 * @return ProductScopeRewriteGenerator|mixed */ private function getProductScopeRewriteGenerator() @@ -147,7 +147,7 @@ public function generate(Product $product, $rootCategoryId = null) /** * Check is global scope * - * @deprecated + * @deprecated 100.1.4 * @param int|null $storeId * @return bool */ @@ -159,7 +159,7 @@ protected function isGlobalScope($storeId) /** * Generate list of urls for global scope * - * @deprecated + * @deprecated 100.1.4 * @param \Magento\Framework\Data\Collection $productCategories * @param \Magento\Catalog\Model\Product|null $product * @param int|null $rootCategoryId @@ -177,7 +177,7 @@ protected function generateForGlobalScope($productCategories, $product = null, $ /** * Generate list of urls for specific store view * - * @deprecated + * @deprecated 100.1.4 * @param int $storeId * @param \Magento\Framework\Data\Collection $productCategories * @param Product|null $product @@ -195,7 +195,7 @@ protected function generateForSpecificStoreView( } /** - * @deprecated + * @deprecated 100.1.4 * @param \Magento\Catalog\Model\Category $category * @param int $storeId * @return bool diff --git a/app/code/Magento/CatalogUrlRewrite/Observer/AfterImportDataObserver.php b/app/code/Magento/CatalogUrlRewrite/Observer/AfterImportDataObserver.php index e4c019ad9c9cd..022a78be00197 100644 --- a/app/code/Magento/CatalogUrlRewrite/Observer/AfterImportDataObserver.php +++ b/app/code/Magento/CatalogUrlRewrite/Observer/AfterImportDataObserver.php @@ -36,61 +36,99 @@ class AfterImportDataObserver implements ObserverInterface */ const URL_KEY_ATTRIBUTE_CODE = 'url_key'; - /** @var \Magento\CatalogUrlRewrite\Service\V1\StoreViewService */ + /** + * @var \Magento\CatalogUrlRewrite\Service\V1\StoreViewService + */ protected $storeViewService; - /** @var \Magento\Catalog\Model\Product */ + /** + * @var \Magento\Catalog\Model\Product + */ protected $product; - /** @var array */ + /** + * @var array + */ protected $productsWithStores; - /** @var array */ + /** + * @var array + */ protected $products = []; - /** @var \Magento\CatalogUrlRewrite\Model\ObjectRegistryFactory */ + /** + * @var \Magento\CatalogUrlRewrite\Model\ObjectRegistryFactory + */ protected $objectRegistryFactory; - /** @var \Magento\CatalogUrlRewrite\Model\ObjectRegistry */ + /** + * @var \Magento\CatalogUrlRewrite\Model\ObjectRegistry + */ protected $productCategories; - /** @var UrlFinderInterface */ + /** + * @var \Magento\UrlRewrite\Model\UrlFinderInterface + */ protected $urlFinder; - /** @var \Magento\Store\Model\StoreManagerInterface */ + /** + * @var \Magento\Store\Model\StoreManagerInterface + */ protected $storeManager; - /** @var UrlPersistInterface */ + /** + * @var \Magento\UrlRewrite\Model\UrlPersistInterface + */ protected $urlPersist; - /** @var UrlRewriteFactory */ + /** + * @var \Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory + */ protected $urlRewriteFactory; - /** @var \Magento\CatalogImportExport\Model\Import\Product */ + /** + * @var \Magento\CatalogImportExport\Model\Import\Product + */ protected $import; - /** @var \Magento\Catalog\Model\ProductFactory $catalogProductFactory */ + /** + * @var \Magento\Catalog\Model\ProductFactory + */ protected $catalogProductFactory; - /** @var array */ + /** + * @var array + */ protected $acceptableCategories; - /** @var \Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator */ + /** + * @var \Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator + */ protected $productUrlPathGenerator; - /** @var array */ + /** + * @var array + */ protected $websitesToStoreIds; - /** @var array */ + /** + * @var array + */ protected $storesCache = []; - /** @var array */ + /** + * @var array + */ protected $categoryCache = []; - /** @var array */ + /** + * @var array + */ protected $websiteCache = []; - /** @var array */ + /** + * @var array + */ protected $vitalForGenerationFields = [ 'sku', 'url_key', @@ -99,7 +137,9 @@ class AfterImportDataObserver implements ObserverInterface 'visibility', ]; - /** @var \Magento\UrlRewrite\Model\MergeDataProvider */ + /** + * @var \Magento\UrlRewrite\Model\MergeDataProvider + */ private $mergeDataProviderPrototype; /** diff --git a/app/code/Magento/CatalogUrlRewrite/Observer/CategoryProcessUrlRewriteMovingObserver.php b/app/code/Magento/CatalogUrlRewrite/Observer/CategoryProcessUrlRewriteMovingObserver.php index 008606b69918d..0afdf774c7eb1 100644 --- a/app/code/Magento/CatalogUrlRewrite/Observer/CategoryProcessUrlRewriteMovingObserver.php +++ b/app/code/Magento/CatalogUrlRewrite/Observer/CategoryProcessUrlRewriteMovingObserver.php @@ -22,25 +22,39 @@ */ class CategoryProcessUrlRewriteMovingObserver implements ObserverInterface { - /** @var \Magento\CatalogUrlRewrite\Model\CategoryUrlRewriteGenerator */ + /** + * @var \Magento\CatalogUrlRewrite\Model\CategoryUrlRewriteGenerator + */ protected $categoryUrlRewriteGenerator; - /** @var \Magento\UrlRewrite\Model\UrlPersistInterface */ + /** + * @var \Magento\UrlRewrite\Model\UrlPersistInterface + */ protected $urlPersist; - /** @var \Magento\Framework\App\Config\ScopeConfigInterface */ + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface + */ protected $scopeConfig; - /** @var \Magento\CatalogUrlRewrite\Observer\UrlRewriteHandler */ + /** + * @var \Magento\CatalogUrlRewrite\Observer\UrlRewriteHandler + */ protected $urlRewriteHandler; - /** @var \Magento\CatalogUrlRewrite\Model\UrlRewriteBunchReplacer */ + /** + * @var \Magento\CatalogUrlRewrite\Model\UrlRewriteBunchReplacer + */ private $urlRewriteBunchReplacer; - /** @var \Magento\CatalogUrlRewrite\Model\Map\DatabaseMapPool */ + /** + * @var \Magento\CatalogUrlRewrite\Model\Map\DatabaseMapPool + */ private $databaseMapPool; - /** @var string[] */ + /** + * @var string[] + */ private $dataUrlRewriteClassNames; /** diff --git a/app/code/Magento/CatalogUrlRewrite/Observer/CategoryProcessUrlRewriteSavingObserver.php b/app/code/Magento/CatalogUrlRewrite/Observer/CategoryProcessUrlRewriteSavingObserver.php index fca7b2d17984d..92a46facbe71c 100644 --- a/app/code/Magento/CatalogUrlRewrite/Observer/CategoryProcessUrlRewriteSavingObserver.php +++ b/app/code/Magento/CatalogUrlRewrite/Observer/CategoryProcessUrlRewriteSavingObserver.php @@ -18,19 +18,29 @@ */ class CategoryProcessUrlRewriteSavingObserver implements ObserverInterface { - /** @var \Magento\CatalogUrlRewrite\Model\CategoryUrlRewriteGenerator */ + /** + * @var \Magento\CatalogUrlRewrite\Model\CategoryUrlRewriteGenerator + */ private $categoryUrlRewriteGenerator; - /** @var \Magento\CatalogUrlRewrite\Model\UrlRewriteBunchReplacer */ + /** + * @var \Magento\CatalogUrlRewrite\Model\UrlRewriteBunchReplacer + */ private $urlRewriteBunchReplacer; - /** @var \Magento\CatalogUrlRewrite\Observer\UrlRewriteHandler */ + /** + * @var \Magento\CatalogUrlRewrite\Observer\UrlRewriteHandler + */ private $urlRewriteHandler; - /** @var \Magento\CatalogUrlRewrite\Model\Map\DatabaseMapPool */ + /** + * @var \Magento\CatalogUrlRewrite\Model\Map\DatabaseMapPool + */ private $databaseMapPool; - /** @var string[] */ + /** + * @var string[] + */ private $dataUrlRewriteClassNames; /** diff --git a/app/code/Magento/CatalogUrlRewrite/Observer/CategoryUrlPathAutogeneratorObserver.php b/app/code/Magento/CatalogUrlRewrite/Observer/CategoryUrlPathAutogeneratorObserver.php index 069638f05d0e5..eb54f0427c11a 100644 --- a/app/code/Magento/CatalogUrlRewrite/Observer/CategoryUrlPathAutogeneratorObserver.php +++ b/app/code/Magento/CatalogUrlRewrite/Observer/CategoryUrlPathAutogeneratorObserver.php @@ -15,13 +15,19 @@ class CategoryUrlPathAutogeneratorObserver implements ObserverInterface { - /** @var CategoryUrlPathGenerator */ + /** + * @var \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator + */ protected $categoryUrlPathGenerator; - /** @var \Magento\CatalogUrlRewrite\Model\Category\ChildrenCategoriesProvider */ + /** + * @var \Magento\CatalogUrlRewrite\Model\Category\ChildrenCategoriesProvider + */ protected $childrenCategoriesProvider; - /** @var StoreViewService */ + /** + * @var \Magento\CatalogUrlRewrite\Service\V1\StoreViewService + */ protected $storeViewService; /** diff --git a/app/code/Magento/CatalogUrlRewrite/Observer/ClearProductUrlsObserver.php b/app/code/Magento/CatalogUrlRewrite/Observer/ClearProductUrlsObserver.php index 102e268116dba..33c75cc609486 100644 --- a/app/code/Magento/CatalogUrlRewrite/Observer/ClearProductUrlsObserver.php +++ b/app/code/Magento/CatalogUrlRewrite/Observer/ClearProductUrlsObserver.php @@ -17,7 +17,9 @@ */ class ClearProductUrlsObserver implements ObserverInterface { - /** @var UrlPersistInterface */ + /** + * @var \Magento\UrlRewrite\Model\UrlPersistInterface + */ protected $urlPersist; /** diff --git a/app/code/Magento/CatalogUrlRewrite/Observer/ProductUrlKeyAutogeneratorObserver.php b/app/code/Magento/CatalogUrlRewrite/Observer/ProductUrlKeyAutogeneratorObserver.php index 1136cf0313f5a..b201ae31b680a 100644 --- a/app/code/Magento/CatalogUrlRewrite/Observer/ProductUrlKeyAutogeneratorObserver.php +++ b/app/code/Magento/CatalogUrlRewrite/Observer/ProductUrlKeyAutogeneratorObserver.php @@ -12,7 +12,9 @@ class ProductUrlKeyAutogeneratorObserver implements ObserverInterface { - /** @var ProductUrlPathGenerator */ + /** + * @var \Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator + */ protected $productUrlPathGenerator; /** diff --git a/app/code/Magento/CatalogUrlRewrite/Observer/UrlRewriteHandler.php b/app/code/Magento/CatalogUrlRewrite/Observer/UrlRewriteHandler.php index df1dcb0f5499e..5a6777f94e2d5 100644 --- a/app/code/Magento/CatalogUrlRewrite/Observer/UrlRewriteHandler.php +++ b/app/code/Magento/CatalogUrlRewrite/Observer/UrlRewriteHandler.php @@ -7,31 +7,49 @@ class UrlRewriteHandler { - /** @var \Magento\CatalogUrlRewrite\Model\Category\ChildrenCategoriesProvider */ + /** + * @var \Magento\CatalogUrlRewrite\Model\Category\ChildrenCategoriesProvider + */ protected $childrenCategoriesProvider; - /** @var \Magento\CatalogUrlRewrite\Model\CategoryUrlRewriteGenerator */ + /** + * @var \Magento\CatalogUrlRewrite\Model\CategoryUrlRewriteGenerator + */ protected $categoryUrlRewriteGenerator; - /** @var \Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator */ + /** + * @var \Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator + */ protected $productUrlRewriteGenerator; - /** @var \Magento\UrlRewrite\Model\UrlPersistInterface */ + /** + * @var \Magento\UrlRewrite\Model\UrlPersistInterface + */ protected $urlPersist; - /** @var array */ + /** + * @var array + */ protected $isSkippedProduct; - /** @var \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory */ + /** + * @var \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory + */ protected $productCollectionFactory; - /** @var \Magento\CatalogUrlRewrite\Model\CategoryProductUrlPathGenerator */ + /** + * @var \Magento\CatalogUrlRewrite\Model\CategoryProductUrlPathGenerator + */ private $categoryBasedProductRewriteGenerator; - /** @var \Magento\UrlRewrite\Model\MergeDataProvider */ + /** + * @var \Magento\UrlRewrite\Model\MergeDataProvider + */ private $mergeDataProviderPrototype; - /** @var \Magento\Framework\Serialize\Serializer\Json */ + /** + * @var \Magento\Framework\Serialize\Serializer\Json + */ private $serializer; /** @@ -88,6 +106,7 @@ public function generateProductUrlRewrites(\Magento\Catalog\Model\Category $cate $storeId = $category->getStoreId(); if ($category->getAffectedProductIds()) { $this->isSkippedProduct[$category->getEntityId()] = $category->getAffectedProductIds(); + /* @var \Magento\Catalog\Model\ResourceModel\Product\Collection $collection */ $collection = $this->productCollectionFactory->create() ->setStoreId($storeId) ->addIdFilter($category->getAffectedProductIds()) @@ -95,12 +114,21 @@ public function generateProductUrlRewrites(\Magento\Catalog\Model\Category $cate ->addAttributeToSelect('name') ->addAttributeToSelect('url_key') ->addAttributeToSelect('url_path'); - foreach ($collection as $product) { - $product->setStoreId($storeId); - $product->setData('save_rewrites_history', $saveRewriteHistory); - $mergeDataProvider->merge( - $this->productUrlRewriteGenerator->generate($product, $category->getEntityId()) - ); + + $collection->setPageSize(1000); + $pageCount = $collection->getLastPageNumber(); + $currentPage = 1; + while ($currentPage <= $pageCount) { + $collection->setCurPage($currentPage); + foreach ($collection as $product) { + $product->setStoreId($storeId); + $product->setData('save_rewrites_history', $saveRewriteHistory); + $mergeDataProvider->merge( + $this->productUrlRewriteGenerator->generate($product, $category->getEntityId()) + ); + } + $collection->clear(); + $currentPage++; } } else { $mergeDataProvider->merge( diff --git a/app/code/Magento/CatalogUrlRewrite/Plugin/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php b/app/code/Magento/CatalogUrlRewrite/Plugin/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php index e206709f9eac0..2c10effb40f24 100644 --- a/app/code/Magento/CatalogUrlRewrite/Plugin/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php +++ b/app/code/Magento/CatalogUrlRewrite/Plugin/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php @@ -7,7 +7,9 @@ class Helper { - /** @var \Magento\Framework\App\RequestInterface */ + /** + * @var \Magento\Framework\App\RequestInterface + */ protected $request; /** diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/CanonicalUrlRewriteGeneratorTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/CanonicalUrlRewriteGeneratorTest.php index 076a476a058fa..eb18e26510389 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/CanonicalUrlRewriteGeneratorTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/CanonicalUrlRewriteGeneratorTest.php @@ -9,7 +9,7 @@ use Magento\CatalogUrlRewrite\Model\CategoryUrlRewriteGenerator; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class CanonicalUrlRewriteGeneratorTest extends \PHPUnit_Framework_TestCase +class CanonicalUrlRewriteGeneratorTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\CatalogUrlRewrite\Model\Category\CanonicalUrlRewriteGenerator */ protected $canonicalUrlRewriteGenerator; diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/ChildrenCategoriesProviderTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/ChildrenCategoriesProviderTest.php index d1169e49e00aa..88a54af26a21f 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/ChildrenCategoriesProviderTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/ChildrenCategoriesProviderTest.php @@ -8,7 +8,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class ChildrenCategoriesProviderTest extends \PHPUnit_Framework_TestCase +class ChildrenCategoriesProviderTest extends \PHPUnit\Framework\TestCase { /** @var \PHPUnit_Framework_MockObject_MockObject */ protected $category; @@ -37,7 +37,7 @@ protected function setUp() $categoryCollection->expects($this->any())->method('addIdFilter')->with(['id'])->willReturnSelf(); $this->select = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->disableOriginalConstructor()->setMethods(['from', 'where', 'deleteFromSelect'])->getMock(); - $this->connection = $this->getMock(\Magento\Framework\DB\Adapter\AdapterInterface::class); + $this->connection = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class); $categoryResource = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Category::class) ->disableOriginalConstructor()->getMock(); $this->category->expects($this->any())->method('getResource')->willReturn($categoryResource); diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/ChildrenUrlRewriteGeneratorTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/ChildrenUrlRewriteGeneratorTest.php index 20c5ff4e85f99..3f641256b1259 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/ChildrenUrlRewriteGeneratorTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/ChildrenUrlRewriteGeneratorTest.php @@ -5,10 +5,10 @@ */ namespace Magento\CatalogUrlRewrite\Test\Unit\Model\Category; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Framework\Serialize\Serializer\Json; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class ChildrenUrlRewriteGeneratorTest extends \PHPUnit_Framework_TestCase +class ChildrenUrlRewriteGeneratorTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\CatalogUrlRewrite\Model\Category\ChildrenUrlRewriteGenerator */ private $childrenUrlRewriteGenerator; @@ -47,14 +47,11 @@ protected function setUp() $this->categoryUrlRewriteGenerator = $this->getMockBuilder( \Magento\CatalogUrlRewrite\Model\CategoryUrlRewriteGenerator::class )->disableOriginalConstructor()->getMock(); - $mergeDataProviderFactory = $this->getMock( + $mergeDataProviderFactory = $this->createPartialMock( \Magento\UrlRewrite\Model\MergeDataProviderFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->mergeDataProvider = new \Magento\UrlRewrite\Model\MergeDataProvider; + $this->mergeDataProvider = new \Magento\UrlRewrite\Model\MergeDataProvider(); $mergeDataProviderFactory->expects($this->once())->method('create')->willReturn($this->mergeDataProvider); $this->childrenUrlRewriteGenerator = (new ObjectManager($this))->getObject( diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/CurrentUrlRewritesRegeneratorTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/CurrentUrlRewritesRegeneratorTest.php index 16a5f9f64036d..2ee2473290306 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/CurrentUrlRewritesRegeneratorTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/CurrentUrlRewritesRegeneratorTest.php @@ -11,7 +11,7 @@ use Magento\UrlRewrite\Model\OptionProvider; use Magento\UrlRewrite\Service\V1\Data\UrlRewrite; -class CurrentUrlRewritesRegeneratorTest extends \PHPUnit_Framework_TestCase +class CurrentUrlRewritesRegeneratorTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\CatalogUrlRewrite\Model\Category\CurrentUrlRewritesRegenerator */ private $currentUrlRewritesRegenerator; @@ -50,13 +50,7 @@ protected function setUp() ->disableOriginalConstructor()->getMock(); $this->urlRewriteFactory->expects($this->once())->method('create') ->willReturn($this->urlRewrite); - $mergeDataProviderFactory = $this->getMock( - \Magento\UrlRewrite\Model\MergeDataProviderFactory::class, - ['create'], - [], - '', - false - ); + $mergeDataProviderFactory = $this->createPartialMock(\Magento\UrlRewrite\Model\MergeDataProviderFactory::class, ['create']); $this->mergeDataProvider = new \Magento\UrlRewrite\Model\MergeDataProvider; $mergeDataProviderFactory->expects($this->once())->method('create')->willReturn($this->mergeDataProvider); diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/Plugin/Category/MoveTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/Plugin/Category/MoveTest.php index 8c87e18669bef..f91a55c11b974 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/Plugin/Category/MoveTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/Plugin/Category/MoveTest.php @@ -12,7 +12,7 @@ use Magento\Catalog\Model\ResourceModel\Category as CategoryResourceModel; use Magento\Catalog\Model\Category; -class MoveTest extends \PHPUnit_Framework_TestCase +class MoveTest extends \PHPUnit\Framework\TestCase { /** * @var ObjectManager diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/Plugin/Category/RemoveTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/Plugin/Category/RemoveTest.php index ae649d1b546f4..9189f77453d59 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/Plugin/Category/RemoveTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/Plugin/Category/RemoveTest.php @@ -12,7 +12,7 @@ use Magento\Catalog\Model\ResourceModel\Category as CategoryResourceModel; use Magento\Catalog\Model\Category; -class RemoveTest extends \PHPUnit_Framework_TestCase +class RemoveTest extends \PHPUnit\Framework\TestCase { /** * @var ObjectManager @@ -55,7 +55,7 @@ protected function setUp() $this->objectMock = $this->getMockBuilder(Category::class) ->disableOriginalConstructor() ->getMock(); - $this->serializerMock = $this->getMock(\Magento\Framework\Serialize\Serializer\Json::class, [], [], '', false); + $this->serializerMock = $this->createMock(\Magento\Framework\Serialize\Serializer\Json::class); } public function testAroundDelete() diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/Plugin/StorageTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/Plugin/StorageTest.php index 120537371205f..e4216841bce25 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/Plugin/StorageTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/Plugin/StorageTest.php @@ -16,7 +16,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class StorageTest extends \PHPUnit_Framework_TestCase +class StorageTest extends \PHPUnit\Framework\TestCase { /** * @var CategoryStoragePlugin diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/Plugin/Store/GroupTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/Plugin/Store/GroupTest.php index 5c2c7b51a3285..c843ef44c97de 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/Plugin/Store/GroupTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/Plugin/Store/GroupTest.php @@ -20,7 +20,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class GroupTest extends \PHPUnit_Framework_TestCase +class GroupTest extends \PHPUnit\Framework\TestCase { /** * @var ObjectManager diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/Plugin/Store/ViewTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/Plugin/Store/ViewTest.php index 9930aeff8c623..d68fcfddde227 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/Plugin/Store/ViewTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/Plugin/Store/ViewTest.php @@ -21,7 +21,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ViewTest extends \PHPUnit_Framework_TestCase +class ViewTest extends \PHPUnit\Framework\TestCase { /** * @var ObjectManager diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/CategoryBasedProductRewriteGeneratorTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/CategoryBasedProductRewriteGeneratorTest.php index 661e6e5b025dc..201e4f9d71e53 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/CategoryBasedProductRewriteGeneratorTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/CategoryBasedProductRewriteGeneratorTest.php @@ -13,7 +13,7 @@ /** * Class CategoryBasedProductRewriteGeneratorTest */ -class CategoryBasedProductRewriteGeneratorTest extends \PHPUnit_Framework_TestCase +class CategoryBasedProductRewriteGeneratorTest extends \PHPUnit\Framework\TestCase { /** * @var ProductScopeRewriteGenerator|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/CategoryProductUrlPathGeneratorTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/CategoryProductUrlPathGeneratorTest.php index 1ec2c1ba9a768..8ba5e68041249 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/CategoryProductUrlPathGeneratorTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/CategoryProductUrlPathGeneratorTest.php @@ -14,7 +14,7 @@ /** * Class CategoryProductUrlPathGeneratorTest */ -class CategoryProductUrlPathGeneratorTest extends \PHPUnit_Framework_TestCase +class CategoryProductUrlPathGeneratorTest extends \PHPUnit\Framework\TestCase { /** * @var ProductScopeRewriteGenerator|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/CategoryUrlPathGeneratorTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/CategoryUrlPathGeneratorTest.php index 62213fadfec06..7297d150a8e6f 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/CategoryUrlPathGeneratorTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/CategoryUrlPathGeneratorTest.php @@ -10,7 +10,7 @@ use Magento\Store\Model\ScopeInterface; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class CategoryUrlPathGeneratorTest extends \PHPUnit_Framework_TestCase +class CategoryUrlPathGeneratorTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator */ protected $categoryUrlPathGenerator; @@ -42,10 +42,10 @@ protected function setUp() 'getName', 'isObjectNew' ]; - $this->category = $this->getMock(\Magento\Catalog\Model\Category::class, $categoryMethods, [], '', false); - $this->storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); - $this->scopeConfig = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $this->categoryRepository = $this->getMock(\Magento\Catalog\Api\CategoryRepositoryInterface::class); + $this->category = $this->createPartialMock(\Magento\Catalog\Model\Category::class, $categoryMethods); + $this->storeManager = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->scopeConfig = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->categoryRepository = $this->createMock(\Magento\Catalog\Api\CategoryRepositoryInterface::class); $this->categoryUrlPathGenerator = (new ObjectManager($this))->getObject( \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator::class, @@ -143,7 +143,7 @@ public function testGetUrlPathWithParent( $this->category->expects($this->any())->method('isObjectNew')->will($this->returnValue($isCategoryNew)); $methods = ['__wakeup', 'getUrlPath', 'getParentId', 'getLevel', 'dataHasChangedFor', 'load']; - $parentCategory = $this->getMock(\Magento\Catalog\Model\Category::class, $methods, [], '', false); + $parentCategory = $this->createPartialMock(\Magento\Catalog\Model\Category::class, $methods); $parentCategory->expects($this->any())->method('getParentId') ->will($this->returnValue($parentCategoryParentId)); $parentCategory->expects($this->any())->method('getLevel')->will($this->returnValue($parentLevel)); @@ -209,7 +209,7 @@ public function testGetUrlPathWithSuffixWithoutStore() $this->category->expects($this->exactly(2))->method('dataHasChangedFor') ->will($this->returnValueMap([['url_key', false], ['path_ids', false]])); - $store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $store = $this->createMock(\Magento\Store\Model\Store::class); $store->expects($this->once())->method('getId')->will($this->returnValue($currentStoreId)); $this->storeManager->expects($this->once())->method('getStore')->will($this->returnValue($store)); $this->scopeConfig->expects($this->once())->method('getValue') diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/CategoryUrlRewriteGeneratorTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/CategoryUrlRewriteGeneratorTest.php index 9084724e95200..2a6c81f26b1b8 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/CategoryUrlRewriteGeneratorTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/CategoryUrlRewriteGeneratorTest.php @@ -15,7 +15,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class CategoryUrlRewriteGeneratorTest extends \PHPUnit_Framework_TestCase +class CategoryUrlRewriteGeneratorTest extends \PHPUnit\Framework\TestCase { /** @var \PHPUnit_Framework_MockObject_MockObject */ private $canonicalUrlRewriteGenerator; @@ -49,7 +49,7 @@ class CategoryUrlRewriteGeneratorTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->serializer = $this->getMock(\Magento\Framework\Serialize\Serializer\Json::class, [], [], '', false); + $this->serializer = $this->createMock(\Magento\Framework\Serialize\Serializer\Json::class); $this->serializer->expects($this->any()) ->method('serialize') ->willReturnCallback( @@ -76,15 +76,9 @@ function ($value) { )->disableOriginalConstructor()->getMock(); $this->storeViewService = $this->getMockBuilder(\Magento\CatalogUrlRewrite\Service\V1\StoreViewService::class) ->disableOriginalConstructor()->getMock(); - $this->category = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false); - $this->categoryRepository = $this->getMock(\Magento\Catalog\Api\CategoryRepositoryInterface::class); - $mergeDataProviderFactory = $this->getMock( - \Magento\UrlRewrite\Model\MergeDataProviderFactory::class, - ['create'], - [], - '', - false - ); + $this->category = $this->createMock(\Magento\Catalog\Model\Category::class); + $this->categoryRepository = $this->createMock(\Magento\Catalog\Api\CategoryRepositoryInterface::class); + $mergeDataProviderFactory = $this->createPartialMock(\Magento\UrlRewrite\Model\MergeDataProviderFactory::class, ['create']); $this->mergeDataProvider = new \Magento\UrlRewrite\Model\MergeDataProvider; $mergeDataProviderFactory->expects($this->once())->method('create')->willReturn($this->mergeDataProvider); @@ -131,13 +125,7 @@ public function testGenerationForGlobalScope() $this->currentUrlRewritesRegenerator->expects($this->any())->method('generate') ->with(1, $this->category, $categoryId) ->will($this->returnValue(['category-3' => $current])); - $categoryForSpecificStore = $this->getMock( - \Magento\Catalog\Model\Category::class, - ['getUrlKey', 'getUrlPath'], - [], - '', - false - ); + $categoryForSpecificStore = $this->createPartialMock(\Magento\Catalog\Model\Category::class, ['getUrlKey', 'getUrlPath']); $this->categoryRepository->expects($this->once())->method('get')->willReturn($categoryForSpecificStore); $this->assertEquals( diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Map/DataCategoryHashMapTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Map/DataCategoryHashMapTest.php index 9a41ab5b64972..dd78c04d2eed8 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Map/DataCategoryHashMapTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Map/DataCategoryHashMapTest.php @@ -17,7 +17,7 @@ /** * Class DataCategoryHashMapTest */ -class DataCategoryHashMapTest extends \PHPUnit_Framework_TestCase +class DataCategoryHashMapTest extends \PHPUnit\Framework\TestCase { /** @var CategoryRepository|\PHPUnit_Framework_MockObject_MockObject */ private $categoryRepository; @@ -33,15 +33,9 @@ class DataCategoryHashMapTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->categoryRepository = $this->getMock(CategoryRepository::class, [], [], '', false); - $this->categoryResourceFactory = $this->getMock(CategoryFactory::class, ['create'], [], '', false); - $this->categoryResource = $this->getMock( - Category::class, - ['getConnection', 'getEntityTable'], - [], - '', - false - ); + $this->categoryRepository = $this->createMock(CategoryRepository::class); + $this->categoryResourceFactory = $this->createPartialMock(CategoryFactory::class, ['create']); + $this->categoryResource = $this->createPartialMock(Category::class, ['getConnection', 'getEntityTable']); $this->categoryResourceFactory->expects($this->any()) ->method('create') @@ -64,9 +58,11 @@ public function testGetAllData() $categoryIds = ['1' => [1, 2, 3], '2' => [2, 3], '3' => 3]; $categoryIdsOther = ['2' => [2, 3, 4]]; - $categoryMock = $this->getMock(CategoryInterface::class, [], [], '', false); - $connectionAdapterMock = $this->getMock(AdapterInterface::class); - $selectMock = $this->getMock(Select::class, [], [], '', false); + $categoryMock = $this->getMockBuilder(CategoryInterface::class) + ->setMethods(['getResource']) + ->getMockForAbstractClass(); + $connectionAdapterMock = $this->createMock(AdapterInterface::class); + $selectMock = $this->createMock(Select::class); $this->categoryRepository->expects($this->any()) ->method('get') diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Map/DataCategoryUrlRewriteDatabaseMapTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Map/DataCategoryUrlRewriteDatabaseMapTest.php index 85fe53d5d1dc7..23406c567accc 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Map/DataCategoryUrlRewriteDatabaseMapTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Map/DataCategoryUrlRewriteDatabaseMapTest.php @@ -19,7 +19,7 @@ /** * Class DataCategoryUrlRewriteDatabaseMapTest */ -class DataCategoryUrlRewriteDatabaseMapTest extends \PHPUnit_Framework_TestCase +class DataCategoryUrlRewriteDatabaseMapTest extends \PHPUnit\Framework\TestCase { /** @var HashMapPool|\PHPUnit_Framework_MockObject_MockObject */ private $hashMapPoolMock; @@ -41,17 +41,11 @@ class DataCategoryUrlRewriteDatabaseMapTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->hashMapPoolMock = $this->getMock(HashMapPool::class, [], [], '', false); - $this->dataCategoryMapMock = $this->getMock(DataProductHashMap::class, [], [], '', false); - $this->dataCategoryUsedInProductsMapMock = $this->getMock( - DataCategoryUsedInProductsHashMap::class, - [], - [], - '', - false - ); - $this->temporaryTableServiceMock = $this->getMock(TemporaryTableService::class, [], [], '', false); - $this->connectionMock = $this->getMock(ResourceConnection::class, [], [], '', false); + $this->hashMapPoolMock = $this->createMock(HashMapPool::class); + $this->dataCategoryMapMock = $this->createMock(DataProductHashMap::class); + $this->dataCategoryUsedInProductsMapMock = $this->createMock(DataCategoryUsedInProductsHashMap::class); + $this->temporaryTableServiceMock = $this->createMock(TemporaryTableService::class); + $this->connectionMock = $this->createMock(ResourceConnection::class); $this->hashMapPoolMock->expects($this->any()) ->method('getDataMap') @@ -80,8 +74,8 @@ public function testGetAllData() '5' => ['store_id' => 2, 'category_id' => 2], ]; - $connectionMock = $this->getMock(AdapterInterface::class); - $selectMock = $this->getMock(Select::class, [], [], '', false); + $connectionMock = $this->createMock(AdapterInterface::class); + $selectMock = $this->createMock(Select::class); $this->connectionMock->expects($this->any()) ->method('getConnection') diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Map/DataCategoryUsedInProductsHashMapTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Map/DataCategoryUsedInProductsHashMapTest.php index f7ae363e65d81..21fa6942975c0 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Map/DataCategoryUsedInProductsHashMapTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Map/DataCategoryUsedInProductsHashMapTest.php @@ -17,7 +17,7 @@ /** * Class DataCategoryUsedInProductsHashMapTest */ -class DataCategoryUsedInProductsHashMapTest extends \PHPUnit_Framework_TestCase +class DataCategoryUsedInProductsHashMapTest extends \PHPUnit\Framework\TestCase { /** @var HashMapPool|\PHPUnit_Framework_MockObject_MockObject */ private $hashMapPoolMock; @@ -36,10 +36,10 @@ class DataCategoryUsedInProductsHashMapTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->hashMapPoolMock = $this->getMock(HashMapPool::class, [], [], '', false); - $this->dataCategoryMapMock = $this->getMock(DataCategoryHashMap::class, [], [], '', false); - $this->dataProductMapMock = $this->getMock(DataProductHashMap::class, [], [], '', false); - $this->connectionMock = $this->getMock(ResourceConnection::class, [], [], '', false); + $this->hashMapPoolMock = $this->createMock(HashMapPool::class); + $this->dataCategoryMapMock = $this->createMock(DataCategoryHashMap::class); + $this->dataProductMapMock = $this->createMock(DataProductHashMap::class); + $this->connectionMock = $this->createMock(ResourceConnection::class); $this->hashMapPoolMock->expects($this->any()) ->method('getDataMap') @@ -69,8 +69,8 @@ public function testGetAllData() $categoryIds = ['1' => [1, 2, 3], '2' => [2, 3], '3' => 3]; $categoryIdsOther = ['2' => [2, 3, 4]]; - $connectionMock = $this->getMock(AdapterInterface::class); - $selectMock = $this->getMock(Select::class, [], [], '', false); + $connectionMock = $this->createMock(AdapterInterface::class); + $selectMock = $this->createMock(Select::class); $this->connectionMock->expects($this->any()) ->method('getConnection') diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Map/DataProductHashMapTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Map/DataProductHashMapTest.php index 4c1ed4219e93c..e8ddec97afb65 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Map/DataProductHashMapTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Map/DataProductHashMapTest.php @@ -5,23 +5,19 @@ */ namespace Magento\CatalogUrlRewrite\Test\Unit\Model\Map; -use Magento\Catalog\Model\ResourceModel\Category\Collection; -use Magento\Catalog\Model\ResourceModel\Category as CategoryResource; -use Magento\Framework\DB\Select; -use Magento\Catalog\Model\ProductRepository; -use Magento\CatalogUrlRewrite\Model\Map\HashMapPool; -use Magento\CatalogUrlRewrite\Model\Map\DataProductHashMap; +use Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollection; +use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory; use Magento\CatalogUrlRewrite\Model\Map\DataCategoryHashMap; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\CatalogUrlRewrite\Model\Map\DataProductHashMap; +use Magento\CatalogUrlRewrite\Model\Map\HashMapPool; use Magento\Framework\DB\Adapter\AdapterInterface; -use Magento\Framework\App\ResourceConnection; -use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory; -use Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollection; +use Magento\Framework\DB\Select; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; /** * Class DataProductHashMapTest */ -class DataProductHashMapTest extends \PHPUnit_Framework_TestCase +class DataProductHashMapTest extends \PHPUnit\Framework\TestCase { /** @var HashMapPool|\PHPUnit_Framework_MockObject_MockObject */ private $hashMapPoolMock; @@ -44,15 +40,12 @@ class DataProductHashMapTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->hashMapPoolMock = $this->getMock(HashMapPool::class, [], [], '', false); - $this->dataCategoryMapMock = $this->getMock(DataCategoryHashMap::class, [], [], '', false); - $this->collectionFactoryMock = $this->getMock(CollectionFactory::class, ['create'], [], '', false); - $this->productCollectionMock = $this->getMock( + $this->hashMapPoolMock = $this->createMock(HashMapPool::class); + $this->dataCategoryMapMock = $this->createMock(DataCategoryHashMap::class); + $this->collectionFactoryMock = $this->createPartialMock(CollectionFactory::class, ['create']); + $this->productCollectionMock = $this->createPartialMock( ProductCollection::class, - ['getSelect', 'getConnection', 'getAllIds'], - [], - '', - false + ['getSelect', 'getConnection', 'getAllIds'] ); $this->collectionFactoryMock->expects($this->any()) @@ -80,8 +73,8 @@ public function testGetAllData() $productIds = ['1' => [1, 2, 3], '2' => [2, 3], '3' => 3]; $productIdsOther = ['2' => [2, 3, 4]]; - $connectionMock = $this->getMock(AdapterInterface::class); - $selectMock = $this->getMock(Select::class, [], [], '', false); + $connectionMock = $this->createMock(AdapterInterface::class); + $selectMock = $this->createMock(Select::class); $this->productCollectionMock->expects($this->exactly(3)) ->method('getAllIds') diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Map/DataProductUrlRewriteDatabaseMapTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Map/DataProductUrlRewriteDatabaseMapTest.php index 8a364c4bd2fc5..c55204893f69f 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Map/DataProductUrlRewriteDatabaseMapTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Map/DataProductUrlRewriteDatabaseMapTest.php @@ -17,7 +17,7 @@ /** * Class DataProductUrlRewriteDatabaseMapTest */ -class DataProductUrlRewriteDatabaseMapTest extends \PHPUnit_Framework_TestCase +class DataProductUrlRewriteDatabaseMapTest extends \PHPUnit\Framework\TestCase { /** @var HashMapPool|\PHPUnit_Framework_MockObject_MockObject */ private $hashMapPoolMock; @@ -36,10 +36,10 @@ class DataProductUrlRewriteDatabaseMapTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->hashMapPoolMock = $this->getMock(HashMapPool::class, [], [], '', false); - $this->dataProductMapMock = $this->getMock(DataProductHashMap::class, [], [], '', false); - $this->temporaryTableServiceMock = $this->getMock(TemporaryTableService::class, [], [], '', false); - $this->connectionMock = $this->getMock(ResourceConnection::class, [], [], '', false); + $this->hashMapPoolMock = $this->createMock(HashMapPool::class); + $this->dataProductMapMock = $this->createMock(DataProductHashMap::class); + $this->temporaryTableServiceMock = $this->createMock(TemporaryTableService::class); + $this->connectionMock = $this->createMock(ResourceConnection::class); $this->hashMapPoolMock->expects($this->any()) ->method('getDataMap') @@ -68,8 +68,8 @@ public function testGetAllData() '5' => ['store_id' => 2, 'product_id' => 2], ]; - $connectionMock = $this->getMock(AdapterInterface::class); - $selectMock = $this->getMock(Select::class, [], [], '', false); + $connectionMock = $this->createMock(AdapterInterface::class); + $selectMock = $this->createMock(Select::class); $this->connectionMock->expects($this->any()) ->method('getConnection') diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Map/HashMapPoolTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Map/HashMapPoolTest.php index 053ecc6d18bb8..823f3a37205d3 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Map/HashMapPoolTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Map/HashMapPoolTest.php @@ -15,7 +15,7 @@ /** * Class HashMapPoolTest */ -class HashMapPoolTest extends \PHPUnit_Framework_TestCase +class HashMapPoolTest extends \PHPUnit\Framework\TestCase { /** @var ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ private $objectManagerMock; @@ -25,7 +25,7 @@ class HashMapPoolTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManagerMock = $this->getMock(ObjectManagerInterface::class); + $this->objectManagerMock = $this->createMock(ObjectManagerInterface::class); $this->model = (new ObjectManager($this))->getObject( HashMapPool::class, @@ -40,9 +40,9 @@ protected function setUp() */ public function testGetDataMap() { - $dataCategoryMapMock = $this->getMock(DataCategoryHashMap::class, [], [], '', false); - $dataProductMapMock = $this->getMock(DataProductHashMap::class, [], [], '', false); - $dataProductMapMockOtherCategory = $this->getMock(DataCategoryUsedInProductsHashMap::class, [], [], '', false); + $dataCategoryMapMock = $this->createMock(DataCategoryHashMap::class); + $dataProductMapMock = $this->createMock(DataProductHashMap::class); + $dataProductMapMockOtherCategory = $this->createMock(DataCategoryUsedInProductsHashMap::class); $this->objectManagerMock->expects($this->any()) ->method('create') @@ -78,12 +78,12 @@ public function testGetDataMap() */ public function testGetDataMapException() { - $nonInterface = $this->getMock(HashMapPool::class, [], [], '', false); + $nonInterface = $this->createMock(HashMapPool::class); $this->objectManagerMock->expects($this->any()) ->method('create') ->willReturn($nonInterface); - $this->setExpectedException(\InvalidArgumentException::class); + $this->expectException(\InvalidArgumentException::class); $this->model->getDataMap(HashMapPool::class, 1); } } diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Map/UrlRewriteFinderTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Map/UrlRewriteFinderTest.php index 1034a91d09e13..388f9a7950c20 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Map/UrlRewriteFinderTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Map/UrlRewriteFinderTest.php @@ -20,7 +20,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class UrlRewriteFinderTest extends \PHPUnit_Framework_TestCase +class UrlRewriteFinderTest extends \PHPUnit\Framework\TestCase { /** @var DatabaseMapPool|\PHPUnit_Framework_MockObject_MockObject */ private $databaseMapPoolMock; @@ -42,10 +42,10 @@ class UrlRewriteFinderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->serializerMock = $this->getMock(Json::class, [], [], '', false); - $this->databaseMapPoolMock = $this->getMock(DatabaseMapPool::class, [], [], '', false); - $this->urlFinderMock = $this->getMock(UrlFinderInterface::class); - $this->urlRewriteFactoryMock = $this->getMock(UrlRewriteFactory::class, ['create'], [], '', false); + $this->serializerMock = $this->createMock(Json::class); + $this->databaseMapPoolMock = $this->createMock(DatabaseMapPool::class); + $this->urlFinderMock = $this->createMock(UrlFinderInterface::class); + $this->urlRewriteFactoryMock = $this->createPartialMock(UrlRewriteFactory::class, ['create']); $this->urlRewritePrototypeMock = new UrlRewrite([], $this->serializerMock); $this->urlRewriteFactoryMock->expects($this->any()) @@ -110,7 +110,7 @@ public function testGetByIdentifiersProduct() ] ]; - $dataProductMapMock = $this->getMock(DataProductUrlRewriteDatabaseMap::class, [], [], '', false); + $dataProductMapMock = $this->createMock(DataProductUrlRewriteDatabaseMap::class); $this->databaseMapPoolMock->expects($this->once()) ->method('getDataMap') ->with(DataProductUrlRewriteDatabaseMap::class, 1) @@ -148,7 +148,7 @@ public function testGetByIdentifiersCategory() ] ]; - $dataCategoryMapMock = $this->getMock(DataCategoryUrlRewriteDatabaseMap::class, [], [], '', false); + $dataCategoryMapMock = $this->createMock(DataCategoryUrlRewriteDatabaseMap::class); $this->databaseMapPoolMock->expects($this->once()) ->method('getDataMap') ->with(DataCategoryUrlRewriteDatabaseMap::class, 1) diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/ObjectRegistryTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/ObjectRegistryTest.php index e2fbf95087800..ea24a05830e8e 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/ObjectRegistryTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/ObjectRegistryTest.php @@ -8,7 +8,7 @@ use Magento\Framework\DataObject; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class ObjectRegistryTest extends \PHPUnit_Framework_TestCase +class ObjectRegistryTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\CatalogUrlRewrite\Model\ObjectRegistry */ protected $objectRegistry; diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/CanonicalUrlRewriteGeneratorTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/CanonicalUrlRewriteGeneratorTest.php index aa40b72dcd6f3..2a8af3fb43eaa 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/CanonicalUrlRewriteGeneratorTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/CanonicalUrlRewriteGeneratorTest.php @@ -8,7 +8,7 @@ use Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class CanonicalUrlRewriteGeneratorTest extends \PHPUnit_Framework_TestCase +class CanonicalUrlRewriteGeneratorTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\CatalogUrlRewrite\Model\Product\CanonicalUrlRewriteGenerator */ protected $canonicalUrlRewriteGenerator; diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/CategoriesUrlRewriteGeneratorTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/CategoriesUrlRewriteGeneratorTest.php index b662dad207e9a..0d3e896f09875 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/CategoriesUrlRewriteGeneratorTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/CategoriesUrlRewriteGeneratorTest.php @@ -9,7 +9,7 @@ use Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class CategoriesUrlRewriteGeneratorTest extends \PHPUnit_Framework_TestCase +class CategoriesUrlRewriteGeneratorTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\CatalogUrlRewrite\Model\Product\CategoriesUrlRewriteGenerator */ protected $categoriesUrlRewriteGenerator; @@ -75,7 +75,7 @@ public function testGenerateCategories() ->will($this->returnValue($urlPathWithCategory)); $this->productUrlPathGenerator->expects($this->any())->method('getCanonicalUrlPath') ->will($this->returnValue($canonicalUrlPathWithCategory)); - $category = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false); + $category = $this->createMock(\Magento\Catalog\Model\Category::class); $category->expects($this->any())->method('getId')->will($this->returnValue($categoryId)); $this->categoryRegistry->expects($this->any())->method('getList') ->will($this->returnValue([$category])); diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/CurrentUrlRewritesRegeneratorTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/CurrentUrlRewritesRegeneratorTest.php index f15c45c1f3f20..4855478b8488a 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/CurrentUrlRewritesRegeneratorTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/CurrentUrlRewritesRegeneratorTest.php @@ -13,7 +13,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class CurrentUrlRewritesRegeneratorTest extends \PHPUnit_Framework_TestCase +class CurrentUrlRewritesRegeneratorTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\CatalogUrlRewrite\Model\Product\CurrentUrlRewritesRegenerator */ private $currentUrlRewritesRegenerator; @@ -62,14 +62,11 @@ protected function setUp() $this->productUrlPathGenerator = $this->getMockBuilder( \Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator::class )->disableOriginalConstructor()->getMock(); - $mergeDataProviderFactory = $this->getMock( + $mergeDataProviderFactory = $this->createPartialMock( \Magento\UrlRewrite\Model\MergeDataProviderFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->mergeDataProvider = new \Magento\UrlRewrite\Model\MergeDataProvider; + $this->mergeDataProvider = new \Magento\UrlRewrite\Model\MergeDataProvider(); $mergeDataProviderFactory->expects($this->once())->method('create')->willReturn($this->mergeDataProvider); $this->currentUrlRewritesRegenerator = (new ObjectManager($this))->getObject( \Magento\CatalogUrlRewrite\Model\Product\CurrentUrlRewritesRegenerator::class, diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/ProductScopeRewriteGeneratorTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/ProductScopeRewriteGeneratorTest.php index d2334c862b17c..48399d5ef612b 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/ProductScopeRewriteGeneratorTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/ProductScopeRewriteGeneratorTest.php @@ -15,7 +15,7 @@ * @package Magento\CatalogUrlRewrite\Test\Unit\Model * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ProductScopeRewriteGeneratorTest extends \PHPUnit_Framework_TestCase +class ProductScopeRewriteGeneratorTest extends \PHPUnit\Framework\TestCase { /** @var \PHPUnit_Framework_MockObject_MockObject */ private $canonicalUrlRewriteGenerator; @@ -49,7 +49,7 @@ class ProductScopeRewriteGeneratorTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->serializer = $this->getMock(\Magento\Framework\Serialize\Serializer\Json::class, [], [], '', false); + $this->serializer = $this->createMock(\Magento\Framework\Serialize\Serializer\Json::class); $this->serializer->expects($this->any()) ->method('serialize') ->willReturnCallback( @@ -82,15 +82,12 @@ function ($value) { )->disableOriginalConstructor()->setMethods(['create'])->getMock(); $this->storeViewService = $this->getMockBuilder(\Magento\CatalogUrlRewrite\Service\V1\StoreViewService::class) ->disableOriginalConstructor()->getMock(); - $this->storeManager = $this->getMock(StoreManagerInterface::class); - $mergeDataProviderFactory = $this->getMock( + $this->storeManager = $this->createMock(StoreManagerInterface::class); + $mergeDataProviderFactory = $this->createPartialMock( \Magento\UrlRewrite\Model\MergeDataProviderFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->mergeDataProvider = new \Magento\UrlRewrite\Model\MergeDataProvider; + $this->mergeDataProvider = new \Magento\UrlRewrite\Model\MergeDataProvider(); $mergeDataProviderFactory->expects($this->once())->method('create')->willReturn($this->mergeDataProvider); $this->productScopeGenerator = (new ObjectManager($this))->getObject( @@ -110,7 +107,7 @@ function ($value) { public function testGenerationForGlobalScope() { - $product = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $product = $this->createMock(\Magento\Catalog\Model\Product::class); $product->expects($this->any())->method('getStoreId')->will($this->returnValue(null)); $product->expects($this->any())->method('getStoreIds')->will($this->returnValue([1])); $this->storeViewService->expects($this->once())->method('doesEntityHaveOverriddenUrlKeyForStore') @@ -158,11 +155,11 @@ public function testGenerationForGlobalScope() public function testGenerationForSpecificStore() { - $product = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $product = $this->createMock(\Magento\Catalog\Model\Product::class); $product->expects($this->any())->method('getStoreId')->will($this->returnValue(1)); $product->expects($this->never())->method('getStoreIds'); $storeRootCategoryId = 'root-for-store-id'; - $category = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false); + $category = $this->createMock(\Magento\Catalog\Model\Category::class); $category->expects($this->any())->method('getParentIds') ->will($this->returnValue(['root-id', $storeRootCategoryId])); $category->expects($this->any())->method('getParentId')->will($this->returnValue('parent_id')); @@ -196,7 +193,7 @@ public function testGenerationForSpecificStore() */ public function testSkipGenerationForGlobalScope() { - $product = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $product = $this->createMock(\Magento\Catalog\Model\Product::class); $product->expects($this->any())->method('getStoreIds')->will($this->returnValue([1, 2])); $this->storeViewService->expects($this->exactly(2))->method('doesEntityHaveOverriddenUrlKeyForStore') ->will($this->returnValue(true)); diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/ProductUrlPathGeneratorTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/ProductUrlPathGeneratorTest.php index a4614eaca25df..b32b0216b9bdf 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/ProductUrlPathGeneratorTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/ProductUrlPathGeneratorTest.php @@ -9,7 +9,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Store\Model\ScopeInterface; -class ProductUrlPathGeneratorTest extends \PHPUnit_Framework_TestCase +class ProductUrlPathGeneratorTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator */ protected $productUrlPathGenerator; @@ -34,7 +34,7 @@ class ProductUrlPathGeneratorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->category = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false); + $this->category = $this->createMock(\Magento\Catalog\Model\Category::class); $productMethods = [ '__wakeup', 'getData', @@ -46,17 +46,13 @@ protected function setUp() 'setStoreId', ]; - $this->product = $this->getMock(\Magento\Catalog\Model\Product::class, $productMethods, [], '', false); - $this->storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); - $this->scopeConfig = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $this->categoryUrlPathGenerator = $this->getMock( - \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator::class, - [], - [], - '', - false + $this->product = $this->createPartialMock(\Magento\Catalog\Model\Product::class, $productMethods); + $this->storeManager = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->scopeConfig = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->categoryUrlPathGenerator = $this->createMock( + \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator::class ); - $this->productRepository = $this->getMock(\Magento\Catalog\Api\ProductRepositoryInterface::class); + $this->productRepository = $this->createMock(\Magento\Catalog\Api\ProductRepositoryInterface::class); $this->productRepository->expects($this->any())->method('getById')->willReturn($this->product); $this->productUrlPathGenerator = (new ObjectManager($this))->getObject( @@ -168,7 +164,7 @@ public function testGetUrlPathWithSuffix() $storeId = 1; $this->product->expects($this->once())->method('getData')->with('url_path') ->will($this->returnValue('product-path')); - $store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $store = $this->createMock(\Magento\Store\Model\Store::class); $store->expects($this->once())->method('getId')->will($this->returnValue($storeId)); $this->storeManager->expects($this->once())->method('getStore')->will($this->returnValue($store)); $this->scopeConfig->expects($this->once())->method('getValue') diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/ProductUrlRewriteGeneratorTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/ProductUrlRewriteGeneratorTest.php index 91dab740f7c64..83957214f69fc 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/ProductUrlRewriteGeneratorTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/ProductUrlRewriteGeneratorTest.php @@ -16,7 +16,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ProductUrlRewriteGeneratorTest extends \PHPUnit_Framework_TestCase +class ProductUrlRewriteGeneratorTest extends \PHPUnit\Framework\TestCase { /** @var \PHPUnit_Framework_MockObject_MockObject */ protected $canonicalUrlRewriteGenerator; @@ -56,7 +56,7 @@ class ProductUrlRewriteGeneratorTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->product = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $this->product = $this->createMock(\Magento\Catalog\Model\Product::class); $this->categoriesCollection = $this->getMockBuilder( \Magento\Catalog\Model\ResourceModel\Category\Collection::class) ->disableOriginalConstructor()->getMock(); diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/UrlRewriteBunchReplacerTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/UrlRewriteBunchReplacerTest.php index 78cfc922fa9fc..99b28b2c1b691 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/UrlRewriteBunchReplacerTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/UrlRewriteBunchReplacerTest.php @@ -8,7 +8,7 @@ use Magento\CatalogUrlRewrite\Model\UrlRewriteBunchReplacer; use Magento\UrlRewrite\Model\UrlPersistInterface; -class UrlRewriteBunchReplacerTest extends \PHPUnit_Framework_TestCase +class UrlRewriteBunchReplacerTest extends \PHPUnit\Framework\TestCase { /** * @var UrlPersistInterface | \PHPUnit_Framework_MockObject_MockObject @@ -22,7 +22,7 @@ class UrlRewriteBunchReplacerTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->urlPersistMock = $this->getMock(UrlPersistInterface::class); + $this->urlPersistMock = $this->createMock(UrlPersistInterface::class); $this->urlRewriteBunchReplacer = new UrlRewriteBunchReplacer( $this->urlPersistMock ); diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/AfterImportDataObserverTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/AfterImportDataObserverTest.php index 995d9540ebc94..fd9ab10537f1c 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/AfterImportDataObserverTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/AfterImportDataObserverTest.php @@ -20,7 +20,7 @@ * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class AfterImportDataObserverTest extends \PHPUnit_Framework_TestCase +class AfterImportDataObserverTest extends \PHPUnit\Framework\TestCase { /** * @var string @@ -153,28 +153,16 @@ class AfterImportDataObserverTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->importProduct = $this->getMock( - \Magento\CatalogImportExport\Model\Import\Product::class, - [ + $this->importProduct = $this->createPartialMock(\Magento\CatalogImportExport\Model\Import\Product::class, [ 'getNewSku', 'getProductCategories', 'getProductWebsites', 'getStoreIdByCode', 'getCategoryProcessor', - ], - [], - '', - false - ); - $this->catalogProductFactory = $this->getMock( - \Magento\Catalog\Model\ProductFactory::class, - [ + ]); + $this->catalogProductFactory = $this->createPartialMock(\Magento\Catalog\Model\ProductFactory::class, [ 'create', - ], - [], - '', - false - ); + ]); $this->storeManager = $this ->getMockBuilder( \Magento\Store\Model\StoreManagerInterface::class @@ -184,10 +172,10 @@ protected function setUp() 'getWebsite', ]) ->getMockForAbstractClass(); - $this->event = $this->getMock(\Magento\Framework\Event::class, ['getAdapter', 'getBunch'], [], '', false); + $this->event = $this->createPartialMock(\Magento\Framework\Event::class, ['getAdapter', 'getBunch']); $this->event->expects($this->any())->method('getAdapter')->willReturn($this->importProduct); $this->event->expects($this->any())->method('getBunch')->willReturn($this->products); - $this->observer = $this->getMock(\Magento\Framework\Event\Observer::class, ['getEvent'], [], '', false); + $this->observer = $this->createPartialMock(\Magento\Framework\Event\Observer::class, ['getEvent']); $this->observer->expects($this->any())->method('getEvent')->willReturn($this->event); $this->urlPersist = $this->getMockBuilder(\Magento\UrlRewrite\Model\UrlPersistInterface::class) ->disableOriginalConstructor() @@ -201,35 +189,16 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); - $this->objectRegistryFactory = $this->getMock( - \Magento\CatalogUrlRewrite\Model\ObjectRegistryFactory::class, - [], - [], - '', - false - ); - $this->productUrlPathGenerator = $this->getMock( - \Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator::class, - [], - [], - '', - false - ); - $this->storeViewService = $this->getMock( - \Magento\CatalogUrlRewrite\Service\V1\StoreViewService::class, - [], - [], - '', - false + $this->objectRegistryFactory = $this->createMock(\Magento\CatalogUrlRewrite\Model\ObjectRegistryFactory::class); + $this->productUrlPathGenerator = $this->createMock( + \Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator::class ); - $this->urlRewriteFactory = $this->getMock( + $this->storeViewService = $this->createMock(\Magento\CatalogUrlRewrite\Service\V1\StoreViewService::class); + $this->urlRewriteFactory = $this->createPartialMock( \Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory::class, [ 'create', - ], - [], - '', - false + ] ); $this->urlFinder = $this ->getMockBuilder(\Magento\UrlRewrite\Model\UrlFinderInterface::class) @@ -254,14 +223,11 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); - $mergeDataProviderFactory = $this->getMock( + $mergeDataProviderFactory = $this->createPartialMock( \Magento\UrlRewrite\Model\MergeDataProviderFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->mergeDataProvider = new \Magento\UrlRewrite\Model\MergeDataProvider; + $this->mergeDataProvider = new \Magento\UrlRewrite\Model\MergeDataProvider(); $mergeDataProviderFactory->expects($this->once())->method('create')->willReturn($this->mergeDataProvider); $this->categoryCollectionFactory = $this->getMockBuilder(CategoryCollectionFactory::class) @@ -303,15 +269,9 @@ public function testAfterImportData() $newSku = [['entity_id' => 'value'], ['entity_id' => 'value3']]; $websiteId = 'websiteId value'; $productsCount = count($this->products); - $websiteMock = $this->getMock( - \Magento\Store\Model\Website::class, - [ + $websiteMock = $this->createPartialMock(\Magento\Store\Model\Website::class, [ 'getStoreIds', - ], - [], - '', - false - ); + ]); $storeIds = [1, Store::DEFAULT_STORE_ID]; $websiteMock ->expects($this->once()) @@ -355,19 +315,13 @@ public function testAfterImportData() ->expects($this->exactly(1)) ->method('getStoreIdByCode') ->will($this->returnValueMap($map)); - $product = $this->getMock( - \Magento\Catalog\Model\Product::class, - [ + $product = $this->createPartialMock(\Magento\Catalog\Model\Product::class, [ 'getId', 'setId', 'getSku', 'setStoreId', 'getStoreId', - ], - [], - '', - false - ); + ]); $product ->expects($this->exactly($productsCount)) ->method('setId') @@ -581,7 +535,7 @@ public function testCategoriesUrlRewriteGenerate() ->expects($this->any()) ->method('getCanonicalUrlPath') ->will($this->returnValue($canonicalUrlPathWithCategory)); - $category = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false); + $category = $this->createMock(\Magento\Catalog\Model\Category::class); $category ->expects($this->any()) ->method('getId') diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/CategoryUrlPathAutogeneratorObserverTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/CategoryUrlPathAutogeneratorObserverTest.php index 9c7239b660d0e..1b4d1e08aa208 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/CategoryUrlPathAutogeneratorObserverTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/CategoryUrlPathAutogeneratorObserverTest.php @@ -7,7 +7,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -class CategoryUrlPathAutogeneratorObserverTest extends \PHPUnit_Framework_TestCase +class CategoryUrlPathAutogeneratorObserverTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\CatalogUrlRewrite\Observer\CategoryUrlPathAutogeneratorObserver */ protected $categoryUrlPathAutogeneratorObserver; @@ -36,23 +36,12 @@ class CategoryUrlPathAutogeneratorObserverTest extends \PHPUnit_Framework_TestCa protected function setUp() { - $this->observer = $this->getMock( + $this->observer = $this->createPartialMock( \Magento\Framework\Event\Observer::class, - ['getEvent', 'getCategory'], - [], - '', - false + ['getEvent', 'getCategory'] ); - $this->categoryResource = $this->getMock( - \Magento\Catalog\Model\ResourceModel\Category::class, - [], - [], - '', - false - ); - $this->category = $this->getMock( - \Magento\Catalog\Model\Category::class, - [ + $this->categoryResource = $this->createMock(\Magento\Catalog\Model\ResourceModel\Category::class); + $this->category = $this->createPartialMock(\Magento\Catalog\Model\Category::class, [ 'setUrlKey', 'setUrlPath', 'dataHasChangedFor', @@ -61,32 +50,18 @@ protected function setUp() 'getUrlKey', 'getStoreId', 'getData' - ], - [], - '', - false - ); + ]); $this->category->expects($this->any())->method('getResource')->willReturn($this->categoryResource); $this->observer->expects($this->any())->method('getEvent')->willReturnSelf(); $this->observer->expects($this->any())->method('getCategory')->willReturn($this->category); - $this->categoryUrlPathGenerator = $this->getMock( - \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator::class, - [], - [], - '', - false + $this->categoryUrlPathGenerator = $this->createMock( + \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator::class ); - $this->childrenCategoriesProvider = $this->getMock( + $this->childrenCategoriesProvider = $this->createMock( \Magento\CatalogUrlRewrite\Model\Category\ChildrenCategoriesProvider::class ); - $this->storeViewService = $this->getMock( - \Magento\CatalogUrlRewrite\Service\V1\StoreViewService::class, - [], - [], - '', - false - ); + $this->storeViewService = $this->createMock(\Magento\CatalogUrlRewrite\Service\V1\StoreViewService::class); $this->categoryUrlPathAutogeneratorObserver = (new ObjectManagerHelper($this))->getObject( \Magento\CatalogUrlRewrite\Observer\CategoryUrlPathAutogeneratorObserver::class, diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/ClearProductUrlsObserverTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/ClearProductUrlsObserverTest.php index b981a8f61c4ba..755a20a24025b 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/ClearProductUrlsObserverTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/ClearProductUrlsObserverTest.php @@ -16,7 +16,7 @@ * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ClearProductUrlsObserverTest extends \PHPUnit_Framework_TestCase +class ClearProductUrlsObserverTest extends \PHPUnit\Framework\TestCase { /** * @var ClearProductUrlsObserver diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/ProductProcessUrlRewriteSavingObserverTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/ProductProcessUrlRewriteSavingObserverTest.php index b5c4a7e5bd276..d294f6d022ef3 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/ProductProcessUrlRewriteSavingObserverTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/ProductProcessUrlRewriteSavingObserverTest.php @@ -6,10 +6,8 @@ namespace Magento\CatalogUrlRewrite\Test\Unit\Observer; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -use Magento\CatalogImportExport\Model\Import\Product as ImportProduct; -use Magento\Store\Model\Store; use Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\UrlRewrite\Service\V1\Data\UrlRewrite; /** @@ -18,7 +16,7 @@ * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ProductProcessUrlRewriteSavingObserverTest extends \PHPUnit_Framework_TestCase +class ProductProcessUrlRewriteSavingObserverTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\UrlRewrite\Model\UrlPersistInterface|\PHPUnit_Framework_MockObject_MockObject @@ -60,32 +58,23 @@ class ProductProcessUrlRewriteSavingObserverTest extends \PHPUnit_Framework_Test */ protected function setUp() { - $this->urlPersist = $this->getMock(\Magento\UrlRewrite\Model\UrlPersistInterface::class, [], [], '', false); - $this->product = $this->getMock( - \Magento\Catalog\Model\Product::class, - [ + $this->urlPersist = $this->createMock(\Magento\UrlRewrite\Model\UrlPersistInterface::class); + $this->product = $this->createPartialMock(\Magento\Catalog\Model\Product::class, [ 'getId', 'dataHasChangedFor', 'isVisibleInSiteVisibility', 'getIsChangedWebsites', 'getIsChangedCategories', 'getStoreId' - ], - [], - '', - false - ); + ]); $this->product->expects($this->any())->method('getId')->will($this->returnValue(3)); - $this->event = $this->getMock(\Magento\Framework\Event::class, ['getProduct'], [], '', false); + $this->event = $this->createPartialMock(\Magento\Framework\Event::class, ['getProduct']); $this->event->expects($this->any())->method('getProduct')->willReturn($this->product); - $this->observer = $this->getMock(\Magento\Framework\Event\Observer::class, ['getEvent'], [], '', false); + $this->observer = $this->createPartialMock(\Magento\Framework\Event\Observer::class, ['getEvent']); $this->observer->expects($this->any())->method('getEvent')->willReturn($this->event); - $this->productUrlRewriteGenerator = $this->getMock( + $this->productUrlRewriteGenerator = $this->createPartialMock( \Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator::class, - ['generate'], - [], - '', - false + ['generate'] ); $this->productUrlRewriteGenerator->expects($this->any()) ->method('generate') @@ -105,7 +94,7 @@ protected function setUp() * * @return array */ - public function testUrlKeyDataProvider() + public function urlKeyDataProvider() { return [ 'url changed' => [ @@ -175,7 +164,7 @@ public function testUrlKeyDataProvider() * @param int $expectedDeleteCount * @param int $expectedReplaceCount * - * @dataProvider testUrlKeyDataProvider + * @dataProvider urlKeyDataProvider */ public function testExecuteUrlKey( $isChangedUrlKey, diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/UrlRewriteHandlerTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/UrlRewriteHandlerTest.php index 3073ed1b28444..747e0cfa771fd 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/UrlRewriteHandlerTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/UrlRewriteHandlerTest.php @@ -5,8 +5,10 @@ */ namespace Magento\CatalogUrlRewrite\Test\Unit\Observer; +use Magento\Catalog\Model\ResourceModel\Product\Collection; use Magento\CatalogUrlRewrite\Observer\UrlRewriteHandler; use Magento\CatalogUrlRewrite\Model\Category\ChildrenCategoriesProvider; +use Magento\CatalogUrlRewrite\Model\CategoryBasedProductRewriteGenerator; use Magento\CatalogUrlRewrite\Model\CategoryUrlRewriteGenerator; use Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator; use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory; @@ -16,7 +18,10 @@ use Magento\UrlRewrite\Model\MergeDataProvider; use Magento\CatalogUrlRewrite\Model\CategoryProductUrlPathGenerator; -class UrlRewriteHandlerTest extends \PHPUnit_Framework_TestCase +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class UrlRewriteHandlerTest extends \PHPUnit\Framework\TestCase { /** * @var UrlRewriteHandler @@ -58,6 +63,11 @@ class UrlRewriteHandlerTest extends \PHPUnit_Framework_TestCase */ private $mergeDataProviderFactoryMock; + /** + * @var MergeDataProvider|\PHPUnit_Framework_MockObject_MockObject + */ + private $mergeDataProviderMock; + /** * @var Json|\PHPUnit_Framework_MockObject_MockObject */ @@ -85,7 +95,7 @@ protected function setUp() ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $mergeDataProviderMock = $this->getMockBuilder(MergeDataProvider::class) + $this->mergeDataProviderMock = $this->getMockBuilder(MergeDataProvider::class) ->disableOriginalConstructor() ->getMock(); $this->categoryBasedProductRewriteGeneratorMock = $this->getMockBuilder(CategoryProductUrlPathGenerator::class) @@ -93,8 +103,7 @@ protected function setUp() ->getMock(); $this->mergeDataProviderFactoryMock->expects($this->any()) ->method('create') - ->willReturn($mergeDataProviderMock); - + ->willReturn($this->mergeDataProviderMock); $this->serializerMock = $this->getMockBuilder(Json::class) ->disableOriginalConstructor() ->getMock(); @@ -111,6 +120,72 @@ protected function setUp() ); } + /** + * @test + */ + public function testGenerateProductUrlRewrites() + { + /* @var \Magento\Catalog\Model\Category|\PHPUnit_Framework_MockObject_MockObject $category */ + $category = $this->getMockBuilder(\Magento\Catalog\Model\Category::class) + ->setMethods(['getEntityId', 'getStoreId', 'getData', 'getAffectedProductIds']) + ->disableOriginalConstructor() + ->getMock(); + $category->expects($this->any()) + ->method('getEntityId') + ->willReturn(2); + $category->expects($this->any()) + ->method('getStoreId') + ->willReturn(1); + $category->expects($this->any()) + ->method('getData') + ->with('save_rewrites_history') + ->willReturn(true); + + /* @var \Magento\Catalog\Model\Category|\PHPUnit_Framework_MockObject_MockObject $childCategory1 */ + $childCategory1 = $this->getMockBuilder(\Magento\Catalog\Model\Category::class) + ->setMethods(['getEntityId']) + ->disableOriginalConstructor() + ->getMock(); + $childCategory1->expects($this->any()) + ->method('getEntityId') + ->willReturn(100); + + /* @var \Magento\Catalog\Model\Category|\PHPUnit_Framework_MockObject_MockObject $childCategory1 */ + $childCategory2 = $this->getMockBuilder(\Magento\Catalog\Model\Category::class) + ->setMethods(['getEntityId']) + ->disableOriginalConstructor() + ->getMock(); + $childCategory1->expects($this->any()) + ->method('getEntityId') + ->willReturn(200); + + $this->childrenCategoriesProviderMock->expects($this->once()) + ->method('getChildren') + ->with($category, true) + ->willReturn([$childCategory1, $childCategory2]); + + /** @var Collection|\PHPUnit_Framework_MockObject_MockObject $productCollection */ + $productCollection = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\Collection::class) + ->disableOriginalConstructor() + ->getMock(); + $productCollection->expects($this->any()) + ->method('addCategoriesFilter') + ->willReturnSelf(); + $productCollection->expects($this->any()) + ->method('addIdFilter') + ->willReturnSelf(); + $productCollection->expects($this->any())->method('setStoreId')->willReturnSelf(); + $productCollection->expects($this->any())->method('addAttributeToSelect')->willReturnSelf(); + $iterator = new \ArrayIterator([]); + $productCollection->expects($this->any())->method('getIterator')->will($this->returnValue($iterator)); + + $this->collectionFactoryMock->expects($this->any())->method('create')->willReturn($productCollection); + + $this->mergeDataProviderMock->expects($this->any())->method('getData')->willReturn([1, 2]); + + $this->urlRewriteHandler->generateProductUrlRewrites($category); + } + public function testDeleteCategoryRewritesForChildren() { $category = $this->getMockBuilder(\Magento\Catalog\Model\Category::class) diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Service/V1/StoreViewServiceTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Service/V1/StoreViewServiceTest.php index 21d9accffba43..7b80cc49ad527 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Service/V1/StoreViewServiceTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Service/V1/StoreViewServiceTest.php @@ -7,7 +7,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class StoreViewServiceTest extends \PHPUnit_Framework_TestCase +class StoreViewServiceTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\CatalogUrlRewrite\Service\V1\StoreViewService */ protected $storeViewService; @@ -26,7 +26,7 @@ class StoreViewServiceTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->config = $this->getMock(\Magento\Eav\Model\Config::class, [], [], '', false); + $this->config = $this->createMock(\Magento\Eav\Model\Config::class); $this->select = $this->getMockBuilder(\Magento\Framework\DB\Select::class) ->setMethods(['select', 'from', 'where', 'join']) ->disableOriginalConstructor() @@ -34,7 +34,7 @@ protected function setUp() $this->connection = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->resource = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); + $this->resource = $this->createMock(\Magento\Framework\App\ResourceConnection::class); $this->resource->expects($this->any())->method('getConnection')->willReturn($this->connection); $this->storeViewService = (new ObjectManager($this))->getObject( diff --git a/app/code/Magento/CatalogWidget/Block/Product/ProductsList.php b/app/code/Magento/CatalogWidget/Block/Product/ProductsList.php index 5809ecbe9fefc..373b88049c7b5 100644 --- a/app/code/Magento/CatalogWidget/Block/Product/ProductsList.php +++ b/app/code/Magento/CatalogWidget/Block/Product/ProductsList.php @@ -259,6 +259,14 @@ protected function getConditions() $conditions = $this->conditionsHelper->decode($conditions); } + foreach ($conditions as $key => $condition) { + if (!empty($condition['attribute']) + && in_array($condition['attribute'], ['special_from_date', 'special_to_date']) + ) { + $conditions[$key]['value'] = date('Y-m-d H:i:s', strtotime($condition['value'])); + } + } + $this->rule->loadPost(['conditions' => $conditions]); return $this->rule->getConditions(); } @@ -378,7 +386,7 @@ public function getTitle() /** * @return PriceCurrencyInterface * - * @deprecated + * @deprecated 100.2.0 */ private function getPriceCurrency() { diff --git a/app/code/Magento/CatalogWidget/Model/Rule.php b/app/code/Magento/CatalogWidget/Model/Rule.php index 9523177ec2ee7..0f7955cc66191 100644 --- a/app/code/Magento/CatalogWidget/Model/Rule.php +++ b/app/code/Magento/CatalogWidget/Model/Rule.php @@ -12,6 +12,7 @@ * Rule for catalog widget * * @api + * @since 100.0.2 */ class Rule extends \Magento\Rule\Model\AbstractModel { diff --git a/app/code/Magento/CatalogWidget/Test/Unit/Block/Product/ProductsListTest.php b/app/code/Magento/CatalogWidget/Test/Unit/Block/Product/ProductsListTest.php index ee87842c9bf2c..e871ed4359d5c 100644 --- a/app/code/Magento/CatalogWidget/Test/Unit/Block/Product/ProductsListTest.php +++ b/app/code/Magento/CatalogWidget/Test/Unit/Block/Product/ProductsListTest.php @@ -16,7 +16,7 @@ * Class ProductsListTest * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ProductsListTest extends \PHPUnit_Framework_TestCase +class ProductsListTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogWidget\Block\Product\ProductsList @@ -93,15 +93,15 @@ protected function setUp() ->setMethods(['getVisibleInCatalogIds']) ->disableOriginalConstructor() ->getMock(); - $this->httpContext = $this->getMock(\Magento\Framework\App\Http\Context::class, [], [], '', false); - $this->builder = $this->getMock(\Magento\Rule\Model\Condition\Sql\Builder::class, [], [], '', false); - $this->rule = $this->getMock(\Magento\CatalogWidget\Model\Rule::class, [], [], '', false); - $this->serializer = $this->getMock(\Magento\Framework\Serialize\Serializer\Json::class, [], [], '', false); + $this->httpContext = $this->createMock(\Magento\Framework\App\Http\Context::class); + $this->builder = $this->createMock(\Magento\Rule\Model\Condition\Sql\Builder::class); + $this->rule = $this->createMock(\Magento\CatalogWidget\Model\Rule::class); + $this->serializer = $this->createMock(\Magento\Framework\Serialize\Serializer\Json::class); $this->widgetConditionsHelper = $this->getMockBuilder(\Magento\Widget\Helper\Conditions::class) ->disableOriginalConstructor() ->getMock(); - $this->storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); - $this->design = $this->getMock(\Magento\Framework\View\DesignInterface::class); + $this->storeManager = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->design = $this->createMock(\Magento\Framework\View\DesignInterface::class); $objectManagerHelper = new ObjectManagerHelper($this); $arguments = $objectManagerHelper->getConstructArguments( @@ -120,7 +120,7 @@ protected function setUp() ); $this->request = $arguments['context']->getRequest(); $this->layout = $arguments['context']->getLayout(); - $this->priceCurrency = $this->getMock(PriceCurrencyInterface::class); + $this->priceCurrency = $this->createMock(PriceCurrencyInterface::class); $this->productsList = $objectManagerHelper->getObject( \Magento\CatalogWidget\Block\Product\ProductsList::class, @@ -136,7 +136,7 @@ public function testGetCacheKeyInfo() $store->expects($this->once())->method('getId')->willReturn(1); $this->storeManager->expects($this->once())->method('getStore')->willReturn($store); - $theme = $this->getMock(\Magento\Framework\View\Design\ThemeInterface::class); + $theme = $this->createMock(\Magento\Framework\View\Design\ThemeInterface::class); $theme->expects($this->once())->method('getId')->willReturn('blank'); $this->design->expects($this->once())->method('getDesignTheme')->willReturn($theme); @@ -288,6 +288,11 @@ public function testCreateCollection($pagerEnable, $productsCount, $productsPerP $this->collectionFactory->expects($this->once())->method('create')->willReturn($collection); $this->productsList->setData('conditions_encoded', 'some_serialized_conditions'); + $this->widgetConditionsHelper->expects($this->once()) + ->method('decode') + ->with('some_serialized_conditions') + ->willReturn([]); + $this->builder->expects($this->once())->method('attachConditionToCollection') ->with($collection, $this->getConditionsForCollection($collection)) ->willReturnSelf(); @@ -356,8 +361,11 @@ public function testGetIdentities() ])->disableOriginalConstructor() ->getMock(); - $product = $this->getMock(\Magento\Framework\DataObject\IdentityInterface::class, ['getIdentities']); - $notProduct = $this->getMock('NotProduct', ['getIdentities']); + $product = $this->createPartialMock(\Magento\Framework\DataObject\IdentityInterface::class, ['getIdentities']); + $notProduct = $this->getMockBuilder('NotProduct') + ->setMethods(['getIdentities']) + ->disableOriginalConstructor() + ->getMock(); $product->expects($this->once())->method('getIdentities')->willReturn(['product_identity']); $collection->expects($this->once())->method('getIterator')->willReturn( new \ArrayIterator([$product, $notProduct]) diff --git a/app/code/Magento/CatalogWidget/Test/Unit/Block/Product/Widget/ConditionsTest.php b/app/code/Magento/CatalogWidget/Test/Unit/Block/Product/Widget/ConditionsTest.php index 17e90fd5389d7..98692124bbf41 100644 --- a/app/code/Magento/CatalogWidget/Test/Unit/Block/Product/Widget/ConditionsTest.php +++ b/app/code/Magento/CatalogWidget/Test/Unit/Block/Product/Widget/ConditionsTest.php @@ -5,19 +5,19 @@ */ namespace Magento\CatalogWidget\Test\Unit\Block\Product\Widget; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -use Magento\CatalogWidget\Block\Product\Widget\Conditions; -use Magento\Framework\Registry; use Magento\Backend\Block\Template\Context; +use Magento\CatalogWidget\Block\Product\Widget\Conditions; use Magento\CatalogWidget\Model\Rule; -use Magento\Framework\View\LayoutInterface; +use Magento\Framework\Registry; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; use Magento\Framework\View\Element\BlockInterface; +use Magento\Framework\View\LayoutInterface; /** * Test class for \Magento\CatalogWidget\Block\Product\Widget\Conditions * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ConditionsTest extends \PHPUnit_Framework_TestCase +class ConditionsTest extends \PHPUnit\Framework\TestCase { /** * @var ObjectManagerHelper @@ -184,83 +184,20 @@ public function testConstructWithParamsFromBlock() public function testRender() { $data = ['area' => 'backend']; - $abstractElementMock = $this->getMock( + $abstractElementMock = $this->createPartialMock( \Magento\Framework\Data\Form\Element\AbstractElement::class, - ['getContainer'], - [], - '', - false - ); - $eventManagerMock = $this->getMock( - \Magento\Framework\Event\ManagerInterface::class, - [], - [], - '', - false - ); - $scopeConfigMock = $this->getMock( - \Magento\Framework\App\Config\ScopeConfigInterface::class, - [], - [], - '', - false - ); - $fieldsetMock = $this->getMock( - \Magento\Framework\Data\Form\Element\Fieldset::class, - [], - [], - '', - false - ); - $combineMock = $this->getMock( - \Magento\Rule\Model\Condition\Combine::class, - [], - [], - '', - false - ); - $resolverMock = $this->getMock( - \Magento\Framework\View\Element\Template\File\Resolver::class, - [], - [], - '', - false - ); - $filesystemMock = $this->getMock( - \Magento\Framework\Filesystem::class, - ['getDirectoryRead'], - [], - '', - false - ); - $validatorMock = $this->getMock( - \Magento\Framework\View\Element\Template\File\Validator::class, - [], - [], - '', - false - ); - $templateEnginePoolMock = $this->getMock( - \Magento\Framework\View\TemplateEnginePool::class, - [], - [], - '', - false - ); - $templateEngineMock = $this->getMock( - \Magento\Framework\View\TemplateEngineInterface::class, - [], - [], - '', - false - ); - $directoryReadMock = $this->getMock( - \Magento\Framework\Filesystem\Directory\ReadInterface::class, - [], - [], - '', - false + ['getContainer'] ); + $eventManagerMock = $this->createMock(\Magento\Framework\Event\ManagerInterface::class); + $scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $fieldsetMock = $this->createMock(\Magento\Framework\Data\Form\Element\Fieldset::class); + $combineMock = $this->createMock(\Magento\Rule\Model\Condition\Combine::class); + $resolverMock = $this->createMock(\Magento\Framework\View\Element\Template\File\Resolver::class); + $filesystemMock = $this->createPartialMock(\Magento\Framework\Filesystem::class, ['getDirectoryRead']); + $validatorMock = $this->createMock(\Magento\Framework\View\Element\Template\File\Validator::class); + $templateEnginePoolMock = $this->createMock(\Magento\Framework\View\TemplateEnginePool::class); + $templateEngineMock = $this->createMock(\Magento\Framework\View\TemplateEngineInterface::class); + $directoryReadMock = $this->createMock(\Magento\Framework\Filesystem\Directory\ReadInterface::class); $this->ruleMock->expects($this->once())->method('getConditions')->willReturn($combineMock); $combineMock->expects($this->once())->method('setJsFormObject')->willReturnSelf(); diff --git a/app/code/Magento/CatalogWidget/Test/Unit/Controller/Adminhtml/Product/Widget/ConditionsTest.php b/app/code/Magento/CatalogWidget/Test/Unit/Controller/Adminhtml/Product/Widget/ConditionsTest.php index 90c854f01181c..9b052d0fff242 100644 --- a/app/code/Magento/CatalogWidget/Test/Unit/Controller/Adminhtml/Product/Widget/ConditionsTest.php +++ b/app/code/Magento/CatalogWidget/Test/Unit/Controller/Adminhtml/Product/Widget/ConditionsTest.php @@ -8,7 +8,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -class ConditionsTest extends \PHPUnit_Framework_TestCase +class ConditionsTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogWidget\Controller\Adminhtml\Product\Widget\Conditions @@ -37,7 +37,7 @@ class ConditionsTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->rule = $this->getMock(\Magento\CatalogWidget\Model\Rule::class, [], [], '', false); + $this->rule = $this->createMock(\Magento\CatalogWidget\Model\Rule::class); $this->response = $this->getMockBuilder(\Magento\Framework\App\ResponseInterface::class) ->setMethods(['setBody', 'sendResponse']) ->disableOriginalConstructor() diff --git a/app/code/Magento/CatalogWidget/Test/Unit/Model/Rule/Condition/CombineTest.php b/app/code/Magento/CatalogWidget/Test/Unit/Model/Rule/Condition/CombineTest.php index 752faca43584c..849ae53a03148 100644 --- a/app/code/Magento/CatalogWidget/Test/Unit/Model/Rule/Condition/CombineTest.php +++ b/app/code/Magento/CatalogWidget/Test/Unit/Model/Rule/Condition/CombineTest.php @@ -11,7 +11,7 @@ /** * Class CombineTest */ -class CombineTest extends \PHPUnit_Framework_TestCase +class CombineTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogWidget\Model\Rule\Condition\Combine|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/CatalogWidget/Test/Unit/Model/Rule/Condition/ProductTest.php b/app/code/Magento/CatalogWidget/Test/Unit/Model/Rule/Condition/ProductTest.php index 7b57802060b35..09270b6b41fc7 100644 --- a/app/code/Magento/CatalogWidget/Test/Unit/Model/Rule/Condition/ProductTest.php +++ b/app/code/Magento/CatalogWidget/Test/Unit/Model/Rule/Condition/ProductTest.php @@ -3,7 +3,6 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ - namespace Magento\CatalogWidget\Test\Unit\Model\Rule\Condition; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; @@ -11,7 +10,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ProductTest extends \PHPUnit_Framework_TestCase +class ProductTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CatalogWidget\Model\Rule\Condition\Product @@ -26,25 +25,21 @@ class ProductTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManagerHelper = new ObjectManager($this); - $eavConfig = $this->getMock(\Magento\Eav\Model\Config::class, [], [], '', false); - $this->attributeMock = $this->getMock( - \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, - [], - [], - '', - false - ); + + $eavConfig = $this->createMock(\Magento\Eav\Model\Config::class); + $this->attributeMock = $this->createMock(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class); $eavConfig->expects($this->any())->method('getAttribute')->willReturn($this->attributeMock); - $ruleMock = $this->getMock(\Magento\SalesRule\Model\Rule::class, [], [], '', false); - $storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); - $storeMock = $this->getMock(\Magento\Store\Api\Data\StoreInterface::class); + $ruleMock = $this->createMock(\Magento\SalesRule\Model\Rule::class); + $storeManager = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); + $storeMock = $this->createMock(\Magento\Store\Api\Data\StoreInterface::class); $storeManager->expects($this->any())->method('getStore')->willReturn($storeMock); - $productResource = $this->getMock(\Magento\Catalog\Model\ResourceModel\Product::class, [], [], '', false); + $productResource = $this->createMock(\Magento\Catalog\Model\ResourceModel\Product::class); $productResource->expects($this->once())->method('loadAllAttributes')->willReturnSelf(); $productResource->expects($this->once())->method('getAttributesByCode')->willReturn([]); $productCategoryList = $this->getMockBuilder(\Magento\Catalog\Model\ProductCategoryList::class) ->disableOriginalConstructor() ->getMock(); + $this->model = $objectManagerHelper->getObject( \Magento\CatalogWidget\Model\Rule\Condition\Product::class, [ @@ -62,14 +57,8 @@ protected function setUp() public function testAddToCollection() { - $collectionMock = $this->getMock( - \Magento\Catalog\Model\ResourceModel\Product\Collection::class, - [], - [], - '', - false - ); - $selectMock = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); + $collectionMock = $this->createMock(\Magento\Catalog\Model\ResourceModel\Product\Collection::class); + $selectMock = $this->createMock(\Magento\Framework\DB\Select::class); $collectionMock->expects($this->once())->method('getSelect')->willReturn($selectMock); $selectMock->expects($this->any())->method('join')->willReturnSelf(); $this->attributeMock->expects($this->any())->method('getAttributeCode')->willReturn('code'); diff --git a/app/code/Magento/CatalogWidget/Test/Unit/Model/RuleTest.php b/app/code/Magento/CatalogWidget/Test/Unit/Model/RuleTest.php index f320ab183f767..24e63f1c93709 100644 --- a/app/code/Magento/CatalogWidget/Test/Unit/Model/RuleTest.php +++ b/app/code/Magento/CatalogWidget/Test/Unit/Model/RuleTest.php @@ -5,7 +5,7 @@ */ namespace Magento\CatalogWidget\Test\Unit\Model; -class RuleTest extends \PHPUnit_Framework_TestCase +class RuleTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager diff --git a/app/code/Magento/Checkout/Block/Cart.php b/app/code/Magento/Checkout/Block/Cart.php index 5a4704c981c23..7940c37917624 100644 --- a/app/code/Magento/Checkout/Block/Cart.php +++ b/app/code/Magento/Checkout/Block/Cart.php @@ -239,6 +239,7 @@ public function getItemsCount() * Render pagination HTML * * @return string + * @since 100.2.0 */ public function getPagerHtml() { diff --git a/app/code/Magento/Checkout/Block/Cart/Grid.php b/app/code/Magento/Checkout/Block/Cart/Grid.php index cfac9ac804e7e..bfe4b6ceed9d0 100644 --- a/app/code/Magento/Checkout/Block/Cart/Grid.php +++ b/app/code/Magento/Checkout/Block/Cart/Grid.php @@ -13,6 +13,7 @@ * custom_items weren't set to cart block * * @api + * @since 100.2.0 */ class Grid extends \Magento\Checkout\Block\Cart { @@ -55,6 +56,7 @@ class Grid extends \Magento\Checkout\Block\Cart * @param \Magento\Quote\Model\ResourceModel\Quote\Item\CollectionFactory $itemCollectionFactory * @param \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $joinProcessor * @param array $data + * @since 100.2.0 */ public function __construct( \Magento\Framework\View\Element\Template\Context $context, @@ -87,6 +89,7 @@ public function __construct( * Configuration path is Store->Configuration->Sales->Checkout->Shopping Cart->Number of items to display pager * * @return void + * @since 100.2.0 */ protected function _construct() { @@ -100,6 +103,7 @@ protected function _construct() /** * {@inheritdoc} + * @since 100.2.0 */ protected function _prepareLayout() { @@ -124,6 +128,7 @@ protected function _prepareLayout() * Prepare quote items collection for pager * * @return \Magento\Quote\Model\ResourceModel\Quote\Item\Collection + * @since 100.2.0 */ public function getItemsForGrid() { @@ -142,6 +147,7 @@ public function getItemsForGrid() /** * {@inheritdoc} + * @since 100.2.0 */ public function getItems() { diff --git a/app/code/Magento/Checkout/Block/Cart/Shipping.php b/app/code/Magento/Checkout/Block/Cart/Shipping.php index f00b6ed8c5be9..7b0ab1bc03e5b 100644 --- a/app/code/Magento/Checkout/Block/Cart/Shipping.php +++ b/app/code/Magento/Checkout/Block/Cart/Shipping.php @@ -90,6 +90,7 @@ public function getBaseUrl() /** * @return bool|string + * @since 100.2.0 */ public function getSerializedCheckoutConfig() { diff --git a/app/code/Magento/Checkout/Block/Cart/Sidebar.php b/app/code/Magento/Checkout/Block/Cart/Sidebar.php index 0ff2081b0e25e..5c237eecf0a9f 100644 --- a/app/code/Magento/Checkout/Block/Cart/Sidebar.php +++ b/app/code/Magento/Checkout/Block/Cart/Sidebar.php @@ -88,6 +88,7 @@ public function getConfig() /** * @return string + * @since 100.2.0 */ public function getSerializedConfig() { diff --git a/app/code/Magento/Checkout/Block/Cart/ValidationMessages.php b/app/code/Magento/Checkout/Block/Cart/ValidationMessages.php index 1086b601df47c..2cc07f49b6dfa 100644 --- a/app/code/Magento/Checkout/Block/Cart/ValidationMessages.php +++ b/app/code/Magento/Checkout/Block/Cart/ValidationMessages.php @@ -15,10 +15,14 @@ */ class ValidationMessages extends \Magento\Framework\View\Element\Messages { - /** @var \Magento\Checkout\Helper\Cart */ + /** + * @var \Magento\Checkout\Helper\Cart + */ protected $cartHelper; - /** @var \Magento\Framework\Locale\CurrencyInterface */ + /** + * @var \Magento\Framework\Locale\CurrencyInterface + */ protected $currency; /** @@ -86,7 +90,7 @@ protected function validateMinimumAmount() /** * @return \Magento\Quote\Model\Quote\Validator\MinimumOrderAmount\ValidationMessage - * @deprecated + * @deprecated 100.1.0 */ private function getMinimumAmountErrorMessage() { diff --git a/app/code/Magento/Checkout/Block/Checkout/AttributeMerger.php b/app/code/Magento/Checkout/Block/Checkout/AttributeMerger.php index 888b7fdbd0945..4ee3d070d5b77 100644 --- a/app/code/Magento/Checkout/Block/Checkout/AttributeMerger.php +++ b/app/code/Magento/Checkout/Block/Checkout/AttributeMerger.php @@ -379,7 +379,7 @@ protected function getFieldOptions($attributeCode, array $attributeConfig) * * @param array $countryOptions * @return array - * @deprecated + * @deprecated 100.2.0 */ protected function orderCountryOptions(array $countryOptions) { diff --git a/app/code/Magento/Checkout/Block/Checkout/LayoutProcessor.php b/app/code/Magento/Checkout/Block/Checkout/LayoutProcessor.php index eed7b444923f3..f47e514948d69 100644 --- a/app/code/Magento/Checkout/Block/Checkout/LayoutProcessor.php +++ b/app/code/Magento/Checkout/Block/Checkout/LayoutProcessor.php @@ -65,7 +65,7 @@ public function __construct( } /** - * @deprecated + * @deprecated 100.0.11 * @return \Magento\Customer\Model\Options */ private function getOptions() @@ -345,7 +345,7 @@ private function getBillingAddressComponent($paymentCode, $elements) * Get checkout data helper instance * * @return Data - * @deprecated + * @deprecated 100.1.4 */ private function getCheckoutDataHelper() { @@ -360,7 +360,7 @@ private function getCheckoutDataHelper() * Retrieve Shipping Configuration. * * @return \Magento\Shipping\Model\Config - * @deprecated + * @deprecated 100.2.0 */ private function getShippingConfig() { @@ -375,7 +375,7 @@ private function getShippingConfig() * Get store resolver. * * @return StoreResolverInterface - * @deprecated + * @deprecated 100.2.0 */ private function getStoreResolver() { diff --git a/app/code/Magento/Checkout/Block/Onepage.php b/app/code/Magento/Checkout/Block/Onepage.php index 457e5ee5fbb46..bc3cd43a024a6 100644 --- a/app/code/Magento/Checkout/Block/Onepage.php +++ b/app/code/Magento/Checkout/Block/Onepage.php @@ -115,6 +115,7 @@ public function getBaseUrl() /** * @return bool|string + * @since 100.2.0 */ public function getSerializedCheckoutConfig() { diff --git a/app/code/Magento/Checkout/Block/Onepage/Success.php b/app/code/Magento/Checkout/Block/Onepage/Success.php index fef3988bc52f8..e7cfaf68cc789 100644 --- a/app/code/Magento/Checkout/Block/Onepage/Success.php +++ b/app/code/Magento/Checkout/Block/Onepage/Success.php @@ -127,6 +127,7 @@ protected function canViewOrder(Order $order) /** * @return string + * @since 100.2.0 */ public function getContinueUrl() { diff --git a/app/code/Magento/Checkout/Block/Shipping/Price.php b/app/code/Magento/Checkout/Block/Shipping/Price.php index a98cd192da6bf..591ee22728fbe 100644 --- a/app/code/Magento/Checkout/Block/Shipping/Price.php +++ b/app/code/Magento/Checkout/Block/Shipping/Price.php @@ -11,7 +11,7 @@ /** * Class Price - * @deprecated + * @deprecated 100.1.0 */ class Price extends AbstractCart { diff --git a/app/code/Magento/Checkout/Controller/Cart/Addgroup.php b/app/code/Magento/Checkout/Controller/Cart/Addgroup.php index 046dd0b8082c1..8654bdbde5893 100644 --- a/app/code/Magento/Checkout/Controller/Cart/Addgroup.php +++ b/app/code/Magento/Checkout/Controller/Cart/Addgroup.php @@ -6,6 +6,8 @@ */ namespace Magento\Checkout\Controller\Cart; +use Magento\Sales\Model\Order\Item; + class Addgroup extends \Magento\Checkout\Controller\Cart { /** @@ -13,7 +15,7 @@ class Addgroup extends \Magento\Checkout\Controller\Cart */ public function execute() { - $orderItemIds = $this->getRequest()->getParam('order_items', []); + $orderItemIds = $this->getRequest()->getPost('order_items'); if (is_array($orderItemIds)) { $itemsCollection = $this->_objectManager->create(\Magento\Sales\Model\Order\Item::class) ->getCollection() @@ -22,7 +24,7 @@ public function execute() /* @var $itemsCollection \Magento\Sales\Model\ResourceModel\Order\Item\Collection */ foreach ($itemsCollection as $item) { try { - $this->cart->addOrderItem($item, 1); + $this->addOrderItem($item); } catch (\Magento\Framework\Exception\LocalizedException $e) { if ($this->_checkoutSession->getUseNotice(true)) { $this->messageManager->addNotice($e->getMessage()); @@ -42,4 +44,25 @@ public function execute() } return $this->_goBack(); } + + /** + * Add item to cart. + * + * Add item to cart only if it's belongs to customer. + * + * @param Item $item + * @return void + */ + private function addOrderItem(Item $item) + { + /** @var \Magento\Customer\Model\Session $session */ + $session = $this->cart->getCustomerSession(); + if ($session->isLoggedIn()) { + $orderCustomerId = $item->getOrder()->getCustomerId(); + $currentCustomerId = $session->getCustomer()->getId(); + if ($orderCustomerId == $currentCustomerId) { + $this->cart->addOrderItem($item, 1); + } + } + } } diff --git a/app/code/Magento/Checkout/Controller/Express/RedirectLoginInterface.php b/app/code/Magento/Checkout/Controller/Express/RedirectLoginInterface.php index 28639ef59cbbd..a5777766c3949 100644 --- a/app/code/Magento/Checkout/Controller/Express/RedirectLoginInterface.php +++ b/app/code/Magento/Checkout/Controller/Express/RedirectLoginInterface.php @@ -5,6 +5,10 @@ */ namespace Magento\Checkout\Controller\Express; +/** + * Interface \Magento\Checkout\Controller\Express\RedirectLoginInterface + * + */ interface RedirectLoginInterface { /** diff --git a/app/code/Magento/Checkout/Controller/Sidebar/RemoveItem.php b/app/code/Magento/Checkout/Controller/Sidebar/RemoveItem.php index 04210dad8fe75..c84aec336a589 100644 --- a/app/code/Magento/Checkout/Controller/Sidebar/RemoveItem.php +++ b/app/code/Magento/Checkout/Controller/Sidebar/RemoveItem.php @@ -91,7 +91,7 @@ protected function jsonResponse($error = '') /** * @return \Magento\Framework\Data\Form\FormKey\Validator - * @deprecated + * @deprecated 100.0.9 */ private function getFormKeyValidator() { diff --git a/app/code/Magento/Checkout/CustomerData/Cart.php b/app/code/Magento/Checkout/CustomerData/Cart.php index 96ea0e366a276..ddb077462ef10 100644 --- a/app/code/Magento/Checkout/CustomerData/Cart.php +++ b/app/code/Magento/Checkout/CustomerData/Cart.php @@ -87,10 +87,12 @@ public function __construct( public function getSectionData() { $totals = $this->getQuote()->getTotals(); + $subtotalAmount = $totals['subtotal']->getValue(); return [ 'summary_count' => $this->getSummaryCount(), + 'subtotalAmount' => $subtotalAmount, 'subtotal' => isset($totals['subtotal']) - ? $this->checkoutHelper->formatPrice($totals['subtotal']->getValue()) + ? $this->checkoutHelper->formatPrice($subtotalAmount) : 0, 'possible_onepage_checkout' => $this->isPossibleOnepageCheckout(), 'items' => $this->getRecentItems(), diff --git a/app/code/Magento/Checkout/Model/Cart.php b/app/code/Magento/Checkout/Model/Cart.php index fdddd91aab456..be5692a894865 100644 --- a/app/code/Magento/Checkout/Model/Cart.php +++ b/app/code/Magento/Checkout/Model/Cart.php @@ -15,7 +15,7 @@ * Shopping cart model * @api * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - * @deprecated + * @deprecated 100.1.0 */ class Cart extends DataObject implements CartInterface { @@ -735,7 +735,7 @@ public function updateItem($itemId, $requestInfo = null, $updatingParams = null) /** * Getter for RequestInfoFilter * - * @deprecated + * @deprecated 100.1.2 * @return \Magento\Checkout\Model\Cart\RequestInfoFilterInterface */ private function getRequestInfoFilter() diff --git a/app/code/Magento/Checkout/Model/Cart/CartInterface.php b/app/code/Magento/Checkout/Model/Cart/CartInterface.php index 07fde2e6d7c38..2f4b679381740 100644 --- a/app/code/Magento/Checkout/Model/Cart/CartInterface.php +++ b/app/code/Magento/Checkout/Model/Cart/CartInterface.php @@ -12,7 +12,7 @@ * * @api * @author Magento Core Team - * @deprecated + * @deprecated 100.1.0 */ interface CartInterface { diff --git a/app/code/Magento/Checkout/Model/Cart/RequestInfoFilterComposite.php b/app/code/Magento/Checkout/Model/Cart/RequestInfoFilterComposite.php index 797d159c448af..f38e15dd628fd 100644 --- a/app/code/Magento/Checkout/Model/Cart/RequestInfoFilterComposite.php +++ b/app/code/Magento/Checkout/Model/Cart/RequestInfoFilterComposite.php @@ -9,6 +9,7 @@ /** * Class RequestInfoFilterComposite * @api + * @since 100.1.2 */ class RequestInfoFilterComposite implements RequestInfoFilterInterface { @@ -19,6 +20,7 @@ class RequestInfoFilterComposite implements RequestInfoFilterInterface /** * @param RequestInfoFilter[] $filters + * @since 100.1.2 */ public function __construct( $filters = [] @@ -31,6 +33,7 @@ public function __construct( * * @param \Magento\Framework\DataObject $params * @return $this + * @since 100.1.2 */ public function filter(\Magento\Framework\DataObject $params) { diff --git a/app/code/Magento/Checkout/Model/Cart/RequestInfoFilterInterface.php b/app/code/Magento/Checkout/Model/Cart/RequestInfoFilterInterface.php index b9523469597e8..511b36e9290fd 100644 --- a/app/code/Magento/Checkout/Model/Cart/RequestInfoFilterInterface.php +++ b/app/code/Magento/Checkout/Model/Cart/RequestInfoFilterInterface.php @@ -9,6 +9,7 @@ /** * Interface RequestInfoFilterInterface used by composite and leafs to implement filtering * @api + * @since 100.1.2 */ interface RequestInfoFilterInterface { @@ -17,6 +18,7 @@ interface RequestInfoFilterInterface * * @param \Magento\Framework\DataObject $params * @return RequestInfoFilterInterface + * @since 100.1.2 */ public function filter(\Magento\Framework\DataObject $params); } diff --git a/app/code/Magento/Checkout/Model/GuestPaymentInformationManagement.php b/app/code/Magento/Checkout/Model/GuestPaymentInformationManagement.php index d8f57534c99d4..6779da354faf8 100644 --- a/app/code/Magento/Checkout/Model/GuestPaymentInformationManagement.php +++ b/app/code/Magento/Checkout/Model/GuestPaymentInformationManagement.php @@ -136,7 +136,7 @@ public function getPaymentInformation($cartId) * Get logger instance * * @return \Psr\Log\LoggerInterface - * @deprecated + * @deprecated 100.2.0 */ private function getLogger() { diff --git a/app/code/Magento/Checkout/Model/PaymentDetails.php b/app/code/Magento/Checkout/Model/PaymentDetails.php index b2eb567f9a899..803f93da2b845 100644 --- a/app/code/Magento/Checkout/Model/PaymentDetails.php +++ b/app/code/Magento/Checkout/Model/PaymentDetails.php @@ -12,7 +12,7 @@ class PaymentDetails extends \Magento\Framework\Model\AbstractExtensibleModel im \Magento\Checkout\Api\Data\PaymentDetailsInterface { /** - * @{inheritdoc} + * {@inheritdoc} */ public function getPaymentMethods() { @@ -20,7 +20,7 @@ public function getPaymentMethods() } /** - * @{inheritdoc} + * {@inheritdoc} */ public function setPaymentMethods($paymentMethods) { @@ -28,7 +28,7 @@ public function setPaymentMethods($paymentMethods) } /** - * @{inheritdoc} + * {@inheritdoc} */ public function getTotals() { @@ -36,7 +36,7 @@ public function getTotals() } /** - * @{inheritdoc} + * {@inheritdoc} */ public function setTotals($totals) { diff --git a/app/code/Magento/Checkout/Model/PaymentInformationManagement.php b/app/code/Magento/Checkout/Model/PaymentInformationManagement.php index 248d319794ecd..3d6b0aa0cdc12 100644 --- a/app/code/Magento/Checkout/Model/PaymentInformationManagement.php +++ b/app/code/Magento/Checkout/Model/PaymentInformationManagement.php @@ -14,7 +14,7 @@ class PaymentInformationManagement implements \Magento\Checkout\Api\PaymentInfor { /** * @var \Magento\Quote\Api\BillingAddressManagementInterface - * @deprecated This call was substituted to eliminate extra quote::save call + * @deprecated 100.2.0 This call was substituted to eliminate extra quote::save call */ protected $billingAddressManagement; @@ -139,7 +139,7 @@ public function getPaymentInformation($cartId) * Get logger instance * * @return \Psr\Log\LoggerInterface - * @deprecated + * @deprecated 100.2.0 */ private function getLogger() { @@ -153,7 +153,7 @@ private function getLogger() * Get Cart repository * * @return \Magento\Quote\Api\CartRepositoryInterface - * @deprecated + * @deprecated 100.2.0 */ private function getCartRepository() { diff --git a/app/code/Magento/Checkout/Model/ShippingInformationManagement.php b/app/code/Magento/Checkout/Model/ShippingInformationManagement.php index 8774962c93f04..d8142d033f78c 100644 --- a/app/code/Magento/Checkout/Model/ShippingInformationManagement.php +++ b/app/code/Magento/Checkout/Model/ShippingInformationManagement.php @@ -49,25 +49,25 @@ class ShippingInformationManagement implements \Magento\Checkout\Api\ShippingInf /** * @var QuoteAddressValidator - * @deprecated + * @deprecated 100.2.0 */ protected $addressValidator; /** * @var \Magento\Customer\Api\AddressRepositoryInterface - * @deprecated + * @deprecated 100.2.0 */ protected $addressRepository; /** * @var \Magento\Framework\App\Config\ScopeConfigInterface - * @deprecated + * @deprecated 100.2.0 */ protected $scopeConfig; /** * @var \Magento\Quote\Model\Quote\TotalsCollector - * @deprecated + * @deprecated 100.2.0 */ protected $totalsCollector; diff --git a/app/code/Magento/Checkout/Model/Sidebar.php b/app/code/Magento/Checkout/Model/Sidebar.php index 4276d7d07f3c3..1a0e3aa818351 100644 --- a/app/code/Magento/Checkout/Model/Sidebar.php +++ b/app/code/Magento/Checkout/Model/Sidebar.php @@ -13,7 +13,7 @@ use Magento\Quote\Model\Quote\Address\Total; /** - * @deprecated + * @deprecated 100.1.0 */ class Sidebar { diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Cart/AbstractCartTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Cart/AbstractCartTest.php index a4bf557889148..aecaf0ec9f039 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/Cart/AbstractCartTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/Cart/AbstractCartTest.php @@ -7,7 +7,7 @@ use \Magento\Checkout\Block\Cart\AbstractCart; -class AbstractCartTest extends \PHPUnit_Framework_TestCase +class AbstractCartTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager @@ -26,7 +26,7 @@ protected function setUp() */ public function testGetItemRenderer($type, $expectedType) { - $renderer = $this->getMock(\Magento\Framework\View\Element\RendererList::class, [], [], '', false); + $renderer = $this->createMock(\Magento\Framework\View\Element\RendererList::class); $renderer->expects( $this->once() @@ -39,13 +39,7 @@ public function testGetItemRenderer($type, $expectedType) $this->returnValue('rendererObject') ); - $layout = $this->getMock( - \Magento\Framework\View\Layout::class, - ['getChildName', 'getBlock'], - [], - '', - false - ); + $layout = $this->createPartialMock(\Magento\Framework\View\Layout::class, ['getChildName', 'getBlock']); $layout->expects($this->once())->method('getChildName')->will($this->returnValue('renderer.list')); @@ -87,13 +81,7 @@ public function getItemRendererDataProvider() */ public function testGetItemRendererThrowsExceptionForNonexistentRenderer() { - $layout = $this->getMock( - \Magento\Framework\View\Layout::class, - ['getChildName', 'getBlock'], - [], - '', - false - ); + $layout = $this->createPartialMock(\Magento\Framework\View\Layout::class, ['getChildName', 'getBlock']); $layout->expects($this->once())->method('getChildName')->will($this->returnValue(null)); /** @var $block \Magento\Checkout\Block\Cart\AbstractCart */ @@ -118,9 +106,9 @@ public function testGetItemRendererThrowsExceptionForNonexistentRenderer() public function testGetTotalsCache($expectedResult, $isVirtual) { $totals = $isVirtual ? ['billing_totals'] : ['shipping_totals']; - $addressMock = $this->getMock(\Magento\Quote\Model\Quote\Address::class, [], [], '', false); - $checkoutSessionMock = $this->getMock(\Magento\Checkout\Model\Session::class, [], [], '', false); - $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); + $addressMock = $this->createMock(\Magento\Quote\Model\Quote\Address::class); + $checkoutSessionMock = $this->createMock(\Magento\Checkout\Model\Session::class); + $quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class); $checkoutSessionMock->expects($this->once())->method('getQuote')->willReturn($quoteMock); $quoteMock->expects($this->once())->method('isVirtual')->willReturn($isVirtual); diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Cart/CartTotalsProcessorTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Cart/CartTotalsProcessorTest.php index d9c11f1da01d2..525c36034897f 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/Cart/CartTotalsProcessorTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/Cart/CartTotalsProcessorTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Checkout\Test\Unit\Block\Cart; -class CartTotalsProcessorTest extends \PHPUnit_Framework_TestCase +class CartTotalsProcessorTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Checkout\Block\Cart\CartTotalsProcessor @@ -19,7 +19,7 @@ class CartTotalsProcessorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->scopeConfig = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->scopeConfig = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $this->model = new \Magento\Checkout\Block\Cart\CartTotalsProcessor($this->scopeConfig); } diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Cart/GridTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Cart/GridTest.php index fbc8da3a83cf1..390c7ae6074f3 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/Cart/GridTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/Cart/GridTest.php @@ -11,7 +11,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class GridTest extends \PHPUnit_Framework_TestCase +class GridTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Checkout\Block\Cart\Grid diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Cart/Item/Renderer/Actions/EditTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Cart/Item/Renderer/Actions/EditTest.php index 6c271d9c7af6b..f66cfb2ceac17 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/Cart/Item/Renderer/Actions/EditTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/Cart/Item/Renderer/Actions/EditTest.php @@ -9,7 +9,7 @@ use Magento\Checkout\Block\Cart\Item\Renderer\Actions\Edit; use Magento\Quote\Model\Quote\Item; -class EditTest extends \PHPUnit_Framework_TestCase +class EditTest extends \PHPUnit\Framework\TestCase { /** * @var Edit diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Cart/Item/Renderer/Actions/GenericTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Cart/Item/Renderer/Actions/GenericTest.php index 037454169c1c0..56299a758948f 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/Cart/Item/Renderer/Actions/GenericTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/Cart/Item/Renderer/Actions/GenericTest.php @@ -9,7 +9,7 @@ use Magento\Checkout\Block\Cart\Item\Renderer\Actions\Generic; use Magento\Quote\Model\Quote\Item; -class GenericTest extends \PHPUnit_Framework_TestCase +class GenericTest extends \PHPUnit\Framework\TestCase { /** * @var Generic diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Cart/Item/Renderer/Actions/RemoveTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Cart/Item/Renderer/Actions/RemoveTest.php index 1f2b27c65d945..e939b8d4b15de 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/Cart/Item/Renderer/Actions/RemoveTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/Cart/Item/Renderer/Actions/RemoveTest.php @@ -9,7 +9,7 @@ use Magento\Checkout\Helper\Cart; use Magento\Quote\Model\Quote\Item; -class RemoveTest extends \PHPUnit_Framework_TestCase +class RemoveTest extends \PHPUnit\Framework\TestCase { /** * @var Remove diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Cart/Item/Renderer/ActionsTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Cart/Item/Renderer/ActionsTest.php index 35ebde324f3a7..bcec37e0c7bf0 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/Cart/Item/Renderer/ActionsTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/Cart/Item/Renderer/ActionsTest.php @@ -9,7 +9,7 @@ use Magento\Checkout\Block\Cart\Item\Renderer\Actions\Generic; use Magento\Quote\Model\Quote\Item; -class ActionsTest extends \PHPUnit_Framework_TestCase +class ActionsTest extends \PHPUnit\Framework\TestCase { /** * @var Actions @@ -68,6 +68,10 @@ public function testToHtml() $childNameTwo = 'child.2'; $childNames = [$childNameOne, $childNameTwo]; + $this->scopeConfigMock->expects($this->once()) + ->method('getValue') + ->willReturn(false); + /** * @var Item|\PHPUnit_Framework_MockObject_MockObject $itemMock */ diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Cart/Item/RendererTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Cart/Item/RendererTest.php index 6e5953562c00d..d963fa2d76e6b 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/Cart/Item/RendererTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/Cart/Item/RendererTest.php @@ -11,7 +11,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class RendererTest extends \PHPUnit_Framework_TestCase +class RendererTest extends \PHPUnit\Framework\TestCase { /** * @var Renderer @@ -32,7 +32,7 @@ protected function setUp() { $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->layout = $this->getMock(\Magento\Framework\View\LayoutInterface::class); + $this->layout = $this->createMock(\Magento\Framework\View\LayoutInterface::class); $context = $this->getMockBuilder(\Magento\Framework\View\Element\Template\Context::class) ->disableOriginalConstructor() @@ -69,17 +69,14 @@ public function testGetProductForThumbnail() protected function _initProduct() { /** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $product */ - $product = $this->getMock( + $product = $this->createPartialMock( \Magento\Catalog\Model\Product::class, - ['getName', '__wakeup', 'getIdentities'], - [], - '', - false + ['getName', '__wakeup', 'getIdentities'] ); $product->expects($this->any())->method('getName')->will($this->returnValue('Parent Product')); /** @var Item|\PHPUnit_Framework_MockObject_MockObject $item */ - $item = $this->getMock(\Magento\Quote\Model\Quote\Item::class, [], [], '', false); + $item = $this->createMock(\Magento\Quote\Model\Quote\Item::class); $item->expects($this->any())->method('getProduct')->will($this->returnValue($product)); $this->_renderer->setItem($item); diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Cart/LayoutProcessorTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Cart/LayoutProcessorTest.php index 2e10cb3fde7a9..d3ceb3eaae772 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/Cart/LayoutProcessorTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/Cart/LayoutProcessorTest.php @@ -5,9 +5,8 @@ */ namespace Magento\Checkout\Test\Unit\Block\Cart; -class LayoutProcessorTest extends \PHPUnit_Framework_TestCase +class LayoutProcessorTest extends \PHPUnit\Framework\TestCase { - /** * @var \Magento\Checkout\Block\Cart\LayoutProcessor */ diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Cart/LinkTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Cart/LinkTest.php index ba870cd3980f9..2478270e0aec6 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/Cart/LinkTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/Cart/LinkTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Checkout\Test\Unit\Block\Cart; -class LinkTest extends \PHPUnit_Framework_TestCase +class LinkTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Cart/ShippingTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Cart/ShippingTest.php index 4705402f6a1c1..e419a1535207e 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/Cart/ShippingTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/Cart/ShippingTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Checkout\Test\Unit\Block\Cart; -class ShippingTest extends \PHPUnit_Framework_TestCase +class ShippingTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Checkout\Block\Cart\Shipping @@ -54,17 +54,11 @@ class ShippingTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->context = $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false); - $this->customerSession = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); - $this->checkoutSession = $this->getMock(\Magento\Checkout\Model\Session::class, [], [], '', false); - $this->configProvider = $this->getMock( - \Magento\Checkout\Model\CompositeConfigProvider::class, - [], - [], - '', - false - ); - $this->layoutProcessor = $this->getMock(\Magento\Checkout\Block\Checkout\LayoutProcessorInterface::class); + $this->context = $this->createMock(\Magento\Framework\View\Element\Template\Context::class); + $this->customerSession = $this->createMock(\Magento\Customer\Model\Session::class); + $this->checkoutSession = $this->createMock(\Magento\Checkout\Model\Session::class); + $this->configProvider = $this->createMock(\Magento\Checkout\Model\CompositeConfigProvider::class); + $this->layoutProcessor = $this->createMock(\Magento\Checkout\Block\Checkout\LayoutProcessorInterface::class); $this->layout = [ 'components' => [ 'firstComponent' => ['param' => 'value'], @@ -72,9 +66,9 @@ protected function setUp() ] ]; - $this->storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->storeManager = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); $this->context->expects($this->once())->method('getStoreManager')->willReturn($this->storeManager); - $this->serializer = $this->getMock(\Magento\Framework\Serialize\Serializer\Json::class, [], [], '', false); + $this->serializer = $this->createMock(\Magento\Framework\Serialize\Serializer\Json::class); $this->model = new \Magento\Checkout\Block\Cart\Shipping( $this->context, @@ -117,7 +111,7 @@ public function testGetJsLayout() public function testGetBaseUrl() { $baseUrl = 'baseUrl'; - $storeMock = $this->getMock(\Magento\Store\Model\Store::class, ['getBaseUrl'], [], '', false); + $storeMock = $this->createPartialMock(\Magento\Store\Model\Store::class, ['getBaseUrl']); $storeMock->expects($this->once())->method('getBaseUrl')->willReturn($baseUrl); $this->storeManager->expects($this->once())->method('getStore')->willReturn($storeMock); $this->assertEquals($baseUrl, $this->model->getBaseUrl()); diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Cart/SidebarTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Cart/SidebarTest.php index c0604c1ea13ec..88751b899d7c9 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/Cart/SidebarTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/Cart/SidebarTest.php @@ -8,7 +8,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class SidebarTest extends \PHPUnit_Framework_TestCase +class SidebarTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager */ protected $_objectManager; @@ -62,26 +62,17 @@ protected function setUp() { $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->requestMock = $this->getMock(\Magento\Framework\App\RequestInterface::class); - $this->layoutMock = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); - $this->checkoutSessionMock = $this->getMock(\Magento\Checkout\Model\Session::class, [], [], '', false); - $this->urlBuilderMock = $this->getMock(\Magento\Framework\UrlInterface::class, [], [], '', false); - $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class, [], [], '', false); - $this->imageHelper = $this->getMock(\Magento\Catalog\Helper\Image::class, [], [], '', false); - $this->scopeConfigMock = $this->getMock( - \Magento\Framework\App\Config\ScopeConfigInterface::class, - [], - [], - '', - false - ); + $this->requestMock = $this->createMock(\Magento\Framework\App\RequestInterface::class); + $this->layoutMock = $this->createMock(\Magento\Framework\View\Layout::class); + $this->checkoutSessionMock = $this->createMock(\Magento\Checkout\Model\Session::class); + $this->urlBuilderMock = $this->createMock(\Magento\Framework\UrlInterface::class); + $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->imageHelper = $this->createMock(\Magento\Catalog\Helper\Image::class); + $this->scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $contextMock = $this->getMock( + $contextMock = $this->createPartialMock( \Magento\Framework\View\Element\Template\Context::class, - ['getLayout', 'getUrlBuilder', 'getStoreManager', 'getScopeConfig', 'getRequest'], - [], - '', - false + ['getLayout', 'getUrlBuilder', 'getStoreManager', 'getScopeConfig', 'getRequest'] ); $contextMock->expects($this->once()) ->method('getLayout') @@ -99,7 +90,7 @@ protected function setUp() ->method('getRequest') ->will($this->returnValue($this->requestMock)); - $this->serializer = $this->getMock(\Magento\Framework\Serialize\Serializer\Json::class, [], [], '', false); + $this->serializer = $this->createMock(\Magento\Framework\Serialize\Serializer\Json::class); $this->model = $this->_objectManager->getObject( \Magento\Checkout\Block\Cart\Sidebar::class, @@ -135,7 +126,7 @@ public function testGetTotalsHtml() public function testGetConfig() { $websiteId = 100; - $storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $storeMock = $this->createMock(\Magento\Store\Model\Store::class); $shoppingCartUrl = 'http://url.com/cart'; $checkoutUrl = 'http://url.com/checkout'; @@ -207,7 +198,7 @@ public function testGetIsNeedToDisplaySideBar() public function testGetTotalsCache() { - $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); + $quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class); $totalsMock = ['totals']; $this->checkoutSessionMock->expects($this->once())->method('getQuote')->willReturn($quoteMock); $quoteMock->expects($this->once())->method('getTotals')->willReturn($totalsMock); diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Checkout/DirectoryDataProcessorTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Checkout/DirectoryDataProcessorTest.php index c619cd6356074..521aebca1875c 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/Checkout/DirectoryDataProcessorTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/Checkout/DirectoryDataProcessorTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Checkout\Test\Unit\Block\Checkout; -class DirectoryDataProcessorTest extends \PHPUnit_Framework_TestCase +class DirectoryDataProcessorTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Checkout\Block\Checkout\DirectoryDataProcessor @@ -49,47 +49,27 @@ class DirectoryDataProcessorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->countryCollectionFactoryMock = $this->getMock( + $this->countryCollectionFactoryMock = $this->createPartialMock( \Magento\Directory\Model\ResourceModel\Country\CollectionFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->countryCollectionMock = $this->getMock( - \Magento\Directory\Model\ResourceModel\Country\Collection::class, - [], - [], - '', - false + $this->countryCollectionMock = $this->createMock( + \Magento\Directory\Model\ResourceModel\Country\Collection::class ); - $this->regionCollectionFactoryMock = $this->getMock( + $this->regionCollectionFactoryMock = $this->createPartialMock( \Magento\Directory\Model\ResourceModel\Region\CollectionFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->regionCollectionMock = $this->getMock( - \Magento\Directory\Model\ResourceModel\Region\Collection::class, - [], - [], - '', - false + $this->regionCollectionMock = $this->createMock( + \Magento\Directory\Model\ResourceModel\Region\Collection::class ); - $this->storeResolverMock = $this->getMock( + $this->storeResolverMock = $this->createMock( \Magento\Store\Api\StoreResolverInterface::class ); + $this->directoryDataHelperMock = $this->createMock(\Magento\Directory\Helper\Data::class); $this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->directoryDataHelperMock = $this->getMock( - \Magento\Directory\Helper\Data::class, - [], - [], - '', - false - ); $this->model = new \Magento\Checkout\Block\Checkout\DirectoryDataProcessor( $this->countryCollectionFactoryMock, diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Checkout/LayoutProcessorTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Checkout/LayoutProcessorTest.php index 6861bfa5c2ab2..b3e55bb418d3d 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/Checkout/LayoutProcessorTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/Checkout/LayoutProcessorTest.php @@ -20,7 +20,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class LayoutProcessorTest extends \PHPUnit_Framework_TestCase +class LayoutProcessorTest extends \PHPUnit\Framework\TestCase { /** * @var AttributeMetadataDataProvider|MockObject @@ -86,7 +86,7 @@ protected function setUp() $this->attributeMerger ); - $this->storeResolver = $this->getMock(\Magento\Store\Api\StoreResolverInterface::class); + $this->storeResolver = $this->createMock(\Magento\Store\Api\StoreResolverInterface::class); $objectManager->setBackwardCompatibleProperty($this->layoutProcessor, 'checkoutDataHelper', $this->dataHelper); $objectManager->setBackwardCompatibleProperty($this->layoutProcessor, 'options', $options); diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Checkout/TotalsProcessorTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Checkout/TotalsProcessorTest.php index 32dfcc405a1f2..0b3b79719bd15 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/Checkout/TotalsProcessorTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/Checkout/TotalsProcessorTest.php @@ -6,7 +6,7 @@ namespace Magento\Checkout\Test\Unit\Block\Checkout; -class TotalsProcessorTest extends \PHPUnit_Framework_TestCase +class TotalsProcessorTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Checkout\Block\Checkout\TotalsProcessor @@ -20,13 +20,7 @@ class TotalsProcessorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->scopeConfigMock = $this->getMock( - \Magento\Framework\App\Config\ScopeConfigInterface::class, - [], - [], - '', - false - ); + $this->scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $this->model = new \Magento\Checkout\Block\Checkout\TotalsProcessor($this->scopeConfigMock); } diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Item/Price/RendererTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Item/Price/RendererTest.php index f5226a18310b1..220e5c9bd4d1f 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/Item/Price/RendererTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/Item/Price/RendererTest.php @@ -7,7 +7,7 @@ use \Magento\Checkout\Block\Item\Price\Renderer; -class RendererTest extends \PHPUnit_Framework_TestCase +class RendererTest extends \PHPUnit\Framework\TestCase { /** * @var Renderer diff --git a/app/code/Magento/Checkout/Test/Unit/Block/LinkTest.php b/app/code/Magento/Checkout/Test/Unit/Block/LinkTest.php index fa92326b89091..24065c1f54eb3 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/LinkTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/LinkTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Checkout\Test\Unit\Block; -class LinkTest extends \PHPUnit_Framework_TestCase +class LinkTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Onepage/SuccessTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Onepage/SuccessTest.php index 2cfb49f8b2b3f..18281494029b6 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/Onepage/SuccessTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/Onepage/SuccessTest.php @@ -12,7 +12,7 @@ * @package Magento\Checkout\Block\Onepage * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class SuccessTest extends \PHPUnit_Framework_TestCase +class SuccessTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Checkout\Block\Onepage\Success @@ -43,8 +43,8 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->orderConfig = $this->getMock(\Magento\Sales\Model\Order\Config::class, [], [], '', false); - $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class, [], [], '', false); + $this->orderConfig = $this->createMock(\Magento\Sales\Model\Order\Config::class); + $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); $this->layout = $this->getMockBuilder(\Magento\Framework\View\LayoutInterface::class) ->disableOriginalConstructor() @@ -101,7 +101,7 @@ protected function setUp() public function testGetAdditionalInfoHtml() { - $layout = $this->getMock(\Magento\Framework\View\LayoutInterface::class, [], [], '', false); + $layout = $this->createMock(\Magento\Framework\View\LayoutInterface::class); $layout->expects( $this->once() )->method( @@ -163,7 +163,7 @@ public function invisibleStatusesProvider() public function testGetContinueUrl() { - $storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $storeMock = $this->createMock(\Magento\Store\Model\Store::class); $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); $storeMock->expects($this->once())->method('getBaseUrl')->will($this->returnValue('Expected Result')); diff --git a/app/code/Magento/Checkout/Test/Unit/Block/OnepageTest.php b/app/code/Magento/Checkout/Test/Unit/Block/OnepageTest.php index 6e6d64cf5cc01..e47fac06d8057 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/OnepageTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/OnepageTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Checkout\Test\Unit\Block; -class OnepageTest extends \PHPUnit_Framework_TestCase +class OnepageTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Checkout\Block\Onepage @@ -39,27 +39,17 @@ class OnepageTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $contextMock = $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false); - $this->formKeyMock = $this->getMock(\Magento\Framework\Data\Form\FormKey::class, [], [], '', false); - $this->configProviderMock = $this->getMock( - \Magento\Checkout\Model\CompositeConfigProvider::class, - [], - [], - '', - false - ); + $contextMock = $this->createMock(\Magento\Framework\View\Element\Template\Context::class); + $this->formKeyMock = $this->createMock(\Magento\Framework\Data\Form\FormKey::class); + $this->configProviderMock = $this->createMock(\Magento\Checkout\Model\CompositeConfigProvider::class); - $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class, [], [], '', false); + $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); $contextMock->expects($this->once())->method('getStoreManager')->willReturn($this->storeManagerMock); - $this->layoutProcessorMock = $this->getMock( - \Magento\Checkout\Block\Checkout\LayoutProcessorInterface::class, - [], - [], - '', - false + $this->layoutProcessorMock = $this->createMock( + \Magento\Checkout\Block\Checkout\LayoutProcessorInterface::class ); - $this->serializer = $this->getMock(\Magento\Framework\Serialize\Serializer\Json::class, [], [], '', false); + $this->serializer = $this->createMock(\Magento\Framework\Serialize\Serializer\Json::class); $this->model = new \Magento\Checkout\Block\Onepage( $contextMock, @@ -74,7 +64,7 @@ protected function setUp() public function testGetBaseUrl() { $baseUrl = 'http://magento.com'; - $storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $storeMock = $this->createMock(\Magento\Store\Model\Store::class); $storeMock->expects($this->once())->method('getBaseUrl')->willReturn($baseUrl); $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($storeMock); diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Shipping/PriceTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Shipping/PriceTest.php index 86eeec9332757..6138752bb9ff6 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/Shipping/PriceTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/Shipping/PriceTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Checkout\Test\Unit\Block\Shipping; -class PriceTest extends \PHPUnit_Framework_TestCase +class PriceTest extends \PHPUnit\Framework\TestCase { const SUBTOTAL = 10; diff --git a/app/code/Magento/Checkout/Test/Unit/Controller/Account/CreateTest.php b/app/code/Magento/Checkout/Test/Unit/Controller/Account/CreateTest.php index e3e6beb8866bf..310090ad05550 100644 --- a/app/code/Magento/Checkout/Test/Unit/Controller/Account/CreateTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Controller/Account/CreateTest.php @@ -8,7 +8,7 @@ /** * Shopping cart edit tests */ -class CreateTest extends \PHPUnit_Framework_TestCase +class CreateTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -43,31 +43,13 @@ class CreateTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->checkoutSession = $this->getMock( - \Magento\Checkout\Model\Session::class, - ['getLastOrderId'], - [], - '', - false - ); - $this->customerSession = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); - $this->orderCustomerService = $this->getMock( - \Magento\Sales\Api\OrderCustomerManagementInterface::class, - [], - [], - '', - false - ); - $this->messageManager = $this->getMock(\Magento\Framework\Message\ManagerInterface::class); - - $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); - $contextMock = $this->getMock( - \Magento\Framework\App\Action\Context::class, - ['getObjectManager'], - [], - '', - false - ); + $this->checkoutSession = $this->createPartialMock(\Magento\Checkout\Model\Session::class, ['getLastOrderId']); + $this->customerSession = $this->createMock(\Magento\Customer\Model\Session::class); + $this->orderCustomerService = $this->createMock(\Magento\Sales\Api\OrderCustomerManagementInterface::class); + $this->messageManager = $this->createMock(\Magento\Framework\Message\ManagerInterface::class); + + $this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); + $contextMock = $this->createPartialMock(\Magento\Framework\App\Action\Context::class, ['getObjectManager']); $contextMock->expects($this->once())->method('getObjectManager')->willReturn($this->objectManagerMock); $this->action = $objectManagerHelper->getObject( @@ -84,12 +66,12 @@ protected function setUp() public function testExecuteAddsSessionMessageIfCustomerIsLoggedIn() { - $jsonFactoryMock = $this->getMock(\Magento\Framework\Controller\Result\JsonFactory::class, [], [], '', false); + $jsonFactoryMock = $this->createMock(\Magento\Framework\Controller\Result\JsonFactory::class); $this->objectManagerMock->expects($this->once()) ->method('get') ->with(\Magento\Framework\Controller\Result\JsonFactory::class) ->willReturn($jsonFactoryMock); - $jsonMock = $this->getMock(\Magento\Framework\Controller\Result\Json::class, [], [], '', false); + $jsonMock = $this->createMock(\Magento\Framework\Controller\Result\Json::class); $jsonFactoryMock->expects($this->once())->method('create')->willReturn($jsonMock); $this->customerSession->expects($this->once())->method('isLoggedIn')->will($this->returnValue(true)); @@ -107,17 +89,17 @@ public function testExecuteAddsSessionMessageIfCustomerIsLoggedIn() public function testExecute() { - $jsonFactoryMock = $this->getMock(\Magento\Framework\Controller\Result\JsonFactory::class, [], [], '', false); + $jsonFactoryMock = $this->createMock(\Magento\Framework\Controller\Result\JsonFactory::class); $this->objectManagerMock->expects($this->once()) ->method('get') ->with(\Magento\Framework\Controller\Result\JsonFactory::class) ->willReturn($jsonFactoryMock); - $jsonMock = $this->getMock(\Magento\Framework\Controller\Result\Json::class, [], [], '', false); + $jsonMock = $this->createMock(\Magento\Framework\Controller\Result\Json::class); $jsonFactoryMock->expects($this->once())->method('create')->willReturn($jsonMock); $this->customerSession->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false)); $this->checkoutSession->expects($this->once())->method('getLastOrderId')->will($this->returnValue(100)); - $customer = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class); + $customer = $this->createMock(\Magento\Customer\Api\Data\CustomerInterface::class); $this->orderCustomerService->expects($this->once())->method('create')->with(100)->will( $this->returnValue($customer) ); diff --git a/app/code/Magento/Checkout/Test/Unit/Controller/Cart/ConfigureTest.php b/app/code/Magento/Checkout/Test/Unit/Controller/Cart/ConfigureTest.php index 67db4dc4fac70..05518e3ab943b 100644 --- a/app/code/Magento/Checkout/Test/Unit/Controller/Cart/ConfigureTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Controller/Cart/ConfigureTest.php @@ -12,7 +12,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ConfigureTest extends \PHPUnit_Framework_TestCase +class ConfigureTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\ObjectManagerInterface | \PHPUnit_Framework_MockObject_MockObject @@ -61,11 +61,11 @@ class ConfigureTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->contextMock = $this->getMock(\Magento\Framework\App\Action\Context::class, [], [], '', false); - $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); - $this->responseMock = $this->getMock(\Magento\Framework\App\ResponseInterface::class); - $this->requestMock = $this->getMock(\Magento\Framework\App\RequestInterface::class); - $this->messageManagerMock = $this->getMock(\Magento\Framework\Message\ManagerInterface::class); + $this->contextMock = $this->createMock(\Magento\Framework\App\Action\Context::class); + $this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); + $this->responseMock = $this->createMock(\Magento\Framework\App\ResponseInterface::class); + $this->requestMock = $this->createMock(\Magento\Framework\App\RequestInterface::class); + $this->messageManagerMock = $this->createMock(\Magento\Framework\Message\ManagerInterface::class); $this->cartMock = $this->getMockBuilder(\Magento\Checkout\Model\Cart::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Checkout/Test/Unit/Controller/Cart/CouponPostTest.php b/app/code/Magento/Checkout/Test/Unit/Controller/Cart/CouponPostTest.php index 8d42f3cc906f2..b8f46feab0a48 100644 --- a/app/code/Magento/Checkout/Test/Unit/Controller/Cart/CouponPostTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Controller/Cart/CouponPostTest.php @@ -12,7 +12,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class CouponPostTest extends \PHPUnit_Framework_TestCase +class CouponPostTest extends \PHPUnit\Framework\TestCase { /** * @var Index @@ -84,11 +84,9 @@ class CouponPostTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->request = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); - $this->response = $this->getMock(\Magento\Framework\App\Response\Http::class, [], [], '', false); - $this->quote = $this->getMock( - \Magento\Quote\Model\Quote::class, - [ + $this->request = $this->createMock(\Magento\Framework\App\Request\Http::class); + $this->response = $this->createMock(\Magento\Framework\App\Response\Http::class); + $this->quote = $this->createPartialMock(\Magento\Quote\Model\Quote::class, [ 'setCouponCode', 'getItemsCount', 'getShippingAddress', @@ -96,29 +94,19 @@ protected function setUp() 'getCouponCode', 'collectTotals', 'save' - ], - [], - '', - false - ); - $this->eventManager = $this->getMock(\Magento\Framework\Event\Manager::class, [], [], '', false); - $this->checkoutSession = $this->getMock(\Magento\Checkout\Model\Session::class, [], [], '', false); + ]); + $this->eventManager = $this->createMock(\Magento\Framework\Event\Manager::class); + $this->checkoutSession = $this->createMock(\Magento\Checkout\Model\Session::class); - $this->objectManagerMock = $this->getMock( - \Magento\Framework\ObjectManager\ObjectManager::class, - [ + $this->objectManagerMock = $this->createPartialMock(\Magento\Framework\ObjectManager\ObjectManager::class, [ 'get', 'escapeHtml' - ], - [], - '', - false - ); + ]); $this->messageManager = $this->getMockBuilder(\Magento\Framework\Message\ManagerInterface::class) ->disableOriginalConstructor() ->getMock(); - $context = $this->getMock(\Magento\Framework\App\Action\Context::class, [], [], '', false); + $context = $this->createMock(\Magento\Framework\App\Action\Context::class); $context->expects($this->once()) ->method('getObjectManager') ->willReturn($this->objectManagerMock); @@ -136,8 +124,8 @@ protected function setUp() ->willReturn($this->messageManager); $this->redirectFactory = - $this->getMock(\Magento\Framework\Controller\Result\RedirectFactory::class, [], [], '', false); - $this->redirect = $this->getMock(\Magento\Store\App\Response\Redirect::class, [], [], '', false); + $this->createMock(\Magento\Framework\Controller\Result\RedirectFactory::class); + $this->redirect = $this->createMock(\Magento\Store\App\Response\Redirect::class); $this->redirect->expects($this->any()) ->method('getRefererUrl') @@ -159,7 +147,7 @@ protected function setUp() ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->quoteRepository = $this->getMock(\Magento\Quote\Api\CartRepositoryInterface::class); + $this->quoteRepository = $this->createMock(\Magento\Quote\Api\CartRepositoryInterface::class); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); @@ -214,7 +202,7 @@ public function testExecuteWithGoodCouponAndItems() ->method('getCouponCode') ->willReturn('OLDCODE'); - $coupon = $this->getMock(\Magento\SalesRule\Model\Coupon::class, [], [], '', false); + $coupon = $this->createMock(\Magento\SalesRule\Model\Coupon::class); $this->couponFactory->expects($this->once()) ->method('create') ->willReturn($coupon); @@ -224,7 +212,7 @@ public function testExecuteWithGoodCouponAndItems() ->method('getItemsCount') ->willReturn(1); - $shippingAddress = $this->getMock(\Magento\Quote\Model\Quote\Address::class, [], [], '', false); + $shippingAddress = $this->createMock(\Magento\Quote\Model\Quote\Address::class); $this->quote->expects($this->any()) ->method('setCollectShippingRates') @@ -282,7 +270,7 @@ public function testExecuteWithGoodCouponAndNoItems() ->method('getItemsCount') ->willReturn(0); - $coupon = $this->getMock(\Magento\Quote\Model\Quote\Address::class, [], [], '', false); + $coupon = $this->createMock(\Magento\Quote\Model\Quote\Address::class); $coupon->expects($this->once()) ->method('getId') @@ -336,7 +324,7 @@ public function testExecuteWithBadCouponAndItems() ->method('getItemsCount') ->willReturn(1); - $shippingAddress = $this->getMock(\Magento\Quote\Model\Quote\Address::class, [], [], '', false); + $shippingAddress = $this->createMock(\Magento\Quote\Model\Quote\Address::class); $this->quote->expects($this->any()) ->method('setCollectShippingRates') @@ -387,7 +375,7 @@ public function testExecuteWithBadCouponAndNoItems() ->method('getItemsCount') ->willReturn(0); - $coupon = $this->getMock(\Magento\Quote\Model\Quote\Address::class, [], [], '', false); + $coupon = $this->createMock(\Magento\Quote\Model\Quote\Address::class); $coupon->expects($this->once()) ->method('getId') diff --git a/app/code/Magento/Checkout/Test/Unit/Controller/Cart/IndexTest.php b/app/code/Magento/Checkout/Test/Unit/Controller/Cart/IndexTest.php index d17995387a1b6..964cbe23879e3 100644 --- a/app/code/Magento/Checkout/Test/Unit/Controller/Cart/IndexTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Controller/Cart/IndexTest.php @@ -12,7 +12,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class IndexTest extends \PHPUnit_Framework_TestCase +class IndexTest extends \PHPUnit\Framework\TestCase { /** * @var Index @@ -74,25 +74,19 @@ class IndexTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->request = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); - $this->response = $this->getMock(\Magento\Framework\App\Response\Http::class, [], [], '', false); - $this->quote = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); - $this->eventManager = $this->getMock(\Magento\Framework\Event\Manager::class, [], [], '', false); - $this->checkoutSession = $this->getMock(\Magento\Checkout\Model\Session::class, [], [], '', false); - - $this->objectManagerMock = $this->getMock( - \Magento\Framework\ObjectManager\ObjectManager::class, - [], - [], - '', - false - ); + $this->request = $this->createMock(\Magento\Framework\App\Request\Http::class); + $this->response = $this->createMock(\Magento\Framework\App\Response\Http::class); + $this->quote = $this->createMock(\Magento\Quote\Model\Quote::class); + $this->eventManager = $this->createMock(\Magento\Framework\Event\Manager::class); + $this->checkoutSession = $this->createMock(\Magento\Checkout\Model\Session::class); + + $this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManager\ObjectManager::class); $this->messageManager = $this->getMockBuilder(\Magento\Framework\Message\ManagerInterface::class) ->disableOriginalConstructor() ->getMock(); - $context = $this->getMock(\Magento\Framework\App\Action\Context::class, [], [], '', false); + $context = $this->createMock(\Magento\Framework\App\Action\Context::class); $context->expects($this->once()) ->method('getObjectManager') ->willReturn($this->objectManagerMock); diff --git a/app/code/Magento/Checkout/Test/Unit/Controller/Index/IndexTest.php b/app/code/Magento/Checkout/Test/Unit/Controller/Index/IndexTest.php index afb131f28e166..8d105f25465e4 100644 --- a/app/code/Magento/Checkout/Test/Unit/Controller/Index/IndexTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Controller/Index/IndexTest.php @@ -14,7 +14,7 @@ * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class IndexTest extends \PHPUnit_Framework_TestCase +class IndexTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager @@ -107,7 +107,10 @@ protected function setUp() $this->objectManager = new ObjectManager($this); $this->objectManagerMock = $this->basicMock(\Magento\Framework\ObjectManagerInterface::class); $this->dataMock = $this->basicMock(\Magento\Checkout\Helper\Data::class); - $this->quoteMock = $this->basicMock(\Magento\Quote\Model\Quote::class); + $this->quoteMock = $this->createPartialMock( + \Magento\Quote\Model\Quote::class, + ['getHasError', 'hasItems', 'validateMinimumAmount', 'hasError'] + ); $this->contextMock = $this->basicMock(\Magento\Framework\App\Action\Context::class); $this->sessionMock = $this->basicMock(\Magento\Customer\Model\Session::class); $this->onepageMock = $this->basicMock(\Magento\Checkout\Model\Type\Onepage::class); @@ -118,7 +121,7 @@ protected function setUp() $this->resultPageMock = $this->basicMock(\Magento\Framework\View\Result\Page::class); $this->pageConfigMock = $this->basicMock(\Magento\Framework\View\Page\Config::class); $this->titleMock = $this->basicMock(\Magento\Framework\View\Page\Title::class); - $this->url = $this->getMock(\Magento\Framework\UrlInterface::class); + $this->url = $this->createMock(\Magento\Framework\UrlInterface::class); $this->resultRedirectMock = $this->basicMock(\Magento\Framework\Controller\Result\Redirect::class); $resultPageFactoryMock = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class) @@ -226,7 +229,7 @@ public function testInvalidQuote() * @param \PHPUnit_Framework_MockObject_MockObject $mock * @param string $method * - * @return \PHPUnit_Framework_MockObject_Builder_InvocationMocker + * @return \PHPUnit\Framework\MockObject_Builder_InvocationMocker */ private function basicStub($mock, $method) { diff --git a/app/code/Magento/Checkout/Test/Unit/Controller/OnepageTest.php b/app/code/Magento/Checkout/Test/Unit/Controller/OnepageTest.php index 64fda4584acd0..1d4b1f92508f0 100644 --- a/app/code/Magento/Checkout/Test/Unit/Controller/OnepageTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Controller/OnepageTest.php @@ -11,7 +11,7 @@ * Class OnepageTest * @package Magento\Checkout\Controller */ -class OnepageTest extends \PHPUnit_Framework_TestCase +class OnepageTest extends \PHPUnit\Framework\TestCase { /** * @var Onepage @@ -52,17 +52,17 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->request = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); - $this->response = $this->getMock(\Magento\Framework\App\Response\Http::class, [], [], '', false); - $this->quote = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); - $this->eventManager = $this->getMock(\Magento\Framework\Event\Manager::class, [], [], '', false); - $this->customerSession = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); - $this->checkoutSession = $this->getMock(\Magento\Checkout\Model\Session::class, [], [], '', false); + $this->request = $this->createMock(\Magento\Framework\App\Request\Http::class); + $this->response = $this->createMock(\Magento\Framework\App\Response\Http::class); + $this->quote = $this->createMock(\Magento\Quote\Model\Quote::class); + $this->eventManager = $this->createMock(\Magento\Framework\Event\Manager::class); + $this->customerSession = $this->createMock(\Magento\Customer\Model\Session::class); + $this->checkoutSession = $this->createMock(\Magento\Checkout\Model\Session::class); $this->checkoutSession->expects($this->once()) ->method('getQuote') ->willReturn($this->quote); - $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManager\ObjectManager::class, [], [], '', false); + $objectManagerMock = $this->createMock(\Magento\Framework\ObjectManager\ObjectManager::class); $objectManagerMock->expects($this->at(0)) ->method('get') ->with(\Magento\Checkout\Model\Session::class) @@ -72,7 +72,7 @@ protected function setUp() ->with(\Magento\Customer\Model\Session::class) ->willReturn($this->customerSession); - $context = $this->getMock(\Magento\Framework\App\Action\Context::class, [], [], '', false); + $context = $this->createMock(\Magento\Framework\App\Action\Context::class); $context->expects($this->once()) ->method('getObjectManager') ->willReturn($objectManagerMock); diff --git a/app/code/Magento/Checkout/Test/Unit/Controller/Sidebar/RemoveItemTest.php b/app/code/Magento/Checkout/Test/Unit/Controller/Sidebar/RemoveItemTest.php index 43748f34ae7ff..7653a51b2f9b7 100644 --- a/app/code/Magento/Checkout/Test/Unit/Controller/Sidebar/RemoveItemTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Controller/Sidebar/RemoveItemTest.php @@ -11,7 +11,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class RemoveItemTest extends \PHPUnit_Framework_TestCase +class RemoveItemTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Checkout\Controller\Sidebar\RemoveItem */ protected $removeItem; @@ -44,10 +44,10 @@ class RemoveItemTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->sidebarMock = $this->getMock(\Magento\Checkout\Model\Sidebar::class, [], [], '', false); - $this->loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); - $this->jsonHelperMock = $this->getMock(\Magento\Framework\Json\Helper\Data::class, [], [], '', false); - $this->requestMock = $this->getMock(\Magento\Framework\App\RequestInterface::class); + $this->sidebarMock = $this->createMock(\Magento\Checkout\Model\Sidebar::class); + $this->loggerMock = $this->createMock(\Psr\Log\LoggerInterface::class); + $this->jsonHelperMock = $this->createMock(\Magento\Framework\Json\Helper\Data::class); + $this->requestMock = $this->createMock(\Magento\Framework\App\RequestInterface::class); $this->responseMock = $this->getMockForAbstractClass( \Magento\Framework\App\ResponseInterface::class, [], @@ -57,19 +57,10 @@ protected function setUp() true, ['representJson'] ); - $this->resultPageFactoryMock = $this->getMock( - \Magento\Framework\View\Result\PageFactory::class, - [], - [], - '', - false - ); - $this->resultRedirectFactory = $this->getMock( + $this->resultPageFactoryMock = $this->createMock(\Magento\Framework\View\Result\PageFactory::class); + $this->resultRedirectFactory = $this->createPartialMock( \Magento\Framework\Controller\Result\RedirectFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->objectManagerHelper = new ObjectManagerHelper($this); @@ -86,13 +77,7 @@ protected function setUp() ] ); - $formKeyValidatorMock = $this->getMock( - \Magento\Framework\Data\Form\FormKey\Validator::class, - [], - [], - '', - false - ); + $formKeyValidatorMock = $this->createMock(\Magento\Framework\Data\Form\FormKey\Validator::class); $this->setPropertyValue($this->removeItem, 'formKeyValidator', $formKeyValidatorMock); } @@ -251,7 +236,7 @@ public function testExecuteWithException() public function testExecuteWhenFormKeyValidationFailed() { - $resultRedirect = $this->getMock(\Magento\Framework\Controller\Result\Redirect::class, [], [], '', false); + $resultRedirect = $this->createMock(\Magento\Framework\Controller\Result\Redirect::class); $resultRedirect->expects($this->once())->method('setPath')->with('*/cart/')->willReturnSelf(); $this->resultRedirectFactory->expects($this->once())->method('create')->willReturn($resultRedirect); $this->getPropertyValue($this->removeItem, 'formKeyValidator') diff --git a/app/code/Magento/Checkout/Test/Unit/Controller/Sidebar/UpdateItemQtyTest.php b/app/code/Magento/Checkout/Test/Unit/Controller/Sidebar/UpdateItemQtyTest.php index 2318f0296618f..e2a00c6872542 100644 --- a/app/code/Magento/Checkout/Test/Unit/Controller/Sidebar/UpdateItemQtyTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Controller/Sidebar/UpdateItemQtyTest.php @@ -8,7 +8,7 @@ use Magento\Framework\Exception\LocalizedException; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -class UpdateItemQtyTest extends \PHPUnit_Framework_TestCase +class UpdateItemQtyTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Checkout\Controller\Sidebar\UpdateItemQty */ protected $updateItemQty; @@ -33,10 +33,10 @@ class UpdateItemQtyTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->sidebarMock = $this->getMock(\Magento\Checkout\Model\Sidebar::class, [], [], '', false); - $this->loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); - $this->jsonHelperMock = $this->getMock(\Magento\Framework\Json\Helper\Data::class, [], [], '', false); - $this->requestMock = $this->getMock(\Magento\Framework\App\RequestInterface::class); + $this->sidebarMock = $this->createMock(\Magento\Checkout\Model\Sidebar::class); + $this->loggerMock = $this->createMock(\Psr\Log\LoggerInterface::class); + $this->jsonHelperMock = $this->createMock(\Magento\Framework\Json\Helper\Data::class); + $this->requestMock = $this->createMock(\Magento\Framework\App\RequestInterface::class); $this->responseMock = $this->getMockForAbstractClass( \Magento\Framework\App\ResponseInterface::class, [], diff --git a/app/code/Magento/Checkout/Test/Unit/CustomerData/CartTest.php b/app/code/Magento/Checkout/Test/Unit/CustomerData/CartTest.php index cd403ee6c2eb3..75e181cbabd08 100644 --- a/app/code/Magento/Checkout/Test/Unit/CustomerData/CartTest.php +++ b/app/code/Magento/Checkout/Test/Unit/CustomerData/CartTest.php @@ -9,7 +9,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class CartTest extends \PHPUnit_Framework_TestCase +class CartTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Checkout\CustomerData\Cart @@ -48,24 +48,15 @@ class CartTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->checkoutSessionMock = $this->getMock(\Magento\Checkout\Model\Session::class, [], [], '', false); - $this->catalogUrlMock = $this->getMock( + $this->checkoutSessionMock = $this->createMock(\Magento\Checkout\Model\Session::class); + $this->catalogUrlMock = $this->createPartialMock( \Magento\Catalog\Model\ResourceModel\Url::class, - ['getRewriteByProductStore'], - [], - '', - false - ); - $this->checkoutCartMock = $this->getMock(\Magento\Checkout\Model\Cart::class, [], [], '', false); - $this->checkoutHelperMock = $this->getMock(\Magento\Checkout\Helper\Data::class, [], [], '', false); - $this->layoutMock = $this->getMock(\Magento\Framework\View\LayoutInterface::class, [], [], '', false); - $this->itemPoolInterfaceMock = $this->getMock( - \Magento\Checkout\CustomerData\ItemPoolInterface::class, - [], - [], - '', - false + ['getRewriteByProductStore'] ); + $this->checkoutCartMock = $this->createMock(\Magento\Checkout\Model\Cart::class); + $this->checkoutHelperMock = $this->createMock(\Magento\Checkout\Helper\Data::class); + $this->layoutMock = $this->createMock(\Magento\Framework\View\LayoutInterface::class); + $this->itemPoolInterfaceMock = $this->createMock(\Magento\Checkout\CustomerData\ItemPoolInterface::class); $this->model = new \Magento\Checkout\CustomerData\Cart( $this->checkoutSessionMock, @@ -79,7 +70,7 @@ protected function setUp() public function testIsGuestCheckoutAllowed() { - $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); + $quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class); $this->checkoutSessionMock->expects($this->once())->method('getQuote')->willReturn($quoteMock); $this->checkoutHelperMock->expects($this->once())->method('isAllowedGuestCheckout')->with($quoteMock) ->willReturn(true); @@ -98,16 +89,13 @@ public function testGetSectionData() $shortcutButtonsHtml = 'Buttons'; $websiteId = 100; - $subtotalMock = $this->getMock(\Magento\Framework\DataObject::class, ['getValue'], [], '', false); + $subtotalMock = $this->createPartialMock(\Magento\Framework\DataObject::class, ['getValue']); $subtotalMock->expects($this->once())->method('getValue')->willReturn($subtotalValue); $totals = ['subtotal' => $subtotalMock]; - $quoteMock = $this->getMock( + $quoteMock = $this->createPartialMock( \Magento\Quote\Model\Quote::class, - ['getTotals', 'getHasError', 'getAllVisibleItems', 'getStore'], - [], - '', - false + ['getTotals', 'getHasError', 'getAllVisibleItems', 'getStore'] ); $this->checkoutSessionMock->expects($this->exactly(2))->method('getQuote')->willReturn($quoteMock); $quoteMock->expects($this->once())->method('getTotals')->willReturn($totals); @@ -120,25 +108,16 @@ public function testGetSectionData() ->willReturn($subtotalValue); $this->checkoutHelperMock->expects($this->once())->method('canOnepageCheckout')->willReturn(true); - $quoteItemMock = $this->getMock( - \Magento\Quote\Model\Quote\Item::class, - ['getProduct', 'getStoreId'], - [], - '', - false - ); + $quoteItemMock = $this->createPartialMock(\Magento\Quote\Model\Quote\Item::class, ['getProduct', 'getStoreId']); $quoteMock->expects($this->once())->method('getAllVisibleItems')->willReturn([$quoteItemMock]); - $storeMock = $this->getMock(\Magento\Store\Model\System\Store::class, ['getWebsiteId'], [], '', false); + $storeMock = $this->createPartialMock(\Magento\Store\Model\System\Store::class, ['getWebsiteId']); $storeMock->expects($this->once())->method('getWebsiteId')->willReturn($websiteId); $quoteMock->expects($this->once())->method('getStore')->willReturn($storeMock); - $productMock = $this->getMock( + $productMock = $this->createPartialMock( \Magento\Catalog\Model\Product::class, - ['isVisibleInSiteVisibility', 'getId', 'setUrlDataObject'], - [], - '', - false + ['isVisibleInSiteVisibility', 'getId', 'setUrlDataObject'] ); $quoteItemMock->expects($this->exactly(3))->method('getProduct')->willReturn($productMock); $quoteItemMock->expects($this->once())->method('getStoreId')->willReturn($storeId); @@ -160,7 +139,7 @@ public function testGetSectionData() ->with($quoteItemMock) ->willReturn($itemData); - $shortcutButtonsMock = $this->getMock(\Magento\Catalog\Block\ShortcutButtons::class, [], [], '', false); + $shortcutButtonsMock = $this->createMock(\Magento\Catalog\Block\ShortcutButtons::class); $this->layoutMock->expects($this->once()) ->method('createBlock') ->with(\Magento\Catalog\Block\ShortcutButtons::class) @@ -181,7 +160,8 @@ public function testGetSectionData() ], 'extra_actions' => 'Buttons', 'isGuestCheckoutAllowed' => 1, - 'website_id' => $websiteId + 'website_id' => $websiteId, + 'subtotalAmount' => 200, ]; $this->assertEquals($expectedResult, $this->model->getSectionData()); } @@ -200,30 +180,24 @@ public function testGetSectionDataWithCompositeProduct() $productRewrite = [$productId => ['rewrite' => 'product']]; $itemData = ['item' => 'data']; $shortcutButtonsHtml = 'Buttons'; - $subtotalMock = $this->getMock(\Magento\Framework\DataObject::class, ['getValue'], [], '', false); + $subtotalMock = $this->createPartialMock(\Magento\Framework\DataObject::class, ['getValue']); $subtotalMock->expects($this->once())->method('getValue')->willReturn($subtotalValue); $totals = ['subtotal' => $subtotalMock]; - $quoteMock = $this->getMock( + $quoteMock = $this->createPartialMock( \Magento\Quote\Model\Quote::class, - ['getTotals', 'getHasError', 'getAllVisibleItems', 'getStore'], - [], - '', - false + ['getTotals', 'getHasError', 'getAllVisibleItems', 'getStore'] ); - $quoteItemMock = $this->getMock( + $quoteItemMock = $this->createPartialMock( \Magento\Quote\Model\Quote\Item::class, - ['getProduct', 'getOptionByCode', 'getStoreId'], - [], - '', - false + ['getProduct', 'getOptionByCode', 'getStoreId'] ); $this->checkoutSessionMock->expects($this->exactly(2))->method('getQuote')->willReturn($quoteMock); $quoteMock->expects($this->once())->method('getTotals')->willReturn($totals); $quoteMock->expects($this->once())->method('getHasError')->willReturn(false); - $storeMock = $this->getMock(\Magento\Store\Model\System\Store::class, ['getWebsiteId'], [], '', false); + $storeMock = $this->createPartialMock(\Magento\Store\Model\System\Store::class, ['getWebsiteId']); $storeMock->expects($this->once())->method('getWebsiteId')->willReturn($websiteId); $quoteMock->expects($this->once())->method('getStore')->willReturn($storeMock); @@ -236,15 +210,12 @@ public function testGetSectionDataWithCompositeProduct() $quoteMock->expects($this->once())->method('getAllVisibleItems')->willReturn([$quoteItemMock]); - $productMock = $this->getMock( + $productMock = $this->createPartialMock( \Magento\Catalog\Model\Product::class, - ['isVisibleInSiteVisibility', 'getId', 'setUrlDataObject'], - [], - '', - false + ['isVisibleInSiteVisibility', 'getId', 'setUrlDataObject'] ); - $optionsMock = $this->getMock(\Magento\Quote\Model\Quote\Item\Option::class, [], [], '', false); + $optionsMock = $this->createMock(\Magento\Quote\Model\Quote\Item\Option::class); $optionsMock->expects($this->once())->method('getProduct')->willReturn($productMock); $quoteItemMock->expects($this->exactly(2))->method('getProduct')->willReturn($productMock); @@ -266,7 +237,7 @@ public function testGetSectionDataWithCompositeProduct() ->with([$productId => $storeId]) ->willReturn($productRewrite); - $shortcutButtonsMock = $this->getMock(\Magento\Catalog\Block\ShortcutButtons::class, [], [], '', false); + $shortcutButtonsMock = $this->createMock(\Magento\Catalog\Block\ShortcutButtons::class); $this->layoutMock->expects($this->once()) ->method('createBlock') ->with(\Magento\Catalog\Block\ShortcutButtons::class) @@ -292,7 +263,8 @@ public function testGetSectionDataWithCompositeProduct() ], 'extra_actions' => 'Buttons', 'isGuestCheckoutAllowed' => 1, - 'website_id' => $websiteId + 'website_id' => $websiteId, + 'subtotalAmount' => 200, ]; $this->assertEquals($expectedResult, $this->model->getSectionData()); } diff --git a/app/code/Magento/Checkout/Test/Unit/CustomerData/DefaultItemTest.php b/app/code/Magento/Checkout/Test/Unit/CustomerData/DefaultItemTest.php index 33cf6c9b4f4e1..8a7c2e951dd72 100644 --- a/app/code/Magento/Checkout/Test/Unit/CustomerData/DefaultItemTest.php +++ b/app/code/Magento/Checkout/Test/Unit/CustomerData/DefaultItemTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Checkout\Test\Unit\CustomerData; -class DefaultItemTest extends \PHPUnit_Framework_TestCase +class DefaultItemTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Checkout\CustomerData\DefaultItem diff --git a/app/code/Magento/Checkout/Test/Unit/CustomerData/ItemPoolTest.php b/app/code/Magento/Checkout/Test/Unit/CustomerData/ItemPoolTest.php index 2ecdd21749fe2..0046676360a3a 100644 --- a/app/code/Magento/Checkout/Test/Unit/CustomerData/ItemPoolTest.php +++ b/app/code/Magento/Checkout/Test/Unit/CustomerData/ItemPoolTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Checkout\Test\Unit\CustomerData; -class ItemPoolTest extends \PHPUnit_Framework_TestCase +class ItemPoolTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -31,7 +31,7 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); $this->model = $objectManager->getObject( \Magento\Checkout\CustomerData\ItemPool::class, [ @@ -46,10 +46,10 @@ public function testGetItemDataIfItemNotExistInMap() { $itemData = ['key' => 'value']; $productType = 'product_type'; - $quoteItemMock = $this->getMock(\Magento\Quote\Model\Quote\Item::class, [], [], '', false); + $quoteItemMock = $this->createMock(\Magento\Quote\Model\Quote\Item::class); $quoteItemMock->expects($this->once())->method('getProductType')->willReturn($productType); - $itemMock = $this->getMock(\Magento\Checkout\CustomerData\ItemInterface::class); + $itemMock = $this->createMock(\Magento\Checkout\CustomerData\ItemInterface::class); $itemMock->expects($this->once())->method('getItemData')->with($quoteItemMock)->willReturn($itemData); $this->objectManagerMock->expects($this->once()) @@ -66,10 +66,10 @@ public function testGetItemDataIfItemExistInMap() $productType = 'product_type'; $this->itemMap[$productType] = 'product_id'; - $quoteItemMock = $this->getMock(\Magento\Quote\Model\Quote\Item::class, [], [], '', false); + $quoteItemMock = $this->createMock(\Magento\Quote\Model\Quote\Item::class); $quoteItemMock->expects($this->once())->method('getProductType')->willReturn($productType); - $itemMock = $this->getMock(\Magento\Checkout\CustomerData\ItemInterface::class); + $itemMock = $this->createMock(\Magento\Checkout\CustomerData\ItemInterface::class); $itemMock->expects($this->once())->method('getItemData')->with($quoteItemMock)->willReturn($itemData); $this->objectManagerMock->expects($this->once()) @@ -98,12 +98,12 @@ public function testGetItemDataIfItemNotValid() { $itemData = ['key' => 'value']; $productType = 'product_type'; - $quoteItemMock = $this->getMock(\Magento\Quote\Model\Quote\Item::class, [], [], '', false); + $quoteItemMock = $this->createMock(\Magento\Quote\Model\Quote\Item::class); $quoteItemMock->expects($this->once())->method('getProductType')->willReturn($productType); $this->objectManagerMock->expects($this->once()) ->method('get') ->with($this->defaultItemId) - ->willReturn($this->getMock(\Magento\Quote\Model\Quote\Item::class, [], [], '', false)); + ->willReturn($this->createMock(\Magento\Quote\Model\Quote\Item::class)); $this->assertEquals($itemData, $this->model->getItemData($quoteItemMock)); } } diff --git a/app/code/Magento/Checkout/Test/Unit/Helper/CartTest.php b/app/code/Magento/Checkout/Test/Unit/Helper/CartTest.php index 5f466152dabd8..2614499d0916c 100644 --- a/app/code/Magento/Checkout/Test/Unit/Helper/CartTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Helper/CartTest.php @@ -14,7 +14,7 @@ use Magento\Framework\DataObject; use Magento\Quote\Model\Quote\Item; -class CartTest extends \PHPUnit_Framework_TestCase +class CartTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -87,7 +87,7 @@ public function testGetCart() public function testGetRemoveUrl() { $quoteItemId = 1; - $quoteItemMock = $this->getMock(\Magento\Quote\Model\Quote\Item::class, [], [], '', false); + $quoteItemMock = $this->createMock(\Magento\Quote\Model\Quote\Item::class); $quoteItemMock->expects($this->any())->method('getId')->will($this->returnValue($quoteItemId)); $currentUrl = 'http://www.example.com/'; $this->urlBuilderMock->expects($this->any())->method('getCurrentUrl')->will($this->returnValue($currentUrl)); @@ -107,7 +107,7 @@ public function testGetCartUrl() public function testGetQuote() { - $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); + $quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class); $this->checkoutSessionMock->expects($this->once())->method('getQuote')->will($this->returnValue($quoteMock)); $this->assertEquals($quoteMock, $this->helper->getQuote()); } @@ -138,9 +138,10 @@ public function testAddUrlWithUencPlaceholder() $productEntityId = 1; $storeId = 1; $isRequestSecure = false; - $productMock = $this->getMock( + $productMock = $this->createPartialMock( \Magento\Catalog\Model\Product::class, - ['getEntityId', 'hasUrlDataObject', 'getUrlDataObject', '__wakeup'], [], '', false); + ['getEntityId', 'hasUrlDataObject', 'getUrlDataObject', '__wakeup'] + ); $productMock->expects($this->any())->method('getEntityId')->will($this->returnValue($productEntityId)); $productMock->expects($this->any())->method('hasUrlDataObject')->will($this->returnValue(true)); $productMock->expects($this->any())->method('getUrlDataObject') @@ -167,7 +168,7 @@ public function testAddUrlWithUencPlaceholder() public function testGetIsVirtualQuote() { $isVirtual = true; - $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); + $quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class); $this->checkoutSessionMock->expects($this->once())->method('getQuote')->will($this->returnValue($quoteMock)); $quoteMock->expects($this->any())->method('isVirtual')->will($this->returnValue($isVirtual)); $this->assertEquals($isVirtual, $this->helper->getIsVirtualQuote()); @@ -187,9 +188,7 @@ public function testGetAddUrl() $productEntityId = 1; $storeId = 1; $isRequestSecure = false; - $productMock = $this->getMock( - \Magento\Catalog\Model\Product::class, - ['getEntityId', 'hasUrlDataObject', 'getUrlDataObject', '__wakeup'], [], '', false); + $productMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['getEntityId', 'hasUrlDataObject', 'getUrlDataObject', '__wakeup']); $productMock->expects($this->any())->method('getEntityId')->will($this->returnValue($productEntityId)); $productMock->expects($this->any())->method('hasUrlDataObject')->will($this->returnValue(true)); $productMock->expects($this->any())->method('getUrlDataObject') @@ -227,7 +226,7 @@ public function testGetAddUrl() */ public function testGetDeletePostJson($id, $url, $isAjax, $expectedPostData) { - $item = $this->getMock(\Magento\Quote\Model\Quote\Item::class, [], [], '', false); + $item = $this->createMock(\Magento\Quote\Model\Quote\Item::class); $item->expects($this->once()) ->method('getId') diff --git a/app/code/Magento/Checkout/Test/Unit/Helper/DataTest.php b/app/code/Magento/Checkout/Test/Unit/Helper/DataTest.php index e7f747172013f..31203b63f854a 100644 --- a/app/code/Magento/Checkout/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Helper/DataTest.php @@ -16,7 +16,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class DataTest extends \PHPUnit_Framework_TestCase +class DataTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Pricing\PriceCurrencyInterface @@ -218,17 +218,17 @@ public function testSendPaymentFailedEmail() )->method( 'getTransport' )->will( - $this->returnValue($this->getMock(\Magento\Framework\Mail\TransportInterface::class)) + $this->returnValue($this->createMock(\Magento\Framework\Mail\TransportInterface::class)) ); $this->_translator->expects($this->at(1))->method('suspend'); $this->_translator->expects($this->at(1))->method('resume'); - $productOne = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $productOne = $this->createMock(\Magento\Catalog\Model\Product::class); $productOne->expects($this->once())->method('getName')->will($this->returnValue('Product One')); $productOne->expects($this->once())->method('getFinalPrice')->with(2)->will($this->returnValue(10)); - $productTwo = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $productTwo = $this->createMock(\Magento\Catalog\Model\Product::class); $productTwo->expects($this->once())->method('getName')->will($this->returnValue('Product Two')); $productTwo->expects($this->once())->method('getFinalPrice')->with(3)->will($this->returnValue(60)); @@ -262,7 +262,7 @@ public function testGetCheckout() public function testGetQuote() { - $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); + $quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class); $this->_checkoutSession->expects($this->once())->method('getQuote')->will($this->returnValue($quoteMock)); $this->assertEquals($quoteMock, $this->_helper->getQuote()); } @@ -270,14 +270,8 @@ public function testGetQuote() public function testFormatPrice() { $price = 5.5; - $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); - $storeMock = $this->getMock( - \Magento\Store\Model\Store::class, - ['formatPrice', '__wakeup'], - [], - '', - false - ); + $quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class); + $storeMock = $this->createPartialMock(\Magento\Store\Model\Store::class, ['formatPrice', '__wakeup']); $this->_checkoutSession->expects($this->once())->method('getQuote')->will($this->returnValue($quoteMock)); $quoteMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock)); $this->priceCurrency->expects($this->once())->method('format')->will($this->returnValue('5.5')); @@ -327,7 +321,7 @@ public function testIsCustomerMustBeLogged() public function testGetPriceInclTax() { - $itemMock = $this->getMock(\Magento\Framework\DataObject::class, ['getPriceInclTax'], [], '', false); + $itemMock = $this->createPartialMock(\Magento\Framework\DataObject::class, ['getPriceInclTax']); $itemMock->expects($this->exactly(2))->method('getPriceInclTax')->will($this->returnValue(5.5)); $this->assertEquals(5.5, $this->_helper->getPriceInclTax($itemMock)); } @@ -340,7 +334,7 @@ public function testGetPriceInclTaxWithoutTax() $rowTotal = 15; $roundPrice = 17; $expected = 17; - $storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class, [], [], '', false); + $storeManager = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); $objectManagerHelper = new ObjectManager($this); $helper = $objectManagerHelper->getObject( \Magento\Checkout\Helper\Data::class, @@ -349,13 +343,7 @@ public function testGetPriceInclTaxWithoutTax() 'priceCurrency' => $this->priceCurrency, ] ); - $itemMock = $this->getMock( - \Magento\Framework\DataObject::class, - ['getPriceInclTax', 'getQty', 'getTaxAmount', 'getDiscountTaxCompensation', 'getRowTotal'], - [], - '', - false - ); + $itemMock = $this->createPartialMock(\Magento\Framework\DataObject::class, ['getPriceInclTax', 'getQty', 'getTaxAmount', 'getDiscountTaxCompensation', 'getRowTotal', 'getQtyOrdered']); $itemMock->expects($this->once())->method('getPriceInclTax')->will($this->returnValue(false)); $itemMock->expects($this->exactly(2))->method('getQty')->will($this->returnValue($qty)); $itemMock->expects($this->never())->method('getQtyOrdered'); @@ -371,7 +359,7 @@ public function testGetSubtotalInclTax() { $rowTotalInclTax = 5.5; $expected = 5.5; - $itemMock = $this->getMock(\Magento\Framework\DataObject::class, ['getRowTotalInclTax'], [], '', false); + $itemMock = $this->createPartialMock(\Magento\Framework\DataObject::class, ['getRowTotalInclTax']); $itemMock->expects($this->exactly(2))->method('getRowTotalInclTax')->will($this->returnValue($rowTotalInclTax)); $this->assertEquals($expected, $this->_helper->getSubtotalInclTax($itemMock)); } @@ -382,13 +370,7 @@ public function testGetSubtotalInclTaxNegative() $discountTaxCompensation = 1; $rowTotal = 15; $expected = 17; - $itemMock = $this->getMock( - \Magento\Framework\DataObject::class, - ['getRowTotalInclTax', 'getTaxAmount', 'getDiscountTaxCompensation', 'getRowTotal'], - [], - '', - false - ); + $itemMock = $this->createPartialMock(\Magento\Framework\DataObject::class, ['getRowTotalInclTax', 'getTaxAmount', 'getDiscountTaxCompensation', 'getRowTotal']); $itemMock->expects($this->once())->method('getRowTotalInclTax')->will($this->returnValue(false)); $itemMock->expects($this->once())->method('getTaxAmount')->will($this->returnValue($taxAmount)); $itemMock->expects($this->once()) @@ -399,7 +381,7 @@ public function testGetSubtotalInclTaxNegative() public function testGetBasePriceInclTaxWithoutQty() { - $storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class, [], [], '', false); + $storeManager = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); $objectManagerHelper = new ObjectManager($this); $helper = $objectManagerHelper->getObject( \Magento\Checkout\Helper\Data::class, @@ -408,7 +390,7 @@ public function testGetBasePriceInclTaxWithoutQty() 'priceCurrency' => $this->priceCurrency, ] ); - $itemMock = $this->getMock(\Magento\Framework\DataObject::class, ['getQty'], [], '', false); + $itemMock = $this->createPartialMock(\Magento\Framework\DataObject::class, ['getQty']); $itemMock->expects($this->once())->method('getQty'); $this->priceCurrency->expects($this->once())->method('round'); $helper->getPriceInclTax($itemMock); @@ -416,7 +398,7 @@ public function testGetBasePriceInclTaxWithoutQty() public function testGetBasePriceInclTax() { - $storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class, [], [], '', false); + $storeManager = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $helper = $objectManagerHelper->getObject( \Magento\Checkout\Helper\Data::class, @@ -425,7 +407,7 @@ public function testGetBasePriceInclTax() 'priceCurrency' => $this->priceCurrency, ] ); - $itemMock = $this->getMock(\Magento\Framework\DataObject::class, ['getQty', 'getQtyOrdered'], [], '', false); + $itemMock = $this->createPartialMock(\Magento\Framework\DataObject::class, ['getQty', 'getQtyOrdered']); $itemMock->expects($this->once())->method('getQty')->will($this->returnValue(false)); $itemMock->expects($this->exactly(2))->method('getQtyOrdered')->will($this->returnValue(5.5)); $this->priceCurrency->expects($this->once())->method('round'); @@ -434,13 +416,7 @@ public function testGetBasePriceInclTax() public function testGetBaseSubtotalInclTax() { - $itemMock = $this->getMock( - \Magento\Framework\DataObject::class, - ['getBaseTaxAmount', 'getBaseDiscountTaxCompensation', 'getBaseRowTotal'], - [], - '', - false - ); + $itemMock = $this->createPartialMock(\Magento\Framework\DataObject::class, ['getBaseTaxAmount', 'getBaseDiscountTaxCompensation', 'getBaseRowTotal']); $itemMock->expects($this->once())->method('getBaseTaxAmount'); $itemMock->expects($this->once())->method('getBaseDiscountTaxCompensation'); $itemMock->expects($this->once())->method('getBaseRowTotal'); @@ -449,7 +425,7 @@ public function testGetBaseSubtotalInclTax() public function testIsAllowedGuestCheckoutWithoutStore() { - $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); + $quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class); $store = null; $quoteMock->expects($this->once())->method('getStoreId')->will($this->returnValue(1)); $this->_scopeConfig->expects($this->once()) diff --git a/app/code/Magento/Checkout/Test/Unit/Helper/ExpressRedirectTest.php b/app/code/Magento/Checkout/Test/Unit/Helper/ExpressRedirectTest.php index c2019618138d2..d2e2b057e7e91 100644 --- a/app/code/Magento/Checkout/Test/Unit/Helper/ExpressRedirectTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Helper/ExpressRedirectTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Checkout\Test\Unit\Helper; -class ExpressRedirectTest extends \PHPUnit_Framework_TestCase +class ExpressRedirectTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -42,7 +42,7 @@ protected function setUp() ['set'] )->getMock(); - $this->_objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->_objectManager = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); $this->_customerSession = $this->getMockBuilder( \Magento\Customer\Model\Session::class diff --git a/app/code/Magento/Checkout/Test/Unit/Model/AgreementsValidatorTest.php b/app/code/Magento/Checkout/Test/Unit/Model/AgreementsValidatorTest.php index eb3aa50966c7d..3ced23cf278fa 100644 --- a/app/code/Magento/Checkout/Test/Unit/Model/AgreementsValidatorTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Model/AgreementsValidatorTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Checkout\Test\Unit\Model; -class AgreementsValidatorTest extends \PHPUnit_Framework_TestCase +class AgreementsValidatorTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Checkout\Model\AgreementsValidator diff --git a/app/code/Magento/Checkout/Test/Unit/Model/Cart/CheckoutSummaryConfigProviderTest.php b/app/code/Magento/Checkout/Test/Unit/Model/Cart/CheckoutSummaryConfigProviderTest.php index 81774980d3404..7f4437a9dce64 100644 --- a/app/code/Magento/Checkout/Test/Unit/Model/Cart/CheckoutSummaryConfigProviderTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Model/Cart/CheckoutSummaryConfigProviderTest.php @@ -11,7 +11,7 @@ use Magento\Checkout\Model\Cart\CheckoutSummaryConfigProvider; use Magento\Store\Model\ScopeInterface; -class CheckoutSummaryConfigProviderTest extends \PHPUnit_Framework_TestCase +class CheckoutSummaryConfigProviderTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\UrlInterface diff --git a/app/code/Magento/Checkout/Test/Unit/Model/Cart/ImageProviderTest.php b/app/code/Magento/Checkout/Test/Unit/Model/Cart/ImageProviderTest.php index fc204e09e61e8..5330d93b46f6a 100644 --- a/app/code/Magento/Checkout/Test/Unit/Model/Cart/ImageProviderTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Model/Cart/ImageProviderTest.php @@ -6,7 +6,7 @@ namespace Magento\Checkout\Test\Unit\Model\Cart; -class ImageProviderTest extends \PHPUnit_Framework_TestCase +class ImageProviderTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Checkout\Model\Cart\ImageProvider @@ -14,31 +14,19 @@ class ImageProviderTest extends \PHPUnit_Framework_TestCase public $model; /** - * @var \PHPUnit_Framework_Mockobject_Mockobject | \Magento\Quote\Api\CartItemRepositoryInterface + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Quote\Api\CartItemRepositoryInterface */ protected $itemRepositoryMock; /** - * @var \PHPUnit_Framework_Mockobject_Mockobject | \Magento\Checkout\CustomerData\ItemPoolInterface + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Checkout\CustomerData\ItemPoolInterface */ protected $itemPoolMock; protected function setUp() { - $this->itemRepositoryMock = $this->getMock( - \Magento\Quote\Api\CartItemRepositoryInterface::class, - [], - [], - '', - false - ); - $this->itemPoolMock = $this->getMock( - \Magento\Checkout\CustomerData\ItemPoolInterface::class, - [], - [], - '', - false - ); + $this->itemRepositoryMock = $this->createMock(\Magento\Quote\Api\CartItemRepositoryInterface::class); + $this->itemPoolMock = $this->createMock(\Magento\Checkout\CustomerData\ItemPoolInterface::class); $this->model = new \Magento\Checkout\Model\Cart\ImageProvider( $this->itemRepositoryMock, $this->itemPoolMock @@ -50,7 +38,7 @@ public function testGetImages() $cartId = 42; $itemId = 74; $itemData = ['product_image' => 'Magento.png', 'random' => '3.1415926535']; - $itemMock = $this->getMock(\Magento\Quote\Model\Quote\Item::class, [], [], '', false); + $itemMock = $this->createMock(\Magento\Quote\Model\Quote\Item::class); $itemMock->expects($this->once())->method('getItemId')->willReturn($itemId); $expectedResult = [$itemId => $itemData['product_image']]; diff --git a/app/code/Magento/Checkout/Test/Unit/Model/Cart/RequestInfoFilterCompositeTest.php b/app/code/Magento/Checkout/Test/Unit/Model/Cart/RequestInfoFilterCompositeTest.php index 49e2477b9a519..f175a06839be5 100644 --- a/app/code/Magento/Checkout/Test/Unit/Model/Cart/RequestInfoFilterCompositeTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Model/Cart/RequestInfoFilterCompositeTest.php @@ -8,7 +8,7 @@ /** * Class RequestInfoFilterTest */ -class RequestInfoFilterCompositeTest extends \PHPUnit_Framework_TestCase +class RequestInfoFilterCompositeTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Checkout\Model\Cart\RequestInfoFilterComposite @@ -27,19 +27,13 @@ protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $requestInfoFilterMock1 = $this->getMock( + $requestInfoFilterMock1 = $this->createPartialMock( \Magento\Checkout\Model\Cart\RequestInfoFilter::class, - ['filter'], - [], - '', - false + ['filter'] ); - $requestInfoFilterMock2 = $this->getMock( + $requestInfoFilterMock2 = $this->createPartialMock( \Magento\Checkout\Model\Cart\RequestInfoFilter::class, - ['filter'], - [], - '', - false + ['filter'] ); $requestInfoFilterMock1->expects($this->atLeastOnce()) diff --git a/app/code/Magento/Checkout/Test/Unit/Model/Cart/RequestInfoFilterTest.php b/app/code/Magento/Checkout/Test/Unit/Model/Cart/RequestInfoFilterTest.php index 5101b59f0536f..f1b3100d30bf1 100644 --- a/app/code/Magento/Checkout/Test/Unit/Model/Cart/RequestInfoFilterTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Model/Cart/RequestInfoFilterTest.php @@ -8,7 +8,7 @@ /** * Class RequestInfoFilterTest */ -class RequestInfoFilterTest extends \PHPUnit_Framework_TestCase +class RequestInfoFilterTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Checkout\Model\Cart\RequestInfoFilter diff --git a/app/code/Magento/Checkout/Test/Unit/Model/CartTest.php b/app/code/Magento/Checkout/Test/Unit/Model/CartTest.php index a106fbba6c835..40de71e28c05e 100644 --- a/app/code/Magento/Checkout/Test/Unit/Model/CartTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Model/CartTest.php @@ -13,7 +13,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class CartTest extends \PHPUnit_Framework_TestCase +class CartTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Checkout\Model\Cart */ protected $cart; @@ -79,34 +79,30 @@ class CartTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->checkoutSessionMock = $this->getMock(\Magento\Checkout\Model\Session::class, [], [], '', false); - $this->customerSessionMock = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); - $this->scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $this->quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); - $this->eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); - $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); - $this->productRepository = $this->getMock(\Magento\Catalog\Api\ProductRepositoryInterface::class); + $this->checkoutSessionMock = $this->createMock(\Magento\Checkout\Model\Session::class); + $this->customerSessionMock = $this->createMock(\Magento\Customer\Model\Session::class); + $this->scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class); + $this->eventManagerMock = $this->createMock(\Magento\Framework\Event\ManagerInterface::class); + $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->productRepository = $this->createMock(\Magento\Catalog\Api\ProductRepositoryInterface::class); $this->stockRegistry = $this->getMockBuilder(\Magento\CatalogInventory\Model\StockRegistry::class) ->disableOriginalConstructor() ->setMethods(['getStockItem', '__wakeup']) ->getMock(); - $this->stockItemMock = $this->getMock( + $this->stockItemMock = $this->createPartialMock( \Magento\CatalogInventory\Model\Stock\Item::class, - ['getMinSaleQty', '__wakeup'], - [], - '', - false + ['getMinSaleQty', '__wakeup'] ); - $this->stockState = $this->getMock( + $this->stockState = $this->createPartialMock( \Magento\CatalogInventory\Model\StockState::class, - ['suggestQty', '__wakeup'], - [], - '', - false + ['suggestQty', '__wakeup'] ); $this->storeMock = - $this->getMock(\Magento\Store\Model\Store::class, ['getWebsiteId', 'getId', '__wakeup'], [], '', false); - $this->requestInfoFilterMock = $this->getMock(\Magento\Checkout\Model\Cart\RequestInfoFilterInterface::class); + $this->createPartialMock(\Magento\Store\Model\Store::class, ['getWebsiteId', 'getId', '__wakeup']); + $this->requestInfoFilterMock = $this->createMock( + \Magento\Checkout\Model\Cart\RequestInfoFilterInterface::class + ); $this->stockRegistry->expects($this->any()) ->method('getStockItem') @@ -206,7 +202,7 @@ public function testUpdateItems() */ public function prepareQuoteItemMock($itemId) { - $store = $this->getMock(\Magento\Store\Model\Store::class, ['getId', '__wakeup'], [], '', false); + $store = $this->createPartialMock(\Magento\Store\Model\Store::class, ['getId', '__wakeup', 'getWebsiteId']); $store->expects($this->any()) ->method('getWebsiteId') ->will($this->returnValue(10)); @@ -219,12 +215,9 @@ public function prepareQuoteItemMock($itemId) switch ($itemId) { case 2: - $product = $this->getMock( + $product = $this->createPartialMock( \Magento\Catalog\Model\Product::class, - ['getStore', 'getId', '__wakeup'], - [], - '', - false + ['getStore', 'getId', '__wakeup'] ); $product->expects($this->once()) ->method('getId') @@ -234,12 +227,9 @@ public function prepareQuoteItemMock($itemId) ->will($this->returnValue($store)); break; case 3: - $product = $this->getMock( + $product = $this->createPartialMock( \Magento\Catalog\Model\Product::class, - ['getStore', 'getId', '__wakeup'], - [], - '', - false + ['getStore', 'getId', '__wakeup'] ); $product->expects($this->once()) ->method('getId') @@ -255,7 +245,7 @@ public function prepareQuoteItemMock($itemId) return false; } - $quoteItem = $this->getMock(\Magento\Quote\Model\Quote\Item::class, [], [], '', false); + $quoteItem = $this->createMock(\Magento\Quote\Model\Quote\Item::class); $quoteItem->expects($this->once()) ->method('getProduct') ->will($this->returnValue($product)); @@ -270,12 +260,9 @@ public function testGetSummaryQty($useQty) { $quoteId = 1; $itemsCount = 1; - $quoteMock = $this->getMock( + $quoteMock = $this->createPartialMock( \Magento\Quote\Model\Quote::class, - ['getItemsCount', 'getItemsQty', '__wakeup'], - [], - '', - false + ['getItemsCount', 'getItemsQty', '__wakeup'] ); $this->checkoutSessionMock->expects($this->any())->method('getQuote')->will($this->returnValue($quoteMock)); @@ -309,12 +296,9 @@ public function useQtyDataProvider() */ public function testAddProduct($productInfo, $requestInfo) { - $product = $this->getMock( + $product = $this->createPartialMock( \Magento\Catalog\Model\Product::class, - ['getStore', 'getWebsiteIds', 'getProductUrl', 'getId', '__wakeup'], - [], - '', - false + ['getStore', 'getWebsiteIds', 'getProductUrl', 'getId', '__wakeup'] ); $product->expects($this->any()) ->method('getId') @@ -357,12 +341,9 @@ public function testAddProduct($productInfo, $requestInfo) */ public function testAddProductException() { - $product = $this->getMock( + $product = $this->createPartialMock( \Magento\Catalog\Model\Product::class, - ['getStore', 'getWebsiteIds', 'getProductUrl', 'getId', '__wakeup'], - [], - '', - false + ['getStore', 'getWebsiteIds', 'getProductUrl', 'getId', '__wakeup'] ); $product->expects($this->any()) ->method('getId') @@ -390,7 +371,7 @@ public function testAddProductException() 'checkout_cart_product_add_after', ['quote_item' => 1, 'product' => $product] ); - $this->setExpectedException(\Magento\Framework\Exception\LocalizedException::class); + $this->expectException(\Magento\Framework\Exception\LocalizedException::class); $this->cart->addProduct(4, 4); } @@ -401,12 +382,9 @@ public function testAddProductException() */ public function testAddProductExceptionBadParams() { - $product = $this->getMock( + $product = $this->createPartialMock( \Magento\Catalog\Model\Product::class, - ['getWebsiteIds', 'getId', '__wakeup'], - [], - '', - false + ['getWebsiteIds', 'getId', '__wakeup'] ); $product->expects($this->any()) ->method('getId') @@ -422,7 +400,7 @@ public function testAddProductExceptionBadParams() 'checkout_cart_product_add_after', ['quote_item' => 1, 'product' => $product] ); - $this->setExpectedException(\Magento\Framework\Exception\LocalizedException::class); + $this->expectException(\Magento\Framework\Exception\LocalizedException::class); $this->cart->addProduct(4, 'bad'); } @@ -433,7 +411,7 @@ public function testAddProductExceptionBadParams() */ public function addProductDataProvider() { - $obj = new ObjectManagerHelper($this) ; + $obj = new ObjectManagerHelper($this); $data = ['qty' => 5.5, 'sku' => 'prod']; return [ diff --git a/app/code/Magento/Checkout/Test/Unit/Model/CompositeConfigProviderTest.php b/app/code/Magento/Checkout/Test/Unit/Model/CompositeConfigProviderTest.php index 5c8e0198e313e..53031c87da8ae 100644 --- a/app/code/Magento/Checkout/Test/Unit/Model/CompositeConfigProviderTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Model/CompositeConfigProviderTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Checkout\Test\Unit\Model; -class CompositeConfigProviderTest extends \PHPUnit_Framework_TestCase +class CompositeConfigProviderTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -21,7 +21,7 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->configProviderMock = $this->getMock(\Magento\Checkout\Model\ConfigProviderInterface::class); + $this->configProviderMock = $this->createMock(\Magento\Checkout\Model\ConfigProviderInterface::class); $this->model = $objectManager->getObject( \Magento\Checkout\Model\CompositeConfigProvider::class, ['configProviders' => [$this->configProviderMock]] diff --git a/app/code/Magento/Checkout/Test/Unit/Model/Config/Source/Cart/SummaryTest.php b/app/code/Magento/Checkout/Test/Unit/Model/Config/Source/Cart/SummaryTest.php index 6d536d7662791..04f98a114ed93 100644 --- a/app/code/Magento/Checkout/Test/Unit/Model/Config/Source/Cart/SummaryTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Model/Config/Source/Cart/SummaryTest.php @@ -7,7 +7,7 @@ use \Magento\Checkout\Model\Config\Source\Cart\Summary; -class SummaryTest extends \PHPUnit_Framework_TestCase +class SummaryTest extends \PHPUnit\Framework\TestCase { /** * @var Summary diff --git a/app/code/Magento/Checkout/Test/Unit/Model/GuestPaymentInformationManagementTest.php b/app/code/Magento/Checkout/Test/Unit/Model/GuestPaymentInformationManagementTest.php index 73b1503daa708..a33649551bdcb 100644 --- a/app/code/Magento/Checkout/Test/Unit/Model/GuestPaymentInformationManagementTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Model/GuestPaymentInformationManagementTest.php @@ -5,12 +5,10 @@ */ namespace Magento\Checkout\Test\Unit\Model; -use Magento\Framework\Exception\CouldNotSaveException; - /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class GuestPaymentInformationManagementTest extends \PHPUnit_Framework_TestCase +class GuestPaymentInformationManagementTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -50,23 +48,20 @@ class GuestPaymentInformationManagementTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->billingAddressManagementMock = $this->getMock( + $this->billingAddressManagementMock = $this->createMock( \Magento\Quote\Api\GuestBillingAddressManagementInterface::class ); - $this->paymentMethodManagementMock = $this->getMock( + $this->paymentMethodManagementMock = $this->createMock( \Magento\Quote\Api\GuestPaymentMethodManagementInterface::class ); - $this->cartManagementMock = $this->getMock(\Magento\Quote\Api\GuestCartManagementInterface::class); - $this->cartRepositoryMock = $this->getMock(\Magento\Quote\Api\CartRepositoryInterface::class); + $this->cartManagementMock = $this->createMock(\Magento\Quote\Api\GuestCartManagementInterface::class); + $this->cartRepositoryMock = $this->createMock(\Magento\Quote\Api\CartRepositoryInterface::class); - $this->quoteIdMaskFactoryMock = $this->getMock( + $this->quoteIdMaskFactoryMock = $this->createPartialMock( \Magento\Quote\Model\QuoteIdMaskFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); + $this->loggerMock = $this->createMock(\Psr\Log\LoggerInterface::class); $this->model = $objectManager->getObject( \Magento\Checkout\Model\GuestPaymentInformationManagement::class, [ @@ -85,8 +80,8 @@ public function testSavePaymentInformationAndPlaceOrder() $cartId = 100; $orderId = 200; $email = 'email@magento.com'; - $paymentMock = $this->getMock(\Magento\Quote\Api\Data\PaymentInterface::class); - $billingAddressMock = $this->getMock(\Magento\Quote\Api\Data\AddressInterface::class); + $paymentMock = $this->createMock(\Magento\Quote\Api\Data\PaymentInterface::class); + $billingAddressMock = $this->createMock(\Magento\Quote\Api\Data\AddressInterface::class); $billingAddressMock->expects($this->once())->method('setEmail')->with($email)->willReturnSelf(); @@ -110,8 +105,8 @@ public function testSavePaymentInformationAndPlaceOrderException() { $cartId = 100; $email = 'email@magento.com'; - $paymentMock = $this->getMock(\Magento\Quote\Api\Data\PaymentInterface::class); - $billingAddressMock = $this->getMock(\Magento\Quote\Api\Data\AddressInterface::class); + $paymentMock = $this->createMock(\Magento\Quote\Api\Data\PaymentInterface::class); + $billingAddressMock = $this->createMock(\Magento\Quote\Api\Data\AddressInterface::class); $billingAddressMock->expects($this->once())->method('setEmail')->with($email)->willReturnSelf(); @@ -129,8 +124,8 @@ public function testSavePaymentInformation() { $cartId = 100; $email = 'email@magento.com'; - $paymentMock = $this->getMock(\Magento\Quote\Api\Data\PaymentInterface::class); - $billingAddressMock = $this->getMock(\Magento\Quote\Api\Data\AddressInterface::class); + $paymentMock = $this->createMock(\Magento\Quote\Api\Data\PaymentInterface::class); + $billingAddressMock = $this->createMock(\Magento\Quote\Api\Data\AddressInterface::class); $billingAddressMock->expects($this->once())->method('setEmail')->with($email)->willReturnSelf(); $this->billingAddressManagementMock->expects($this->once()) @@ -145,21 +140,15 @@ public function testSavePaymentInformationWithoutBillingAddress() { $cartId = 100; $email = 'email@magento.com'; - $paymentMock = $this->getMock(\Magento\Quote\Api\Data\PaymentInterface::class); - $billingAddressMock = $this->getMock(\Magento\Quote\Api\Data\AddressInterface::class); - $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); + $paymentMock = $this->createMock(\Magento\Quote\Api\Data\PaymentInterface::class); + $billingAddressMock = $this->createMock(\Magento\Quote\Api\Data\AddressInterface::class); + $quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class); $billingAddressMock->expects($this->once())->method('setEmail')->with($email)->willReturnSelf(); $this->billingAddressManagementMock->expects($this->never())->method('assign'); $this->paymentMethodManagementMock->expects($this->once())->method('set')->with($cartId, $paymentMock); - $quoteIdMaskMock = $this->getMock( - \Magento\Quote\Model\QuoteIdMask::class, - ['getQuoteId', 'load'], - [], - '', - false - ); + $quoteIdMaskMock = $this->createPartialMock(\Magento\Quote\Model\QuoteIdMask::class, ['getQuoteId', 'load']); $this->quoteIdMaskFactoryMock->expects($this->once())->method('create')->willReturn($quoteIdMaskMock); $quoteIdMaskMock->expects($this->once())->method('load')->with($cartId, 'masked_id')->willReturnSelf(); $quoteIdMaskMock->expects($this->once())->method('getQuoteId')->willReturn($cartId); @@ -177,8 +166,8 @@ public function testSavePaymentInformationAndPlaceOrderWithLocolizedException() { $cartId = 100; $email = 'email@magento.com'; - $paymentMock = $this->getMock(\Magento\Quote\Api\Data\PaymentInterface::class); - $billingAddressMock = $this->getMock(\Magento\Quote\Api\Data\AddressInterface::class); + $paymentMock = $this->createMock(\Magento\Quote\Api\Data\PaymentInterface::class); + $billingAddressMock = $this->createMock(\Magento\Quote\Api\Data\AddressInterface::class); $billingAddressMock->expects($this->once())->method('setEmail')->with($email)->willReturnSelf(); diff --git a/app/code/Magento/Checkout/Test/Unit/Model/GuestShippingInformationManagementTest.php b/app/code/Magento/Checkout/Test/Unit/Model/GuestShippingInformationManagementTest.php index 7c016d6471708..a0b6df444e56f 100644 --- a/app/code/Magento/Checkout/Test/Unit/Model/GuestShippingInformationManagementTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Model/GuestShippingInformationManagementTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Checkout\Test\Unit\Model; -class GuestShippingInformationManagementTest extends \PHPUnit_Framework_TestCase +class GuestShippingInformationManagementTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -25,14 +25,11 @@ class GuestShippingInformationManagementTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->quoteIdMaskFactoryMock = $this->getMock( + $this->quoteIdMaskFactoryMock = $this->createPartialMock( \Magento\Quote\Model\QuoteIdMaskFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->shippingInformationManagementMock = $this->getMock( + $this->shippingInformationManagementMock = $this->createMock( \Magento\Checkout\Api\ShippingInformationManagementInterface::class ); @@ -49,21 +46,15 @@ public function testSaveAddressInformation() { $cartId = 'masked_id'; $quoteId = 100; - $addressInformationMock = $this->getMock(\Magento\Checkout\Api\Data\ShippingInformationInterface::class); + $addressInformationMock = $this->createMock(\Magento\Checkout\Api\Data\ShippingInformationInterface::class); - $quoteIdMaskMock = $this->getMock( - \Magento\Quote\Model\QuoteIdMask::class, - ['load', 'getQuoteId'], - [], - '', - false - ); + $quoteIdMaskMock = $this->createPartialMock(\Magento\Quote\Model\QuoteIdMask::class, ['load', 'getQuoteId']); $this->quoteIdMaskFactoryMock->expects($this->once())->method('create')->willReturn($quoteIdMaskMock); $quoteIdMaskMock->expects($this->once())->method('load')->with($cartId, 'masked_id')->willReturnSelf(); $quoteIdMaskMock->expects($this->once())->method('getQuoteId')->willReturn($quoteId); - $paymentInformationMock = $this->getMock(\Magento\Checkout\Api\Data\PaymentDetailsInterface::class); + $paymentInformationMock = $this->createMock(\Magento\Checkout\Api\Data\PaymentDetailsInterface::class); $this->shippingInformationManagementMock->expects($this->once()) ->method('saveAddressInformation') ->with($quoteId, $addressInformationMock) diff --git a/app/code/Magento/Checkout/Test/Unit/Model/Layout/DepersonalizePluginTest.php b/app/code/Magento/Checkout/Test/Unit/Model/Layout/DepersonalizePluginTest.php index 3cd0e6c1b710e..586ed57076763 100644 --- a/app/code/Magento/Checkout/Test/Unit/Model/Layout/DepersonalizePluginTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Model/Layout/DepersonalizePluginTest.php @@ -11,7 +11,7 @@ /** * Class DepersonalizePluginTest */ -class DepersonalizePluginTest extends \PHPUnit_Framework_TestCase +class DepersonalizePluginTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Model\Layout\DepersonalizePluginTest @@ -38,31 +38,13 @@ class DepersonalizePluginTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->layoutMock = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); - $this->checkoutSessionMock = $this->getMock( - \Magento\Framework\Session\Generic::class, - ['clearStorage', 'setData', 'getData'], - [], - '', - false - ); - $this->checkoutSessionMock = $this->getMock( - \Magento\Checkout\Model\Session::class, - ['clearStorage'], - [], - '', - false - ); - $this->requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); - $this->moduleManagerMock = $this->getMock(\Magento\Framework\Module\Manager::class, [], [], '', false); - $this->cacheConfigMock = $this->getMock(\Magento\PageCache\Model\Config::class, [], [], '', false); - $this->depersonalizeCheckerMock = $this->getMock( - \Magento\PageCache\Model\DepersonalizeChecker::class, - [], - [], - '', - false - ); + $this->layoutMock = $this->createMock(\Magento\Framework\View\Layout::class); + $this->checkoutSessionMock = $this->createPartialMock(\Magento\Framework\Session\Generic::class, ['clearStorage', 'setData', 'getData']); + $this->checkoutSessionMock = $this->createPartialMock(\Magento\Checkout\Model\Session::class, ['clearStorage']); + $this->requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class); + $this->moduleManagerMock = $this->createMock(\Magento\Framework\Module\Manager::class); + $this->cacheConfigMock = $this->createMock(\Magento\PageCache\Model\Config::class); + $this->depersonalizeCheckerMock = $this->createMock(\Magento\PageCache\Model\DepersonalizeChecker::class); $this->plugin = new \Magento\Checkout\Model\Layout\DepersonalizePlugin( $this->depersonalizeCheckerMock, @@ -75,7 +57,7 @@ protected function setUp() */ public function testAfterGenerateXml() { - $expectedResult = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); + $expectedResult = $this->createMock(\Magento\Framework\View\Layout::class); $this->depersonalizeCheckerMock->expects($this->once())->method('checkIfDepersonalize')->willReturn(true); $this->checkoutSessionMock @@ -89,7 +71,7 @@ public function testAfterGenerateXml() public function testAfterGenerateXmlNoDepersonalize() { - $expectedResult = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); + $expectedResult = $this->createMock(\Magento\Framework\View\Layout::class); $this->depersonalizeCheckerMock->expects($this->once())->method('checkIfDepersonalize')->willReturn(false); $this->checkoutSessionMock diff --git a/app/code/Magento/Checkout/Test/Unit/Model/PaymentInformationManagementTest.php b/app/code/Magento/Checkout/Test/Unit/Model/PaymentInformationManagementTest.php index 0ca5b268060f9..b40b2b244ac4c 100644 --- a/app/code/Magento/Checkout/Test/Unit/Model/PaymentInformationManagementTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Model/PaymentInformationManagementTest.php @@ -8,7 +8,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class PaymentInformationManagementTest extends \PHPUnit_Framework_TestCase +class PaymentInformationManagementTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -43,15 +43,15 @@ class PaymentInformationManagementTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->billingAddressManagementMock = $this->getMock( + $this->billingAddressManagementMock = $this->createMock( \Magento\Quote\Api\BillingAddressManagementInterface::class ); - $this->paymentMethodManagementMock = $this->getMock( + $this->paymentMethodManagementMock = $this->createMock( \Magento\Quote\Api\PaymentMethodManagementInterface::class ); - $this->cartManagementMock = $this->getMock(\Magento\Quote\Api\CartManagementInterface::class); + $this->cartManagementMock = $this->createMock(\Magento\Quote\Api\CartManagementInterface::class); - $this->loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); + $this->loggerMock = $this->createMock(\Psr\Log\LoggerInterface::class); $this->cartRepositoryMock = $this->getMockBuilder(\Magento\Quote\Api\CartRepositoryInterface::class)->getMock(); $this->model = $objectManager->getObject( \Magento\Checkout\Model\PaymentInformationManagement::class, @@ -69,8 +69,8 @@ public function testSavePaymentInformationAndPlaceOrder() { $cartId = 100; $orderId = 200; - $paymentMock = $this->getMock(\Magento\Quote\Api\Data\PaymentInterface::class); - $billingAddressMock = $this->getMock(\Magento\Quote\Api\Data\AddressInterface::class); + $paymentMock = $this->createMock(\Magento\Quote\Api\Data\PaymentInterface::class); + $billingAddressMock = $this->createMock(\Magento\Quote\Api\Data\AddressInterface::class); $this->getMockForAssignBillingAddress($cartId, $billingAddressMock); $this->paymentMethodManagementMock->expects($this->once())->method('set')->with($cartId, $paymentMock); @@ -89,8 +89,8 @@ public function testSavePaymentInformationAndPlaceOrder() public function testSavePaymentInformationAndPlaceOrderException() { $cartId = 100; - $paymentMock = $this->getMock(\Magento\Quote\Api\Data\PaymentInterface::class); - $billingAddressMock = $this->getMock(\Magento\Quote\Api\Data\AddressInterface::class); + $paymentMock = $this->createMock(\Magento\Quote\Api\Data\PaymentInterface::class); + $billingAddressMock = $this->createMock(\Magento\Quote\Api\Data\AddressInterface::class); $this->getMockForAssignBillingAddress($cartId, $billingAddressMock); $this->paymentMethodManagementMock->expects($this->once())->method('set')->with($cartId, $paymentMock); @@ -105,7 +105,7 @@ public function testSavePaymentInformationAndPlaceOrderIfBillingAddressNotExist( { $cartId = 100; $orderId = 200; - $paymentMock = $this->getMock(\Magento\Quote\Api\Data\PaymentInterface::class); + $paymentMock = $this->createMock(\Magento\Quote\Api\Data\PaymentInterface::class); $this->paymentMethodManagementMock->expects($this->once())->method('set')->with($cartId, $paymentMock); $this->cartManagementMock->expects($this->once())->method('placeOrder')->with($cartId)->willReturn($orderId); @@ -119,8 +119,8 @@ public function testSavePaymentInformationAndPlaceOrderIfBillingAddressNotExist( public function testSavePaymentInformation() { $cartId = 100; - $paymentMock = $this->getMock(\Magento\Quote\Api\Data\PaymentInterface::class); - $billingAddressMock = $this->getMock(\Magento\Quote\Api\Data\AddressInterface::class); + $paymentMock = $this->createMock(\Magento\Quote\Api\Data\PaymentInterface::class); + $billingAddressMock = $this->createMock(\Magento\Quote\Api\Data\AddressInterface::class); $this->getMockForAssignBillingAddress($cartId, $billingAddressMock); $this->paymentMethodManagementMock->expects($this->once())->method('set')->with($cartId, $paymentMock); @@ -131,7 +131,7 @@ public function testSavePaymentInformation() public function testSavePaymentInformationWithoutBillingAddress() { $cartId = 100; - $paymentMock = $this->getMock(\Magento\Quote\Api\Data\PaymentInterface::class); + $paymentMock = $this->createMock(\Magento\Quote\Api\Data\PaymentInterface::class); $this->paymentMethodManagementMock->expects($this->once())->method('set')->with($cartId, $paymentMock); @@ -145,8 +145,8 @@ public function testSavePaymentInformationWithoutBillingAddress() public function testSavePaymentInformationAndPlaceOrderWithLocolizedException() { $cartId = 100; - $paymentMock = $this->getMock(\Magento\Quote\Api\Data\PaymentInterface::class); - $billingAddressMock = $this->getMock(\Magento\Quote\Api\Data\AddressInterface::class); + $paymentMock = $this->createMock(\Magento\Quote\Api\Data\PaymentInterface::class); + $billingAddressMock = $this->createMock(\Magento\Quote\Api\Data\AddressInterface::class); $this->getMockForAssignBillingAddress($cartId, $billingAddressMock); @@ -166,14 +166,11 @@ public function testSavePaymentInformationAndPlaceOrderWithLocolizedException() private function getMockForAssignBillingAddress($cartId, $billingAddressMock) { $billingAddressId = 1; - $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); - $quoteBillingAddress = $this->getMock(\Magento\Quote\Model\Quote\Address::class, [], [], '', false); - $quoteShippingAddress = $this->getMock( + $quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class); + $quoteBillingAddress = $this->createMock(\Magento\Quote\Model\Quote\Address::class); + $quoteShippingAddress = $this->createPartialMock( \Magento\Quote\Model\Quote\Address::class, - ['setLimitCarrier', 'getShippingMethod'], - [], - '', - false + ['setLimitCarrier', 'getShippingMethod'] ); $this->cartRepositoryMock->expects($this->any())->method('getActive')->with($cartId)->willReturn($quoteMock); $quoteMock->expects($this->once())->method('getBillingAddress')->willReturn($quoteBillingAddress); diff --git a/app/code/Magento/Checkout/Test/Unit/Model/Session/SuccessValidatorTest.php b/app/code/Magento/Checkout/Test/Unit/Model/Session/SuccessValidatorTest.php index 80670e4124d2a..fec1d6d4d003f 100644 --- a/app/code/Magento/Checkout/Test/Unit/Model/Session/SuccessValidatorTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Model/Session/SuccessValidatorTest.php @@ -7,7 +7,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -class SuccessValidatorTest extends \PHPUnit_Framework_TestCase +class SuccessValidatorTest extends \PHPUnit\Framework\TestCase { /** @var ObjectManagerHelper */ protected $objectManagerHelper; diff --git a/app/code/Magento/Checkout/Test/Unit/Model/SessionTest.php b/app/code/Magento/Checkout/Test/Unit/Model/SessionTest.php index 9865b80a816ea..8889927730302 100644 --- a/app/code/Magento/Checkout/Test/Unit/Model/SessionTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Model/SessionTest.php @@ -16,7 +16,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class SessionTest extends \PHPUnit_Framework_TestCase +class SessionTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager @@ -51,12 +51,12 @@ public function testGetLastRealOrder($orderId, $incrementId, $orderMock) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $quoteRepository = $this->getMock(\Magento\Quote\Api\CartRepositoryInterface::class); + $quoteRepository = $this->createMock(\Magento\Quote\Api\CartRepositoryInterface::class); - $appState = $this->getMock(\Magento\Framework\App\State::class, [], [], '', false); + $appState = $this->createPartialMock(\Magento\Framework\App\State::class, ['isInstalled']); $appState->expects($this->any())->method('isInstalled')->will($this->returnValue(true)); - $request = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); + $request = $this->createMock(\Magento\Framework\App\Request\Http::class); $request->expects($this->any())->method('getHttpHost')->will($this->returnValue([])); $constructArguments = $this->_helper->getConstructArguments( @@ -104,14 +104,9 @@ protected function _getOrderMock($incrementId, $orderId) ['getIncrementId', 'loadByIncrementId', '__sleep', '__wakeup'] )->getMock(); - $order->expects($this->once())->method('getIncrementId')->will($this->returnValue($incrementId)); - - if ($orderId) { - $order->expects($this->once())->method('loadByIncrementId')->with($orderId); - } - - if ($orderId == $incrementId) { + if ($orderId && $incrementId) { $order->expects($this->once())->method('getIncrementId')->will($this->returnValue($incrementId)); + $order->expects($this->once())->method('loadByIncrementId')->with($orderId); } return $order; @@ -151,19 +146,15 @@ public function clearHelperDataDataProvider() */ public function testRestoreQuote($hasOrderId, $hasQuoteId) { - $order = $this->getMock( - \Magento\Sales\Model\Order::class, - ['getId', 'loadByIncrementId', '__wakeup'], - [], - '', - false - ); + $order = $this->createPartialMock(\Magento\Sales\Model\Order::class, ['getId', 'loadByIncrementId', '__wakeup']); $order->expects($this->once())->method('getId')->will($this->returnValue($hasOrderId ? 'order id' : null)); - $orderFactory = $this->getMock(\Magento\Sales\Model\OrderFactory::class, ['create'], [], '', false); + $orderFactory = $this->createPartialMock(\Magento\Sales\Model\OrderFactory::class, ['create']); $orderFactory->expects($this->once())->method('create')->will($this->returnValue($order)); - $quoteRepository = $this->getMock(\Magento\Quote\Api\CartRepositoryInterface::class); - $storage = $this->getMock(\Magento\Framework\Session\Storage::class, null); - $store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $quoteRepository = $this->getMockBuilder(\Magento\Quote\Api\CartRepositoryInterface::class) + ->setMethods(['save']) + ->getMockForAbstractClass(); + $storage = new \Magento\Framework\Session\Storage(); + $store = $this->createMock(\Magento\Store\Model\Store::class); $storeManager = $this->getMockForAbstractClass(\Magento\Store\Model\StoreManagerInterface::class); $storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store)); $eventManager = $this->getMockForAbstractClass(\Magento\Framework\Event\ManagerInterface::class); @@ -187,13 +178,7 @@ public function testRestoreQuote($hasOrderId, $hasQuoteId) if ($hasOrderId) { $order->setQuoteId($quoteId); - $quote = $this->getMock( - \Magento\Quote\Model\Quote::class, - ['setIsActive', 'getId', 'setReservedOrderId', '__wakeup'], - [], - '', - false - ); + $quote = $this->createPartialMock(\Magento\Quote\Model\Quote::class, ['setIsActive', 'getId', 'setReservedOrderId', '__wakeup', 'save']); if ($hasQuoteId) { $quoteRepository->expects($this->once())->method('get')->with($quoteId)->willReturn($quote); $quote->expects( @@ -306,25 +291,13 @@ public function testReplaceQuote() $storage->expects($this->any()) ->method('setData'); - $quoteIdMaskMock = $this->getMock( - \Magento\Quote\Model\QuoteIdMask::class, - ['getMaskedId', 'load', 'setQuoteId', 'save'], - [], - '', - false - ); + $quoteIdMaskMock = $this->createPartialMock(\Magento\Quote\Model\QuoteIdMask::class, ['getMaskedId', 'load', 'setQuoteId', 'save']); $quoteIdMaskMock->expects($this->once())->method('load')->with($replaceQuoteId, 'quote_id')->willReturnSelf(); $quoteIdMaskMock->expects($this->once())->method('getMaskedId')->willReturn(null); $quoteIdMaskMock->expects($this->once())->method('setQuoteId')->with($replaceQuoteId)->willReturnSelf(); $quoteIdMaskMock->expects($this->once())->method('save'); - $quoteIdMaskFactoryMock = $this->getMock( - \Magento\Quote\Model\QuoteIdMaskFactory::class, - ['create'], - [], - '', - false - ); + $quoteIdMaskFactoryMock = $this->createPartialMock(\Magento\Quote\Model\QuoteIdMaskFactory::class, ['create']); $quoteIdMaskFactoryMock->expects($this->once())->method('create')->willReturn($quoteIdMaskMock); $session = $this->_helper->getObject( diff --git a/app/code/Magento/Checkout/Test/Unit/Model/ShippingInformationManagementTest.php b/app/code/Magento/Checkout/Test/Unit/Model/ShippingInformationManagementTest.php index e7388613867eb..5c6314b2a35c8 100644 --- a/app/code/Magento/Checkout/Test/Unit/Model/ShippingInformationManagementTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Model/ShippingInformationManagementTest.php @@ -9,7 +9,7 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.TooManyFields) */ -class ShippingInformationManagementTest extends \PHPUnit_Framework_TestCase +class ShippingInformationManagementTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager @@ -84,17 +84,16 @@ class ShippingInformationManagementTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->paymentMethodManagementMock = $this->getMock(\Magento\Quote\Api\PaymentMethodManagementInterface::class); - $this->paymentDetailsFactoryMock = $this->getMock( + $this->paymentMethodManagementMock = $this->createMock( + \Magento\Quote\Api\PaymentMethodManagementInterface::class + ); + $this->paymentDetailsFactoryMock = $this->createPartialMock( \Magento\Checkout\Model\PaymentDetailsFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->cartTotalsRepositoryMock = $this->getMock(\Magento\Quote\Api\CartTotalRepositoryInterface::class); - $this->quoteRepositoryMock = $this->getMock(\Magento\Quote\Api\CartRepositoryInterface::class); - $this->shippingAddressMock = $this->getMock( + $this->cartTotalsRepositoryMock = $this->createMock(\Magento\Quote\Api\CartTotalRepositoryInterface::class); + $this->quoteRepositoryMock = $this->createMock(\Magento\Quote\Api\CartRepositoryInterface::class); + $this->shippingAddressMock = $this->createPartialMock( \Magento\Quote\Model\Quote\Address::class, [ 'getSaveInAddressBook', @@ -111,13 +110,10 @@ protected function setUp() 'getShippingRateByCode', 'getShippingMethod', 'setLimitCarrier' - ], - [], - '', - false + ] ); - $this->quoteMock = $this->getMock( + $this->quoteMock = $this->createPartialMock( \Magento\Quote\Model\Quote::class, [ 'isVirtual', @@ -139,11 +135,11 @@ protected function setUp() ); $this->shippingAssignmentFactoryMock = - $this->getMock(\Magento\Quote\Model\ShippingAssignmentFactory::class, ['create'], [], '', false); + $this->createPartialMock(\Magento\Quote\Model\ShippingAssignmentFactory::class, ['create']); $this->cartExtensionFactoryMock = - $this->getMock(\Magento\Quote\Api\Data\CartExtensionFactory::class, ['create'], [], '', false); + $this->createPartialMock(\Magento\Quote\Api\Data\CartExtensionFactory::class, ['create']); $this->shippingFactoryMock = - $this->getMock(\Magento\Quote\Model\ShippingFactory::class, ['create'], [], '', false); + $this->createPartialMock(\Magento\Quote\Model\ShippingFactory::class, ['create']); $this->model = $this->objectManager->getObject( \Magento\Checkout\Model\ShippingInformationManagement::class, @@ -168,9 +164,9 @@ public function testSaveAddressInformationIfCartIsEmpty() $cartId = 100; $carrierCode = 'carrier_code'; $shippingMethod = 'shipping_method'; - $addressInformationMock = $this->getMock(\Magento\Checkout\Api\Data\ShippingInformationInterface::class); + $addressInformationMock = $this->createMock(\Magento\Checkout\Api\Data\ShippingInformationInterface::class); - $billingAddress = $this->getMock(\Magento\Quote\Api\Data\AddressInterface::class); + $billingAddress = $this->createMock(\Magento\Quote\Api\Data\AddressInterface::class); $addressInformationMock->expects($this->once()) ->method('getShippingAddress') ->willReturn($this->shippingAddressMock); @@ -198,31 +194,24 @@ private function setShippingAssignmentsMocks($shippingMethod) { $this->quoteMock->expects($this->once())->method('getExtensionAttributes')->willReturn(null); $this->shippingAddressMock->expects($this->once())->method('setLimitCarrier'); - $this->cartExtensionMock = $this->getMock( + $this->cartExtensionMock = $this->createPartialMock( \Magento\Quote\Api\Data\CartExtension::class, - ['getShippingAssignments', 'setShippingAssignments'], - [], - '', - false + ['getShippingAssignments', 'setShippingAssignments'] ); $this->cartExtensionFactoryMock->expects($this->once()) ->method('create') ->willReturn($this->cartExtensionMock); $this->cartExtensionMock->expects($this->once())->method('getShippingAssignments')->willReturn(null); - $this->shippingAssignmentMock = $this->getMock( - \Magento\Quote\Model\ShippingAssignment::class, - [], - [], - '', - false + $this->shippingAssignmentMock = $this->createMock( + \Magento\Quote\Model\ShippingAssignment::class ); $this->shippingAssignmentFactoryMock->expects($this->once()) ->method('create') ->willReturn($this->shippingAssignmentMock); $this->shippingAssignmentMock->expects($this->once())->method('getShipping')->willReturn(null); - $this->shippingMock = $this->getMock(\Magento\Quote\Model\Shipping::class, [], [], '', false); + $this->shippingMock = $this->createMock(\Magento\Quote\Model\Shipping::class); $this->shippingFactoryMock->expects($this->once())->method('create')->willReturn($this->shippingMock); $this->shippingMock->expects($this->once()) @@ -256,7 +245,7 @@ public function testSaveAddressInformationIfShippingAddressNotSet() $cartId = 100; $carrierCode = 'carrier_code'; $shippingMethod = 'shipping_method'; - $addressInformationMock = $this->getMock(\Magento\Checkout\Api\Data\ShippingInformationInterface::class); + $addressInformationMock = $this->createMock(\Magento\Checkout\Api\Data\ShippingInformationInterface::class); $addressInformationMock->expects($this->once()) ->method('getShippingAddress') @@ -264,7 +253,7 @@ public function testSaveAddressInformationIfShippingAddressNotSet() $addressInformationMock->expects($this->once())->method('getShippingCarrierCode')->willReturn($carrierCode); $addressInformationMock->expects($this->once())->method('getShippingMethodCode')->willReturn($shippingMethod); - $billingAddress = $this->getMock(\Magento\Quote\Api\Data\AddressInterface::class); + $billingAddress = $this->createMock(\Magento\Quote\Api\Data\AddressInterface::class); $addressInformationMock->expects($this->once())->method('getBillingAddress')->willReturn($billingAddress); $this->shippingAddressMock->expects($this->once())->method('getCountryId')->willReturn(null); @@ -281,7 +270,7 @@ public function testSaveAddressInformationIfCanNotSaveQuote() $cartId = 100; $carrierCode = 'carrier_code'; $shippingMethod = 'shipping_method'; - $addressInformationMock = $this->getMock(\Magento\Checkout\Api\Data\ShippingInformationInterface::class); + $addressInformationMock = $this->createMock(\Magento\Checkout\Api\Data\ShippingInformationInterface::class); $this->quoteRepositoryMock->expects($this->once()) ->method('getActive') @@ -294,7 +283,7 @@ public function testSaveAddressInformationIfCanNotSaveQuote() $addressInformationMock->expects($this->once())->method('getShippingCarrierCode')->willReturn($carrierCode); $addressInformationMock->expects($this->once())->method('getShippingMethodCode')->willReturn($shippingMethod); - $billingAddress = $this->getMock(\Magento\Quote\Api\Data\AddressInterface::class); + $billingAddress = $this->createMock(\Magento\Quote\Api\Data\AddressInterface::class); $addressInformationMock->expects($this->once())->method('getBillingAddress')->willReturn($billingAddress); $this->shippingAddressMock->expects($this->once())->method('getCountryId')->willReturn('USA'); @@ -322,7 +311,7 @@ public function testSaveAddressInformationIfCarrierCodeIsInvalid() $cartId = 100; $carrierCode = 'carrier_code'; $shippingMethod = 'shipping_method'; - $addressInformationMock = $this->getMock(\Magento\Checkout\Api\Data\ShippingInformationInterface::class); + $addressInformationMock = $this->createMock(\Magento\Checkout\Api\Data\ShippingInformationInterface::class); $this->quoteRepositoryMock->expects($this->once()) ->method('getActive') @@ -334,7 +323,7 @@ public function testSaveAddressInformationIfCarrierCodeIsInvalid() $addressInformationMock->expects($this->once())->method('getShippingCarrierCode')->willReturn($carrierCode); $addressInformationMock->expects($this->once())->method('getShippingMethodCode')->willReturn($shippingMethod); - $billingAddress = $this->getMock(\Magento\Quote\Api\Data\AddressInterface::class); + $billingAddress = $this->createMock(\Magento\Quote\Api\Data\AddressInterface::class); $addressInformationMock->expects($this->once())->method('getBillingAddress')->willReturn($billingAddress); $this->shippingAddressMock->expects($this->once())->method('getCountryId')->willReturn('USA'); @@ -363,7 +352,7 @@ public function testSaveAddressInformation() $cartId = 100; $carrierCode = 'carrier_code'; $shippingMethod = 'shipping_method'; - $addressInformationMock = $this->getMock(\Magento\Checkout\Api\Data\ShippingInformationInterface::class); + $addressInformationMock = $this->createMock(\Magento\Checkout\Api\Data\ShippingInformationInterface::class); $this->quoteRepositoryMock->expects($this->once()) ->method('getActive') @@ -375,7 +364,7 @@ public function testSaveAddressInformation() $addressInformationMock->expects($this->once())->method('getShippingCarrierCode')->willReturn($carrierCode); $addressInformationMock->expects($this->once())->method('getShippingMethodCode')->willReturn($shippingMethod); - $billingAddress = $this->getMock(\Magento\Quote\Api\Data\AddressInterface::class); + $billingAddress = $this->createMock(\Magento\Quote\Api\Data\AddressInterface::class); $addressInformationMock->expects($this->once())->method('getBillingAddress')->willReturn($billingAddress); $this->shippingAddressMock->expects($this->once())->method('getCountryId')->willReturn('USA'); @@ -396,16 +385,16 @@ public function testSaveAddressInformation() ->with($shippingMethod) ->willReturn('rates'); - $paymentDetailsMock = $this->getMock(\Magento\Checkout\Api\Data\PaymentDetailsInterface::class); + $paymentDetailsMock = $this->createMock(\Magento\Checkout\Api\Data\PaymentDetailsInterface::class); $this->paymentDetailsFactoryMock->expects($this->once())->method('create')->willReturn($paymentDetailsMock); - $paymentMethodMock = $this->getMock(\Magento\Quote\Api\Data\PaymentMethodInterface::class); + $paymentMethodMock = $this->createMock(\Magento\Quote\Api\Data\PaymentMethodInterface::class); $this->paymentMethodManagementMock->expects($this->once()) ->method('getList') ->with($cartId) ->willReturn([$paymentMethodMock]); - $cartTotalsMock = $this->getMock(\Magento\Quote\Api\Data\TotalsInterface::class); + $cartTotalsMock = $this->createMock(\Magento\Quote\Api\Data\TotalsInterface::class); $this->cartTotalsRepositoryMock->expects($this->once()) ->method('get') ->with($cartId) diff --git a/app/code/Magento/Checkout/Test/Unit/Model/SidebarTest.php b/app/code/Magento/Checkout/Test/Unit/Model/SidebarTest.php index 16c2848e2e017..29537e8ec0526 100644 --- a/app/code/Magento/Checkout/Test/Unit/Model/SidebarTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Model/SidebarTest.php @@ -7,7 +7,7 @@ use Magento\Checkout\Model\Sidebar; -class SidebarTest extends \PHPUnit_Framework_TestCase +class SidebarTest extends \PHPUnit\Framework\TestCase { /** @var Sidebar */ protected $sidebar; @@ -23,9 +23,9 @@ class SidebarTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->cartMock = $this->getMock(\Magento\Checkout\Model\Cart::class, [], [], '', false); - $this->checkoutHelperMock = $this->getMock(\Magento\Checkout\Helper\Data::class, [], [], '', false); - $this->resolverMock = $this->getMock(\Magento\Framework\Locale\ResolverInterface::class); + $this->cartMock = $this->createMock(\Magento\Checkout\Model\Cart::class); + $this->checkoutHelperMock = $this->createMock(\Magento\Checkout\Helper\Data::class); + $this->resolverMock = $this->createMock(\Magento\Framework\Locale\ResolverInterface::class); $this->sidebar = new Sidebar( $this->cartMock, diff --git a/app/code/Magento/Checkout/Test/Unit/Model/Type/OnepageTest.php b/app/code/Magento/Checkout/Test/Unit/Model/Type/OnepageTest.php index 0c563d7b492b5..684ad9264f77c 100644 --- a/app/code/Magento/Checkout/Test/Unit/Model/Type/OnepageTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Model/Type/OnepageTest.php @@ -16,7 +16,7 @@ * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class OnepageTest extends \PHPUnit_Framework_TestCase +class OnepageTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Checkout\Model\Type\Onepage */ protected $onepage; @@ -118,53 +118,29 @@ protected function setUp() '', false ); - $this->eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); - $this->checkoutHelperMock = $this->getMock(\Magento\Checkout\Helper\Data::class, [], [], '', false); - $this->customerUrlMock = $this->getMock(\Magento\Customer\Model\Url::class, [], [], '', false); - $this->loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); - $this->checkoutSessionMock = $this->getMock( - \Magento\Checkout\Model\Session::class, - ['getLastOrderId', 'getQuote', 'setStepData', 'getStepData'], - [], - '', - false - ); - $this->customerSessionMock = $this->getMock( - \Magento\Customer\Model\Session::class, - ['getCustomerDataObject', 'isLoggedIn'], - [], - '', - false - ); - $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->eventManagerMock = $this->createMock(\Magento\Framework\Event\ManagerInterface::class); + $this->checkoutHelperMock = $this->createMock(\Magento\Checkout\Helper\Data::class); + $this->customerUrlMock = $this->createMock(\Magento\Customer\Model\Url::class); + $this->loggerMock = $this->createMock(\Psr\Log\LoggerInterface::class); + $this->checkoutSessionMock = $this->createPartialMock(\Magento\Checkout\Model\Session::class, ['getLastOrderId', 'getQuote', 'setStepData', 'getStepData']); + $this->customerSessionMock = $this->createPartialMock(\Magento\Customer\Model\Session::class, ['getCustomerDataObject', 'isLoggedIn']); + $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); - $this->addressFactoryMock = $this->getMock(\Magento\Customer\Model\AddressFactory::class, [], [], '', false); - $this->formFactoryMock = $this->getMock(\Magento\Customer\Model\Metadata\FormFactory::class, [], [], '', false); - $this->customerFactoryMock = $this->getMock(\Magento\Customer\Model\CustomerFactory::class, [], [], '', false); - $this->quoteManagementMock = $this->getMock(\Magento\Quote\Api\CartManagementInterface::class); - $this->orderFactoryMock = $this->getMock(\Magento\Sales\Model\OrderFactory::class, ['create'], [], '', false); - $this->copyMock = $this->getMock(\Magento\Framework\DataObject\Copy::class, [], [], '', false); - $this->messageManagerMock = $this->getMock(\Magento\Framework\Message\ManagerInterface::class); - - $this->customerFormFactoryMock = $this->getMock( - \Magento\Customer\Model\FormFactory::class, - ['create'], - [], - '', - false - ); + $this->addressFactoryMock = $this->createMock(\Magento\Customer\Model\AddressFactory::class); + $this->formFactoryMock = $this->createMock(\Magento\Customer\Model\Metadata\FormFactory::class); + $this->customerFactoryMock = $this->createMock(\Magento\Customer\Model\CustomerFactory::class); + $this->quoteManagementMock = $this->createMock(\Magento\Quote\Api\CartManagementInterface::class); + $this->orderFactoryMock = $this->createPartialMock(\Magento\Sales\Model\OrderFactory::class, ['create']); + $this->copyMock = $this->createMock(\Magento\Framework\DataObject\Copy::class); + $this->messageManagerMock = $this->createMock(\Magento\Framework\Message\ManagerInterface::class); - $this->customerDataFactoryMock = $this->getMock( - \Magento\Customer\Api\Data\CustomerInterfaceFactory::class, - [], - [], - '', - false - ); + $this->customerFormFactoryMock = $this->createPartialMock(\Magento\Customer\Model\FormFactory::class, ['create']); + + $this->customerDataFactoryMock = $this->createMock(\Magento\Customer\Api\Data\CustomerInterfaceFactory::class); - $this->randomMock = $this->getMock(\Magento\Framework\Math\Random::class); - $this->encryptorMock = $this->getMock(\Magento\Framework\Encryption\EncryptorInterface::class); + $this->randomMock = $this->createMock(\Magento\Framework\Math\Random::class); + $this->encryptorMock = $this->createMock(\Magento\Framework\Encryption\EncryptorInterface::class); $this->customerRepositoryMock = $this->getMockForAbstractClass( \Magento\Customer\Api\CustomerRepositoryInterface::class, @@ -173,15 +149,9 @@ protected function setUp() false ); - $orderSenderMock = $this->getMock( - \Magento\Sales\Model\Order\Email\Sender\OrderSender::class, - [], - [], - '', - false - ); + $orderSenderMock = $this->createMock(\Magento\Sales\Model\Order\Email\Sender\OrderSender::class); - $this->quoteRepositoryMock = $this->getMock(\Magento\Quote\Api\CartRepositoryInterface::class); + $this->quoteRepositoryMock = $this->createMock(\Magento\Quote\Api\CartRepositoryInterface::class); $this->extensibleDataObjectConverterMock = $this->getMockBuilder( \Magento\Framework\Api\ExtensibleDataObjectConverter::class @@ -192,13 +162,7 @@ protected function setUp() ->method('toFlatArray') ->will($this->returnValue([])); $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->totalsCollectorMock = $this->getMock( - \Magento\Quote\Model\Quote\TotalsCollector::class, - [], - [], - '', - false - ); + $this->totalsCollectorMock = $this->createMock(\Magento\Quote\Model\Quote\TotalsCollector::class); $this->onepage = $this->objectManagerHelper->getObject( \Magento\Checkout\Model\Type\Onepage::class, [ @@ -242,7 +206,7 @@ public function testGetQuote() public function testSetQuote() { /** @var \Magento\Quote\Model\Quote $quoteMock */ - $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); + $quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class); $this->onepage->setQuote($quoteMock); $this->assertEquals($quoteMock, $this->onepage->getQuote()); } @@ -259,9 +223,7 @@ public function testInitCheckout($stepData, $isLoggedIn, $isSetStepDataCalled) false ); /** @var \Magento\Quote\Model\Quote|\PHPUnit_Framework_MockObject_MockObject $quoteMock */ - $quoteMock = $this->getMock( - \Magento\Quote\Model\Quote::class, - [ + $quoteMock = $this->createPartialMock(\Magento\Quote\Model\Quote::class, [ 'isMultipleShippingAddresses', 'removeAllAddresses', 'save', @@ -276,11 +238,7 @@ public function testInitCheckout($stepData, $isLoggedIn, $isSetStepDataCalled) 'getShippingAddress', 'getCustomerData', 'collectTotals', - ], - [], - '', - false - ); + ]); $quoteMock->expects($this->once())->method('isMultipleShippingAddresses')->will($this->returnValue(true)); $quoteMock->expects($this->once())->method('removeAllAddresses'); $quoteMock->expects($this->once())->method('assignCustomer')->with($customer); @@ -322,7 +280,7 @@ public function testGetCheckoutMethod($isLoggedIn, $quoteCheckoutMethod, $isAllo { $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue($isLoggedIn)); /** @var \Magento\Quote\Model\Quote|\PHPUnit_Framework_MockObject_MockObject $quoteMock */ - $quoteMock = $this->getMock(\Magento\Quote\Model\Quote::class, [], [], '', false); + $quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class); $quoteMock->expects($this->any())->method('setCheckoutMethod')->with($expected); $quoteMock->expects($this->any()) @@ -353,13 +311,7 @@ public function testSaveCheckoutMethod() { $this->assertEquals(['error' => -1, 'message' => 'Invalid data'], $this->onepage->saveCheckoutMethod(null)); /** @var \Magento\Quote\Model\Quote|\PHPUnit_Framework_MockObject_MockObject $quoteMock */ - $quoteMock = $this->getMock( - \Magento\Quote\Model\Quote::class, - ['setCheckoutMethod', '__wakeup'], - [], - '', - false - ); + $quoteMock = $this->createPartialMock(\Magento\Quote\Model\Quote::class, ['setCheckoutMethod', '__wakeup']); $quoteMock->expects($this->once())->method('setCheckoutMethod')->with('someMethod')->will($this->returnSelf()); $this->quoteRepositoryMock->expects($this->once())->method('save')->with($quoteMock); $this->checkoutSessionMock->expects($this->once())->method('setStepData')->with('billing', 'allow', true); @@ -373,13 +325,7 @@ public function testGetLastOrderId() $orderId = 1; $this->checkoutSessionMock->expects($this->once())->method('getLastOrderId') ->will($this->returnValue($orderId)); - $orderMock = $this->getMock( - \Magento\Sales\Model\Order::class, - ['load', 'getIncrementId', '__wakeup'], - [], - '', - false - ); + $orderMock = $this->createPartialMock(\Magento\Sales\Model\Order::class, ['load', 'getIncrementId', '__wakeup']); $orderMock->expects($this->once())->method('load')->with($orderId)->will($this->returnSelf()); $orderMock->expects($this->once())->method('getIncrementId')->will($this->returnValue($orderIncrementId)); $this->orderFactoryMock->expects($this->once())->method('create')->will($this->returnValue($orderMock)); diff --git a/app/code/Magento/Checkout/Test/Unit/Observer/LoadCustomerQuoteObserverTest.php b/app/code/Magento/Checkout/Test/Unit/Observer/LoadCustomerQuoteObserverTest.php index 4dc6a64896c8a..ab207d0a67ec2 100644 --- a/app/code/Magento/Checkout/Test/Unit/Observer/LoadCustomerQuoteObserverTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Observer/LoadCustomerQuoteObserverTest.php @@ -7,7 +7,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class LoadCustomerQuoteObserverTest extends \PHPUnit_Framework_TestCase +class LoadCustomerQuoteObserverTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Checkout\Observer\LoadCustomerQuoteObserver */ protected $object; @@ -24,8 +24,8 @@ class LoadCustomerQuoteObserverTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new ObjectManager($this); - $this->checkoutSession = $this->getMock(\Magento\Checkout\Model\Session::class, [], [], '', false); - $this->messageManager = $this->getMock(\Magento\Framework\Message\ManagerInterface::class, [], [], '', false); + $this->checkoutSession = $this->createMock(\Magento\Checkout\Model\Session::class); + $this->messageManager = $this->createMock(\Magento\Framework\Message\ManagerInterface::class); $this->object = $this->objectManager->getObject( \Magento\Checkout\Observer\LoadCustomerQuoteObserver::class, [ diff --git a/app/code/Magento/Checkout/Test/Unit/Observer/SalesQuoteSaveAfterObserverTest.php b/app/code/Magento/Checkout/Test/Unit/Observer/SalesQuoteSaveAfterObserverTest.php index 2cbf961e5127f..6070bb5d424c1 100644 --- a/app/code/Magento/Checkout/Test/Unit/Observer/SalesQuoteSaveAfterObserverTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Observer/SalesQuoteSaveAfterObserverTest.php @@ -7,7 +7,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class SalesQuoteSaveAfterObserverTest extends \PHPUnit_Framework_TestCase +class SalesQuoteSaveAfterObserverTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Checkout\Observer\SalesQuoteSaveAfterObserver */ protected $object; @@ -21,7 +21,7 @@ class SalesQuoteSaveAfterObserverTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new ObjectManager($this); - $this->checkoutSession = $this->getMock(\Magento\Checkout\Model\Session::class, [], [], '', false); + $this->checkoutSession = $this->createMock(\Magento\Checkout\Model\Session::class); $this->object = $this->objectManager->getObject( \Magento\Checkout\Observer\SalesQuoteSaveAfterObserver::class, ['checkoutSession' => $this->checkoutSession] @@ -30,7 +30,7 @@ protected function setUp() public function testSalesQuoteSaveAfter() { - $observer = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false); + $observer = $this->createMock(\Magento\Framework\Event\Observer::class); $observer->expects($this->once())->method('getEvent')->will( $this->returnValue(new \Magento\Framework\DataObject( ['quote' => new \Magento\Framework\DataObject(['is_checkout_cart' => 1, 'id' => 7])] diff --git a/app/code/Magento/Checkout/Test/Unit/Observer/UnsetAllObserverTest.php b/app/code/Magento/Checkout/Test/Unit/Observer/UnsetAllObserverTest.php index 17a78ebd2aec0..d635dea3c2f2d 100644 --- a/app/code/Magento/Checkout/Test/Unit/Observer/UnsetAllObserverTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Observer/UnsetAllObserverTest.php @@ -7,7 +7,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class UnsetAllObserverTest extends \PHPUnit_Framework_TestCase +class UnsetAllObserverTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Checkout\Observer\UnsetAllObserver */ protected $object; @@ -21,7 +21,7 @@ class UnsetAllObserverTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new ObjectManager($this); - $this->checkoutSession = $this->getMock(\Magento\Checkout\Model\Session::class, [], [], '', false); + $this->checkoutSession = $this->createMock(\Magento\Checkout\Model\Session::class); $this->object = $this->objectManager->getObject( \Magento\Checkout\Observer\UnsetAllObserver::class, ['checkoutSession' => $this->checkoutSession] diff --git a/app/code/Magento/Checkout/view/frontend/web/js/checkout-data.js b/app/code/Magento/Checkout/view/frontend/web/js/checkout-data.js index 9c0ef8bb58c07..22b37b2da0b2f 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/checkout-data.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/checkout-data.js @@ -259,6 +259,29 @@ define([ obj.inputFieldEmailValue = email; saveData(obj); + }, + + /** + * Pulling the checked email value from persistence storage + * + * @return {*} + */ + getCheckedEmailValue: function () { + var obj = getData(); + + return obj.checkedEmailValue ? obj.checkedEmailValue : ''; + }, + + /** + * Setting the checked email value pulled from persistence storage + * + * @param {String} email + */ + setCheckedEmailValue: function (email) { + var obj = getData(); + + obj.checkedEmailValue = email; + saveData(obj); } }; }); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/cart/cache.js b/app/code/Magento/Checkout/view/frontend/web/js/model/cart/cache.js index a7c3089b26790..ac3a43af39ba8 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/model/cart/cache.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/model/cart/cache.js @@ -188,6 +188,19 @@ define([ _isAddressChanged: function (address) { return JSON.stringify(_.pick(this.get('address'), this.requiredFields)) !== JSON.stringify(_.pick(address, this.requiredFields)); + }, + + /** + * Compare cached subtotal with provided. + * Custom method for check object equality. + * + * @param {float} subtotal + * @returns {Boolean} + */ + _isSubtotalChanged: function (subtotal) { + var cached = parseFloat(this.get('totals').subtotal); + + return subtotal !== cached; } }; }); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/cart/totals-processor/default.js b/app/code/Magento/Checkout/view/frontend/web/js/model/cart/totals-processor/default.js index 55be66f8b0a08..e269462047748 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/model/cart/totals-processor/default.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/model/cart/totals-processor/default.js @@ -91,7 +91,8 @@ define([ !cartCache.isChanged('shippingMethodCode', data.shippingMethodCode) && !cartCache.isChanged('shippingCarrierCode', data.shippingCarrierCode) && !cartCache.isChanged('address', address) && - cartCache.get('totals') + cartCache.get('totals') && + !cartCache.isChanged('subtotal', parseFloat(quote.totals().subtotal)) ) { quote.setTotals(cartCache.get('totals')); } else { diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/totals.js b/app/code/Magento/Checkout/view/frontend/web/js/model/totals.js index 5bf40df24f0d9..aba0c31b998d1 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/model/totals.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/model/totals.js @@ -8,16 +8,24 @@ */ define([ 'ko', - 'Magento_Checkout/js/model/quote' -], function (ko, quote) { + 'Magento_Checkout/js/model/quote', + 'Magento_Customer/js/customer-data' +], function (ko, quote, customerData) { 'use strict'; - var quoteItems = ko.observable(quote.totals().items); + var quoteItems = ko.observable(quote.totals().items), + cartData = customerData.get('cart'), + quoteSubtotal = parseFloat(quote.totals().subtotal), + subtotalAmount = parseFloat(cartData().subtotalAmount); quote.totals.subscribe(function (newValue) { quoteItems(newValue.items); }); + if (quoteSubtotal !== subtotalAmount) { + customerData.reload(['cart'], false); + } + return { totals: quote.totals, isLoading: ko.observable(false), diff --git a/app/code/Magento/Checkout/view/frontend/web/js/sidebar.js b/app/code/Magento/Checkout/view/frontend/web/js/sidebar.js index 3bc624e5dfdb6..13a2b524e5186 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/sidebar.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/sidebar.js @@ -228,10 +228,17 @@ define([ }, /** - * Update content after item remove. + * Update content after item remove + * + * @param {Object} elem * @private */ - _removeItemAfter: function () { + _removeItemAfter: function (elem) { + var productData = customerData.get('cart')().items.find(function (item) { + return Number(elem.data('cart-item')) === Number(item['item_id']); + }); + + $(document).trigger('ajax:removeFromCart', productData['product_sku']); }, /** diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/beforePlaceOrder.js b/app/code/Magento/Checkout/view/frontend/web/js/view/beforePlaceOrder.js index 3350eb1f9982a..d5809b38e26df 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/beforePlaceOrder.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/beforePlaceOrder.js @@ -3,6 +3,9 @@ * See COPYING.txt for license details. */ +/** + * @deprecated since version 2.2.0 + */ define(['uiComponent'], function (Component) { 'use strict'; diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/form/element/email.js b/app/code/Magento/Checkout/view/frontend/web/js/view/form/element/email.js index b9c4aeb27ad32..90ad07da0ae37 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/form/element/email.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/form/element/email.js @@ -54,6 +54,15 @@ define([ return this; }, + /** @inheritdoc */ + initConfig: function () { + this._super(); + + this.isPasswordVisible = this.resolveInitialPasswordVisibility(); + + return this; + }, + /** * Callback on changing email property */ @@ -81,20 +90,19 @@ define([ * Check email existing. */ checkEmailAvailability: function () { - var self = this; - this.validateRequest(); this.isEmailCheckComplete = $.Deferred(); this.isLoading(true); this.checkRequest = checkEmailAvailability(this.isEmailCheckComplete, this.email()); $.when(this.isEmailCheckComplete).done(function () { - self.isPasswordVisible(false); - }).fail(function () { - self.isPasswordVisible(true); - }).always(function () { - self.isLoading(false); - }); + this.isPasswordVisible(false); + }.bind(this)).fail(function () { + this.isPasswordVisible(true); + checkoutData.setCheckedEmailValue(this.email()); + }.bind(this)).always(function () { + this.isLoading(false); + }.bind(this)); }, /** @@ -153,6 +161,19 @@ define([ fullScreenLoader.stopLoader(); }); } + }, + + /** + * Resolves an initial sate of a login form. + * + * @returns {Boolean} - initial visibility state. + */ + resolveInitialPasswordVisibility: function () { + if (checkoutData.getInputFieldEmailValue() !== '') { + return checkoutData.getInputFieldEmailValue() === checkoutData.getCheckedEmailValue(); + } + + return false; } }); }); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/review/actions.js b/app/code/Magento/Checkout/view/frontend/web/js/view/review/actions.js index 28a73a9b4c64e..7292d8b333c20 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/review/actions.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/review/actions.js @@ -3,6 +3,9 @@ * See COPYING.txt for license details. */ +/** + * @deprecated since version 2.2.0 + */ define([ 'uiComponent', 'Magento_Checkout/js/model/quote', diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/review/actions/default.js b/app/code/Magento/Checkout/view/frontend/web/js/view/review/actions/default.js index 7c30970f5c8d0..99c9d10902989 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/review/actions/default.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/review/actions/default.js @@ -3,6 +3,9 @@ * See COPYING.txt for license details. */ +/** + * @deprecated since version 2.2.0 + */ define([ 'uiComponent' ], function (Component) { diff --git a/app/code/Magento/Checkout/view/frontend/web/template/shipping-address/address-renderer/default.html b/app/code/Magento/Checkout/view/frontend/web/template/shipping-address/address-renderer/default.html index f9400227fae09..2e268461d1eea 100644 --- a/app/code/Magento/Checkout/view/frontend/web/template/shipping-address/address-renderer/default.html +++ b/app/code/Magento/Checkout/view/frontend/web/template/shipping-address/address-renderer/default.html @@ -7,7 +7,7 @@

-
+
,

diff --git a/app/code/Magento/CheckoutAgreements/Api/CheckoutAgreementsRepositoryInterface.php b/app/code/Magento/CheckoutAgreements/Api/CheckoutAgreementsRepositoryInterface.php index ea4756bc10e98..ffff1675d8ff4 100644 --- a/app/code/Magento/CheckoutAgreements/Api/CheckoutAgreementsRepositoryInterface.php +++ b/app/code/Magento/CheckoutAgreements/Api/CheckoutAgreementsRepositoryInterface.php @@ -8,6 +8,7 @@ /** * Interface CheckoutAgreementsRepositoryInterface * @api + * @since 100.0.2 */ interface CheckoutAgreementsRepositoryInterface { diff --git a/app/code/Magento/CheckoutAgreements/Api/Data/AgreementInterface.php b/app/code/Magento/CheckoutAgreements/Api/Data/AgreementInterface.php index 20eddb5164140..6a233767fcf24 100644 --- a/app/code/Magento/CheckoutAgreements/Api/Data/AgreementInterface.php +++ b/app/code/Magento/CheckoutAgreements/Api/Data/AgreementInterface.php @@ -8,6 +8,7 @@ /** * Interface AgreementInterface * @api + * @since 100.0.2 */ interface AgreementInterface extends \Magento\Framework\Api\ExtensibleDataInterface { diff --git a/app/code/Magento/CheckoutAgreements/Block/Agreements.php b/app/code/Magento/CheckoutAgreements/Block/Agreements.php index 68af59da18d5a..47c7d8462b980 100644 --- a/app/code/Magento/CheckoutAgreements/Block/Agreements.php +++ b/app/code/Magento/CheckoutAgreements/Block/Agreements.php @@ -10,6 +10,7 @@ /** * @api + * @since 100.0.2 */ class Agreements extends \Magento\Framework\View\Element\Template { diff --git a/app/code/Magento/CheckoutAgreements/Model/AgreementsValidator.php b/app/code/Magento/CheckoutAgreements/Model/AgreementsValidator.php index 5ce22a566576b..8d25ba88c0f82 100644 --- a/app/code/Magento/CheckoutAgreements/Model/AgreementsValidator.php +++ b/app/code/Magento/CheckoutAgreements/Model/AgreementsValidator.php @@ -10,7 +10,9 @@ */ class AgreementsValidator implements \Magento\Checkout\Api\AgreementsValidatorInterface { - /** @var AgreementsProviderInterface[] */ + /** + * @var \Magento\CheckoutAgreements\Model\AgreementsProviderInterface[] + */ protected $agreementsProviders; /** diff --git a/app/code/Magento/CheckoutAgreements/Test/Unit/Block/AgreementsTest.php b/app/code/Magento/CheckoutAgreements/Test/Unit/Block/AgreementsTest.php index da226626774f0..d28d3218a6bfd 100644 --- a/app/code/Magento/CheckoutAgreements/Test/Unit/Block/AgreementsTest.php +++ b/app/code/Magento/CheckoutAgreements/Test/Unit/Block/AgreementsTest.php @@ -5,10 +5,10 @@ */ namespace Magento\CheckoutAgreements\Test\Unit\Block; -use Magento\Store\Model\ScopeInterface; use Magento\CheckoutAgreements\Model\AgreementsProvider; +use Magento\Store\Model\ScopeInterface; -class AgreementsTest extends \PHPUnit_Framework_TestCase +class AgreementsTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CheckoutAgreements\Block\Agreements @@ -33,18 +33,15 @@ class AgreementsTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->agreementCollFactoryMock = $this->getMock( + $this->agreementCollFactoryMock = $this->createPartialMock( \Magento\CheckoutAgreements\Model\ResourceModel\Agreement\CollectionFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); - $contextMock = $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false); + $contextMock = $this->createMock(\Magento\Framework\View\Element\Template\Context::class); $contextMock->expects($this->once())->method('getScopeConfig')->willReturn($this->scopeConfigMock); $contextMock->expects($this->once())->method('getStoreManager')->willReturn($this->storeManagerMock); @@ -65,16 +62,12 @@ public function testGetAgreements() ->with(AgreementsProvider::PATH_ENABLED, ScopeInterface::SCOPE_STORE) ->willReturn(true); - $agreementCollection = $this->getMock( - \Magento\CheckoutAgreements\Model\ResourceModel\Agreement\Collection::class, - [], - [], - '', - false + $agreementCollection = $this->createMock( + \Magento\CheckoutAgreements\Model\ResourceModel\Agreement\Collection::class ); $this->agreementCollFactoryMock->expects($this->once())->method('create')->willReturn($agreementCollection); - $storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $storeMock = $this->createMock(\Magento\Store\Model\Store::class); $storeMock->expects($this->once())->method('getId')->willReturn($storeId); $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($storeMock); diff --git a/app/code/Magento/CheckoutAgreements/Test/Unit/Model/AgreementModeOptionsTest.php b/app/code/Magento/CheckoutAgreements/Test/Unit/Model/AgreementModeOptionsTest.php index 8f4d0649bd5d7..58c1e104b744f 100644 --- a/app/code/Magento/CheckoutAgreements/Test/Unit/Model/AgreementModeOptionsTest.php +++ b/app/code/Magento/CheckoutAgreements/Test/Unit/Model/AgreementModeOptionsTest.php @@ -7,7 +7,7 @@ use Magento\CheckoutAgreements\Model\AgreementModeOptions; -class AgreementModeOptionsTest extends \PHPUnit_Framework_TestCase +class AgreementModeOptionsTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CheckoutAgreements\Model\AgreementModeOptions diff --git a/app/code/Magento/CheckoutAgreements/Test/Unit/Model/AgreementTest.php b/app/code/Magento/CheckoutAgreements/Test/Unit/Model/AgreementTest.php index 8c57626789b6f..ef50d0e1edbaa 100644 --- a/app/code/Magento/CheckoutAgreements/Test/Unit/Model/AgreementTest.php +++ b/app/code/Magento/CheckoutAgreements/Test/Unit/Model/AgreementTest.php @@ -5,7 +5,7 @@ */ namespace Magento\CheckoutAgreements\Test\Unit\Model; -class AgreementTest extends \PHPUnit_Framework_TestCase +class AgreementTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CheckoutAgreements\Model\Agreement diff --git a/app/code/Magento/CheckoutAgreements/Test/Unit/Model/AgreementsConfigProviderTest.php b/app/code/Magento/CheckoutAgreements/Test/Unit/Model/AgreementsConfigProviderTest.php index d3e15f5bf9c05..eae347e27aa11 100644 --- a/app/code/Magento/CheckoutAgreements/Test/Unit/Model/AgreementsConfigProviderTest.php +++ b/app/code/Magento/CheckoutAgreements/Test/Unit/Model/AgreementsConfigProviderTest.php @@ -5,10 +5,10 @@ */ namespace Magento\CheckoutAgreements\Test\Unit\Model; -use Magento\Store\Model\ScopeInterface; use Magento\CheckoutAgreements\Model\AgreementsProvider; +use Magento\Store\Model\ScopeInterface; -class AgreementsConfigProviderTest extends \PHPUnit_Framework_TestCase +class AgreementsConfigProviderTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CheckoutAgreements\Model\AgreementsConfigProvider @@ -32,15 +32,11 @@ class AgreementsConfigProviderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $this->agreementsRepositoryMock = $this->getMock( - \Magento\CheckoutAgreements\Api\CheckoutAgreementsRepositoryInterface::class, - [], - [], - '', - false + $this->scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->agreementsRepositoryMock = $this->createMock( + \Magento\CheckoutAgreements\Api\CheckoutAgreementsRepositoryInterface::class ); - $this->escaperMock = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); + $this->escaperMock = $this->createMock(\Magento\Framework\Escaper::class); $this->model = new \Magento\CheckoutAgreements\Model\AgreementsConfigProvider( $this->scopeConfigMock, @@ -74,7 +70,7 @@ public function testGetConfigIfContentIsHtml() ->with(AgreementsProvider::PATH_ENABLED, ScopeInterface::SCOPE_STORE) ->willReturn(true); - $agreement = $this->getMock(\Magento\CheckoutAgreements\Api\Data\AgreementInterface::class); + $agreement = $this->createMock(\Magento\CheckoutAgreements\Api\Data\AgreementInterface::class); $this->agreementsRepositoryMock->expects($this->any())->method('getList')->willReturn([$agreement]); $agreement->expects($this->once())->method('getIsHtml')->willReturn(true); @@ -112,7 +108,7 @@ public function testGetConfigIfContentIsNotHtml() ->with(AgreementsProvider::PATH_ENABLED, ScopeInterface::SCOPE_STORE) ->willReturn(true); - $agreement = $this->getMock(\Magento\CheckoutAgreements\Api\Data\AgreementInterface::class); + $agreement = $this->createMock(\Magento\CheckoutAgreements\Api\Data\AgreementInterface::class); $this->agreementsRepositoryMock->expects($this->any())->method('getList')->willReturn([$agreement]); $this->escaperMock->expects($this->once())->method('escapeHtml')->with($content)->willReturn($escapedContent); diff --git a/app/code/Magento/CheckoutAgreements/Test/Unit/Model/AgreementsProviderTest.php b/app/code/Magento/CheckoutAgreements/Test/Unit/Model/AgreementsProviderTest.php index 2a2e20cf76865..6dd71282f8011 100644 --- a/app/code/Magento/CheckoutAgreements/Test/Unit/Model/AgreementsProviderTest.php +++ b/app/code/Magento/CheckoutAgreements/Test/Unit/Model/AgreementsProviderTest.php @@ -5,11 +5,11 @@ */ namespace Magento\CheckoutAgreements\Test\Unit\Model; -use Magento\Store\Model\ScopeInterface; -use Magento\CheckoutAgreements\Model\AgreementsProvider; use Magento\CheckoutAgreements\Model\AgreementModeOptions; +use Magento\CheckoutAgreements\Model\AgreementsProvider; +use Magento\Store\Model\ScopeInterface; -class AgreementsProviderTest extends \PHPUnit_Framework_TestCase +class AgreementsProviderTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CheckoutAgreements\Model\AgreementsProvider @@ -35,15 +35,12 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->agreementCollFactoryMock = $this->getMock( + $this->agreementCollFactoryMock = $this->createPartialMock( \Magento\CheckoutAgreements\Model\ResourceModel\Agreement\CollectionFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); - $this->scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $this->model = $objectManager->getObject( \Magento\CheckoutAgreements\Model\AgreementsProvider::class, @@ -64,16 +61,12 @@ public function testGetRequiredAgreementIdsIfAgreementsEnabled() ->with(AgreementsProvider::PATH_ENABLED, ScopeInterface::SCOPE_STORE) ->willReturn(true); - $agreementCollection = $this->getMock( - \Magento\CheckoutAgreements\Model\ResourceModel\Agreement\Collection::class, - [], - [], - '', - false + $agreementCollection = $this->createMock( + \Magento\CheckoutAgreements\Model\ResourceModel\Agreement\Collection::class ); $this->agreementCollFactoryMock->expects($this->once())->method('create')->willReturn($agreementCollection); - $storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $storeMock = $this->createMock(\Magento\Store\Model\Store::class); $storeMock->expects($this->once())->method('getId')->willReturn($storeId); $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($storeMock); diff --git a/app/code/Magento/CheckoutAgreements/Test/Unit/Model/AgreementsValidatorTest.php b/app/code/Magento/CheckoutAgreements/Test/Unit/Model/AgreementsValidatorTest.php index 3b961d9dafbf2..cc81ef96e1168 100644 --- a/app/code/Magento/CheckoutAgreements/Test/Unit/Model/AgreementsValidatorTest.php +++ b/app/code/Magento/CheckoutAgreements/Test/Unit/Model/AgreementsValidatorTest.php @@ -8,7 +8,7 @@ use Magento\CheckoutAgreements\Model\AgreementsValidator; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -class AgreementsValidatorTest extends \PHPUnit_Framework_TestCase +class AgreementsValidatorTest extends \PHPUnit\Framework\TestCase { /** @var AgreementsValidator */ protected $object; diff --git a/app/code/Magento/CheckoutAgreements/Test/Unit/Model/Checkout/Plugin/GuestValidationTest.php b/app/code/Magento/CheckoutAgreements/Test/Unit/Model/Checkout/Plugin/GuestValidationTest.php index f1c9e82733359..23c6adf48f721 100644 --- a/app/code/Magento/CheckoutAgreements/Test/Unit/Model/Checkout/Plugin/GuestValidationTest.php +++ b/app/code/Magento/CheckoutAgreements/Test/Unit/Model/Checkout/Plugin/GuestValidationTest.php @@ -8,7 +8,7 @@ use Magento\CheckoutAgreements\Model\AgreementsProvider; use Magento\Store\Model\ScopeInterface; -class GuestValidationTest extends \PHPUnit_Framework_TestCase +class GuestValidationTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CheckoutAgreements\Model\Checkout\Plugin\GuestValidation @@ -52,19 +52,16 @@ class GuestValidationTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->agreementsValidatorMock = $this->getMock(\Magento\Checkout\Api\AgreementsValidatorInterface::class); - $this->subjectMock = $this->getMock(\Magento\Checkout\Api\GuestPaymentInformationManagementInterface::class); - $this->paymentMock = $this->getMock(\Magento\Quote\Api\Data\PaymentInterface::class); - $this->addressMock = $this->getMock(\Magento\Quote\Api\Data\AddressInterface::class); - $this->extensionAttributesMock = $this->getMock( + $this->agreementsValidatorMock = $this->createMock(\Magento\Checkout\Api\AgreementsValidatorInterface::class); + $this->subjectMock = $this->createMock(\Magento\Checkout\Api\GuestPaymentInformationManagementInterface::class); + $this->paymentMock = $this->createMock(\Magento\Quote\Api\Data\PaymentInterface::class); + $this->addressMock = $this->createMock(\Magento\Quote\Api\Data\AddressInterface::class); + $this->extensionAttributesMock = $this->createPartialMock( \Magento\Quote\Api\Data\PaymentExtension::class, - ['getAgreementIds'], - [], - '', - false + ['getAgreementIds'] ); - $this->scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $this->repositoryMock = $this->getMock( + $this->scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->repositoryMock = $this->createMock( \Magento\CheckoutAgreements\Api\CheckoutAgreementsRepositoryInterface::class ); diff --git a/app/code/Magento/CheckoutAgreements/Test/Unit/Model/Checkout/Plugin/ValidationTest.php b/app/code/Magento/CheckoutAgreements/Test/Unit/Model/Checkout/Plugin/ValidationTest.php index fd8db1a793a5d..fbc896863e5b5 100644 --- a/app/code/Magento/CheckoutAgreements/Test/Unit/Model/Checkout/Plugin/ValidationTest.php +++ b/app/code/Magento/CheckoutAgreements/Test/Unit/Model/Checkout/Plugin/ValidationTest.php @@ -8,7 +8,7 @@ use Magento\CheckoutAgreements\Model\AgreementsProvider; use Magento\Store\Model\ScopeInterface; -class ValidationTest extends \PHPUnit_Framework_TestCase +class ValidationTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CheckoutAgreements\Model\Checkout\Plugin\Validation @@ -52,19 +52,16 @@ class ValidationTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->agreementsValidatorMock = $this->getMock(\Magento\Checkout\Api\AgreementsValidatorInterface::class); - $this->subjectMock = $this->getMock(\Magento\Checkout\Api\PaymentInformationManagementInterface::class); - $this->paymentMock = $this->getMock(\Magento\Quote\Api\Data\PaymentInterface::class); - $this->addressMock = $this->getMock(\Magento\Quote\Api\Data\AddressInterface::class); - $this->extensionAttributesMock = $this->getMock( + $this->agreementsValidatorMock = $this->createMock(\Magento\Checkout\Api\AgreementsValidatorInterface::class); + $this->subjectMock = $this->createMock(\Magento\Checkout\Api\PaymentInformationManagementInterface::class); + $this->paymentMock = $this->createMock(\Magento\Quote\Api\Data\PaymentInterface::class); + $this->addressMock = $this->createMock(\Magento\Quote\Api\Data\AddressInterface::class); + $this->extensionAttributesMock = $this->createPartialMock( \Magento\Quote\Api\Data\PaymentExtension::class, - ['getAgreementIds'], - [], - '', - false + ['getAgreementIds'] ); - $this->scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $this->repositoryMock = $this->getMock( + $this->scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->repositoryMock = $this->createMock( \Magento\CheckoutAgreements\Api\CheckoutAgreementsRepositoryInterface::class ); diff --git a/app/code/Magento/CheckoutAgreements/Test/Unit/Model/CheckoutAgreementsRepositoryTest.php b/app/code/Magento/CheckoutAgreements/Test/Unit/Model/CheckoutAgreementsRepositoryTest.php index 7cbe88e3f9055..bcb3c798e515c 100644 --- a/app/code/Magento/CheckoutAgreements/Test/Unit/Model/CheckoutAgreementsRepositoryTest.php +++ b/app/code/Magento/CheckoutAgreements/Test/Unit/Model/CheckoutAgreementsRepositoryTest.php @@ -6,13 +6,13 @@ namespace Magento\CheckoutAgreements\Test\Unit\Model; use Magento\CheckoutAgreements\Model\CheckoutAgreementsRepository; -use Magento\Store\Model\ScopeInterface; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Store\Model\ScopeInterface; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class CheckoutAgreementsRepositoryTest extends \PHPUnit_Framework_TestCase +class CheckoutAgreementsRepositoryTest extends \PHPUnit\Framework\TestCase { /** * @var CheckoutAgreementsRepository @@ -68,39 +68,24 @@ protected function setUp() { $this->objectManager = new ObjectManager($this); - $this->factoryMock = $this->getMock( + $this->factoryMock = $this->createPartialMock( \Magento\CheckoutAgreements\Model\ResourceModel\Agreement\CollectionFactory::class, - ['create'], - [], - '', - false - ); - $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); - $this->scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $this->resourceMock = $this->getMock( - \Magento\CheckoutAgreements\Model\ResourceModel\Agreement::class, - [], - [], - '', - false + ['create'] ); - $this->agrFactoryMock = $this->getMock( + $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->resourceMock = $this->createMock(\Magento\CheckoutAgreements\Model\ResourceModel\Agreement::class); + $this->agrFactoryMock = $this->createPartialMock( \Magento\CheckoutAgreements\Model\AgreementFactory::class, - ['create'], - [], - '', - false + ['create'] ); $methods = ['addData', 'getData', 'setStores', 'getAgreementId', 'getId']; $this->agreementMock = - $this->getMock(\Magento\CheckoutAgreements\Model\Agreement::class, $methods, [], '', false); - $this->storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); - $this->extensionAttributesJoinProcessorMock = $this->getMock( + $this->createPartialMock(\Magento\CheckoutAgreements\Model\Agreement::class, $methods); + $this->storeMock = $this->createMock(\Magento\Store\Model\Store::class); + $this->extensionAttributesJoinProcessorMock = $this->createPartialMock( \Magento\Framework\Api\ExtensionAttribute\JoinProcessor::class, - ['process'], - [], - '', - false + ['process'] ); $this->model = new \Magento\CheckoutAgreements\Model\CheckoutAgreementsRepository( @@ -137,7 +122,7 @@ public function testGetListReturnsTheListOfActiveCheckoutAgreements() ->will($this->returnValue(true)); $storeId = 1; - $storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $storeMock = $this->createMock(\Magento\Store\Model\Store::class); $storeMock->expects($this->any())->method('getId')->will($this->returnValue($storeId)); $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($storeMock)); diff --git a/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/agreements-assigner.js b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/agreements-assigner.js index c40ae23f9c948..af856992f8cdc 100644 --- a/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/agreements-assigner.js +++ b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/agreements-assigner.js @@ -3,7 +3,6 @@ * See COPYING.txt for license details. */ -/*jshint browser:true jquery:true*/ /*global alert*/ define([ 'jquery' diff --git a/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/set-payment-information-mixin.js b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/set-payment-information-mixin.js index 396066d23c7fd..ad50d0ae020ed 100644 --- a/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/set-payment-information-mixin.js +++ b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/set-payment-information-mixin.js @@ -2,7 +2,6 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ -/*jshint browser:true jquery:true*/ /*global alert*/ define([ 'jquery', diff --git a/app/code/Magento/Cms/Api/BlockRepositoryInterface.php b/app/code/Magento/Cms/Api/BlockRepositoryInterface.php index 3f7e3e85336a3..9b285051fc44b 100644 --- a/app/code/Magento/Cms/Api/BlockRepositoryInterface.php +++ b/app/code/Magento/Cms/Api/BlockRepositoryInterface.php @@ -10,6 +10,7 @@ /** * CMS block CRUD interface. * @api + * @since 100.0.2 */ interface BlockRepositoryInterface { diff --git a/app/code/Magento/Cms/Api/Data/BlockInterface.php b/app/code/Magento/Cms/Api/Data/BlockInterface.php index d950d2d9249f9..68110b52d2cb2 100644 --- a/app/code/Magento/Cms/Api/Data/BlockInterface.php +++ b/app/code/Magento/Cms/Api/Data/BlockInterface.php @@ -8,6 +8,7 @@ /** * CMS block interface. * @api + * @since 100.0.2 */ interface BlockInterface { diff --git a/app/code/Magento/Cms/Api/Data/BlockSearchResultsInterface.php b/app/code/Magento/Cms/Api/Data/BlockSearchResultsInterface.php index 021b1b117beda..0b043fb1753e4 100644 --- a/app/code/Magento/Cms/Api/Data/BlockSearchResultsInterface.php +++ b/app/code/Magento/Cms/Api/Data/BlockSearchResultsInterface.php @@ -10,6 +10,7 @@ /** * Interface for cms block search results. * @api + * @since 100.0.2 */ interface BlockSearchResultsInterface extends SearchResultsInterface { diff --git a/app/code/Magento/Cms/Api/Data/PageInterface.php b/app/code/Magento/Cms/Api/Data/PageInterface.php index 24c47f3bd2c92..032f4916a85e4 100644 --- a/app/code/Magento/Cms/Api/Data/PageInterface.php +++ b/app/code/Magento/Cms/Api/Data/PageInterface.php @@ -8,6 +8,7 @@ /** * CMS page interface. * @api + * @since 100.0.2 */ interface PageInterface { @@ -67,6 +68,7 @@ public function getPageLayout(); * Get meta title * * @return string|null + * @since 101.0.0 */ public function getMetaTitle(); @@ -205,6 +207,7 @@ public function setPageLayout($pageLayout); * * @param string $metaTitle * @return \Magento\Cms\Api\Data\PageInterface + * @since 101.0.0 */ public function setMetaTitle($metaTitle); diff --git a/app/code/Magento/Cms/Api/Data/PageSearchResultsInterface.php b/app/code/Magento/Cms/Api/Data/PageSearchResultsInterface.php index 0aad50a521a76..5b77c5c49baa3 100644 --- a/app/code/Magento/Cms/Api/Data/PageSearchResultsInterface.php +++ b/app/code/Magento/Cms/Api/Data/PageSearchResultsInterface.php @@ -10,6 +10,7 @@ /** * Interface for cms page search results. * @api + * @since 100.0.2 */ interface PageSearchResultsInterface extends SearchResultsInterface { diff --git a/app/code/Magento/Cms/Api/PageRepositoryInterface.php b/app/code/Magento/Cms/Api/PageRepositoryInterface.php index 9c4ca3b7f25c1..7849a57153055 100644 --- a/app/code/Magento/Cms/Api/PageRepositoryInterface.php +++ b/app/code/Magento/Cms/Api/PageRepositoryInterface.php @@ -10,6 +10,7 @@ /** * CMS page CRUD interface. * @api + * @since 100.0.2 */ interface PageRepositoryInterface { diff --git a/app/code/Magento/Cms/Block/Adminhtml/Page/Grid/Renderer/Action/UrlBuilder.php b/app/code/Magento/Cms/Block/Adminhtml/Page/Grid/Renderer/Action/UrlBuilder.php index b40820441604b..67ae137fb4d8e 100644 --- a/app/code/Magento/Cms/Block/Adminhtml/Page/Grid/Renderer/Action/UrlBuilder.php +++ b/app/code/Magento/Cms/Block/Adminhtml/Page/Grid/Renderer/Action/UrlBuilder.php @@ -37,6 +37,7 @@ public function getUrl($routePath, $scope, $store) $routePath, [ '_current' => false, + '_nosid' => true, '_query' => [StoreResolverInterface::PARAM_NAME => $store] ] ); diff --git a/app/code/Magento/Cms/Block/Adminhtml/Wysiwyg/Images/Content.php b/app/code/Magento/Cms/Block/Adminhtml/Wysiwyg/Images/Content.php index 4c9f6fbcd11e0..1946615eef778 100644 --- a/app/code/Magento/Cms/Block/Adminhtml/Wysiwyg/Images/Content.php +++ b/app/code/Magento/Cms/Block/Adminhtml/Wysiwyg/Images/Content.php @@ -9,6 +9,7 @@ * Wysiwyg Images content block * * @api + * @since 100.0.2 */ class Content extends \Magento\Backend\Block\Widget\Container { diff --git a/app/code/Magento/Cms/Block/Adminhtml/Wysiwyg/Images/Content/Files.php b/app/code/Magento/Cms/Block/Adminhtml/Wysiwyg/Images/Content/Files.php index 377c1821ad4ff..e76da406f4c33 100644 --- a/app/code/Magento/Cms/Block/Adminhtml/Wysiwyg/Images/Content/Files.php +++ b/app/code/Magento/Cms/Block/Adminhtml/Wysiwyg/Images/Content/Files.php @@ -9,6 +9,7 @@ * Directory contents block for Wysiwyg Images * * @api + * @since 100.0.2 */ class Files extends \Magento\Backend\Block\Template { diff --git a/app/code/Magento/Cms/Block/Adminhtml/Wysiwyg/Images/Content/Uploader.php b/app/code/Magento/Cms/Block/Adminhtml/Wysiwyg/Images/Content/Uploader.php index 58e0b41850adb..cf0fc34b217e4 100644 --- a/app/code/Magento/Cms/Block/Adminhtml/Wysiwyg/Images/Content/Uploader.php +++ b/app/code/Magento/Cms/Block/Adminhtml/Wysiwyg/Images/Content/Uploader.php @@ -9,6 +9,7 @@ * Uploader block for Wysiwyg Images * * @api + * @since 100.0.2 */ class Uploader extends \Magento\Backend\Block\Media\Uploader { diff --git a/app/code/Magento/Cms/Block/Adminhtml/Wysiwyg/Images/Tree.php b/app/code/Magento/Cms/Block/Adminhtml/Wysiwyg/Images/Tree.php index 4428095b3c14c..5471bbfb8b0f3 100644 --- a/app/code/Magento/Cms/Block/Adminhtml/Wysiwyg/Images/Tree.php +++ b/app/code/Magento/Cms/Block/Adminhtml/Wysiwyg/Images/Tree.php @@ -9,6 +9,7 @@ * Directory tree renderer for Cms Wysiwyg Images * * @api + * @since 100.0.2 */ class Tree extends \Magento\Backend\Block\Template { diff --git a/app/code/Magento/Cms/Block/Page.php b/app/code/Magento/Cms/Block/Page.php index adbb1251c2d4c..3eca0bb440fe5 100644 --- a/app/code/Magento/Cms/Block/Page.php +++ b/app/code/Magento/Cms/Block/Page.php @@ -11,6 +11,7 @@ * Cms page content block * * @api + * @since 100.0.2 */ class Page extends \Magento\Framework\View\Element\AbstractBlock implements \Magento\Framework\DataObject\IdentityInterface diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Block/InlineEdit.php b/app/code/Magento/Cms/Controller/Adminhtml/Block/InlineEdit.php index b4cda628734a2..e267c568fa9e5 100644 --- a/app/code/Magento/Cms/Controller/Adminhtml/Block/InlineEdit.php +++ b/app/code/Magento/Cms/Controller/Adminhtml/Block/InlineEdit.php @@ -12,10 +12,21 @@ class InlineEdit extends \Magento\Backend\App\Action { - /** @var BlockRepository */ + /** + * Authorization level of a basic admin session + * + * @see _isAllowed() + */ + const ADMIN_RESOURCE = 'Magento_Cms::block'; + + /** + * @var \Magento\Cms\Api\BlockRepositoryInterface + */ protected $blockRepository; - /** @var JsonFactory */ + /** + * @var \Magento\Framework\Controller\Result\JsonFactory + */ protected $jsonFactory; /** diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Block/MassDelete.php b/app/code/Magento/Cms/Controller/Adminhtml/Block/MassDelete.php index c606c7180046e..cff9c8a39b746 100644 --- a/app/code/Magento/Cms/Controller/Adminhtml/Block/MassDelete.php +++ b/app/code/Magento/Cms/Controller/Adminhtml/Block/MassDelete.php @@ -16,6 +16,13 @@ */ class MassDelete extends \Magento\Backend\App\Action { + /** + * Authorization level of a basic admin session + * + * @see _isAllowed() + */ + const ADMIN_RESOURCE = 'Magento_Cms::block'; + /** * @var Filter */ diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Block/Widget/Chooser.php b/app/code/Magento/Cms/Controller/Adminhtml/Block/Widget/Chooser.php index a390e0612e45b..8277aef781303 100644 --- a/app/code/Magento/Cms/Controller/Adminhtml/Block/Widget/Chooser.php +++ b/app/code/Magento/Cms/Controller/Adminhtml/Block/Widget/Chooser.php @@ -12,6 +12,11 @@ class Chooser extends \Magento\Backend\App\Action { + /** + * Authorization level of a basic admin session + */ + const ADMIN_RESOURCE = 'Magento_Widget::widget_instance'; + /** * @var \Magento\Framework\View\LayoutFactory */ diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Page/InlineEdit.php b/app/code/Magento/Cms/Controller/Adminhtml/Page/InlineEdit.php index 51d88626e8ac6..6d75f490d42dc 100644 --- a/app/code/Magento/Cms/Controller/Adminhtml/Page/InlineEdit.php +++ b/app/code/Magento/Cms/Controller/Adminhtml/Page/InlineEdit.php @@ -22,13 +22,19 @@ class InlineEdit extends \Magento\Backend\App\Action */ const ADMIN_RESOURCE = 'Magento_Cms::save'; - /** @var PostDataProcessor */ + /** + * @var \Magento\Cms\Controller\Adminhtml\Page\PostDataProcessor + */ protected $dataProcessor; - /** @var PageRepository */ + /** + * @var \Magento\Cms\Api\PageRepositoryInterface + */ protected $pageRepository; - /** @var JsonFactory */ + /** + * @var \Magento\Framework\Controller\Result\JsonFactory + */ protected $jsonFactory; /** diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Page/MassDisable.php b/app/code/Magento/Cms/Controller/Adminhtml/Page/MassDisable.php index 9402ae9283a0f..e39c2115f961e 100644 --- a/app/code/Magento/Cms/Controller/Adminhtml/Page/MassDisable.php +++ b/app/code/Magento/Cms/Controller/Adminhtml/Page/MassDisable.php @@ -15,6 +15,13 @@ */ class MassDisable extends \Magento\Backend\App\Action { + /** + * Authorization level of a basic admin session + * + * @see _isAllowed() + */ + const ADMIN_RESOURCE = 'Magento_Cms::save'; + /** * @var Filter */ diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Page/MassEnable.php b/app/code/Magento/Cms/Controller/Adminhtml/Page/MassEnable.php index 0cbec4da8dfba..8278c28a1e696 100644 --- a/app/code/Magento/Cms/Controller/Adminhtml/Page/MassEnable.php +++ b/app/code/Magento/Cms/Controller/Adminhtml/Page/MassEnable.php @@ -15,6 +15,13 @@ */ class MassEnable extends \Magento\Backend\App\Action { + /** + * Authorization level of a basic admin session + * + * @see _isAllowed() + */ + const ADMIN_RESOURCE = 'Magento_Cms::save'; + /** * @var Filter */ diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php b/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php index e335ad59ee14e..5644e25dd4c4a 100644 --- a/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php +++ b/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php @@ -91,6 +91,12 @@ public function execute() $id = $this->getRequest()->getParam('page_id'); if ($id) { $model->load($id); + if (!$model->getId()) { + $this->messageManager->addErrorMessage(__('This page no longer exists.')); + /** \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ + $resultRedirect = $this->resultRedirectFactory->create(); + return $resultRedirect->setPath('*/*/'); + } } $model->setData($data); diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Page/Widget/Chooser.php b/app/code/Magento/Cms/Controller/Adminhtml/Page/Widget/Chooser.php index ba0b0c25862f6..1c46ac6807eef 100644 --- a/app/code/Magento/Cms/Controller/Adminhtml/Page/Widget/Chooser.php +++ b/app/code/Magento/Cms/Controller/Adminhtml/Page/Widget/Chooser.php @@ -10,6 +10,11 @@ class Chooser extends \Magento\Backend\App\Action { + /** + * Authorization level of a basic admin session + */ + const ADMIN_RESOURCE = 'Magento_Widget::widget_instance'; + /** * @var \Magento\Framework\View\LayoutFactory */ diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Directive.php b/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Directive.php index 896c73c456269..807bdcb015ad6 100644 --- a/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Directive.php +++ b/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Directive.php @@ -10,6 +10,14 @@ class Directive extends \Magento\Backend\App\Action { + + /** + * Authorization level of a basic admin session + * + * @see _isAllowed() + */ + const ADMIN_RESOURCE = 'Magento_Cms::media_gallery'; + /** * @var \Magento\Framework\Url\DecoderInterface */ diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/DeleteFiles.php b/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/DeleteFiles.php index 40a3dd9a722a2..19dc989620b89 100644 --- a/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/DeleteFiles.php +++ b/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/DeleteFiles.php @@ -1,6 +1,5 @@ _objectManager->get(\Magento\Framework\Filesystem::class); $dir = $filesystem->getDirectoryRead(DirectoryList::MEDIA); - $filePath = $path . '/' . $file; + $filePath = $path . '/' . \Magento\Framework\File\Uploader::getCorrectFileName($file); if ($dir->isFile($dir->getRelativePath($filePath))) { $this->getStorage()->deleteFile($filePath); } diff --git a/app/code/Magento/Cms/Model/Block.php b/app/code/Magento/Cms/Model/Block.php index ee4e1dfb9b7cd..fc369971054d7 100644 --- a/app/code/Magento/Cms/Model/Block.php +++ b/app/code/Magento/Cms/Model/Block.php @@ -13,8 +13,6 @@ /** * CMS block model * - * @method ResourceCmsBlock _getResource() - * @method ResourceCmsBlock getResource() * @method Block setStoreId(array $storeId) * @method array getStoreId() */ @@ -33,9 +31,7 @@ class Block extends AbstractModel implements BlockInterface, IdentityInterface /**#@-*/ - /** - * @var string - */ + /**#@-*/ protected $_cacheTag = self::CACHE_TAG; /** diff --git a/app/code/Magento/Cms/Model/BlockRepository.php b/app/code/Magento/Cms/Model/BlockRepository.php index 5f8ec399e9bd6..e724c1581e8f5 100644 --- a/app/code/Magento/Cms/Model/BlockRepository.php +++ b/app/code/Magento/Cms/Model/BlockRepository.php @@ -195,7 +195,7 @@ public function deleteById($blockId) /** * Retrieve collection processor * - * @deprecated + * @deprecated 101.1.0 * @return CollectionProcessorInterface */ private function getCollectionProcessor() diff --git a/app/code/Magento/Cms/Model/Page.php b/app/code/Magento/Cms/Model/Page.php index 059ffcfc0320d..591f8d93fcdc6 100644 --- a/app/code/Magento/Cms/Model/Page.php +++ b/app/code/Magento/Cms/Model/Page.php @@ -17,11 +17,10 @@ * Cms Page Model * * @api - * @method ResourceCmsPage _getResource() - * @method ResourceCmsPage getResource() * @method Page setStoreId(array $storeId) * @method array getStoreId() * @SuppressWarnings(PHPMD.ExcessivePublicCount) + * @since 100.0.2 */ class Page extends AbstractModel implements PageInterface, IdentityInterface { @@ -182,6 +181,7 @@ public function getPageLayout() * Get meta title * * @return string|null + * @since 101.0.0 */ public function getMetaTitle() { @@ -377,6 +377,7 @@ public function setPageLayout($pageLayout) * * @param string $metaTitle * @return \Magento\Cms\Api\Data\PageInterface + * @since 101.0.0 */ public function setMetaTitle($metaTitle) { @@ -539,6 +540,7 @@ public function setIsActive($isActive) /** * {@inheritdoc} + * @since 101.0.0 */ public function beforeSave() { diff --git a/app/code/Magento/Cms/Model/PageRepository.php b/app/code/Magento/Cms/Model/PageRepository.php index 49e8fffc059c5..9c9e18211aa86 100644 --- a/app/code/Magento/Cms/Model/PageRepository.php +++ b/app/code/Magento/Cms/Model/PageRepository.php @@ -201,7 +201,7 @@ public function deleteById($pageId) /** * Retrieve collection processor * - * @deprecated + * @deprecated 101.1.0 * @return CollectionProcessorInterface */ private function getCollectionProcessor() diff --git a/app/code/Magento/Cms/Model/Wysiwyg/Config.php b/app/code/Magento/Cms/Model/Wysiwyg/Config.php index b85d91bcc7911..b95187f01271a 100644 --- a/app/code/Magento/Cms/Model/Wysiwyg/Config.php +++ b/app/code/Magento/Cms/Model/Wysiwyg/Config.php @@ -13,6 +13,7 @@ * Wysiwyg Config for Editor HTML Element * * @api + * @since 100.0.2 */ class Config extends \Magento\Framework\DataObject implements ConfigInterface { @@ -97,6 +98,7 @@ class Config extends \Magento\Framework\DataObject implements ConfigInterface /** * @var Filesystem + * @since 101.0.0 */ protected $filesystem; diff --git a/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php b/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php index f879f2edcafb2..0688534dc4ad9 100644 --- a/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php +++ b/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php @@ -16,6 +16,7 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * * @api + * @since 100.0.2 */ class Storage extends \Magento\Framework\DataObject { diff --git a/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage/Collection.php b/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage/Collection.php index 88d440cfa84ae..f66c0f6b06d91 100644 --- a/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage/Collection.php +++ b/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage/Collection.php @@ -12,6 +12,7 @@ * Wysiwyg Images storage collection * * @api + * @since 100.0.2 */ class Collection extends \Magento\Framework\Data\Collection\Filesystem { diff --git a/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Block/Widget/ChooserTest.php b/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Block/Widget/ChooserTest.php index 21471b75db01f..97988a5676842 100644 --- a/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Block/Widget/ChooserTest.php +++ b/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Block/Widget/ChooserTest.php @@ -8,7 +8,7 @@ /** * @covers \Magento\Cms\Block\Adminhtml\Block\Widget\Chooser */ -class ChooserTest extends \PHPUnit_Framework_TestCase +class ChooserTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Cms\Block\Adminhtml\Block\Widget\Chooser diff --git a/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Page/Widget/ChooserTest.php b/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Page/Widget/ChooserTest.php index 590d21687f486..174e3a68b7c66 100644 --- a/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Page/Widget/ChooserTest.php +++ b/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Page/Widget/ChooserTest.php @@ -8,7 +8,7 @@ /** * @covers \Magento\Cms\Block\Adminhtml\Page\Widget\Chooser */ -class ChooserTest extends \PHPUnit_Framework_TestCase +class ChooserTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Cms\Block\Adminhtml\Page\Widget\Chooser diff --git a/app/code/Magento/Cms/Test/Unit/Block/BlockTest.php b/app/code/Magento/Cms/Test/Unit/Block/BlockTest.php index b41193372c85d..4fb9b357645e6 100644 --- a/app/code/Magento/Cms/Test/Unit/Block/BlockTest.php +++ b/app/code/Magento/Cms/Test/Unit/Block/BlockTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Cms\Test\Unit\Block; -class BlockTest extends \PHPUnit_Framework_TestCase +class BlockTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Cms\Block\Block diff --git a/app/code/Magento/Cms/Test/Unit/Block/PageTest.php b/app/code/Magento/Cms/Test/Unit/Block/PageTest.php index db83521cfd531..1c681f4c2b4b1 100644 --- a/app/code/Magento/Cms/Test/Unit/Block/PageTest.php +++ b/app/code/Magento/Cms/Test/Unit/Block/PageTest.php @@ -8,7 +8,7 @@ /** * Class PageTest */ -class PageTest extends \PHPUnit_Framework_TestCase +class PageTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Cms\Block\Page diff --git a/app/code/Magento/Cms/Test/Unit/Block/Widget/Page/LinkTest.php b/app/code/Magento/Cms/Test/Unit/Block/Widget/Page/LinkTest.php index 42c23dce019f5..6860bfcc0097a 100644 --- a/app/code/Magento/Cms/Test/Unit/Block/Widget/Page/LinkTest.php +++ b/app/code/Magento/Cms/Test/Unit/Block/Widget/Page/LinkTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Cms\Test\Unit\Block\Widget\Page; -class LinkTest extends \PHPUnit_Framework_TestCase +class LinkTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Cms\Block\Widget\Page\Link @@ -30,15 +30,8 @@ class LinkTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->mockCmsPage = $this->getMock(\Magento\Cms\Helper\Page::class, [], [], '', false, false); - $this->mockResourcePage = $this->getMock( - \Magento\Cms\Model\ResourceModel\Page::class, - [], - [], - '', - false, - false - ); + $this->mockCmsPage = $this->createMock(\Magento\Cms\Helper\Page::class); + $this->mockResourcePage = $this->createMock(\Magento\Cms\Model\ResourceModel\Page::class); $this->linkElement = $this->objectManager->getObject( \Magento\Cms\Block\Widget\Page\Link::class, diff --git a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/AbstractMassActionTest.php b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/AbstractMassActionTest.php index e81bb702abe74..e6bbe8476cbef 100644 --- a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/AbstractMassActionTest.php +++ b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/AbstractMassActionTest.php @@ -7,7 +7,7 @@ use Magento\Framework\Controller\ResultFactory; -abstract class AbstractMassActionTest extends \PHPUnit_Framework_TestCase +abstract class AbstractMassActionTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager @@ -43,13 +43,7 @@ protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->messageManagerMock = $this->getMock( - \Magento\Framework\Message\ManagerInterface::class, - [], - [], - '', - false - ); + $this->messageManagerMock = $this->createMock(\Magento\Framework\Message\ManagerInterface::class); $this->resultFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\ResultFactory::class) ->disableOriginalConstructor() @@ -62,7 +56,7 @@ protected function setUp() ->with(ResultFactory::TYPE_REDIRECT, []) ->willReturn($this->resultRedirectMock); - $this->contextMock = $this->getMock(\Magento\Backend\App\Action\Context::class, [], [], '', false); + $this->contextMock = $this->createMock(\Magento\Backend\App\Action\Context::class); $this->filterMock = $this->getMockBuilder(\Magento\Ui\Component\MassAction\Filter::class) ->disableOriginalConstructor() diff --git a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Block/DeleteTest.php b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Block/DeleteTest.php index f9dc6c50a6ea5..ff1ed408eb131 100644 --- a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Block/DeleteTest.php +++ b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Block/DeleteTest.php @@ -8,7 +8,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class DeleteTest extends \PHPUnit_Framework_TestCase +class DeleteTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Cms\Controller\Adminhtml\Block\Delete @@ -64,13 +64,7 @@ protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->messageManagerMock = $this->getMock( - \Magento\Framework\Message\ManagerInterface::class, - [], - [], - '', - false - ); + $this->messageManagerMock = $this->createMock(\Magento\Framework\Message\ManagerInterface::class); $this->requestMock = $this->getMockForAbstractClass( \Magento\Framework\App\RequestInterface::class, @@ -107,13 +101,7 @@ protected function setUp() ->method('create') ->willReturn($this->resultRedirectMock); - $this->contextMock = $this->getMock( - \Magento\Backend\App\Action\Context::class, - [], - [], - '', - false - ); + $this->contextMock = $this->createMock(\Magento\Backend\App\Action\Context::class); $this->contextMock->expects($this->any())->method('getRequest')->willReturn($this->requestMock); $this->contextMock->expects($this->any())->method('getMessageManager')->willReturn($this->messageManagerMock); diff --git a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Block/EditTest.php b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Block/EditTest.php index 55d88c1b1a8f5..875dde9fb226b 100644 --- a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Block/EditTest.php +++ b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Block/EditTest.php @@ -8,7 +8,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class EditTest extends \PHPUnit_Framework_TestCase +class EditTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Cms\Controller\Adminhtml\Block\Edit @@ -68,14 +68,8 @@ class EditTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->messageManagerMock = $this->getMock( - \Magento\Framework\Message\ManagerInterface::class, - [], - [], - '', - false - ); - $this->coreRegistryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); + $this->messageManagerMock = $this->createMock(\Magento\Framework\Message\ManagerInterface::class); + $this->coreRegistryMock = $this->createMock(\Magento\Framework\Registry::class); $this->blockMock = $this->getMockBuilder(\Magento\Cms\Model\Block::class) ->disableOriginalConstructor() @@ -98,13 +92,7 @@ protected function setUp() \Magento\Backend\Model\View\Result\RedirectFactory::class )->disableOriginalConstructor()->getMock(); - $this->resultPageFactoryMock = $this->getMock( - \Magento\Framework\View\Result\PageFactory::class, - [], - [], - '', - false - ); + $this->resultPageFactoryMock = $this->createMock(\Magento\Framework\View\Result\PageFactory::class); $this->requestMock = $this->getMockForAbstractClass( \Magento\Framework\App\RequestInterface::class, @@ -116,13 +104,7 @@ protected function setUp() [] ); - $this->contextMock = $this->getMock( - \Magento\Backend\App\Action\Context::class, - [], - [], - '', - false - ); + $this->contextMock = $this->createMock(\Magento\Backend\App\Action\Context::class); $this->contextMock->expects($this->once())->method('getRequest')->willReturn($this->requestMock); $this->contextMock->expects($this->once())->method('getObjectManager')->willReturn($this->objectManagerMock); $this->contextMock->expects($this->once())->method('getMessageManager')->willReturn($this->messageManagerMock); @@ -199,16 +181,16 @@ public function testEditAction($blockId, $label, $title) ->method('register') ->with('cms_block', $this->blockMock); - $resultPageMock = $this->getMock(\Magento\Backend\Model\View\Result\Page::class, [], [], '', false); + $resultPageMock = $this->createMock(\Magento\Backend\Model\View\Result\Page::class); $this->resultPageFactoryMock->expects($this->once()) ->method('create') ->willReturn($resultPageMock); - $titleMock = $this->getMock(\Magento\Framework\View\Page\Title::class, [], [], '', false); + $titleMock = $this->createMock(\Magento\Framework\View\Page\Title::class); $titleMock->expects($this->at(0))->method('prepend')->with(__('Blocks')); $titleMock->expects($this->at(1))->method('prepend')->with($this->getTitle()); - $pageConfigMock = $this->getMock(\Magento\Framework\View\Page\Config::class, [], [], '', false); + $pageConfigMock = $this->createMock(\Magento\Framework\View\Page\Config::class); $pageConfigMock->expects($this->exactly(2))->method('getTitle')->willReturn($titleMock); $resultPageMock->expects($this->once()) diff --git a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Block/MassDeleteTest.php b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Block/MassDeleteTest.php index 614c5ebbd0993..2dc14154c85e5 100644 --- a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Block/MassDeleteTest.php +++ b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Block/MassDeleteTest.php @@ -28,16 +28,13 @@ protected function setUp() { parent::setUp(); - $this->collectionFactoryMock = $this->getMock( + $this->collectionFactoryMock = $this->createPartialMock( \Magento\Cms\Model\ResourceModel\Block\CollectionFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->blockCollectionMock = - $this->getMock(\Magento\Cms\Model\ResourceModel\Block\Collection::class, [], [], '', false); + $this->createMock(\Magento\Cms\Model\ResourceModel\Block\Collection::class); $this->massDeleteController = $this->objectManager->getObject( \Magento\Cms\Controller\Adminhtml\Block\MassDelete::class, @@ -90,13 +87,7 @@ public function testMassDeleteAction() */ protected function getBlockMock() { - $blockMock = $this->getMock( - \Magento\Cms\Model\ResourceModel\Block\Collection::class, - ['delete'], - [], - '', - false - ); + $blockMock = $this->createPartialMock(\Magento\Cms\Model\ResourceModel\Block\Collection::class, ['delete']); $blockMock->expects($this->once())->method('delete')->willReturn(true); return $blockMock; diff --git a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Block/SaveTest.php b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Block/SaveTest.php index 8f7122e19206b..f6b709a5c96c9 100644 --- a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Block/SaveTest.php +++ b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Block/SaveTest.php @@ -8,7 +8,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class SaveTest extends \PHPUnit_Framework_TestCase +class SaveTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject @@ -74,7 +74,7 @@ protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->contextMock = $this->getMock(\Magento\Backend\App\Action\Context::class, [], [], '', false); + $this->contextMock = $this->createMock(\Magento\Backend\App\Action\Context::class); $this->resultRedirectFactory = $this->getMockBuilder(\Magento\Backend\Model\View\Result\RedirectFactory::class) ->disableOriginalConstructor() @@ -104,13 +104,7 @@ protected function setUp() \Magento\Cms\Model\Block::class )->disableOriginalConstructor()->getMock(); - $this->messageManagerMock = $this->getMock( - \Magento\Framework\Message\ManagerInterface::class, - [], - [], - '', - false - ); + $this->messageManagerMock = $this->createMock(\Magento\Framework\Message\ManagerInterface::class); $this->eventManagerMock = $this->getMockForAbstractClass( \Magento\Framework\Event\ManagerInterface::class, diff --git a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/DeleteTest.php b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/DeleteTest.php index 7ea1daacf5b7c..7f994bf5b3df5 100644 --- a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/DeleteTest.php +++ b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/DeleteTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Cms\Test\Unit\Controller\Adminhtml\Page; -class DeleteTest extends \PHPUnit_Framework_TestCase +class DeleteTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Cms\Controller\Adminhtml\Page\Delete */ protected $deleteController; @@ -47,13 +47,7 @@ protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->messageManagerMock = $this->getMock( - \Magento\Framework\Message\ManagerInterface::class, - [], - [], - '', - false - ); + $this->messageManagerMock = $this->createMock(\Magento\Framework\Message\ManagerInterface::class); $this->requestMock = $this->getMockForAbstractClass( \Magento\Framework\App\RequestInterface::class, @@ -89,15 +83,9 @@ protected function setUp() ->method('create') ->willReturn($this->resultRedirectMock); - $this->eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); + $this->eventManagerMock = $this->createMock(\Magento\Framework\Event\ManagerInterface::class); - $this->contextMock = $this->getMock( - \Magento\Backend\App\Action\Context::class, - [], - [], - '', - false - ); + $this->contextMock = $this->createMock(\Magento\Backend\App\Action\Context::class); $this->contextMock->expects($this->any())->method('getRequest')->willReturn($this->requestMock); $this->contextMock->expects($this->any())->method('getMessageManager')->willReturn($this->messageManagerMock); diff --git a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/EditTest.php b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/EditTest.php index 332142de0b0e4..335abb837523a 100644 --- a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/EditTest.php +++ b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/EditTest.php @@ -8,7 +8,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class EditTest extends \PHPUnit_Framework_TestCase +class EditTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Cms\Controller\Adminhtml\Page\Edit @@ -68,14 +68,8 @@ class EditTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->messageManagerMock = $this->getMock( - \Magento\Framework\Message\ManagerInterface::class, - [], - [], - '', - false - ); - $this->coreRegistryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); + $this->messageManagerMock = $this->createMock(\Magento\Framework\Message\ManagerInterface::class); + $this->coreRegistryMock = $this->createMock(\Magento\Framework\Registry::class); $this->pageMock = $this->getMockBuilder(\Magento\Cms\Model\Page::class) ->disableOriginalConstructor() @@ -98,13 +92,7 @@ protected function setUp() \Magento\Backend\Model\View\Result\RedirectFactory::class )->disableOriginalConstructor()->getMock(); - $this->resultPageFactoryMock = $this->getMock( - \Magento\Framework\View\Result\PageFactory::class, - [], - [], - '', - false - ); + $this->resultPageFactoryMock = $this->createMock(\Magento\Framework\View\Result\PageFactory::class); $this->requestMock = $this->getMockForAbstractClass( \Magento\Framework\App\RequestInterface::class, @@ -116,13 +104,7 @@ protected function setUp() [] ); - $this->contextMock = $this->getMock( - \Magento\Backend\App\Action\Context::class, - [], - [], - '', - false - ); + $this->contextMock = $this->createMock(\Magento\Backend\App\Action\Context::class); $this->contextMock->expects($this->once())->method('getRequest')->willReturn($this->requestMock); $this->contextMock->expects($this->once())->method('getObjectManager')->willReturn($this->objectManagerMock); $this->contextMock->expects($this->once())->method('getMessageManager')->willReturn($this->messageManagerMock); @@ -199,16 +181,16 @@ public function testEditAction($pageId, $label, $title) ->method('register') ->with('cms_page', $this->pageMock); - $resultPageMock = $this->getMock(\Magento\Backend\Model\View\Result\Page::class, [], [], '', false); + $resultPageMock = $this->createMock(\Magento\Backend\Model\View\Result\Page::class); $this->resultPageFactoryMock->expects($this->once()) ->method('create') ->willReturn($resultPageMock); - $titleMock = $this->getMock(\Magento\Framework\View\Page\Title::class, [], [], '', false); + $titleMock = $this->createMock(\Magento\Framework\View\Page\Title::class); $titleMock->expects($this->at(0))->method('prepend')->with(__('Pages')); $titleMock->expects($this->at(1))->method('prepend')->with($this->getTitle()); - $pageConfigMock = $this->getMock(\Magento\Framework\View\Page\Config::class, [], [], '', false); + $pageConfigMock = $this->createMock(\Magento\Framework\View\Page\Config::class); $pageConfigMock->expects($this->exactly(2))->method('getTitle')->willReturn($titleMock); $resultPageMock->expects($this->once()) diff --git a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/InlineEditTest.php b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/InlineEditTest.php index 0cda103cd6963..9d51431b26d8f 100644 --- a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/InlineEditTest.php +++ b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/InlineEditTest.php @@ -10,7 +10,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class InlineEditTest extends \PHPUnit_Framework_TestCase +class InlineEditTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $request; @@ -51,9 +51,9 @@ protected function setUp() $this->request = $this->getMockForAbstractClass(\Magento\Framework\App\RequestInterface::class); $this->messageManager = $this->getMockForAbstractClass(\Magento\Framework\Message\ManagerInterface::class); - $this->messageCollection = $this->getMock(\Magento\Framework\Message\Collection::class, [], [], '', false); + $this->messageCollection = $this->createMock(\Magento\Framework\Message\Collection::class); $this->message = $this->getMockForAbstractClass(\Magento\Framework\Message\MessageInterface::class); - $this->cmsPage = $this->getMock(\Magento\Cms\Model\Page::class, [], [], '', false); + $this->cmsPage = $this->createMock(\Magento\Cms\Model\Page::class); $this->context = $helper->getObject( \Magento\Backend\App\Action\Context::class, [ @@ -61,21 +61,12 @@ protected function setUp() 'messageManager' => $this->messageManager ] ); - $this->dataProcessor = $this->getMock( - \Magento\Cms\Controller\Adminhtml\Page\PostDataProcessor::class, - [], - [], - '', - false - ); + $this->dataProcessor = $this->createMock(\Magento\Cms\Controller\Adminhtml\Page\PostDataProcessor::class); $this->pageRepository = $this->getMockForAbstractClass(\Magento\Cms\Api\PageRepositoryInterface::class); - $this->resultJson = $this->getMock(\Magento\Framework\Controller\Result\Json::class, [], [], '', false); - $this->jsonFactory = $this->getMock( + $this->resultJson = $this->createMock(\Magento\Framework\Controller\Result\Json::class); + $this->jsonFactory = $this->createPartialMock( \Magento\Framework\Controller\Result\JsonFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->controller = new InlineEdit( $this->context, diff --git a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/MassDeleteTest.php b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/MassDeleteTest.php index 180974d9a199f..8f1a651b0a7e1 100644 --- a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/MassDeleteTest.php +++ b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/MassDeleteTest.php @@ -28,16 +28,13 @@ protected function setUp() { parent::setUp(); - $this->collectionFactoryMock = $this->getMock( + $this->collectionFactoryMock = $this->createPartialMock( \Magento\Cms\Model\ResourceModel\Page\CollectionFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->pageCollectionMock = - $this->getMock(\Magento\Cms\Model\ResourceModel\Page\Collection::class, [], [], '', false); + $this->createMock(\Magento\Cms\Model\ResourceModel\Page\Collection::class); $this->massDeleteController = $this->objectManager->getObject( \Magento\Cms\Controller\Adminhtml\Page\MassDelete::class, @@ -90,7 +87,7 @@ public function testMassDeleteAction() */ protected function getPageMock() { - $pageMock = $this->getMock(\Magento\Cms\Model\ResourceModel\Page\Collection::class, ['delete'], [], '', false); + $pageMock = $this->createPartialMock(\Magento\Cms\Model\ResourceModel\Page\Collection::class, ['delete']); $pageMock->expects($this->once())->method('delete')->willReturn(true); return $pageMock; diff --git a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/MassDisableTest.php b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/MassDisableTest.php index 3a79516d10493..0185654434be1 100644 --- a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/MassDisableTest.php +++ b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/MassDisableTest.php @@ -28,21 +28,12 @@ protected function setUp() { parent::setUp(); - $this->collectionFactoryMock = $this->getMock( + $this->collectionFactoryMock = $this->createPartialMock( \Magento\Cms\Model\ResourceModel\Page\CollectionFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->pageCollectionMock = $this->getMock( - \Magento\Cms\Model\ResourceModel\Page\Collection::class, - [], - [], - '', - false - ); + $this->pageCollectionMock = $this->createMock(\Magento\Cms\Model\ResourceModel\Page\Collection::class); $this->massDisableController = $this->objectManager->getObject( \Magento\Cms\Controller\Adminhtml\Page\MassDisable::class, @@ -95,12 +86,9 @@ public function testMassDisableAction() */ protected function getPageMock() { - $pageMock = $this->getMock( + $pageMock = $this->createPartialMock( \Magento\Cms\Model\ResourceModel\Page\Collection::class, - ['setIsActive', 'save'], - [], - '', - false + ['setIsActive', 'save'] ); $pageMock->expects($this->once())->method('setIsActive')->with(false)->willReturn(true); $pageMock->expects($this->once())->method('save')->willReturn(true); diff --git a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/MassEnableTest.php b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/MassEnableTest.php index 92e0e22e7b643..b5907e7b3ffed 100644 --- a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/MassEnableTest.php +++ b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/MassEnableTest.php @@ -28,21 +28,12 @@ protected function setUp() { parent::setUp(); - $this->collectionFactoryMock = $this->getMock( + $this->collectionFactoryMock = $this->createPartialMock( \Magento\Cms\Model\ResourceModel\Page\CollectionFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->pageCollectionMock = $this->getMock( - \Magento\Cms\Model\ResourceModel\Page\Collection::class, - [], - [], - '', - false - ); + $this->pageCollectionMock = $this->createMock(\Magento\Cms\Model\ResourceModel\Page\Collection::class); $this->massEnableController = $this->objectManager->getObject( \Magento\Cms\Controller\Adminhtml\Page\MassEnable::class, @@ -95,12 +86,9 @@ public function testMassEnableAction() */ protected function getPageMock() { - $pageMock = $this->getMock( + $pageMock = $this->createPartialMock( \Magento\Cms\Model\ResourceModel\Page\Collection::class, - ['setIsActive', 'save'], - [], - '', - false + ['setIsActive', 'save'] ); $pageMock->expects($this->once())->method('setIsActive')->with(true)->willReturn(true); $pageMock->expects($this->once())->method('save')->willReturn(true); diff --git a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/SaveTest.php b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/SaveTest.php index 1880a767dbba9..03a8fc0969064 100644 --- a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/SaveTest.php +++ b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/SaveTest.php @@ -8,7 +8,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class SaveTest extends \PHPUnit_Framework_TestCase +class SaveTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Wysiwyg/DirectiveTest.php b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Wysiwyg/DirectiveTest.php index 63d2c065781f9..16b218ebf6493 100644 --- a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Wysiwyg/DirectiveTest.php +++ b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Wysiwyg/DirectiveTest.php @@ -9,7 +9,7 @@ * @covers \Magento\Cms\Controller\Adminhtml\Wysiwyg\Directive * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class DirectiveTest extends \PHPUnit_Framework_TestCase +class DirectiveTest extends \PHPUnit\Framework\TestCase { const IMAGE_PATH = 'pub/media/wysiwyg/image.jpg'; diff --git a/app/code/Magento/Cms/Test/Unit/Controller/Block/InlineEditTest.php b/app/code/Magento/Cms/Test/Unit/Controller/Block/InlineEditTest.php index 7da0f5fffe7e7..667192fb00feb 100644 --- a/app/code/Magento/Cms/Test/Unit/Controller/Block/InlineEditTest.php +++ b/app/code/Magento/Cms/Test/Unit/Controller/Block/InlineEditTest.php @@ -7,7 +7,7 @@ use Magento\Cms\Controller\Adminhtml\Block\InlineEdit; -class InlineEditTest extends \PHPUnit_Framework_TestCase +class InlineEditTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $request; @@ -40,13 +40,7 @@ protected function setUp() '', false ); - $this->cmsBlock = $this->getMock( - \Magento\Cms\Model\Block::class, - [], - [], - '', - false - ); + $this->cmsBlock = $this->createMock(\Magento\Cms\Model\Block::class); $this->context = $helper->getObject( \Magento\Backend\App\Action\Context::class, [ @@ -59,13 +53,10 @@ protected function setUp() '', false ); - $this->resultJson = $this->getMock(\Magento\Framework\Controller\Result\Json::class, [], [], '', false); - $this->jsonFactory = $this->getMock( + $this->resultJson = $this->createMock(\Magento\Framework\Controller\Result\Json::class); + $this->jsonFactory = $this->createPartialMock( \Magento\Framework\Controller\Result\JsonFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->controller = new InlineEdit( $this->context, diff --git a/app/code/Magento/Cms/Test/Unit/Controller/Index/IndexTest.php b/app/code/Magento/Cms/Test/Unit/Controller/Index/IndexTest.php index ff7a0b89a9e30..8ff206e8a80fc 100644 --- a/app/code/Magento/Cms/Test/Unit/Controller/Index/IndexTest.php +++ b/app/code/Magento/Cms/Test/Unit/Controller/Index/IndexTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Cms\Test\Unit\Controller\Index; -class IndexTest extends \PHPUnit_Framework_TestCase +class IndexTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Cms\Controller\Index\Index @@ -45,8 +45,8 @@ class IndexTest extends \PHPUnit_Framework_TestCase protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); - $responseMock = $this->getMock(\Magento\Framework\App\Response\Http::class, [], [], '', false); + $objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); + $responseMock = $this->createMock(\Magento\Framework\App\Response\Http::class); $this->resultPageMock = $this->getMockBuilder(\Magento\Framework\View\Result\Page::class) ->disableOriginalConstructor() ->getMock(); @@ -61,9 +61,9 @@ protected function setUp() ->method('create') ->willReturn($this->forwardMock); - $scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $this->requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); - $this->cmsHelperMock = $this->getMock(\Magento\Cms\Helper\Page::class, [], [], '', false); + $scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class); + $this->cmsHelperMock = $this->createMock(\Magento\Cms\Helper\Page::class); $valueMap = [ [\Magento\Framework\App\Config\ScopeConfigInterface::class, $scopeConfigMock, diff --git a/app/code/Magento/Cms/Test/Unit/Controller/Noroute/IndexTest.php b/app/code/Magento/Cms/Test/Unit/Controller/Noroute/IndexTest.php index db2e3576b3aec..dc1d9b9c85445 100644 --- a/app/code/Magento/Cms/Test/Unit/Controller/Noroute/IndexTest.php +++ b/app/code/Magento/Cms/Test/Unit/Controller/Noroute/IndexTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Cms\Test\Unit\Controller\Noroute; -class IndexTest extends \PHPUnit_Framework_TestCase +class IndexTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Cms\Controller\Noroute\Index @@ -40,8 +40,8 @@ class IndexTest extends \PHPUnit_Framework_TestCase protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); - $responseMock = $this->getMock(\Magento\Framework\App\Response\Http::class, [], [], '', false); + $objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); + $responseMock = $this->createMock(\Magento\Framework\App\Response\Http::class); $this->resultPageMock = $this->getMockBuilder(\Magento\Framework\View\Result\Page::class) ->disableOriginalConstructor() ->getMock(); @@ -56,9 +56,9 @@ protected function setUp() ->method('create') ->willReturn($this->forwardMock); - $scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $this->_requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); - $this->_cmsHelperMock = $this->getMock(\Magento\Cms\Helper\Page::class, [], [], '', false); + $scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->_requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class); + $this->_cmsHelperMock = $this->createMock(\Magento\Cms\Helper\Page::class); $valueMap = [ [\Magento\Framework\App\Config\ScopeConfigInterface::class, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, diff --git a/app/code/Magento/Cms/Test/Unit/Controller/Page/PostDataProcessorTest.php b/app/code/Magento/Cms/Test/Unit/Controller/Page/PostDataProcessorTest.php index 73add3553c480..31d99df5f6289 100644 --- a/app/code/Magento/Cms/Test/Unit/Controller/Page/PostDataProcessorTest.php +++ b/app/code/Magento/Cms/Test/Unit/Controller/Page/PostDataProcessorTest.php @@ -15,7 +15,7 @@ * Class PostDataProcessorTest * @package Magento\Cms\Test\Unit\Controller\Page */ -class PostDataProcessorTest extends \PHPUnit_Framework_TestCase +class PostDataProcessorTest extends \PHPUnit\Framework\TestCase { /** * @var Date|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Cms/Test/Unit/Controller/Page/ViewTest.php b/app/code/Magento/Cms/Test/Unit/Controller/Page/ViewTest.php index 9b14df70a7b41..f15e6ff3e3bf2 100644 --- a/app/code/Magento/Cms/Test/Unit/Controller/Page/ViewTest.php +++ b/app/code/Magento/Cms/Test/Unit/Controller/Page/ViewTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Cms\Test\Unit\Controller\Page; -class ViewTest extends \PHPUnit_Framework_TestCase +class ViewTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Cms\Controller\Page\View @@ -45,8 +45,8 @@ class ViewTest extends \PHPUnit_Framework_TestCase protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); - $responseMock = $this->getMock(\Magento\Framework\App\Response\Http::class, [], [], '', false); + $objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); + $responseMock = $this->createMock(\Magento\Framework\App\Response\Http::class); $this->resultPageMock = $this->getMockBuilder(\Magento\Framework\View\Result\Page::class) ->disableOriginalConstructor() ->getMock(); @@ -61,8 +61,8 @@ protected function setUp() ->method('create') ->willReturn($this->forwardMock); - $this->requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); - $this->cmsHelperMock = $this->getMock(\Magento\Cms\Helper\Page::class, [], [], '', false); + $this->requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class); + $this->cmsHelperMock = $this->createMock(\Magento\Cms\Helper\Page::class); $objectManagerMock->expects($this->once())->method('get')->willReturn($this->cmsHelperMock); $this->controller = $helper->getObject( \Magento\Cms\Controller\Page\View::class, diff --git a/app/code/Magento/Cms/Test/Unit/Controller/RouterTest.php b/app/code/Magento/Cms/Test/Unit/Controller/RouterTest.php index 8b3b04b1ce0e9..3bf67bf1a41ae 100644 --- a/app/code/Magento/Cms/Test/Unit/Controller/RouterTest.php +++ b/app/code/Magento/Cms/Test/Unit/Controller/RouterTest.php @@ -8,7 +8,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class RouterTest extends \PHPUnit_Framework_TestCase +class RouterTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Cms\Controller\Router diff --git a/app/code/Magento/Cms/Test/Unit/Helper/PageTest.php b/app/code/Magento/Cms/Test/Unit/Helper/PageTest.php index 71c51690f7249..8b41f0e3ac0d4 100644 --- a/app/code/Magento/Cms/Test/Unit/Helper/PageTest.php +++ b/app/code/Magento/Cms/Test/Unit/Helper/PageTest.php @@ -11,7 +11,7 @@ * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class PageTest extends \PHPUnit_Framework_TestCase +class PageTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Cms\Helper\Page @@ -175,6 +175,7 @@ protected function setUp() $this->layoutProcessorMock = $this->getMockBuilder(\Magento\Framework\View\Layout\ProcessorInterface::class) ->getMockForAbstractClass(); $this->blockMock = $this->getMockBuilder(\Magento\Framework\View\Element\AbstractBlock::class) + ->setMethods(['setContentHeading']) ->disableOriginalConstructor() ->getMockForAbstractClass(); $this->messagesBlockMock = $this->getMockBuilder(\Magento\Framework\View\Element\Messages::class) @@ -196,7 +197,7 @@ protected function setUp() ] ); - $this->resultPageFactory = $this->getMock(\Magento\Framework\View\Result\PageFactory::class, [], [], '', false); + $this->resultPageFactory = $this->createMock(\Magento\Framework\View\Result\PageFactory::class); $this->object = $objectManager->getObject( \Magento\Cms\Helper\Page::class, diff --git a/app/code/Magento/Cms/Test/Unit/Helper/Wysiwyg/ImagesTest.php b/app/code/Magento/Cms/Test/Unit/Helper/Wysiwyg/ImagesTest.php index afc6e0a1c3a50..1fcc10609870a 100644 --- a/app/code/Magento/Cms/Test/Unit/Helper/Wysiwyg/ImagesTest.php +++ b/app/code/Magento/Cms/Test/Unit/Helper/Wysiwyg/ImagesTest.php @@ -10,7 +10,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ImagesTest extends \PHPUnit_Framework_TestCase +class ImagesTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Cms\Helper\Wysiwyg\Images @@ -77,15 +77,15 @@ protected function setUp() $this->path = 'PATH/'; $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); + $this->eventManagerMock = $this->createMock(\Magento\Framework\Event\ManagerInterface::class); - $this->requestMock = $this->getMock(\Magento\Framework\App\RequestInterface::class, [], [], '', false); + $this->requestMock = $this->createMock(\Magento\Framework\App\RequestInterface::class); - $this->urlEncoderMock = $this->getMock(\Magento\Framework\Url\EncoderInterface::class, [], [], '', false); + $this->urlEncoderMock = $this->createMock(\Magento\Framework\Url\EncoderInterface::class); - $this->backendDataMock = $this->getMock(\Magento\Backend\Helper\Data::class, [], [], '', false); + $this->backendDataMock = $this->createMock(\Magento\Backend\Helper\Data::class); - $this->contextMock = $this->getMock(\Magento\Framework\App\Helper\Context::class, [], [], '', false); + $this->contextMock = $this->createMock(\Magento\Framework\App\Helper\Context::class); $this->contextMock->expects($this->any()) ->method('getEventManager') ->willReturn($this->eventManagerMock); @@ -96,13 +96,10 @@ protected function setUp() ->method('getUrlEncoder') ->willReturn($this->urlEncoderMock); - $this->directoryWriteMock = $this->getMock( - \Magento\Framework\Filesystem\Directory\Write::class, - [], - ['path' => $this->path], - '', - false - ); + $this->directoryWriteMock = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\Write::class) + ->setConstructorArgs(['path' => $this->path]) + ->disableOriginalConstructor() + ->getMock(); $this->directoryWriteMock->expects($this->any()) ->method('getAbsolutePath') ->willReturnMap( @@ -112,7 +109,7 @@ protected function setUp() ] ); - $this->filesystemMock = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); + $this->filesystemMock = $this->createMock(\Magento\Framework\Filesystem::class); $this->filesystemMock->expects($this->once()) ->method('getDirectoryWrite') ->willReturn($this->directoryWriteMock); @@ -128,7 +125,7 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); - $this->storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $this->storeMock = $this->createMock(\Magento\Store\Model\Store::class); $this->imagesHelper = $this->objectManager->getObject( \Magento\Cms\Helper\Wysiwyg\Images::class, @@ -359,7 +356,7 @@ public function testGetCurrentPath($pathId, $expectedPath, $isExist) public function testGetCurrentPathThrowException() { - $this->setExpectedException( + $this->expectException( \Magento\Framework\Exception\LocalizedException::class, 'The directory PATH/wysiwyg is not writable by server.' ); diff --git a/app/code/Magento/Cms/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/BlockStoreFilterTest.php b/app/code/Magento/Cms/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/BlockStoreFilterTest.php index 4a0b9254f8b67..11e00cefdcbc7 100644 --- a/app/code/Magento/Cms/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/BlockStoreFilterTest.php +++ b/app/code/Magento/Cms/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/BlockStoreFilterTest.php @@ -7,7 +7,7 @@ use Magento\Cms\Model\Api\SearchCriteria\CollectionProcessor\FilterProcessor\BlockStoreFilter; -class BlockStoreFilterTest extends \PHPUnit_Framework_TestCase +class BlockStoreFilterTest extends \PHPUnit\Framework\TestCase { /** * @var BlockStoreFilter diff --git a/app/code/Magento/Cms/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/PageStoreFilterTest.php b/app/code/Magento/Cms/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/PageStoreFilterTest.php index e84aadec59875..1f0d6b258b7b5 100644 --- a/app/code/Magento/Cms/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/PageStoreFilterTest.php +++ b/app/code/Magento/Cms/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/PageStoreFilterTest.php @@ -7,7 +7,7 @@ use Magento\Cms\Model\Api\SearchCriteria\CollectionProcessor\FilterProcessor\PageStoreFilter; -class PageStoreFilterTest extends \PHPUnit_Framework_TestCase +class PageStoreFilterTest extends \PHPUnit\Framework\TestCase { /** * @var PageStoreFilter diff --git a/app/code/Magento/Cms/Test/Unit/Model/Block/Source/IsActiveTest.php b/app/code/Magento/Cms/Test/Unit/Model/Block/Source/IsActiveTest.php index e9c05f499e533..6250791813d83 100644 --- a/app/code/Magento/Cms/Test/Unit/Model/Block/Source/IsActiveTest.php +++ b/app/code/Magento/Cms/Test/Unit/Model/Block/Source/IsActiveTest.php @@ -8,7 +8,7 @@ use Magento\Cms\Model\Block; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class IsActiveTest extends \PHPUnit_Framework_TestCase +class IsActiveTest extends \PHPUnit\Framework\TestCase { /** * @var Block|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Cms/Test/Unit/Model/BlockRepositoryTest.php b/app/code/Magento/Cms/Test/Unit/Model/BlockRepositoryTest.php index 6e4440ef97b25..3db1c8b35e2d5 100644 --- a/app/code/Magento/Cms/Test/Unit/Model/BlockRepositoryTest.php +++ b/app/code/Magento/Cms/Test/Unit/Model/BlockRepositoryTest.php @@ -13,7 +13,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class BlockRepositoryTest extends \PHPUnit_Framework_TestCase +class BlockRepositoryTest extends \PHPUnit\Framework\TestCase { /** * @var BlockRepository diff --git a/app/code/Magento/Cms/Test/Unit/Model/Config/Source/PageTest.php b/app/code/Magento/Cms/Test/Unit/Model/Config/Source/PageTest.php index def8e9e2adcbd..4e8259976909d 100644 --- a/app/code/Magento/Cms/Test/Unit/Model/Config/Source/PageTest.php +++ b/app/code/Magento/Cms/Test/Unit/Model/Config/Source/PageTest.php @@ -8,7 +8,7 @@ /** * Class PageTest */ -class PageTest extends \PHPUnit_Framework_TestCase +class PageTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Cms\Model\ResourceModel\Page\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject @@ -29,12 +29,9 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->collectionFactory = $this->getMock( + $this->collectionFactory = $this->createPartialMock( \Magento\Cms\Model\ResourceModel\Page\CollectionFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->page = $objectManager->getObject( @@ -52,13 +49,7 @@ protected function setUp() */ public function testToOptionArray() { - $pageCollectionMock = $this->getMock( - \Magento\Cms\Model\ResourceModel\Page\Collection::class, - [], - [], - '', - false - ); + $pageCollectionMock = $this->createMock(\Magento\Cms\Model\ResourceModel\Page\Collection::class); $this->collectionFactory->expects($this->once()) ->method('create') diff --git a/app/code/Magento/Cms/Test/Unit/Model/Page/Source/IsActiveTest.php b/app/code/Magento/Cms/Test/Unit/Model/Page/Source/IsActiveTest.php index aa6c7956e5566..910e48f431a8e 100644 --- a/app/code/Magento/Cms/Test/Unit/Model/Page/Source/IsActiveTest.php +++ b/app/code/Magento/Cms/Test/Unit/Model/Page/Source/IsActiveTest.php @@ -8,7 +8,7 @@ use Magento\Cms\Model\Page; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class IsActiveTest extends \PHPUnit_Framework_TestCase +class IsActiveTest extends \PHPUnit\Framework\TestCase { /** * @var Page|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Cms/Test/Unit/Model/Page/Source/PageLayoutTest.php b/app/code/Magento/Cms/Test/Unit/Model/Page/Source/PageLayoutTest.php index 22f447eb77c2e..85a0acf7cb375 100644 --- a/app/code/Magento/Cms/Test/Unit/Model/Page/Source/PageLayoutTest.php +++ b/app/code/Magento/Cms/Test/Unit/Model/Page/Source/PageLayoutTest.php @@ -10,7 +10,7 @@ use Magento\Framework\View\Model\PageLayout\Config\BuilderInterface; use Magento\Framework\View\PageLayout\Config; -class PageLayoutTest extends \PHPUnit_Framework_TestCase +class PageLayoutTest extends \PHPUnit\Framework\TestCase { /** * @var BuilderInterface|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Cms/Test/Unit/Model/Page/Source/ThemeTest.php b/app/code/Magento/Cms/Test/Unit/Model/Page/Source/ThemeTest.php index cb4bd73bdb27a..dc424e9d3e58b 100644 --- a/app/code/Magento/Cms/Test/Unit/Model/Page/Source/ThemeTest.php +++ b/app/code/Magento/Cms/Test/Unit/Model/Page/Source/ThemeTest.php @@ -9,7 +9,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Framework\View\Design\Theme\Label\ListInterface; -class ThemeTest extends \PHPUnit_Framework_TestCase +class ThemeTest extends \PHPUnit\Framework\TestCase { /** * @var ListInterface|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Cms/Test/Unit/Model/PageRepositoryTest.php b/app/code/Magento/Cms/Test/Unit/Model/PageRepositoryTest.php index 1bd742048c51e..61001794e2a0b 100644 --- a/app/code/Magento/Cms/Test/Unit/Model/PageRepositoryTest.php +++ b/app/code/Magento/Cms/Test/Unit/Model/PageRepositoryTest.php @@ -13,7 +13,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class PageRepositoryTest extends \PHPUnit_Framework_TestCase +class PageRepositoryTest extends \PHPUnit\Framework\TestCase { /** * @var PageRepository diff --git a/app/code/Magento/Cms/Test/Unit/Model/PageTest.php b/app/code/Magento/Cms/Test/Unit/Model/PageTest.php index 8aca827768fd3..9fdd394973265 100644 --- a/app/code/Magento/Cms/Test/Unit/Model/PageTest.php +++ b/app/code/Magento/Cms/Test/Unit/Model/PageTest.php @@ -16,7 +16,7 @@ * @covers \Magento\Cms\Model\Page * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class PageTest extends \PHPUnit_Framework_TestCase +class PageTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Cms\Model\Page @@ -58,7 +58,7 @@ protected function setUp() ->getMock(); $this->resourcePageMock = $this->getMockBuilder(PageResource::class) ->disableOriginalConstructor() - ->setMethods(['getIdFieldName', 'checkIdentifier']) + ->setMethods(['getIdFieldName', 'checkIdentifier', 'getResources']) ->getMock(); $this->eventManagerMock = $this->getMockBuilder(ManagerInterface::class) ->disableOriginalConstructor() diff --git a/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/AbstractCollectionTest.php b/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/AbstractCollectionTest.php index b6709ce2bac69..39d8285df89a1 100644 --- a/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/AbstractCollectionTest.php +++ b/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/AbstractCollectionTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Cms\Test\Unit\Model\ResourceModel; -abstract class AbstractCollectionTest extends \PHPUnit_Framework_TestCase +abstract class AbstractCollectionTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/Block/Relation/Store/ReadHandlerTest.php b/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/Block/Relation/Store/ReadHandlerTest.php index 1de40e93cbb53..af9208bab2334 100644 --- a/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/Block/Relation/Store/ReadHandlerTest.php +++ b/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/Block/Relation/Store/ReadHandlerTest.php @@ -9,7 +9,7 @@ use Magento\Cms\Model\ResourceModel\Block\Relation\Store\ReadHandler; use Magento\Framework\EntityManager\MetadataPool; -class ReadHandlerTest extends \PHPUnit_Framework_TestCase +class ReadHandlerTest extends \PHPUnit\Framework\TestCase { /** * @var ReadHandler diff --git a/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/Block/Relation/Store/SaveHandlerTest.php b/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/Block/Relation/Store/SaveHandlerTest.php index 4a186b9a263d1..a61bc92c6ca9f 100644 --- a/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/Block/Relation/Store/SaveHandlerTest.php +++ b/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/Block/Relation/Store/SaveHandlerTest.php @@ -10,7 +10,7 @@ use Magento\Framework\EntityManager\MetadataPool; use Magento\Cms\Api\Data\BlockInterface; -class SaveHandlerTest extends \PHPUnit_Framework_TestCase +class SaveHandlerTest extends \PHPUnit\Framework\TestCase { /** * @var SaveHandler diff --git a/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/Page/Grid/CollectionTest.php b/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/Page/Grid/CollectionTest.php index d97334a5b4912..e08da5c41e5fb 100644 --- a/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/Page/Grid/CollectionTest.php +++ b/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/Page/Grid/CollectionTest.php @@ -22,7 +22,7 @@ * Class CollectionTest * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class CollectionTest extends \PHPUnit_Framework_TestCase +class CollectionTest extends \PHPUnit\Framework\TestCase { /** * @var EntityFactoryInterface|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/Page/Relation/Store/ReadHandlerTest.php b/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/Page/Relation/Store/ReadHandlerTest.php index e9af8802a78cd..52432d2317e15 100644 --- a/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/Page/Relation/Store/ReadHandlerTest.php +++ b/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/Page/Relation/Store/ReadHandlerTest.php @@ -9,7 +9,7 @@ use Magento\Cms\Model\ResourceModel\Page\Relation\Store\ReadHandler; use Magento\Framework\EntityManager\MetadataPool; -class ReadHandlerTest extends \PHPUnit_Framework_TestCase +class ReadHandlerTest extends \PHPUnit\Framework\TestCase { /** * @var ReadHandler diff --git a/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/Page/Relation/Store/SaveHandlerTest.php b/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/Page/Relation/Store/SaveHandlerTest.php index fcaa2c10d2a05..154b9301751a1 100644 --- a/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/Page/Relation/Store/SaveHandlerTest.php +++ b/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/Page/Relation/Store/SaveHandlerTest.php @@ -10,7 +10,7 @@ use Magento\Framework\EntityManager\MetadataPool; use Magento\Cms\Api\Data\PageInterface; -class SaveHandlerTest extends \PHPUnit_Framework_TestCase +class SaveHandlerTest extends \PHPUnit\Framework\TestCase { /** * @var SaveHandler diff --git a/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/PageTest.php b/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/PageTest.php index 6d36593a59659..cf129ba298194 100644 --- a/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/PageTest.php +++ b/app/code/Magento/Cms/Test/Unit/Model/ResourceModel/PageTest.php @@ -20,7 +20,7 @@ * Class PageTest * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class PageTest extends \PHPUnit_Framework_TestCase +class PageTest extends \PHPUnit\Framework\TestCase { /** * @var PageResourceModel diff --git a/app/code/Magento/Cms/Test/Unit/Model/Template/FilterProviderTest.php b/app/code/Magento/Cms/Test/Unit/Model/Template/FilterProviderTest.php index 552e9c22d9aaa..c0c929e32ceb6 100644 --- a/app/code/Magento/Cms/Test/Unit/Model/Template/FilterProviderTest.php +++ b/app/code/Magento/Cms/Test/Unit/Model/Template/FilterProviderTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Cms\Test\Unit\Model\Template; -class FilterProviderTest extends \PHPUnit_Framework_TestCase +class FilterProviderTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Cms\Model\Template\FilterProvider @@ -24,8 +24,8 @@ class FilterProviderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_filterMock = $this->getMock(\Magento\Cms\Model\Template\Filter::class, [], [], '', false); - $this->_objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->_filterMock = $this->createMock(\Magento\Cms\Model\Template\Filter::class); + $this->_objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); $this->_objectManagerMock->expects($this->any())->method('get')->will($this->returnValue($this->_filterMock)); $this->_model = new \Magento\Cms\Model\Template\FilterProvider($this->_objectManagerMock); } @@ -62,8 +62,8 @@ public function testGetPageFilterInnerCache() */ public function testGetPageWrongInstance() { - $someClassMock = $this->getMock('SomeClass'); - $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $someClassMock = $this->createMock('SomeClass'); + $objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); $objectManagerMock->expects($this->once())->method('get')->will($this->returnValue($someClassMock)); $model = new \Magento\Cms\Model\Template\FilterProvider($objectManagerMock, 'SomeClass', 'SomeClass'); $model->getPageFilter(); diff --git a/app/code/Magento/Cms/Test/Unit/Model/Template/FilterTest.php b/app/code/Magento/Cms/Test/Unit/Model/Template/FilterTest.php index 78be79e852c72..009a740305a82 100644 --- a/app/code/Magento/Cms/Test/Unit/Model/Template/FilterTest.php +++ b/app/code/Magento/Cms/Test/Unit/Model/Template/FilterTest.php @@ -10,7 +10,7 @@ * * @covers \Magento\Cms\Model\Template\Filter */ -class FilterTest extends \PHPUnit_Framework_TestCase +class FilterTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/ConfigTest.php b/app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/ConfigTest.php index c3b3574757114..d633c5a21fe32 100644 --- a/app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/ConfigTest.php +++ b/app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/ConfigTest.php @@ -9,7 +9,7 @@ * @covers \Magento\Cms\Model\Wysiwyg\Config * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ConfigTest extends \PHPUnit_Framework_TestCase +class ConfigTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Cms\Model\Wysiwyg\Config @@ -73,7 +73,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->filesystemMock = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); + $this->filesystemMock = $this->createMock(\Magento\Framework\Filesystem::class); $this->backendUrlMock = $this->getMockBuilder(\Magento\Backend\Model\UrlInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -160,7 +160,7 @@ public function testGetConfig($data, $isAuthorizationAllowed, $expectedResults) ->method('getUri') ->willReturn('pub/static'); /** @var \Magento\Framework\View\Asset\ContextInterface|\PHPUnit_Framework_MockObject_MockObject $contextMock */ - $contextMock = $this->getMock(\Magento\Framework\View\Asset\ContextInterface::class); + $contextMock = $this->createMock(\Magento\Framework\View\Asset\ContextInterface::class); $contextMock->expects($this->once()) ->method('getBaseUrl') ->willReturn('localhost/pub/static/'); diff --git a/app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/Images/StorageTest.php b/app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/Images/StorageTest.php index 6bae4afa7342d..a2178489e1298 100644 --- a/app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/Images/StorageTest.php +++ b/app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/Images/StorageTest.php @@ -5,15 +5,15 @@ */ namespace Magento\Cms\Test\Unit\Model\Wysiwyg\Images; -use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Cms\Model\Wysiwyg\Images\Storage\Collection as StorageCollection; +use Magento\Framework\App\Filesystem\DirectoryList; /** * @SuppressWarnings(PHPMD.LongVariable) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.TooManyFields) */ -class StorageTest extends \PHPUnit_Framework_TestCase +class StorageTest extends \PHPUnit\Framework\TestCase { /** * Directory paths samples @@ -113,7 +113,7 @@ class StorageTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->filesystemMock = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); + $this->filesystemMock = $this->createMock(\Magento\Framework\Filesystem::class); $this->driverMock = $this->getMockForAbstractClass( \Magento\Framework\Filesystem\DriverInterface::class, [], @@ -125,12 +125,9 @@ protected function setUp() ); $this->driverMock->expects($this->any())->method('getRealPath')->will($this->returnArgument(0)); - $this->directoryMock = $this->getMock( + $this->directoryMock = $this->createPartialMock( \Magento\Framework\Filesystem\Directory\Write::class, - ['delete', 'getDriver', 'create'], - [], - '', - false + ['delete', 'getDriver', 'create'] ); $this->directoryMock->expects( $this->any() @@ -140,13 +137,7 @@ protected function setUp() $this->returnValue($this->driverMock) ); - $this->filesystemMock = $this->getMock( - \Magento\Framework\Filesystem::class, - ['getDirectoryWrite'], - [], - '', - false - ); + $this->filesystemMock = $this->createPartialMock(\Magento\Framework\Filesystem::class, ['getDirectoryWrite']); $this->filesystemMock->expects( $this->any() )->method( @@ -157,19 +148,10 @@ protected function setUp() $this->returnValue($this->directoryMock) ); - $this->adapterFactoryMock = $this->getMock( - \Magento\Framework\Image\AdapterFactory::class, - [], - [], - '', - false - ); - $this->imageHelperMock = $this->getMock( + $this->adapterFactoryMock = $this->createMock(\Magento\Framework\Image\AdapterFactory::class); + $this->imageHelperMock = $this->createPartialMock( \Magento\Cms\Helper\Wysiwyg\Images::class, - ['getStorageRoot'], - [], - '', - false + ['getStorageRoot'] ); $this->imageHelperMock->expects( $this->any() @@ -181,47 +163,27 @@ protected function setUp() $this->resizeParameters = ['width' => 100, 'height' => 50]; - $this->storageCollectionFactoryMock = $this->getMock( + $this->storageCollectionFactoryMock = $this->createPartialMock( \Magento\Cms\Model\Wysiwyg\Images\Storage\CollectionFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->storageFileFactoryMock = $this->getMock( - \Magento\MediaStorage\Model\File\Storage\FileFactory::class, - [], - [], - '', - false + $this->storageFileFactoryMock = $this->createMock(\Magento\MediaStorage\Model\File\Storage\FileFactory::class); + $this->storageDatabaseFactoryMock = $this->createMock( + \Magento\MediaStorage\Model\File\Storage\DatabaseFactory::class ); - $this->storageDatabaseFactoryMock = $this->getMock( - \Magento\MediaStorage\Model\File\Storage\DatabaseFactory::class, - [], - [], - '', - false - ); - $this->directoryDatabaseFactoryMock = $this->getMock( + $this->directoryDatabaseFactoryMock = $this->createPartialMock( \Magento\MediaStorage\Model\File\Storage\Directory\DatabaseFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->directoryCollectionMock = $this->getMock( - \Magento\MediaStorage\Model\File\Storage\Directory\Database::class, - [], - [], - '', - false + $this->directoryCollectionMock = $this->createMock( + \Magento\MediaStorage\Model\File\Storage\Directory\Database::class ); $this->uploaderFactoryMock = $this->getMockBuilder(\Magento\MediaStorage\Model\File\UploaderFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->sessionMock = $this->getMock(\Magento\Backend\Model\Session::class, [], [], '', false); - $this->backendUrlMock = $this->getMock(\Magento\Backend\Model\Url::class, [], [], '', false); + $this->sessionMock = $this->createMock(\Magento\Backend\Model\Session::class); + $this->backendUrlMock = $this->createMock(\Magento\Backend\Model\Url::class); $this->coreFileStorageMock = $this->getMockBuilder(\Magento\MediaStorage\Helper\File\Storage\Database::class) ->disableOriginalConstructor() @@ -238,7 +200,7 @@ protected function setUp() 'coreFileStorageDb' => $this->coreFileStorageMock, 'filesystem' => $this->filesystemMock, 'imageFactory' => $this->adapterFactoryMock, - 'assetRepo' => $this->getMock(\Magento\Framework\View\Asset\Repository::class, [], [], '', false), + 'assetRepo' => $this->createMock(\Magento\Framework\View\Asset\Repository::class), 'storageCollectionFactory' => $this->storageCollectionFactoryMock, 'storageFileFactory' => $this->storageFileFactoryMock, 'storageDatabaseFactory' => $this->storageDatabaseFactoryMock, @@ -274,7 +236,7 @@ public function testGetResizeHeight() */ public function testDeleteDirectoryOverRoot() { - $this->setExpectedException( + $this->expectException( \Magento\Framework\Exception\LocalizedException::class, sprintf('Directory %s is not under storage root path.', self::INVALID_DIRECTORY_OVER_ROOT) ); @@ -286,7 +248,7 @@ public function testDeleteDirectoryOverRoot() */ public function testDeleteRootDirectory() { - $this->setExpectedException( + $this->expectException( \Magento\Framework\Exception\LocalizedException::class, sprintf('We can\'t delete root directory %s right now.', self::STORAGE_ROOT_DIR) ); @@ -335,7 +297,7 @@ public function testGetDirsCollection($exclude, $include, $fileNames, $expectedR 'coreFileStorageDb' => $this->coreFileStorageMock, 'filesystem' => $this->filesystemMock, 'imageFactory' => $this->adapterFactoryMock, - 'assetRepo' => $this->getMock(\Magento\Framework\View\Asset\Repository::class, [], [], '', false), + 'assetRepo' => $this->createMock(\Magento\Framework\View\Asset\Repository::class), 'storageCollectionFactory' => $this->storageCollectionFactoryMock, 'storageFileFactory' => $this->storageFileFactoryMock, 'storageDatabaseFactory' => $this->storageDatabaseFactoryMock, @@ -352,7 +314,7 @@ public function testGetDirsCollection($exclude, $include, $fileNames, $expectedR $collection = []; foreach ($fileNames as $filename) { /** @var \Magento\Framework\DataObject|\PHPUnit_Framework_MockObject_MockObject $objectMock */ - $objectMock = $this->getMock(\Magento\Framework\DataObject::class, ['getFilename'], [], '', false); + $objectMock = $this->createPartialMock(\Magento\Framework\DataObject::class, ['getFilename']); $objectMock->expects($this->any()) ->method('getFilename') ->willReturn(self::STORAGE_ROOT_DIR . $filename); diff --git a/app/code/Magento/Cms/Test/Unit/Observer/NoCookiesObserverTest.php b/app/code/Magento/Cms/Test/Unit/Observer/NoCookiesObserverTest.php index b4901da998334..8c09d42ec556e 100644 --- a/app/code/Magento/Cms/Test/Unit/Observer/NoCookiesObserverTest.php +++ b/app/code/Magento/Cms/Test/Unit/Observer/NoCookiesObserverTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Cms\Test\Unit\Observer; -class NoCookiesObserverTest extends \PHPUnit_Framework_TestCase +class NoCookiesObserverTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Cms\Observer\NoCookiesObserver diff --git a/app/code/Magento/Cms/Test/Unit/Observer/NoRouteObserverTest.php b/app/code/Magento/Cms/Test/Unit/Observer/NoRouteObserverTest.php index 2ab43dbc30995..376bc6ec9d2bc 100644 --- a/app/code/Magento/Cms/Test/Unit/Observer/NoRouteObserverTest.php +++ b/app/code/Magento/Cms/Test/Unit/Observer/NoRouteObserverTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Cms\Test\Unit\Observer; -class NoRouteObserverTest extends \PHPUnit_Framework_TestCase +class NoRouteObserverTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Cms\Observer\NoRouteObserver diff --git a/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/BlockActionsTest.php b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/BlockActionsTest.php index e137270128c10..3dcf6c4a3fce0 100644 --- a/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/BlockActionsTest.php +++ b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/BlockActionsTest.php @@ -16,7 +16,7 @@ /** * BlockActionsTest contains unit tests for \Magento\Cms\Ui\Component\Listing\Column\BlockActions class */ -class BlockActionsTest extends \PHPUnit_Framework_TestCase +class BlockActionsTest extends \PHPUnit\Framework\TestCase { /** * @var BlockActions @@ -37,7 +37,7 @@ protected function setUp() { $objectManager = new ObjectManager($this); - $context = $this->getMock(ContextInterface::class); + $context = $this->createMock(ContextInterface::class); $processor = $this->getMockBuilder(Processor::class) ->disableOriginalConstructor() @@ -46,7 +46,7 @@ protected function setUp() ->method('getProcessor') ->willReturn($processor); - $this->urlBuilder = $this->getMock(UrlInterface::class); + $this->urlBuilder = $this->createMock(UrlInterface::class); $this->escaper = $this->getMockBuilder(Escaper::class) ->disableOriginalConstructor() diff --git a/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/Cms/OptionsTest.php b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/Cms/OptionsTest.php index 93f8358395eac..e681464349d57 100644 --- a/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/Cms/OptionsTest.php +++ b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/Cms/OptionsTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Cms\Test\Unit\Ui\Component\Listing\Column\Cms; -class OptionsTest extends \PHPUnit_Framework_TestCase +class OptionsTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Cms\Ui\Component\Listing\Column\Cms\Options @@ -45,19 +45,13 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); - $this->websiteMock = $this->getMock( - \Magento\Store\Model\Website::class, - ['getId', 'getName'], - [], - '', - false - ); + $this->websiteMock = $this->createPartialMock(\Magento\Store\Model\Website::class, ['getId', 'getName']); - $this->groupMock = $this->getMock(\Magento\Store\Model\Group::class, [], [], '', false); + $this->groupMock = $this->createMock(\Magento\Store\Model\Group::class); - $this->storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $this->storeMock = $this->createMock(\Magento\Store\Model\Store::class); - $this->escaperMock = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); + $this->escaperMock = $this->createMock(\Magento\Framework\Escaper::class); $this->options = $objectManager->getObject( \Magento\Cms\Ui\Component\Listing\Column\Cms\Options::class, diff --git a/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/PageActionsTest.php b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/PageActionsTest.php index af3b4de2e03db..b0cc1bf061a48 100644 --- a/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/PageActionsTest.php +++ b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/PageActionsTest.php @@ -8,7 +8,7 @@ use Magento\Cms\Ui\Component\Listing\Column\PageActions; use Magento\Framework\Escaper; -class PageActionsTest extends \PHPUnit_Framework_TestCase +class PageActionsTest extends \PHPUnit\Framework\TestCase { public function testPrepareItemsByPageId() { diff --git a/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/DataProviderTest.php b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/DataProviderTest.php index 40b248266f0f0..54e0e17ab7ad6 100644 --- a/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/DataProviderTest.php +++ b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/DataProviderTest.php @@ -14,7 +14,7 @@ use Magento\Framework\ObjectManagerInterface; use Magento\Framework\View\Element\UiComponent\DataProvider\Reporting; -class DataProviderTest extends \PHPUnit_Framework_TestCase +class DataProviderTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\Authorization|\PHPUnit_Framework_MockObject_MockObject @@ -84,7 +84,7 @@ public function setUp() ->getMock(); /** @var ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject $objectManagerMock */ - $objectManagerMock = $this->getMock(ObjectManagerInterface::class); + $objectManagerMock = $this->createMock(ObjectManagerInterface::class); $objectManagerMock->expects($this->once()) ->method('get') ->willReturn($this->authorizationMock); diff --git a/app/code/Magento/Cms/Ui/Component/DataProvider.php b/app/code/Magento/Cms/Ui/Component/DataProvider.php index a5093bd0261f4..f03c68875650e 100644 --- a/app/code/Magento/Cms/Ui/Component/DataProvider.php +++ b/app/code/Magento/Cms/Ui/Component/DataProvider.php @@ -57,7 +57,7 @@ public function __construct( } /** - * @deprecated + * @deprecated 101.1.0 * @return AuthorizationInterface|mixed */ private function getAuthorizationInstance() diff --git a/app/code/Magento/Cms/Ui/Component/Listing/Column/BlockActions.php b/app/code/Magento/Cms/Ui/Component/Listing/Column/BlockActions.php index 1ea35d4154687..9177171f479af 100644 --- a/app/code/Magento/Cms/Ui/Component/Listing/Column/BlockActions.php +++ b/app/code/Magento/Cms/Ui/Component/Listing/Column/BlockActions.php @@ -100,7 +100,7 @@ public function prepareDataSource(array $dataSource) /** * Get instance of escaper * @return Escaper - * @deprecated + * @deprecated 101.1.0 */ private function getEscaper() { diff --git a/app/code/Magento/Cms/Ui/Component/Listing/Column/PageActions.php b/app/code/Magento/Cms/Ui/Component/Listing/Column/PageActions.php index 50ddb465fd7a6..cb091001609aa 100644 --- a/app/code/Magento/Cms/Ui/Component/Listing/Column/PageActions.php +++ b/app/code/Magento/Cms/Ui/Component/Listing/Column/PageActions.php @@ -22,10 +22,14 @@ class PageActions extends Column const CMS_URL_PATH_EDIT = 'cms/page/edit'; const CMS_URL_PATH_DELETE = 'cms/page/delete'; - /** @var UrlBuilder */ + /** + * @var \Magento\Cms\Block\Adminhtml\Page\Grid\Renderer\Action\UrlBuilder + */ protected $actionUrlBuilder; - /** @var UrlInterface */ + /** + * @var \Magento\Framework\UrlInterface + */ protected $urlBuilder; /** @@ -107,7 +111,7 @@ public function prepareDataSource(array $dataSource) /** * Get instance of escaper * @return Escaper - * @deprecated + * @deprecated 101.1.0 */ private function getEscaper() { diff --git a/app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml b/app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml index 5943caa906087..9f886f6f1345e 100644 --- a/app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml +++ b/app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml @@ -31,6 +31,7 @@ + Magento_Cms::block id diff --git a/app/code/Magento/Cms/view/adminhtml/ui_component/cms_page_listing.xml b/app/code/Magento/Cms/view/adminhtml/ui_component/cms_page_listing.xml index ac66a4df2c560..846356adf9429 100644 --- a/app/code/Magento/Cms/view/adminhtml/ui_component/cms_page_listing.xml +++ b/app/code/Magento/Cms/view/adminhtml/ui_component/cms_page_listing.xml @@ -31,6 +31,7 @@ + Magento_Cms::page id diff --git a/app/code/Magento/CmsUrlRewrite/Model/CmsPageUrlPathGenerator.php b/app/code/Magento/CmsUrlRewrite/Model/CmsPageUrlPathGenerator.php index 825212d7b1c3b..72e424bb442ca 100644 --- a/app/code/Magento/CmsUrlRewrite/Model/CmsPageUrlPathGenerator.php +++ b/app/code/Magento/CmsUrlRewrite/Model/CmsPageUrlPathGenerator.php @@ -9,12 +9,17 @@ /** * @api + * @since 100.0.2 */ class CmsPageUrlPathGenerator { - /** @var \Magento\Framework\Filter\FilterManager */ + /** + * @var \Magento\Framework\Filter\FilterManager + */ protected $filterManager; + /** + */ public function __construct( \Magento\Framework\Filter\FilterManager $filterManager ) { diff --git a/app/code/Magento/CmsUrlRewrite/Model/CmsPageUrlRewriteGenerator.php b/app/code/Magento/CmsUrlRewrite/Model/CmsPageUrlRewriteGenerator.php index df4e26baff42e..ecb578961f2c8 100644 --- a/app/code/Magento/CmsUrlRewrite/Model/CmsPageUrlRewriteGenerator.php +++ b/app/code/Magento/CmsUrlRewrite/Model/CmsPageUrlRewriteGenerator.php @@ -15,10 +15,14 @@ class CmsPageUrlRewriteGenerator */ const ENTITY_TYPE = 'cms-page'; - /** @var \Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory */ + /** + * @var \Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory + */ protected $urlRewriteFactory; - /** @var \Magento\CmsUrlRewrite\Model\CmsPageUrlPathGenerator */ + /** + * @var \Magento\CmsUrlRewrite\Model\CmsPageUrlPathGenerator + */ protected $cmsPageUrlPathGenerator; /** diff --git a/app/code/Magento/CmsUrlRewrite/Test/Unit/Model/CmsPageUrlRewriteGeneratorTest.php b/app/code/Magento/CmsUrlRewrite/Test/Unit/Model/CmsPageUrlRewriteGeneratorTest.php index 58b6140b9a4d6..cb0a5906c02a5 100644 --- a/app/code/Magento/CmsUrlRewrite/Test/Unit/Model/CmsPageUrlRewriteGeneratorTest.php +++ b/app/code/Magento/CmsUrlRewrite/Test/Unit/Model/CmsPageUrlRewriteGeneratorTest.php @@ -5,7 +5,7 @@ */ namespace Magento\CmsUrlRewrite\Test\Unit\Model; -class CmsPageUrlRewriteGeneratorTest extends \PHPUnit_Framework_TestCase +class CmsPageUrlRewriteGeneratorTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager diff --git a/app/code/Magento/CmsUrlRewrite/Test/Unit/Observer/ProcessUrlRewriteSavingObserverTest.php b/app/code/Magento/CmsUrlRewrite/Test/Unit/Observer/ProcessUrlRewriteSavingObserverTest.php index c45ec029d367d..ba93d68648416 100644 --- a/app/code/Magento/CmsUrlRewrite/Test/Unit/Observer/ProcessUrlRewriteSavingObserverTest.php +++ b/app/code/Magento/CmsUrlRewrite/Test/Unit/Observer/ProcessUrlRewriteSavingObserverTest.php @@ -17,7 +17,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ProcessUrlRewriteSavingObserverTest extends \PHPUnit_Framework_TestCase +class ProcessUrlRewriteSavingObserverTest extends \PHPUnit\Framework\TestCase { /** * @var ObjectManagerHelper diff --git a/app/code/Magento/CmsUrlRewrite/Test/Unit/Plugin/Cms/Model/ResourceModel/PageTest.php b/app/code/Magento/CmsUrlRewrite/Test/Unit/Plugin/Cms/Model/ResourceModel/PageTest.php index b1e0097026209..8315b1ed75929 100644 --- a/app/code/Magento/CmsUrlRewrite/Test/Unit/Plugin/Cms/Model/ResourceModel/PageTest.php +++ b/app/code/Magento/CmsUrlRewrite/Test/Unit/Plugin/Cms/Model/ResourceModel/PageTest.php @@ -8,7 +8,7 @@ use Magento\UrlRewrite\Service\V1\Data\UrlRewrite; use Magento\CmsUrlRewrite\Model\CmsPageUrlRewriteGenerator; -class PageTest extends \PHPUnit_Framework_TestCase +class PageTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CmsUrlRewrite\Plugin\Cms\Model\ResourceModel\Page diff --git a/app/code/Magento/Config/App/Config/Source/DumpConfigSourceInterface.php b/app/code/Magento/Config/App/Config/Source/DumpConfigSourceInterface.php index 0ac26ab793afe..df205302286dd 100644 --- a/app/code/Magento/Config/App/Config/Source/DumpConfigSourceInterface.php +++ b/app/code/Magento/Config/App/Config/Source/DumpConfigSourceInterface.php @@ -10,6 +10,7 @@ /** * Interface DumpConfigSourceInterface * @api + * @since 100.1.2 */ interface DumpConfigSourceInterface extends ConfigSourceInterface { @@ -17,6 +18,7 @@ interface DumpConfigSourceInterface extends ConfigSourceInterface * Retrieves list of field paths were excluded from config dump * * @return array + * @since 100.1.2 */ public function getExcludedFields(); } diff --git a/app/code/Magento/Config/App/Config/Source/EnvironmentConfigSource.php b/app/code/Magento/Config/App/Config/Source/EnvironmentConfigSource.php index 11a6064bbcded..d2b87b1ae2841 100644 --- a/app/code/Magento/Config/App/Config/Source/EnvironmentConfigSource.php +++ b/app/code/Magento/Config/App/Config/Source/EnvironmentConfigSource.php @@ -15,6 +15,7 @@ * Class for retrieving configurations from environment variables. * * @api + * @since 100.2.0 */ class EnvironmentConfigSource implements ConfigSourceInterface { @@ -46,6 +47,7 @@ public function __construct( /** * @inheritdoc + * @since 100.2.0 */ public function get($path = '') { diff --git a/app/code/Magento/Config/App/Config/Source/InitialSnapshotConfigSource.php b/app/code/Magento/Config/App/Config/Source/InitialSnapshotConfigSource.php index cb52ead6ffef5..40978320797d4 100644 --- a/app/code/Magento/Config/App/Config/Source/InitialSnapshotConfigSource.php +++ b/app/code/Magento/Config/App/Config/Source/InitialSnapshotConfigSource.php @@ -12,6 +12,7 @@ /** * The source with previously imported configuration. * @api + * @since 100.2.0 */ class InitialSnapshotConfigSource implements ConfigSourceInterface { @@ -44,6 +45,7 @@ public function __construct(FlagManager $flagManager, DataObjectFactory $dataObj * Snapshots are stored in flags. * * {@inheritdoc} + * @since 100.2.0 */ public function get($path = '') { diff --git a/app/code/Magento/Config/App/Config/Source/ModularConfigSource.php b/app/code/Magento/Config/App/Config/Source/ModularConfigSource.php index 93f27d7fd0852..01cea0a8ee4e7 100644 --- a/app/code/Magento/Config/App/Config/Source/ModularConfigSource.php +++ b/app/code/Magento/Config/App/Config/Source/ModularConfigSource.php @@ -13,6 +13,7 @@ * Class for retrieving initial configuration from modules * * @api + * @since 100.1.2 */ class ModularConfigSource implements ConfigSourceInterface { @@ -34,6 +35,7 @@ public function __construct(Reader $reader) * * @param string $path Format is scope type and scope code separated by slash: e.g. "type/code" * @return array + * @since 100.1.2 */ public function get($path = '') { diff --git a/app/code/Magento/Config/App/Config/Source/RuntimeConfigSource.php b/app/code/Magento/Config/App/Config/Source/RuntimeConfigSource.php index ca6a4e0a7d0db..b33c944c73477 100644 --- a/app/code/Magento/Config/App/Config/Source/RuntimeConfigSource.php +++ b/app/code/Magento/Config/App/Config/Source/RuntimeConfigSource.php @@ -16,6 +16,7 @@ * Class for retrieving runtime configuration from database. * * @api + * @since 100.1.2 */ class RuntimeConfigSource implements ConfigSourceInterface { @@ -54,6 +55,7 @@ public function __construct( * * @param string $path Format is scope type and scope code separated by slash: e.g. "type/code" * @return array + * @since 100.1.2 */ public function get($path = '') { diff --git a/app/code/Magento/Config/App/Config/Type/System.php b/app/code/Magento/Config/App/Config/Type/System.php index f984c2d2a19eb..4f6d9c14346f0 100644 --- a/app/code/Magento/Config/App/Config/Type/System.php +++ b/app/code/Magento/Config/App/Config/Type/System.php @@ -12,6 +12,7 @@ /** * System configuration type * @api + * @since 100.1.2 */ class System implements ConfigTypeInterface { @@ -129,6 +130,7 @@ public function __construct( * '{scopeType}/{scopeCode}/some/config/variable' - will return value of the config variable in the specified scope * * @inheritdoc + * @since 100.1.2 */ public function get($path = '') { @@ -139,7 +141,7 @@ public function get($path = '') $pathParts = explode('/', $path); if (count($pathParts) === 1 && $pathParts[0] !== 'default') { if (!isset($this->data[$pathParts[0]])) { - $data = $this->reader->read(); + $data = $this->readData(); $this->data = array_replace_recursive($data, $this->data); } return $this->data[$pathParts[0]]; @@ -169,7 +171,7 @@ private function loadAllData() { $cachedData = $this->cache->load($this->configType); if ($cachedData === false) { - $data = $this->reader->read(); + $data = $this->readData(); } else { $data = $this->serializer->unserialize($cachedData); } @@ -186,7 +188,7 @@ private function loadDefaultScopeData($scopeType) { $cachedData = $this->cache->load($this->configType . '_' . $scopeType); if ($cachedData === false) { - $data = $this->reader->read(); + $data = $this->readData(); $this->cacheData($data); } else { $data = [$scopeType => $this->serializer->unserialize($cachedData)]; @@ -214,7 +216,7 @@ private function loadScopeData($scopeType, $scopeId) if (is_array($this->availableDataScopes) && !isset($this->availableDataScopes[$scopeType][$scopeId])) { return [$scopeType => [$scopeId => []]]; } - $data = $this->reader->read(); + $data = $this->readData(); $this->cacheData($data); } else { $data = [$scopeType => [$scopeId => $this->serializer->unserialize($cachedData)]]; @@ -280,6 +282,21 @@ private function getDataByPathParts($data, $pathParts) return $data; } + /** + * The freshly read data. + * + * @return array + */ + private function readData(): array + { + $this->data = $this->reader->read(); + $this->data = $this->postProcessor->process( + $this->data + ); + + return $this->data; + } + /** * Clean cache and global variables cache * @@ -288,6 +305,7 @@ private function getDataByPathParts($data, $pathParts) * - All records in cache storage tagged with CACHE_TAG * * @return void + * @since 100.1.2 */ public function clean() { diff --git a/app/code/Magento/Config/App/Config/Type/System/Reader.php b/app/code/Magento/Config/App/Config/Type/System/Reader.php index d5a0f09cdd631..9916b795a53b2 100644 --- a/app/code/Magento/Config/App/Config/Type/System/Reader.php +++ b/app/code/Magento/Config/App/Config/Type/System/Reader.php @@ -27,17 +27,13 @@ class Reader */ private $preProcessor; - /** - * @var \Magento\Framework\App\Config\Spi\PostProcessorInterface - */ - private $postProcessor; - /** * Reader constructor. * @param \Magento\Framework\App\Config\ConfigSourceInterface $source * @param \Magento\Store\Model\Config\Processor\Fallback $fallback * @param \Magento\Framework\App\Config\Spi\PreProcessorInterface $preProcessor * @param \Magento\Framework\App\Config\Spi\PostProcessorInterface $postProcessor + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function __construct( \Magento\Framework\App\Config\ConfigSourceInterface $source, @@ -48,7 +44,6 @@ public function __construct( $this->source = $source; $this->fallback = $fallback; $this->preProcessor = $preProcessor; - $this->postProcessor = $postProcessor; } /** @@ -60,11 +55,9 @@ public function __construct( */ public function read() { - return $this->postProcessor->process( - $this->fallback->process( - $this->preProcessor->process( - $this->source->get() - ) + return $this->fallback->process( + $this->preProcessor->process( + $this->source->get() ) ); } diff --git a/app/code/Magento/Config/Block/System/Config/Edit.php b/app/code/Magento/Config/Block/System/Config/Edit.php index 10b724781e1f7..23acfc1ec628c 100644 --- a/app/code/Magento/Config/Block/System/Config/Edit.php +++ b/app/code/Magento/Config/Block/System/Config/Edit.php @@ -14,6 +14,7 @@ /** * @api * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class Edit extends \Magento\Backend\Block\Widget { diff --git a/app/code/Magento/Config/Block/System/Config/Form.php b/app/code/Magento/Config/Block/System/Config/Form.php index 220affe2b441b..0a7f8fcca01a9 100644 --- a/app/code/Magento/Config/Block/System/Config/Form.php +++ b/app/code/Magento/Config/Block/System/Config/Form.php @@ -19,6 +19,7 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.DepthOfInheritance) * @api + * @since 100.0.2 */ class Form extends \Magento\Backend\Block\Widget\Form\Generic { @@ -157,7 +158,7 @@ public function __construct( } /** - * @deprecated + * @deprecated 100.1.2 * @return SettingChecker */ private function getSettingChecker() @@ -600,6 +601,7 @@ public function canUseWebsiteValue($fieldValue) * * @param int $fieldValue * @return bool + * @since 100.1.0 */ public function isCanRestoreToDefault($fieldValue) { @@ -785,7 +787,7 @@ protected function _getRequiresCssClass(\Magento\Config\Model\Config\Structure\E /** * Retrieve Deployment Configuration object. * - * @deprecated + * @deprecated 100.1.2 * @return DeploymentConfig */ private function getAppConfig() @@ -820,9 +822,10 @@ private function getAppConfigDataValue($path) * Gets instance of ElementVisibilityInterface. * * @return ElementVisibilityInterface - * @deprecated Added to not break backward compatibility of the constructor signature + * @deprecated 100.2.0 Added to not break backward compatibility of the constructor signature * by injecting the new dependency directly. * The method can be removed in a future major release, when constructor signature can be changed. + * @since 100.2.0 */ public function getElementVisibility() { diff --git a/app/code/Magento/Config/Block/System/Config/Form/Field.php b/app/code/Magento/Config/Block/System/Config/Form/Field.php index 9a77289f39768..37b9b1d656ba7 100644 --- a/app/code/Magento/Config/Block/System/Config/Form/Field.php +++ b/app/code/Magento/Config/Block/System/Config/Form/Field.php @@ -14,6 +14,7 @@ * @api * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.NumberOfChildren) + * @since 100.0.2 */ class Field extends \Magento\Backend\Block\Template implements \Magento\Framework\Data\Form\Element\Renderer\RendererInterface { diff --git a/app/code/Magento/Config/Block/System/Config/Form/Field/FieldArray/AbstractFieldArray.php b/app/code/Magento/Config/Block/System/Config/Form/Field/FieldArray/AbstractFieldArray.php index c0be9491c943d..a5cdd7b84f6dc 100644 --- a/app/code/Magento/Config/Block/System/Config/Form/Field/FieldArray/AbstractFieldArray.php +++ b/app/code/Magento/Config/Block/System/Config/Form/Field/FieldArray/AbstractFieldArray.php @@ -13,6 +13,7 @@ * * @author Magento Core Team * @api + * @since 100.0.2 */ abstract class AbstractFieldArray extends \Magento\Config\Block\System\Config\Form\Field { @@ -283,6 +284,7 @@ public function getColumns() /** * @return string + * @since 100.2.0 */ public function getAddButtonLabel() { diff --git a/app/code/Magento/Config/Block/System/Config/Form/Field/Heading.php b/app/code/Magento/Config/Block/System/Config/Form/Field/Heading.php index d0d25df28482a..e9a0562f9a95c 100644 --- a/app/code/Magento/Config/Block/System/Config/Form/Field/Heading.php +++ b/app/code/Magento/Config/Block/System/Config/Form/Field/Heading.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class Heading extends \Magento\Backend\Block\AbstractBlock implements \Magento\Framework\Data\Form\Element\Renderer\RendererInterface diff --git a/app/code/Magento/Config/Block/System/Config/Form/Field/Notification.php b/app/code/Magento/Config/Block/System/Config/Form/Field/Notification.php index ce7667ed1918d..7f21bf4b92bf4 100644 --- a/app/code/Magento/Config/Block/System/Config/Form/Field/Notification.php +++ b/app/code/Magento/Config/Block/System/Config/Form/Field/Notification.php @@ -11,6 +11,7 @@ /** * Backend system config datetime field renderer * @api + * @since 100.0.2 */ class Notification extends \Magento\Config\Block\System\Config\Form\Field { diff --git a/app/code/Magento/Config/Block/System/Config/Form/Field/Regexceptions.php b/app/code/Magento/Config/Block/System/Config/Form/Field/Regexceptions.php index ebf3d574ccbba..9b8940567daab 100644 --- a/app/code/Magento/Config/Block/System/Config/Form/Field/Regexceptions.php +++ b/app/code/Magento/Config/Block/System/Config/Form/Field/Regexceptions.php @@ -7,7 +7,7 @@ /** * Backend system config array field renderer - * @deprecated + * @deprecated 100.1.0 */ class Regexceptions extends \Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray { diff --git a/app/code/Magento/Config/Block/System/Config/Form/Fieldset.php b/app/code/Magento/Config/Block/System/Config/Form/Fieldset.php index c7df46edf8f29..05c98a3eba99d 100644 --- a/app/code/Magento/Config/Block/System/Config/Form/Fieldset.php +++ b/app/code/Magento/Config/Block/System/Config/Form/Fieldset.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class Fieldset extends \Magento\Backend\Block\AbstractBlock implements \Magento\Framework\Data\Form\Element\Renderer\RendererInterface @@ -72,6 +73,7 @@ public function render(AbstractElement $element) /** * @param AbstractElement $element * @return string + * @since 100.1.0 */ protected function _getChildrenElementsHtml(AbstractElement $element) { diff --git a/app/code/Magento/Config/Block/System/Config/Form/Fieldset/Modules/DisableOutput.php b/app/code/Magento/Config/Block/System/Config/Form/Fieldset/Modules/DisableOutput.php index d4c8132eb0fa5..99fa7b5addee8 100644 --- a/app/code/Magento/Config/Block/System/Config/Form/Fieldset/Modules/DisableOutput.php +++ b/app/code/Magento/Config/Block/System/Config/Form/Fieldset/Modules/DisableOutput.php @@ -10,32 +10,37 @@ * on the store settings page. * * @method \Magento\Config\Block\System\Config\Form getForm() - * @deprecated Magento does not support custom disabling/enabling module output since 2.2.0 version + * @deprecated 100.2.0 Magento does not support disabling/enabling modules output from the Admin Panel since 2.2.0 + * version. Module output can still be enabled/disabled in configuration files. However, this functionality should + * not be used in future development. Module design should explicitly state dependencies to avoid requiring output + * disabling. This functionality will temporarily be kept in Magento core, as there are unresolved modularity + * issues that will be addressed in future releases. * @api + * @since 100.0.2 */ class DisableOutput extends \Magento\Config\Block\System\Config\Form\Fieldset { /** * @var \Magento\Framework\DataObject - * @deprecated Magento does not support custom disabling/enabling module output since 2.2.0 version + * @deprecated 100.2.0 */ protected $_dummyElement; /** * @var \Magento\Config\Block\System\Config\Form\Field - * @deprecated Magento does not support custom disabling/enabling module output since 2.2.0 version + * @deprecated 100.2.0 */ protected $_fieldRenderer; /** * @var array - * @deprecated Magento does not support custom disabling/enabling module output since 2.2.0 version + * @deprecated 100.2.0 */ protected $_values; /** * @var \Magento\Framework\Module\ModuleListInterface - * @deprecated Magento does not support custom disabling/enabling module output since 2.2.0 version + * @deprecated 100.2.0 */ protected $_moduleList; @@ -59,7 +64,11 @@ public function __construct( /** * {@inheritdoc} - * @deprecated Magento does not support custom disabling/enabling module output since 2.2.0 version + * @deprecated 100.2.0 Magento does not support disabling/enabling modules output from the Admin Panel since 2.2.0 + * version. Module output can still be enabled/disabled in configuration files. However, this functionality should + * not be used in future development. Module design should explicitly state dependencies to avoid requiring output + * disabling. This functionality will temporarily be kept in Magento core, as there are unresolved modularity + * issues that will be addressed in future releases. */ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element) { @@ -88,7 +97,7 @@ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $ele } /** - * @deprecated Magento does not support custom disabling/enabling module output since 2.2.0 version + * @deprecated 100.2.0 * @return \Magento\Framework\DataObject */ protected function _getDummyElement() @@ -100,7 +109,7 @@ protected function _getDummyElement() } /** - * @deprecated Magento does not support custom disabling/enabling module output since 2.2.0 version + * @deprecated 100.2.0 * @return \Magento\Config\Block\System\Config\Form\Field */ protected function _getFieldRenderer() @@ -114,7 +123,7 @@ protected function _getFieldRenderer() } /** - * @deprecated Magento does not support custom disabling/enabling module output since 2.2.0 version + * @deprecated 100.2.0 * @return array */ protected function _getValues() @@ -131,7 +140,7 @@ protected function _getValues() /** * @param \Magento\Framework\Data\Form\Element\Fieldset $fieldset * @param string $moduleName - * @deprecated Magento does not support custom disabling/enabling module output since 2.2.0 version + * @deprecated 100.2.0 * @return mixed */ protected function _getFieldHtml($fieldset, $moduleName) diff --git a/app/code/Magento/Config/Block/System/Config/Tabs.php b/app/code/Magento/Config/Block/System/Config/Tabs.php index 05d80363e96bd..42e9b1940fb5f 100644 --- a/app/code/Magento/Config/Block/System/Config/Tabs.php +++ b/app/code/Magento/Config/Block/System/Config/Tabs.php @@ -16,6 +16,7 @@ /** * @api * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class Tabs extends \Magento\Backend\Block\Widget { diff --git a/app/code/Magento/Config/Console/Command/ConfigSet/ConfigSetProcessorFactory.php b/app/code/Magento/Config/Console/Command/ConfigSet/ConfigSetProcessorFactory.php index eb8a8e52881fd..e005747ea5ed5 100644 --- a/app/code/Magento/Config/Console/Command/ConfigSet/ConfigSetProcessorFactory.php +++ b/app/code/Magento/Config/Console/Command/ConfigSet/ConfigSetProcessorFactory.php @@ -16,6 +16,7 @@ * @see ConfigSetCommand * * @api + * @since 100.2.0 */ class ConfigSetProcessorFactory { @@ -29,9 +30,7 @@ class ConfigSetProcessorFactory const TYPE_LOCK = 'lock'; /**#@-*/ - /** - * @var ObjectManagerInterface - */ + /**#@-*/ private $objectManager; /** @@ -61,6 +60,7 @@ public function __construct( * @return ConfigSetProcessorInterface New processor instance * @throws ConfigurationMismatchException If processor type is not exists in processors array * or declared class has wrong implementation + * @since 100.2.0 */ public function create($processorName) { diff --git a/app/code/Magento/Config/Console/Command/ConfigSet/ConfigSetProcessorInterface.php b/app/code/Magento/Config/Console/Command/ConfigSet/ConfigSetProcessorInterface.php index 27d2a39c2539b..01aa03b188e62 100644 --- a/app/code/Magento/Config/Console/Command/ConfigSet/ConfigSetProcessorInterface.php +++ b/app/code/Magento/Config/Console/Command/ConfigSet/ConfigSetProcessorInterface.php @@ -14,6 +14,7 @@ * @see ConfigSetCommand * * @api + * @since 100.2.0 */ interface ConfigSetProcessorInterface { @@ -26,6 +27,7 @@ interface ConfigSetProcessorInterface * @param string $scopeCode The scope code * @return void * @throws CouldNotSaveException An exception on processing error + * @since 100.2.0 */ public function process($path, $value, $scope, $scopeCode); } diff --git a/app/code/Magento/Config/Console/Command/ConfigSet/DefaultProcessor.php b/app/code/Magento/Config/Console/Command/ConfigSet/DefaultProcessor.php index 9f2797667fc52..2f5c10037ef06 100644 --- a/app/code/Magento/Config/Console/Command/ConfigSet/DefaultProcessor.php +++ b/app/code/Magento/Config/Console/Command/ConfigSet/DefaultProcessor.php @@ -19,6 +19,7 @@ * * {@inheritdoc} * @api + * @since 100.2.0 */ class DefaultProcessor implements ConfigSetProcessorInterface { @@ -63,6 +64,7 @@ public function __construct( * Requires installed application. * * {@inheritdoc} + * @since 100.2.0 */ public function process($path, $value, $scope, $scopeCode) { diff --git a/app/code/Magento/Config/Console/Command/ConfigSet/ProcessorFacade.php b/app/code/Magento/Config/Console/Command/ConfigSet/ProcessorFacade.php index c94b33fa0422f..06a01c6686bfd 100644 --- a/app/code/Magento/Config/Console/Command/ConfigSet/ProcessorFacade.php +++ b/app/code/Magento/Config/Console/Command/ConfigSet/ProcessorFacade.php @@ -23,6 +23,7 @@ * @see ConfigSetCommand * * @api + * @since 100.2.0 */ class ProcessorFacade { @@ -99,6 +100,7 @@ public function __construct( * @throws ValidatorException If some validation is wrong * @throws CouldNotSaveException If cannot save config value * @throws ConfigurationMismatchException If processor can not be instantiated + * @since 100.2.0 */ public function process($path, $value, $scope, $scopeCode, $lock) { diff --git a/app/code/Magento/Config/Console/Command/ConfigSetCommand.php b/app/code/Magento/Config/Console/Command/ConfigSetCommand.php index 060dd3b3426e2..1df1b3c4bed14 100644 --- a/app/code/Magento/Config/Console/Command/ConfigSetCommand.php +++ b/app/code/Magento/Config/Console/Command/ConfigSetCommand.php @@ -22,6 +22,7 @@ * * @api * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.2.0 */ class ConfigSetCommand extends Command { @@ -35,11 +36,7 @@ class ConfigSetCommand extends Command const OPTION_LOCK = 'lock'; /**#@-*/ - /** - * Emulator adminhtml area for CLI command. - * - * @var EmulatedAdminhtmlAreaProcessor - */ + /**#@-*/ private $emulatedAreaProcessor; /** @@ -85,6 +82,7 @@ public function __construct( /** * @inheritdoc + * @since 100.2.0 */ protected function configure() { @@ -125,6 +123,7 @@ protected function configure() * Creates and run appropriate processor, depending on input options. * * {@inheritdoc} + * @since 100.2.0 */ protected function execute(InputInterface $input, OutputInterface $output) { diff --git a/app/code/Magento/Config/Console/Command/ConfigShow/ValueProcessor.php b/app/code/Magento/Config/Console/Command/ConfigShow/ValueProcessor.php index 84c1fa9525d18..582f87508089f 100644 --- a/app/code/Magento/Config/Console/Command/ConfigShow/ValueProcessor.php +++ b/app/code/Magento/Config/Console/Command/ConfigShow/ValueProcessor.php @@ -19,6 +19,7 @@ * Class processes values using backend model which declared in system.xml. * * @api + * @since 100.2.0 */ class ValueProcessor { @@ -82,6 +83,7 @@ public function __construct( * @param string $value The value to process * @param string $path The configuration path for getting backend model. E.g. scope_id/group_id/field_id * @return string processed value result + * @since 100.2.0 */ public function process($scope, $scopeCode, $value, $path) { diff --git a/app/code/Magento/Config/Console/Command/ConfigShowCommand.php b/app/code/Magento/Config/Console/Command/ConfigShowCommand.php index b880bcaaee3a5..2d3dabdb24e67 100644 --- a/app/code/Magento/Config/Console/Command/ConfigShowCommand.php +++ b/app/code/Magento/Config/Console/Command/ConfigShowCommand.php @@ -21,6 +21,7 @@ * Command provides possibility to show saved system configuration. * * @api + * @since 100.2.0 */ class ConfigShowCommand extends Command { @@ -32,11 +33,7 @@ class ConfigShowCommand extends Command const INPUT_ARGUMENT_PATH = 'path'; /**#@-*/ - /** - * Scope validator. - * - * @var ValidatorInterface - */ + /**#@-*/ private $scopeValidator; /** @@ -103,6 +100,7 @@ public function __construct( /** * @inheritdoc + * @since 100.2.0 */ protected function configure() { @@ -139,6 +137,7 @@ protected function configure() * or scope/scope-code doesn't pass validation. * * {@inheritdoc} + * @since 100.2.0 */ protected function execute(InputInterface $input, OutputInterface $output) { diff --git a/app/code/Magento/Config/Controller/Adminhtml/System/AbstractConfig.php b/app/code/Magento/Config/Controller/Adminhtml/System/AbstractConfig.php index 60f5dfac986ee..36e4603cba577 100644 --- a/app/code/Magento/Config/Controller/Adminhtml/System/AbstractConfig.php +++ b/app/code/Magento/Config/Controller/Adminhtml/System/AbstractConfig.php @@ -11,6 +11,7 @@ /** * System Configuration Abstract Controller * @api + * @since 100.0.2 */ abstract class AbstractConfig extends \Magento\Backend\App\AbstractAction { @@ -27,7 +28,7 @@ abstract class AbstractConfig extends \Magento\Backend\App\AbstractAction protected $_configStructure; /** - * @deprecated + * @deprecated 100.2.0 */ protected $_sectionChecker; @@ -109,6 +110,7 @@ protected function _saveState($configState = []) * @param array $configState * @return array * @SuppressWarnings(PHPMD.UnusedLocalVariable) + * @since 100.1.0 */ protected function sanitizeConfigState($configState) { diff --git a/app/code/Magento/Config/Controller/Adminhtml/System/Config/AbstractScopeConfig.php b/app/code/Magento/Config/Controller/Adminhtml/System/Config/AbstractScopeConfig.php index 258c74651c4d9..27f7217b50ba1 100644 --- a/app/code/Magento/Config/Controller/Adminhtml/System/Config/AbstractScopeConfig.php +++ b/app/code/Magento/Config/Controller/Adminhtml/System/Config/AbstractScopeConfig.php @@ -10,6 +10,7 @@ /** * @api + * @since 100.0.2 */ abstract class AbstractScopeConfig extends \Magento\Config\Controller\Adminhtml\System\AbstractConfig { diff --git a/app/code/Magento/Config/Controller/Adminhtml/System/ConfigSectionChecker.php b/app/code/Magento/Config/Controller/Adminhtml/System/ConfigSectionChecker.php index 6d555173c5cab..0af19b83a5a3f 100644 --- a/app/code/Magento/Config/Controller/Adminhtml/System/ConfigSectionChecker.php +++ b/app/code/Magento/Config/Controller/Adminhtml/System/ConfigSectionChecker.php @@ -9,7 +9,7 @@ use Magento\Framework\Exception\NotFoundException; /** - * @deprecated - unused class. + * @deprecated 100.2.0 - unused class. * @see \Magento\Config\Model\Config\Structure\Element\Section::isAllowed() */ class ConfigSectionChecker diff --git a/app/code/Magento/Config/Model/Config.php b/app/code/Magento/Config/Model/Config.php index 04db969efa5ff..bc1515aadb0ca 100644 --- a/app/code/Magento/Config/Model/Config.php +++ b/app/code/Magento/Config/Model/Config.php @@ -12,6 +12,7 @@ * @author Magento Core Team * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @api + * @since 100.0.2 */ class Config extends \Magento\Framework\DataObject { diff --git a/app/code/Magento/Config/Model/Config/Backend/Admin/Custom.php b/app/code/Magento/Config/Model/Config/Backend/Admin/Custom.php index 156e2b180cc5a..27a8485741877 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Admin/Custom.php +++ b/app/code/Magento/Config/Model/Config/Backend/Admin/Custom.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class Custom extends \Magento\Framework\App\Config\Value { @@ -53,7 +54,9 @@ class Custom extends \Magento\Framework\App\Config\Value const XML_PATH_CARRIERS = 'carriers'; const XML_PATH_PAYMENT = 'payment'; - /* @var \Magento\Framework\App\Config\Storage\WriterInterface */ + /** + * @var \Magento\Framework\App\Config\Storage\WriterInterface + */ protected $_configWriter; /** diff --git a/app/code/Magento/Config/Model/Config/Backend/Admin/Custompath.php b/app/code/Magento/Config/Model/Config/Backend/Admin/Custompath.php index c3e4761440d12..a335efc95d207 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Admin/Custompath.php +++ b/app/code/Magento/Config/Model/Config/Backend/Admin/Custompath.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class Custompath extends \Magento\Framework\App\Config\Value { diff --git a/app/code/Magento/Config/Model/Config/Backend/Admin/Password/Link/Expirationperiod.php b/app/code/Magento/Config/Model/Config/Backend/Admin/Password/Link/Expirationperiod.php index 10de98a200c47..615cb9de62d4b 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Admin/Password/Link/Expirationperiod.php +++ b/app/code/Magento/Config/Model/Config/Backend/Admin/Password/Link/Expirationperiod.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class Expirationperiod extends \Magento\Framework\App\Config\Value { diff --git a/app/code/Magento/Config/Model/Config/Backend/Admin/Robots.php b/app/code/Magento/Config/Model/Config/Backend/Admin/Robots.php index a98e76285ce08..7bbbafe826422 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Admin/Robots.php +++ b/app/code/Magento/Config/Model/Config/Backend/Admin/Robots.php @@ -13,7 +13,7 @@ use Magento\Framework\App\ObjectManager; /** - * @deprecated robots.txt file is no longer stored in filesystem. It generates as response on request. + * @deprecated 100.2.0 robots.txt file is no longer stored in filesystem. It generates as response on request. */ class Robots extends \Magento\Framework\App\Config\Value { diff --git a/app/code/Magento/Config/Model/Config/Backend/Admin/Usecustom.php b/app/code/Magento/Config/Model/Config/Backend/Admin/Usecustom.php index 7828c2af54897..9a483de6a695b 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Admin/Usecustom.php +++ b/app/code/Magento/Config/Model/Config/Backend/Admin/Usecustom.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class Usecustom extends \Magento\Framework\App\Config\Value { diff --git a/app/code/Magento/Config/Model/Config/Backend/Admin/Usesecretkey.php b/app/code/Magento/Config/Model/Config/Backend/Admin/Usesecretkey.php index 1e1154f3b39bb..6be646bb90a15 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Admin/Usesecretkey.php +++ b/app/code/Magento/Config/Model/Config/Backend/Admin/Usesecretkey.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class Usesecretkey extends \Magento\Framework\App\Config\Value { diff --git a/app/code/Magento/Config/Model/Config/Backend/Baseurl.php b/app/code/Magento/Config/Model/Config/Backend/Baseurl.php index 39c4620edb063..a218d2b0d07e6 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Baseurl.php +++ b/app/code/Magento/Config/Model/Config/Backend/Baseurl.php @@ -10,6 +10,7 @@ /** * @api + * @since 100.0.2 */ class Baseurl extends \Magento\Framework\App\Config\Value { @@ -230,7 +231,7 @@ public function afterSave() /** * Get URL Validator * - * @deprecated + * @deprecated 100.2.0 * @return UrlValidator */ private function getUrlValidator() diff --git a/app/code/Magento/Config/Model/Config/Backend/Cache.php b/app/code/Magento/Config/Model/Config/Backend/Cache.php index b85dd3dbb551a..71feb85e97736 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Cache.php +++ b/app/code/Magento/Config/Model/Config/Backend/Cache.php @@ -12,6 +12,7 @@ /** * @api + * @since 100.0.2 */ class Cache extends \Magento\Framework\App\Config\Value { diff --git a/app/code/Magento/Config/Model/Config/Backend/Currency/AbstractCurrency.php b/app/code/Magento/Config/Model/Config/Backend/Currency/AbstractCurrency.php index 5c2dfe97bce96..b86b86ad3bb8c 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Currency/AbstractCurrency.php +++ b/app/code/Magento/Config/Model/Config/Backend/Currency/AbstractCurrency.php @@ -15,6 +15,7 @@ /** * @api + * @since 100.0.2 */ abstract class AbstractCurrency extends \Magento\Framework\App\Config\Value { diff --git a/app/code/Magento/Config/Model/Config/Backend/Currency/Allow.php b/app/code/Magento/Config/Model/Config/Backend/Currency/Allow.php index e4472e81b7b69..7ff1d367c5e58 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Currency/Allow.php +++ b/app/code/Magento/Config/Model/Config/Backend/Currency/Allow.php @@ -12,6 +12,7 @@ /** * @api + * @since 100.0.2 */ class Allow extends AbstractCurrency { @@ -80,6 +81,7 @@ public function afterSave() /** * @inheritdoc + * @since 100.2.0 */ protected function _getAllowedCurrencies() { diff --git a/app/code/Magento/Config/Model/Config/Backend/Currency/Base.php b/app/code/Magento/Config/Model/Config/Backend/Currency/Base.php index 707c5af49290a..41ca67b04b22f 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Currency/Base.php +++ b/app/code/Magento/Config/Model/Config/Backend/Currency/Base.php @@ -12,10 +12,13 @@ /** * @api + * @since 100.0.2 */ class Base extends AbstractCurrency { - /** @var \Magento\Directory\Model\CurrencyFactory */ + /** + * @var \Magento\Directory\Model\CurrencyFactory + */ private $currencyFactory; /** diff --git a/app/code/Magento/Config/Model/Config/Backend/Currency/Cron.php b/app/code/Magento/Config/Model/Config/Backend/Currency/Cron.php index 01e1fc1c211d4..3f80e01802b8d 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Currency/Cron.php +++ b/app/code/Magento/Config/Model/Config/Backend/Currency/Cron.php @@ -11,12 +11,15 @@ /** * @api + * @since 100.0.2 */ class Cron extends \Magento\Framework\App\Config\Value { const CRON_STRING_PATH = 'crontab/default/jobs/currency_rates_update/schedule/cron_expr'; - /** @var \Magento\Framework\App\Config\ValueFactory */ + /** + * @var \Magento\Framework\App\Config\ValueFactory + */ protected $_configValueFactory; /** diff --git a/app/code/Magento/Config/Model/Config/Backend/Currency/DefaultCurrency.php b/app/code/Magento/Config/Model/Config/Backend/Currency/DefaultCurrency.php index 23a30ec63b696..3323b5d455f95 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Currency/DefaultCurrency.php +++ b/app/code/Magento/Config/Model/Config/Backend/Currency/DefaultCurrency.php @@ -12,6 +12,7 @@ /** * @api + * @since 100.0.2 */ class DefaultCurrency extends AbstractCurrency { diff --git a/app/code/Magento/Config/Model/Config/Backend/Datashare.php b/app/code/Magento/Config/Model/Config/Backend/Datashare.php index 4115a0201ff90..f571dc7a4158e 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Datashare.php +++ b/app/code/Magento/Config/Model/Config/Backend/Datashare.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class Datashare extends \Magento\Framework\App\Config\Value { diff --git a/app/code/Magento/Config/Model/Config/Backend/Design/Exception.php b/app/code/Magento/Config/Model/Config/Backend/Design/Exception.php index 4b2d8be9abf1f..524e932c35a93 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Design/Exception.php +++ b/app/code/Magento/Config/Model/Config/Backend/Design/Exception.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Exception extends \Magento\Config\Model\Config\Backend\Serialized\ArraySerialized { diff --git a/app/code/Magento/Config/Model/Config/Backend/Email/Address.php b/app/code/Magento/Config/Model/Config/Backend/Email/Address.php index 82860db2ce529..77fa787bcadc5 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Email/Address.php +++ b/app/code/Magento/Config/Model/Config/Backend/Email/Address.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class Address extends \Magento\Framework\App\Config\Value { @@ -23,7 +24,7 @@ class Address extends \Magento\Framework\App\Config\Value public function beforeSave() { $value = $this->getValue(); - if (!\Zend_Validate::is($value, 'EmailAddress')) { + if (!\Zend_Validate::is($value, \Magento\Framework\Validator\EmailAddress::class)) { throw new LocalizedException(__('Please correct the email address: "%1".', $value)); } return $this; diff --git a/app/code/Magento/Config/Model/Config/Backend/Email/Logo.php b/app/code/Magento/Config/Model/Config/Backend/Email/Logo.php index 0db4ddb8193ac..015bdfc7496e3 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Email/Logo.php +++ b/app/code/Magento/Config/Model/Config/Backend/Email/Logo.php @@ -12,7 +12,7 @@ namespace Magento\Config\Model\Config\Backend\Email; /** - * @deprecated + * @deprecated 100.1.5 */ class Logo extends \Magento\Config\Model\Config\Backend\Image { diff --git a/app/code/Magento/Config/Model/Config/Backend/Email/Sender.php b/app/code/Magento/Config/Model/Config/Backend/Email/Sender.php index d552b6b0e0f57..7350302606503 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Email/Sender.php +++ b/app/code/Magento/Config/Model/Config/Backend/Email/Sender.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class Sender extends \Magento\Framework\App\Config\Value { diff --git a/app/code/Magento/Config/Model/Config/Backend/Encrypted.php b/app/code/Magento/Config/Model/Config/Backend/Encrypted.php index 3ca980527dd91..fa5a12af51fcc 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Encrypted.php +++ b/app/code/Magento/Config/Model/Config/Backend/Encrypted.php @@ -12,6 +12,7 @@ /** * @api + * @since 100.0.2 */ class Encrypted extends \Magento\Framework\App\Config\Value implements \Magento\Framework\App\Config\Data\ProcessorInterface diff --git a/app/code/Magento/Config/Model/Config/Backend/File.php b/app/code/Magento/Config/Model/Config/Backend/File.php index 548239488efc7..03a8ff4ffe312 100644 --- a/app/code/Magento/Config/Model/Config/Backend/File.php +++ b/app/code/Magento/Config/Model/Config/Backend/File.php @@ -16,6 +16,7 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.ExcessiveParameterList) * @api + * @since 100.0.2 */ class File extends \Magento\Framework\App\Config\Value { @@ -122,6 +123,7 @@ public function beforeSave() * Receiving uploaded file data * * @return array + * @since 100.1.0 */ protected function getFileData() { @@ -210,6 +212,7 @@ protected function _getUploadDir() * * @param string $uploadDir * @return string + * @since 100.1.0 */ protected function getUploadDirPath($uploadDir) { diff --git a/app/code/Magento/Config/Model/Config/Backend/File/RequestData/RequestDataInterface.php b/app/code/Magento/Config/Model/Config/Backend/File/RequestData/RequestDataInterface.php index 9783ce29dd920..7e9fdaad1ee96 100644 --- a/app/code/Magento/Config/Model/Config/Backend/File/RequestData/RequestDataInterface.php +++ b/app/code/Magento/Config/Model/Config/Backend/File/RequestData/RequestDataInterface.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ interface RequestDataInterface { diff --git a/app/code/Magento/Config/Model/Config/Backend/Filename.php b/app/code/Magento/Config/Model/Config/Backend/Filename.php index f95039837fc0c..314d834c47fce 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Filename.php +++ b/app/code/Magento/Config/Model/Config/Backend/Filename.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Filename extends \Magento\Framework\App\Config\Value { diff --git a/app/code/Magento/Config/Model/Config/Backend/Image.php b/app/code/Magento/Config/Model/Config/Backend/Image.php index 90ec3dc0e7cf8..1f2778fb03cc5 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Image.php +++ b/app/code/Magento/Config/Model/Config/Backend/Image.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class Image extends File { diff --git a/app/code/Magento/Config/Model/Config/Backend/Image/Adapter.php b/app/code/Magento/Config/Model/Config/Backend/Image/Adapter.php index 9ae1e2332f2d4..ccebb8c76ece8 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Image/Adapter.php +++ b/app/code/Magento/Config/Model/Config/Backend/Image/Adapter.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class Adapter extends \Magento\Framework\App\Config\Value { diff --git a/app/code/Magento/Config/Model/Config/Backend/Image/Favicon.php b/app/code/Magento/Config/Model/Config/Backend/Image/Favicon.php index a8a5eb306d83f..7e06999b271de 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Image/Favicon.php +++ b/app/code/Magento/Config/Model/Config/Backend/Image/Favicon.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class Favicon extends \Magento\Config\Model\Config\Backend\Image { diff --git a/app/code/Magento/Config/Model/Config/Backend/Image/Logo.php b/app/code/Magento/Config/Model/Config/Backend/Image/Logo.php index cef7c484eeae2..70834b30822d6 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Image/Logo.php +++ b/app/code/Magento/Config/Model/Config/Backend/Image/Logo.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class Logo extends \Magento\Config\Model\Config\Backend\Image { diff --git a/app/code/Magento/Config/Model/Config/Backend/Image/Pdf.php b/app/code/Magento/Config/Model/Config/Backend/Image/Pdf.php index 82f599b9acfe6..44131fe8a7966 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Image/Pdf.php +++ b/app/code/Magento/Config/Model/Config/Backend/Image/Pdf.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class Pdf extends \Magento\Config\Model\Config\Backend\Image { diff --git a/app/code/Magento/Config/Model/Config/Backend/Locale.php b/app/code/Magento/Config/Model/Config/Backend/Locale.php index 30b30f1899a98..7675a0937eb44 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Locale.php +++ b/app/code/Magento/Config/Model/Config/Backend/Locale.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class Locale extends \Magento\Framework\App\Config\Value { diff --git a/app/code/Magento/Config/Model/Config/Backend/Locale/Timezone.php b/app/code/Magento/Config/Model/Config/Backend/Locale/Timezone.php index 533ede0117efb..4e8be3623f399 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Locale/Timezone.php +++ b/app/code/Magento/Config/Model/Config/Backend/Locale/Timezone.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class Timezone extends \Magento\Framework\App\Config\Value { diff --git a/app/code/Magento/Config/Model/Config/Backend/Log/Cron.php b/app/code/Magento/Config/Model/Config/Backend/Log/Cron.php index 952ac7bffab4e..3c36baf6f31f4 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Log/Cron.php +++ b/app/code/Magento/Config/Model/Config/Backend/Log/Cron.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class Cron extends \Magento\Framework\App\Config\Value { diff --git a/app/code/Magento/Config/Model/Config/Backend/Secure.php b/app/code/Magento/Config/Model/Config/Backend/Secure.php index 177f9cc94830a..4b4b692cce76f 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Secure.php +++ b/app/code/Magento/Config/Model/Config/Backend/Secure.php @@ -7,10 +7,13 @@ /** * @api + * @since 100.0.2 */ class Secure extends \Magento\Framework\App\Config\Value { - /** @var \Magento\Framework\View\Asset\MergeService */ + /** + * @var \Magento\Framework\View\Asset\MergeService + */ protected $_mergeService; /** diff --git a/app/code/Magento/Config/Model/Config/Backend/Serialized.php b/app/code/Magento/Config/Model/Config/Backend/Serialized.php index e5c6ded4f0e09..3d5713357c39c 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Serialized.php +++ b/app/code/Magento/Config/Model/Config/Backend/Serialized.php @@ -10,6 +10,7 @@ /** * @api + * @since 100.0.2 */ class Serialized extends \Magento\Framework\App\Config\Value { diff --git a/app/code/Magento/Config/Model/Config/Backend/Serialized/ArraySerialized.php b/app/code/Magento/Config/Model/Config/Backend/Serialized/ArraySerialized.php index 66a2cf77f368a..6961eeb528629 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Serialized/ArraySerialized.php +++ b/app/code/Magento/Config/Model/Config/Backend/Serialized/ArraySerialized.php @@ -12,6 +12,7 @@ /** * @api + * @since 100.0.2 */ class ArraySerialized extends \Magento\Config\Model\Config\Backend\Serialized { diff --git a/app/code/Magento/Config/Model/Config/Backend/Store.php b/app/code/Magento/Config/Model/Config/Backend/Store.php index 16a4d2b709e58..0dfb2374fec09 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Store.php +++ b/app/code/Magento/Config/Model/Config/Backend/Store.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class Store extends \Magento\Framework\App\Config\Value { diff --git a/app/code/Magento/Config/Model/Config/Backend/Translate.php b/app/code/Magento/Config/Model/Config/Backend/Translate.php index 91df75e0b694c..48e6cd4762d0b 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Translate.php +++ b/app/code/Magento/Config/Model/Config/Backend/Translate.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class Translate extends \Magento\Framework\App\Config\Value { diff --git a/app/code/Magento/Config/Model/Config/BackendClone/Factory.php b/app/code/Magento/Config/Model/Config/BackendClone/Factory.php index 1f4bd9c532f4f..58f5fb69e4af2 100644 --- a/app/code/Magento/Config/Model/Config/BackendClone/Factory.php +++ b/app/code/Magento/Config/Model/Config/BackendClone/Factory.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class Factory { diff --git a/app/code/Magento/Config/Model/Config/BackendFactory.php b/app/code/Magento/Config/Model/Config/BackendFactory.php index 3ed57ae65302c..eea2535db823f 100644 --- a/app/code/Magento/Config/Model/Config/BackendFactory.php +++ b/app/code/Magento/Config/Model/Config/BackendFactory.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class BackendFactory { diff --git a/app/code/Magento/Config/Model/Config/CommentFactory.php b/app/code/Magento/Config/Model/Config/CommentFactory.php index d4cb2f9f0de1b..86faa18770485 100644 --- a/app/code/Magento/Config/Model/Config/CommentFactory.php +++ b/app/code/Magento/Config/Model/Config/CommentFactory.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class CommentFactory { diff --git a/app/code/Magento/Config/Model/Config/CommentInterface.php b/app/code/Magento/Config/Model/Config/CommentInterface.php index 42dba3a07ee1b..285f0cae0e892 100644 --- a/app/code/Magento/Config/Model/Config/CommentInterface.php +++ b/app/code/Magento/Config/Model/Config/CommentInterface.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ interface CommentInterface { diff --git a/app/code/Magento/Config/Model/Config/Compiler/IncludeElement.php b/app/code/Magento/Config/Model/Config/Compiler/IncludeElement.php index 2adad8d7594bc..961931d6d28c1 100644 --- a/app/code/Magento/Config/Model/Config/Compiler/IncludeElement.php +++ b/app/code/Magento/Config/Model/Config/Compiler/IncludeElement.php @@ -16,6 +16,7 @@ /** * Class IncludeElement * @api + * @since 100.0.2 */ class IncludeElement implements ElementInterface { diff --git a/app/code/Magento/Config/Model/Config/Export/Comment.php b/app/code/Magento/Config/Model/Config/Export/Comment.php index 20c029fc41637..8ef7b94a50260 100644 --- a/app/code/Magento/Config/Model/Config/Export/Comment.php +++ b/app/code/Magento/Config/Model/Config/Export/Comment.php @@ -15,6 +15,7 @@ /** * Class Comment. Is used to retrieve comment for config dump file * @api + * @since 100.1.2 */ class Comment implements CommentInterface { @@ -57,6 +58,7 @@ public function __construct( * a list with descriptions of these fields will be added to the comments. * * @return string + * @since 100.1.2 */ public function get() { diff --git a/app/code/Magento/Config/Model/Config/Export/ExcludeList.php b/app/code/Magento/Config/Model/Config/Export/ExcludeList.php index 2716702acd38c..e556c42f66a99 100644 --- a/app/code/Magento/Config/Model/Config/Export/ExcludeList.php +++ b/app/code/Magento/Config/Model/Config/Export/ExcludeList.php @@ -8,7 +8,7 @@ /** * Class ExcludeList contains list of config fields which should be excluded from config export file. * - * @deprecated because in Magento since version 2.2.0 there are several + * @deprecated 100.2.0 because in Magento since version 2.2.0 there are several * types for configuration fields that require special processing. * @see \Magento\Config\Model\Config\TypePool */ @@ -32,7 +32,7 @@ public function __construct(array $configs = []) * * @param string $path * @return bool - * @deprecated + * @deprecated 100.2.0 */ public function isPresent($path) { @@ -43,7 +43,7 @@ public function isPresent($path) * Retrieves all excluded field paths for export * * @return array - * @deprecated + * @deprecated 100.2.0 */ public function get() { diff --git a/app/code/Magento/Config/Model/Config/Factory.php b/app/code/Magento/Config/Model/Config/Factory.php index b480c670c4919..efcccac2ae872 100644 --- a/app/code/Magento/Config/Model/Config/Factory.php +++ b/app/code/Magento/Config/Model/Config/Factory.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class Factory { diff --git a/app/code/Magento/Config/Model/Config/Importer.php b/app/code/Magento/Config/Model/Config/Importer.php index bcf3ea0e5d4fe..70ffdaec829b2 100644 --- a/app/code/Magento/Config/Model/Config/Importer.php +++ b/app/code/Magento/Config/Model/Config/Importer.php @@ -23,6 +23,7 @@ * {@inheritdoc} * @see \Magento\Deploy\Console\Command\App\ConfigImport\Importer * @api + * @since 100.2.0 */ class Importer implements ImporterInterface { @@ -102,6 +103,7 @@ public function __construct( * or current value is different from previously imported. * * {@inheritdoc} + * @since 100.2.0 */ public function import(array $data) { @@ -141,6 +143,7 @@ public function import(array $data) /** * @inheritdoc * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @since 100.2.0 */ public function getWarningMessages(array $data) { diff --git a/app/code/Magento/Config/Model/Config/Loader.php b/app/code/Magento/Config/Model/Config/Loader.php index 93dd79c0d7685..625c3cf2f41fe 100644 --- a/app/code/Magento/Config/Model/Config/Loader.php +++ b/app/code/Magento/Config/Model/Config/Loader.php @@ -14,6 +14,7 @@ * * @package Magento\Config\Model\Config * @api + * @since 100.0.2 */ class Loader { diff --git a/app/code/Magento/Config/Model/Config/Parser/Comment.php b/app/code/Magento/Config/Model/Config/Parser/Comment.php index 39304c836ff39..b46b2308f8df5 100644 --- a/app/code/Magento/Config/Model/Config/Parser/Comment.php +++ b/app/code/Magento/Config/Model/Config/Parser/Comment.php @@ -19,6 +19,7 @@ * It is used to parse config paths from * comment section in provided configuration file. * @api + * @since 100.2.0 */ class Comment implements CommentParserInterface { @@ -83,6 +84,7 @@ public function __construct( * @param string $fileName the basename of file * @return array * @throws FileSystemException + * @since 100.2.0 */ public function execute($fileName) { diff --git a/app/code/Magento/Config/Model/Config/PathValidator.php b/app/code/Magento/Config/Model/Config/PathValidator.php index 87ef9a88e55f4..c7edbf51b7d36 100644 --- a/app/code/Magento/Config/Model/Config/PathValidator.php +++ b/app/code/Magento/Config/Model/Config/PathValidator.php @@ -10,6 +10,7 @@ /** * Validates the config path by config structure schema. * @api + * @since 100.2.0 */ class PathValidator { @@ -34,6 +35,7 @@ public function __construct(Structure $structure) * @param string $path The config path * @return true The result of validation * @throws ValidatorException If provided path is not valid + * @since 100.2.0 */ public function validate($path) { diff --git a/app/code/Magento/Config/Model/Config/Processor/EnvironmentPlaceholder.php b/app/code/Magento/Config/Model/Config/Processor/EnvironmentPlaceholder.php index 2b2831998d15f..ef75d5c5dd62a 100644 --- a/app/code/Magento/Config/Model/Config/Processor/EnvironmentPlaceholder.php +++ b/app/code/Magento/Config/Model/Config/Processor/EnvironmentPlaceholder.php @@ -13,6 +13,7 @@ /** * Allows to extract configurations from environment variables. * @api + * @since 100.1.2 */ class EnvironmentPlaceholder implements PreProcessorInterface { @@ -49,6 +50,7 @@ public function __construct( * If environment variable is matching the desired rule - it's being used as value. * * {@inheritdoc} + * @since 100.1.2 */ public function process(array $config) { diff --git a/app/code/Magento/Config/Model/Config/Reader/Source/Deployed/DocumentRoot.php b/app/code/Magento/Config/Model/Config/Reader/Source/Deployed/DocumentRoot.php index 23aa0385f9d54..5f8dc3f7ab4a7 100644 --- a/app/code/Magento/Config/Model/Config/Reader/Source/Deployed/DocumentRoot.php +++ b/app/code/Magento/Config/Model/Config/Reader/Source/Deployed/DocumentRoot.php @@ -14,6 +14,7 @@ * Class DocumentRoot * @package Magento\Config\Model\Config\Reader\Source\Deployed * @api + * @since 100.2.0 */ class DocumentRoot { @@ -36,6 +37,7 @@ public function __construct(DeploymentConfig $config) * deployment configuration. * * @return string + * @since 100.2.0 */ public function getPath() { @@ -48,6 +50,7 @@ public function getPath() * likely be extended to control other areas). * * @return bool + * @since 100.2.0 */ public function isPub() { diff --git a/app/code/Magento/Config/Model/Config/Reader/Source/Deployed/SettingChecker.php b/app/code/Magento/Config/Model/Config/Reader/Source/Deployed/SettingChecker.php index 6b3a8c7c7cb1f..e3561261d17c7 100644 --- a/app/code/Magento/Config/Model/Config/Reader/Source/Deployed/SettingChecker.php +++ b/app/code/Magento/Config/Model/Config/Reader/Source/Deployed/SettingChecker.php @@ -15,6 +15,7 @@ /** * Class for checking settings that defined in config file * @api + * @since 100.1.2 */ class SettingChecker { @@ -55,6 +56,7 @@ public function __construct( * @param string $scope * @param string|null $scopeCode * @return boolean + * @since 100.1.2 */ public function isReadOnly($path, $scope, $scopeCode = null) { @@ -79,6 +81,7 @@ public function isReadOnly($path, $scope, $scopeCode = null) * @param string $scopeCode * @param string|null $scopeCode * @return string|null + * @since 100.1.2 */ public function getPlaceholderValue($path, $scope, $scopeCode = null) { @@ -90,6 +93,7 @@ public function getPlaceholderValue($path, $scope, $scopeCode = null) * * @param string $placeholder * @return string|null + * @since 100.1.2 */ public function getEnvValue($placeholder) { diff --git a/app/code/Magento/Config/Model/Config/SchemaLocator.php b/app/code/Magento/Config/Model/Config/SchemaLocator.php index 3d42dc01de81a..6546d64b3bf6f 100644 --- a/app/code/Magento/Config/Model/Config/SchemaLocator.php +++ b/app/code/Magento/Config/Model/Config/SchemaLocator.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class SchemaLocator implements \Magento\Framework\Config\SchemaLocatorInterface { diff --git a/app/code/Magento/Config/Model/Config/ScopeDefiner.php b/app/code/Magento/Config/Model/Config/ScopeDefiner.php index f5a07f181390a..4de37fe87b654 100644 --- a/app/code/Magento/Config/Model/Config/ScopeDefiner.php +++ b/app/code/Magento/Config/Model/Config/ScopeDefiner.php @@ -11,6 +11,7 @@ /** * System configuration scope * @api + * @since 100.0.2 */ class ScopeDefiner { diff --git a/app/code/Magento/Config/Model/Config/Source/Admin/Page.php b/app/code/Magento/Config/Model/Config/Source/Admin/Page.php index 9adc75e9fd43c..a4ede7e8d1468 100644 --- a/app/code/Magento/Config/Model/Config/Source/Admin/Page.php +++ b/app/code/Magento/Config/Model/Config/Source/Admin/Page.php @@ -9,6 +9,7 @@ /** * @api + * @since 100.0.2 */ class Page implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Config/Model/Config/Source/Date/Short.php b/app/code/Magento/Config/Model/Config/Source/Date/Short.php index f40e6655e788c..90ac0d3d5fb35 100644 --- a/app/code/Magento/Config/Model/Config/Source/Date/Short.php +++ b/app/code/Magento/Config/Model/Config/Source/Date/Short.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Short implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Config/Model/Config/Source/Design/Robots.php b/app/code/Magento/Config/Model/Config/Source/Design/Robots.php index 3e9bb0f2e5be0..415e3389b3b4f 100644 --- a/app/code/Magento/Config/Model/Config/Source/Design/Robots.php +++ b/app/code/Magento/Config/Model/Config/Source/Design/Robots.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Robots implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Config/Model/Config/Source/Dev/Dbautoup.php b/app/code/Magento/Config/Model/Config/Source/Dev/Dbautoup.php index 76acff87f127e..e1977c74d77fb 100644 --- a/app/code/Magento/Config/Model/Config/Source/Dev/Dbautoup.php +++ b/app/code/Magento/Config/Model/Config/Source/Dev/Dbautoup.php @@ -10,6 +10,7 @@ /** * @api + * @since 100.0.2 */ class Dbautoup implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Config/Model/Config/Source/Email/Identity.php b/app/code/Magento/Config/Model/Config/Source/Email/Identity.php index 582a41abe3d21..8cc7af6f619ac 100644 --- a/app/code/Magento/Config/Model/Config/Source/Email/Identity.php +++ b/app/code/Magento/Config/Model/Config/Source/Email/Identity.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Identity implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Config/Model/Config/Source/Email/Method.php b/app/code/Magento/Config/Model/Config/Source/Email/Method.php index 609724737a9b5..4ce575b64d21b 100644 --- a/app/code/Magento/Config/Model/Config/Source/Email/Method.php +++ b/app/code/Magento/Config/Model/Config/Source/Email/Method.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class Method implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Config/Model/Config/Source/Email/Smtpauth.php b/app/code/Magento/Config/Model/Config/Source/Email/Smtpauth.php index 6ec1b181cdebd..1742d16e79c2e 100644 --- a/app/code/Magento/Config/Model/Config/Source/Email/Smtpauth.php +++ b/app/code/Magento/Config/Model/Config/Source/Email/Smtpauth.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Smtpauth implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Config/Model/Config/Source/Email/Template.php b/app/code/Magento/Config/Model/Config/Source/Email/Template.php index 687c65f18c73b..04222733418d3 100644 --- a/app/code/Magento/Config/Model/Config/Source/Email/Template.php +++ b/app/code/Magento/Config/Model/Config/Source/Email/Template.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Template extends \Magento\Framework\DataObject implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Config/Model/Config/Source/Enabledisable.php b/app/code/Magento/Config/Model/Config/Source/Enabledisable.php index f9ce4e1b9bc89..c015f41a659d9 100644 --- a/app/code/Magento/Config/Model/Config/Source/Enabledisable.php +++ b/app/code/Magento/Config/Model/Config/Source/Enabledisable.php @@ -8,6 +8,7 @@ /** * Source model for element with enable and disable variants. * @api + * @since 100.0.2 */ class Enabledisable implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Config/Model/Config/Source/Image/Adapter.php b/app/code/Magento/Config/Model/Config/Source/Image/Adapter.php index 836a936131475..cfd86c9e75fe1 100644 --- a/app/code/Magento/Config/Model/Config/Source/Image/Adapter.php +++ b/app/code/Magento/Config/Model/Config/Source/Image/Adapter.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Adapter implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Config/Model/Config/Source/Locale.php b/app/code/Magento/Config/Model/Config/Source/Locale.php index 5137e4c75bd4c..62357aa159fe2 100644 --- a/app/code/Magento/Config/Model/Config/Source/Locale.php +++ b/app/code/Magento/Config/Model/Config/Source/Locale.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class Locale implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Config/Model/Config/Source/Locale/Country.php b/app/code/Magento/Config/Model/Config/Source/Locale/Country.php index 320151226e71a..0724352d11bd5 100644 --- a/app/code/Magento/Config/Model/Config/Source/Locale/Country.php +++ b/app/code/Magento/Config/Model/Config/Source/Locale/Country.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class Country implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Config/Model/Config/Source/Locale/Currency.php b/app/code/Magento/Config/Model/Config/Source/Locale/Currency.php index 9606c4b0fac1e..b3474674cf76d 100644 --- a/app/code/Magento/Config/Model/Config/Source/Locale/Currency.php +++ b/app/code/Magento/Config/Model/Config/Source/Locale/Currency.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class Currency implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Config/Model/Config/Source/Locale/Currency/All.php b/app/code/Magento/Config/Model/Config/Source/Locale/Currency/All.php index 811b6e999d39c..bac1064cc2d1e 100644 --- a/app/code/Magento/Config/Model/Config/Source/Locale/Currency/All.php +++ b/app/code/Magento/Config/Model/Config/Source/Locale/Currency/All.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class All implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Config/Model/Config/Source/Locale/Timezone.php b/app/code/Magento/Config/Model/Config/Source/Locale/Timezone.php index 2807fd4c05097..4813fd370e279 100644 --- a/app/code/Magento/Config/Model/Config/Source/Locale/Timezone.php +++ b/app/code/Magento/Config/Model/Config/Source/Locale/Timezone.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class Timezone implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Config/Model/Config/Source/Locale/Weekdaycodes.php b/app/code/Magento/Config/Model/Config/Source/Locale/Weekdaycodes.php index afe037d9da9f5..93375eaf1b67f 100644 --- a/app/code/Magento/Config/Model/Config/Source/Locale/Weekdaycodes.php +++ b/app/code/Magento/Config/Model/Config/Source/Locale/Weekdaycodes.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class Weekdaycodes implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Config/Model/Config/Source/Locale/Weekdays.php b/app/code/Magento/Config/Model/Config/Source/Locale/Weekdays.php index 13037bcbf1beb..7e4507336d899 100644 --- a/app/code/Magento/Config/Model/Config/Source/Locale/Weekdays.php +++ b/app/code/Magento/Config/Model/Config/Source/Locale/Weekdays.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class Weekdays implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Config/Model/Config/Source/Nooptreq.php b/app/code/Magento/Config/Model/Config/Source/Nooptreq.php index defa9a46a513d..03fe5ca2abccc 100644 --- a/app/code/Magento/Config/Model/Config/Source/Nooptreq.php +++ b/app/code/Magento/Config/Model/Config/Source/Nooptreq.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Nooptreq implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Config/Model/Config/Source/Reports/Scope.php b/app/code/Magento/Config/Model/Config/Source/Reports/Scope.php index 5922216ce06d4..f52a1cb5d3f6b 100644 --- a/app/code/Magento/Config/Model/Config/Source/Reports/Scope.php +++ b/app/code/Magento/Config/Model/Config/Source/Reports/Scope.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class Scope implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Config/Model/Config/Source/Store.php b/app/code/Magento/Config/Model/Config/Source/Store.php index 0c05e380f9279..7ba46677a08c7 100644 --- a/app/code/Magento/Config/Model/Config/Source/Store.php +++ b/app/code/Magento/Config/Model/Config/Source/Store.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Store implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Config/Model/Config/Source/Web/Protocol.php b/app/code/Magento/Config/Model/Config/Source/Web/Protocol.php index 3a41481f2cdbb..d42d78e6417c4 100644 --- a/app/code/Magento/Config/Model/Config/Source/Web/Protocol.php +++ b/app/code/Magento/Config/Model/Config/Source/Web/Protocol.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Protocol implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Config/Model/Config/Source/Web/Redirect.php b/app/code/Magento/Config/Model/Config/Source/Web/Redirect.php index 5d771eeb87974..100e9a12d15b6 100644 --- a/app/code/Magento/Config/Model/Config/Source/Web/Redirect.php +++ b/app/code/Magento/Config/Model/Config/Source/Web/Redirect.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Redirect implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Config/Model/Config/Source/Website.php b/app/code/Magento/Config/Model/Config/Source/Website.php index 9664dde93989f..40583d93187e2 100644 --- a/app/code/Magento/Config/Model/Config/Source/Website.php +++ b/app/code/Magento/Config/Model/Config/Source/Website.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Website implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Config/Model/Config/Source/Website/AdminOptionHash.php b/app/code/Magento/Config/Model/Config/Source/Website/AdminOptionHash.php index a0ff7861129ee..e342ae693ae0d 100644 --- a/app/code/Magento/Config/Model/Config/Source/Website/AdminOptionHash.php +++ b/app/code/Magento/Config/Model/Config/Source/Website/AdminOptionHash.php @@ -12,6 +12,7 @@ * * This class is needed until the layout file supports supplying arguments to an option model. * @api + * @since 100.0.2 */ class AdminOptionHash extends OptionHash { diff --git a/app/code/Magento/Config/Model/Config/Source/Website/OptionHash.php b/app/code/Magento/Config/Model/Config/Source/Website/OptionHash.php index 89bc20bfe6a7f..d9b2783cad84c 100644 --- a/app/code/Magento/Config/Model/Config/Source/Website/OptionHash.php +++ b/app/code/Magento/Config/Model/Config/Source/Website/OptionHash.php @@ -10,6 +10,7 @@ /** * @api + * @since 100.0.2 */ class OptionHash implements ArrayInterface { diff --git a/app/code/Magento/Config/Model/Config/Source/Yesno.php b/app/code/Magento/Config/Model/Config/Source/Yesno.php index 79797493aa308..bdc39ee3a6f20 100644 --- a/app/code/Magento/Config/Model/Config/Source/Yesno.php +++ b/app/code/Magento/Config/Model/Config/Source/Yesno.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Yesno implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Config/Model/Config/Source/Yesnocustom.php b/app/code/Magento/Config/Model/Config/Source/Yesnocustom.php index 5f40dd44def17..939d512f72f20 100644 --- a/app/code/Magento/Config/Model/Config/Source/Yesnocustom.php +++ b/app/code/Magento/Config/Model/Config/Source/Yesnocustom.php @@ -12,6 +12,7 @@ /** * @api + * @since 100.0.2 */ class Yesnocustom implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Config/Model/Config/SourceFactory.php b/app/code/Magento/Config/Model/Config/SourceFactory.php index b195648e5b331..52a136f697dc0 100644 --- a/app/code/Magento/Config/Model/Config/SourceFactory.php +++ b/app/code/Magento/Config/Model/Config/SourceFactory.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class SourceFactory { diff --git a/app/code/Magento/Config/Model/Config/Structure.php b/app/code/Magento/Config/Model/Config/Structure.php index 45179ab5959fc..5a6dbc8e31896 100644 --- a/app/code/Magento/Config/Model/Config/Structure.php +++ b/app/code/Magento/Config/Model/Config/Structure.php @@ -42,6 +42,7 @@ * - the configuration path section/group/field * * @api + * @since 100.0.2 */ class Structure implements \Magento\Config\Model\Config\Structure\SearchInterface { @@ -89,6 +90,7 @@ class Structure implements \Magento\Config\Model\Config\Structure\SearchInterfac * List of config sections * * @var array + * @since 100.1.0 */ protected $sectionList; @@ -151,6 +153,7 @@ public function getTabs() * * @return array * @SuppressWarnings(PHPMD.UnusedLocalVariable) + * @since 100.1.0 */ public function getSectionList() { @@ -182,6 +185,7 @@ public function getElement($path) * * @param string $path The configuration path * @return \Magento\Config\Model\Config\Structure\ElementInterface|null + * @since 100.2.0 */ public function getElementByConfigPath($path) { @@ -361,6 +365,7 @@ protected function _getGroupFieldPathsByAttribute(array $fields, $parentPath, $a * ``` * * @return array An array of config path to config structure path map + * @since 100.2.0 */ public function getFieldPaths() { diff --git a/app/code/Magento/Config/Model/Config/Structure/AbstractElement.php b/app/code/Magento/Config/Model/Config/Structure/AbstractElement.php index 12b4a2e352329..0f625ba9fff0e 100644 --- a/app/code/Magento/Config/Model/Config/Structure/AbstractElement.php +++ b/app/code/Magento/Config/Model/Config/Structure/AbstractElement.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ abstract class AbstractElement implements ElementInterface { @@ -221,9 +222,10 @@ public function getPath($fieldPrefix = '') * Get instance of ElementVisibilityInterface. * * @return ElementVisibilityInterface - * @deprecated Added to not break backward compatibility of the constructor signature + * @deprecated 100.2.0 Added to not break backward compatibility of the constructor signature * by injecting the new dependency directly. * The method can be removed in a future major release, when constructor signature can be changed. + * @since 100.2.0 */ public function getElementVisibility() { diff --git a/app/code/Magento/Config/Model/Config/Structure/AbstractMapper.php b/app/code/Magento/Config/Model/Config/Structure/AbstractMapper.php index e4f4838c82573..711a165dc5541 100644 --- a/app/code/Magento/Config/Model/Config/Structure/AbstractMapper.php +++ b/app/code/Magento/Config/Model/Config/Structure/AbstractMapper.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ abstract class AbstractMapper implements MapperInterface { diff --git a/app/code/Magento/Config/Model/Config/Structure/ConcealInProductionConfigList.php b/app/code/Magento/Config/Model/Config/Structure/ConcealInProductionConfigList.php index 6a8b20897c380..115a372e6150a 100644 --- a/app/code/Magento/Config/Model/Config/Structure/ConcealInProductionConfigList.php +++ b/app/code/Magento/Config/Model/Config/Structure/ConcealInProductionConfigList.php @@ -11,6 +11,7 @@ * Defines status of visibility of form elements on Stores > Settings > Configuration page * in Admin Panel in Production mode. * @api + * @since 100.2.0 */ class ConcealInProductionConfigList implements ElementVisibilityInterface { @@ -53,6 +54,7 @@ public function __construct(State $state, array $configs = []) /** * @inheritdoc + * @since 100.2.0 */ public function isHidden($path) { @@ -64,6 +66,7 @@ public function isHidden($path) /** * @inheritdoc + * @since 100.2.0 */ public function isDisabled($path) { diff --git a/app/code/Magento/Config/Model/Config/Structure/Converter.php b/app/code/Magento/Config/Model/Config/Structure/Converter.php index caf898a7c3e39..6dc8aba986162 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Converter.php +++ b/app/code/Magento/Config/Model/Config/Structure/Converter.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Converter implements \Magento\Framework\Config\ConverterInterface { diff --git a/app/code/Magento/Config/Model/Config/Structure/Data.php b/app/code/Magento/Config/Model/Config/Structure/Data.php index 3714d5128d2d0..6d197050dafc7 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Data.php +++ b/app/code/Magento/Config/Model/Config/Structure/Data.php @@ -10,6 +10,7 @@ /** * Provides configuration * @api + * @since 100.0.2 */ class Data extends \Magento\Framework\Config\Data\Scoped { diff --git a/app/code/Magento/Config/Model/Config/Structure/Element/AbstractComposite.php b/app/code/Magento/Config/Model/Config/Structure/Element/AbstractComposite.php index 197a8f2232f21..724772622c35b 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Element/AbstractComposite.php +++ b/app/code/Magento/Config/Model/Config/Structure/Element/AbstractComposite.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ abstract class AbstractComposite extends \Magento\Config\Model\Config\Structure\AbstractElement { diff --git a/app/code/Magento/Config/Model/Config/Structure/Element/Dependency/Field.php b/app/code/Magento/Config/Model/Config/Structure/Element/Dependency/Field.php index 74576411b089f..8f4d82eed51c5 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Element/Dependency/Field.php +++ b/app/code/Magento/Config/Model/Config/Structure/Element/Dependency/Field.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Field { diff --git a/app/code/Magento/Config/Model/Config/Structure/Element/Dependency/FieldFactory.php b/app/code/Magento/Config/Model/Config/Structure/Element/Dependency/FieldFactory.php index 8a227bace0ed1..a9ca19ffcc582 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Element/Dependency/FieldFactory.php +++ b/app/code/Magento/Config/Model/Config/Structure/Element/Dependency/FieldFactory.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class FieldFactory { diff --git a/app/code/Magento/Config/Model/Config/Structure/Element/Dependency/Mapper.php b/app/code/Magento/Config/Model/Config/Structure/Element/Dependency/Mapper.php index 676e74f6c9be9..9a931a12ab6a9 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Element/Dependency/Mapper.php +++ b/app/code/Magento/Config/Model/Config/Structure/Element/Dependency/Mapper.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Mapper { diff --git a/app/code/Magento/Config/Model/Config/Structure/Element/Field.php b/app/code/Magento/Config/Model/Config/Structure/Element/Field.php index ebb57a60f17e3..0a6a600b41dd4 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Element/Field.php +++ b/app/code/Magento/Config/Model/Config/Structure/Element/Field.php @@ -9,6 +9,7 @@ /** * @api + * @since 100.0.2 */ class Field extends \Magento\Config\Model\Config\Structure\AbstractElement { @@ -289,6 +290,7 @@ public function showInStore() * Check if the field can be restored to default * * @return bool + * @since 100.1.0 */ public function canRestore() { diff --git a/app/code/Magento/Config/Model/Config/Structure/Element/FlyweightFactory.php b/app/code/Magento/Config/Model/Config/Structure/Element/FlyweightFactory.php index cb8cdaaa0c60c..daf60cb62f98c 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Element/FlyweightFactory.php +++ b/app/code/Magento/Config/Model/Config/Structure/Element/FlyweightFactory.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class FlyweightFactory { diff --git a/app/code/Magento/Config/Model/Config/Structure/Element/Group.php b/app/code/Magento/Config/Model/Config/Structure/Element/Group.php index e6eaeeb9615f0..d277e24857659 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Element/Group.php +++ b/app/code/Magento/Config/Model/Config/Structure/Element/Group.php @@ -10,6 +10,7 @@ /** * @api + * @since 100.0.2 */ class Group extends AbstractComposite { diff --git a/app/code/Magento/Config/Model/Config/Structure/Element/Group/Proxy.php b/app/code/Magento/Config/Model/Config/Structure/Element/Group/Proxy.php index 499d91557e512..62d15b10897eb 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Element/Group/Proxy.php +++ b/app/code/Magento/Config/Model/Config/Structure/Element/Group/Proxy.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Proxy extends \Magento\Config\Model\Config\Structure\Element\Group implements \Magento\Framework\ObjectManager\NoninterceptableInterface diff --git a/app/code/Magento/Config/Model/Config/Structure/Element/Iterator.php b/app/code/Magento/Config/Model/Config/Structure/Element/Iterator.php index 2678c43be3c6d..fc5c8b769c88b 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Element/Iterator.php +++ b/app/code/Magento/Config/Model/Config/Structure/Element/Iterator.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Iterator implements \Iterator { diff --git a/app/code/Magento/Config/Model/Config/Structure/Element/Iterator/Field.php b/app/code/Magento/Config/Model/Config/Structure/Element/Iterator/Field.php index c5f6f8a20bc41..2886010f83448 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Element/Iterator/Field.php +++ b/app/code/Magento/Config/Model/Config/Structure/Element/Iterator/Field.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Field extends \Magento\Config\Model\Config\Structure\Element\Iterator { diff --git a/app/code/Magento/Config/Model/Config/Structure/Element/Iterator/Group.php b/app/code/Magento/Config/Model/Config/Structure/Element/Iterator/Group.php index c1b6f16ecdcf2..8828791a40fbe 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Element/Iterator/Group.php +++ b/app/code/Magento/Config/Model/Config/Structure/Element/Iterator/Group.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Group extends \Magento\Config\Model\Config\Structure\Element\Iterator { diff --git a/app/code/Magento/Config/Model/Config/Structure/Element/Iterator/Section.php b/app/code/Magento/Config/Model/Config/Structure/Element/Iterator/Section.php index 1cfd865a4c3f6..bad1152fe5da2 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Element/Iterator/Section.php +++ b/app/code/Magento/Config/Model/Config/Structure/Element/Iterator/Section.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Section extends \Magento\Config\Model\Config\Structure\Element\Iterator { diff --git a/app/code/Magento/Config/Model/Config/Structure/Element/Iterator/Tab.php b/app/code/Magento/Config/Model/Config/Structure/Element/Iterator/Tab.php index eb63e0622e205..9efc2f39d3c60 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Element/Iterator/Tab.php +++ b/app/code/Magento/Config/Model/Config/Structure/Element/Iterator/Tab.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Tab extends \Magento\Config\Model\Config\Structure\Element\Iterator { diff --git a/app/code/Magento/Config/Model/Config/Structure/Element/Section.php b/app/code/Magento/Config/Model/Config/Structure/Element/Section.php index 4f748c194374b..c3d927a1d6d1b 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Element/Section.php +++ b/app/code/Magento/Config/Model/Config/Structure/Element/Section.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Section extends AbstractComposite { diff --git a/app/code/Magento/Config/Model/Config/Structure/Element/Tab.php b/app/code/Magento/Config/Model/Config/Structure/Element/Tab.php index a6a745a61573f..6655ffa76614f 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Element/Tab.php +++ b/app/code/Magento/Config/Model/Config/Structure/Element/Tab.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Tab extends AbstractComposite { diff --git a/app/code/Magento/Config/Model/Config/Structure/ElementInterface.php b/app/code/Magento/Config/Model/Config/Structure/ElementInterface.php index dc03fd2a6ed09..ca3548ac39fdb 100644 --- a/app/code/Magento/Config/Model/Config/Structure/ElementInterface.php +++ b/app/code/Magento/Config/Model/Config/Structure/ElementInterface.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ interface ElementInterface { diff --git a/app/code/Magento/Config/Model/Config/Structure/ElementVisibilityComposite.php b/app/code/Magento/Config/Model/Config/Structure/ElementVisibilityComposite.php index 905ceede25e8b..23074297e6323 100644 --- a/app/code/Magento/Config/Model/Config/Structure/ElementVisibilityComposite.php +++ b/app/code/Magento/Config/Model/Config/Structure/ElementVisibilityComposite.php @@ -11,6 +11,7 @@ * Contains list of classes which implement ElementVisibilityInterface for * checking of visibility of form elements on Stores > Settings > Configuration page in Admin Panel. * @api + * @since 100.2.0 */ class ElementVisibilityComposite implements ElementVisibilityInterface { @@ -48,6 +49,7 @@ public function __construct(array $visibility = []) /** * @inheritdoc + * @since 100.2.0 */ public function isHidden($path) { @@ -62,6 +64,7 @@ public function isHidden($path) /** * @inheritdoc + * @since 100.2.0 */ public function isDisabled($path) { diff --git a/app/code/Magento/Config/Model/Config/Structure/ElementVisibilityInterface.php b/app/code/Magento/Config/Model/Config/Structure/ElementVisibilityInterface.php index ad58bf27b53ea..21dff52843765 100644 --- a/app/code/Magento/Config/Model/Config/Structure/ElementVisibilityInterface.php +++ b/app/code/Magento/Config/Model/Config/Structure/ElementVisibilityInterface.php @@ -9,6 +9,7 @@ * Checks visibility status of form elements on Stores > Settings > Configuration page in Admin Panel * by their paths in the system.xml structure. * @api + * @since 100.2.0 */ interface ElementVisibilityInterface { @@ -24,6 +25,7 @@ interface ElementVisibilityInterface * * @param string $path The path of form element in the system.xml structure * @return bool + * @since 100.2.0 */ public function isDisabled($path); @@ -32,6 +34,7 @@ public function isDisabled($path); * * @param string $path The path of form element in the system.xml structure * @return bool + * @since 100.2.0 */ public function isHidden($path); } diff --git a/app/code/Magento/Config/Model/Config/Structure/Mapper/Attribute/Inheritance.php b/app/code/Magento/Config/Model/Config/Structure/Mapper/Attribute/Inheritance.php index 6a44b0fc8984e..8189245caeee4 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Mapper/Attribute/Inheritance.php +++ b/app/code/Magento/Config/Model/Config/Structure/Mapper/Attribute/Inheritance.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class Inheritance implements \Magento\Config\Model\Config\Structure\MapperInterface { diff --git a/app/code/Magento/Config/Model/Config/Structure/Mapper/Dependencies.php b/app/code/Magento/Config/Model/Config/Structure/Mapper/Dependencies.php index 5c2f5059885b9..01f9df17e7134 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Mapper/Dependencies.php +++ b/app/code/Magento/Config/Model/Config/Structure/Mapper/Dependencies.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class Dependencies extends \Magento\Config\Model\Config\Structure\AbstractMapper { diff --git a/app/code/Magento/Config/Model/Config/Structure/Mapper/ExtendsMapper.php b/app/code/Magento/Config/Model/Config/Structure/Mapper/ExtendsMapper.php index 8851891cb3103..7708a8904de79 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Mapper/ExtendsMapper.php +++ b/app/code/Magento/Config/Model/Config/Structure/Mapper/ExtendsMapper.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class ExtendsMapper extends \Magento\Config\Model\Config\Structure\AbstractMapper { diff --git a/app/code/Magento/Config/Model/Config/Structure/Mapper/Factory.php b/app/code/Magento/Config/Model/Config/Structure/Mapper/Factory.php index 9707b9870289b..e678d2126347f 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Mapper/Factory.php +++ b/app/code/Magento/Config/Model/Config/Structure/Mapper/Factory.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class Factory { diff --git a/app/code/Magento/Config/Model/Config/Structure/Mapper/Helper/RelativePathConverter.php b/app/code/Magento/Config/Model/Config/Structure/Mapper/Helper/RelativePathConverter.php index 324fbb0dce244..63cf315ef2db7 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Mapper/Helper/RelativePathConverter.php +++ b/app/code/Magento/Config/Model/Config/Structure/Mapper/Helper/RelativePathConverter.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class RelativePathConverter { diff --git a/app/code/Magento/Config/Model/Config/Structure/Mapper/Ignore.php b/app/code/Magento/Config/Model/Config/Structure/Mapper/Ignore.php index 7399b00a9f97b..57ecf83e2546d 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Mapper/Ignore.php +++ b/app/code/Magento/Config/Model/Config/Structure/Mapper/Ignore.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class Ignore implements \Magento\Config\Model\Config\Structure\MapperInterface { diff --git a/app/code/Magento/Config/Model/Config/Structure/Mapper/Path.php b/app/code/Magento/Config/Model/Config/Structure/Mapper/Path.php index b200849769467..13a70a1553359 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Mapper/Path.php +++ b/app/code/Magento/Config/Model/Config/Structure/Mapper/Path.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class Path extends \Magento\Config\Model\Config\Structure\AbstractMapper { diff --git a/app/code/Magento/Config/Model/Config/Structure/Mapper/Sorting.php b/app/code/Magento/Config/Model/Config/Structure/Mapper/Sorting.php index e6085b416e041..f6f3a0be187a3 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Mapper/Sorting.php +++ b/app/code/Magento/Config/Model/Config/Structure/Mapper/Sorting.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class Sorting extends \Magento\Config\Model\Config\Structure\AbstractMapper { diff --git a/app/code/Magento/Config/Model/Config/Structure/MapperInterface.php b/app/code/Magento/Config/Model/Config/Structure/MapperInterface.php index d72fe18738477..7c3486a152b14 100644 --- a/app/code/Magento/Config/Model/Config/Structure/MapperInterface.php +++ b/app/code/Magento/Config/Model/Config/Structure/MapperInterface.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ interface MapperInterface { diff --git a/app/code/Magento/Config/Model/Config/Structure/Reader.php b/app/code/Magento/Config/Model/Config/Structure/Reader.php index a271da897336a..5916649588bcb 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Reader.php +++ b/app/code/Magento/Config/Model/Config/Structure/Reader.php @@ -15,6 +15,7 @@ /** * Class Reader * @api + * @since 100.0.2 */ class Reader extends \Magento\Framework\Config\Reader\Filesystem { diff --git a/app/code/Magento/Config/Model/Config/Structure/Search/Proxy.php b/app/code/Magento/Config/Model/Config/Structure/Search/Proxy.php index 9c8a4f704a234..8db890b5577b3 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Search/Proxy.php +++ b/app/code/Magento/Config/Model/Config/Structure/Search/Proxy.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Proxy implements \Magento\Config\Model\Config\Structure\SearchInterface, diff --git a/app/code/Magento/Config/Model/Config/Structure/SearchInterface.php b/app/code/Magento/Config/Model/Config/Structure/SearchInterface.php index 36f2fa601e229..174750249f2ab 100644 --- a/app/code/Magento/Config/Model/Config/Structure/SearchInterface.php +++ b/app/code/Magento/Config/Model/Config/Structure/SearchInterface.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ interface SearchInterface { diff --git a/app/code/Magento/Config/Model/Config/TypePool.php b/app/code/Magento/Config/Model/Config/TypePool.php index 453d4484b477c..e41ff8e88a595 100644 --- a/app/code/Magento/Config/Model/Config/TypePool.php +++ b/app/code/Magento/Config/Model/Config/TypePool.php @@ -13,6 +13,7 @@ * Used when you need to know if the configuration path belongs to a certain type. * Participates in the mechanism for creating the configuration dump file. * @api + * @since 100.2.0 */ class TypePool { @@ -51,7 +52,7 @@ class TypePool * Checks if the configuration path is contained in exclude list. * * @var ExcludeList - * @deprecated We use it only to support backward compatibility. If some configurations + * @deprecated 100.2.0 We use it only to support backward compatibility. If some configurations * were set to this list before, we need to read them. * It will be supported for next 2 minor releases or until a major release. * TypePool should be used to mark configurations with types. @@ -82,6 +83,7 @@ public function __construct(array $sensitive = [], array $environment = [], Excl * @param string $path Configuration field path. For example, 'contact/email/recipient_email' * @param string $type Type of configuration fields * @return bool True when the path belongs to requested type, false otherwise + * @since 100.2.0 */ public function isPresent($path, $type) { diff --git a/app/code/Magento/Config/Model/Placeholder/Environment.php b/app/code/Magento/Config/Model/Placeholder/Environment.php index 6b2789abfd48d..74e9b8820d4de 100644 --- a/app/code/Magento/Config/Model/Placeholder/Environment.php +++ b/app/code/Magento/Config/Model/Placeholder/Environment.php @@ -11,6 +11,7 @@ /** * Class is used to work with placeholders for environment variables names based on config paths * @api + * @since 100.1.2 */ class Environment implements PlaceholderInterface { @@ -36,6 +37,7 @@ public function __construct(DeploymentConfig $deploymentConfig) * Generates placeholder like CONFIG__DEFAULT__TEST__TEST_VALUE * * @inheritdoc + * @since 100.1.2 */ public function generate($path, $scopeType = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeCode = null) { @@ -57,6 +59,7 @@ public function generate($path, $scopeType = ScopeConfigInterface::SCOPE_TYPE_DE /** * @inheritdoc + * @since 100.1.2 */ public function restore($template) { @@ -69,6 +72,7 @@ public function restore($template) /** * @inheritdoc + * @since 100.1.2 */ public function isApplicable($placeholder) { diff --git a/app/code/Magento/Config/Model/Placeholder/PlaceholderFactory.php b/app/code/Magento/Config/Model/Placeholder/PlaceholderFactory.php index e88e77b54a476..13453dfead139 100644 --- a/app/code/Magento/Config/Model/Placeholder/PlaceholderFactory.php +++ b/app/code/Magento/Config/Model/Placeholder/PlaceholderFactory.php @@ -10,6 +10,7 @@ /** * @api + * @since 100.1.2 */ class PlaceholderFactory { @@ -44,6 +45,7 @@ public function __construct(ObjectManagerInterface $objectManager, array $types * @param string $type * @return PlaceholderInterface * @throws LocalizedException + * @since 100.1.2 */ public function create($type) { diff --git a/app/code/Magento/Config/Model/Placeholder/PlaceholderInterface.php b/app/code/Magento/Config/Model/Placeholder/PlaceholderInterface.php index 26da345510b29..e56aa1f0427b9 100644 --- a/app/code/Magento/Config/Model/Placeholder/PlaceholderInterface.php +++ b/app/code/Magento/Config/Model/Placeholder/PlaceholderInterface.php @@ -10,6 +10,7 @@ /** * Interface PlaceholderInterface * @api + * @since 100.1.2 */ interface PlaceholderInterface { @@ -20,6 +21,7 @@ interface PlaceholderInterface * @param string $scopeType * @param string $scopeCode * @return string + * @since 100.1.2 */ public function generate($path, $scopeType = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeCode = null); @@ -28,6 +30,7 @@ public function generate($path, $scopeType = ScopeConfigInterface::SCOPE_TYPE_DE * * @param string $template * @return string + * @since 100.1.2 */ public function restore($template); @@ -36,6 +39,7 @@ public function restore($template); * * @param string $placeholder * @return bool + * @since 100.1.2 */ public function isApplicable($placeholder); } diff --git a/app/code/Magento/Config/Model/PreparedValueFactory.php b/app/code/Magento/Config/Model/PreparedValueFactory.php index 6775287aecc8a..19d607ad3dc1a 100644 --- a/app/code/Magento/Config/Model/PreparedValueFactory.php +++ b/app/code/Magento/Config/Model/PreparedValueFactory.php @@ -21,6 +21,7 @@ * * @see ValueInterface * @api + * @since 100.2.0 */ class PreparedValueFactory { @@ -91,6 +92,7 @@ public function __construct( * @return ValueInterface * @throws RuntimeException If Value can not be created * @see ValueInterface + * @since 100.2.0 */ public function create($path, $value, $scope, $scopeCode = null) { diff --git a/app/code/Magento/Config/Model/ResourceModel/Config.php b/app/code/Magento/Config/Model/ResourceModel/Config.php index 9a534fc2260bc..d8ea2410ce860 100644 --- a/app/code/Magento/Config/Model/ResourceModel/Config.php +++ b/app/code/Magento/Config/Model/ResourceModel/Config.php @@ -10,6 +10,7 @@ * * @author Magento Core Team * @api + * @since 100.0.2 */ class Config extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb implements \Magento\Framework\App\Config\ConfigResource\ConfigInterface diff --git a/app/code/Magento/Config/Model/ResourceModel/Config/Data.php b/app/code/Magento/Config/Model/ResourceModel/Config/Data.php index b19c3d4529904..c15966e01c0e8 100644 --- a/app/code/Magento/Config/Model/ResourceModel/Config/Data.php +++ b/app/code/Magento/Config/Model/ResourceModel/Config/Data.php @@ -10,6 +10,7 @@ * * @author Magento Core Team * @api + * @since 100.0.2 */ class Data extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { diff --git a/app/code/Magento/Config/Model/ResourceModel/Config/Data/Collection.php b/app/code/Magento/Config/Model/ResourceModel/Config/Data/Collection.php index a57b520ddb896..4c92a380df8bb 100644 --- a/app/code/Magento/Config/Model/ResourceModel/Config/Data/Collection.php +++ b/app/code/Magento/Config/Model/ResourceModel/Config/Data/Collection.php @@ -10,6 +10,7 @@ * * @author Magento Core Team * @api + * @since 100.0.2 */ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { diff --git a/app/code/Magento/Config/Test/Unit/App/Config/Source/DumpConfigSourceAggregatedTest.php b/app/code/Magento/Config/Test/Unit/App/Config/Source/DumpConfigSourceAggregatedTest.php index 5578066b724c6..c2c117f7e014c 100644 --- a/app/code/Magento/Config/Test/Unit/App/Config/Source/DumpConfigSourceAggregatedTest.php +++ b/app/code/Magento/Config/Test/Unit/App/Config/Source/DumpConfigSourceAggregatedTest.php @@ -12,7 +12,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; use PHPUnit_Framework_MockObject_MockObject as MockObject; -class DumpConfigSourceAggregatedTest extends \PHPUnit_Framework_TestCase +class DumpConfigSourceAggregatedTest extends \PHPUnit\Framework\TestCase { /** * @var ConfigSourceInterface|MockObject diff --git a/app/code/Magento/Config/Test/Unit/App/Config/Source/EnvironmentConfigSourceTest.php b/app/code/Magento/Config/Test/Unit/App/Config/Source/EnvironmentConfigSourceTest.php index 87b7056b50b88..5737ee54fd3a4 100644 --- a/app/code/Magento/Config/Test/Unit/App/Config/Source/EnvironmentConfigSourceTest.php +++ b/app/code/Magento/Config/Test/Unit/App/Config/Source/EnvironmentConfigSourceTest.php @@ -10,7 +10,7 @@ use Magento\Config\Model\Placeholder\PlaceholderInterface; use Magento\Framework\Stdlib\ArrayManager; -class EnvironmentConfigSourceTest extends \PHPUnit_Framework_TestCase +class EnvironmentConfigSourceTest extends \PHPUnit\Framework\TestCase { /** * @var ArrayManager|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Config/Test/Unit/App/Config/Source/InitialSnapshotConfigSourceTest.php b/app/code/Magento/Config/Test/Unit/App/Config/Source/InitialSnapshotConfigSourceTest.php index 67b0f3d034d11..ed42233ae7da6 100644 --- a/app/code/Magento/Config/Test/Unit/App/Config/Source/InitialSnapshotConfigSourceTest.php +++ b/app/code/Magento/Config/Test/Unit/App/Config/Source/InitialSnapshotConfigSourceTest.php @@ -14,7 +14,7 @@ /** * @inheritdoc */ -class InitialSnapshotConfigSourceTest extends \PHPUnit_Framework_TestCase +class InitialSnapshotConfigSourceTest extends \PHPUnit\Framework\TestCase { /** * @var InitialSnapshotConfigSource diff --git a/app/code/Magento/Config/Test/Unit/App/Config/Source/ModularConfigSourceTest.php b/app/code/Magento/Config/Test/Unit/App/Config/Source/ModularConfigSourceTest.php index 963a177ce07f1..ab369ed268f7f 100644 --- a/app/code/Magento/Config/Test/Unit/App/Config/Source/ModularConfigSourceTest.php +++ b/app/code/Magento/Config/Test/Unit/App/Config/Source/ModularConfigSourceTest.php @@ -13,7 +13,7 @@ * * @package Magento\Config\Test\Unit\App\Config\Source */ -class ModularConfigSourceTest extends \PHPUnit_Framework_TestCase +class ModularConfigSourceTest extends \PHPUnit\Framework\TestCase { /** * @var Reader|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Config/Test/Unit/App/Config/Source/RuntimeConfigSourceTest.php b/app/code/Magento/Config/Test/Unit/App/Config/Source/RuntimeConfigSourceTest.php index 28e1365865b0e..ae6ee8a028868 100644 --- a/app/code/Magento/Config/Test/Unit/App/Config/Source/RuntimeConfigSourceTest.php +++ b/app/code/Magento/Config/Test/Unit/App/Config/Source/RuntimeConfigSourceTest.php @@ -16,7 +16,7 @@ * Test Class for retrieving runtime configuration from database. * @package Magento\Config\Test\Unit\App\Config\Source */ -class RuntimeConfigSourceTest extends \PHPUnit_Framework_TestCase +class RuntimeConfigSourceTest extends \PHPUnit\Framework\TestCase { /** * @var CollectionFactory|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Config/Test/Unit/App/Config/Type/System/ReaderTest.php b/app/code/Magento/Config/Test/Unit/App/Config/Type/System/ReaderTest.php index 3f02e22465aa0..9ec2d9bb9a1f4 100644 --- a/app/code/Magento/Config/Test/Unit/App/Config/Type/System/ReaderTest.php +++ b/app/code/Magento/Config/Test/Unit/App/Config/Type/System/ReaderTest.php @@ -11,7 +11,7 @@ use Magento\Framework\App\Config\Spi\PostProcessorInterface; use Magento\Config\App\Config\Type\System\Reader; -class ReaderTest extends \PHPUnit_Framework_TestCase +class ReaderTest extends \PHPUnit\Framework\TestCase { /** * @var ConfigSourceInterface|\PHPUnit_Framework_MockObject_MockObject @@ -84,10 +84,6 @@ public function testGetCachedWithLoadDefaultScopeData() ->method('process') ->with($data) ->willReturn($data); - $this->postProcessor->expects($this->once()) - ->method('process') - ->with($data) - ->willReturn($data); $this->assertEquals($data, $this->model->read()); } } diff --git a/app/code/Magento/Config/Test/Unit/App/Config/Type/SystemTest.php b/app/code/Magento/Config/Test/Unit/App/Config/Type/SystemTest.php index cbc89df802890..40aa110382ede 100644 --- a/app/code/Magento/Config/Test/Unit/App/Config/Type/SystemTest.php +++ b/app/code/Magento/Config/Test/Unit/App/Config/Type/SystemTest.php @@ -19,7 +19,7 @@ * Test how Class process source, cache them and retrieve value by path * @package Magento\Config\Test\Unit\App\Config\Type */ -class SystemTest extends \PHPUnit_Framework_TestCase +class SystemTest extends \PHPUnit\Framework\TestCase { /** * @var ConfigSourceInterface|\PHPUnit_Framework_MockObject_MockObject @@ -170,7 +170,12 @@ public function testGetNotCached() $this->reader->expects($this->once()) ->method('read') ->willReturn($data); + $this->postProcessor->expects($this->once()) + ->method('process') + ->with($data) + ->willReturn($data); $this->assertEquals($url, $this->configType->get($path)); + $this->assertEquals($url, $this->configType->get($path)); } } diff --git a/app/code/Magento/Config/Test/Unit/Block/System/Config/DwstreeTest.php b/app/code/Magento/Config/Test/Unit/Block/System/Config/DwstreeTest.php index 713fb415f7590..d3750022d93de 100644 --- a/app/code/Magento/Config/Test/Unit/Block/System/Config/DwstreeTest.php +++ b/app/code/Magento/Config/Test/Unit/Block/System/Config/DwstreeTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Config\Test\Unit\Block\System\Config; -class DwstreeTest extends \PHPUnit_Framework_TestCase +class DwstreeTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Config\Block\System\Config\Dwstree diff --git a/app/code/Magento/Config/Test/Unit/Block/System/Config/EditTest.php b/app/code/Magento/Config/Test/Unit/Block/System/Config/EditTest.php index 3dff10d3b1f36..e26189dec316f 100644 --- a/app/code/Magento/Config/Test/Unit/Block/System/Config/EditTest.php +++ b/app/code/Magento/Config/Test/Unit/Block/System/Config/EditTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Config\Test\Unit\Block\System\Config; -class EditTest extends \PHPUnit_Framework_TestCase +class EditTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Config\Block\System\Config\Edit @@ -39,23 +39,9 @@ class EditTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_systemConfigMock = $this->getMock( - \Magento\Config\Model\Config\Structure::class, - [], - [], - '', - false, - false - ); + $this->_systemConfigMock = $this->createMock(\Magento\Config\Model\Config\Structure::class); - $this->_requestMock = $this->getMock( - \Magento\Framework\App\RequestInterface::class, - [], - [], - '', - false, - false - ); + $this->_requestMock = $this->createMock(\Magento\Framework\App\RequestInterface::class); $this->_requestMock->expects( $this->any() )->method( @@ -66,17 +52,11 @@ protected function setUp() $this->returnValue('test_section') ); - $this->_layoutMock = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false, false); + $this->_layoutMock = $this->createMock(\Magento\Framework\View\Layout::class); - $this->_urlModelMock = $this->getMock(\Magento\Backend\Model\Url::class, [], [], '', false, false); + $this->_urlModelMock = $this->createMock(\Magento\Backend\Model\Url::class); - $this->_sectionMock = $this->getMock( - \Magento\Config\Model\Config\Structure\Element\Section::class, - [], - [], - '', - false - ); + $this->_sectionMock = $this->createMock(\Magento\Config\Model\Config\Structure\Element\Section::class); $this->_systemConfigMock->expects( $this->any() )->method( diff --git a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/FieldArray/AbstractTest.php b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/FieldArray/AbstractTest.php index fa518ed172b76..7818bcf3cce89 100644 --- a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/FieldArray/AbstractTest.php +++ b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/FieldArray/AbstractTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Config\Test\Unit\Block\System\Config\Form\Field\FieldArray; -class AbstractTest extends \PHPUnit_Framework_TestCase +class AbstractTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray diff --git a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/FileTest.php b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/FileTest.php index 7a2ccf270ae07..de18d45d26864 100644 --- a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/FileTest.php +++ b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/FileTest.php @@ -9,7 +9,7 @@ */ namespace Magento\Config\Test\Unit\Block\System\Config\Form\Field; -class FileTest extends \PHPUnit_Framework_TestCase +class FileTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Config\Block\System\Config\Form\Field\File diff --git a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/HeadingTest.php b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/HeadingTest.php index 85b26e4fecda7..a865cfec600f3 100644 --- a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/HeadingTest.php +++ b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/HeadingTest.php @@ -9,7 +9,7 @@ */ namespace Magento\Config\Test\Unit\Block\System\Config\Form\Field; -class HeadingTest extends \PHPUnit_Framework_TestCase +class HeadingTest extends \PHPUnit\Framework\TestCase { public function testRender() { diff --git a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/ImageTest.php b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/ImageTest.php index 4bb917b6520e2..d0648ab008234 100644 --- a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/ImageTest.php +++ b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/ImageTest.php @@ -11,7 +11,7 @@ */ namespace Magento\Config\Test\Unit\Block\System\Config\Form\Field; -class ImageTest extends \PHPUnit_Framework_TestCase +class ImageTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\Url|\PHPUnit_Framework_MockObject_MockObject @@ -31,7 +31,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->urlBuilderMock = $this->getMock(\Magento\Framework\Url::class, [], [], '', false); + $this->urlBuilderMock = $this->createMock(\Magento\Framework\Url::class); $this->image = $objectManager->getObject( \Magento\Config\Block\System\Config\Form\Field\Image::class, [ diff --git a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/NotificationTest.php b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/NotificationTest.php index 5e7fa8bbb5c94..5e3eb986d23e0 100644 --- a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/NotificationTest.php +++ b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/NotificationTest.php @@ -9,7 +9,7 @@ */ namespace Magento\Config\Test\Unit\Block\System\Config\Form\Field; -class NotificationTest extends \PHPUnit_Framework_TestCase +class NotificationTest extends \PHPUnit\Framework\TestCase { public function testRender() { @@ -45,7 +45,7 @@ public function testRender() $elementMock->expects($this->any())->method('getHtmlId')->willReturn($htmlId); $elementMock->expects($this->any())->method('getLabel')->willReturn($label); - $dateTimeFormatter = $this->getMock(\Magento\Framework\Stdlib\DateTime\DateTimeFormatterInterface::class); + $dateTimeFormatter = $this->createMock(\Magento\Framework\Stdlib\DateTime\DateTimeFormatterInterface::class); $dateTimeFormatter->expects($this->once()) ->method('formatObject') ->with($testDatetime) diff --git a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/RegexceptionsTest.php b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/RegexceptionsTest.php index bc06e9e06ee31..4f53f1072e035 100644 --- a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/RegexceptionsTest.php +++ b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/RegexceptionsTest.php @@ -9,7 +9,7 @@ */ namespace Magento\Config\Test\Unit\Block\System\Config\Form\Field; -class RegexceptionsTest extends \PHPUnit_Framework_TestCase +class RegexceptionsTest extends \PHPUnit\Framework\TestCase { /** * @var array @@ -128,7 +128,7 @@ public function testRenderCellTemplateWrongColumnName() $this->object->addColumn($wrongColumnName, $this->cellParameters); - $this->setExpectedException('\Exception', 'Wrong column name specified.'); + $this->expectException('\Exception', 'Wrong column name specified.'); $this->object->renderCellTemplate($columnName); } diff --git a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/Select/AllowspecificTest.php b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/Select/AllowspecificTest.php index 7c15e6f79658a..be3b8e2ead0c1 100644 --- a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/Select/AllowspecificTest.php +++ b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/Select/AllowspecificTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Config\Test\Unit\Block\System\Config\Form\Field\Select; -class AllowspecificTest extends \PHPUnit_Framework_TestCase +class AllowspecificTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Config\Block\System\Config\Form\Field\Select\Allowspecific @@ -24,13 +24,9 @@ protected function setUp() \Magento\Config\Block\System\Config\Form\Field\Select\Allowspecific::class ); $this->_object->setData('html_id', 'spec_element'); - $this->_formMock = $this->getMock( + $this->_formMock = $this->createPartialMock( \Magento\Framework\Data\Form::class, - ['getHtmlIdPrefix', 'getHtmlIdSuffix', 'getElement'], - [], - '', - false, - false + ['getHtmlIdPrefix', 'getHtmlIdSuffix', 'getElement'] ); } @@ -70,14 +66,7 @@ public function testGetHtmlWhenValueIsEmpty($value) { $this->_object->setForm($this->_formMock); - $elementMock = $this->getMock( - \Magento\Framework\Data\Form\Element\Select::class, - ['setDisabled'], - [], - '', - false, - false - ); + $elementMock = $this->createPartialMock(\Magento\Framework\Data\Form\Element\Select::class, ['setDisabled']); $elementMock->expects($this->once())->method('setDisabled')->with('disabled'); $countryId = 'tetst_county_specificcountry'; diff --git a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/FieldTest.php b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/FieldTest.php index 4a581fd444687..6be1fe04b68dd 100644 --- a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/FieldTest.php +++ b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/FieldTest.php @@ -10,7 +10,7 @@ * * @package Magento\Config\Test\Unit\Block\System\Config\Form */ -class FieldTest extends \PHPUnit_Framework_TestCase +class FieldTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Config\Block\System\Config\Form\Field @@ -39,18 +39,11 @@ class FieldTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_storeManagerMock = $this->getMock( - \Magento\Store\Model\StoreManager::class, - [], - [], - '', - false, - false - ); + $this->_storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManager::class); $data = [ 'storeManager' => $this->_storeManagerMock, - 'urlBuilder' => $this->getMock(\Magento\Backend\Model\Url::class, [], [], '', false), + 'urlBuilder' => $this->createMock(\Magento\Backend\Model\Url::class), ]; $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_object = $helper->getObject(\Magento\Config\Block\System\Config\Form\Field::class, $data); @@ -62,7 +55,7 @@ protected function setUp() 'elementHTML' => 'test_html', ]; - $this->_elementMock = $this->getMock( + $this->_elementMock = $this->createPartialMock( \Magento\Framework\Data\Form\Element\Text::class, [ 'getHtmlId', @@ -79,12 +72,7 @@ protected function setUp() 'getCanUseDefaultValue', 'setDisabled', 'getTooltip', - ], - [], - '', - false, - false, - true + ] ); $this->_elementMock->expects( diff --git a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Fieldset/Modules/DisableOutputTest.php b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Fieldset/Modules/DisableOutputTest.php index e68f4118b90c5..9d76363213d0b 100644 --- a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Fieldset/Modules/DisableOutputTest.php +++ b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Fieldset/Modules/DisableOutputTest.php @@ -7,9 +7,8 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - * @deprecated because \Magento\Config\Block\System\Config\Form\Fieldset\Modules\DisableOutput is deprecated */ -class DisableOutputTest extends \PHPUnit_Framework_TestCase +class DisableOutputTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Config\Block\System\Config\Form\Fieldset\Modules\DisableOutput @@ -131,7 +130,9 @@ protected function setUp() $factoryColl = $this->getMockBuilder(\Magento\Framework\Data\Form\Element\CollectionFactory::class) ->disableOriginalConstructor() ->getMock(); - $formMock = $this->getMock(\Magento\Framework\Data\Form\AbstractForm::class, [], [$factory, $factoryColl]); + $formMock = $this->getMockBuilder(\Magento\Framework\Data\Form\AbstractForm::class) + ->setConstructorArgs([$factory, $factoryColl]) + ->getMock(); $context = $this->objectManager->getObject( \Magento\Backend\Block\Context::class, diff --git a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/FieldsetTest.php b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/FieldsetTest.php index cde1d3a81746f..66bbf407c06a5 100644 --- a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/FieldsetTest.php +++ b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/FieldsetTest.php @@ -8,7 +8,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class FieldsetTest extends \PHPUnit_Framework_TestCase +class FieldsetTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Config\Block\System\Config\Form\Fieldset @@ -94,18 +94,12 @@ protected function setUp() $this->_requestMock->expects($this->any()) ->method('getParam') ->willReturn('Test Param'); - $this->_urlModelMock = $this->getMock(\Magento\Backend\Model\Url::class, [], [], '', false, false); - $this->_layoutMock = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false, false); - $groupMock = $this->getMock( - \Magento\Config\Model\Config\Structure\Element\Group::class, - [], - [], - '', - false - ); + $this->_urlModelMock = $this->createMock(\Magento\Backend\Model\Url::class); + $this->_layoutMock = $this->createMock(\Magento\Framework\View\Layout::class); + $groupMock = $this->createMock(\Magento\Config\Model\Config\Structure\Element\Group::class); $groupMock->expects($this->any())->method('getFieldsetCss')->will($this->returnValue('test_fieldset_css')); - $this->_helperMock = $this->getMock(\Magento\Framework\View\Helper\Js::class, [], [], '', false, false); + $this->_helperMock = $this->createMock(\Magento\Framework\View\Helper\Js::class); $data = [ 'request' => $this->_requestMock, @@ -118,7 +112,7 @@ protected function setUp() $this->_testHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_object = $this->_testHelper->getObject(\Magento\Config\Block\System\Config\Form\Fieldset::class, $data); - $this->_elementMock = $this->getMock( + $this->_elementMock = $this->createPartialMock( \Magento\Framework\Data\Form\Element\Text::class, [ 'getId', @@ -130,12 +124,7 @@ protected function setUp() 'getIsNested', 'getExpanded', 'getForm' - ], - [], - '', - false, - false, - true + ] ); $this->_elementMock->expects($this->any()) @@ -159,13 +148,13 @@ protected function setUp() * @param $expanded * @param $nested * @param extra - * @dataProvider testRenderWithoutStoredElementsDataProvider + * @dataProvider renderWithoutStoredElementsDataProvider */ public function testRenderWithoutStoredElements($expanded, $nested, $extra) { $this->userMock->expects($this->any())->method('getExtra')->willReturn($extra); $collection = $this->_testHelper->getObject(\Magento\Framework\Data\Form\Element\Collection::class); - $formMock = $this->getMock(\Magento\Framework\Data\Form::class, [], [], '', false); + $formMock = $this->createMock(\Magento\Framework\Data\Form::class); $this->_elementMock->expects($this->any())->method('getForm')->willReturn($formMock); $formMock->expects($this->any())->method('getElements')->willReturn($collection); $this->_elementMock->expects($this->any())->method('getElements')->will($this->returnValue($collection)); @@ -184,7 +173,7 @@ public function testRenderWithoutStoredElements($expanded, $nested, $extra) * @param $expanded * @param $nested * @param $extra - * @dataProvider testRenderWithStoredElementsDataProvider + * @dataProvider renderWithStoredElementsDataProvider */ public function testRenderWithStoredElements($expanded, $nested, $extra) { @@ -208,17 +197,13 @@ public function testRenderWithStoredElements($expanded, $nested, $extra) $fieldSetMock->expects($this->any())->method('toHtml')->will($this->returnValue('test_fieldset_toHTML')); $fieldSetMock->expects($this->any())->method('getHtmlId')->willReturn('test_fieldset_HTML_id'); - $factory = $this->getMock(\Magento\Framework\Data\Form\Element\Factory::class, [], [], '', false); + $factory = $this->createMock(\Magento\Framework\Data\Form\Element\Factory::class); - $factoryColl = $this->getMock( - \Magento\Framework\Data\Form\Element\CollectionFactory::class, - [], - [], - '', - false - ); + $factoryColl = $this->createMock(\Magento\Framework\Data\Form\Element\CollectionFactory::class); - $formMock = $this->getMock(\Magento\Framework\Data\Form\AbstractForm::class, [], [$factory, $factoryColl]); + $formMock = $this->getMockBuilder(\Magento\Framework\Data\Form\AbstractForm::class) + ->setConstructorArgs([$factory, $factoryColl]) + ->getMock(); $collection = $this->_testHelper->getObject( \Magento\Framework\Data\Form\Element\Collection::class, @@ -226,7 +211,7 @@ public function testRenderWithStoredElements($expanded, $nested, $extra) ); $collection->add($fieldMock); $collection->add($fieldSetMock); - $formMock = $this->getMock(\Magento\Framework\Data\Form::class, [], [], '', false); + $formMock = $this->createMock(\Magento\Framework\Data\Form::class); $this->_elementMock->expects($this->any())->method('getForm')->willReturn($formMock); $formMock->expects($this->any())->method('getElements')->willReturn($collection); $this->_elementMock->expects($this->any())->method('getElements')->will($this->returnValue($collection)); @@ -248,7 +233,7 @@ public function testRenderWithStoredElements($expanded, $nested, $extra) /** * @return array */ - public function testRenderWithoutStoredElementsDataProvider() + public function renderWithoutStoredElementsDataProvider() { return $this->dataProvider(); } @@ -256,7 +241,7 @@ public function testRenderWithoutStoredElementsDataProvider() /** * @return array */ - public function testRenderWithStoredElementsDataProvider() + public function renderWithStoredElementsDataProvider() { return $this->dataProvider(); } diff --git a/app/code/Magento/Config/Test/Unit/Block/System/Config/FormTest.php b/app/code/Magento/Config/Test/Unit/Block/System/Config/FormTest.php index 506806df8ab31..bee0d5172093c 100644 --- a/app/code/Magento/Config/Test/Unit/Block/System/Config/FormTest.php +++ b/app/code/Magento/Config/Test/Unit/Block/System/Config/FormTest.php @@ -22,10 +22,10 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class FormTest extends \PHPUnit_Framework_TestCase +class FormTest extends \PHPUnit\Framework\TestCase { /** - * @var \PHPUnit_Framework_MockObject_MockBuilder + * @var \PHPUnit\Framework\MockObject_MockBuilder */ protected $_objectBuilder; @@ -85,16 +85,9 @@ class FormTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->_systemConfigMock = $this->getMock( - \Magento\Config\Model\Config\Structure::class, - [], - [], - '', - false, - false - ); + $this->_systemConfigMock = $this->createMock(\Magento\Config\Model\Config\Structure::class); - $requestMock = $this->getMock(\Magento\Framework\App\RequestInterface::class, [], [], '', false, false); + $requestMock = $this->createMock(\Magento\Framework\App\RequestInterface::class); $requestParams = [ ['website', '', 'website_code'], ['section', '', 'section_code'], @@ -102,44 +95,16 @@ protected function setUp() ]; $requestMock->expects($this->any())->method('getParam')->will($this->returnValueMap($requestParams)); - $layoutMock = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false, false); + $layoutMock = $this->createMock(\Magento\Framework\View\Layout::class); - $this->_urlModelMock = $this->getMock(\Magento\Backend\Model\Url::class, [], [], '', false, false); - $configFactoryMock = $this->getMock( - \Magento\Config\Model\Config\Factory::class, - [], - [], - '', - false, - false - ); - $this->_formFactoryMock = $this->getMock( - \Magento\Framework\Data\FormFactory::class, - ['create'], - [], - '', - false, - false - ); - $this->_fieldsetFactoryMock = $this->getMock( - \Magento\Config\Block\System\Config\Form\Fieldset\Factory::class, - [], - [], - '', - false, - false - ); - $this->_fieldFactoryMock = $this->getMock( - \Magento\Config\Block\System\Config\Form\Field\Factory::class, - [], - [], - '', - false, - false - ); - $this->_coreConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->_urlModelMock = $this->createMock(\Magento\Backend\Model\Url::class); + $configFactoryMock = $this->createMock(\Magento\Config\Model\Config\Factory::class); + $this->_formFactoryMock = $this->createPartialMock(\Magento\Framework\Data\FormFactory::class, ['create']); + $this->_fieldsetFactoryMock = $this->createMock(\Magento\Config\Block\System\Config\Form\Fieldset\Factory::class); + $this->_fieldFactoryMock = $this->createMock(\Magento\Config\Block\System\Config\Form\Field\Factory::class); + $this->_coreConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $this->_backendConfigMock = $this->getMock(\Magento\Config\Model\Config::class, [], [], '', false, false); + $this->_backendConfigMock = $this->createMock(\Magento\Config\Model\Config::class); $configFactoryMock->expects( $this->once() @@ -159,14 +124,7 @@ protected function setUp() $this->returnValue(['section1/group1/field1' => 'some_value']) ); - $this->_formMock = $this->getMock( - \Magento\Framework\Data\Form::class, - ['setParent', 'setBaseUrl', 'addFieldset'], - [], - '', - false, - false - ); + $this->_formMock = $this->createPartialMock(\Magento\Framework\Data\Form::class, ['setParent', 'setBaseUrl', 'addFieldset']); $this->storeManagerMock = $this->getMockBuilder(StoreManagerInterface::class) ->getMockForAbstractClass(); @@ -205,7 +163,7 @@ protected function setUp() ->method('get') ->willReturn([]); - $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); $objectManagerMock->expects($this->any()) ->method('get') ->willReturnMap([ @@ -240,14 +198,7 @@ public function testInitForm($sectionIsVisible) $sectionMock->expects($this->once()) ->method('getChildren') ->willReturn([ - $this->getMock( - \Magento\Config\Model\Config\Structure\Element\Group::class, - [], - [], - '', - false, - false - ) + $this->createMock(\Magento\Config\Model\Config\Structure\Element\Group::class) ]); } @@ -297,14 +248,7 @@ public function testInitGroup($shouldCloneFields, $prefixes, $callNum) $this->_formMock->expects($this->once())->method('setBaseUrl')->with('base_url'); $this->_urlModelMock->expects($this->any())->method('getBaseUrl')->will($this->returnValue('base_url')); - $fieldsetRendererMock = $this->getMock( - \Magento\Config\Block\System\Config\Form\Fieldset::class, - [], - [], - '', - false, - false - ); + $fieldsetRendererMock = $this->createMock(\Magento\Config\Block\System\Config\Form\Fieldset::class); $this->_fieldsetFactoryMock->expects( $this->once() )->method( @@ -313,23 +257,9 @@ public function testInitGroup($shouldCloneFields, $prefixes, $callNum) $this->returnValue($fieldsetRendererMock) ); - $cloneModelMock = $this->getMock( - \Magento\Config\Model\Config::class, - ['getPrefixes'], - [], - '', - false, - false - ); + $cloneModelMock = $this->createPartialMock(\Magento\Config\Model\Config::class, ['getPrefixes']); - $groupMock = $this->getMock( - \Magento\Config\Model\Config\Structure\Element\Group::class, - [], - [], - '', - false, - false - ); + $groupMock = $this->createMock(\Magento\Config\Model\Config\Structure\Element\Group::class); $groupMock->expects($this->once())->method('getFrontendModel')->will($this->returnValue(false)); $groupMock->expects($this->any())->method('getPath')->will($this->returnValue('section_id_group_id')); $groupMock->expects($this->once())->method('getLabel')->will($this->returnValue('label')); @@ -348,14 +278,7 @@ public function testInitGroup($shouldCloneFields, $prefixes, $callNum) $this->returnValue([]) ); - $sectionMock = $this->getMock( - \Magento\Config\Model\Config\Structure\Element\Section::class, - [], - [], - '', - false, - false - ); + $sectionMock = $this->createMock(\Magento\Config\Model\Config\Structure\Element\Section::class); $sectionMock->expects($this->once())->method('isVisible')->will($this->returnValue(true)); $sectionMock->expects($this->once())->method('getChildren')->will($this->returnValue([$groupMock])); @@ -370,11 +293,7 @@ public function testInitGroup($shouldCloneFields, $prefixes, $callNum) $this->returnValue($sectionMock) ); - $formFieldsetMock = $this->getMock( - \Magento\Framework\Data\Form\Element\Fieldset::class, - [], - [], - '', false, false); + $formFieldsetMock = $this->createMock(\Magento\Framework\Data\Form\Element\Fieldset::class); $params = [ 'legend' => 'label', @@ -456,42 +375,14 @@ public function testInitFields( $expectedDisable ) { // Parameters initialization - $fieldsetMock = $this->getMock( - \Magento\Framework\Data\Form\Element\Fieldset::class, - [], - [], - '', - false, - false - ); - $groupMock = $this->getMock( - \Magento\Config\Model\Config\Structure\Element\Group::class, - [], - [], - '', - false, - false - ); - $sectionMock = $this->getMock( - \Magento\Config\Model\Config\Structure\Element\Section::class, - [], - [], - '', - false, - false - ); + $fieldsetMock = $this->createMock(\Magento\Framework\Data\Form\Element\Fieldset::class); + $groupMock = $this->createMock(\Magento\Config\Model\Config\Structure\Element\Group::class); + $sectionMock = $this->createMock(\Magento\Config\Model\Config\Structure\Element\Section::class); $fieldPrefix = 'fieldPrefix'; $labelPrefix = 'labelPrefix'; // Field Renderer Mock configuration - $fieldRendererMock = $this->getMock( - \Magento\Config\Block\System\Config\Form\Field::class, - [], - [], - '', - false, - false - ); + $fieldRendererMock = $this->createMock(\Magento\Config\Block\System\Config\Form\Field::class); $this->_fieldFactoryMock->expects( $this->once() )->method( @@ -535,14 +426,7 @@ public function testInitFields( ->willReturn($storeMock); // Field mock configuration - $fieldMock = $this->getMock( - \Magento\Config\Model\Config\Structure\Element\Field::class, - [], - [], - '', - false, - false - ); + $fieldMock = $this->createMock(\Magento\Config\Model\Config\Structure\Element\Field::class); $fieldMock->expects($this->any())->method('getPath')->will($this->returnValue('section1/group1/field1')); $fieldMock->expects($this->any())->method('getConfigPath')->will($this->returnValue($configPath)); $fieldMock->expects($this->any())->method('getGroupPath')->will($this->returnValue('some/config/path')); diff --git a/app/code/Magento/Config/Test/Unit/Block/System/Config/TabsTest.php b/app/code/Magento/Config/Test/Unit/Block/System/Config/TabsTest.php index 5d65793793606..ab9f4b0a73147 100644 --- a/app/code/Magento/Config/Test/Unit/Block/System/Config/TabsTest.php +++ b/app/code/Magento/Config/Test/Unit/Block/System/Config/TabsTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Config\Test\Unit\Block\System\Config; -class TabsTest extends \PHPUnit_Framework_TestCase +class TabsTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Config\Block\System\Config\Tabs @@ -29,7 +29,7 @@ class TabsTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_requestMock = $this->getMock(\Magento\Framework\App\RequestInterface::class, [], [], '', false); + $this->_requestMock = $this->createMock(\Magento\Framework\App\RequestInterface::class); $this->_requestMock->expects( $this->any() )->method( @@ -39,9 +39,9 @@ protected function setUp() )->will( $this->returnValue('currentSectionId') ); - $this->_structureMock = $this->getMock(\Magento\Config\Model\Config\Structure::class, [], [], '', false); + $this->_structureMock = $this->createMock(\Magento\Config\Model\Config\Structure::class); $this->_structureMock->expects($this->once())->method('getTabs')->will($this->returnValue([])); - $this->_urlBuilderMock = $this->getMock(\Magento\Backend\Model\Url::class, [], [], '', false); + $this->_urlBuilderMock = $this->createMock(\Magento\Backend\Model\Url::class); $data = [ 'configStructure' => $this->_structureMock, @@ -73,13 +73,7 @@ public function testGetSectionUrl() $this->returnValue('testSectionUrl') ); - $sectionMock = $this->getMock( - \Magento\Config\Model\Config\Structure\Element\Section::class, - [], - [], - '', - false - ); + $sectionMock = $this->createMock(\Magento\Config\Model\Config\Structure\Element\Section::class); $sectionMock->expects($this->once())->method('getId')->will($this->returnValue('testSectionId')); $this->assertEquals('testSectionUrl', $this->_object->getSectionUrl($sectionMock)); @@ -87,26 +81,14 @@ public function testGetSectionUrl() public function testIsSectionActiveReturnsTrueForActiveSection() { - $sectionMock = $this->getMock( - \Magento\Config\Model\Config\Structure\Element\Section::class, - [], - [], - '', - false - ); + $sectionMock = $this->createMock(\Magento\Config\Model\Config\Structure\Element\Section::class); $sectionMock->expects($this->once())->method('getId')->will($this->returnValue('currentSectionId')); $this->assertTrue($this->_object->isSectionActive($sectionMock)); } public function testIsSectionActiveReturnsFalseForNonActiveSection() { - $sectionMock = $this->getMock( - \Magento\Config\Model\Config\Structure\Element\Section::class, - [], - [], - '', - false - ); + $sectionMock = $this->createMock(\Magento\Config\Model\Config\Structure\Element\Section::class); $sectionMock->expects($this->once())->method('getId')->will($this->returnValue('nonCurrentSectionId')); $this->assertFalse($this->_object->isSectionActive($sectionMock)); } diff --git a/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/ConfigSetProcessorFactoryTest.php b/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/ConfigSetProcessorFactoryTest.php index e1712e22cfd16..1fa0310ca62eb 100644 --- a/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/ConfigSetProcessorFactoryTest.php +++ b/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/ConfigSetProcessorFactoryTest.php @@ -17,7 +17,7 @@ * * @see ConfigSetProcessorFactory */ -class ConfigSetProcessorFactoryTest extends \PHPUnit_Framework_TestCase +class ConfigSetProcessorFactoryTest extends \PHPUnit\Framework\TestCase { /** * @var ConfigSetProcessorFactory diff --git a/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/DefaultProcessorTest.php b/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/DefaultProcessorTest.php index 7543887696a87..066b0fbe84b50 100644 --- a/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/DefaultProcessorTest.php +++ b/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/DefaultProcessorTest.php @@ -23,7 +23,7 @@ * @see DefaultProcessor * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class DefaultProcessorTest extends \PHPUnit_Framework_TestCase +class DefaultProcessorTest extends \PHPUnit\Framework\TestCase { /** * @var DefaultProcessor diff --git a/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/LockProcessorTest.php b/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/LockProcessorTest.php index 62028eb789230..4535e9ad888c2 100644 --- a/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/LockProcessorTest.php +++ b/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/LockProcessorTest.php @@ -23,7 +23,7 @@ * @see LockProcessor * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class LockProcessorTest extends \PHPUnit_Framework_TestCase +class LockProcessorTest extends \PHPUnit\Framework\TestCase { /** * @var LockProcessor diff --git a/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/ProcessorFacadeTest.php b/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/ProcessorFacadeTest.php index 991ab1bd882a4..4e65ab3f4cc21 100644 --- a/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/ProcessorFacadeTest.php +++ b/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/ProcessorFacadeTest.php @@ -26,7 +26,7 @@ * @see ProcessorFacade * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ProcessorFacadeTest extends \PHPUnit_Framework_TestCase +class ProcessorFacadeTest extends \PHPUnit\Framework\TestCase { /** * @var ProcessorFacade @@ -132,7 +132,7 @@ public function testProcess() */ public function testProcessWithValidatorException(LocalizedException $exception) { - $this->setExpectedException(ValidatorException::class, 'Some error'); + $this->expectException(ValidatorException::class, 'Some error'); $this->scopeValidatorMock->expects($this->once()) ->method('isValid') ->willThrowException($exception); diff --git a/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSetCommandTest.php b/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSetCommandTest.php index ceae19826b047..39f9c47361352 100644 --- a/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSetCommandTest.php +++ b/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSetCommandTest.php @@ -21,7 +21,7 @@ * * @see ConfigSetCommand */ -class ConfigSetCommandTest extends \PHPUnit_Framework_TestCase +class ConfigSetCommandTest extends \PHPUnit\Framework\TestCase { /** * @var ConfigSetCommand diff --git a/app/code/Magento/Config/Test/Unit/Console/Command/ConfigShow/ValueProcessorTest.php b/app/code/Magento/Config/Test/Unit/Console/Command/ConfigShow/ValueProcessorTest.php index fa66a34db0c63..cf758553e876d 100644 --- a/app/code/Magento/Config/Test/Unit/Console/Command/ConfigShow/ValueProcessorTest.php +++ b/app/code/Magento/Config/Test/Unit/Console/Command/ConfigShow/ValueProcessorTest.php @@ -21,7 +21,7 @@ * * @see ValueProcessor */ -class ValueProcessorTest extends \PHPUnit_Framework_TestCase +class ValueProcessorTest extends \PHPUnit\Framework\TestCase { /** * @var ValueFactory|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Config/Test/Unit/Console/Command/ConfigShowCommandTest.php b/app/code/Magento/Config/Test/Unit/Console/Command/ConfigShowCommandTest.php index ba6d632a639a0..f6c2c404cabbf 100644 --- a/app/code/Magento/Config/Test/Unit/Console/Command/ConfigShowCommandTest.php +++ b/app/code/Magento/Config/Test/Unit/Console/Command/ConfigShowCommandTest.php @@ -15,7 +15,7 @@ use Magento\Framework\App\Config\ConfigPathResolver; use Magento\Config\Console\Command\ConfigShow\ValueProcessor; -class ConfigShowCommandTest extends \PHPUnit_Framework_TestCase +class ConfigShowCommandTest extends \PHPUnit\Framework\TestCase { /** * @var ValidatorInterface|MockObject diff --git a/app/code/Magento/Config/Test/Unit/Console/Command/EmulatedAdminhtmlAreaProcessorTest.php b/app/code/Magento/Config/Test/Unit/Console/Command/EmulatedAdminhtmlAreaProcessorTest.php index 29de0dc0b3c2b..51db1b1e21aa5 100644 --- a/app/code/Magento/Config/Test/Unit/Console/Command/EmulatedAdminhtmlAreaProcessorTest.php +++ b/app/code/Magento/Config/Test/Unit/Console/Command/EmulatedAdminhtmlAreaProcessorTest.php @@ -11,7 +11,7 @@ use Magento\Framework\Config\ScopeInterface; use PHPUnit_Framework_MockObject_MockObject as MockObject; -class EmulatedAdminhtmlAreaProcessorTest extends \PHPUnit_Framework_TestCase +class EmulatedAdminhtmlAreaProcessorTest extends \PHPUnit\Framework\TestCase { /** * The application scope manager. diff --git a/app/code/Magento/Config/Test/Unit/Controller/Adminhtml/System/Config/SaveTest.php b/app/code/Magento/Config/Test/Unit/Controller/Adminhtml/System/Config/SaveTest.php index 19b7de9a7358d..069a1c20b2966 100644 --- a/app/code/Magento/Config/Test/Unit/Controller/Adminhtml/System/Config/SaveTest.php +++ b/app/code/Magento/Config/Test/Unit/Controller/Adminhtml/System/Config/SaveTest.php @@ -8,7 +8,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class SaveTest extends \PHPUnit_Framework_TestCase +class SaveTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Config\Controller\Adminhtml\System\Config\Save @@ -68,63 +68,25 @@ class SaveTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->_requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false, false); - $this->_responseMock = $this->getMock( - \Magento\Framework\App\Response\Http::class, - [], - [], - '', - false, - false - ); + $this->_requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class); + $this->_responseMock = $this->createMock(\Magento\Framework\App\Response\Http::class); - $configStructureMock = $this->getMock( - \Magento\Config\Model\Config\Structure::class, - [], - [], - '', - false, - false - ); - $this->_configFactoryMock = $this->getMock( - \Magento\Config\Model\Config\Factory::class, - [], - [], - '', - false, - false - ); - $this->_eventManagerMock = $this->getMock( - \Magento\Framework\Event\ManagerInterface::class, - [], - [], - '', - false, - false - ); + $configStructureMock = $this->createMock(\Magento\Config\Model\Config\Structure::class); + $this->_configFactoryMock = $this->createMock(\Magento\Config\Model\Config\Factory::class); + $this->_eventManagerMock = $this->createMock(\Magento\Framework\Event\ManagerInterface::class); - $helperMock = $this->getMock(\Magento\Backend\Helper\Data::class, [], [], '', false, false); + $helperMock = $this->createMock(\Magento\Backend\Helper\Data::class); - $this->messageManagerMock = $this->getMock( + $this->messageManagerMock = $this->createPartialMock( \Magento\Framework\Message\Manager::class, - ['addSuccess', 'addException'], - [], - '', - false, - false + ['addSuccess', 'addException'] ); - $this->_authMock = $this->getMock(\Magento\Backend\Model\Auth::class, ['getUser'], [], '', false, false); + $this->_authMock = $this->createPartialMock(\Magento\Backend\Model\Auth::class, ['getUser']); - $this->_sectionMock = $this->getMock( - \Magento\Config\Model\Config\Structure\Element\Section::class, - [], - [], - '', - false - ); + $this->_sectionMock = $this->createMock(\Magento\Config\Model\Config\Structure\Element\Section::class); - $this->_cacheMock = $this->getMock(\Magento\Framework\App\Cache\Type\Layout::class, [], [], '', false); + $this->_cacheMock = $this->createMock(\Magento\Framework\App\Cache\Type\Layout::class); $configStructureMock->expects($this->any())->method('getElement')->willReturn($this->_sectionMock); $configStructureMock->expects($this->any())->method('getSectionList')->willReturn( @@ -163,27 +125,24 @@ protected function setUp() 'resultRedirectFactory' => $resultRedirectFactory ]; - $this->_sectionCheckerMock = $this->getMock( - \Magento\Config\Controller\Adminhtml\System\ConfigSectionChecker::class, - [], - [], - '', - false + $this->_sectionCheckerMock = $this->createMock( + \Magento\Config\Controller\Adminhtml\System\ConfigSectionChecker::class ); $context = $helper->getObject(\Magento\Backend\App\Action\Context::class, $arguments); - $this->_controller = $this->getMock( - \Magento\Config\Controller\Adminhtml\System\Config\Save::class, - ['deniedAction'], - [ - $context, - $configStructureMock, - $this->_sectionCheckerMock, - $this->_configFactoryMock, - $this->_cacheMock, - new \Magento\Framework\Stdlib\StringUtils(), - ] - ); + $this->_controller = $this->getMockBuilder(\Magento\Config\Controller\Adminhtml\System\Config\Save::class) + ->setMethods(['deniedAction']) + ->setConstructorArgs( + [ + $context, + $configStructureMock, + $this->_sectionCheckerMock, + $this->_configFactoryMock, + $this->_cacheMock, + new \Magento\Framework\Stdlib\StringUtils(), + ] + ) + ->getMock(); } public function testIndexActionWithAllowedSection() @@ -203,7 +162,7 @@ public function testIndexActionWithAllowedSection() $this->_requestMock->expects($this->any())->method('getPost')->will($this->returnValueMap($requestPostMap)); $this->_requestMock->expects($this->any())->method('getParam')->will($this->returnValueMap($requestParamMap)); - $backendConfigMock = $this->getMock(\Magento\Config\Model\Config::class, [], [], '', false, false); + $backendConfigMock = $this->createMock(\Magento\Config\Model\Config::class); $backendConfigMock->expects($this->once())->method('save'); $params = [ @@ -238,7 +197,7 @@ public function testIndexActionSaveState() 'some_key_1' => '1', ]; - $userMock = $this->getMock(\Magento\User\Model\User::class, [], [], '', false, false); + $userMock = $this->createMock(\Magento\User\Model\User::class); $userMock->expects($this->once())->method('saveExtra')->with(['configState' => $extraData]); $this->_authMock->expects($this->once())->method('getUser')->will($this->returnValue($userMock)); $this->_requestMock->expects( @@ -290,7 +249,7 @@ public function testIndexActionGetGroupForSave() 'store' => 'test_store', 'groups' => $groupToSave, ]; - $backendConfigMock = $this->getMock(\Magento\Config\Model\Config::class, [], [], '', false, false); + $backendConfigMock = $this->createMock(\Magento\Config\Model\Config::class); $this->_configFactoryMock->expects( $this->once() )->method( @@ -317,7 +276,7 @@ public function testIndexActionSaveAdvanced() $this->_requestMock->expects($this->any())->method('getParam')->will($this->returnValueMap($requestParamMap)); - $backendConfigMock = $this->getMock(\Magento\Config\Model\Config::class, [], [], '', false, false); + $backendConfigMock = $this->createMock(\Magento\Config\Model\Config::class); $this->_configFactoryMock->expects( $this->once() )->method( diff --git a/app/code/Magento/Config/Test/Unit/Model/Compiler/IncludeElementTest.php b/app/code/Magento/Config/Test/Unit/Model/Compiler/IncludeElementTest.php index 0f8e842aeb42b..451c73319d5bc 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Compiler/IncludeElementTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Compiler/IncludeElementTest.php @@ -8,7 +8,7 @@ /** * Class IncludeElementTest */ -class IncludeElementTest extends \PHPUnit_Framework_TestCase +class IncludeElementTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Config\Model\Config\Compiler\IncludeElement diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Backend/BaseurlTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/BaseurlTest.php index 2bd9b2f2cba90..f82e700f108b3 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Backend/BaseurlTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/BaseurlTest.php @@ -6,32 +6,40 @@ namespace Magento\Config\Test\Unit\Model\Config\Backend; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -use Magento\Store\Model\StoreManagerInterface; use Magento\Store\Model\Store; -class BaseurlTest extends \PHPUnit_Framework_TestCase +class BaseurlTest extends \PHPUnit\Framework\TestCase { public function testSaveMergedJsCssMustBeCleaned() { - $context = (new ObjectManager($this))->getObject(\Magento\Framework\Model\Context::class); - $resource = $this->getMock(\Magento\Config\Model\ResourceModel\Config\Data::class, [], [], '', false); + $resource = $this->createMock(\Magento\Config\Model\ResourceModel\Config\Data::class); $resource->expects($this->any())->method('addCommitCallback')->will($this->returnValue($resource)); $resourceCollection = $this->getMockBuilder(\Magento\Framework\Data\Collection\AbstractDb::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $mergeService = $this->getMock(\Magento\Framework\View\Asset\MergeService::class, [], [], '', false); - $coreRegistry = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); - $coreConfig = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $mergeService = $this->createMock(\Magento\Framework\View\Asset\MergeService::class); + $coreRegistry = $this->createMock(\Magento\Framework\Registry::class); + $coreConfig = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $cacheTypeListMock = $this->getMockBuilder(\Magento\Framework\App\Cache\TypeListInterface::class) ->disableOriginalConstructor() ->getMock(); - $model = $this->getMock( - \Magento\Config\Model\Config\Backend\Baseurl::class, - ['getOldValue'], - [$context, $coreRegistry, $coreConfig, $cacheTypeListMock, $mergeService, $resource, $resourceCollection] - ); + $model = $this->getMockBuilder(\Magento\Config\Model\Config\Backend\Baseurl::class) + ->setMethods(['getOldValue']) + ->setConstructorArgs( + [ + $context, + $coreRegistry, + $coreConfig, + $cacheTypeListMock, + $mergeService, + $resource, + $resourceCollection + ] + ) + ->getMock(); + $cacheTypeListMock->expects($this->once()) ->method('invalidate') ->with(\Magento\Framework\App\Cache\Type\Config::TYPE_IDENTIFIER) diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Backend/Email/AddressTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/Email/AddressTest.php new file mode 100644 index 0000000000000..bacbda537fb1d --- /dev/null +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/Email/AddressTest.php @@ -0,0 +1,53 @@ +model = $objectManager->getObject(Address::class); + } + + /** + * @dataProvider beforeSaveDataProvider + * @param string|null $value + * @param string|bool $expectedValue false if exception to be thrown + * @return void + */ + public function testBeforeSave($value, $expectedValue) + { + $this->model->setValue($value); + + if ($expectedValue === false) { + $this->expectException(LocalizedException::class); + } + + $this->model->beforeSave(); + $this->assertEquals($expectedValue, $this->model->getValue()); + } + + public function beforeSaveDataProvider() + { + return [ + ['someone@magento.com', 'someone@magento.com'], + ['real+email@magento.com', 'real+email@magento.com'], + ['not.a.real.email', false], + [null, false], + ['', false] + ]; + } +} diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Backend/Email/LogoTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/Email/LogoTest.php index d6d429471865c..8d6dbba3e90cf 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Backend/Email/LogoTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/Email/LogoTest.php @@ -20,7 +20,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class LogoTest extends \PHPUnit_Framework_TestCase +class LogoTest extends \PHPUnit\Framework\TestCase { /** @var Logo */ protected $model; diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Backend/Email/SenderTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/Email/SenderTest.php new file mode 100644 index 0000000000000..8e559ff8284ed --- /dev/null +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/Email/SenderTest.php @@ -0,0 +1,53 @@ +model = $objectManager->getObject(Sender::class); + } + + /** + * @dataProvider beforeSaveDataProvider + * @param string|null $value + * @param string|bool $expectedValue false if exception to be thrown + * @return void + */ + public function testBeforeSave($value, $expectedValue) + { + $this->model->setValue($value); + + if ($expectedValue === false) { + $this->expectException(LocalizedException::class); + } + + $this->model->beforeSave(); + + $this->assertEquals($expectedValue, $this->model->getValue()); + } + + public function beforeSaveDataProvider() + { + return [ + ['Mr. Real Name', 'Mr. Real Name'], + [str_repeat('a', 256), false], + [null, false], + ['', false], + ]; + } +} diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Backend/EncryptedTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/EncryptedTest.php index 48425a46f80b9..ec1dab4c11fba 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Backend/EncryptedTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/EncryptedTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Config\Test\Unit\Model\Config\Backend; -class EncryptedTest extends \PHPUnit_Framework_TestCase +class EncryptedTest extends \PHPUnit\Framework\TestCase { /** @var \PHPUnit_Framework_MockObject_MockObject */ protected $_encryptorMock; @@ -23,8 +23,8 @@ protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $eventDispatcherMock = $this->getMock(\Magento\Framework\Event\Manager::class, [], [], '', false); - $contextMock = $this->getMock(\Magento\Framework\Model\Context::class, [], [], '', false); + $eventDispatcherMock = $this->createMock(\Magento\Framework\Event\Manager::class); + $contextMock = $this->createMock(\Magento\Framework\Model\Context::class); $contextMock->expects( $this->any() )->method( @@ -32,7 +32,7 @@ protected function setUp() )->will( $this->returnValue($eventDispatcherMock) ); - $this->_resourceMock = $this->getMock( + $this->_resourceMock = $this->createPartialMock( \Magento\Framework\Model\ResourceModel\AbstractResource::class, [ '_construct', @@ -42,19 +42,10 @@ protected function setUp() 'save', 'commit', 'addCommitCallback', - ], - [], - '', - false - ); - $this->_configMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $this->_encryptorMock = $this->getMock( - \Magento\Framework\Encryption\EncryptorInterface::class, - [], - [], - '', - false + ] ); + $this->_configMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->_encryptorMock = $this->createMock(\Magento\Framework\Encryption\EncryptorInterface::class); $this->_model = $helper->getObject( \Magento\Config\Model\Config\Backend\Encrypted::class, [ diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Backend/File/RequestDataTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/File/RequestDataTest.php index 4f4125d9adfee..4995241eca1ee 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Backend/File/RequestDataTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/File/RequestDataTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Config\Test\Unit\Model\Config\Backend\File; -class RequestDataTest extends \PHPUnit_Framework_TestCase +class RequestDataTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Config\Model\Config\Backend\File\RequestData diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Backend/FileTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/FileTest.php index 4e1312f0927b0..8dc530fa71ccb 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Backend/FileTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/FileTest.php @@ -21,7 +21,7 @@ * Class FileTest * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class FileTest extends \PHPUnit_Framework_TestCase +class FileTest extends \PHPUnit\Framework\TestCase { /** @var File */ protected $model; diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Backend/Image/LogoTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/Image/LogoTest.php index 28f35c233b874..d5ddf7a27eeab 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Backend/Image/LogoTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/Image/LogoTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Config\Test\Unit\Model\Config\Backend\Image; -class LogoTest extends \PHPUnit_Framework_TestCase +class LogoTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Config\Model\Config\Backend\Image\Logo diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Backend/SecureTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/SecureTest.php index b6871ffcf54c6..fcf74fcd0e350 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Backend/SecureTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/SecureTest.php @@ -7,29 +7,39 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class SecureTest extends \PHPUnit_Framework_TestCase +class SecureTest extends \PHPUnit\Framework\TestCase { public function testSaveMergedJsCssMustBeCleaned() { $context = (new ObjectManager($this))->getObject(\Magento\Framework\Model\Context::class); - $resource = $this->getMock(\Magento\Config\Model\ResourceModel\Config\Data::class, [], [], '', false); + $resource = $this->createMock(\Magento\Config\Model\ResourceModel\Config\Data::class); $resource->expects($this->any())->method('addCommitCallback')->will($this->returnValue($resource)); $resourceCollection = $this->getMockBuilder(\Magento\Framework\Data\Collection\AbstractDb::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $mergeService = $this->getMock(\Magento\Framework\View\Asset\MergeService::class, [], [], '', false); - $coreRegistry = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); - $coreConfig = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $mergeService = $this->createMock(\Magento\Framework\View\Asset\MergeService::class); + $coreRegistry = $this->createMock(\Magento\Framework\Registry::class); + $coreConfig = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $cacheTypeListMock = $this->getMockBuilder(\Magento\Framework\App\Cache\TypeListInterface::class) ->disableOriginalConstructor() ->getMock(); - $model = $this->getMock( - \Magento\Config\Model\Config\Backend\Secure::class, - ['getOldValue'], - [$context, $coreRegistry, $coreConfig, $cacheTypeListMock, $mergeService, $resource, $resourceCollection] - ); + $model = $this->getMockBuilder(\Magento\Config\Model\Config\Backend\Secure::class) + ->setMethods(['getOldValue']) + ->setConstructorArgs( + [ + $context, + $coreRegistry, + $coreConfig, + $cacheTypeListMock, + $mergeService, + $resource, + $resourceCollection + ] + ) + ->getMock(); + $cacheTypeListMock->expects($this->once()) ->method('invalidate') ->with(\Magento\Framework\App\Cache\Type\Config::TYPE_IDENTIFIER) diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Backend/SerializedTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/SerializedTest.php index fdfa6e7dc3fcb..493fdf9505c4c 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Backend/SerializedTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/SerializedTest.php @@ -10,7 +10,7 @@ use Magento\Framework\Serialize\Serializer\Json; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class SerializedTest extends \PHPUnit_Framework_TestCase +class SerializedTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Config\Model\Config\Backend\Serialized */ private $serializedConfig; @@ -21,9 +21,9 @@ class SerializedTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $this->serializerMock = $this->getMock(Json::class, [], [], '', false); - $contextMock = $this->getMock(Context::class, [], [], '', false); - $eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); + $this->serializerMock = $this->createMock(Json::class); + $contextMock = $this->createMock(Context::class); + $eventManagerMock = $this->createMock(\Magento\Framework\Event\ManagerInterface::class); $contextMock->method('getEventDispatcher') ->willReturn($eventManagerMock); $this->serializedConfig = $objectManager->getObject( diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Export/CommentTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Export/CommentTest.php index 8e6390637b9a0..32f2929f4938b 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Export/CommentTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Export/CommentTest.php @@ -13,7 +13,7 @@ use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class CommentTest extends \PHPUnit_Framework_TestCase +class CommentTest extends \PHPUnit\Framework\TestCase { /** * @var DumpConfigSourceInterface|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Export/ExcludeListTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Export/ExcludeListTest.php index e530001589291..35e7db9e5cce9 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Export/ExcludeListTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Export/ExcludeListTest.php @@ -7,7 +7,7 @@ use Magento\Config\Model\Config\Export\ExcludeList; -class ExcludeListTest extends \PHPUnit_Framework_TestCase +class ExcludeListTest extends \PHPUnit\Framework\TestCase { /** * @var ExcludeList diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Export/TypePoolTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Export/TypePoolTest.php index f6da528df1043..c57b4577df662 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Export/TypePoolTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Export/TypePoolTest.php @@ -9,7 +9,7 @@ use Magento\Config\Model\Config\TypePool; use \PHPUnit_Framework_MockObject_MockObject as MockObject; -class TypePoolTest extends \PHPUnit_Framework_TestCase +class TypePoolTest extends \PHPUnit\Framework\TestCase { /** * @var ExcludeList|MockObject diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Importer/SaveProcessorTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Importer/SaveProcessorTest.php index 9e4abf1658a17..aec3a6f64fec0 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Importer/SaveProcessorTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Importer/SaveProcessorTest.php @@ -19,7 +19,7 @@ * * @see Importer */ -class SaveProcessorTest extends \PHPUnit_Framework_TestCase +class SaveProcessorTest extends \PHPUnit\Framework\TestCase { /** * @var SaveProcessor diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/ImporterTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/ImporterTest.php index e7441adc1ec88..0fdf4532462ac 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/ImporterTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/ImporterTest.php @@ -14,7 +14,6 @@ use Magento\Framework\App\State; use Magento\Framework\Config\ScopeInterface; use Magento\Framework\Flag; -use Magento\Framework\Flag\FlagResource; use Magento\Framework\FlagManager; use Magento\Framework\Stdlib\ArrayUtils; use PHPUnit_Framework_MockObject_MockObject as Mock; @@ -25,7 +24,7 @@ * @see Importer * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ImporterTest extends \PHPUnit_Framework_TestCase +class ImporterTest extends \PHPUnit\Framework\TestCase { /** * @var Importer @@ -83,14 +82,12 @@ class ImporterTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->flagManagerMock = $this->getMockBuilder(FlagManager::class) + ->setMethods(['create', 'getFlagData', 'saveFlag']) ->disableOriginalConstructor() ->getMock(); $this->flagMock = $this->getMockBuilder(Flag::class) ->disableOriginalConstructor() ->getMock(); - $this->flagResourceMock = $this->getMockBuilder(FlagResource::class) - ->disableOriginalConstructor() - ->getMock(); $this->arrayUtilsMock = $this->getMockBuilder(ArrayUtils::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/LoaderTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/LoaderTest.php index d746d40b3048d..c1e6607a9dc66 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/LoaderTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/LoaderTest.php @@ -8,7 +8,7 @@ /** * @package Magento\Config\Test\Unit\Model\Config */ -class LoaderTest extends \PHPUnit_Framework_TestCase +class LoaderTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Config\Model\Config\Loader @@ -27,21 +27,12 @@ class LoaderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_configValueFactory = $this->getMock( + $this->_configValueFactory = $this->createPartialMock( \Magento\Framework\App\Config\ValueFactory::class, - ['create', 'getCollection'], - [], - '', - false + ['create', 'getCollection'] ); $this->_model = new \Magento\Config\Model\Config\Loader($this->_configValueFactory); - $this->_configCollection = $this->getMock( - \Magento\Config\Model\ResourceModel\Config\Data\Collection::class, - [], - [], - '', - false - ); + $this->_configCollection = $this->createMock(\Magento\Config\Model\ResourceModel\Config\Data\Collection::class); $this->_configCollection->expects( $this->once() )->method( @@ -54,7 +45,7 @@ protected function setUp() $this->returnSelf() ); - $configDataMock = $this->getMock(\Magento\Framework\App\Config\Value::class, [], [], '', false); + $configDataMock = $this->createMock(\Magento\Framework\App\Config\Value::class); $this->_configValueFactory->expects( $this->once() )->method( diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Parser/CommentTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Parser/CommentTest.php index bb0fe786a214e..71732be3d23c0 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Parser/CommentTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Parser/CommentTest.php @@ -12,7 +12,7 @@ use Magento\Framework\Filesystem\Directory\ReadInterface; use PHPUnit_Framework_MockObject_MockObject as MockObject; -class CommentTest extends \PHPUnit_Framework_TestCase +class CommentTest extends \PHPUnit\Framework\TestCase { /** * @var PlaceholderInterface|MockObject diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/PathValidatorTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/PathValidatorTest.php index 5afca7a78bf21..b1d712a29cb5f 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/PathValidatorTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/PathValidatorTest.php @@ -14,7 +14,7 @@ * * @see PathValidator */ -class PathValidatorTest extends \PHPUnit_Framework_TestCase +class PathValidatorTest extends \PHPUnit\Framework\TestCase { /** * @var PathValidator diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Processor/EnvironmentPlaceholderTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Processor/EnvironmentPlaceholderTest.php index 017519c48d868..7b15a8deb638c 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Processor/EnvironmentPlaceholderTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Processor/EnvironmentPlaceholderTest.php @@ -11,7 +11,7 @@ use Magento\Framework\Stdlib\ArrayManager; use \PHPUnit_Framework_MockObject_MockObject as Mock; -class EnvironmentPlaceholderTest extends \PHPUnit_Framework_TestCase +class EnvironmentPlaceholderTest extends \PHPUnit\Framework\TestCase { /** * @var EnvironmentPlaceholder diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Reader/Source/Deployed/DocumentRootTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Reader/Source/Deployed/DocumentRootTest.php index 1313b34c7d402..3612848ec125e 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Reader/Source/Deployed/DocumentRootTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Reader/Source/Deployed/DocumentRootTest.php @@ -15,7 +15,7 @@ /** * Test class for checking settings that defined in config file */ -class DocumentRootTest extends \PHPUnit_Framework_TestCase +class DocumentRootTest extends \PHPUnit\Framework\TestCase { /** * @var Config|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Reader/Source/Deployed/SettingCheckerTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Reader/Source/Deployed/SettingCheckerTest.php index 45f18005ed151..dc3a9a3cfa4ef 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Reader/Source/Deployed/SettingCheckerTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Reader/Source/Deployed/SettingCheckerTest.php @@ -15,7 +15,7 @@ /** * Test class for checking settings that defined in config file */ -class SettingCheckerTest extends \PHPUnit_Framework_TestCase +class SettingCheckerTest extends \PHPUnit\Framework\TestCase { /** * @var Config|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/SchemaLocatorTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/SchemaLocatorTest.php index 18a6fa994bde5..e4517c3e5f583 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/SchemaLocatorTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/SchemaLocatorTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Config\Test\Unit\Model\Config; -class SchemaLocatorTest extends \PHPUnit_Framework_TestCase +class SchemaLocatorTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -19,7 +19,7 @@ class SchemaLocatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_moduleReaderMock = $this->getMock(\Magento\Framework\Module\Dir\Reader::class, [], [], '', false); + $this->_moduleReaderMock = $this->createMock(\Magento\Framework\Module\Dir\Reader::class); $this->_moduleReaderMock->expects( $this->any() diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/ScopeDefinerTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/ScopeDefinerTest.php index e17a6d0dbeee1..59a917c924131 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/ScopeDefinerTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/ScopeDefinerTest.php @@ -8,7 +8,7 @@ use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class ScopeDefinerTest extends \PHPUnit_Framework_TestCase +class ScopeDefinerTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Config\Model\Config\ScopeDefiner @@ -22,7 +22,7 @@ class ScopeDefinerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_requestMock = $this->getMock(\Magento\Framework\App\RequestInterface::class, [], [], '', false); + $this->_requestMock = $this->createMock(\Magento\Framework\App\RequestInterface::class); $objectManager = new ObjectManager($this); $this->_model = $objectManager->getObject( \Magento\Config\Model\Config\ScopeDefiner::class, diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Source/Admin/PageTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Source/Admin/PageTest.php index f34bae17b8da3..a449e3a2b3f19 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Source/Admin/PageTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Source/Admin/PageTest.php @@ -9,7 +9,7 @@ */ namespace Magento\Config\Test\Unit\Model\Config\Source\Admin; -class PageTest extends \PHPUnit_Framework_TestCase +class PageTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\Model\Menu @@ -33,19 +33,16 @@ class PageTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $logger = $this->getMock(\Psr\Log\LoggerInterface::class); + $logger = $this->createMock(\Psr\Log\LoggerInterface::class); $this->_menuModel = new \Magento\Backend\Model\Menu($logger); $this->_menuSubModel = new \Magento\Backend\Model\Menu($logger); - $this->_factoryMock = $this->getMock( + $this->_factoryMock = $this->createPartialMock( \Magento\Backend\Model\Menu\Filter\IteratorFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $itemOne = $this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false); + $itemOne = $this->createMock(\Magento\Backend\Model\Menu\Item::class); $itemOne->expects($this->any())->method('getId')->will($this->returnValue('item1')); $itemOne->expects($this->any())->method('getTitle')->will($this->returnValue('Item 1')); $itemOne->expects($this->any())->method('isAllowed')->will($this->returnValue(true)); @@ -55,7 +52,7 @@ protected function setUp() $itemOne->expects($this->any())->method('hasChildren')->will($this->returnValue(true)); $this->_menuModel->add($itemOne); - $itemTwo = $this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false); + $itemTwo = $this->createMock(\Magento\Backend\Model\Menu\Item::class); $itemTwo->expects($this->any())->method('getId')->will($this->returnValue('item2')); $itemTwo->expects($this->any())->method('getTitle')->will($this->returnValue('Item 2')); $itemTwo->expects($this->any())->method('isAllowed')->will($this->returnValue(true)); @@ -64,7 +61,7 @@ protected function setUp() $itemTwo->expects($this->any())->method('hasChildren')->will($this->returnValue(false)); $this->_menuSubModel->add($itemTwo); - $menuConfig = $this->getMock(\Magento\Backend\Model\Menu\Config::class, [], [], '', false); + $menuConfig = $this->createMock(\Magento\Backend\Model\Menu\Config::class); $menuConfig->expects($this->once())->method('getMenu')->will($this->returnValue($this->_menuModel)); $this->_model = new \Magento\Config\Model\Config\Source\Admin\Page($this->_factoryMock, $menuConfig); diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php index 81af832db88a4..e869fe8556bf7 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php @@ -8,7 +8,7 @@ namespace Magento\Config\Test\Unit\Model\Config\Source\Email; -class TemplateTest extends \PHPUnit_Framework_TestCase +class TemplateTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Config\Model\Config\Source\Email\Template @@ -32,15 +32,9 @@ class TemplateTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_coreRegistry = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false, false); - $this->_emailConfig = $this->getMock(\Magento\Email\Model\Template\Config::class, [], [], '', false); - $this->_templatesFactory = $this->getMock( - \Magento\Email\Model\ResourceModel\Template\CollectionFactory::class, - [], - [], - '', - false - ); + $this->_coreRegistry = $this->createMock(\Magento\Framework\Registry::class); + $this->_emailConfig = $this->createMock(\Magento\Email\Model\Template\Config::class); + $this->_templatesFactory = $this->createMock(\Magento\Email\Model\ResourceModel\Template\CollectionFactory::class); $this->_model = new \Magento\Config\Model\Config\Source\Email\Template( $this->_coreRegistry, $this->_templatesFactory, @@ -50,7 +44,7 @@ protected function setUp() public function testToOptionArray() { - $collection = $this->getMock(\Magento\Email\Model\ResourceModel\Template\Collection::class, [], [], '', false); + $collection = $this->createMock(\Magento\Email\Model\ResourceModel\Template\Collection::class); $collection->expects( $this->once() )->method( diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Source/Locale/TimezoneTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Source/Locale/TimezoneTest.php index b15ed679d3e51..314a522024161 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Source/Locale/TimezoneTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Source/Locale/TimezoneTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Config\Test\Unit\Model\Config\Source\Locale; -class TimezoneTest extends \PHPUnit_Framework_TestCase +class TimezoneTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/AbstractElementTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/AbstractElementTest.php index 64b90acf1f366..51432366bb441 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/AbstractElementTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/AbstractElementTest.php @@ -5,11 +5,11 @@ */ namespace Magento\Config\Test\Unit\Model\Config\Structure; -use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Config\Model\Config\Structure\ElementVisibilityInterface; +use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -class AbstractElementTest extends \PHPUnit_Framework_TestCase +class AbstractElementTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Config\Model\Config\Structure\AbstractElement @@ -35,13 +35,10 @@ protected function setUp() { $this->elementVisibilityMock = $this->getMockBuilder(ElementVisibilityInterface::class) ->getMockForAbstractClass(); - $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); - $this->moduleManagerMock = $this->getMock( + $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManager::class); + $this->moduleManagerMock = $this->createPartialMock( \Magento\Framework\Module\Manager::class, - ['isOutputEnabled'], - [], - '', - false + ['isOutputEnabled'] ); $this->_model = $this->getMockForAbstractClass( diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/ConcealInProductionConfigListTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/ConcealInProductionConfigListTest.php index fca09fed309e2..5cad923264e00 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/ConcealInProductionConfigListTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/ConcealInProductionConfigListTest.php @@ -8,7 +8,7 @@ use Magento\Config\Model\Config\Structure\ConcealInProductionConfigList; use Magento\Framework\App\State; -class ConcealInProductionConfigListTest extends \PHPUnit_Framework_TestCase +class ConcealInProductionConfigListTest extends \PHPUnit\Framework\TestCase { /** * @var State|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/ConverterTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/ConverterTest.php index 50c61944084dc..2b3417836444e 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/ConverterTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/ConverterTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Config\Test\Unit\Model\Config\Structure; -class ConverterTest extends \PHPUnit_Framework_TestCase +class ConverterTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Config\Model\Config\Structure\Converter @@ -14,23 +14,9 @@ class ConverterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $factoryMock = $this->getMock( - \Magento\Config\Model\Config\Structure\Mapper\Factory::class, - [], - [], - '', - false, - false - ); + $factoryMock = $this->createMock(\Magento\Config\Model\Config\Structure\Mapper\Factory::class); - $mapperMock = $this->getMock( - \Magento\Config\Model\Config\Structure\Mapper\Dependencies::class, - [], - [], - '', - false, - false - ); + $mapperMock = $this->createMock(\Magento\Config\Model\Config\Structure\Mapper\Dependencies::class); $mapperMock->expects($this->any())->method('map')->will($this->returnArgument(0)); $factoryMock->expects($this->any())->method('create')->will($this->returnValue($mapperMock)); diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/AbstractCompositeTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/AbstractCompositeTest.php index 2ce5c1789d8e2..57d6fa28a7822 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/AbstractCompositeTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/AbstractCompositeTest.php @@ -8,7 +8,7 @@ use Magento\Config\Model\Config\Structure\ElementVisibilityInterface; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -class AbstractCompositeTest extends \PHPUnit_Framework_TestCase +class AbstractCompositeTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Config\Model\Config\Structure\Element\AbstractComposite @@ -51,15 +51,9 @@ protected function setUp() { $this->elementVisibilityMock = $this->getMockBuilder(ElementVisibilityInterface::class) ->getMockForAbstractClass(); - $this->_iteratorMock = $this->getMock( - \Magento\Config\Model\Config\Structure\Element\Iterator::class, - [], - [], - '', - false - ); - $this->_storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); - $this->moduleManagerMock = $this->getMock(\Magento\Framework\Module\Manager::class, [], [], '', false); + $this->_iteratorMock = $this->createMock(\Magento\Config\Model\Config\Structure\Element\Iterator::class); + $this->_storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManager::class); + $this->moduleManagerMock = $this->createMock(\Magento\Framework\Module\Manager::class); $this->_model = $this->getMockForAbstractClass( \Magento\Config\Model\Config\Structure\Element\AbstractComposite::class, [$this->_storeManagerMock, $this->moduleManagerMock, $this->_iteratorMock] diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/Dependency/FieldTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/Dependency/FieldTest.php index 25982c3713337..30c567fb490e6 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/Dependency/FieldTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/Dependency/FieldTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Config\Test\Unit\Model\Config\Structure\Element\Dependency; -class FieldTest extends \PHPUnit_Framework_TestCase +class FieldTest extends \PHPUnit\Framework\TestCase { /**#@+ * SUT values diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/Dependency/MapperTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/Dependency/MapperTest.php index bb37ad9249908..1c758bfcbefaa 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/Dependency/MapperTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/Dependency/MapperTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Config\Test\Unit\Model\Config\Structure\Element\Dependency; -class MapperTest extends \PHPUnit_Framework_TestCase +class MapperTest extends \PHPUnit\Framework\TestCase { /** * Field prefix diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/FieldTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/FieldTest.php index b9bdc3d84cea5..b45cea0f4b7e7 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/FieldTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/FieldTest.php @@ -15,7 +15,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class FieldTest extends \PHPUnit_Framework_TestCase +class FieldTest extends \PHPUnit\Framework\TestCase { const FIELD_TEST_CONSTANT = "field test constant"; @@ -53,41 +53,11 @@ protected function setUp() { $objectManager = new ObjectManager($this); - $this->_backendFactoryMock = $this->getMock( - \Magento\Config\Model\Config\BackendFactory::class, - [], - [], - '', - false - ); - $this->_sourceFactoryMock = $this->getMock( - \Magento\Config\Model\Config\SourceFactory::class, - [], - [], - '', - false - ); - $this->_commentFactoryMock = $this->getMock( - \Magento\Config\Model\Config\CommentFactory::class, - [], - [], - '', - false - ); - $this->_blockFactoryMock = $this->getMock( - \Magento\Framework\View\Element\BlockFactory::class, - [], - [], - '', - false - ); - $this->_depMapperMock = $this->getMock( - \Magento\Config\Model\Config\Structure\Element\Dependency\Mapper::class, - [], - [], - '', - false - ); + $this->_backendFactoryMock = $this->createMock(\Magento\Config\Model\Config\BackendFactory::class); + $this->_sourceFactoryMock = $this->createMock(\Magento\Config\Model\Config\SourceFactory::class); + $this->_commentFactoryMock = $this->createMock(\Magento\Config\Model\Config\CommentFactory::class); + $this->_blockFactoryMock = $this->createMock(\Magento\Framework\View\Element\BlockFactory::class); + $this->_depMapperMock = $this->createMock(\Magento\Config\Model\Config\Structure\Element\Dependency\Mapper::class); $this->_model = $objectManager->getObject( \Magento\Config\Model\Config\Structure\Element\Field::class, @@ -133,7 +103,7 @@ public function testGetCommentRetrievesCommentFromCommentModelIfItsProvided() { $config = ['comment' => ['model' => 'Model_Name']]; $this->_model->setData($config, 'scope'); - $commentModelMock = $this->getMock(\Magento\Config\Model\Config\CommentInterface::class); + $commentModelMock = $this->createMock(\Magento\Config\Model\Config\CommentInterface::class); $commentModelMock->expects( $this->once() )->method( @@ -164,7 +134,7 @@ public function testGetTooltipRetunrsTranslatedAttributeIfNoBlockIsProvided() public function testGetTooltipCreatesTooltipBlock() { $this->_model->setData(['tooltip_block' => \Magento\Config\Block\Tooltip::class], 'scope'); - $tooltipBlock = $this->getMock(\Magento\Framework\View\Element\BlockInterface::class); + $tooltipBlock = $this->createMock(\Magento\Framework\View\Element\BlockInterface::class); $tooltipBlock->expects($this->once())->method('toHtml')->will($this->returnValue('tooltip block')); $this->_blockFactoryMock->expects( $this->once() @@ -266,13 +236,7 @@ public function testPopulateInput() 'someArr' => ['testVar' => 'testVal'], ]; $this->_model->setData($params, 'scope'); - $elementMock = $this->getMock( - \Magento\Framework\Data\Form\Element\Text::class, - ['setOriginalData'], - [], - '', - false - ); + $elementMock = $this->createPartialMock(\Magento\Framework\Data\Form\Element\Text::class, ['setOriginalData']); unset($params['someArr']); $elementMock->expects($this->once())->method('setOriginalData')->with($params); $this->_model->populateInput($elementMock); @@ -343,7 +307,7 @@ public function testGetOptionsWithConstantValOptions() public function testGetOptionsUsesOptionsInterfaceIfNoMethodIsProvided() { $this->_model->setData(['source_model' => 'Source_Model_Name'], 'scope'); - $sourceModelMock = $this->getMock(\Magento\Framework\Option\ArrayInterface::class); + $sourceModelMock = $this->createMock(\Magento\Framework\Option\ArrayInterface::class); $this->_sourceFactoryMock->expects( $this->once() )->method( @@ -372,7 +336,7 @@ public function testGetOptionsUsesProvidedMethodOfSourceModel() ['source_model' => 'Source_Model_Name::retrieveElements', 'path' => 'path', 'type' => 'multiselect'], 'scope' ); - $sourceModelMock = $this->getMock(\Magento\Framework\DataObject::class, ['setPath', 'retrieveElements']); + $sourceModelMock = $this->createPartialMock(\Magento\Framework\DataObject::class, ['setPath', 'retrieveElements']); $this->_sourceFactoryMock->expects( $this->once() )->method( @@ -394,7 +358,7 @@ public function testGetOptionsParsesResultOfProvidedMethodOfSourceModelIfTypeIsN ['source_model' => 'Source_Model_Name::retrieveElements', 'path' => 'path', 'type' => 'select'], 'scope' ); - $sourceModelMock = $this->getMock(\Magento\Framework\DataObject::class, ['setPath', 'retrieveElements']); + $sourceModelMock = $this->createPartialMock(\Magento\Framework\DataObject::class, ['setPath', 'retrieveElements']); $this->_sourceFactoryMock->expects( $this->once() )->method( diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/FlyweightFactoryTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/FlyweightFactoryTest.php index 6c1d7683e3e21..c3988aec154bc 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/FlyweightFactoryTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/FlyweightFactoryTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Config\Test\Unit\Model\Config\Structure\Element; -class FlyweightFactoryTest extends \PHPUnit_Framework_TestCase +class FlyweightFactoryTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Config\Model\Config\Structure\Element\FlyweightFactory @@ -19,7 +19,7 @@ class FlyweightFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->_objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); $this->_model = new \Magento\Config\Model\Config\Structure\Element\FlyweightFactory( $this->_objectManagerMock ); diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/Group/ProxyTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/Group/ProxyTest.php index 4577f3ed5bc11..4fa1da3bd63a1 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/Group/ProxyTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/Group/ProxyTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Config\Test\Unit\Model\Config\Structure\Element\Group; -class ProxyTest extends \PHPUnit_Framework_TestCase +class ProxyTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Config\Model\Config\Structure\Element\Group\Proxy @@ -19,7 +19,7 @@ class ProxyTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $this->_objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); $this->_model = new \Magento\Config\Model\Config\Structure\Element\Group\Proxy($this->_objectManagerMock); } @@ -31,13 +31,7 @@ protected function tearDown() public function testProxyInitializesProxiedObjectOnFirstCall() { - $groupMock = $this->getMock( - \Magento\Config\Model\Config\Structure\Element\Group::class, - [], - [], - '', - false - ); + $groupMock = $this->createMock(\Magento\Config\Model\Config\Structure\Element\Group::class); $groupMock->expects($this->once())->method('setData'); $groupMock->expects($this->once())->method('getId')->will($this->returnValue('group_id')); diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/GroupTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/GroupTest.php index d14d26d985820..a2d68189e95ca 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/GroupTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/GroupTest.php @@ -7,7 +7,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class GroupTest extends \PHPUnit_Framework_TestCase +class GroupTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Config\Model\Config\Structure\Element\Group @@ -27,19 +27,9 @@ class GroupTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $this->_cloneFactoryMock = $this->getMock( - \Magento\Config\Model\Config\BackendClone\Factory::class, - [], - [], - '', - false - ); - $this->_depMapperMock = $this->getMock( - \Magento\Config\Model\Config\Structure\Element\Dependency\Mapper::class, - [], - [], - '', - false + $this->_cloneFactoryMock = $this->createMock(\Magento\Config\Model\Config\BackendClone\Factory::class); + $this->_depMapperMock = $this->createMock( + \Magento\Config\Model\Config\Structure\Element\Dependency\Mapper::class ); $this->_model = $objectManager->getObject( @@ -79,13 +69,9 @@ public function testGetCloneModelThrowsExceptionIfNoSourceModelIsSet() public function testGetCloneModelCreatesCloneModel() { - $cloneModel = $this->getMock(\Magento\Framework\App\Config\ValueInterface::class, [], [], '', false); - $this->_depMapperMock = $this->getMock( - \Magento\Config\Model\Config\Structure\Element\Dependency\Mapper::class, - [], - [], - '', - false + $cloneModel = $this->createMock(\Magento\Framework\App\Config\ValueInterface::class); + $this->_depMapperMock = $this->createMock( + \Magento\Config\Model\Config\Structure\Element\Dependency\Mapper::class ); $this->_cloneFactoryMock->expects( $this->once() @@ -102,12 +88,9 @@ public function testGetCloneModelCreatesCloneModel() public function testGetFieldsetSetsOnlyNonArrayValuesToFieldset() { - $fieldsetMock = $this->getMock( + $fieldsetMock = $this->createPartialMock( \Magento\Framework\Data\Form\Element\Fieldset::class, - ['setOriginalData'], - [], - '', - false + ['setOriginalData'] ); $fieldsetMock->expects( $this->once() diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/Iterator/FieldTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/Iterator/FieldTest.php index 9a5058d01fc38..9246ced39b233 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/Iterator/FieldTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/Iterator/FieldTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Config\Test\Unit\Model\Config\Structure\Element\Iterator; -class FieldTest extends \PHPUnit_Framework_TestCase +class FieldTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Config\Model\Config\Structure\Element\Iterator\Field @@ -24,20 +24,8 @@ class FieldTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_fieldMock = $this->getMock( - \Magento\Config\Model\Config\Structure\Element\Field::class, - [], - [], - '', - false - ); - $this->_groupMock = $this->getMock( - \Magento\Config\Model\Config\Structure\Element\Group::class, - [], - [], - '', - false - ); + $this->_fieldMock = $this->createMock(\Magento\Config\Model\Config\Structure\Element\Field::class); + $this->_groupMock = $this->createMock(\Magento\Config\Model\Config\Structure\Element\Group::class); $this->_model = new \Magento\Config\Model\Config\Structure\Element\Iterator\Field( $this->_groupMock, $this->_fieldMock diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/IteratorTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/IteratorTest.php index b821152d8a1ed..1a0f3d03b060c 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/IteratorTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/IteratorTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Config\Test\Unit\Model\Config\Structure\Element; -class IteratorTest extends \PHPUnit_Framework_TestCase +class IteratorTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Config\Model\Config\Structure\Element\Iterator @@ -20,13 +20,7 @@ class IteratorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $elementData = ['group1' => ['id' => 1], 'group2' => ['id' => 2], 'group3' => ['id' => 3]]; - $this->_flyweightMock = $this->getMock( - \Magento\Config\Model\Config\Structure\Element\Group::class, - [], - [], - '', - false - ); + $this->_flyweightMock = $this->createMock(\Magento\Config\Model\Config\Structure\Element\Group::class); $this->_model = new \Magento\Config\Model\Config\Structure\Element\Iterator($this->_flyweightMock); $this->_model->setElements($elementData, 'scope'); @@ -69,13 +63,7 @@ public function testIteratorSkipsNonValidElements() */ public function testIsLast($elementId, $result) { - $elementMock = $this->getMock( - \Magento\Config\Model\Config\Structure\Element\Field::class, - [], - [], - '', - false - ); + $elementMock = $this->createMock(\Magento\Config\Model\Config\Structure\Element\Field::class); $elementMock->expects($this->once())->method('getId')->will($this->returnValue($elementId)); $this->assertEquals($result, $this->_model->isLast($elementMock)); } diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/SectionTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/SectionTest.php index 91d6ad8f51ac9..e9be51722cbe0 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/SectionTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/SectionTest.php @@ -8,7 +8,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Config\Model\Config\Structure\ElementVisibilityInterface; -class SectionTest extends \PHPUnit_Framework_TestCase +class SectionTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Config\Model\Config\Structure\Element\Section @@ -35,8 +35,8 @@ protected function setUp() $objectManager = new ObjectManager($this); $this->elementVisibilityMock = $this->getMockBuilder(ElementVisibilityInterface::class) ->getMockForAbstractClass(); - $this->_storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); - $this->_authorizationMock = $this->getMock(\Magento\Framework\AuthorizationInterface::class); + $this->_storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManager::class); + $this->_authorizationMock = $this->createMock(\Magento\Framework\AuthorizationInterface::class); $this->_model = $objectManager->getObject( \Magento\Config\Model\Config\Structure\Element\Section::class, diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/TabTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/TabTest.php index 232c839fd58a1..898c458218e63 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/TabTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/TabTest.php @@ -7,7 +7,7 @@ use \Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class TabTest extends \PHPUnit_Framework_TestCase +class TabTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Config\Model\Config\Structure\Element\Tab @@ -21,13 +21,7 @@ class TabTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_iteratorMock = $this->getMock( - \Magento\Config\Model\Config\Structure\Element\Iterator\Field::class, - [], - [], - '', - false - ); + $this->_iteratorMock = $this->createMock(\Magento\Config\Model\Config\Structure\Element\Iterator\Field::class); $this->_model = (new ObjectManager($this))->getObject( \Magento\Config\Model\Config\Structure\Element\Tab::class, diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/ElementVisibilityCompositeTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/ElementVisibilityCompositeTest.php index 4d8a70fdadcb6..a3bdb6f008f1d 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/ElementVisibilityCompositeTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/ElementVisibilityCompositeTest.php @@ -8,7 +8,7 @@ use Magento\Config\Model\Config\Structure\ElementVisibilityComposite; use Magento\Config\Model\Config\Structure\ElementVisibilityInterface; -class ElementVisibilityCompositeTest extends \PHPUnit_Framework_TestCase +class ElementVisibilityCompositeTest extends \PHPUnit\Framework\TestCase { /** * @var ElementVisibilityComposite diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/DependenciesTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/DependenciesTest.php index a37e8bc1b1f61..1ba22b029a476 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/DependenciesTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/DependenciesTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Config\Test\Unit\Model\Config\Structure\Mapper; -class DependenciesTest extends \PHPUnit_Framework_TestCase +class DependenciesTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Config\Model\Config\Structure\Mapper\Dependencies diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/ExtendsTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/ExtendsTest.php index bb4840ce044c3..95e8246c6a3d3 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/ExtendsTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/ExtendsTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Config\Test\Unit\Model\Config\Structure\Mapper; -class ExtendsTest extends \PHPUnit_Framework_TestCase +class ExtendsTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Config\Model\Config\Structure\Mapper\ExtendsMapper @@ -20,7 +20,7 @@ protected function setUp() } /** - * @dataProvider testMapDataProvider + * @dataProvider mapDataProvider * @param array $sourceData * @param array $resultData */ @@ -31,7 +31,7 @@ public function testMap($sourceData, $resultData) public function testMapWithBadPath() { - $this->setExpectedException( + $this->expectException( 'InvalidArgumentException', 'Invalid path in extends attribute of config/system/sections/section1 node' ); @@ -44,7 +44,7 @@ public function testMapWithBadPath() $this->_sut->map($sourceData); } - public function testMapDataProvider() + public function mapDataProvider() { return [ [[], []], diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/Helper/RelativePathConverterTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/Helper/RelativePathConverterTest.php index 143bdabd2685f..c671a5326c4de 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/Helper/RelativePathConverterTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/Helper/RelativePathConverterTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Config\Test\Unit\Model\Config\Structure\Mapper\Helper; -class RelativePathConverterTest extends \PHPUnit_Framework_TestCase +class RelativePathConverterTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Config\Model\Config\Structure\Mapper\Helper\RelativePathConverter @@ -24,23 +24,23 @@ public function testConvertWithInvalidRelativePath() $exceptionMessage = sprintf('Invalid relative path %s in %s node', $relativePath, $nodePath); - $this->setExpectedException('InvalidArgumentException', $exceptionMessage); + $this->expectException('InvalidArgumentException', $exceptionMessage); $this->_sut->convert($nodePath, $relativePath); } /** - * @dataProvider testConvertWithInvalidArgumentsDataProvider + * @dataProvider convertWithInvalidArgumentsDataProvider * @param string $nodePath * @param string $relativePath */ public function testConvertWithInvalidArguments($nodePath, $relativePath) { - $this->setExpectedException('InvalidArgumentException', 'Invalid arguments'); + $this->expectException('InvalidArgumentException', 'Invalid arguments'); $this->_sut->convert($nodePath, $relativePath); } /** - * @dataProvider testConvertDataProvider + * @dataProvider convertDataProvider * @param string $nodePath * @param string $relativePath * @param string $result @@ -50,12 +50,12 @@ public function testConvert($nodePath, $relativePath, $result) $this->assertEquals($result, $this->_sut->convert($nodePath, $relativePath)); } - public function testConvertWithInvalidArgumentsDataProvider() + public function convertWithInvalidArgumentsDataProvider() { return [['', ''], ['some/node', ''], ['', 'some/node']]; } - public function testConvertDataProvider() + public function convertDataProvider() { return [ ['currentNode', 'relativeNode', 'relativeNode'], diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/PathTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/PathTest.php index a1d85b9c8a352..7f6590a88f565 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/PathTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/PathTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Config\Test\Unit\Model\Config\Structure\Mapper; -class PathTest extends \PHPUnit_Framework_TestCase +class PathTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Config\Model\Config\Structure\Mapper\Path diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/SortingTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/SortingTest.php index d3656922346eb..718cf47b296d4 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/SortingTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Mapper/SortingTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Config\Test\Unit\Model\Config\Structure\Mapper; -class SortingTest extends \PHPUnit_Framework_TestCase +class SortingTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Config\Model\Config\Structure\Mapper\Sorting diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/ReaderTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/ReaderTest.php index 26a034a258279..3b076b219109d 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/ReaderTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/ReaderTest.php @@ -8,7 +8,7 @@ /** * Class ReaderTest */ -class ReaderTest extends \PHPUnit_Framework_TestCase +class ReaderTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Config\Model\Config\Structure\Reader diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/StructureTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/StructureTest.php index 1bb1c3bf22a9a..e67ea6ec0fba1 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/StructureTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/StructureTest.php @@ -18,7 +18,7 @@ * * @see Structure */ -class StructureTest extends \PHPUnit_Framework_TestCase +class StructureTest extends \PHPUnit\Framework\TestCase { /** * @var Structure|Mock diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/XsdTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/XsdTest.php index 0843d589d4428..e46aa9a9d834a 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/XsdTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/XsdTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Config\Test\Unit\Model\Config; -class XsdTest extends \PHPUnit_Framework_TestCase +class XsdTest extends \PHPUnit\Framework\TestCase { /** * Path to xsd schema file diff --git a/app/code/Magento/Config/Test/Unit/Model/ConfigTest.php b/app/code/Magento/Config/Test/Unit/Model/ConfigTest.php index 203909c01edc6..2832e8e54e5f6 100644 --- a/app/code/Magento/Config/Test/Unit/Model/ConfigTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/ConfigTest.php @@ -8,7 +8,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ConfigTest extends \PHPUnit_Framework_TestCase +class ConfigTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Config\Model\Config @@ -62,27 +62,12 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_eventManagerMock = $this->getMock( - \Magento\Framework\Event\ManagerInterface::class, - [], - [], - '', - false - ); - $this->_structureReaderMock = $this->getMock( + $this->_eventManagerMock = $this->createMock(\Magento\Framework\Event\ManagerInterface::class); + $this->_structureReaderMock = $this->createPartialMock( \Magento\Config\Model\Config\Structure\Reader::class, - [], - [], - '', - false - ); - $this->_configStructure = $this->getMock( - \Magento\Config\Model\Config\Structure::class, - [], - [], - '', - false + ['getConfiguration'] ); + $this->_configStructure = $this->createMock(\Magento\Config\Model\Config\Structure::class); $this->_structureReaderMock->expects( $this->any() @@ -92,28 +77,16 @@ protected function setUp() $this->returnValue($this->_configStructure) ); - $this->_transFactoryMock = $this->getMock( + $this->_transFactoryMock = $this->createPartialMock( \Magento\Framework\DB\TransactionFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->_appConfigMock = $this->getMock(\Magento\Framework\App\Config\ReinitableConfigInterface::class); - $this->_configLoaderMock = $this->getMock( + $this->_appConfigMock = $this->createMock(\Magento\Framework\App\Config\ReinitableConfigInterface::class); + $this->_configLoaderMock = $this->createPartialMock( \Magento\Config\Model\Config\Loader::class, - ['getConfigByPath'], - [], - '', - false - ); - $this->_dataFactoryMock = $this->getMock( - \Magento\Framework\App\Config\ValueFactory::class, - [], - [], - '', - false + ['getConfigByPath'] ); + $this->_dataFactoryMock = $this->createMock(\Magento\Framework\App\Config\ValueFactory::class); $this->_storeManager = $this->getMockForAbstractClass(\Magento\Store\Model\StoreManagerInterface::class); @@ -148,7 +121,7 @@ public function testSaveEmptiesNonSetArguments() public function testSaveToCheckAdminSystemConfigChangedSectionEvent() { - $transactionMock = $this->getMock(\Magento\Framework\DB\Transaction::class, [], [], '', false); + $transactionMock = $this->createMock(\Magento\Framework\DB\Transaction::class); $this->_transFactoryMock->expects($this->any())->method('create')->will($this->returnValue($transactionMock)); @@ -178,7 +151,7 @@ public function testSaveToCheckAdminSystemConfigChangedSectionEvent() public function testSaveToCheckScopeDataSet() { - $transactionMock = $this->getMock(\Magento\Framework\DB\Transaction::class, [], [], '', false); + $transactionMock = $this->createMock(\Magento\Framework\DB\Transaction::class); $this->_transFactoryMock->expects($this->any())->method('create')->will($this->returnValue($transactionMock)); @@ -202,9 +175,9 @@ public function testSaveToCheckScopeDataSet() $this->arrayHasKey('store') ); - $group = $this->getMock(\Magento\Config\Model\Config\Structure\Element\Group::class, [], [], '', false); + $group = $this->createMock(\Magento\Config\Model\Config\Structure\Element\Group::class); - $field = $this->getMock(\Magento\Config\Model\Config\Structure\Element\Field::class, [], [], '', false); + $field = $this->createMock(\Magento\Config\Model\Config\Structure\Element\Field::class); $this->_configStructure->expects( $this->at(0) @@ -226,7 +199,7 @@ public function testSaveToCheckScopeDataSet() $this->returnValue($field) ); - $website = $this->getMock(\Magento\Store\Model\Website::class, [], [], '', false); + $website = $this->createMock(\Magento\Store\Model\Website::class); $website->expects($this->any())->method('getCode')->will($this->returnValue('website_code')); $this->_storeManager->expects($this->any())->method('getWebsite')->will($this->returnValue($website)); $this->_storeManager->expects($this->any())->method('getWebsites')->will($this->returnValue([$website])); @@ -236,12 +209,9 @@ public function testSaveToCheckScopeDataSet() $this->_model->setGroups(['1' => ['fields' => ['key' => ['data']]]]); - $backendModel = $this->getMock( + $backendModel = $this->createPartialMock( \Magento\Framework\App\Config\Value::class, - ['setPath', 'addData', '__sleep', '__wakeup'], - [], - '', - false + ['setPath', 'addData', '__sleep', '__wakeup'] ); $backendModel->expects( $this->once() @@ -310,7 +280,7 @@ public function testSetDataByPathEmpty() public function testSetDataByPathWrongDepth($path, $expectedException) { $expectedException = 'Allowed depth of configuration is 3 (
//). ' . $expectedException; - $this->setExpectedException('\UnexpectedValueException', $expectedException); + $this->expectException('\UnexpectedValueException', $expectedException); $value = 'value'; $this->_model->setDataByPath($path, $value); } diff --git a/app/code/Magento/Config/Test/Unit/Model/Placeholder/EnvironmentTest.php b/app/code/Magento/Config/Test/Unit/Model/Placeholder/EnvironmentTest.php index b25aeae336860..8217ff09c0541 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Placeholder/EnvironmentTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Placeholder/EnvironmentTest.php @@ -14,7 +14,7 @@ /** * Class EnvironmentTest */ -class EnvironmentTest extends \PHPUnit_Framework_TestCase +class EnvironmentTest extends \PHPUnit\Framework\TestCase { /** * @var Environment diff --git a/app/code/Magento/Config/Test/Unit/Model/Placeholder/PlaceholderFactoryTest.php b/app/code/Magento/Config/Test/Unit/Model/Placeholder/PlaceholderFactoryTest.php index 98e4950bf7719..17e47ee8be363 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Placeholder/PlaceholderFactoryTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Placeholder/PlaceholderFactoryTest.php @@ -9,7 +9,7 @@ use Magento\Config\Model\Placeholder\PlaceholderFactory; use Magento\Framework\ObjectManagerInterface; -class PlaceholderFactoryTest extends \PHPUnit_Framework_TestCase +class PlaceholderFactoryTest extends \PHPUnit\Framework\TestCase { /** * @var PlaceholderFactory diff --git a/app/code/Magento/Config/Test/Unit/Model/PreparedValueFactoryTest.php b/app/code/Magento/Config/Test/Unit/Model/PreparedValueFactoryTest.php index e883f17dfbe4d..1f786f8aca37e 100644 --- a/app/code/Magento/Config/Test/Unit/Model/PreparedValueFactoryTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/PreparedValueFactoryTest.php @@ -25,7 +25,7 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ -class PreparedValueFactoryTest extends \PHPUnit_Framework_TestCase +class PreparedValueFactoryTest extends \PHPUnit\Framework\TestCase { /** * @var StructureFactory|Mock diff --git a/app/code/Magento/ConfigurableImportExport/Model/Export/RowCustomizer.php b/app/code/Magento/ConfigurableImportExport/Model/Export/RowCustomizer.php index 322d272599b06..58462b873d8b1 100644 --- a/app/code/Magento/ConfigurableImportExport/Model/Export/RowCustomizer.php +++ b/app/code/Magento/ConfigurableImportExport/Model/Export/RowCustomizer.php @@ -13,11 +13,29 @@ class RowCustomizer implements RowCustomizerInterface { + /** + * Header column for Configurable Product variations + */ + const CONFIGURABLE_VARIATIONS_COLUMN = 'configurable_variations'; + + /** + * Header column for Configurable Product variation labels + */ + const CONFIGURABLE_VARIATIONS_LABELS_COLUMN = 'configurable_variation_labels'; + /** * @var array */ protected $configurableData = []; + /** + * @var string[] + */ + private $configurableColumns = [ + self::CONFIGURABLE_VARIATIONS_COLUMN, + self::CONFIGURABLE_VARIATIONS_LABELS_COLUMN + ]; + /** * Prepare configurable data for export * @@ -54,8 +72,11 @@ public function prepareData($collection, $productIds) } $this->configurableData[$product->getId()] = [ - 'configurable_variations' => implode(ImportProduct::PSEUDO_MULTI_LINE_SEPARATOR, $variations), - 'configurable_variation_labels' => implode( + self::CONFIGURABLE_VARIATIONS_COLUMN => implode( + ImportProduct::PSEUDO_MULTI_LINE_SEPARATOR, + $variations + ), + self::CONFIGURABLE_VARIATIONS_LABELS_COLUMN => implode( Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $variationsLabels ) @@ -71,17 +92,7 @@ public function prepareData($collection, $productIds) */ public function addHeaderColumns($columns) { - // have we merge configurable products data - if (!empty($this->configurableData)) { - $columns = array_merge( - $columns, - [ - 'configurable_variations', - 'configurable_variation_labels', - ] - ); - } - return $columns; + return array_merge($columns, $this->configurableColumns); } /** diff --git a/app/code/Magento/ConfigurableImportExport/Model/Import/Product/Type/Configurable.php b/app/code/Magento/ConfigurableImportExport/Model/Import/Product/Type/Configurable.php index 5a030581f4301..718a7dba73eb2 100644 --- a/app/code/Magento/ConfigurableImportExport/Model/Import/Product/Type/Configurable.php +++ b/app/code/Magento/ConfigurableImportExport/Model/Import/Product/Type/Configurable.php @@ -141,7 +141,7 @@ class Configurable extends \Magento\CatalogImportExport\Model\Import\Product\Typ * Instance of database adapter. * * @var \Magento\Framework\DB\Adapter\AdapterInterface - * @deprecated + * @deprecated 100.2.0 */ protected $_connection; diff --git a/app/code/Magento/ConfigurableImportExport/Test/Unit/Model/Export/RowCustomizerTest.php b/app/code/Magento/ConfigurableImportExport/Test/Unit/Model/Export/RowCustomizerTest.php index 8462b5a702dc4..f877237a2ba66 100644 --- a/app/code/Magento/ConfigurableImportExport/Test/Unit/Model/Export/RowCustomizerTest.php +++ b/app/code/Magento/ConfigurableImportExport/Test/Unit/Model/Export/RowCustomizerTest.php @@ -13,7 +13,7 @@ use Magento\CatalogImportExport\Model\Import\Product as ImportProduct; use Magento\ImportExport\Model\Import; -class RowCustomizerTest extends \PHPUnit_Framework_TestCase +class RowCustomizerTest extends \PHPUnit\Framework\TestCase { /** * @var ExportRowCustomizer diff --git a/app/code/Magento/ConfigurableImportExport/Test/Unit/Model/Import/Product/Type/ConfigurableTest.php b/app/code/Magento/ConfigurableImportExport/Test/Unit/Model/Import/Product/Type/ConfigurableTest.php index 8f142d9c82fe9..f6912fe8b6d6c 100644 --- a/app/code/Magento/ConfigurableImportExport/Test/Unit/Model/Import/Product/Type/ConfigurableTest.php +++ b/app/code/Magento/ConfigurableImportExport/Test/Unit/Model/Import/Product/Type/ConfigurableTest.php @@ -6,7 +6,7 @@ namespace Magento\ConfigurableImportExport\Test\Unit\Model\Import\Product\Type; -use \Magento\ConfigurableImportExport; +use Magento\ConfigurableImportExport; /** * Class ConfigurableTest @@ -84,19 +84,13 @@ protected function setUp() { parent::setUp(); - $this->setCollectionFactory = $this->getMock( + $this->setCollectionFactory = $this->createPartialMock( \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->setCollection = $this->getMock( + $this->setCollection = $this->createPartialMock( \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection::class, - ['setEntityTypeFilter'], - [], - '', - false + ['setEntityTypeFilter'] ); $this->setCollectionFactory->expects($this->any())->method('create')->will( @@ -113,31 +107,23 @@ protected function setUp() ->method('setEntityTypeFilter') ->will($this->returnValue([$item])); - $this->attrCollectionFactory = $this->getMock( + $this->attrCollectionFactory = $this->createPartialMock( \Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->attrCollection = $this->getMock( + $this->attrCollection = $this->createPartialMock( \Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection::class, - ['setAttributeSetFilter'], - [], - '', - false + ['setAttributeSetFilter'] ); $superAttributes = []; foreach ($this->_getSuperAttributes() as $superAttribute) { - $item = $this->getMock( - \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class, - ['isStatic'], - $superAttribute, - '', - false - ); + $item = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class) + ->setMethods(['isStatic']) + ->disableOriginalConstructor() + ->setConstructorArgs($superAttribute) + ->getMock(); $item->setData($superAttribute); $item->method('isStatic') ->will($this->returnValue(false)); @@ -152,9 +138,7 @@ protected function setUp() ->method('setAttributeSetFilter') ->will($this->returnValue($superAttributes)); - $this->_entityModel = $this->getMock( - \Magento\CatalogImportExport\Model\Import\Product::class, - [ + $this->_entityModel = $this->createPartialMock(\Magento\CatalogImportExport\Model\Import\Product::class, [ 'getNewSku', 'getOldSku', 'getNextBunch', @@ -163,11 +147,7 @@ protected function setUp() 'getAttrSetIdToName', 'getErrorAggregator', 'getAttributeOptions' - ], - [], - '', - false - ); + ]); $this->_entityModel->method('getErrorAggregator')->willReturn($this->getErrorAggregatorObject()); $this->params = [ @@ -175,9 +155,7 @@ protected function setUp() 1 => 'configurable' ]; - $this->_connection = $this->getMock( - \Magento\Framework\DB\Adapter\Pdo\Mysql::class, - [ + $this->_connection = $this->createPartialMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, [ 'select', 'fetchAll', 'fetchPairs', @@ -186,28 +164,18 @@ protected function setUp() 'quoteIdentifier', 'delete', 'quoteInto' - ], - [], - '', - false - ); - $this->select = $this->getMock( - \Magento\Framework\DB\Select::class, - [ + ]); + $this->select = $this->createPartialMock(\Magento\Framework\DB\Select::class, [ 'from', 'where', 'joinLeft', 'getConnection', - ], - [], - '', - false - ); + ]); $this->select->expects($this->any())->method('from')->will($this->returnSelf()); $this->select->expects($this->any())->method('where')->will($this->returnSelf()); $this->select->expects($this->any())->method('joinLeft')->will($this->returnSelf()); $this->_connection->expects($this->any())->method('select')->will($this->returnValue($this->select)); - $connectionMock = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false); + $connectionMock = $this->createMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class); $connectionMock->expects($this->any())->method('quoteInto')->will($this->returnValue('query')); $this->select->expects($this->any())->method('getConnection')->willReturn($connectionMock); $this->_connection->expects($this->any())->method('insertOnDuplicate')->willReturnSelf(); @@ -215,16 +183,10 @@ protected function setUp() $this->_connection->expects($this->any())->method('quoteInto')->willReturn(''); $this->_connection->expects($this->any())->method('fetchAll')->will($this->returnValue([])); - $this->resource = $this->getMock( - \Magento\Framework\App\ResourceConnection::class, - [ + $this->resource = $this->createPartialMock(\Magento\Framework\App\ResourceConnection::class, [ 'getConnection', 'getTableName', - ], - [], - '', - false - ); + ]); $this->resource->expects($this->any())->method('getConnection')->will( $this->returnValue($this->_connection) ); @@ -235,20 +197,14 @@ protected function setUp() $this->returnValue($this->_connection) ); - $this->productCollectionFactory = $this->getMock( + $this->productCollectionFactory = $this->createPartialMock( \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->productCollection = $this->getMock( + $this->productCollection = $this->createPartialMock( \Magento\Catalog\Model\ResourceModel\Product\Collection::class, - ['addFieldToFilter', 'addAttributeToSelect'], - [], - '', - false + ['addFieldToFilter', 'addAttributeToSelect'] ); $products = []; @@ -258,13 +214,7 @@ protected function setUp() ['id' => 20, 'attribute_set_id' => 4, 'testattr2'=> 1, 'testattr3'=> 1], ]; foreach ($testProducts as $product) { - $item = $this->getMock( - \Magento\Framework\DataObject::class, - ['getAttributeSetId'], - [], - '', - false - ); + $item = $this->createPartialMock(\Magento\Framework\DataObject::class, ['getAttributeSetId']); $item->setData($product); $item->expects($this->any())->method('getAttributeSetId')->willReturn(4); @@ -293,8 +243,8 @@ protected function setUp() 'testattr3v3' => '6', ])); - $metadataPoolMock = $this->getMock(\Magento\Framework\EntityManager\MetadataPool::class, [], [], '', false); - $entityMetadataMock = $this->getMock(\Magento\Framework\EntityManager\EntityMetadata::class, [], [], '', false); + $metadataPoolMock = $this->createMock(\Magento\Framework\EntityManager\MetadataPool::class); + $entityMetadataMock = $this->createMock(\Magento\Framework\EntityManager\EntityMetadata::class); $metadataPoolMock->expects($this->any()) ->method('getMetadata') ->with(\Magento\Catalog\Api\Data\ProductInterface::class) @@ -333,8 +283,7 @@ protected function _getBunch() 'name' => 'Configurable Product 21', 'product_websites' => 'website_1', 'configurable_variation_labels' => 'testattr2=Select Color, testattr3=Select Size', - 'configurable_variations' => - 'sku=testconf2-attr2val1-testattr3v1,' + 'configurable_variations' => 'sku=testconf2-attr2val1-testattr3v1,' . 'testattr2=attr2val1,' . 'testattr3=testattr3v1,' . 'display=1|sku=testconf2-attr2val1-testattr3v2,' @@ -408,8 +357,7 @@ protected function _getBunch() 'name' => 'Configurable Product 21', 'product_websites' => 'website_1', 'configurable_variation_labels' => 'testattr2=Select Color, testattr3=Select Size', - 'configurable_variations' => - 'sku=testconf2-attr2val1-testattr3v1,' + 'configurable_variations' => 'sku=testconf2-attr2val1-testattr3v1,' . 'testattr2=attr2val1,' . 'testattr3=testattr3v1,' . 'testattr3=testattr3v2,' @@ -459,8 +407,7 @@ protected function _getSuperAttributes() 'frontend_label' => 'testattr2', 'is_static' => false, 'backend_type' => 'select', - 'apply_to' => - [], + 'apply_to' => [], 'type' => 'select', 'default_value' => null, 'options' => [ @@ -485,8 +432,7 @@ protected function _getSuperAttributes() 'apply_to' => [], 'type' => 'select', 'default_value' => null, - 'options' => - [ + 'options' => [ 'testattr3v1' => '9', 'testattr3v2' => '10', 'testattr3v3' => '11', @@ -495,6 +441,9 @@ protected function _getSuperAttributes() ]; } + /** + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ public function testSaveData() { $newSkus = array_change_key_case([ @@ -599,8 +548,7 @@ public function testIsRowValid() 'name' => 'Configurable Product 21 BadPrice', 'product_websites' => 'website_1', 'configurable_variation_labels' => 'testattr2=Select Color, testattr3=Select Size', - 'configurable_variations' => - 'sku=testconf2-attr2val1-testattr3v1,' + 'configurable_variations' => 'sku=testconf2-attr2val1-testattr3v1,' . 'testattr2=attr2val1_DOESNT_EXIST,' . 'testattr3=testattr3v1,' . 'display=1|sku=testconf2-attr2val1-testattr3v2,' @@ -619,11 +567,8 @@ public function testIsRowValid() ]); foreach ($bunch as $rowData) { - $this->configurable->isRowValid( - $rowData, - 0, - !isset($this->_oldSku[$rowData['sku']]) - ); + $result = $this->configurable->isRowValid($rowData, 0, !isset($this->_oldSku[$rowData['sku']])); + $this->assertNotNull($result); } } diff --git a/app/code/Magento/ConfigurableProduct/Api/ConfigurableProductManagementInterface.php b/app/code/Magento/ConfigurableProduct/Api/ConfigurableProductManagementInterface.php index f5917ea2c0498..4593f6926e904 100644 --- a/app/code/Magento/ConfigurableProduct/Api/ConfigurableProductManagementInterface.php +++ b/app/code/Magento/ConfigurableProduct/Api/ConfigurableProductManagementInterface.php @@ -9,6 +9,7 @@ /** * Interface ConfigurableProductManagementInterface * @api + * @since 100.0.2 */ interface ConfigurableProductManagementInterface { diff --git a/app/code/Magento/ConfigurableProduct/Api/Data/ConfigurableItemOptionValueInterface.php b/app/code/Magento/ConfigurableProduct/Api/Data/ConfigurableItemOptionValueInterface.php index 91c7128d1e57d..d1fa2b44c078c 100644 --- a/app/code/Magento/ConfigurableProduct/Api/Data/ConfigurableItemOptionValueInterface.php +++ b/app/code/Magento/ConfigurableProduct/Api/Data/ConfigurableItemOptionValueInterface.php @@ -8,6 +8,7 @@ /** * Interface ConfigurableItemOptionValueInterface * @api + * @since 100.0.2 */ interface ConfigurableItemOptionValueInterface extends \Magento\Framework\Api\ExtensibleDataInterface { diff --git a/app/code/Magento/ConfigurableProduct/Api/Data/OptionInterface.php b/app/code/Magento/ConfigurableProduct/Api/Data/OptionInterface.php index 99f1cf9aa9df4..bc11b11cd8fe7 100644 --- a/app/code/Magento/ConfigurableProduct/Api/Data/OptionInterface.php +++ b/app/code/Magento/ConfigurableProduct/Api/Data/OptionInterface.php @@ -9,6 +9,7 @@ /** * Interface OptionInterface * @api + * @since 100.0.2 */ interface OptionInterface extends \Magento\Framework\Api\ExtensibleDataInterface { diff --git a/app/code/Magento/ConfigurableProduct/Api/Data/OptionValueInterface.php b/app/code/Magento/ConfigurableProduct/Api/Data/OptionValueInterface.php index 0cf3dd414f256..10cde4b39fc0a 100644 --- a/app/code/Magento/ConfigurableProduct/Api/Data/OptionValueInterface.php +++ b/app/code/Magento/ConfigurableProduct/Api/Data/OptionValueInterface.php @@ -9,6 +9,7 @@ /** * Interface OptionValueInterface * @api + * @since 100.0.2 */ interface OptionValueInterface extends \Magento\Framework\Api\ExtensibleDataInterface { diff --git a/app/code/Magento/ConfigurableProduct/Api/LinkManagementInterface.php b/app/code/Magento/ConfigurableProduct/Api/LinkManagementInterface.php index 63a471b1f6d3d..7a7a869d178af 100644 --- a/app/code/Magento/ConfigurableProduct/Api/LinkManagementInterface.php +++ b/app/code/Magento/ConfigurableProduct/Api/LinkManagementInterface.php @@ -10,6 +10,7 @@ * Manage children products of configurable product * * @api + * @since 100.0.2 */ interface LinkManagementInterface { diff --git a/app/code/Magento/ConfigurableProduct/Api/OptionRepositoryInterface.php b/app/code/Magento/ConfigurableProduct/Api/OptionRepositoryInterface.php index 5188d94adb1da..0788540967051 100644 --- a/app/code/Magento/ConfigurableProduct/Api/OptionRepositoryInterface.php +++ b/app/code/Magento/ConfigurableProduct/Api/OptionRepositoryInterface.php @@ -10,6 +10,7 @@ * Manage options of configurable product * * @api + * @since 100.0.2 */ interface OptionRepositoryInterface { diff --git a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Order/Create/Sidebar.php b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Order/Create/Sidebar.php index 5c92ffeaae163..7fe3ef8974805 100644 --- a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Order/Create/Sidebar.php +++ b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Order/Create/Sidebar.php @@ -9,6 +9,7 @@ /** * @api + * @since 100.1.0 */ class Sidebar { @@ -20,6 +21,7 @@ class Sidebar * @param \Magento\Framework\DataObject $item * @return string * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @since 100.1.0 */ public function aroundGetItemQty( \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar $subject, @@ -40,6 +42,7 @@ public function aroundGetItemQty( * @param string $productType * @return bool * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @since 100.1.0 */ public function aroundIsConfigurationRequired( \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar $subject, diff --git a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Attribute/NewAttribute/Product/Created.php b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Attribute/NewAttribute/Product/Created.php index 33ea66b222420..9ebd5f3ee3705 100644 --- a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Attribute/NewAttribute/Product/Created.php +++ b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Attribute/NewAttribute/Product/Created.php @@ -9,6 +9,7 @@ * New product attribute created on product edit page * * @api + * @since 100.0.2 */ class Created extends \Magento\Backend\Block\Widget { diff --git a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Composite/Fieldset/Configurable.php b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Composite/Fieldset/Configurable.php index f2ca1a3fc1941..11e75839ec33c 100644 --- a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Composite/Fieldset/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Composite/Fieldset/Configurable.php @@ -9,6 +9,7 @@ /** * @api + * @since 100.0.2 */ class Configurable extends \Magento\ConfigurableProduct\Block\Product\View\Type\Configurable { diff --git a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/AttributeSet/Form.php b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/AttributeSet/Form.php index 63bc6359ce2f3..478358cffc378 100644 --- a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/AttributeSet/Form.php +++ b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/AttributeSet/Form.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class Form extends \Magento\Backend\Block\Widget\Form\Generic { diff --git a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Variations/Config/Matrix.php b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Variations/Config/Matrix.php index 06ca29553388e..a994532d5a69e 100644 --- a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Variations/Config/Matrix.php +++ b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Variations/Config/Matrix.php @@ -15,6 +15,7 @@ * * @api * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class Matrix extends \Magento\Backend\Block\Template { @@ -38,13 +39,19 @@ class Matrix extends \Magento\Backend\Block\Template */ protected $productRepository; - /** @var \Magento\Catalog\Helper\Image */ + /** + * @var \Magento\Catalog\Helper\Image + */ protected $image; - /** @var null|array */ + /** + * @var null|array + */ private $productMatrix; - /** @var null|array */ + /** + * @var null|array + */ private $productAttributes; /** @@ -54,6 +61,7 @@ class Matrix extends \Magento\Backend\Block\Template /** * @var LocatorInterface + * @since 100.1.0 */ protected $locator; @@ -121,6 +129,7 @@ public function getVariations() * Retrieve data source for variations data * * @return string + * @since 100.1.0 */ public function getProvider() { @@ -131,6 +140,7 @@ public function getProvider() * Retrieve configurable modal name * * @return string + * @since 100.1.0 */ public function getModal() { @@ -141,6 +151,7 @@ public function getModal() * Retrieve form name * * @return string + * @since 100.1.0 */ public function getForm() { @@ -151,6 +162,7 @@ public function getForm() * Retrieve configurable modal name * * @return string + * @since 100.1.0 */ public function getConfigurableModal() { diff --git a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Steps/AttributeValues.php b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Steps/AttributeValues.php index d0695c67c6409..31bf457fefe93 100644 --- a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Steps/AttributeValues.php +++ b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Steps/AttributeValues.php @@ -9,6 +9,7 @@ * Adminhtml block for fieldset of configurable product * * @api + * @since 100.0.2 */ class AttributeValues extends \Magento\Ui\Block\Component\StepsWizard\StepAbstract { diff --git a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Steps/Bulk.php b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Steps/Bulk.php index 564ce43668760..bb5c8d8b49ca2 100644 --- a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Steps/Bulk.php +++ b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Steps/Bulk.php @@ -17,10 +17,13 @@ * Adminhtml block for fieldset of configurable product * * @api + * @since 100.0.2 */ class Bulk extends \Magento\Ui\Block\Component\StepsWizard\StepAbstract { - /** @var Image */ + /** + * @var \Magento\Catalog\Helper\Image + */ protected $image; /** diff --git a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Steps/SelectAttributes.php b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Steps/SelectAttributes.php index 54e974f7674e5..f244d5cd62a5e 100644 --- a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Steps/SelectAttributes.php +++ b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Steps/SelectAttributes.php @@ -9,6 +9,7 @@ * Adminhtml block for fieldset of configurable product * * @api + * @since 100.0.2 */ class SelectAttributes extends \Magento\Ui\Block\Component\StepsWizard\StepAbstract { diff --git a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Steps/Summary.php b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Steps/Summary.php index 81cbae0b483b6..cf299d152e173 100644 --- a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Steps/Summary.php +++ b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Steps/Summary.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Summary extends \Magento\Ui\Block\Component\StepsWizard\StepAbstract { diff --git a/app/code/Magento/ConfigurableProduct/Block/Cart/Item/Renderer/Configurable.php b/app/code/Magento/ConfigurableProduct/Block/Cart/Item/Renderer/Configurable.php index 1d512d6e829a8..d1e4db41cd209 100644 --- a/app/code/Magento/ConfigurableProduct/Block/Cart/Item/Renderer/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Block/Cart/Item/Renderer/Configurable.php @@ -13,6 +13,7 @@ * Shopping cart item render block for configurable products. * * @api + * @since 100.0.2 */ class Configurable extends Renderer implements IdentityInterface { diff --git a/app/code/Magento/ConfigurableProduct/Block/Product/Configurable/AssociatedSelector/Renderer/Id.php b/app/code/Magento/ConfigurableProduct/Block/Product/Configurable/AssociatedSelector/Renderer/Id.php index c4745d1c62e81..772c6020cedbd 100644 --- a/app/code/Magento/ConfigurableProduct/Block/Product/Configurable/AssociatedSelector/Renderer/Id.php +++ b/app/code/Magento/ConfigurableProduct/Block/Product/Configurable/AssociatedSelector/Renderer/Id.php @@ -9,6 +9,7 @@ /** * @api + * @since 100.0.2 */ class Id extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { diff --git a/app/code/Magento/ConfigurableProduct/Block/Product/Configurable/AttributeSelector.php b/app/code/Magento/ConfigurableProduct/Block/Product/Configurable/AttributeSelector.php index a9fdecbb92910..841525e52526a 100644 --- a/app/code/Magento/ConfigurableProduct/Block/Product/Configurable/AttributeSelector.php +++ b/app/code/Magento/ConfigurableProduct/Block/Product/Configurable/AttributeSelector.php @@ -11,6 +11,7 @@ * @api * @SuppressWarnings(PHPMD.LongVariable) * @api + * @since 100.0.2 */ class AttributeSelector extends \Magento\Backend\Block\Template { diff --git a/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php b/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php index 4b0329fead780..edd18cd7ffbc7 100644 --- a/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php @@ -9,6 +9,7 @@ use Magento\ConfigurableProduct\Model\ConfigurableAttributeData; use Magento\Customer\Helper\Session\CurrentCustomer; +use Magento\Customer\Model\Session; use Magento\Framework\App\ObjectManager; use Magento\Framework\Locale\Format; use Magento\Framework\Pricing\PriceCurrencyInterface; @@ -17,6 +18,7 @@ * @api * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @api + * @since 100.0.2 */ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView { @@ -30,6 +32,7 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView /** * Current customer * + * @deprecated, as unused property * @var CurrentCustomer */ protected $currentCustomer; @@ -66,6 +69,11 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView */ private $localeFormat; + /** + * @var Session + */ + private $customerSession; + /** * @param \Magento\Catalog\Block\Product\Context $context * @param \Magento\Framework\Stdlib\ArrayUtils $arrayUtils @@ -77,6 +85,7 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView * @param ConfigurableAttributeData $configurableAttributeData * @param array $data * @param Format|null $localeFormat + * @param Session|null $customerSession * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -89,7 +98,8 @@ public function __construct( PriceCurrencyInterface $priceCurrency, ConfigurableAttributeData $configurableAttributeData, array $data = [], - Format $localeFormat = null + Format $localeFormat = null, + Session $customerSession = null ) { $this->priceCurrency = $priceCurrency; $this->helper = $helper; @@ -98,6 +108,7 @@ public function __construct( $this->currentCustomer = $currentCustomer; $this->configurableAttributeData = $configurableAttributeData; $this->localeFormat = $localeFormat ?: ObjectManager::getInstance()->get(Format::class); + $this->customerSession = $customerSession ?: ObjectManager::getInstance()->get(Session::class); parent::__construct( $context, @@ -110,11 +121,13 @@ public function __construct( * Get cache key informative items. * * @return array + * @since 100.2.0 */ public function getCacheKeyInfo() { $parentData = parent::getCacheKeyInfo(); $parentData[] = $this->priceCurrency->getCurrencySymbol(); + $parentData[] = $this->customerSession->getCustomerGroupId(); return $parentData; } @@ -240,6 +253,7 @@ public function getJsonConfig() * Get product images for configurable variations * * @return array + * @since 100.2.0 */ protected function getOptionImages() { @@ -311,7 +325,7 @@ protected function getOptionPrices() /** * Replace ',' on '.' for js * - * @deprecated Will be removed in major release + * @deprecated 100.2.0 Will be removed in major release * @param float $price * @return string */ @@ -324,6 +338,7 @@ protected function _registerJsPrice($price) * Should we generate "As low as" block or not * * @return bool + * @since 100.2.0 */ public function showMinimalPrice() { diff --git a/app/code/Magento/ConfigurableProduct/Block/Stockqty/Type/Configurable.php b/app/code/Magento/ConfigurableProduct/Block/Stockqty/Type/Configurable.php index be4be3c8ad876..52241b010259f 100644 --- a/app/code/Magento/ConfigurableProduct/Block/Stockqty/Type/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Block/Stockqty/Type/Configurable.php @@ -11,6 +11,7 @@ * Product stock qty block for configurable product type * * @api + * @since 100.0.2 */ class Configurable extends \Magento\CatalogInventory\Block\Stockqty\Composite { diff --git a/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/AddAttribute.php b/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/AddAttribute.php index 19f4d1e0ee91d..5991097e456f2 100644 --- a/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/AddAttribute.php +++ b/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/AddAttribute.php @@ -11,6 +11,13 @@ class AddAttribute extends Action { + /** + * Authorization level of a basic admin session + * + * @see _isAllowed() + */ + const ADMIN_RESOURCE = 'Magento_Catalog::products'; + /** * @var \Magento\Catalog\Controller\Adminhtml\Product\Builder */ diff --git a/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Associated/Grid.php b/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Associated/Grid.php index eacca230335bd..7e9b163541bea 100644 --- a/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Associated/Grid.php +++ b/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Associated/Grid.php @@ -12,6 +12,13 @@ class Grid extends Action { + /** + * Authorization level of a basic admin session + * + * @see _isAllowed() + */ + const ADMIN_RESOURCE = 'Magento_Catalog::products'; + /** * @var LayoutFactory */ diff --git a/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Configurable.php b/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Configurable.php index 0341811caec02..5cd8b6a7d0b95 100644 --- a/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Configurable.php @@ -153,17 +153,17 @@ private function setLinkedProducts(ProductInterface $product, ProductExtensionIn protected function getVariationMatrix() { $result = []; - $configurableMatrix = $this->request->getParam('configurable-matrix-serialized', '[]'); - if ($configurableMatrix != null && !empty($configurableMatrix)) { + $configurableMatrix = $this->request->getParam('configurable-matrix-serialized', "[]"); + if (isset($configurableMatrix) && $configurableMatrix != "") { $configurableMatrix = json_decode($configurableMatrix, true); - } - foreach ($configurableMatrix as $item) { - if ($item['newProduct']) { - $result[$item['variationKey']] = $this->mapData($item); + foreach ($configurableMatrix as $item) { + if ($item['newProduct']) { + $result[$item['variationKey']] = $this->mapData($item); - if (isset($item['qty'])) { - $result[$item['variationKey']]['quantity_and_stock_status']['qty'] = $item['qty']; + if (isset($item['qty'])) { + $result[$item['variationKey']]['quantity_and_stock_status']['qty'] = $item['qty']; + } } } } diff --git a/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/UpdateConfigurations.php b/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/UpdateConfigurations.php index 668a3aee56cfd..442c48a4554d0 100644 --- a/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/UpdateConfigurations.php +++ b/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/UpdateConfigurations.php @@ -9,13 +9,19 @@ class UpdateConfigurations { - /** @var \Magento\Catalog\Api\ProductRepositoryInterface */ + /** + * @var \Magento\Catalog\Api\ProductRepositoryInterface + */ protected $productRepository; - /** @var \Magento\Framework\App\RequestInterface */ + /** + * @var \Magento\Framework\App\RequestInterface + */ protected $request; - /** @var \Magento\ConfigurableProduct\Model\Product\VariationHandler */ + /** + * @var \Magento\ConfigurableProduct\Model\Product\VariationHandler + */ protected $variationHandler; /** @@ -87,23 +93,23 @@ public function afterInitialize( protected function getConfigurations() { $result = []; - $configurableMatrix = $this->request->getParam('configurable-matrix-serialized', '[]'); - if ($configurableMatrix != null && !empty($configurableMatrix)) { + $configurableMatrix = $this->request->getParam('configurable-matrix-serialized', "[]"); + if (isset($configurableMatrix) && $configurableMatrix != "") { $configurableMatrix = json_decode($configurableMatrix, true); - } - foreach ($configurableMatrix as $item) { - if (empty($item['was_changed'])) { - continue; - } else { - unset($item['was_changed']); - } + foreach ($configurableMatrix as $item) { + if (empty($item['was_changed'])) { + continue; + } else { + unset($item['was_changed']); + } - if (!$item['newProduct']) { - $result[$item['id']] = $this->mapData($item); + if (!$item['newProduct']) { + $result[$item['id']] = $this->mapData($item); - if (isset($item['qty'])) { - $result[$item['id']]['quantity_and_stock_status']['qty'] = $item['qty']; + if (isset($item['qty'])) { + $result[$item['id']]['quantity_and_stock_status']['qty'] = $item['qty']; + } } } } diff --git a/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Wizard.php b/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Wizard.php index a065914ae01be..8adfdea96102c 100644 --- a/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Wizard.php +++ b/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Wizard.php @@ -15,6 +15,13 @@ */ class Wizard extends Action { + /** + * Authorization level of a basic admin session + * + * @see _isAllowed() + */ + const ADMIN_RESOURCE = 'Magento_Catalog::products'; + /** * @var Builder */ diff --git a/app/code/Magento/ConfigurableProduct/Helper/Data.php b/app/code/Magento/ConfigurableProduct/Helper/Data.php index 8e22548babf5e..1de82eaad3196 100644 --- a/app/code/Magento/ConfigurableProduct/Helper/Data.php +++ b/app/code/Magento/ConfigurableProduct/Helper/Data.php @@ -12,6 +12,7 @@ * Class Data * Helper class for getting options * @api + * @since 100.0.2 */ class Data { diff --git a/app/code/Magento/ConfigurableProduct/Helper/Product/Options/Factory.php b/app/code/Magento/ConfigurableProduct/Helper/Product/Options/Factory.php index 86bd0c57da2ae..8a60b62d093d5 100644 --- a/app/code/Magento/ConfigurableProduct/Helper/Product/Options/Factory.php +++ b/app/code/Magento/ConfigurableProduct/Helper/Product/Options/Factory.php @@ -15,6 +15,7 @@ /** * Class Factory * @api + * @since 100.1.0 */ class Factory { @@ -64,6 +65,7 @@ public function __construct( * @param array $attributesData * @return OptionInterface[] * @throws \InvalidArgumentException + * @since 100.1.0 */ public function create(array $attributesData) { diff --git a/app/code/Magento/ConfigurableProduct/Model/AttributeOptionProviderInterface.php b/app/code/Magento/ConfigurableProduct/Model/AttributeOptionProviderInterface.php index 8116069a80762..ca289122a2126 100644 --- a/app/code/Magento/ConfigurableProduct/Model/AttributeOptionProviderInterface.php +++ b/app/code/Magento/ConfigurableProduct/Model/AttributeOptionProviderInterface.php @@ -8,6 +8,7 @@ /** * Interface to retrieve options for attribute * @api + * @since 100.2.0 */ interface AttributeOptionProviderInterface { @@ -17,6 +18,7 @@ interface AttributeOptionProviderInterface * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute * @param int $productId * @return array + * @since 100.2.0 */ public function getAttributeOptions(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute, $productId); } diff --git a/app/code/Magento/ConfigurableProduct/Model/AttributesListInterface.php b/app/code/Magento/ConfigurableProduct/Model/AttributesListInterface.php index ff96aa65d3b92..5e8ca1b889c1a 100644 --- a/app/code/Magento/ConfigurableProduct/Model/AttributesListInterface.php +++ b/app/code/Magento/ConfigurableProduct/Model/AttributesListInterface.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ interface AttributesListInterface { diff --git a/app/code/Magento/ConfigurableProduct/Model/ConfigurableAttributeData.php b/app/code/Magento/ConfigurableProduct/Model/ConfigurableAttributeData.php index 2bbcfb51c3e0d..7b2cabc78884f 100644 --- a/app/code/Magento/ConfigurableProduct/Model/ConfigurableAttributeData.php +++ b/app/code/Magento/ConfigurableProduct/Model/ConfigurableAttributeData.php @@ -12,6 +12,7 @@ /** * Class ConfigurableAttributeData * @api + * @since 100.0.2 */ class ConfigurableAttributeData { diff --git a/app/code/Magento/ConfigurableProduct/Model/LinkManagement.php b/app/code/Magento/ConfigurableProduct/Model/LinkManagement.php index 825e19c442c88..01981b5dae9db 100644 --- a/app/code/Magento/ConfigurableProduct/Model/LinkManagement.php +++ b/app/code/Magento/ConfigurableProduct/Model/LinkManagement.php @@ -177,7 +177,7 @@ public function removeChild($sku, $childSku) * * @return \Magento\ConfigurableProduct\Helper\Product\Options\Factory * - * @deprecated + * @deprecated 100.1.2 */ private function getOptionsFactory() { diff --git a/app/code/Magento/ConfigurableProduct/Model/Plugin/ProductRepositorySave.php b/app/code/Magento/ConfigurableProduct/Model/Plugin/ProductRepositorySave.php index 075b07c38eb9f..54b6e42ff7678 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Plugin/ProductRepositorySave.php +++ b/app/code/Magento/ConfigurableProduct/Model/Plugin/ProductRepositorySave.php @@ -81,9 +81,9 @@ public function afterSave( $attributeCodes[] = $attributeCode; } $this->validateProductLinks($attributeCodes, $configurableLinks); - $product->getTypeInstance()->resetConfigurableAttributes($product); + $result->getTypeInstance()->resetConfigurableAttributes($product); - return $product; + return $result; } /** diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php index d477f2a0da6ff..360a11cf2748f 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php @@ -24,6 +24,7 @@ * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @api + * @since 100.0.2 */ class Configurable extends \Magento\Catalog\Model\Product\Type\AbstractType { @@ -36,6 +37,7 @@ class Configurable extends \Magento\Catalog\Model\Product\Type\AbstractType * Cache key for Used Product Attribute Ids * * @var string + * @since 100.1.0 */ protected $usedProductAttributeIds = '_cache_instance_used_product_attribute_ids'; @@ -43,6 +45,7 @@ class Configurable extends \Magento\Catalog\Model\Product\Type\AbstractType * Cache key for Used Product Attributes * * @var string + * @since 100.1.0 */ protected $usedProductAttributes = '_cache_instance_used_product_attributes'; @@ -126,6 +129,7 @@ class Configurable extends \Magento\Catalog\Model\Product\Type\AbstractType * Configurable attribute factory * * @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable\AttributeFactory + * @since 100.1.0 */ protected $configurableAttributeFactory; @@ -140,6 +144,7 @@ class Configurable extends \Magento\Catalog\Model\Product\Type\AbstractType * Type configurable factory * * @var \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\ConfigurableFactory + * @since 100.1.0 */ protected $typeConfigurableFactory; @@ -265,7 +270,7 @@ public function __construct( } /** - * @deprecated + * @deprecated 100.1.1 * @return \Magento\Framework\Cache\FrontendInterface */ private function getCache() @@ -277,7 +282,7 @@ private function getCache() } /** - * @deprecated + * @deprecated 100.1.1 * @return \Magento\Customer\Model\Session */ private function getCustomerSession() @@ -352,7 +357,7 @@ public function canUseAttribute(\Magento\Catalog\Model\ResourceModel\Eav\Attribu * @param array $ids * @param \Magento\Catalog\Model\Product $product * @return \Magento\ConfigurableProduct\Model\Product\Type\Configurable - * @deprecated use \Magento\ConfigurableProduct\Model\Product\Type\Configurable::setUsedProductAttributes instead + * @deprecated 100.1.0 use \Magento\ConfigurableProduct\Model\Product\Type\Configurable::setUsedProductAttributes instead */ public function setUsedProductAttributeIds($ids, $product) { @@ -378,6 +383,7 @@ public function setUsedProductAttributeIds($ids, $product) * @param ProductInterface $product * @param array $ids * @return $this + * @since 100.0.6 */ public function setUsedProductAttributes(ProductInterface $product, array $ids) { @@ -515,7 +521,7 @@ public function getConfigurableAttributeCollection(\Magento\Catalog\Model\Produc /** * Retrieve subproducts identifiers * - * @deprecated + * @deprecated 100.1.1 * @param \Magento\Catalog\Model\Product $product * @return array */ @@ -535,7 +541,8 @@ public function getUsedProductIds($product) * Retrieve GalleryReadHandler * * @return GalleryReadHandler - * @deprecated + * @deprecated 100.1.1 + * @since 100.1.0 */ protected function getGalleryReadHandler() { @@ -609,7 +616,7 @@ public function beforeSave($product) * @param \Magento\Catalog\Model\Product $product * @return $this * @throws \InvalidArgumentException - * @deprecated the \Magento\ConfigurableProduct\Model\Product\SaveHandler::execute should be used instead + * @deprecated 100.1.0 the \Magento\ConfigurableProduct\Model\Product\SaveHandler::execute should be used instead */ public function save($product) { @@ -637,7 +644,7 @@ public function save($product) * @param ProductInterface $product * @return void * @throws \Exception - * @deprecated + * @deprecated 100.1.0 */ private function saveConfigurableOptions(ProductInterface $product) { @@ -690,7 +697,7 @@ private function saveConfigurableOptions(ProductInterface $product) * * @param ProductInterface $product * @return void - * @deprecated + * @deprecated 100.1.0 */ private function saveRelatedProducts(ProductInterface $product) { @@ -1189,7 +1196,7 @@ private function getMetadataPool() /** * Get Config instance * @return Config - * @deprecated + * @deprecated 100.1.0 */ private function getCatalogConfig() { @@ -1201,6 +1208,7 @@ private function getCatalogConfig() /** * @inheritdoc + * @since 100.2.0 */ public function isPossibleBuyFromList($product) { @@ -1242,12 +1250,13 @@ public function getUsedProducts($product, $requiredAttributeIds = null) * * Result array contains only those children for specified configurable product which are salable on store front * - * @deprecated Not used anymore. Keep it for backward compatibility. + * @deprecated 100.2.0 Not used anymore. Keep it for backward compatibility. * * @param \Magento\Catalog\Model\Product $product * @param array|null $requiredAttributeIds * @return ProductInterface[] * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @since 100.1.3 */ public function getSalableUsedProducts(\Magento\Catalog\Model\Product $product, $requiredAttributeIds = null) { diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Attribute.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Attribute.php index e1c02df6ecfde..a6bec4ac6274f 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Attribute.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Attribute.php @@ -12,8 +12,6 @@ use Magento\Framework\EntityManager\MetadataPool; /** - * @method Attribute _getResource() - * @method Attribute getResource() * @method Attribute setProductAttribute(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $value) * @method \Magento\Eav\Model\Entity\Attribute\AbstractAttribute getProductAttribute() */ @@ -31,9 +29,7 @@ class Attribute extends \Magento\Framework\Model\AbstractExtensibleModel impleme const KEY_PRODUCT_ID = 'product_id'; /**#@-*/ - /** - * @var MetadataPool - */ + /**#@-*/ private $metadataPool; /** diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/VariationMatrix.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/VariationMatrix.php index 113aecc8c353d..979587dc500a4 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/VariationMatrix.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/VariationMatrix.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class VariationMatrix { diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/VariationHandler.php b/app/code/Magento/ConfigurableProduct/Model/Product/VariationHandler.php index 5bac181ca5a2d..a462a5ffd9edd 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/VariationHandler.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/VariationHandler.php @@ -12,30 +12,44 @@ * Variation Handler * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @api + * @since 100.0.2 */ class VariationHandler { - /** @var \Magento\Catalog\Model\Product\Gallery\Processor */ + /** + * @var \Magento\Catalog\Model\Product\Gallery\Processor + * @since 100.1.0 + */ protected $mediaGalleryProcessor; - /** @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable */ + /** + * @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable + */ protected $configurableProduct; - /** @var \Magento\Eav\Model\Entity\Attribute\SetFactory */ + /** + * @var \Magento\Eav\Model\Entity\Attribute\SetFactory + */ protected $attributeSetFactory; - /** @var \Magento\Eav\Model\EntityFactory */ + /** + * @var \Magento\Eav\Model\EntityFactory + */ protected $entityFactory; - /** @var \Magento\Catalog\Model\ProductFactory */ + /** + * @var \Magento\Catalog\Model\ProductFactory + */ protected $productFactory; - /** @var \Magento\Eav\Model\Entity\Attribute\AbstractAttribute[] */ + /** + * @var \Magento\Eav\Model\Entity\Attribute\AbstractAttribute[] + */ private $attributes; /** * @var \Magento\CatalogInventory\Api\StockConfigurationInterface - * @deprecated + * @deprecated 100.1.0 */ protected $stockConfiguration; @@ -100,7 +114,7 @@ public function generateSimpleProducts($parentProduct, $productsData) /** * Prepare attribute set comprising all selected configurable attributes * - * @deprecated since 2.1.0 + * @deprecated 100.1.0 * @param \Magento\Catalog\Model\Product $product * @return void */ @@ -114,6 +128,7 @@ protected function prepareAttributeSetToBeBaseForNewVariations(\Magento\Catalog\ * * @param \Magento\Catalog\Model\Product $product * @return void + * @since 100.1.0 */ public function prepareAttributeSet(\Magento\Catalog\Model\Product $product) { diff --git a/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Type/Configurable/Attribute/Collection.php b/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Type/Configurable/Attribute/Collection.php index d21b0a4ca3610..e46f688db562e 100644 --- a/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Type/Configurable/Attribute/Collection.php +++ b/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Type/Configurable/Attribute/Collection.php @@ -19,10 +19,13 @@ * @api * @SuppressWarnings(PHPMD.LongVariable) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { - /** @var ConfigurableResource */ + /** + * @var \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable + */ private $configurableResource; /** @@ -197,7 +200,7 @@ protected function _addProductAttributes() * Add Associated Product Filters (From Product Type Instance) * * @return $this - * @deprecated + * @deprecated 100.1.1 */ public function _addAssociatedProductFilters() { @@ -314,6 +317,7 @@ private function getProduct() /** * @inheritdoc + * @since 100.0.6 */ public function __sleep() { @@ -332,6 +336,7 @@ public function __sleep() /** * @inheritdoc + * @since 100.0.6 */ public function __wakeup() { @@ -347,7 +352,7 @@ public function __wakeup() /** * Get MetadataPool instance * - * @deprecated + * @deprecated 100.2.0 * @return MetadataPool */ private function getMetadataPool() @@ -361,7 +366,7 @@ private function getMetadataPool() /** * Get Configurable Resource * - * @deprecated + * @deprecated 100.1.1 * @return ConfigurableResource */ private function getConfigurableResource() diff --git a/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Type/Configurable/Product/Collection.php b/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Type/Configurable/Product/Collection.php index 71700d183b3a7..7b83d4e4d9614 100644 --- a/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Type/Configurable/Product/Collection.php +++ b/app/code/Magento/ConfigurableProduct/Model/ResourceModel/Product/Type/Configurable/Product/Collection.php @@ -12,6 +12,7 @@ * * @api * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection { diff --git a/app/code/Magento/ConfigurableProduct/Plugin/Model/ResourceModel/Product.php b/app/code/Magento/ConfigurableProduct/Plugin/Model/ResourceModel/Product.php index 79c08b8502b0d..1555e88700a45 100644 --- a/app/code/Magento/ConfigurableProduct/Plugin/Model/ResourceModel/Product.php +++ b/app/code/Magento/ConfigurableProduct/Plugin/Model/ResourceModel/Product.php @@ -7,9 +7,34 @@ namespace Magento\ConfigurableProduct\Plugin\Model\ResourceModel; use Magento\ConfigurableProduct\Model\Product\Type\Configurable; +use Magento\Framework\Indexer\ActionInterface; class Product { + /** + * @var Configurable + */ + private $configurable; + + /** + * @var ActionInterface + */ + private $productIndexer; + + /** + * Initialize Product dependencies. + * + * @param Configurable $configurable + * @param ActionInterface $productIndexer + */ + public function __construct( + Configurable $configurable, + ActionInterface $productIndexer + ) { + $this->configurable = $configurable; + $this->productIndexer = $productIndexer; + } + /** * We need reset attribute set id to attribute after related simple product was saved * @@ -28,4 +53,25 @@ public function beforeSave( $object->getTypeInstance()->getSetAttributes($object); } } + + /** + * Gather configurable parent ids of product being deleted and reindex after delete is complete. + * + * @param \Magento\Catalog\Model\ResourceModel\Product $subject + * @param \Closure $proceed + * @param \Magento\Catalog\Model\Product $product + * @return \Magento\Catalog\Model\ResourceModel\Product + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function aroundDelete( + \Magento\Catalog\Model\ResourceModel\Product $subject, + \Closure $proceed, + \Magento\Catalog\Model\Product $product + ) { + $configurableProductIds = $this->configurable->getParentIdsByChild($product->getId()); + $result = $proceed($product); + $this->productIndexer->executeList($configurableProductIds); + + return $result; + } } diff --git a/app/code/Magento/ConfigurableProduct/Pricing/Price/ConfigurableOptionsProvider.php b/app/code/Magento/ConfigurableProduct/Pricing/Price/ConfigurableOptionsProvider.php index 2e491d42ff25d..6cc5625df5b18 100644 --- a/app/code/Magento/ConfigurableProduct/Pricing/Price/ConfigurableOptionsProvider.php +++ b/app/code/Magento/ConfigurableProduct/Pricing/Price/ConfigurableOptionsProvider.php @@ -15,7 +15,9 @@ class ConfigurableOptionsProvider implements ConfigurableOptionsProviderInterface { - /** @var Configurable */ + /** + * @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable + */ private $configurable; /** diff --git a/app/code/Magento/ConfigurableProduct/Pricing/Price/ConfigurableOptionsProviderInterface.php b/app/code/Magento/ConfigurableProduct/Pricing/Price/ConfigurableOptionsProviderInterface.php index a58c7fbaa34fb..d0b88bfc33b8c 100644 --- a/app/code/Magento/ConfigurableProduct/Pricing/Price/ConfigurableOptionsProviderInterface.php +++ b/app/code/Magento/ConfigurableProduct/Pricing/Price/ConfigurableOptionsProviderInterface.php @@ -11,12 +11,14 @@ /** * Provide configurable sub-products for price calculation * @api + * @since 100.1.1 */ interface ConfigurableOptionsProviderInterface { /** * @param ProductInterface $product * @return \Magento\Catalog\Api\Data\ProductInterface[] + * @since 100.1.1 */ public function getProducts(\Magento\Catalog\Api\Data\ProductInterface $product); } diff --git a/app/code/Magento/ConfigurableProduct/Pricing/Price/ConfigurablePriceResolver.php b/app/code/Magento/ConfigurableProduct/Pricing/Price/ConfigurablePriceResolver.php index da268ce533046..3d42217de5f91 100644 --- a/app/code/Magento/ConfigurableProduct/Pricing/Price/ConfigurablePriceResolver.php +++ b/app/code/Magento/ConfigurableProduct/Pricing/Price/ConfigurablePriceResolver.php @@ -12,18 +12,20 @@ class ConfigurablePriceResolver implements PriceResolverInterface { - /** @var PriceResolverInterface */ + /** + * @var \Magento\ConfigurableProduct\Pricing\Price\PriceResolverInterface + */ protected $priceResolver; /** * @var PriceCurrencyInterface - * @deprecated + * @deprecated 100.1.1 */ protected $priceCurrency; /** * @var Configurable - * @deprecated + * @deprecated 100.1.1 */ protected $configurable; diff --git a/app/code/Magento/ConfigurableProduct/Pricing/Price/ConfigurableRegularPrice.php b/app/code/Magento/ConfigurableProduct/Pricing/Price/ConfigurableRegularPrice.php index 0649d10019575..a6a6b8753824f 100644 --- a/app/code/Magento/ConfigurableProduct/Pricing/Price/ConfigurableRegularPrice.php +++ b/app/code/Magento/ConfigurableProduct/Pricing/Price/ConfigurableRegularPrice.php @@ -35,7 +35,9 @@ class ConfigurableRegularPrice extends AbstractPrice implements ConfigurableRegu */ protected $values = []; - /** @var PriceResolverInterface */ + /** + * @var \Magento\ConfigurableProduct\Pricing\Price\PriceResolverInterface + */ protected $priceResolver; /** @@ -158,7 +160,7 @@ protected function getUsedProducts() /** * @return \Magento\ConfigurableProduct\Pricing\Price\ConfigurableOptionsProviderInterface - * @deprecated + * @deprecated 100.1.1 */ private function getConfigurableOptionsProvider() { diff --git a/app/code/Magento/ConfigurableProduct/Pricing/Price/ConfigurableRegularPriceInterface.php b/app/code/Magento/ConfigurableProduct/Pricing/Price/ConfigurableRegularPriceInterface.php index 2f45285070a82..1aef59b376e3f 100644 --- a/app/code/Magento/ConfigurableProduct/Pricing/Price/ConfigurableRegularPriceInterface.php +++ b/app/code/Magento/ConfigurableProduct/Pricing/Price/ConfigurableRegularPriceInterface.php @@ -12,6 +12,7 @@ /** * Configurable regular price interface * @api + * @since 100.0.2 */ interface ConfigurableRegularPriceInterface extends BasePriceProviderInterface { diff --git a/app/code/Magento/ConfigurableProduct/Pricing/Price/FinalPrice.php b/app/code/Magento/ConfigurableProduct/Pricing/Price/FinalPrice.php index 9f18e986c2ccb..0cb1197dc955d 100644 --- a/app/code/Magento/ConfigurableProduct/Pricing/Price/FinalPrice.php +++ b/app/code/Magento/ConfigurableProduct/Pricing/Price/FinalPrice.php @@ -8,7 +8,9 @@ class FinalPrice extends \Magento\Catalog\Pricing\Price\FinalPrice { - /** @var PriceResolverInterface */ + /** + * @var \Magento\ConfigurableProduct\Pricing\Price\PriceResolverInterface + */ protected $priceResolver; /** diff --git a/app/code/Magento/ConfigurableProduct/Pricing/Price/LowestPriceOptionsProviderInterface.php b/app/code/Magento/ConfigurableProduct/Pricing/Price/LowestPriceOptionsProviderInterface.php index d8d11323b0357..24dfff05bf20e 100644 --- a/app/code/Magento/ConfigurableProduct/Pricing/Price/LowestPriceOptionsProviderInterface.php +++ b/app/code/Magento/ConfigurableProduct/Pricing/Price/LowestPriceOptionsProviderInterface.php @@ -10,12 +10,14 @@ /** * Retrieve list of products where each product contains lower price than others at least for one possible price type * @api + * @since 100.1.3 */ interface LowestPriceOptionsProviderInterface { /** * @param ProductInterface $product * @return \Magento\Catalog\Api\Data\ProductInterface[] + * @since 100.1.3 */ public function getProducts(\Magento\Catalog\Api\Data\ProductInterface $product); } diff --git a/app/code/Magento/ConfigurableProduct/Pricing/Price/PriceResolverInterface.php b/app/code/Magento/ConfigurableProduct/Pricing/Price/PriceResolverInterface.php index 600903f7ece1c..7c489eec430ef 100644 --- a/app/code/Magento/ConfigurableProduct/Pricing/Price/PriceResolverInterface.php +++ b/app/code/Magento/ConfigurableProduct/Pricing/Price/PriceResolverInterface.php @@ -8,6 +8,7 @@ /** * @api + * @since 100.0.2 */ interface PriceResolverInterface { diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Adminhtml/Product/Edit/Button/SaveTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Adminhtml/Product/Edit/Button/SaveTest.php index 685e463a4eda7..8df6df53cc065 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Adminhtml/Product/Edit/Button/SaveTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Adminhtml/Product/Edit/Button/SaveTest.php @@ -10,7 +10,7 @@ use Magento\Framework\Registry; use Magento\Catalog\Api\Data\ProductInterface; -class SaveTest extends \PHPUnit_Framework_TestCase +class SaveTest extends \PHPUnit\Framework\TestCase { /** * @var SaveButton diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Adminhtml/Product/Edit/Tab/Variations/Config/MatrixTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Adminhtml/Product/Edit/Tab/Variations/Config/MatrixTest.php index 2993269990da2..86692396b4671 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Adminhtml/Product/Edit/Tab/Variations/Config/MatrixTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Adminhtml/Product/Edit/Tab/Variations/Config/MatrixTest.php @@ -8,7 +8,7 @@ /** * Class MatrixTest */ -class MatrixTest extends \PHPUnit_Framework_TestCase +class MatrixTest extends \PHPUnit\Framework\TestCase { /** * Object under test @@ -41,8 +41,8 @@ protected function setUp() ); $data = [ 'context' => $context, - 'formFactory' => $this->getMock(\Magento\Framework\Data\FormFactory::class, [], [], '', false), - 'productFactory' => $this->getMock(\Magento\Catalog\Model\ProductFactory::class, [], [], '', false), + 'formFactory' => $this->createMock(\Magento\Framework\Data\FormFactory::class), + 'productFactory' => $this->createMock(\Magento\Catalog\Model\ProductFactory::class), 'stockRegistry' => $this->stockRegistryMock, ]; $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); @@ -64,20 +64,8 @@ public function testGetProductStockQty() $websiteId = 99; $qty = 100.00; - $productMock = $this->getMock( - \Magento\Catalog\Model\Product::class, - ['getId', 'getStore'], - [], - '', - false - ); - $storeMock = $this->getMock( - \Magento\Store\Model\Store::class, - ['getWebsiteId'], - [], - '', - false - ); + $productMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['getId', 'getStore']); + $storeMock = $this->createPartialMock(\Magento\Store\Model\Store::class, ['getWebsiteId']); $stockItemMock = $this->getMockForAbstractClass( \Magento\CatalogInventory\Api\Data\StockItemInterface::class, [], @@ -123,8 +111,8 @@ public function testGetVariationWizard($wizardBlockName, $wizardHtml) ] ]; - $layout = $this->getMock(\Magento\Framework\View\LayoutInterface::class); - $wizardBlock = $this->getMock(\Magento\Ui\Block\Component\StepsWizard::class, [], [], '', false); + $layout = $this->createMock(\Magento\Framework\View\LayoutInterface::class); + $wizardBlock = $this->createMock(\Magento\Ui\Block\Component\StepsWizard::class); $layout->expects($this->any())->method('getChildName')->with(null, $wizardName) ->willReturn($wizardBlockName); $layout->expects($this->any())->method('getBlock')->with($wizardBlockName)->willReturn($wizardBlock); diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Adminhtml/Product/Steps/SelectAttributesTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Adminhtml/Product/Steps/SelectAttributesTest.php index 872514313108f..040329dbb3d87 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Adminhtml/Product/Steps/SelectAttributesTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Adminhtml/Product/Steps/SelectAttributesTest.php @@ -13,7 +13,7 @@ use Magento\Catalog\Api\Data\ProductInterface; use Magento\Framework\UrlInterface; -class SelectAttributesTest extends \PHPUnit_Framework_TestCase +class SelectAttributesTest extends \PHPUnit\Framework\TestCase { /** * @var SelectAttributes diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Cart/Item/Renderer/ConfigurableTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Cart/Item/Renderer/ConfigurableTest.php index 8260b777db29d..e199841cbcdc4 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Cart/Item/Renderer/ConfigurableTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Cart/Item/Renderer/ConfigurableTest.php @@ -8,7 +8,7 @@ use Magento\Catalog\Model\Config\Source\Product\Thumbnail as ThumbnailSource; use Magento\ConfigurableProduct\Block\Cart\Item\Renderer\Configurable as Renderer; -class ConfigurableTest extends \PHPUnit_Framework_TestCase +class ConfigurableTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Framework\View\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_configManager; @@ -29,22 +29,13 @@ protected function setUp() { parent::setUp(); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_configManager = $this->getMock(\Magento\Framework\View\ConfigInterface::class, [], [], '', false); - $this->_imageHelper = $this->getMock( + $this->_configManager = $this->createMock(\Magento\Framework\View\ConfigInterface::class); + $this->_imageHelper = $this->createPartialMock( \Magento\Catalog\Helper\Image::class, - ['init', 'resize', '__toString'], - [], - '', - false - ); - $this->_scopeConfig = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $this->productConfigMock = $this->getMock( - \Magento\Catalog\Helper\Product\Configuration::class, - [], - [], - '', - false + ['init', 'resize', '__toString'] ); + $this->_scopeConfig = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->productConfigMock = $this->createMock(\Magento\Catalog\Helper\Product\Configuration::class); $this->_renderer = $objectManagerHelper->getObject( \Magento\ConfigurableProduct\Block\Cart\Item\Renderer\Configurable::class, [ @@ -133,26 +124,20 @@ protected function _initProducts($childHasThumbnail = true, $useParentThumbnail /** Initialized parent product */ /** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $parentProduct */ - $parentProduct = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $parentProduct = $this->createMock(\Magento\Catalog\Model\Product::class); /** Initialize child product */ /** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $childProduct */ - $childProduct = $this->getMock( - \Magento\Catalog\Model\Product::class, - ['getThumbnail', '__wakeup'], - [], - '', - false - ); + $childProduct = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['getThumbnail', '__wakeup']); $childThumbnail = $childHasThumbnail ? 'thumbnail.jpg' : 'no_selection'; $childProduct->expects($this->any())->method('getThumbnail')->will($this->returnValue($childThumbnail)); /** Mock methods which return parent and child products */ /** @var \Magento\Quote\Model\Quote\Item\Option|\PHPUnit_Framework_MockObject_MockObject $itemOption */ - $itemOption = $this->getMock(\Magento\Quote\Model\Quote\Item\Option::class, [], [], '', false); + $itemOption = $this->createMock(\Magento\Quote\Model\Quote\Item\Option::class); $itemOption->expects($this->any())->method('getProduct')->will($this->returnValue($childProduct)); /** @var \Magento\Quote\Model\Quote\Item|\PHPUnit_Framework_MockObject_MockObject $item */ - $item = $this->getMock(\Magento\Quote\Model\Quote\Item::class, [], [], '', false); + $item = $this->createMock(\Magento\Quote\Model\Quote\Item::class); $item->expects($this->any())->method('getProduct')->will($this->returnValue($parentProduct)); $item->expects( $this->any() @@ -170,7 +155,7 @@ protected function _initProducts($childHasThumbnail = true, $useParentThumbnail public function testGetOptionList() { - $itemMock = $this->getMock(\Magento\Quote\Model\Quote\Item::class, [], [], '', false); + $itemMock = $this->createMock(\Magento\Quote\Model\Quote\Item::class); $this->_renderer->setItem($itemMock); $this->productConfigMock->expects($this->once())->method('getOptions')->with($itemMock); $this->_renderer->getOptionList(); @@ -179,9 +164,9 @@ public function testGetOptionList() public function testGetIdentities() { $productTags = ['catalog_product_1']; - $product = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $product = $this->createMock(\Magento\Catalog\Model\Product::class); $product->expects($this->exactly(2))->method('getIdentities')->will($this->returnValue($productTags)); - $item = $this->getMock(\Magento\Quote\Model\Quote\Item::class, [], [], '', false); + $item = $this->createMock(\Magento\Quote\Model\Quote\Item::class); $item->expects($this->exactly(2))->method('getProduct')->will($this->returnValue($product)); $this->_renderer->setItem($item); $this->assertEquals(array_merge($productTags, $productTags), $this->_renderer->getIdentities()); diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Plugin/Product/Media/GalleryTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Plugin/Product/Media/GalleryTest.php index 34e4925c7bc9b..83056e7d0554f 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Plugin/Product/Media/GalleryTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Plugin/Product/Media/GalleryTest.php @@ -12,7 +12,7 @@ /** * Class GalleryTest */ -class GalleryTest extends \PHPUnit_Framework_TestCase +class GalleryTest extends \PHPUnit\Framework\TestCase { public function testAfterGetOptions() diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Product/Configurable/AttributeSelectorTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Product/Configurable/AttributeSelectorTest.php index daece080baf7a..049be61fb9e36 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Product/Configurable/AttributeSelectorTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Product/Configurable/AttributeSelectorTest.php @@ -5,7 +5,7 @@ */ namespace Magento\ConfigurableProduct\Test\Unit\Block\Product\Configurable; -class AttributeSelectorTest extends \PHPUnit_Framework_TestCase +class AttributeSelectorTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\ConfigurableProduct\Block\Product\Configurable\AttributeSelector @@ -20,7 +20,7 @@ class AttributeSelectorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->urlBuilder = $this->getMock(\Magento\Framework\UrlInterface::class); + $this->urlBuilder = $this->createMock(\Magento\Framework\UrlInterface::class); $this->attributeSelector = $helper->getObject( \Magento\ConfigurableProduct\Block\Product\Configurable\AttributeSelector::class, ['urlBuilder' => $this->urlBuilder] diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Product/View/Type/ConfigurableTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Product/View/Type/ConfigurableTest.php index 05d34a4661003..1908d897be6da 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Product/View/Type/ConfigurableTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Product/View/Type/ConfigurableTest.php @@ -5,10 +5,13 @@ */ namespace Magento\ConfigurableProduct\Test\Unit\Block\Product\View\Type; +use Magento\Customer\Model\Session; +use Magento\Framework\App\State; + /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ConfigurableTest extends \PHPUnit_Framework_TestCase +class ConfigurableTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Catalog\Block\Product\Context|\PHPUnit_Framework_MockObject_MockObject @@ -65,6 +68,11 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase */ private $storeManager; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $customerSession; + protected function setUp() { $this->mockContextObject(); @@ -92,6 +100,28 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); + $appState = $this->getMockBuilder(State::class) + ->disableOriginalConstructor() + ->getMock(); + $this->context->expects($this->once()) + ->method('getAppState') + ->willReturn($appState); + $appState->expects($this->any()) + ->method('getAreaCode') + ->willReturn('frontend'); + $urlBuilder = $this->getMockBuilder(\Magento\Framework\UrlInterface::class) + ->disableOriginalConstructor() + ->getMock(); + $this->context->expects($this->once()) + ->method('getUrlBuilder') + ->willReturn($urlBuilder); + $fileResolverMock = $this + ->getMockBuilder(\Magento\Framework\View\Element\Template\File\Resolver::class) + ->disableOriginalConstructor() + ->getMock(); + $this->context->expects($this->once()) + ->method('getResolver') + ->willReturn($fileResolverMock); $this->configurableAttributeData = $this->getMockBuilder( \Magento\ConfigurableProduct\Model\ConfigurableAttributeData::class ) @@ -102,6 +132,10 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); + $this->customerSession = $this->getMockBuilder(Session::class) + ->disableOriginalConstructor() + ->getMock(); + $this->block = new \Magento\ConfigurableProduct\Block\Product\View\Type\Configurable( $this->context, $this->arrayUtils, @@ -112,10 +146,92 @@ protected function setUp() $this->priceCurrency, $this->configurableAttributeData, [], - $this->localeFormat + $this->localeFormat, + $this->customerSession ); } + /** + * Provide cache key info + * + * @return array + */ + public function cacheKeyProvider() : array + { + return [ + 'without_currency_and_customer_group' => [ + [ + 0 => 'BLOCK_TPL', + 1 => 'default', + 2 => null, + 'base_url' => null, + 'template' => null, + 3 => null, + 4 => null, + ], + null, + null, + ], + 'with_customer_group' => [ + [ + 0 => 'BLOCK_TPL', + 1 => 'default', + 2 => null, + 'base_url' => null, + 'template' => null, + 3 => null, + 4 => 1, + ], + null, + 1, + ], + 'with_price_currency' => [ + [ + 0 => 'BLOCK_TPL', + 1 => 'default', + 2 => null, + 'base_url' => null, + 'template' => null, + 3 => '$', + 4 => null, + ], + '$', + null, + ] + ]; + } + + /** + * Test cache Tags + * @dataProvider cacheKeyProvider + * @param array $expected + * @param string|null $priceCurrency + * @param string|null $customerGroupId + */ + public function testGetCacheKeyInfo(array $expected, string $priceCurrency = null, string $customerGroupId = null) + { + $storeMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class) + ->setMethods([ + 'getCurrentCurrency', + ]) + ->getMockForAbstractClass(); + $storeMock->expects($this->any()) + ->method('getCode') + ->willReturn('default'); + + $this->storeManager->expects($this->any()) + ->method('getStore') + ->willReturn($storeMock); + $this->priceCurrency->expects($this->once()) + ->method('getCurrencySymbol') + ->willReturn($priceCurrency); + $this->customerSession->expects($this->once()) + ->method('getCustomerGroupId') + ->willReturn($customerGroupId); + $actual = $this->block->getCacheKeyInfo(); + $this->assertEquals($expected, $actual); + } + /** * Check that getJsonConfig() method returns expected value */ diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/AddAttributeTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/AddAttributeTest.php index 8aadb8ece4e00..560a1cd527c2e 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/AddAttributeTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/AddAttributeTest.php @@ -9,7 +9,7 @@ use Magento\Framework\Controller\ResultFactory; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -class AddAttributeTest extends \PHPUnit_Framework_TestCase +class AddAttributeTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Framework\Controller\ResultFactory|\PHPUnit_Framework_MockObject_MockObject */ private $resultFactory; @@ -52,9 +52,9 @@ protected function setUp() $this->context = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class) ->disableOriginalConstructor() ->getMock(); - $this->request = $this->getMock(\Magento\Framework\App\RequestInterface::class); - $this->resultFactory = $this->getMock(\Magento\Framework\Controller\ResultFactory::class, [], [], '', false); - $this->response = $this->getMock( + $this->request = $this->createMock(\Magento\Framework\App\RequestInterface::class); + $this->resultFactory = $this->createMock(\Magento\Framework\Controller\ResultFactory::class); + $this->response = $this->createPartialMock( \Magento\Framework\App\ResponseInterface::class, [ 'sendResponse', @@ -65,7 +65,7 @@ protected function setUp() ->disableOriginalConstructor() ->setMethods(['build']) ->getMock(); - $this->view = $this->getMock(\Magento\Framework\App\ViewInterface::class); + $this->view = $this->createMock(\Magento\Framework\App\ViewInterface::class); $this->context->expects($this->any()) ->method('getRequest') @@ -97,7 +97,7 @@ public function testExecute() ->getMock(); $this->productBuilder->expects($this->once())->method('build')->with($this->request)->willReturn($product); - $resultLayout = $this->getMock(\Magento\Framework\View\Result\Layout::class, [], [], '', false); + $resultLayout = $this->createMock(\Magento\Framework\View\Result\Layout::class); $this->resultFactory->expects($this->once())->method('create')->with(ResultFactory::TYPE_LAYOUT) ->willReturn($resultLayout); diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Attribute/SuggestConfigurableAttributesTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Attribute/SuggestConfigurableAttributesTest.php index 2963b9841bbfc..13c13542c7355 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Attribute/SuggestConfigurableAttributesTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Attribute/SuggestConfigurableAttributesTest.php @@ -5,7 +5,7 @@ */ namespace Magento\ConfigurableProduct\Test\Unit\Controller\Adminhtml\Product\Attribute; -class SuggestConfigurableAttributesTest extends \PHPUnit_Framework_TestCase +class SuggestConfigurableAttributesTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\ConfigurableProduct\Controller\Adminhtml\Product\Attribute\SuggestConfigurableAttributes @@ -35,16 +35,10 @@ class SuggestConfigurableAttributesTest extends \PHPUnit_Framework_TestCase protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->responseMock = $this->getMock(\Magento\Framework\App\Response\Http::class, [], [], '', false); - $this->requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); - $this->helperMock = $this->getMock(\Magento\Framework\Json\Helper\Data::class, [], [], '', false); - $this->attributeListMock = $this->getMock( - \Magento\ConfigurableProduct\Model\SuggestedAttributeList::class, - [], - [], - '', - false - ); + $this->responseMock = $this->createMock(\Magento\Framework\App\Response\Http::class); + $this->requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class); + $this->helperMock = $this->createMock(\Magento\Framework\Json\Helper\Data::class); + $this->attributeListMock = $this->createMock(\Magento\ConfigurableProduct\Model\SuggestedAttributeList::class); $this->suggestAttributes = $helper->getObject( \Magento\ConfigurableProduct\Controller\Adminhtml\Product\Attribute\SuggestConfigurableAttributes::class, [ diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Builder/PluginTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Builder/PluginTest.php index 4a25e09c7403a..456407c14ca05 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Builder/PluginTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Builder/PluginTest.php @@ -5,7 +5,7 @@ */ namespace Magento\ConfigurableProduct\Test\Unit\Controller\Adminhtml\Product\Builder; -class PluginTest extends \PHPUnit_Framework_TestCase +class PluginTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\ConfigurableProduct\Controller\Adminhtml\Product\Builder\Plugin @@ -54,23 +54,13 @@ class PluginTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->productFactoryMock = $this->getMock( - \Magento\Catalog\Model\ProductFactory::class, - ['create'], - [], - '', - false + $this->productFactoryMock = $this->createPartialMock(\Magento\Catalog\Model\ProductFactory::class, ['create']); + $this->configurableTypeMock = $this->createMock( + \Magento\ConfigurableProduct\Model\Product\Type\Configurable::class ); - $this->configurableTypeMock = $this->getMock( - \Magento\ConfigurableProduct\Model\Product\Type\Configurable::class, - [], - [], - '', - false - ); - $this->requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); + $this->requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class); $methods = ['setTypeId', 'getAttributes', 'addData', 'setWebsiteIds', '__wakeup']; - $this->productMock = $this->getMock(\Magento\Catalog\Model\Product::class, $methods, [], '', false); + $this->productMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, $methods); $attributeMethods = [ 'getId', 'getFrontend', @@ -79,12 +69,9 @@ protected function setUp() 'setIsRequired', 'getIsUnique', ]; - $this->attributeMock = $this->getMock( + $this->attributeMock = $this->createPartialMock( \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, - $attributeMethods, - [], - '', - false + $attributeMethods ); $configMethods = [ 'setStoreId', @@ -97,27 +84,14 @@ protected function setUp() 'setTypeId', 'getSetAttributes', ]; - $this->configurableMock = $this->getMock( + $this->configurableMock = $this->createPartialMock( \Magento\ConfigurableProduct\Model\Product\Type\Configurable::class, - $configMethods, - [], - '', - false - ); - $this->frontendAttrMock = $this->getMock( - \Magento\Quote\Model\ResourceModel\Quote\Address\Attribute\Frontend::class, - [], - [], - '', - false + $configMethods ); - $this->subjectMock = $this->getMock( - \Magento\Catalog\Controller\Adminhtml\Product\Builder::class, - [], - [], - '', - false + $this->frontendAttrMock = $this->createMock( + \Magento\Quote\Model\ResourceModel\Quote\Address\Attribute\Frontend::class ); + $this->subjectMock = $this->createMock(\Magento\Catalog\Controller\Adminhtml\Product\Builder::class); $this->plugin = new \Magento\ConfigurableProduct\Controller\Adminhtml\Product\Builder\Plugin( $this->productFactoryMock, $this->configurableTypeMock diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/ConfigurableTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/ConfigurableTest.php index bbab246625f67..90306de598895 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/ConfigurableTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/ConfigurableTest.php @@ -18,7 +18,7 @@ /** * Class ConfigurableTest */ -class ConfigurableTest extends \PHPUnit_Framework_TestCase +class ConfigurableTest extends \PHPUnit\Framework\TestCase { /** * @var Magento\ConfigurableProduct\Model\Product\VariationHandler|MockObject @@ -150,7 +150,7 @@ public function testAfterInitializeWithAttributesAndVariations() ] ]; $paramValueMap = [ - ['configurable-matrix-serialized', '[]', json_encode($simpleProducts)], + ['configurable-matrix-serialized', "[]", json_encode($simpleProducts)], ['attributes', null, $attributes], ]; @@ -212,11 +212,11 @@ public function testAfterInitializeWithAttributesAndWithoutVariations() ]; $valueMap = [ ['new-variations-attribute-set-id', null, 24], - ['associated_product_ids_serialized', '[]', []], + ['associated_product_ids_serialized', "[]", "[]"], ['product', [], ['configurable_attributes_data' => $attributes]], ]; $paramValueMap = [ - ['configurable-matrix-serialized', '[]', []], + ['configurable-matrix-serialized', "[]", "[]"], ['attributes', null, $attributes], ]; diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/UpdateConfigurationsTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/UpdateConfigurationsTest.php index 6adfd86ac7608..fb63dc330db32 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/UpdateConfigurationsTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/UpdateConfigurationsTest.php @@ -18,7 +18,7 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @package Magento\ConfigurableProduct\Test\Unit\Controller\Adminhtml\Product\Initialization\Helper\Plugin */ -class UpdateConfigurationsTest extends \PHPUnit_Framework_TestCase +class UpdateConfigurationsTest extends \PHPUnit\Framework\TestCase { /** * @var UpdateConfigurations @@ -153,7 +153,7 @@ public function testAfterInitialize() ->willReturnMap( [ ['store', 0, 0], - ['configurable-matrix-serialized', '[]', json_encode($configurableMatrix)] + ['configurable-matrix-serialized', "[]", json_encode($configurableMatrix)] ] ); $this->variationHandlerMock->expects(static::once()) @@ -210,4 +210,30 @@ protected function getProductMock(array $expectedData = null, $hasDataChanges = } return $productMock; } + + /** + * Test for no exceptions if configurable matrix is empty string. + */ + public function testAfterInitializeEmptyMatrix() + { + $productMock = $this->getProductMock(); + + $this->requestMock->expects(static::any()) + ->method('getParam') + ->willReturnMap( + [ + ['store', 0, 0], + ['configurable-matrix-serialized', null, ''], + ] + ); + + $this->variationHandlerMock->expects(static::once()) + ->method('duplicateImagesForVariations') + ->with([]) + ->willReturn([]); + + $this->updateConfigurations->afterInitialize($this->subjectMock, $productMock); + + $this->assertEmpty($productMock->getData()); + } } diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/WizardTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/WizardTest.php index ea3f87d5ea4db..a191f62ebce9a 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/WizardTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/WizardTest.php @@ -9,7 +9,7 @@ use Magento\Framework\Controller\ResultFactory; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -class WizardTest extends \PHPUnit_Framework_TestCase +class WizardTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Helper/DataTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Helper/DataTest.php index e0d57201c0ad2..c89d6e2e9ac45 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Helper/DataTest.php @@ -8,7 +8,7 @@ namespace Magento\ConfigurableProduct\Test\Unit\Helper; -class DataTest extends \PHPUnit_Framework_TestCase +class DataTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\ConfigurableProduct\Helper\Data|\PHPUnit_Framework_MockObject_MockObject @@ -27,17 +27,15 @@ class DataTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_imageHelperMock = $this->getMock(\Magento\Catalog\Helper\Image::class, [], [], '', false); - $this->_productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $this->_imageHelperMock = $this->createMock(\Magento\Catalog\Helper\Image::class); + $this->_productMock = $this->createMock(\Magento\Catalog\Model\Product::class); $this->_model = new \Magento\ConfigurableProduct\Helper\Data($this->_imageHelperMock); } public function testGetAllowAttributes() { - $typeInstanceMock = $this->getMock( - \Magento\ConfigurableProduct\Model\Product\Type\Configurable::class, [], [], '', false - ); + $typeInstanceMock = $this->createMock(\Magento\ConfigurableProduct\Model\Product\Type\Configurable::class); $typeInstanceMock->expects($this->once()) ->method('getConfigurableAttributes') ->with($this->_productMock); @@ -91,9 +89,7 @@ public function testGetOptions(array $expected, array $data) */ public function getOptionsDataProvider() { - $currentProductMock = $this->getMock( - \Magento\Catalog\Model\Product::class, ['getTypeInstance', '__wakeup'], [], '', false - ); + $currentProductMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['getTypeInstance', '__wakeup']); $provider = []; $provider[] = [ [], @@ -106,16 +102,8 @@ public function getOptionsDataProvider() $attributesCount = 3; $attributes = []; for ($i = 1; $i < $attributesCount; $i++) { - $attribute = $this->getMock( - \Magento\Framework\DataObject::class, ['getProductAttribute'], [], '', false - ); - $productAttribute = $this->getMock( - \Magento\Framework\DataObject::class, - ['getId', 'getAttributeCode'], - [], - '', - false - ); + $attribute = $this->createPartialMock(\Magento\Framework\DataObject::class, ['getProductAttribute']); + $productAttribute = $this->createPartialMock(\Magento\Framework\DataObject::class, ['getId', 'getAttributeCode']); $productAttribute->expects($this->any()) ->method('getId') ->will($this->returnValue('attribute_id_' . $i)); @@ -127,9 +115,7 @@ public function getOptionsDataProvider() ->will($this->returnValue($productAttribute)); $attributes[] = $attribute; } - $typeInstanceMock = $this->getMock( - \Magento\ConfigurableProduct\Model\Product\Type\Configurable::class, [], [], '', false - ); + $typeInstanceMock = $this->createMock(\Magento\ConfigurableProduct\Model\Product\Type\Configurable::class); $typeInstanceMock->expects($this->any()) ->method('getConfigurableAttributes') ->will($this->returnValue($attributes)); @@ -138,9 +124,7 @@ public function getOptionsDataProvider() ->will($this->returnValue($typeInstanceMock)); $allowedProducts = []; for ($i = 1; $i <= 2; $i++) { - $productMock = $this->getMock( - \Magento\Catalog\Model\Product::class, ['getData', 'getImage', 'getId', '__wakeup', 'getMediaGalleryImages'], [], '', false - ); + $productMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['getData', 'getImage', 'getId', '__wakeup', 'getMediaGalleryImages']); $productMock->expects($this->any()) ->method('getData') ->will($this->returnCallback([$this, 'getDataCallback'])); diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Helper/Product/Configuration/PluginTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Helper/Product/Configuration/PluginTest.php index de0ce31337fc0..00ab43028ffd6 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Helper/Product/Configuration/PluginTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Helper/Product/Configuration/PluginTest.php @@ -5,7 +5,7 @@ */ namespace Magento\ConfigurableProduct\Test\Unit\Helper\Product\Configuration; -class PluginTest extends \PHPUnit_Framework_TestCase +class PluginTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\ConfigurableProduct\Helper\Product\Configuration\Plugin @@ -39,26 +39,17 @@ class PluginTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->itemMock = $this->getMock(\Magento\Catalog\Model\Product\Configuration\Item\ItemInterface::class); - $this->productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); - $this->typeInstanceMock = $this->getMock( + $this->itemMock = $this->createMock(\Magento\Catalog\Model\Product\Configuration\Item\ItemInterface::class); + $this->productMock = $this->createMock(\Magento\Catalog\Model\Product::class); + $this->typeInstanceMock = $this->createPartialMock( \Magento\ConfigurableProduct\Model\Product\Type\Configurable::class, - ['getSelectedAttributesInfo', '__wakeup'], - [], - '', - false + ['getSelectedAttributesInfo', '__wakeup'] ); $this->itemMock->expects($this->once())->method('getProduct')->will($this->returnValue($this->productMock)); $this->closureMock = function () { return ['options']; }; - $this->subjectMock = $this->getMock( - \Magento\Catalog\Helper\Product\Configuration::class, - [], - [], - '', - false - ); + $this->subjectMock = $this->createMock(\Magento\Catalog\Helper\Product\Configuration::class); $this->plugin = new \Magento\ConfigurableProduct\Helper\Product\Configuration\Plugin(); } diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Helper/Product/Options/FactoryTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Helper/Product/Options/FactoryTest.php index 19f09a6417339..5fef85d8c581c 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Helper/Product/Options/FactoryTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Helper/Product/Options/FactoryTest.php @@ -21,7 +21,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class FactoryTest extends \PHPUnit_Framework_TestCase +class FactoryTest extends \PHPUnit\Framework\TestCase { /** * @var Configurable|MockObject @@ -75,7 +75,7 @@ protected function setUp() ->setMethods(['create']) ->getMock(); - $this->productAttributeRepository = $this->getMock(ProductAttributeRepositoryInterface::class); + $this->productAttributeRepository = $this->createMock(ProductAttributeRepositoryInterface::class); $this->factory = new Factory( $this->configurable, @@ -156,7 +156,7 @@ public function testCreate() ->with($eavAttribute) ->willReturn(true); - $option = $this->getMock(OptionValueInterface::class); + $option = $this->createMock(OptionValueInterface::class); $option->expects(static::once()) ->method('setValueIndex') ->with($valueIndex) diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Helper/Product/Options/LoaderTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Helper/Product/Options/LoaderTest.php index 586ef6e44e10e..921a2bcfcc2ef 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Helper/Product/Options/LoaderTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Helper/Product/Options/LoaderTest.php @@ -18,7 +18,7 @@ /** * Class LoaderTest */ -class LoaderTest extends \PHPUnit_Framework_TestCase +class LoaderTest extends \PHPUnit\Framework\TestCase { /** * @var OptionValueInterfaceFactory|MockObject diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Attribute/LockValidatorTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Attribute/LockValidatorTest.php index f83ced1fc73d9..090c464d49307 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Attribute/LockValidatorTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Attribute/LockValidatorTest.php @@ -12,7 +12,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\ConfigurableProduct\Model\Attribute\LockValidator; -class LockValidatorTest extends \PHPUnit_Framework_TestCase +class LockValidatorTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\ConfigurableProduct\Model\Attribute\LockValidator diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/AttributeOptionProviderTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/AttributeOptionProviderTest.php index 8a2530ab58eb2..cdaad049423af 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/AttributeOptionProviderTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/AttributeOptionProviderTest.php @@ -20,7 +20,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class AttributeOptionProviderTest extends \PHPUnit_Framework_TestCase +class AttributeOptionProviderTest extends \PHPUnit\Framework\TestCase { /** * @var AttributeOptionProvider diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/AttributesListTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/AttributesListTest.php index c629efe51c282..03dcb62d205cf 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/AttributesListTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/AttributesListTest.php @@ -6,7 +6,7 @@ namespace Magento\ConfigurableProduct\Test\Unit\Model; -class AttributesListTest extends \PHPUnit_Framework_TestCase +class AttributesListTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\ConfigurableProduct\Model\AttributesList @@ -25,31 +25,21 @@ class AttributesListTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->collectionMock = $this->getMock( - \Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection::class, - [], - [], - '', - false + $this->collectionMock = $this->createMock( + \Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection::class ); /** @var \Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory $collectionFactoryMock */ - $collectionFactoryMock = $this->getMock( + $collectionFactoryMock = $this->createPartialMock( \Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory::class, - ['create'], - [], - '', - false + ['create'] ); $collectionFactoryMock->expects($this->once())->method('create')->willReturn($this->collectionMock); $methods = ['getId', 'getFrontendLabel', 'getAttributeCode', 'getSource']; - $this->attributeMock = $this->getMock( + $this->attributeMock = $this->createPartialMock( \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, - $methods, - [], - '', - false + $methods ); $this->collectionMock ->expects($this->once()) @@ -82,7 +72,7 @@ public function testGetAttributes() $this->attributeMock->expects($this->once())->method('getFrontendLabel')->will($this->returnValue('label')); $this->attributeMock->expects($this->once())->method('getAttributeCode')->will($this->returnValue('code')); - $source = $this->getMock(\Magento\Eav\Model\Entity\Attribute\Source\AbstractSource::class, [], [], '', false); + $source = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Source\AbstractSource::class); $source->expects($this->once())->method('getAllOptions')->with(false)->will($this->returnValue(['options'])); $this->attributeMock->expects($this->once())->method('getSource')->will($this->returnValue($source)); diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ConfigurableAttributeDataTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ConfigurableAttributeDataTest.php index c3c60f1e4d58a..df61b68c14cb1 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ConfigurableAttributeDataTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ConfigurableAttributeDataTest.php @@ -9,7 +9,7 @@ /** * Class CustomOptionTest */ -class ConfigurableAttributeDataTest extends \PHPUnit_Framework_TestCase +class ConfigurableAttributeDataTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject @@ -32,26 +32,16 @@ class ConfigurableAttributeDataTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->product = $this->getMock( - \Magento\Catalog\Model\Product::class, - [ + $this->product = $this->createPartialMock(\Magento\Catalog\Model\Product::class, [ 'getTypeInstance', 'setParentId', 'hasPreconfiguredValues', 'getPreconfiguredValues', 'getPriceInfo', 'getStoreId' - ], - [], - '', - false - ); - $this->attributeMock = $this->getMock( - \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Attribute::class, - [], - [], - '', - false + ]); + $this->attributeMock = $this->createMock( + \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Attribute::class ); $this->configurableAttributeData = new \Magento\ConfigurableProduct\Model\ConfigurableAttributeData(); } diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ConfigurableProductManagementTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ConfigurableProductManagementTest.php index 47da829cb0e71..bed3d82768085 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ConfigurableProductManagementTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ConfigurableProductManagementTest.php @@ -9,7 +9,7 @@ use Magento\ConfigurableProduct\Model\ConfigurableProductManagement; use Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Product\CollectionFactory; -class ConfigurableProductManagementTest extends \PHPUnit_Framework_TestCase +class ConfigurableProductManagementTest extends \PHPUnit\Framework\TestCase { /** * @var ConfigurableProductManagement @@ -43,28 +43,17 @@ class ConfigurableProductManagementTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->attributeRepository = $this->getMock(\Magento\Catalog\Api\ProductAttributeRepositoryInterface::class); - $this->product = $this->getMock(\Magento\Catalog\Api\Data\ProductInterface::class); - $this->option = $this->getMock( - \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute::class, - [], - [], - '', - false + $this->attributeRepository = $this->createMock(\Magento\Catalog\Api\ProductAttributeRepositoryInterface::class); + $this->product = $this->createMock(\Magento\Catalog\Api\Data\ProductInterface::class); + $this->option = $this->createMock( + \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute::class ); - $this->productVariationBuilder = $this->getMock( - \Magento\ConfigurableProduct\Model\ProductVariationsBuilder::class, - [], - [], - '', - false + $this->productVariationBuilder = $this->createMock( + \Magento\ConfigurableProduct\Model\ProductVariationsBuilder::class ); - $this->productsFactoryMock = $this->getMock( + $this->productsFactoryMock = $this->createPartialMock( \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Product\CollectionFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->model = new ConfigurableProductManagement( @@ -77,10 +66,10 @@ protected function setUp() public function testGenerateVariation() { $data = ['someKey' => 'someValue']; - $attributeOption = $this->getMock(\Magento\Eav\Model\Entity\Attribute\Option::class, [], [], '', false); + $attributeOption = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Option::class); $attributeOption->expects($this->once())->method('getData')->willReturn(['key' => 'value']); - $attribute = $this->getMock(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, [], [], '', false); + $attribute = $this->createMock(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class); $attribute->expects($this->any())->method('getOptions')->willReturn([$attributeOption]); $attribute->expects($this->once())->method('getAttributeCode')->willReturn(10); @@ -109,12 +98,8 @@ public function testGenerateVariation() public function testGetEnabledCount() { $statusEnabled = 1; - $productsMock = $this->getMock( - \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Product\Collection::class, - [], - [], - '', - false + $productsMock = $this->createMock( + \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Product\Collection::class ); $this->productsFactoryMock @@ -140,12 +125,8 @@ public function testGetEnabledCount() public function testGetDisabledCount() { $statusDisabled = 2; - $productsMock = $this->getMock( - \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Product\Collection::class, - [], - [], - '', - false + $productsMock = $this->createMock( + \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Product\Collection::class ); $this->productsFactoryMock diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Entity/Product/Attribute/Group/AttributeMapper/PluginTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Entity/Product/Attribute/Group/AttributeMapper/PluginTest.php index dc47aad60d0bd..6c90dff257ee0 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Entity/Product/Attribute/Group/AttributeMapper/PluginTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Entity/Product/Attribute/Group/AttributeMapper/PluginTest.php @@ -8,7 +8,7 @@ use Magento\Eav\Model\Entity\Attribute; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class PluginTest extends \PHPUnit_Framework_TestCase +class PluginTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\ConfigurableProduct\Model\Entity\Product\Attribute\Group\AttributeMapper\Plugin diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/LinkManagementTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/LinkManagementTest.php index f94bf1999dd55..acbb976318b3b 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/LinkManagementTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/LinkManagementTest.php @@ -12,7 +12,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class LinkManagementTest extends \PHPUnit_Framework_TestCase +class LinkManagementTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -46,14 +46,11 @@ class LinkManagementTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->productRepository = $this->getMock(\Magento\Catalog\Api\ProductRepositoryInterface::class); + $this->productRepository = $this->createMock(\Magento\Catalog\Api\ProductRepositoryInterface::class); $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->productFactory = $this->getMock( + $this->productFactory = $this->createPartialMock( \Magento\Catalog\Api\Data\ProductInterfaceFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->dataObjectHelperMock = $this->getMockBuilder(\Magento\Framework\Api\DataObjectHelper::class) ->disableOriginalConstructor() @@ -102,14 +99,14 @@ public function testGetChildren() ->method('get')->with($productId) ->willReturn($product); - $attribute = $this->getMock(\Magento\Eav\Api\Data\AttributeInterface::class); + $attribute = $this->createMock(\Magento\Eav\Api\Data\AttributeInterface::class); $attribute->expects($this->once())->method('getAttributeCode')->willReturn('code'); $childProduct->expects($this->once())->method('getDataUsingMethod')->with('code')->willReturn(false); $childProduct->expects($this->once())->method('getData')->with('code')->willReturn(10); $childProduct->expects($this->once())->method('getStoreId')->willReturn(1); $childProduct->expects($this->once())->method('getAttributes')->willReturn([$attribute]); - $productMock = $this->getMock(\Magento\Catalog\Api\Data\ProductInterface::class); + $productMock = $this->createMock(\Magento\Catalog\Api\Data\ProductInterface::class); $this->dataObjectHelperMock->expects($this->once()) ->method('populateWithArray') @@ -320,7 +317,7 @@ public function testRemoveChildForbidden() $productSku = 'configurable'; $childSku = 'simple_10'; - $product = $this->getMock(\Magento\Catalog\Api\Data\ProductInterface::class); + $product = $this->createMock(\Magento\Catalog\Api\Data\ProductInterface::class); $product->expects($this->any()) ->method('getTypeId') diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/OptionRepositoryTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/OptionRepositoryTest.php index 9fdadc3dd3dc6..2d824e52c7244 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/OptionRepositoryTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/OptionRepositoryTest.php @@ -16,7 +16,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class OptionRepositoryTest extends \PHPUnit_Framework_TestCase +class OptionRepositoryTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\ConfigurableProduct\Model\OptionRepository @@ -53,7 +53,7 @@ protected function setUp() $this->productRepositoryMock = $this->getMockBuilder(ProductRepositoryInterface::class) ->getMockForAbstractClass(); - $this->productMock = $this->getMock(\Magento\Catalog\Api\Data\ProductInterface::class); + $this->productMock = $this->createMock(\Magento\Catalog\Api\Data\ProductInterface::class); $this->configurableTypeResource = $this->getMockBuilder( \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable::class @@ -95,7 +95,7 @@ public function testGet() ->with($productSku) ->willReturn($this->productMock); - $optionMock = $this->getMock(OptionInterface::class); + $optionMock = $this->createMock(OptionInterface::class); $optionMock->expects(self::once()) ->method('getId') ->willReturn($optionId); @@ -129,7 +129,7 @@ public function testGetNotConfigurableProduct() ->with($productSku) ->willReturn($this->productMock); - $optionMock = $this->getMock(OptionInterface::class); + $optionMock = $this->createMock(OptionInterface::class); $optionMock->expects(self::never()) ->method('getId'); @@ -147,7 +147,7 @@ public function testGetNotProductById() { $entityId = 3; /** @var OptionInterface $optionMock */ - $optionMock = $this->getMock(OptionInterface::class); + $optionMock = $this->createMock(OptionInterface::class); $this->configurableTypeResource->expects(self::once()) ->method('getEntityIdByAttribute') @@ -174,7 +174,7 @@ public function testDeleteCantSaveProducts() { $entityId = 3; /** @var OptionInterface $optionMock */ - $optionMock = $this->getMock(OptionInterface::class); + $optionMock = $this->createMock(OptionInterface::class); $this->configurableTypeResource->expects(self::once()) ->method('getEntityIdByAttribute') @@ -292,7 +292,7 @@ public function testGetEmptyExtensionAttribute() ->with($productSku) ->willReturn($this->productMock); - $optionMock = $this->getMock(OptionInterface::class); + $optionMock = $this->createMock(OptionInterface::class); $optionMock->expects(self::never()) ->method('getId'); @@ -317,7 +317,7 @@ public function testGetList() ->with($productSku) ->willReturn($this->productMock); - $optionMock = $this->getMock(OptionInterface::class); + $optionMock = $this->createMock(OptionInterface::class); $this->optionLoader->expects(self::once()) ->method('load') @@ -356,8 +356,10 @@ public function testGetListNotConfigurableProduct() */ public function testValidateNewOptionData($attributeId, $label, $optionValues, $msg) { - $this->setExpectedException(\Magento\Framework\Exception\InputException::class, $msg); - $optionValueMock = $this->getMock(\Magento\ConfigurableProduct\Api\Data\OptionValueInterface::class); + $this->expectException(\Magento\Framework\Exception\InputException::class, $msg); + $optionValueMock = $this->getMockBuilder(\Magento\ConfigurableProduct\Api\Data\OptionValueInterface::class) + ->setMethods(['getValueIndex', 'getPricingValue', 'getIsPercent']) + ->getMockForAbstractClass(); $optionValuesMock = []; if (!empty($optionValues)) { $optionValueMock->expects($this->any()) @@ -372,7 +374,7 @@ public function testValidateNewOptionData($attributeId, $label, $optionValues, $ $optionValuesMock = [$optionValueMock]; } - $optionMock = $this->getMock(\Magento\ConfigurableProduct\Api\Data\OptionInterface::class); + $optionMock = $this->createMock(\Magento\ConfigurableProduct\Api\Data\OptionInterface::class); $optionMock->expects($this->any()) ->method('getAttributeId') ->willReturn($attributeId); diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Order/Admin/Item/Plugin/ConfigurableTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Order/Admin/Item/Plugin/ConfigurableTest.php index bcbb2cfe47fd4..163111b8545f7 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Order/Admin/Item/Plugin/ConfigurableTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Order/Admin/Item/Plugin/ConfigurableTest.php @@ -5,7 +5,7 @@ */ namespace Magento\ConfigurableProduct\Test\Unit\Model\Order\Admin\Item\Plugin; -class ConfigurableTest extends \PHPUnit_Framework_TestCase +class ConfigurableTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\ConfigurableProduct\Model\Order\Admin\Item\Plugin\Configurable @@ -39,25 +39,16 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->itemMock = $this->getMock( + $this->itemMock = $this->createPartialMock( \Magento\Sales\Model\Order\Item::class, - ['getProductType', 'getProductOptions', '__wakeup'], - [], - '', - false + ['getProductType', 'getProductOptions', '__wakeup'] ); $this->closureMock = function () { return 'Expected'; }; - $this->productFactoryMock = $this->getMock( - \Magento\Catalog\Model\ProductFactory::class, - ['create'], - [], - '', - false - ); - $this->productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); - $this->subjectMock = $this->getMock(\Magento\Sales\Model\Order\Admin\Item::class, [], [], '', false); + $this->productFactoryMock = $this->createPartialMock(\Magento\Catalog\Model\ProductFactory::class, ['create']); + $this->productMock = $this->createMock(\Magento\Catalog\Model\Product::class); + $this->subjectMock = $this->createMock(\Magento\Sales\Model\Order\Admin\Item::class); $this->configurable = new \Magento\ConfigurableProduct\Model\Order\Admin\Item\Plugin\Configurable( $this->productFactoryMock ); diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Plugin/PriceBackendTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Plugin/PriceBackendTest.php index e6c582319ea8e..992a27eb41dc9 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Plugin/PriceBackendTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Plugin/PriceBackendTest.php @@ -17,7 +17,7 @@ /** * Class PriceBackendTest */ -class PriceBackendTest extends \PHPUnit_Framework_TestCase +class PriceBackendTest extends \PHPUnit\Framework\TestCase { const CLOSURE_VALUE = 'CLOSURE'; diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Plugin/ProductRepositorySaveTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Plugin/ProductRepositorySaveTest.php index 913d72e6a4a47..1c3e421ae924f 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Plugin/ProductRepositorySaveTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Plugin/ProductRepositorySaveTest.php @@ -21,7 +21,7 @@ * Class ProductRepositorySaveTest * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ProductRepositorySaveTest extends \PHPUnit_Framework_TestCase +class ProductRepositorySaveTest extends \PHPUnit\Framework\TestCase { /** * @var ProductAttributeRepositoryInterface|MockObject @@ -79,7 +79,7 @@ protected function setUp() $this->product = $this->getMockBuilder(Product::class) ->disableOriginalConstructor() - ->setMethods(['getTypeId']) + ->setMethods(['getTypeId', 'getExtensionAttributes']) ->getMock(); $this->result = $this->getMockBuilder(Product::class) diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Cache/Tag/ConfigurableTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Cache/Tag/ConfigurableTest.php index 634c80f4fe249..519288a50c858 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Cache/Tag/ConfigurableTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Cache/Tag/ConfigurableTest.php @@ -6,9 +6,9 @@ namespace Magento\ConfigurableProduct\Test\Unit\Model\Product\Cache\Tag; -use \Magento\ConfigurableProduct\Model\Product\Cache\Tag\Configurable; +use Magento\ConfigurableProduct\Model\Product\Cache\Tag\Configurable; -class ConfigurableTest extends \PHPUnit_Framework_TestCase +class ConfigurableTest extends \PHPUnit\Framework\TestCase { /** @@ -23,12 +23,8 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->typeResource = $this->getMock( - \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable::class, - [], - [], - '', - false + $this->typeResource = $this->createMock( + \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable::class ); $this->model = new Configurable($this->typeResource); @@ -36,19 +32,19 @@ protected function setUp() public function testGetWithScalar() { - $this->setExpectedException(\InvalidArgumentException::class, 'Provided argument is not an object'); + $this->expectException(\InvalidArgumentException::class, 'Provided argument is not an object'); $this->model->getTags('scalar'); } public function testGetTagsWithObject() { - $this->setExpectedException(\InvalidArgumentException::class, 'Provided argument must be a product'); - $this->model->getTags(new \StdClass); + $this->expectException(\InvalidArgumentException::class, 'Provided argument must be a product'); + $this->model->getTags(new \StdClass()); } public function testGetTagsWithVariation() { - $product = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $product = $this->createMock(\Magento\Catalog\Model\Product::class); $identities = ['id1', 'id2']; diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/CartConfiguration/Plugin/ConfigurableTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/CartConfiguration/Plugin/ConfigurableTest.php index c557858b4777c..1e808a97da39e 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/CartConfiguration/Plugin/ConfigurableTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/CartConfiguration/Plugin/ConfigurableTest.php @@ -5,7 +5,7 @@ */ namespace Magento\ConfigurableProduct\Test\Unit\Model\Product\CartConfiguration\Plugin; -class ConfigurableTest extends \PHPUnit_Framework_TestCase +class ConfigurableTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\ConfigurableProduct\Model\Product\CartConfiguration\Plugin\Configurable @@ -32,14 +32,8 @@ protected function setUp() $this->closureMock = function () { return 'Expected'; }; - $this->productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); - $this->subjectMock = $this->getMock( - \Magento\Catalog\Model\Product\CartConfiguration::class, - [], - [], - '', - false - ); + $this->productMock = $this->createMock(\Magento\Catalog\Model\Product::class); + $this->subjectMock = $this->createMock(\Magento\Catalog\Model\Product\CartConfiguration::class); $this->model = new \Magento\ConfigurableProduct\Model\Product\CartConfiguration\Plugin\Configurable(); } diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/ReadHandlerTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/ReadHandlerTest.php index 9bc3d75592b58..b1f708e3c4062 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/ReadHandlerTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/ReadHandlerTest.php @@ -14,7 +14,7 @@ /** * Class ReadHandlerTest */ -class ReadHandlerTest extends \PHPUnit_Framework_TestCase +class ReadHandlerTest extends \PHPUnit\Framework\TestCase { /** * @var ReadHandler diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/SaveHandlerTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/SaveHandlerTest.php index 4b10a7af63003..6fda5b867ccef 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/SaveHandlerTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/SaveHandlerTest.php @@ -21,7 +21,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class SaveHandlerTest extends \PHPUnit_Framework_TestCase +class SaveHandlerTest extends \PHPUnit\Framework\TestCase { /** * @var OptionRepository|MockObject @@ -220,12 +220,12 @@ private function initConfigurableFactoryMock() /** * Mock for options save * - * @param MockObject $attribute + * @param \PHPUnit_Framework_MockObject_MockObject $attribute * @param $sku * @param $id * @return void */ - private function processSaveOptions(MockObject $attribute, $sku, $id) + private function processSaveOptions(\PHPUnit_Framework_MockObject_MockObject $attribute, $sku, $id) { $attribute->expects(static::once()) ->method('setId') diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Type/Collection/SalableProcessorTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Type/Collection/SalableProcessorTest.php index ca15633ee0a33..4e42da090e57a 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Type/Collection/SalableProcessorTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Type/Collection/SalableProcessorTest.php @@ -9,7 +9,7 @@ use Magento\Catalog\Api\Data\ProductInterface; use Magento\Catalog\Model\Product\Attribute\Source\Status; -class SalableProcessorTest extends \PHPUnit_Framework_TestCase +class SalableProcessorTest extends \PHPUnit\Framework\TestCase { const STOCK_FLAG = 'has_stock_status_filter'; diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Type/Configurable/PriceTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Type/Configurable/PriceTest.php index d75ed5367caad..64b9b3776442a 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Type/Configurable/PriceTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Type/Configurable/PriceTest.php @@ -8,7 +8,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -class PriceTest extends \PHPUnit_Framework_TestCase +class PriceTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Price */ protected $model; diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Type/ConfigurableTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Type/ConfigurableTest.php index 7cde8ea54fba8..6ffdede34d04c 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Type/ConfigurableTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Type/ConfigurableTest.php @@ -29,7 +29,7 @@ * @SuppressWarnings(PHPMD.TooManyFields) * @codingStandardsIgnoreFile */ -class ConfigurableTest extends \PHPUnit_Framework_TestCase +class ConfigurableTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Catalog\Api\Data\ProductInterfaceFactory @@ -202,13 +202,7 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); - $this->salableProcessor = $this->getMock( - SalableProcessor::class, - [], - [], - '', - false - ); + $this->salableProcessor = $this->createMock(SalableProcessor::class); $this->model = $this->objectHelper->getObject( Configurable::class, diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Type/PluginTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Type/PluginTest.php index 2236207a1207b..8d54c465f7431 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Type/PluginTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Type/PluginTest.php @@ -11,7 +11,7 @@ /** * Class \Magento\ConfigurableProduct\Test\Unit\Model\Product\Type\PluginTest */ -class PluginTest extends \PHPUnit_Framework_TestCase +class PluginTest extends \PHPUnit\Framework\TestCase { /** * @param array $expected @@ -20,9 +20,7 @@ class PluginTest extends \PHPUnit_Framework_TestCase */ public function testAfterGetOptionArray(array $expected, array $data) { - $moduleManagerMock = $this->getMock( - \Magento\Framework\Module\Manager::class, ['isOutputEnabled'], [], '', false - ); + $moduleManagerMock = $this->createPartialMock(\Magento\Framework\Module\Manager::class, ['isOutputEnabled']); $moduleManagerMock->expects($this->once()) ->method('isOutputEnabled') ->with('Magento_ConfigurableProduct') @@ -40,7 +38,7 @@ public function testAfterGetOptionArray(array $expected, array $data) */ public function afterGetOptionArrayDataProvider() { - $productTypeMock = $this->getMock(\Magento\Catalog\Model\Product\Type::class, [], [], '', false); + $productTypeMock = $this->createMock(\Magento\Catalog\Model\Product\Type::class); return [ [ [ diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Type/VariationMatrixTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Type/VariationMatrixTest.php index 601cf1998b99c..41995be418130 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Type/VariationMatrixTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Type/VariationMatrixTest.php @@ -8,7 +8,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -class VariationMatrixTest extends \PHPUnit_Framework_TestCase +class VariationMatrixTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\ConfigurableProduct\Model\Product\Type\VariationMatrix */ protected $model; diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/TypeTransitionManager/Plugin/ConfigurableTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/TypeTransitionManager/Plugin/ConfigurableTest.php index abd93d03227b6..1495eed5ec396 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/TypeTransitionManager/Plugin/ConfigurableTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/TypeTransitionManager/Plugin/ConfigurableTest.php @@ -5,7 +5,7 @@ */ namespace Magento\ConfigurableProduct\Test\Unit\Model\Product\TypeTransitionManager\Plugin; -class ConfigurableTest extends \PHPUnit_Framework_TestCase +class ConfigurableTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -34,24 +34,12 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); + $this->requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class); $this->model = new \Magento\ConfigurableProduct\Model\Product\TypeTransitionManager\Plugin\Configurable( $this->requestMock ); - $this->productMock = $this->getMock( - \Magento\Catalog\Model\Product::class, - ['setTypeId', '__wakeup'], - [], - '', - false - ); - $this->subjectMock = $this->getMock( - \Magento\Catalog\Model\Product\TypeTransitionManager::class, - [], - [], - '', - false - ); + $this->productMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['setTypeId', '__wakeup']); + $this->subjectMock = $this->createMock(\Magento\Catalog\Model\Product\TypeTransitionManager::class); $this->closureMock = function () { return 'Expected'; }; diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Validator/PluginTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Validator/PluginTest.php index 43e78d5434ad3..5f95d98054600 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Validator/PluginTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Validator/PluginTest.php @@ -5,7 +5,7 @@ */ namespace Magento\ConfigurableProduct\Test\Unit\Model\Product\Validator; -class PluginTest extends \PHPUnit_Framework_TestCase +class PluginTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\ConfigurableProduct\Model\Product\Validator\Plugin @@ -59,46 +59,25 @@ class PluginTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->eventManagerMock = $this->getMock(\Magento\Framework\Event\Manager::class, [], [], '', false); - $this->productFactoryMock = $this->getMock( - \Magento\Catalog\Model\ProductFactory::class, - ['create'], - [], - '', - false - ); - $this->jsonHelperMock = $this->getMock( - \Magento\Framework\Json\Helper\Data::class, - ['jsonDecode'], - [], - '', - false - ); + $this->eventManagerMock = $this->createMock(\Magento\Framework\Event\Manager::class); + $this->productFactoryMock = $this->createPartialMock(\Magento\Catalog\Model\ProductFactory::class, ['create']); + $this->jsonHelperMock = $this->createPartialMock(\Magento\Framework\Json\Helper\Data::class, ['jsonDecode']); $this->jsonHelperMock->expects($this->any())->method('jsonDecode')->will($this->returnArgument(0)); - $this->productMock = $this->getMock( + $this->productMock = $this->createPartialMock( \Magento\Catalog\Model\Product::class, - ['getData', 'getAttributes', 'setTypeId'], - [], - '', - false + ['getData', 'getAttributes', 'setTypeId'] ); - $this->requestMock = $this->getMock( + $this->requestMock = $this->createPartialMock( \Magento\Framework\App\Request\Http::class, - ['getPost', 'getParam', '__wakeup', 'has'], - [], - '', - false + ['getPost', 'getParam', '__wakeup', 'has'] ); - $this->responseMock = $this->getMock( + $this->responseMock = $this->createPartialMock( \Magento\Framework\DataObject::class, - ['setError', 'setMessage', 'setAttributes'], - [], - '', - false + ['setError', 'setMessage', 'setAttributes'] ); $this->arguments = [$this->productMock, $this->requestMock, $this->responseMock]; - $this->subjectMock = $this->getMock(\Magento\Catalog\Model\Product\Validator::class, [], [], '', false); + $this->subjectMock = $this->createMock(\Magento\Catalog\Model\Product\Validator::class); $this->plugin = new \Magento\ConfigurableProduct\Model\Product\Validator\Plugin( $this->eventManagerMock, $this->productFactoryMock, @@ -123,11 +102,10 @@ public function testAfterValidateWithVariationsValid() { $matrix = ['products']; - $plugin = $this->getMock( - \Magento\ConfigurableProduct\Model\Product\Validator\Plugin::class, - ['_validateProductVariations'], - [$this->eventManagerMock, $this->productFactoryMock, $this->jsonHelperMock] - ); + $plugin = $this->getMockBuilder(\Magento\ConfigurableProduct\Model\Product\Validator\Plugin::class) + ->setMethods(['_validateProductVariations']) + ->setConstructorArgs([$this->eventManagerMock, $this->productFactoryMock, $this->jsonHelperMock]) + ->getMock(); $plugin->expects( $this->once() @@ -169,11 +147,10 @@ public function testAfterValidateWithVariationsInvalid() { $matrix = ['products']; - $plugin = $this->getMock( - \Magento\ConfigurableProduct\Model\Product\Validator\Plugin::class, - ['_validateProductVariations'], - [$this->eventManagerMock, $this->productFactoryMock, $this->jsonHelperMock] - ); + $plugin = $this->getMockBuilder(\Magento\ConfigurableProduct\Model\Product\Validator\Plugin::class) + ->setMethods(['_validateProductVariations']) + ->setConstructorArgs([$this->eventManagerMock, $this->productFactoryMock, $this->jsonHelperMock]) + ->getMock(); $plugin->expects( $this->once() @@ -341,12 +318,9 @@ public function testAfterValidateWithVariationsAndRequiredAttributes() */ private function createProduct($index, $id, $isValid = true) { - $productMock = $this->getMock( + $productMock = $this->createPartialMock( \Magento\Catalog\Model\Product::class, - ['getAttributes', 'addData', 'setAttributeSetId', 'validate'], - [], - '', - false + ['getAttributes', 'addData', 'setAttributeSetId', 'validate'] ); $this->productFactoryMock->expects($this->at($index)) ->method('create') diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/VariationHandlerTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/VariationHandlerTest.php index 3d567897364c5..78707332f60c8 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/VariationHandlerTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/VariationHandlerTest.php @@ -15,7 +15,7 @@ * @SuppressWarnings(PHPMD.LongVariable) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class VariationHandlerTest extends \PHPUnit_Framework_TestCase +class VariationHandlerTest extends \PHPUnit\Framework\TestCase { /** * @var VariationHandler @@ -63,43 +63,13 @@ class VariationHandlerTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->productFactoryMock = $this->getMock( - \Magento\Catalog\Model\ProductFactory::class, - ['create'], - [], - '', - false - ); - $this->entityFactoryMock = $this->getMock( - \Magento\Eav\Model\EntityFactory::class, - ['create'], - [], - '', - false - ); - $this->attributeSetFactory = $this->getMock( - \Magento\Eav\Model\Entity\Attribute\SetFactory::class, - ['create'], - [], - '', - false - ); - $this->stockConfiguration = $this->getMock( - \Magento\CatalogInventory\Api\StockConfigurationInterface::class, - [], - [], - '', - false - ); - $this->configurableProduct = $this->getMock( - \Magento\ConfigurableProduct\Model\Product\Type\Configurable::class, - [], - [], - '', - false - ); + $this->productFactoryMock = $this->createPartialMock(\Magento\Catalog\Model\ProductFactory::class, ['create']); + $this->entityFactoryMock = $this->createPartialMock(\Magento\Eav\Model\EntityFactory::class, ['create']); + $this->attributeSetFactory = $this->createPartialMock(\Magento\Eav\Model\Entity\Attribute\SetFactory::class, ['create']); + $this->stockConfiguration = $this->createMock(\Magento\CatalogInventory\Api\StockConfigurationInterface::class); + $this->configurableProduct = $this->createMock(\Magento\ConfigurableProduct\Model\Product\Type\Configurable::class); - $this->product = $this->getMock(\Magento\Catalog\Model\Product::class, ['getMediaGallery'], [], '', false); + $this->product = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['getMediaGallery']); $this->model = $this->objectHelper->getObject( \Magento\ConfigurableProduct\Model\Product\VariationHandler::class, diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ProductOptionProcessorTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ProductOptionProcessorTest.php index 957a375c6afe4..396b3373428f3 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ProductOptionProcessorTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ProductOptionProcessorTest.php @@ -15,7 +15,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ProductOptionProcessorTest extends \PHPUnit_Framework_TestCase +class ProductOptionProcessorTest extends \PHPUnit\Framework\TestCase { /** * @var ProductOptionProcessor @@ -46,7 +46,7 @@ protected function setUp() { $this->dataObject = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->setMethods([ - 'getSuperAttribute', + 'getSuperAttribute', 'addData' ]) ->disableOriginalConstructor() ->getMock(); @@ -172,6 +172,8 @@ public function testConvertToProductOption( if (!empty($expected)) { $this->assertArrayHasKey($expected, $result); $this->assertTrue(is_array($result[$expected])); + } else { + $this->assertEmpty($result); } } diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ProductVariationsBuilderTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ProductVariationsBuilderTest.php index 4e88eb5676c4b..0c5d201d590a1 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ProductVariationsBuilderTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ProductVariationsBuilderTest.php @@ -6,7 +6,7 @@ namespace Magento\ConfigurableProduct\Test\Unit\Model; -class ProductVariationsBuilderTest extends \PHPUnit_Framework_TestCase +class ProductVariationsBuilderTest extends \PHPUnit\Framework\TestCase { /** * @var ProductVariationsBuilder @@ -35,30 +35,17 @@ class ProductVariationsBuilderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->customAttributeFactory = $this->getMock( - \Magento\Framework\Api\AttributeValueFactory::class, - [], - [], - '', - false - ); + $this->customAttributeFactory = $this->createMock(\Magento\Framework\Api\AttributeValueFactory::class); - $this->product = $this->getMock( + $this->product = $this->createPartialMock( \Magento\Catalog\Model\Product::class, - ['getData', 'getPrice', 'getName', 'getSku', '__wakeup', 'getCustomAttributes'], - [], - '', - false + ['getData', 'getPrice', 'getName', 'getSku', '__wakeup', 'getCustomAttributes'] ); - $this->productFactory = $this->getMock(\Magento\Catalog\Model\ProductFactory::class, ['create'], [], '', false); + $this->productFactory = $this->createPartialMock(\Magento\Catalog\Model\ProductFactory::class, ['create']); - $this->variationMatrix = $this->getMock( - \Magento\ConfigurableProduct\Model\Product\Type\VariationMatrix::class, - [], - [], - '', - false + $this->variationMatrix = $this->createMock( + \Magento\ConfigurableProduct\Model\Product\Type\VariationMatrix::class ); $this->model = new \Magento\ConfigurableProduct\Model\ProductVariationsBuilder( @@ -70,12 +57,9 @@ protected function setUp() public function testCreate() { - $output = $this->getMock( + $output = $this->createPartialMock( \Magento\Catalog\Model\Product::class, - ['setPrice', '__wakeup', 'setData', 'getCustomAttributes', 'setName', 'setSku', 'setVisibility'], - [], - '', - false + ['setPrice', '__wakeup', 'setData', 'getCustomAttributes', 'setName', 'setSku', 'setVisibility'] ); $attributes = [10 => ['attribute_code' => 'sort_order']]; $variations = [ @@ -95,7 +79,7 @@ public function testCreate() $output->expects($this->at(0))->method('setData')->with($productData); - $attribute = $this->getMock(\Magento\Framework\Api\AttributeInterface::class); + $attribute = $this->createMock(\Magento\Framework\Api\AttributeInterface::class); $attribute->expects($this->once()) ->method('setAttributeCode') ->with('sort_order') diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Quote/Item/CartItemProcessorTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Quote/Item/CartItemProcessorTest.php index 7f5d3a8159a72..d1df2b354204f 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Quote/Item/CartItemProcessorTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Quote/Item/CartItemProcessorTest.php @@ -11,7 +11,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class CartItemProcessorTest extends \PHPUnit_Framework_TestCase +class CartItemProcessorTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\ConfigurableProduct\Model\Quote\Item\CartItemProcessor @@ -48,33 +48,18 @@ class CartItemProcessorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectFactoryMock = $this->getMock( - \Magento\Framework\DataObject\Factory::class, - ['create'], - [], - '', - false - ); - $this->optionFactoryMock = $this->getMock( + $this->objectFactoryMock = $this->createPartialMock(\Magento\Framework\DataObject\Factory::class, ['create']); + $this->optionFactoryMock = $this->createPartialMock( \Magento\Quote\Model\Quote\ProductOptionFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->optionExtensionFactoryMock = $this->getMock( + $this->optionExtensionFactoryMock = $this->createPartialMock( \Magento\Quote\Api\Data\ProductOptionExtensionFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->optionValueFactoryMock = $this->getMock( + $this->optionValueFactoryMock = $this->createPartialMock( \Magento\ConfigurableProduct\Model\Quote\Item\ConfigurableItemOptionValueFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->productOptionExtensionAttributes = $this->getMockForAbstractClass( @@ -87,13 +72,7 @@ protected function setUp() ['setConfigurableItemOptions'] ); - $this->serializer = $this->getMock( - \Magento\Framework\Serialize\Serializer\Json::class, - [], - [], - '', - false - ); + $this->serializer = $this->createMock(\Magento\Framework\Serialize\Serializer\Json::class); $this->serializer->expects($this->any()) ->method('serialize') @@ -122,7 +101,7 @@ function ($value) { public function testConvertToBuyRequestIfNoProductOption() { - $cartItemMock = $this->getMock(\Magento\Quote\Api\Data\CartItemInterface::class); + $cartItemMock = $this->createMock(\Magento\Quote\Api\Data\CartItemInterface::class); $cartItemMock->expects($this->once())->method('getProductOption')->willReturn(null); $this->assertNull($this->model->convertToBuyRequest($cartItemMock)); } @@ -132,22 +111,19 @@ public function testConvertToBuyRequest() $optionId = 'option_id'; $optionValue = 'option_value'; - $productOptionMock = $this->getMock(\Magento\Quote\Api\Data\ProductOptionInterface::class); - $cartItemMock = $this->getMock(\Magento\Quote\Api\Data\CartItemInterface::class); + $productOptionMock = $this->createMock(\Magento\Quote\Api\Data\ProductOptionInterface::class); + $cartItemMock = $this->createMock(\Magento\Quote\Api\Data\CartItemInterface::class); $cartItemMock->expects($this->exactly(3))->method('getProductOption')->willReturn($productOptionMock); - $extAttributesMock = $this->getMock( - \Magento\Quote\Api\Data\ProductOption::class, - ['getConfigurableItemOptions'], - [], - '', - false - ); + $extAttributesMock = $this->getMockBuilder(\Magento\Quote\Api\Data\ProductOption::class) + ->setMethods(['getConfigurableItemOptions']) + ->disableOriginalConstructor() + ->getMock(); $productOptionMock ->expects($this->exactly(2)) ->method('getExtensionAttributes') ->willReturn($extAttributesMock); - $optionValueMock = $this->getMock( + $optionValueMock = $this->createMock( \Magento\ConfigurableProduct\Api\Data\ConfigurableItemOptionValueInterface::class ); $extAttributesMock->expects($this->once()) @@ -173,19 +149,13 @@ public function testConvertToBuyRequest() public function testProcessProductOptionsIfOptionNotSelected() { - $customOption = $this->getMock( - \Magento\Catalog\Model\Product\Configuration\Item\Option::class, - [], - [], - '', - false - ); + $customOption = $this->createMock(\Magento\Catalog\Model\Product\Configuration\Item\Option::class); $customOption->expects($this->once())->method('getValue')->willReturn(''); - $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $productMock = $this->createMock(\Magento\Catalog\Model\Product::class); $productMock->expects($this->once())->method('getCustomOption')->with('attributes')->willReturn($customOption); - $cartItemMock = $this->getMock(\Magento\Quote\Model\Quote\Item::class, ['getProduct'], [], '', false); + $cartItemMock = $this->createPartialMock(\Magento\Quote\Model\Quote\Item::class, ['getProduct']); $cartItemMock->expects($this->once())->method('getProduct')->willReturn($productMock); $this->assertEquals($cartItemMock, $this->model->processOptions($cartItemMock)); } @@ -195,35 +165,26 @@ public function testProcessProductOptions() $optionId = 'option_id'; $optionValue = 'option_value'; - $customOption = $this->getMock( - \Magento\Catalog\Model\Product\Configuration\Item\Option::class, - [], - [], - '', - false - ); + $customOption = $this->createMock(\Magento\Catalog\Model\Product\Configuration\Item\Option::class); $customOption->expects($this->once())->method('getValue')->willReturn(json_encode([$optionId => $optionValue])); - $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $productMock = $this->createMock(\Magento\Catalog\Model\Product::class); $productMock->expects($this->once())->method('getCustomOption')->with('attributes')->willReturn($customOption); - $cartItemMock = $this->getMock( + $cartItemMock = $this->createPartialMock( \Magento\Quote\Model\Quote\Item::class, - ['getProduct', 'getProductOption', 'setProductOption'], - [], - '', - false + ['getProduct', 'getProductOption', 'setProductOption'] ); $cartItemMock->expects($this->once())->method('getProduct')->willReturn($productMock); $cartItemMock->expects($this->once())->method('getProductOption')->willReturn(null); - $optionValueMock = $this->getMock( + $optionValueMock = $this->createMock( \Magento\ConfigurableProduct\Api\Data\ConfigurableItemOptionValueInterface::class ); $this->optionValueFactoryMock->expects($this->once())->method('create')->willReturn($optionValueMock); $optionValueMock->expects($this->once())->method('setOptionId')->with($optionId)->willReturnSelf(); $optionValueMock->expects($this->once())->method('setOptionValue')->with($optionValue)->willReturnSelf(); - $productOptionMock = $this->getMock(\Magento\Quote\Api\Data\ProductOptionInterface::class); + $productOptionMock = $this->createMock(\Magento\Quote\Api\Data\ProductOptionInterface::class); $this->optionFactoryMock->expects($this->once())->method('create')->willReturn($productOptionMock); $productOptionMock->expects($this->once())->method('getExtensionAttributes')->willReturn(null); @@ -248,26 +209,17 @@ public function testProcessProductOptionsIfOptionsExist() $optionId = 'option_id'; $optionValue = 'option_value'; - $customOption = $this->getMock( - \Magento\Catalog\Model\Product\Configuration\Item\Option::class, - [], - [], - '', - false - ); + $customOption = $this->createMock(\Magento\Catalog\Model\Product\Configuration\Item\Option::class); $customOption->expects($this->once())->method('getValue')->willReturn(json_encode([$optionId => $optionValue])); - $productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $productMock = $this->createMock(\Magento\Catalog\Model\Product::class); $productMock->expects($this->once())->method('getCustomOption')->with('attributes')->willReturn($customOption); - $cartItemMock = $this->getMock( + $cartItemMock = $this->createPartialMock( \Magento\Quote\Model\Quote\Item::class, - ['getProduct', 'getProductOption', 'setProductOption'], - [], - '', - false + ['getProduct', 'getProductOption', 'setProductOption'] ); - $optionValueMock = $this->getMock( + $optionValueMock = $this->createMock( \Magento\ConfigurableProduct\Api\Data\ConfigurableItemOptionValueInterface::class ); $this->optionValueFactoryMock->expects($this->once())->method('create')->willReturn($optionValueMock); @@ -279,7 +231,7 @@ public function testProcessProductOptionsIfOptionsExist() ->with([$optionValueMock]) ->willReturnSelf(); - $productOptionMock = $this->getMock(\Magento\Quote\Api\Data\ProductOptionInterface::class); + $productOptionMock = $this->createMock(\Magento\Quote\Api\Data\ProductOptionInterface::class); $productOptionMock->expects(static::exactly(2)) ->method('getExtensionAttributes') ->willReturn($this->productOptionExtensionAttributes); diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/Option/Plugin/ConfigurableProductTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/Option/Plugin/ConfigurableProductTest.php index 7fc603e1e9e5e..9f0b545d7c8f8 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/Option/Plugin/ConfigurableProductTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/Option/Plugin/ConfigurableProductTest.php @@ -5,10 +5,10 @@ */ namespace Magento\ConfigurableProduct\Test\Unit\Model\Quote\Item\QuantityValidator\Initializer\Option\Plugin; -use \Magento\ConfigurableProduct\Model\Quote\Item\QuantityValidator\Initializer\Option\Plugin\ConfigurableProduct +use Magento\ConfigurableProduct\Model\Quote\Item\QuantityValidator\Initializer\Option\Plugin\ConfigurableProduct as InitializerOptionPlugin; -class ConfigurableProductTest extends \PHPUnit_Framework_TestCase +class ConfigurableProductTest extends \PHPUnit\Framework\TestCase { /** * @param array $data @@ -16,42 +16,29 @@ class ConfigurableProductTest extends \PHPUnit_Framework_TestCase */ public function testAfterGetStockItem(array $data) { - $subjectMock = $this->getMock( - \Magento\CatalogInventory\Model\Quote\Item\QuantityValidator\Initializer\Option::class, - [], - [], - '', - false + $subjectMock = $this->createMock( + \Magento\CatalogInventory\Model\Quote\Item\QuantityValidator\Initializer\Option::class ); - $quoteItemMock = $this->getMock( + $quoteItemMock = $this->createPartialMock( \Magento\Quote\Model\Quote\Item::class, - ['getProductType', '__wakeup'], - [], - '', - false + ['getProductType', '__wakeup'] ); $quoteItemMock->expects($this->once()) ->method('getProductType') ->will($this->returnValue($data['product_type'])); - $stockItemMock = $this->getMock( + $stockItemMock = $this->createPartialMock( \Magento\CatalogInventory\Model\Stock\Item::class, - ['setProductName', '__wakeup'], - [], - '', - false + ['setProductName', '__wakeup'] ); $matcherMethod = $data['matcher_method']; $stockItemMock->expects($this->$matcherMethod()) ->method('setProductName'); - $optionMock = $this->getMock( + $optionMock = $this->createPartialMock( \Magento\Quote\Model\Quote\Item\Option::class, - ['getProduct', '__wakeup'], - [], - '', - false + ['getProduct', '__wakeup'] ); $model = new InitializerOptionPlugin(); diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ResourceModel/Attribute/OptionProviderTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ResourceModel/Attribute/OptionProviderTest.php index d86b0e977c3f5..7aa67832eb802 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ResourceModel/Attribute/OptionProviderTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ResourceModel/Attribute/OptionProviderTest.php @@ -10,7 +10,7 @@ use Magento\ConfigurableProduct\Model\ResourceModel\Attribute\OptionProvider; use Magento\Framework\EntityManager\EntityMetadataInterface; -class OptionProviderTest extends \PHPUnit_Framework_TestCase +class OptionProviderTest extends \PHPUnit\Framework\TestCase { /** * @var OptionProvider diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ResourceModel/Attribute/OptionSelectBuilderTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ResourceModel/Attribute/OptionSelectBuilderTest.php index 1ccd0b08c2911..235c16c9b556c 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ResourceModel/Attribute/OptionSelectBuilderTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ResourceModel/Attribute/OptionSelectBuilderTest.php @@ -17,7 +17,7 @@ /** * Class OptionSelectBuilderTest */ -class OptionSelectBuilderTest extends \PHPUnit_Framework_TestCase +class OptionSelectBuilderTest extends \PHPUnit\Framework\TestCase { /** * @var OptionSelectBuilder diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ResourceModel/Product/Type/Configurable/AttributeTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ResourceModel/Product/Type/Configurable/AttributeTest.php index 9452ea6a49722..a6c7f00c2dfbe 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ResourceModel/Product/Type/Configurable/AttributeTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ResourceModel/Product/Type/Configurable/AttributeTest.php @@ -11,7 +11,7 @@ use Magento\Framework\DB\Select; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -class AttributeTest extends \PHPUnit_Framework_TestCase +class AttributeTest extends \PHPUnit\Framework\TestCase { /** @var \PHPUnit_Framework_MockObject_MockObject */ protected $connection; @@ -40,7 +40,7 @@ protected function setUp() { $this->connection = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class)->getMock(); - $this->resource = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); + $this->resource = $this->createMock(\Magento\Framework\App\ResourceConnection::class); $this->resource->expects($this->any())->method('getConnection')->will($this->returnValue($this->connection)); $this->resource->expects($this->any())->method('getTableName')->willReturnArgument(0); diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ResourceModel/Product/Type/ConfigurableTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ResourceModel/Product/Type/ConfigurableTest.php index e37260eea3b6e..5a494d1c7a19b 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ResourceModel/Product/Type/ConfigurableTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ResourceModel/Product/Type/ConfigurableTest.php @@ -21,7 +21,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ConfigurableTest extends \PHPUnit_Framework_TestCase +class ConfigurableTest extends \PHPUnit\Framework\TestCase { /** * @var Configurable @@ -109,16 +109,17 @@ protected function setUp() ->getMock(); $this->objectManagerHelper = new ObjectManagerHelper($this); - $context = $this->getMock( - Context::class, - ['getResources'], - $this->objectManagerHelper->getConstructArguments( - Context::class, - [ - 'resources' => $this->resource - ] + $context = $this->getMockBuilder(Context::class) + ->setMethods(['getResources']) + ->setConstructorArgs( + $this->objectManagerHelper->getConstructArguments( + Context::class, + [ + 'resources' => $this->resource + ] + ) ) - ); + ->getMock(); $context->expects($this->once())->method('getResources')->willReturn($this->resource); $this->configurable = $this->objectManagerHelper->getObject( diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/SuggestedAttributeListTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/SuggestedAttributeListTest.php index 75e00c45760a9..95c12fe570708 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/SuggestedAttributeListTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/SuggestedAttributeListTest.php @@ -8,7 +8,7 @@ namespace Magento\ConfigurableProduct\Test\Unit\Model; -class SuggestedAttributeListTest extends \PHPUnit_Framework_TestCase +class SuggestedAttributeListTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\ConfigurableProduct\Model\SuggestedAttributeList @@ -42,27 +42,9 @@ class SuggestedAttributeListTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->configurableAttributeHandler = $this->getMock( - \Magento\ConfigurableProduct\Model\ConfigurableAttributeHandler::class, - [], - [], - '', - false - ); - $this->resourceHelperMock = $this->getMock( - \Magento\Catalog\Model\ResourceModel\Helper::class, - [], - [], - '', - false - ); - $this->collectionMock = $this->getMock( - \Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection::class, - [], - [], - '', - false - ); + $this->configurableAttributeHandler = $this->createMock(\Magento\ConfigurableProduct\Model\ConfigurableAttributeHandler::class); + $this->resourceHelperMock = $this->createMock(\Magento\Catalog\Model\ResourceModel\Helper::class); + $this->collectionMock = $this->createMock(\Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection::class); $this->resourceHelperMock->expects( $this->once() )->method( @@ -91,13 +73,7 @@ protected function setUp() $this->returnValueMap($valueMap) ); $methods = ['getId', 'getFrontendLabel', 'getAttributeCode', 'getSource']; - $this->attributeMock = $this->getMock( - \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, - $methods, - [], - '', - false - ); + $this->attributeMock = $this->createPartialMock(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, $methods); $this->collectionMock->expects( $this->once() )->method( @@ -113,13 +89,7 @@ protected function setUp() public function testGetSuggestedAttributesIfTheyApplicable() { - $source = $this->getMock( - \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource::class, - [], - [], - '', - false - ); + $source = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Source\AbstractSource::class); $result['id'] = ['id' => 'id', 'label' => 'label', 'code' => 'code', 'options' => 'options']; $this->attributeMock->expects($this->once())->method('getId')->will($this->returnValue('id')); $this->attributeMock->expects($this->once())->method('getFrontendLabel')->will($this->returnValue('label')); diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Observer/HideUnsupportedAttributeTypesTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Observer/HideUnsupportedAttributeTypesTest.php index 9ea49c4143c6c..3bad81126f510 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Observer/HideUnsupportedAttributeTypesTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Observer/HideUnsupportedAttributeTypesTest.php @@ -18,7 +18,7 @@ /** * Unit test for Magento\ConfigurableProduct\Observer\HideUnsupportedAttributeTypes */ -class HideUnsupportedAttributeTypesTest extends \PHPUnit_Framework_TestCase +class HideUnsupportedAttributeTypesTest extends \PHPUnit\Framework\TestCase { /** * @var ObjectManager @@ -44,11 +44,11 @@ public function testExecuteWhenBlockNotPassed() } /** - * @param RequestInterface|MockObject $request + * @param RequestInterface|\PHPUnit_Framework_MockObject_MockObject $request * @param array $supportedTypes * @return HideUnsupportedAttributeTypes */ - private function createTarget(MockObject $request, array $supportedTypes = []) + private function createTarget(\PHPUnit_Framework_MockObject_MockObject $request, array $supportedTypes = []) { return $this->objectManager->getObject( HideUnsupportedAttributeTypes::class, @@ -81,11 +81,11 @@ function ($name) use ($popup, $productTab) { } /** - * @param MockObject|null $form - * @return EventObserver|MockObject + * @param \PHPUnit_Framework_MockObject_MockObject|null $form + * @return EventObserver|\PHPUnit_Framework_MockObject_MockObject * @internal param null|MockObject $block */ - private function createEventMock(MockObject $form = null) + private function createEventMock(\PHPUnit_Framework_MockObject_MockObject $form = null) { $event = $this->getMockBuilder(EventObserver::class) ->setMethods(['getForm', 'getBlock']) diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Plugin/Model/ResourceModel/Attribute/InStockOptionSelectBuilderTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Plugin/Model/ResourceModel/Attribute/InStockOptionSelectBuilderTest.php index 18550e7d26f92..4d7d5702aacf6 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Plugin/Model/ResourceModel/Attribute/InStockOptionSelectBuilderTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Plugin/Model/ResourceModel/Attribute/InStockOptionSelectBuilderTest.php @@ -12,7 +12,7 @@ use Magento\Framework\DB\Select; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class InStockOptionSelectBuilderTest extends \PHPUnit_Framework_TestCase +class InStockOptionSelectBuilderTest extends \PHPUnit\Framework\TestCase { /** * @var InStockOptionSelectBuilder diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Plugin/Model/ResourceModel/ProductTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Plugin/Model/ResourceModel/ProductTest.php index d66e7cf0d19f3..73eb8734b6063 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Plugin/Model/ResourceModel/ProductTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Plugin/Model/ResourceModel/ProductTest.php @@ -8,33 +8,61 @@ use Magento\Catalog\Model\Product\Type; use Magento\ConfigurableProduct\Model\Product\Type\Configurable; +use Magento\Framework\Indexer\ActionInterface; -class ProductTest extends \PHPUnit_Framework_TestCase +class ProductTest extends \PHPUnit\Framework\TestCase { - public function testBeforeSaveConfigurable() + /** + * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager + */ + private $objectManager; + + /** + * @var Configurable|\PHPUnit_Framework_MockObject_MockObject + */ + private $configurableMock; + + /** + * @var ActionInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $actionMock; + + /** + * @var \Magento\ConfigurableProduct\Plugin\Model\ResourceModel\Product + */ + private $model; + + public function setUp() { - $subject = $this->getMock(\Magento\Catalog\Model\ResourceModel\Product::class, [], [], '', false); - $object = $this->getMock( - \Magento\Catalog\Model\Product::class, - ['getTypeId', 'getTypeInstance'], - [], - '', - false + $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $this->configurableMock = $this->createMock(Configurable::class); + $this->actionMock = $this->createMock(ActionInterface::class); + + $this->model = $this->objectManager->getObject( + \Magento\ConfigurableProduct\Plugin\Model\ResourceModel\Product::class, + [ + 'configurable' => $this->configurableMock, + 'productIndexer' => $this->actionMock, + ] ); - $type = $this->getMock( + } + + public function testBeforeSaveConfigurable() + { + /** @var \Magento\Catalog\Model\ResourceModel\Product|\PHPUnit_Framework_MockObject_MockObject $subject */ + $subject = $this->createMock(\Magento\Catalog\Model\ResourceModel\Product::class); + /** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $object */ + $object = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['getTypeId', 'getTypeInstance']); + $type = $this->createPartialMock( \Magento\ConfigurableProduct\Model\Product\Type\Configurable::class, - ['getSetAttributes'], - [], - '', - false + ['getSetAttributes'] ); $type->expects($this->once())->method('getSetAttributes')->with($object); $object->expects($this->once())->method('getTypeId')->will($this->returnValue(Configurable::TYPE_CODE)); $object->expects($this->once())->method('getTypeInstance')->will($this->returnValue($type)); - $product = new \Magento\ConfigurableProduct\Plugin\Model\ResourceModel\Product(); - $product->beforeSave( + $this->model->beforeSave( $subject, $object ); @@ -42,21 +70,48 @@ public function testBeforeSaveConfigurable() public function testBeforeSaveSimple() { - $subject = $this->getMock(\Magento\Catalog\Model\ResourceModel\Product::class, [], [], '', false); - $object = $this->getMock( - \Magento\Catalog\Model\Product::class, - ['getTypeId', 'getTypeInstance'], - [], - '', - false - ); + /** @var \Magento\Catalog\Model\ResourceModel\Product|\PHPUnit_Framework_MockObject_MockObject $subject */ + $subject = $this->createMock(\Magento\Catalog\Model\ResourceModel\Product::class); + /** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $object */ + $object = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['getTypeId', 'getTypeInstance']); $object->expects($this->once())->method('getTypeId')->will($this->returnValue(Type::TYPE_SIMPLE)); $object->expects($this->never())->method('getTypeInstance'); - $product = new \Magento\ConfigurableProduct\Plugin\Model\ResourceModel\Product(); - $product->beforeSave( + $this->model->beforeSave( $subject, $object ); } + + public function testAroundDelete() + { + $productId = '1'; + $parentConfigId = ['2']; + /** @var \Magento\Catalog\Model\ResourceModel\Product|\PHPUnit_Framework_MockObject_MockObject $subject */ + $subject = $this->createMock(\Magento\Catalog\Model\ResourceModel\Product::class); + /** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $product */ + $product = $this->createPartialMock( + \Magento\Catalog\Model\Product::class, + ['getId', 'delete'] + ); + $product->expects($this->once())->method('getId')->willReturn($productId); + $product->expects($this->once())->method('delete')->willReturn(true); + $this->configurableMock->expects($this->once()) + ->method('getParentIdsByChild') + ->with($productId) + ->willReturn($parentConfigId); + $this->actionMock->expects($this->once())->method('executeList')->with($parentConfigId); + + $return = $this->model->aroundDelete( + $subject, + /** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $prod */ + function (\Magento\Catalog\Model\Product $prod) use ($subject) { + $prod->delete(); + return $subject; + }, + $product + ); + + $this->assertEquals($subject->getTypeId(), $return->getTypeId()); + } } diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Pricing/Price/ConfigurablePriceResolverTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Pricing/Price/ConfigurablePriceResolverTest.php index c528030433e64..99c31420473f5 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Pricing/Price/ConfigurablePriceResolverTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Pricing/Price/ConfigurablePriceResolverTest.php @@ -8,7 +8,7 @@ use Magento\ConfigurableProduct\Pricing\Price\LowestPriceOptionsProviderInterface; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class ConfigurablePriceResolverTest extends \PHPUnit_Framework_TestCase +class ConfigurablePriceResolverTest extends \PHPUnit\Framework\TestCase { /** * @var LowestPriceOptionsProviderInterface|\PHPUnit_Framework_MockObject_MockObject @@ -33,12 +33,12 @@ class ConfigurablePriceResolverTest extends \PHPUnit_Framework_TestCase protected function setUp() { $className = \Magento\ConfigurableProduct\Model\Product\Type\Configurable::class; - $this->configurable = $this->getMock($className, ['getUsedProducts'], [], '', false); + $this->configurable = $this->createPartialMock($className, ['getUsedProducts']); $className = \Magento\ConfigurableProduct\Pricing\Price\PriceResolverInterface::class; $this->priceResolver = $this->getMockForAbstractClass($className, [], '', false, true, true, ['resolvePrice']); - $this->lowestPriceOptionsProvider = $this->getMock(LowestPriceOptionsProviderInterface::class); + $this->lowestPriceOptionsProvider = $this->createMock(LowestPriceOptionsProviderInterface::class); $objectManager = new ObjectManager($this); $this->resolver = $objectManager->getObject( @@ -54,7 +54,7 @@ protected function setUp() /** * situation: one product is supplying the price, which could be a price of zero (0) * - * @dataProvider testResolvePriceDataProvider + * @dataProvider resolvePriceDataProvider */ public function testResolvePrice($expectedValue) { @@ -78,7 +78,7 @@ public function testResolvePrice($expectedValue) /** * @return array */ - public function testResolvePriceDataProvider() + public function resolvePriceDataProvider() { return [ 'price of zero' => [0.00], diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Pricing/Price/LowestPriceOptionsProviderTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Pricing/Price/LowestPriceOptionsProviderTest.php index 65b80eceefc89..80d020542f056 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Pricing/Price/LowestPriceOptionsProviderTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Pricing/Price/LowestPriceOptionsProviderTest.php @@ -10,7 +10,7 @@ use Magento\Catalog\Api\Data\ProductInterface; use Magento\Catalog\Model\ResourceModel\Product\LinkedProductSelectBuilderInterface; -class LowestPriceOptionsProviderTest extends \PHPUnit_Framework_TestCase +class LowestPriceOptionsProviderTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\ConfigurableProduct\Pricing\Price\LowestPriceOptionsProvider diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Pricing/Render/FinalPriceBoxTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Pricing/Render/FinalPriceBoxTest.php index c115849e68d2c..3c4b9b4392ad7 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Pricing/Render/FinalPriceBoxTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Pricing/Render/FinalPriceBoxTest.php @@ -11,7 +11,7 @@ use Magento\ConfigurableProduct\Pricing\Render\FinalPriceBox; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class FinalPriceBoxTest extends \PHPUnit_Framework_TestCase +class FinalPriceBoxTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\View\Element\Template\Context|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/Component/Listing/AssociatedProduct/Columns/AttributesTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/Component/Listing/AssociatedProduct/Columns/AttributesTest.php index 5c75b75baf956..4ee7901e3da47 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/Component/Listing/AssociatedProduct/Columns/AttributesTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/Component/Listing/AssociatedProduct/Columns/AttributesTest.php @@ -19,7 +19,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class AttributesTest extends \PHPUnit_Framework_TestCase +class AttributesTest extends \PHPUnit\Framework\TestCase { /** * @var AttributesColumn diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/Component/Listing/AssociatedProduct/Columns/NameTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/Component/Listing/AssociatedProduct/Columns/NameTest.php index 2358f8fd00f90..06ee3502c0a19 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/Component/Listing/AssociatedProduct/Columns/NameTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/Component/Listing/AssociatedProduct/Columns/NameTest.php @@ -11,7 +11,7 @@ use Magento\Framework\View\Element\UiComponent\ContextInterface; use Magento\Framework\View\Element\UiComponent\Processor as UiElementProcessor; -class NameTest extends \PHPUnit_Framework_TestCase +class NameTest extends \PHPUnit\Framework\TestCase { /** * @var NameColumn diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/Component/Listing/AssociatedProduct/Columns/PriceTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/Component/Listing/AssociatedProduct/Columns/PriceTest.php index 2ed4832136d52..cdae68b4c7a8d 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/Component/Listing/AssociatedProduct/Columns/PriceTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/Component/Listing/AssociatedProduct/Columns/PriceTest.php @@ -19,7 +19,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class PriceTest extends \PHPUnit_Framework_TestCase +class PriceTest extends \PHPUnit\Framework\TestCase { /** * @var PriceColumn diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CompositeTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CompositeTest.php index 65eed3d148a32..67f758af22bec 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CompositeTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CompositeTest.php @@ -18,7 +18,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class CompositeTest extends \PHPUnit_Framework_TestCase +class CompositeTest extends \PHPUnit\Framework\TestCase { /** * @var ObjectManagerHelper @@ -61,7 +61,7 @@ protected function setUp() ->getMock(); $this->productMock = $this->getMockBuilder(ProductInterface::class) ->getMockForAbstractClass(); - $this->allowedProductTypesMock = $this->getMock(AllowedProductTypes::class, [], [], '', false); + $this->allowedProductTypesMock = $this->createMock(AllowedProductTypes::class); $this->productLocatorMock->expects(static::any()) ->method('getProduct') diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ConfigurableAttributeSetHandlerTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ConfigurableAttributeSetHandlerTest.php index b20b246e85ee1..eb114ac5e51a8 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ConfigurableAttributeSetHandlerTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ConfigurableAttributeSetHandlerTest.php @@ -8,7 +8,7 @@ use Magento\ConfigurableProduct\Ui\DataProvider\Product\Form\Modifier\ConfigurableAttributeSetHandler; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -class ConfigurableAttributeSetHandlerTest extends \PHPUnit_Framework_TestCase +class ConfigurableAttributeSetHandlerTest extends \PHPUnit\Framework\TestCase { /** * @var ConfigurableAttributeSetHandler diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ConfigurablePanelTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ConfigurablePanelTest.php index 21909cd844490..020551ff02537 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ConfigurablePanelTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ConfigurablePanelTest.php @@ -11,7 +11,7 @@ use Magento\Framework\UrlInterface; use Magento\Catalog\Api\Data\ProductInterface; -class ConfigurablePanelTest extends \PHPUnit_Framework_TestCase +class ConfigurablePanelTest extends \PHPUnit\Framework\TestCase { /** * @var ConfigurablePanelModifier diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/DataProvider/Product/Form/Modifier/StockDataTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/DataProvider/Product/Form/Modifier/StockDataTest.php index abc9199164811..0a65454192adc 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/DataProvider/Product/Form/Modifier/StockDataTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Ui/DataProvider/Product/Form/Modifier/StockDataTest.php @@ -10,7 +10,7 @@ use Magento\Catalog\Model\Locator\LocatorInterface; use Magento\Catalog\Api\Data\ProductInterface; -class StockDataTest extends \PHPUnit_Framework_TestCase +class StockDataTest extends \PHPUnit\Framework\TestCase { /** * @var StockDataModifier diff --git a/app/code/Magento/ConfigurableProduct/Ui/Component/Listing/AssociatedProduct/Attribute/Repository.php b/app/code/Magento/ConfigurableProduct/Ui/Component/Listing/AssociatedProduct/Attribute/Repository.php index 22f63b1bc19cd..8129f44368182 100644 --- a/app/code/Magento/ConfigurableProduct/Ui/Component/Listing/AssociatedProduct/Attribute/Repository.php +++ b/app/code/Magento/ConfigurableProduct/Ui/Component/Listing/AssociatedProduct/Attribute/Repository.php @@ -7,10 +7,13 @@ /** * @api + * @since 100.0.2 */ class Repository extends \Magento\Catalog\Ui\Component\Listing\Attribute\AbstractRepository { - /** @var \Magento\Framework\App\RequestInterface */ + /** + * @var \Magento\Framework\App\RequestInterface + */ protected $request; /** diff --git a/app/code/Magento/ConfigurableProduct/Ui/Component/Listing/AssociatedProduct/Columns.php b/app/code/Magento/ConfigurableProduct/Ui/Component/Listing/AssociatedProduct/Columns.php index 22f920450d1e3..2ca46b4e67288 100644 --- a/app/code/Magento/ConfigurableProduct/Ui/Component/Listing/AssociatedProduct/Columns.php +++ b/app/code/Magento/ConfigurableProduct/Ui/Component/Listing/AssociatedProduct/Columns.php @@ -7,7 +7,9 @@ class Columns extends \Magento\Ui\Component\Listing\Columns { - /** @var \Magento\Catalog\Ui\Component\Listing\Attribute\RepositoryInterface */ + /** + * @var \Magento\Catalog\Ui\Component\Listing\Attribute\RepositoryInterface + */ protected $attributeRepository; /** diff --git a/app/code/Magento/ConfigurableProduct/Ui/Component/Listing/AssociatedProduct/Filters.php b/app/code/Magento/ConfigurableProduct/Ui/Component/Listing/AssociatedProduct/Filters.php index e4219f3d35d20..364fae9519f7a 100644 --- a/app/code/Magento/ConfigurableProduct/Ui/Component/Listing/AssociatedProduct/Filters.php +++ b/app/code/Magento/ConfigurableProduct/Ui/Component/Listing/AssociatedProduct/Filters.php @@ -12,6 +12,7 @@ /** * @api + * @since 100.0.2 */ class Filters implements ObserverInterface { diff --git a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php index d384fc82094e8..636d832842f92 100644 --- a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php +++ b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php @@ -127,8 +127,8 @@ private function modifyPriceTypeFields(array $meta) 'bannedOptions' => ['percent'], 'imports' => [ 'updateOptions' => 'ns = ${ $.ns }, index = ' - . ConfigurablePanel::CONFIGURABLE_MATRIX . ':isEmpty' - ] + . ConfigurablePanel::CONFIGURABLE_MATRIX . ':isEmpty', + ], ] ); } diff --git a/app/code/Magento/ConfigurableProduct/etc/di.xml b/app/code/Magento/ConfigurableProduct/etc/di.xml index 1ec382bf37b29..b9ea0c7e27011 100644 --- a/app/code/Magento/ConfigurableProduct/etc/di.xml +++ b/app/code/Magento/ConfigurableProduct/etc/di.xml @@ -180,6 +180,9 @@ Magento\Catalog\Model\Indexer\Price\CompositeProductBatchSizeManagement + + Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\CompositeProductBatchSizeAdjuster + @@ -188,4 +191,9 @@ indexer + + + Magento\Catalog\Model\Indexer\Product\Full + + diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/configurable_associated_product_listing.xml b/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/configurable_associated_product_listing.xml index 6a628b8e8ad36..2a40caaabae04 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/configurable_associated_product_listing.xml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/configurable_associated_product_listing.xml @@ -24,6 +24,7 @@ + Magento_Catalog::products id diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/product_attributes_listing.xml b/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/product_attributes_listing.xml index 61c7645a5eb57..ea80c218516c3 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/product_attributes_listing.xml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/product_attributes_listing.xml @@ -25,6 +25,7 @@ + Magento_Catalog::products id diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/custom-options-price-type.js b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/custom-options-price-type.js index b502f986c5af4..8425d12d4c763 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/custom-options-price-type.js +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/custom-options-price-type.js @@ -5,11 +5,11 @@ define([ 'underscore', - 'Magento_Ui/js/form/element/select' -], function (_, Select) { + 'Magento_Catalog/js/components/custom-options-price-type' +], function (_, PriceType) { 'use strict'; - return Select.extend({ + return PriceType.extend({ defaults: { isConfigurable: false, isFiltered: null, diff --git a/app/code/Magento/Analytics/LICENSE.txt b/app/code/Magento/ConfigurableProductSales/LICENSE.txt similarity index 100% rename from app/code/Magento/Analytics/LICENSE.txt rename to app/code/Magento/ConfigurableProductSales/LICENSE.txt diff --git a/app/code/Magento/Analytics/LICENSE_AFL.txt b/app/code/Magento/ConfigurableProductSales/LICENSE_AFL.txt similarity index 100% rename from app/code/Magento/Analytics/LICENSE_AFL.txt rename to app/code/Magento/ConfigurableProductSales/LICENSE_AFL.txt diff --git a/app/code/Magento/ConfigurableProductSales/Model/Order/Reorder/OrderedProductAvailabilityChecker.php b/app/code/Magento/ConfigurableProductSales/Model/Order/Reorder/OrderedProductAvailabilityChecker.php new file mode 100644 index 0000000000000..dceb5767edae9 --- /dev/null +++ b/app/code/Magento/ConfigurableProductSales/Model/Order/Reorder/OrderedProductAvailabilityChecker.php @@ -0,0 +1,115 @@ +resourceConnection = $resourceConnection; + $this->metadataPool = $metadataPool; + } + + /** + * @inheritdoc + */ + public function isAvailable(Item $item) + { + $buyRequest = $item->getBuyRequest(); + $superAttribute = $buyRequest->getData()['super_attribute']; + $connection = $this->getConnection(); + $select = $connection->select(); + $orderItemParentId = $item->getParentItem()->getProductId(); + $select->from( + ['cpe' => $this->resourceConnection->getTableName('catalog_product_entity')], + ['cpe.entity_id'] + ) + ->where('cpe.entity_id = ?', $item->getProductId()); + $select->join( + ['cpsl' => $this->resourceConnection->getTableName('catalog_product_super_link')], + sprintf( + 'cpe.entity_id = cpsl.product_id AND cpsl.parent_id = %d', + $orderItemParentId + ), + [] + ); + foreach ($superAttribute as $attributeId => $attributeValue) { + $select->join( + ['cpid' . $attributeId => $this->resourceConnection->getTableName('catalog_product_entity_int')], + sprintf( + 'cpe.%1$s = cpid%2$d.%1$s AND cpid%2$d.attribute_id = %2$d AND cpid%2$d.store_id = %3$d', + $this->getMetadata()->getLinkField(), + $attributeId, + Store::DEFAULT_STORE_ID + ), + [] + ) + ->joinLeft( + ['cpis' . $attributeId => $this->resourceConnection->getTableName('catalog_product_entity_int')], + sprintf( + 'cpe.%1$s = cpis%2$d.%1$s AND cpis%2$d.attribute_id = %2$d AND cpis%2$d.store_id = %3$d', + $this->getMetadata()->getLinkField(), + $attributeId, + $item->getStoreId() + ), + [] + ) + ->where( + sprintf( + '%s = ?', + $connection->getIfNullSql( + 'cpis' . $attributeId . '.value', + 'cpid' . $attributeId . '.value' + ) + ), + $attributeValue + ); + } + return (bool)$connection->fetchCol($select); + } + + /** + * @return \Magento\Framework\DB\Adapter\AdapterInterface + */ + private function getConnection() + { + return $this->resourceConnection->getConnection(); + } + + /** + * @return \Magento\Framework\EntityManager\EntityMetadataInterface + */ + private function getMetadata() + { + return $this->metadataPool->getMetadata(ProductInterface::class); + } +} diff --git a/app/code/Magento/ConfigurableProductSales/README.md b/app/code/Magento/ConfigurableProductSales/README.md new file mode 100644 index 0000000000000..af915a8265827 --- /dev/null +++ b/app/code/Magento/ConfigurableProductSales/README.md @@ -0,0 +1,4 @@ +# Magento_ConfigurableProductSales module + +The Magento_ConfigurableProductSales module checks that the selected options of order item are still presented in +Catalog. Returns true if the previously ordered item configuration is still available. \ No newline at end of file diff --git a/app/code/Magento/Analytics/composer.json b/app/code/Magento/ConfigurableProductSales/composer.json similarity index 59% rename from app/code/Magento/Analytics/composer.json rename to app/code/Magento/ConfigurableProductSales/composer.json index edc3443e487b6..acf7b5c191f8a 100644 --- a/app/code/Magento/Analytics/composer.json +++ b/app/code/Magento/ConfigurableProductSales/composer.json @@ -1,14 +1,16 @@ { - "name": "magento/module-analytics", + "name": "magento/module-configurable-product-sales", "description": "N/A", "require": { "php": "7.0.2|7.0.4|~7.0.6|~7.1.0", - "magento/module-backend": "100.2.*", - "magento/module-config": "100.2.*", - "magento/module-integration": "100.2.*", + "magento/module-catalog": "101.1.*", + "magento/module-sales": "100.2.*", "magento/module-store": "100.2.*", "magento/framework": "100.2.*" }, + "suggest": { + "magento/module-configurable-product": "100.2.*" + }, "type": "magento2-module", "version": "100.2.0-dev", "license": [ @@ -20,7 +22,7 @@ "registration.php" ], "psr-4": { - "Magento\\Analytics\\": "" + "Magento\\ConfigurableProductSales\\": "" } } } diff --git a/app/code/Magento/Analytics/etc/adminhtml/di.xml b/app/code/Magento/ConfigurableProductSales/etc/di.xml similarity index 53% rename from app/code/Magento/Analytics/etc/adminhtml/di.xml rename to app/code/Magento/ConfigurableProductSales/etc/di.xml index 5e305e70e5ad3..b53faf74ffa1d 100644 --- a/app/code/Magento/Analytics/etc/adminhtml/di.xml +++ b/app/code/Magento/ConfigurableProductSales/etc/di.xml @@ -6,10 +6,10 @@ */ --> - + - - Magento\Analytics\Model\System\Message\NotificationAboutFailedSubscription + + Magento\ConfigurableProductSales\Model\Order\Reorder\OrderedProductAvailabilityChecker diff --git a/app/code/Magento/SalesAnalytics/etc/module.xml b/app/code/Magento/ConfigurableProductSales/etc/module.xml similarity index 73% rename from app/code/Magento/SalesAnalytics/etc/module.xml rename to app/code/Magento/ConfigurableProductSales/etc/module.xml index 7a15075a4bc21..4da83c9c0269b 100644 --- a/app/code/Magento/SalesAnalytics/etc/module.xml +++ b/app/code/Magento/ConfigurableProductSales/etc/module.xml @@ -6,10 +6,10 @@ */ --> - + + - diff --git a/app/code/Magento/ConfigurableProductSales/registration.php b/app/code/Magento/ConfigurableProductSales/registration.php new file mode 100644 index 0000000000000..99affe39c15c1 --- /dev/null +++ b/app/code/Magento/ConfigurableProductSales/registration.php @@ -0,0 +1,9 @@ +mailMock = $this->getMockBuilder(MailInterface::class)->getMockForAbstractClass(); $this->configMock = $this->getMockBuilder(ConfigInterface::class)->getMockForAbstractClass(); - $context = $this->getMock( + $context = $this->createPartialMock( \Magento\Framework\App\Action\Context::class, - ['getRequest', 'getResponse', 'getResultRedirectFactory', 'getUrl', 'getRedirect', 'getMessageManager'], - [], - '', - false + ['getRequest', 'getResponse', 'getResultRedirectFactory', 'getUrl', 'getRedirect', 'getMessageManager'] ); - $this->urlMock = $this->getMock(\Magento\Framework\UrlInterface::class, [], [], '', false); + $this->urlMock = $this->createMock(\Magento\Framework\UrlInterface::class); $this->messageManagerMock = - $this->getMock(\Magento\Framework\Message\ManagerInterface::class, [], [], '', false); - $this->requestStub = $this->getMock( + $this->createMock(\Magento\Framework\Message\ManagerInterface::class); + $this->requestStub = $this->createPartialMock( \Magento\Framework\App\Request\Http::class, - ['getPostValue', 'getParams', 'getParam'], - [], - '', - false - ); - $this->redirectResultMock = $this->getMock( - \Magento\Framework\Controller\Result\Redirect::class, - [], - [], - '', - false + ['getPostValue', 'getParams', 'getParam'] ); + $this->redirectResultMock = $this->createMock(\Magento\Framework\Controller\Result\Redirect::class); $this->redirectResultMock->method('setPath')->willReturnSelf(); - $this->redirectResultFactoryMock = $this->getMock( + $this->redirectResultFactoryMock = $this->createPartialMock( \Magento\Framework\Controller\Result\RedirectFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->redirectResultFactoryMock ->method('create') ->willReturn($this->redirectResultMock); - $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class, [], [], '', false); + $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); $this->dataPersistorMock = $this->getMockBuilder(\Magento\Framework\App\Request\DataPersistorInterface::class) ->getMockForAbstractClass(); $context->expects($this->any()) @@ -113,7 +98,7 @@ protected function setUp() $context->expects($this->any()) ->method('getResponse') - ->willReturn($this->getMock(\Magento\Framework\App\ResponseInterface::class, [], [], '', false)); + ->willReturn($this->createMock(\Magento\Framework\App\ResponseInterface::class)); $context->expects($this->any()) ->method('getMessageManager') diff --git a/app/code/Magento/Contact/Test/Unit/Controller/IndexTest.php b/app/code/Magento/Contact/Test/Unit/Controller/IndexTest.php index f047bb2e3c9ea..750bcda24cb12 100644 --- a/app/code/Magento/Contact/Test/Unit/Controller/IndexTest.php +++ b/app/code/Magento/Contact/Test/Unit/Controller/IndexTest.php @@ -10,7 +10,7 @@ use Magento\Framework\App\RequestInterface; use Magento\Framework\App\ResponseInterface; -class IndexTest extends \PHPUnit_Framework_TestCase +class IndexTest extends \PHPUnit\Framework\TestCase { /** * Controller instance diff --git a/app/code/Magento/Contact/Test/Unit/Helper/DataTest.php b/app/code/Magento/Contact/Test/Unit/Helper/DataTest.php index 11a188039346c..f5dc4c94cadab 100644 --- a/app/code/Magento/Contact/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Contact/Test/Unit/Helper/DataTest.php @@ -6,7 +6,7 @@ namespace Magento\Contact\Test\Unit\Helper; -class DataTest extends \PHPUnit_Framework_TestCase +class DataTest extends \PHPUnit\Framework\TestCase { /** * Helper @@ -118,7 +118,7 @@ public function testGetUserEmail() ->method('isLoggedIn') ->willReturn(true); - $customerDataObject = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', false); + $customerDataObject = $this->createMock(\Magento\Customer\Api\Data\CustomerInterface::class); $customerDataObject->expects($this->once()) ->method('getEmail') ->willReturn('customer@email.com'); diff --git a/app/code/Magento/Contact/Test/Unit/Model/MailTest.php b/app/code/Magento/Contact/Test/Unit/Model/MailTest.php index f432a4fc5ccee..54583e25eaf9c 100644 --- a/app/code/Magento/Contact/Test/Unit/Model/MailTest.php +++ b/app/code/Magento/Contact/Test/Unit/Model/MailTest.php @@ -11,7 +11,7 @@ use Magento\Store\Model\StoreManagerInterface; use Magento\Store\Api\Data\StoreInterface; -class MailTest extends \PHPUnit_Framework_TestCase +class MailTest extends \PHPUnit\Framework\TestCase { /** @@ -47,7 +47,7 @@ class MailTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->configMock = $this->getMockBuilder(ConfigInterface::class)->getMockForAbstractClass(); - $this->urlMock = $this->getMock(\Magento\Framework\UrlInterface::class, [], [], '', false); + $this->urlMock = $this->createMock(\Magento\Framework\UrlInterface::class); $this->transportBuilderMock = $this->getMockBuilder( \Magento\Framework\Mail\Template\TransportBuilder::class )->disableOriginalConstructor( @@ -57,7 +57,7 @@ protected function setUp() )->disableOriginalConstructor( )->getMock(); - $this->storeManagerMock = $this->getMock(StoreManagerInterface::class); + $this->storeManagerMock = $this->createMock(StoreManagerInterface::class); $this->mail = new Mail( $this->configMock, @@ -72,9 +72,9 @@ public function testSendMail() $email = 'reply-to@example.com'; $templateVars = ['comment' => 'Comment']; - $transport = $this->getMock(\Magento\Framework\Mail\TransportInterface::class, [], [], '', false); + $transport = $this->createMock(\Magento\Framework\Mail\TransportInterface::class); - $store = $this->getMock(StoreInterface::class); + $store = $this->createMock(StoreInterface::class); $store->expects($this->once())->method('getId')->willReturn(555); $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($store); diff --git a/app/code/Magento/Contact/Test/Unit/Model/System/Config/Backend/LinksTest.php b/app/code/Magento/Contact/Test/Unit/Model/System/Config/Backend/LinksTest.php index 33d139744fef4..c1f8cb78f760f 100644 --- a/app/code/Magento/Contact/Test/Unit/Model/System/Config/Backend/LinksTest.php +++ b/app/code/Magento/Contact/Test/Unit/Model/System/Config/Backend/LinksTest.php @@ -7,7 +7,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class LinksTest extends \PHPUnit_Framework_TestCase +class LinksTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Contact\Model\System\Config\Backend\Links|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Cookie/Block/Html/Notices.php b/app/code/Magento/Cookie/Block/Html/Notices.php index ab9505a3a5880..b4dda788a0292 100644 --- a/app/code/Magento/Cookie/Block/Html/Notices.php +++ b/app/code/Magento/Cookie/Block/Html/Notices.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class Notices extends \Magento\Framework\View\Element\Template { diff --git a/app/code/Magento/Cookie/Block/RequireCookie.php b/app/code/Magento/Cookie/Block/RequireCookie.php index b57adcd5cdbc6..0a836e5441540 100644 --- a/app/code/Magento/Cookie/Block/RequireCookie.php +++ b/app/code/Magento/Cookie/Block/RequireCookie.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ class RequireCookie extends \Magento\Framework\View\Element\Template { diff --git a/app/code/Magento/Cookie/Helper/Cookie.php b/app/code/Magento/Cookie/Helper/Cookie.php index 592e68494494d..05ab02d7a2a1a 100644 --- a/app/code/Magento/Cookie/Helper/Cookie.php +++ b/app/code/Magento/Cookie/Helper/Cookie.php @@ -8,6 +8,7 @@ /** * Cookie helper * @api + * @since 100.0.2 */ class Cookie extends \Magento\Framework\App\Helper\AbstractHelper { @@ -78,6 +79,7 @@ public function isUserNotAllowSaveCookie() * Check if cookie restriction mode is enabled for this store * * @return bool + * @since 100.2.0 */ public function isCookieRestrictionModeEnabled() { diff --git a/app/code/Magento/Cookie/Model/Config/Backend/Domain.php b/app/code/Magento/Cookie/Model/Config/Backend/Domain.php index 80426658c88fe..d0c2ec0e749d0 100644 --- a/app/code/Magento/Cookie/Model/Config/Backend/Domain.php +++ b/app/code/Magento/Cookie/Model/Config/Backend/Domain.php @@ -10,7 +10,9 @@ */ class Domain extends \Magento\Framework\App\Config\Value { - /** @var \Magento\Framework\Session\Config\Validator\CookieDomainValidator */ + /** + * @var \Magento\Framework\Session\Config\Validator\CookieDomainValidator + */ protected $configValidator; /** diff --git a/app/code/Magento/Cookie/Model/Config/Backend/Lifetime.php b/app/code/Magento/Cookie/Model/Config/Backend/Lifetime.php index 2218490dd432e..5f092e786f448 100644 --- a/app/code/Magento/Cookie/Model/Config/Backend/Lifetime.php +++ b/app/code/Magento/Cookie/Model/Config/Backend/Lifetime.php @@ -10,7 +10,9 @@ */ class Lifetime extends \Magento\Framework\App\Config\Value { - /** @var \Magento\Framework\Session\Config\Validator\CookieLifetimeValidator */ + /** + * @var \Magento\Framework\Session\Config\Validator\CookieLifetimeValidator + */ protected $configValidator; /** diff --git a/app/code/Magento/Cookie/Model/Config/Backend/Path.php b/app/code/Magento/Cookie/Model/Config/Backend/Path.php index 28d1d4fb7e355..916a5e81ebc89 100644 --- a/app/code/Magento/Cookie/Model/Config/Backend/Path.php +++ b/app/code/Magento/Cookie/Model/Config/Backend/Path.php @@ -10,7 +10,9 @@ */ class Path extends \Magento\Framework\App\Config\Value { - /** @var \Magento\Framework\Session\Config\Validator\CookiePathValidator */ + /** + * @var \Magento\Framework\Session\Config\Validator\CookiePathValidator + */ protected $configValidator; /** diff --git a/app/code/Magento/Cookie/Test/Unit/Controller/Index/NoCookiesTest.php b/app/code/Magento/Cookie/Test/Unit/Controller/Index/NoCookiesTest.php index d511e8d63b784..70f7d236e0b3b 100644 --- a/app/code/Magento/Cookie/Test/Unit/Controller/Index/NoCookiesTest.php +++ b/app/code/Magento/Cookie/Test/Unit/Controller/Index/NoCookiesTest.php @@ -7,7 +7,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class NoCookiesTest extends \PHPUnit_Framework_TestCase +class NoCookiesTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Cookie\Controller\Index\NoCookies @@ -55,7 +55,7 @@ public function setup() ->getMock(); $this->redirectResponseMock = $this->getMockBuilder(\Magento\Framework\App\Response\RedirectInterface::class) ->getMock(); - $this->viewMock = $this->getMock(\Magento\Framework\App\ViewInterface::class); + $this->viewMock = $this->createMock(\Magento\Framework\App\ViewInterface::class); $this->controller = $objectManager->getObject( \Magento\Cookie\Controller\Index\NoCookies::class, diff --git a/app/code/Magento/Cookie/Test/Unit/Helper/CookieTest.php b/app/code/Magento/Cookie/Test/Unit/Helper/CookieTest.php index 27cecb4305d03..5694f3f3cab56 100644 --- a/app/code/Magento/Cookie/Test/Unit/Helper/CookieTest.php +++ b/app/code/Magento/Cookie/Test/Unit/Helper/CookieTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Cookie\Test\Unit\Helper; -class CookieTest extends \PHPUnit_Framework_TestCase +class CookieTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Cookie\Helper\Cookie @@ -26,22 +26,18 @@ public function testIsUserNotAllowSaveCookie() { $this->_initMock()->_getCookieStub([1 => 1]); $this->assertFalse($this->_object->isUserNotAllowSaveCookie()); - $request = $this->getMock(\Magento\Framework\App\Request\Http::class, ['getCookie'], [], '', false, false); + $request = $this->createPartialMock(\Magento\Framework\App\Request\Http::class, ['getCookie']); $request->expects($this->any())->method('getCookie')->will($this->returnValue(json_encode([]))); $scopeConfig = $this->_getConfigStub(); - $context = $this->getMock( + $context = $this->createPartialMock( \Magento\Framework\App\Helper\Context::class, - ['getRequest', 'getScopeConfig'], - [], - '', - false, - false + ['getRequest', 'getScopeConfig'] ); $context->expects($this->once())->method('getRequest')->will($this->returnValue($request)); $context->expects($this->once())->method('getScopeConfig')->will($this->returnValue($scopeConfig)); $this->_object = new \Magento\Cookie\Helper\Cookie( $context, - $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false, false), + $this->createMock(\Magento\Store\Model\StoreManager::class), ['current_store' => $this->_getStoreStub(), 'website' => $this->_getWebsiteStub()] ); $this->assertTrue($this->_object->isUserNotAllowSaveCookie()); @@ -56,8 +52,8 @@ public function testGetAcceptedSaveCookiesWebsiteIds() public function testGetCookieRestrictionLifetime() { $this->_request = - $this->getMock(\Magento\Framework\App\Request\Http::class, ['getCookie'], [], '', false, false); - $scopeConfig = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->createPartialMock(\Magento\Framework\App\Request\Http::class, ['getCookie']); + $scopeConfig = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $storeStub = $this->_getStoreStub(); $scopeConfig->expects( $this->once() @@ -68,20 +64,16 @@ public function testGetCookieRestrictionLifetime() )->with( $this->equalTo('web/cookie/cookie_restriction_lifetime') ); - $this->_context = $this->getMock( + $this->_context = $this->createPartialMock( \Magento\Framework\App\Helper\Context::class, - ['getRequest', 'getScopeConfig'], - [], - '', - false, - false + ['getRequest', 'getScopeConfig'] ); $this->_context->expects($this->once())->method('getRequest')->will($this->returnValue($this->_request)); $this->_context->expects($this->once())->method('getScopeConfig')->will($this->returnValue($scopeConfig)); - + $this->_object = new \Magento\Cookie\Helper\Cookie( $this->_context, - $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false, false), + $this->createMock(\Magento\Store\Model\StoreManager::class), ['current_store' => $storeStub, 'website' => $this->_getWebsiteStub()] ); $this->assertEquals($this->_object->getCookieRestrictionLifetime(), 60 * 60 * 24 * 365); @@ -91,20 +83,16 @@ protected function _initMock() { $scopeConfig = $this->_getConfigStub(); $this->_request = - $this->getMock(\Magento\Framework\App\Request\Http::class, ['getCookie'], [], '', false, false); - $this->_context = $this->getMock( + $this->createPartialMock(\Magento\Framework\App\Request\Http::class, ['getCookie']); + $this->_context = $this->createPartialMock( \Magento\Framework\App\Helper\Context::class, - ['getRequest', 'getScopeConfig'], - [], - '', - false, - false + ['getRequest', 'getScopeConfig'] ); $this->_context->expects($this->once())->method('getRequest')->will($this->returnValue($this->_request)); $this->_context->expects($this->once())->method('getScopeConfig')->will($this->returnValue($scopeConfig)); $this->_object = new \Magento\Cookie\Helper\Cookie( $this->_context, - $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false, false), + $this->createMock(\Magento\Store\Model\StoreManager::class), ['current_store' => $this->_getStoreStub(), 'website' => $this->_getWebsiteStub()] ); return $this; @@ -116,7 +104,7 @@ protected function _initMock() */ protected function _getStoreStub() { - $store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $store = $this->createMock(\Magento\Store\Model\Store::class); return $store; } @@ -127,7 +115,7 @@ protected function _getStoreStub() */ protected function _getConfigStub() { - $scopeConfig = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $scopeConfig = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $scopeConfig->expects( $this->any() )->method( @@ -161,7 +149,7 @@ protected function _getCookieStub($cookieString = []) */ protected function _getWebsiteStub() { - $websiteMock = $this->getMock(\Magento\Store\Model\Website::class, [], [], '', false); + $websiteMock = $this->createMock(\Magento\Store\Model\Website::class); $websiteMock->expects($this->any())->method('getId')->will($this->returnValue(1)); diff --git a/app/code/Magento/Cookie/Test/Unit/Model/Config/Backend/DomainTest.php b/app/code/Magento/Cookie/Test/Unit/Model/Config/Backend/DomainTest.php index ad7d5e83f344d..6ca57c09fdf36 100644 --- a/app/code/Magento/Cookie/Test/Unit/Model/Config/Backend/DomainTest.php +++ b/app/code/Magento/Cookie/Test/Unit/Model/Config/Backend/DomainTest.php @@ -11,7 +11,7 @@ /** * Test \Magento\Cookie\Model\Config\Backend\Domain */ -class DomainTest extends \PHPUnit_Framework_TestCase +class DomainTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Framework\Model\ResourceModel\AbstractResource | \PHPUnit_Framework_MockObject_MockObject */ protected $resourceMock; @@ -26,8 +26,8 @@ class DomainTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $eventDispatcherMock = $this->getMock(\Magento\Framework\Event\Manager::class, [], [], '', false); - $contextMock = $this->getMock(\Magento\Framework\Model\Context::class, [], [], '', false); + $eventDispatcherMock = $this->createMock(\Magento\Framework\Event\Manager::class); + $contextMock = $this->createMock(\Magento\Framework\Model\Context::class); $contextMock->expects( $this->any() )->method( @@ -36,9 +36,7 @@ protected function setUp() $this->returnValue($eventDispatcherMock) ); - $this->resourceMock = $this->getMock( - \Magento\Framework\Model\ResourceModel\AbstractResource::class, - [ + $this->resourceMock = $this->createPartialMock(\Magento\Framework\Model\ResourceModel\AbstractResource::class, [ '_construct', 'getConnection', 'getIdFieldName', @@ -47,11 +45,7 @@ protected function setUp() 'commit', 'addCommitCallback', 'rollBack', - ], - [], - '', - false - ); + ]); $this->validatorMock = $this->getMockBuilder( \Magento\Framework\Session\Config\Validator\CookieDomainValidator::class diff --git a/app/code/Magento/Cookie/Test/Unit/Model/Config/Backend/LifetimeTest.php b/app/code/Magento/Cookie/Test/Unit/Model/Config/Backend/LifetimeTest.php index fc99cc5a237a6..c11bd741bc4b1 100644 --- a/app/code/Magento/Cookie/Test/Unit/Model/Config/Backend/LifetimeTest.php +++ b/app/code/Magento/Cookie/Test/Unit/Model/Config/Backend/LifetimeTest.php @@ -13,7 +13,7 @@ use Magento\Framework\Session\Config\Validator\CookieLifetimeValidator; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class LifetimeTest extends \PHPUnit_Framework_TestCase +class LifetimeTest extends \PHPUnit\Framework\TestCase { /** @var \PHPUnit_Framework_MockObject_MockObject | CookieLifetimeValidator */ private $validatorMock; diff --git a/app/code/Magento/Cookie/Test/Unit/Model/Config/Backend/PathTest.php b/app/code/Magento/Cookie/Test/Unit/Model/Config/Backend/PathTest.php index 97f0459756cac..705312425a75a 100644 --- a/app/code/Magento/Cookie/Test/Unit/Model/Config/Backend/PathTest.php +++ b/app/code/Magento/Cookie/Test/Unit/Model/Config/Backend/PathTest.php @@ -13,7 +13,7 @@ use Magento\Framework\Session\Config\Validator\CookiePathValidator; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class PathTest extends \PHPUnit_Framework_TestCase +class PathTest extends \PHPUnit\Framework\TestCase { /** @var \PHPUnit_Framework_MockObject_MockObject | CookiePathValidator */ private $validatorMock; diff --git a/app/code/Magento/Cookie/view/adminhtml/requirejs-config.js b/app/code/Magento/Cookie/view/adminhtml/requirejs-config.js deleted file mode 100644 index 9339ea7a4a0d6..0000000000000 --- a/app/code/Magento/Cookie/view/adminhtml/requirejs-config.js +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - -var config = { - map: { - '*': { - requireCookie: 'Magento_Cookie/js/require-cookie' - } - } -}; diff --git a/app/code/Magento/Cron/Model/ConfigInterface.php b/app/code/Magento/Cron/Model/ConfigInterface.php index 904a748f000b8..5571c5f8a9c8b 100644 --- a/app/code/Magento/Cron/Model/ConfigInterface.php +++ b/app/code/Magento/Cron/Model/ConfigInterface.php @@ -9,6 +9,7 @@ * Interface \Magento\Cron\Model\ConfigInterface * * @api + * @since 100.0.2 */ interface ConfigInterface { diff --git a/app/code/Magento/Cron/Model/ResourceModel/Schedule.php b/app/code/Magento/Cron/Model/ResourceModel/Schedule.php index 713224745dcfa..a47227bb60598 100644 --- a/app/code/Magento/Cron/Model/ResourceModel/Schedule.php +++ b/app/code/Magento/Cron/Model/ResourceModel/Schedule.php @@ -9,6 +9,7 @@ * Schedule resource * * @api + * @since 100.0.2 */ class Schedule extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { @@ -59,6 +60,7 @@ public function trySetJobStatusAtomic($scheduleId, $newStatus, $currentStatus) * @param string $newStatus * @param string $currentStatus * @return bool + * @since 100.2.0 */ public function trySetJobUniqueStatusAtomic($scheduleId, $newStatus, $currentStatus) { diff --git a/app/code/Magento/Cron/Model/ResourceModel/Schedule/Collection.php b/app/code/Magento/Cron/Model/ResourceModel/Schedule/Collection.php index 32a8aa3c2d9d4..8841650f38b75 100644 --- a/app/code/Magento/Cron/Model/ResourceModel/Schedule/Collection.php +++ b/app/code/Magento/Cron/Model/ResourceModel/Schedule/Collection.php @@ -9,6 +9,7 @@ * Schedules Collection * * @api + * @since 100.0.2 */ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { diff --git a/app/code/Magento/Cron/Model/Schedule.php b/app/code/Magento/Cron/Model/Schedule.php index df9586143aa9a..5670a6867e0fb 100644 --- a/app/code/Magento/Cron/Model/Schedule.php +++ b/app/code/Magento/Cron/Model/Schedule.php @@ -11,8 +11,6 @@ /** * Crontab schedule model * - * @method \Magento\Cron\Model\ResourceModel\Schedule _getResource() - * @method \Magento\Cron\Model\ResourceModel\Schedule getResource() * @method string getJobCode() * @method \Magento\Cron\Model\Schedule setJobCode(string $value) * @method string getStatus() @@ -31,6 +29,7 @@ * @method \Magento\Cron\Model\Schedule setCronExprArr(array $value) * * @api + * @since 100.0.2 */ class Schedule extends \Magento\Framework\Model\AbstractModel { diff --git a/app/code/Magento/Cron/Test/Unit/Console/Command/CronCommandTest.php b/app/code/Magento/Cron/Test/Unit/Console/Command/CronCommandTest.php index b9349c65a2dbc..8b3e50d6afb3a 100644 --- a/app/code/Magento/Cron/Test/Unit/Console/Command/CronCommandTest.php +++ b/app/code/Magento/Cron/Test/Unit/Console/Command/CronCommandTest.php @@ -8,13 +8,13 @@ use Magento\Cron\Console\Command\CronCommand; use Symfony\Component\Console\Tester\CommandTester; -class CronCommandTest extends \PHPUnit_Framework_TestCase +class CronCommandTest extends \PHPUnit\Framework\TestCase { public function testExecute() { - $objectManagerFactory = $this->getMock(\Magento\Framework\App\ObjectManagerFactory::class, [], [], '', false); - $objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class, [], [], '', false); - $cron = $this->getMock(\Magento\Framework\App\Cron::class, [], [], '', false); + $objectManagerFactory = $this->createMock(\Magento\Framework\App\ObjectManagerFactory::class); + $objectManager = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); + $cron = $this->createMock(\Magento\Framework\App\Cron::class); $objectManager->expects($this->once())->method('create')->willReturn($cron); $cron->expects($this->once())->method('launch'); $objectManagerFactory->expects($this->once())->method('create')->willReturn($objectManager); diff --git a/app/code/Magento/Cron/Test/Unit/Console/Command/CronInstallCommandTest.php b/app/code/Magento/Cron/Test/Unit/Console/Command/CronInstallCommandTest.php index 2e4bb9d99f0dd..23403d3bdd73b 100644 --- a/app/code/Magento/Cron/Test/Unit/Console/Command/CronInstallCommandTest.php +++ b/app/code/Magento/Cron/Test/Unit/Console/Command/CronInstallCommandTest.php @@ -13,7 +13,7 @@ use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Phrase; -class CronInstallCommandTest extends \PHPUnit_Framework_TestCase +class CronInstallCommandTest extends \PHPUnit\Framework\TestCase { /** * @var CrontabManagerInterface|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Cron/Test/Unit/Console/Command/CronRemoveCommandTest.php b/app/code/Magento/Cron/Test/Unit/Console/Command/CronRemoveCommandTest.php index fd3540be5a763..fa0de64f43004 100644 --- a/app/code/Magento/Cron/Test/Unit/Console/Command/CronRemoveCommandTest.php +++ b/app/code/Magento/Cron/Test/Unit/Console/Command/CronRemoveCommandTest.php @@ -12,7 +12,7 @@ use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Phrase; -class CronRemoveCommandTest extends \PHPUnit_Framework_TestCase +class CronRemoveCommandTest extends \PHPUnit\Framework\TestCase { /** * @var CrontabManagerInterface|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Cron/Test/Unit/Model/Config/Converter/DbTest.php b/app/code/Magento/Cron/Test/Unit/Model/Config/Converter/DbTest.php index 3755b81399167..ff8e735091d25 100644 --- a/app/code/Magento/Cron/Test/Unit/Model/Config/Converter/DbTest.php +++ b/app/code/Magento/Cron/Test/Unit/Model/Config/Converter/DbTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Cron\Test\Unit\Model\Config\Converter; -class DbTest extends \PHPUnit_Framework_TestCase +class DbTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Cron\Model\Config\Converter\Db diff --git a/app/code/Magento/Cron/Test/Unit/Model/Config/Converter/XmlTest.php b/app/code/Magento/Cron/Test/Unit/Model/Config/Converter/XmlTest.php index 25ad961bbe8e6..7fb652398bfb3 100644 --- a/app/code/Magento/Cron/Test/Unit/Model/Config/Converter/XmlTest.php +++ b/app/code/Magento/Cron/Test/Unit/Model/Config/Converter/XmlTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Cron\Test\Unit\Model\Config\Converter; -class XmlTest extends \PHPUnit_Framework_TestCase +class XmlTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Cron\Model\Config\Converter\Xml diff --git a/app/code/Magento/Cron/Test/Unit/Model/Config/DataTest.php b/app/code/Magento/Cron/Test/Unit/Model/Config/DataTest.php index 1bba9ce1bd61c..b15613c31821e 100644 --- a/app/code/Magento/Cron/Test/Unit/Model/Config/DataTest.php +++ b/app/code/Magento/Cron/Test/Unit/Model/Config/DataTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Cron\Test\Unit\Model\Config; -class DataTest extends \PHPUnit_Framework_TestCase +class DataTest extends \PHPUnit\Framework\TestCase { /** * Testing return jobs from different sources (DB, XML) @@ -15,7 +15,7 @@ public function testGetJobs() $reader = $this->getMockBuilder( \Magento\Cron\Model\Config\Reader\Xml::class )->disableOriginalConstructor()->getMock(); - $cache = $this->getMock(\Magento\Framework\Config\CacheInterface::class); + $cache = $this->createMock(\Magento\Framework\Config\CacheInterface::class); $dbReader = $this->getMockBuilder( \Magento\Cron\Model\Config\Reader\Db::class )->disableOriginalConstructor()->getMock(); @@ -37,7 +37,7 @@ public function testGetJobs() $dbReader->expects($this->once())->method('get')->will($this->returnValue($dbReaderData)); - $serializerMock = $this->getMock(\Magento\Framework\Serialize\SerializerInterface::class); + $serializerMock = $this->createMock(\Magento\Framework\Serialize\SerializerInterface::class); $serializerMock->method('unserialize') ->willReturn($jobs); diff --git a/app/code/Magento/Cron/Test/Unit/Model/Config/Reader/DbTest.php b/app/code/Magento/Cron/Test/Unit/Model/Config/Reader/DbTest.php index 8906a8db9fc91..1f69429e7c389 100644 --- a/app/code/Magento/Cron/Test/Unit/Model/Config/Reader/DbTest.php +++ b/app/code/Magento/Cron/Test/Unit/Model/Config/Reader/DbTest.php @@ -13,7 +13,7 @@ * * @package Magento\Cron\Test\Unit\Model\Config\Reader */ -class DbTest extends \PHPUnit_Framework_TestCase +class DbTest extends \PHPUnit\Framework\TestCase { /** * @var Config | \PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Cron/Test/Unit/Model/Config/Reader/XmlTest.php b/app/code/Magento/Cron/Test/Unit/Model/Config/Reader/XmlTest.php index 3a21bfddcb2fd..bcd7186cd9a11 100644 --- a/app/code/Magento/Cron/Test/Unit/Model/Config/Reader/XmlTest.php +++ b/app/code/Magento/Cron/Test/Unit/Model/Config/Reader/XmlTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Cron\Test\Unit\Model\Config\Reader; -class XmlTest extends \PHPUnit_Framework_TestCase +class XmlTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Cron\Model\Config\Reader\Xml diff --git a/app/code/Magento/Cron/Test/Unit/Model/Config/SchemaLocatorTest.php b/app/code/Magento/Cron/Test/Unit/Model/Config/SchemaLocatorTest.php index cb16c42c71a7a..0746f5d0f3be7 100644 --- a/app/code/Magento/Cron/Test/Unit/Model/Config/SchemaLocatorTest.php +++ b/app/code/Magento/Cron/Test/Unit/Model/Config/SchemaLocatorTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Cron\Test\Unit\Model\Config; -class SchemaLocatorTest extends \PHPUnit_Framework_TestCase +class SchemaLocatorTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Cron/Test/Unit/Model/Config/XsdTest.php b/app/code/Magento/Cron/Test/Unit/Model/Config/XsdTest.php index 7466a517dd640..96f772e1be32b 100644 --- a/app/code/Magento/Cron/Test/Unit/Model/Config/XsdTest.php +++ b/app/code/Magento/Cron/Test/Unit/Model/Config/XsdTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Cron\Test\Unit\Model\Config; -class XsdTest extends \PHPUnit_Framework_TestCase +class XsdTest extends \PHPUnit\Framework\TestCase { /** * @var string diff --git a/app/code/Magento/Cron/Test/Unit/Model/ConfigTest.php b/app/code/Magento/Cron/Test/Unit/Model/ConfigTest.php index 1b3a55812535f..50eeacd71752b 100644 --- a/app/code/Magento/Cron/Test/Unit/Model/ConfigTest.php +++ b/app/code/Magento/Cron/Test/Unit/Model/ConfigTest.php @@ -8,7 +8,7 @@ /** * Class \Magento\Cron\Model\Config */ -class ConfigTest extends \PHPUnit_Framework_TestCase +class ConfigTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Cron\Model\Config\Data|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Cron/Test/Unit/Model/Groups/Config/Converter/XmlTest.php b/app/code/Magento/Cron/Test/Unit/Model/Groups/Config/Converter/XmlTest.php index b0173d2340287..8c4fb1d1b7b32 100644 --- a/app/code/Magento/Cron/Test/Unit/Model/Groups/Config/Converter/XmlTest.php +++ b/app/code/Magento/Cron/Test/Unit/Model/Groups/Config/Converter/XmlTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Cron\Test\Unit\Model\Groups\Config\Converter; -class XmlTest extends \PHPUnit_Framework_TestCase +class XmlTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Cron\Model\Groups\Config\Converter\Xml diff --git a/app/code/Magento/Cron/Test/Unit/Model/ScheduleTest.php b/app/code/Magento/Cron/Test/Unit/Model/ScheduleTest.php index 14c4d48e71237..04b47445cc7ba 100644 --- a/app/code/Magento/Cron/Test/Unit/Model/ScheduleTest.php +++ b/app/code/Magento/Cron/Test/Unit/Model/ScheduleTest.php @@ -11,7 +11,7 @@ * Class \Magento\Cron\Test\Unit\Model\ObserverTest * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ScheduleTest extends \PHPUnit_Framework_TestCase +class ScheduleTest extends \PHPUnit\Framework\TestCase { protected $helper; diff --git a/app/code/Magento/Cron/Test/Unit/Observer/ProcessCronQueueObserverTest.php b/app/code/Magento/Cron/Test/Unit/Observer/ProcessCronQueueObserverTest.php index 830bf420ee679..0db6a598fb56f 100644 --- a/app/code/Magento/Cron/Test/Unit/Observer/ProcessCronQueueObserverTest.php +++ b/app/code/Magento/Cron/Test/Unit/Observer/ProcessCronQueueObserverTest.php @@ -5,19 +5,16 @@ */ namespace Magento\Cron\Test\Unit\Observer; -use Magento\Cron\Model\ResourceModel\Schedule as ScheduleResource; use Magento\Cron\Model\Schedule; -use Magento\Cron\Observer\ProcessCronQueueObserver; +use Magento\Cron\Observer\ProcessCronQueueObserver as ProcessCronQueueObserver; use Magento\Framework\App\State; -use Magento\Framework\DB\Adapter\AdapterInterface; -use PHPUnit_Framework_MockObject_MockObject as Mock; /** * Class \Magento\Cron\Test\Unit\Model\ObserverTest * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.TooManyFields) */ -class ProcessCronQueueObserverTest extends \PHPUnit_Framework_TestCase +class ProcessCronQueueObserverTest extends \PHPUnit\Framework\TestCase { /** * @var ProcessCronQueueObserver @@ -25,43 +22,41 @@ class ProcessCronQueueObserverTest extends \PHPUnit_Framework_TestCase protected $_observer; /** - * @var \Magento\Framework\App\ObjectManager | Mock + * @var \Magento\Framework\App\ObjectManager|\PHPUnit_Framework_MockObject_MockObject */ protected $_objectManager; /** - * @var Mock + * @var \PHPUnit_Framework_MockObject_MockObject */ protected $_cache; /** - * @var \Magento\Cron\Model\Config | Mock + * @var \Magento\Cron\Model\Config|\PHPUnit_Framework_MockObject_MockObject */ protected $_config; /** - * @var \Magento\Cron\Model\ScheduleFactory | Mock + * @var \Magento\Cron\Model\ScheduleFactory|\PHPUnit_Framework_MockObject_MockObject */ protected $_scheduleFactory; /** - * @var \Magento\Framework\App\Config\ScopeConfigInterface | Mock + * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_scopeConfig; /** - * @var \Magento\Framework\App\Console\Request | Mock + * @var \Magento\Framework\App\Console\Request|\PHPUnit_Framework_MockObject_MockObject */ protected $_request; /** - * @var \Magento\Framework\ShellInterface | Mock + * @var \Magento\Framework\ShellInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_shell; - /** - * @var \Magento\Cron\Model\ResourceModel\Schedule\Collection | Mock - */ + /** @var \Magento\Cron\Model\ResourceModel\Schedule\Collection|\PHPUnit_Framework_MockObject_MockObject */ protected $_collection; /** @@ -80,24 +75,24 @@ class ProcessCronQueueObserverTest extends \PHPUnit_Framework_TestCase protected $observer; /** - * @var \Psr\Log\LoggerInterface | Mock + * @var \Psr\Log\LoggerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $loggerMock; /** - * @var \Magento\Framework\App\State | Mock + * @var \Magento\Framework\App\State|\PHPUnit_Framework_MockObject_MockObject */ protected $appStateMock; /** - * @var ScheduleResource | Mock + * @var \Magento\Cron\Model\ResourceModel\Schedule|\PHPUnit_Framework_MockObject_MockObject */ - private $scheduleResource; + protected $scheduleResource; /** - * @var AdapterInterface | Mock + * @var int */ - private $connection; + protected $time = 1501538400; /** * Prepare parameters @@ -107,23 +102,13 @@ protected function setUp() $this->_objectManager = $this->getMockBuilder( \Magento\Framework\App\ObjectManager::class )->disableOriginalConstructor()->getMock(); - $this->_cache = $this->getMock(\Magento\Framework\App\CacheInterface::class); + $this->_cache = $this->createMock(\Magento\Framework\App\CacheInterface::class); $this->_config = $this->getMockBuilder( \Magento\Cron\Model\Config::class )->disableOriginalConstructor()->getMock(); $this->_scopeConfig = $this->getMockBuilder( \Magento\Framework\App\Config\ScopeConfigInterface::class )->disableOriginalConstructor()->getMock(); - $this->_scopeConfig->expects($this->any())->method('getValue')->will($this->returnValueMap([ - ['system/cron/default/schedule_generate_every', 'store', null, 1], - ['system/cron/default/schedule_ahead_for', 'store', null, 20], - ['system/cron/default/schedule_lifetime', 'store', null, 15], - ['system/cron/default/history_cleanup_every', 'store', null, 10], - ['system/cron/default/history_success_lifetime', 'store', null, 60], - ['system/cron/default/history_failure_lifetime', 'store', null, 600], - ['system/cron/default/use_separate_process', 'store', null, 0], - ])); - $this->_collection = $this->getMockBuilder( \Magento\Cron\Model\ResourceModel\Schedule\Collection::class )->setMethods( @@ -131,42 +116,48 @@ protected function setUp() )->disableOriginalConstructor()->getMock(); $this->_collection->expects($this->any())->method('addFieldToFilter')->will($this->returnSelf()); $this->_collection->expects($this->any())->method('load')->will($this->returnSelf()); - $this->_scheduleFactory = $this->getMockBuilder(\Magento\Cron\Model\ScheduleFactory::class) - ->setMethods(['create'])->disableOriginalConstructor()->getMock(); - $this->_request = $this->getMockBuilder(\Magento\Framework\App\Console\Request::class) - ->disableOriginalConstructor()->getMock(); - $this->_shell = $this->getMockBuilder(\Magento\Framework\ShellInterface::class) - ->disableOriginalConstructor()->setMethods(['execute'])->getMock(); - $this->loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); + $this->_scheduleFactory = $this->getMockBuilder( + \Magento\Cron\Model\ScheduleFactory::class + )->setMethods( + ['create'] + )->disableOriginalConstructor()->getMock(); + $this->_request = $this->getMockBuilder( + \Magento\Framework\App\Console\Request::class + )->disableOriginalConstructor()->getMock(); + $this->_shell = $this->getMockBuilder( + \Magento\Framework\ShellInterface::class + )->disableOriginalConstructor()->setMethods( + ['execute'] + )->getMock(); + $this->loggerMock = $this->createMock(\Psr\Log\LoggerInterface::class); $this->appStateMock = $this->getMockBuilder(\Magento\Framework\App\State::class) ->disableOriginalConstructor() ->getMock(); - $this->observer = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false); + $this->observer = $this->createMock(\Magento\Framework\Event\Observer::class); $this->dateTimeMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\DateTime::class) ->disableOriginalConstructor() ->getMock(); - $this->dateTimeMock->expects($this->any())->method('gmtTimestamp')->will($this->returnValue(time())); + $this->dateTimeMock->expects($this->any())->method('gmtTimestamp')->will($this->returnValue($this->time)); - $phpExecutableFinder = $this->getMock(\Symfony\Component\Process\PhpExecutableFinder::class, [], [], '', false); + $phpExecutableFinder = $this->createMock(\Symfony\Component\Process\PhpExecutableFinder::class); $phpExecutableFinder->expects($this->any())->method('find')->willReturn('php'); - $phpExecutableFinderFactory = $this->getMock( - \Magento\Framework\Process\PhpExecutableFinderFactory::class, - [], - [], - '', - false + $phpExecutableFinderFactory = $this->createMock( + \Magento\Framework\Process\PhpExecutableFinderFactory::class ); $phpExecutableFinderFactory->expects($this->any())->method('create')->willReturn($phpExecutableFinder); - $this->scheduleResource = $this->getMockBuilder(ScheduleResource::class) - ->disableOriginalConstructor()->getMock(); - $this->connection = $this->getMockBuilder(AdapterInterface::class)->disableOriginalConstructor()->getMock(); + $this->scheduleResource = $this->getMockBuilder(\Magento\Cron\Model\ResourceModel\Schedule::class) + ->disableOriginalConstructor() + ->getMock(); + $connection = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class) + ->disableOriginalConstructor() + ->getMock(); - $this->scheduleResource->method('getConnection')->willReturn($this->connection); - $this->connection->method('delete')->willReturn(1); + $this->scheduleResource->method('getConnection')->willReturn($connection); + $connection->method('delete')->willReturn(1); $this->_observer = new ProcessCronQueueObserver( $this->_objectManager, @@ -184,78 +175,91 @@ protected function setUp() } /** - * Test case for an empty cron_schedule table and no job generation + * Test case without saved cron jobs in data base */ public function testDispatchNoPendingJobs() { - $lastRun = time() + 10000000; // skip cleanup and generation + $lastRun = $this->time + 10000000; $this->_cache->expects($this->any())->method('load')->will($this->returnValue($lastRun)); - $this->_request->expects($this->any())->method('getParam')->will($this->returnValue('default')); + $this->_scopeConfig->expects($this->any())->method('getValue')->will($this->returnValue(0)); - $this->_config->expects($this->exactly(2))->method('getJobs') - ->will($this->returnValue(['default' => ['test_job1' => ['test_data']]])); + $this->_config->expects($this->once())->method('getJobs')->will($this->returnValue([])); - $scheduleMock = $this->getMockBuilder(Schedule::class)->disableOriginalConstructor()->getMock(); + $scheduleMock = $this->getMockBuilder( + \Magento\Cron\Model\Schedule::class + )->disableOriginalConstructor()->getMock(); $scheduleMock->expects($this->any())->method('getCollection')->will($this->returnValue($this->_collection)); - $scheduleMock->expects($this->any())->method('getResource')->will($this->returnValue($this->scheduleResource)); - $scheduleMock->expects($this->never())->method('setStatus'); - $scheduleMock->expects($this->never())->method('setExecutedAt'); - $this->_scheduleFactory->expects($this->exactly(2))->method('create')->will($this->returnValue($scheduleMock)); + $this->_scheduleFactory->expects($this->once())->method('create')->will($this->returnValue($scheduleMock)); $this->_observer->execute($this->observer); } /** - * Test case for a cron job in the database that is not found in the config + * Test case for not existed cron jobs in files but in data base is presented */ public function testDispatchNoJobConfig() { - $lastRun = time() + 10000000; // skip cleanup and generation + $lastRun = $this->time + 10000000; $this->_cache->expects($this->any())->method('load')->will($this->returnValue($lastRun)); - $this->_request->expects($this->any())->method('getParam')->will($this->returnValue('default')); - - $this->_config->expects($this->any())->method('getJobs')->will($this->returnValue(['default' => []])); + $this->_scopeConfig->expects($this->any())->method('getValue')->will($this->returnValue(0)); + + $this->_config->expects( + $this->any() + )->method( + 'getJobs' + )->will( + $this->returnValue(['test_job1' => ['test_data']]) + ); - /** @var Schedule | Mock $schedule */ - $schedule = $this->getMock(Schedule::class, ['getJobCode', '__wakeup'], [], '', false); - $schedule->expects($this->any())->method('getJobCode')->will($this->returnValue('not_existed_job_code')); + $schedule = $this->createPartialMock(\Magento\Cron\Model\Schedule::class, ['getJobCode', '__wakeup']); + $schedule->expects($this->once())->method('getJobCode')->will($this->returnValue('not_existed_job_code')); $this->_collection->addItem($schedule); - $scheduleMock = $this->getMockBuilder(Schedule::class)->disableOriginalConstructor()->getMock(); + $scheduleMock = $this->getMockBuilder( + \Magento\Cron\Model\Schedule::class + )->disableOriginalConstructor()->getMock(); $scheduleMock->expects($this->any())->method('getCollection')->will($this->returnValue($this->_collection)); $scheduleMock->expects($this->any())->method('getResource')->will($this->returnValue($this->scheduleResource)); - $scheduleMock->expects($this->never())->method('getScheduledAt'); - $this->_scheduleFactory->expects($this->once())->method('create')->will($this->returnValue($scheduleMock)); + $this->_scheduleFactory->expects($this->any())->method('create')->will($this->returnValue($scheduleMock)); $this->_observer->execute($this->observer); } /** - * Test case when a job can't be locked + * Test case checks if some job can't be locked */ public function testDispatchCanNotLock() { - $lastRun = time() + 10000000; // skip cleanup and generation + $lastRun = $this->time + 10000000; $this->_cache->expects($this->any())->method('load')->will($this->returnValue($lastRun)); - $this->_request->expects($this->any())->method('getParam')->will($this->returnValue('default')); - /** @var Schedule | Mock $schedule */ - $schedule = $this->getMockBuilder(Schedule::class) - ->setMethods(['getJobCode', 'tryLockJob', 'getScheduledAt', '__wakeup', 'save']) - ->disableOriginalConstructor()->getMock(); + $this->_scopeConfig->expects($this->any())->method('getValue')->will($this->returnValue(0)); + $this->_request->expects($this->any())->method('getParam')->will($this->returnValue('test_group')); + + $dateScheduledAt = date('Y-m-d H:i:s', $this->time - 86400); + $schedule = $this->getMockBuilder( + \Magento\Cron\Model\Schedule::class + )->setMethods( + ['getJobCode', 'tryLockJob', 'getScheduledAt', '__wakeup', 'save'] + )->disableOriginalConstructor()->getMock(); $schedule->expects($this->any())->method('getJobCode')->will($this->returnValue('test_job1')); - $schedule->expects($this->once())->method('getScheduledAt')->will($this->returnValue('-1 day')); + $schedule->expects($this->once())->method('getScheduledAt')->will($this->returnValue($dateScheduledAt)); $schedule->expects($this->once())->method('tryLockJob')->will($this->returnValue(false)); - $schedule->expects($this->never())->method('setStatus'); - $schedule->expects($this->never())->method('setExecutedAt'); - $abstractModel = $this->getMock(\Magento\Framework\Model\AbstractModel::class, [], [], '', false); + $abstractModel = $this->createMock(\Magento\Framework\Model\AbstractModel::class); $schedule->expects($this->any())->method('save')->will($this->returnValue($abstractModel)); $this->_collection->addItem($schedule); - $this->_config->expects($this->exactly(2))->method('getJobs') - ->will($this->returnValue(['default' => ['test_job1' => ['test_data']]])); + $this->_config->expects( + $this->exactly(2) + )->method( + 'getJobs' + )->will( + $this->returnValue(['test_group' => ['test_job1' => ['test_data']]]) + ); - $scheduleMock = $this->getMockBuilder(Schedule::class)->disableOriginalConstructor()->getMock(); + $scheduleMock = $this->getMockBuilder( + \Magento\Cron\Model\Schedule::class + )->disableOriginalConstructor()->getMock(); $scheduleMock->expects($this->any())->method('getCollection')->will($this->returnValue($this->_collection)); $scheduleMock->expects($this->any())->method('getResource')->will($this->returnValue($this->scheduleResource)); $this->_scheduleFactory->expects($this->exactly(2))->method('create')->will($this->returnValue($scheduleMock)); @@ -264,21 +268,23 @@ public function testDispatchCanNotLock() } /** - * Test case for catching the exception 'Too late for the schedule' + * Test case catch exception if too late for schedule */ public function testDispatchExceptionTooLate() { - $lastRun = time() + 10000000; // skip cleanup and generation $exceptionMessage = 'Too late for the schedule'; $scheduleId = 42; $jobCode = 'test_job1'; $exception = $exceptionMessage . ' Schedule Id: ' . $scheduleId . ' Job Code: ' . $jobCode; + $lastRun = $this->time + 10000000; $this->_cache->expects($this->any())->method('load')->willReturn($lastRun); - $this->_request->expects($this->any())->method('getParam')->willReturn('default'); - /** @var Schedule | Mock $schedule */ + $this->_scopeConfig->expects($this->any())->method('getValue')->willReturn(0); + $this->_request->expects($this->any())->method('getParam')->willReturn('test_group'); + + $dateScheduledAt = date('Y-m-d H:i:s', $this->time - 86400); $schedule = $this->getMockBuilder( - Schedule::class + \Magento\Cron\Model\Schedule::class )->setMethods( [ 'getJobCode', @@ -294,24 +300,36 @@ public function testDispatchExceptionTooLate() ] )->disableOriginalConstructor()->getMock(); $schedule->expects($this->any())->method('getJobCode')->willReturn($jobCode); - $schedule->expects($this->once())->method('getScheduledAt')->willReturn('-16 minutes'); + $schedule->expects($this->once())->method('getScheduledAt')->willReturn($dateScheduledAt); $schedule->expects($this->once())->method('tryLockJob')->willReturn(true); - $schedule->expects($this->once())->method('setStatus') - ->with($this->equalTo(Schedule::STATUS_MISSED))->willReturnSelf(); + $schedule->expects( + $this->once() + )->method( + 'setStatus' + )->with( + $this->equalTo(\Magento\Cron\Model\Schedule::STATUS_MISSED) + )->willReturnSelf(); $schedule->expects($this->once())->method('setMessages')->with($this->equalTo($exceptionMessage)); - $schedule->expects($this->once())->method('setStatus')->with(Schedule::STATUS_MISSED); $schedule->expects($this->any())->method('getStatus')->willReturn(Schedule::STATUS_MISSED); $schedule->expects($this->once())->method('getMessages')->willReturn($exceptionMessage); $schedule->expects($this->once())->method('getScheduleId')->willReturn($scheduleId); $schedule->expects($this->once())->method('save'); - $this->_collection->addItem($schedule); $this->appStateMock->expects($this->once())->method('getMode')->willReturn(State::MODE_DEVELOPER); + $this->loggerMock->expects($this->once())->method('info')->with($exception); - $this->_config->expects($this->exactly(2))->method('getJobs') - ->willReturn(['default' => ['test_job1' => ['test_data']]]); - $scheduleMock = $this->getMockBuilder(Schedule::class) + $this->_collection->addItem($schedule); + + $this->_config->expects( + $this->exactly(2) + )->method( + 'getJobs' + )->willReturn( + ['test_group' => ['test_job1' => ['test_data']]] + ); + + $scheduleMock = $this->getMockBuilder(\Magento\Cron\Model\Schedule::class) ->disableOriginalConstructor()->getMock(); $scheduleMock->expects($this->any())->method('getCollection')->willReturn($this->_collection); $scheduleMock->expects($this->any())->method('getResource')->will($this->returnValue($this->scheduleResource)); @@ -321,37 +339,52 @@ public function testDispatchExceptionTooLate() } /** - * Test case catch exception if callback does not exist + * Test case catch exception if callback not exist */ public function testDispatchExceptionNoCallback() { - $lastRun = time() + 10000000; // skip cleanup and generation $exceptionMessage = 'No callbacks found'; $exception = new \Exception(__($exceptionMessage)); - $jobConfig = ['default' => ['test_job1' => ['instance' => 'Some_Class', /* 'method' => 'not_set' */]]]; - /** @var Schedule | Mock $schedule */ + $dateScheduledAt = date('Y-m-d H:i:s', $this->time - 86400); $schedule = $this->getMockBuilder( - Schedule::class + \Magento\Cron\Model\Schedule::class )->setMethods( ['getJobCode', 'tryLockJob', 'getScheduledAt', 'save', 'setStatus', 'setMessages', '__wakeup', 'getStatus'] )->disableOriginalConstructor()->getMock(); $schedule->expects($this->any())->method('getJobCode')->will($this->returnValue('test_job1')); - $schedule->expects($this->once())->method('getScheduledAt')->will($this->returnValue(date('Y-m-d H:i:00'))); + $schedule->expects($this->once())->method('getScheduledAt')->will($this->returnValue($dateScheduledAt)); $schedule->expects($this->once())->method('tryLockJob')->will($this->returnValue(true)); - $schedule->expects($this->once())->method('setStatus') - ->with($this->equalTo(Schedule::STATUS_ERROR))->will($this->returnSelf()); + $schedule->expects( + $this->once() + )->method( + 'setStatus' + )->with( + $this->equalTo(\Magento\Cron\Model\Schedule::STATUS_ERROR) + )->will( + $this->returnSelf() + ); $schedule->expects($this->once())->method('setMessages')->with($this->equalTo($exceptionMessage)); $schedule->expects($this->any())->method('getStatus')->willReturn(Schedule::STATUS_ERROR); $schedule->expects($this->once())->method('save'); - $this->_request->expects($this->any())->method('getParam')->will($this->returnValue('default')); + $this->_request->expects($this->any())->method('getParam')->will($this->returnValue('test_group')); $this->_collection->addItem($schedule); + $this->loggerMock->expects($this->once())->method('critical')->with($exception); + + $jobConfig = ['test_group' => ['test_job1' => ['instance' => 'Some_Class']]]; + $this->_config->expects($this->exactly(2))->method('getJobs')->will($this->returnValue($jobConfig)); + + $lastRun = $this->time + 10000000; $this->_cache->expects($this->any())->method('load')->will($this->returnValue($lastRun)); + $this->_scopeConfig->expects($this->any()) + ->method('getValue') + ->will($this->returnValue($this->time + 86400)); + $scheduleMock = $this->getMockBuilder( - Schedule::class + \Magento\Cron\Model\Schedule::class )->disableOriginalConstructor()->getMock(); $scheduleMock->expects($this->any())->method('getCollection')->will($this->returnValue($this->_collection)); $scheduleMock->expects($this->any())->method('getResource')->will($this->returnValue($this->scheduleResource)); @@ -378,32 +411,45 @@ public function testDispatchExceptionInCallback( $saveCalls, $exception ) { - $lastRun = time() + 10000000; // skip cleanup and generation - $jobConfig = ['default' => ['test_job1' => ['instance' => $cronJobType, 'method' => 'execute']]]; + $jobConfig = [ + 'test_group' => [ + 'test_job1' => ['instance' => $cronJobType, 'method' => 'execute'], + ], + ]; - $this->_request->expects($this->any())->method('getParam')->will($this->returnValue('default')); - /** @var Schedule | Mock $schedule */ - $schedule = $this->getMockBuilder(Schedule::class)->setMethods( + $this->_request->expects($this->any())->method('getParam')->will($this->returnValue('test_group')); + + $dateScheduledAt = date('Y-m-d H:i:s', $this->time - 86400); + $schedule = $this->getMockBuilder( + \Magento\Cron\Model\Schedule::class + )->setMethods( ['getJobCode', 'tryLockJob', 'getScheduledAt', 'save', 'setStatus', 'setMessages', '__wakeup', 'getStatus'] )->disableOriginalConstructor()->getMock(); $schedule->expects($this->any())->method('getJobCode')->will($this->returnValue('test_job1')); - $schedule->expects($this->once())->method('getScheduledAt')->will($this->returnValue(date('Y-m-d H:i:00'))); + $schedule->expects($this->once())->method('getScheduledAt')->will($this->returnValue($dateScheduledAt)); $schedule->expects($this->once())->method('tryLockJob')->will($this->returnValue(true)); $schedule->expects($this->once()) ->method('setStatus') - ->with($this->equalTo(Schedule::STATUS_ERROR)) + ->with($this->equalTo(\Magento\Cron\Model\Schedule::STATUS_ERROR)) ->will($this->returnSelf()); $schedule->expects($this->once())->method('setMessages')->with($this->equalTo($exceptionMessage)); $schedule->expects($this->any())->method('getStatus')->willReturn(Schedule::STATUS_ERROR); $schedule->expects($this->exactly($saveCalls))->method('save'); - $this->_collection->addItem($schedule); $this->loggerMock->expects($this->once())->method('critical')->with($exception); + + $this->_collection->addItem($schedule); + $this->_config->expects($this->exactly(2))->method('getJobs')->will($this->returnValue($jobConfig)); + + $lastRun = $this->time + 10000000; $this->_cache->expects($this->any())->method('load')->will($this->returnValue($lastRun)); + $this->_scopeConfig->expects($this->any()) + ->method('getValue') + ->will($this->returnValue($this->time + 86400)); $scheduleMock = $this->getMockBuilder( - Schedule::class + \Magento\Cron\Model\Schedule::class )->disableOriginalConstructor()->getMock(); $scheduleMock->expects($this->any())->method('getCollection')->will($this->returnValue($this->_collection)); $scheduleMock->expects($this->any())->method('getResource')->will($this->returnValue($this->scheduleResource)); @@ -445,10 +491,12 @@ public function dispatchExceptionInCallbackDataProvider() */ public function testDispatchRunJob() { - $lastRun = time() + 10000000; // skip cleanup and generation - $jobConfig = ['default' => ['test_job1' => ['instance' => 'CronJob', 'method' => 'execute']]]; - $this->_request->expects($this->any())->method('getParam')->will($this->returnValue('default')); + $jobConfig = [ + 'test_group' => ['test_job1' => ['instance' => 'CronJob', 'method' => 'execute']], + ]; + $this->_request->expects($this->any())->method('getParam')->will($this->returnValue('test_group')); + $dateScheduledAt = date('Y-m-d H:i:s', $this->time - 86400); $scheduleMethods = [ 'getJobCode', 'tryLockJob', @@ -460,14 +508,14 @@ public function testDispatchRunJob() 'setFinishedAt', '__wakeup', ]; - /** @var Schedule | Mock $schedule */ + /** @var \Magento\Cron\Model\Schedule|\PHPUnit_Framework_MockObject_MockObject $schedule */ $schedule = $this->getMockBuilder( - Schedule::class + \Magento\Cron\Model\Schedule::class )->setMethods( $scheduleMethods )->disableOriginalConstructor()->getMock(); $schedule->expects($this->any())->method('getJobCode')->will($this->returnValue('test_job1')); - $schedule->expects($this->once())->method('getScheduledAt')->will($this->returnValue(date('Y-m-d H:i:00'))); + $schedule->expects($this->once())->method('getScheduledAt')->will($this->returnValue($dateScheduledAt)); $schedule->expects($this->once())->method('tryLockJob')->will($this->returnValue(true)); // cron start to execute some job @@ -475,19 +523,30 @@ public function testDispatchRunJob() $schedule->expects($this->at(5))->method('save'); // cron end execute some job - $schedule->expects($this->at(6)) - ->method('setStatus') - ->with($this->equalTo(Schedule::STATUS_SUCCESS)) - ->will($this->returnSelf()); + $schedule->expects( + $this->at(6) + )->method( + 'setStatus' + )->with( + $this->equalTo(\Magento\Cron\Model\Schedule::STATUS_SUCCESS) + )->will( + $this->returnSelf() + ); $schedule->expects($this->at(8))->method('save'); $this->_collection->addItem($schedule); + $this->_config->expects($this->exactly(2))->method('getJobs')->will($this->returnValue($jobConfig)); + + $lastRun = $this->time + 10000000; $this->_cache->expects($this->any())->method('load')->will($this->returnValue($lastRun)); + $this->_scopeConfig->expects($this->any()) + ->method('getValue') + ->will($this->returnValue($this->time + 86400)); $scheduleMock = $this->getMockBuilder( - Schedule::class + \Magento\Cron\Model\Schedule::class )->disableOriginalConstructor()->getMock(); $scheduleMock->expects($this->any())->method('getCollection')->will($this->returnValue($this->_collection)); $scheduleMock->expects($this->any())->method('getResource')->will($this->returnValue($this->scheduleResource)); @@ -496,74 +555,90 @@ public function testDispatchRunJob() $testCronJob = $this->getMockBuilder('CronJob')->setMethods(['execute'])->getMock(); $testCronJob->expects($this->atLeastOnce())->method('execute')->with($schedule); - $this->_objectManager->expects($this->once()) - ->method('create') - ->with($this->equalTo('CronJob')) - ->will($this->returnValue($testCronJob)); + $this->_objectManager->expects( + $this->once() + )->method( + 'create' + )->with( + $this->equalTo('CronJob') + )->will( + $this->returnValue($testCronJob) + ); $this->_observer->execute($this->observer); } /** - * Testing generate(), iterate over saved cron jobs - * Generate should not generate any jobs, because they are already in the database + * Testing _generate(), iterate over saved cron jobs */ public function testDispatchNotGenerate() { - $jobConfig = ['default' => [ - 'test_job1' => ['instance' => 'CronJob', 'method' => 'execute', 'schedule' => '* * * * *']] + $jobConfig = [ + 'test_group' => ['test_job1' => ['instance' => 'CronJob', 'method' => 'execute']], ]; - $this->_config->expects($this->any())->method('getJobs')->will($this->returnValue($jobConfig)); - $this->_request->expects($this->any())->method('getParam')->will($this->returnValue('default')); - $this->_cache->expects($this->any())->method('load')->willReturnMap([ - [ProcessCronQueueObserver::CACHE_KEY_LAST_HISTORY_CLEANUP_AT . 'default', time() + 1000], // skip cleanup - [ProcessCronQueueObserver::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT . 'default', time() - 1000], // do generation - ]); + $this->_config->expects($this->at(0))->method('getJobs')->will($this->returnValue($jobConfig)); + $this->_config->expects( + $this->at(1) + )->method( + 'getJobs' + )->will( + $this->returnValue(['test_group' => []]) + ); + $this->_request->expects($this->any())->method('getParam')->will($this->returnValue('test_group')); + $this->_cache->expects( + $this->at(0) + )->method( + 'load' + )->with( + $this->equalTo(ProcessCronQueueObserver::CACHE_KEY_LAST_HISTORY_CLEANUP_AT . 'test_group') + )->will( + $this->returnValue($this->time + 10000000) + ); + $this->_cache->expects( + $this->at(1) + )->method( + 'load' + )->with( + $this->equalTo(ProcessCronQueueObserver::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT . 'test_group') + )->will( + $this->returnValue($this->time - 10000000) + ); + + $this->_scopeConfig->expects($this->any())->method('getValue')->will($this->returnValue(0)); - /** @var Schedule | Mock $schedule */ - $schedule = $this->getMockBuilder(Schedule::class) - ->setMethods(['getJobCode', 'getScheduledAt', '__wakeup', 'save']) - ->disableOriginalConstructor()->getMock(); - $schedule->expects($this->any())->method('getJobCode')->will($this->returnValue('test_job1')); - for ($i=0; $i < 20 * 2; $i+=2) { - $minutes = 0.5 * $i; - $schedule->expects($this->at($i))->method('getScheduledAt') - ->will($this->returnValue(date('Y-m-d H:i:00', strtotime("+$minutes minutes")))); - $schedule->expects($this->at($i + 1))->method('getScheduledAt') - ->will($this->returnValue(date('Y-m-d H:i:00', strtotime("+$minutes minutes")))); - $schedule->expects($this->at($minutes))->method('getId')->willReturn($minutes + 1); - $this->_collection->addItem($schedule); - } + $schedule = $this->getMockBuilder( + \Magento\Cron\Model\Schedule::class + )->setMethods( + ['getJobCode', 'getScheduledAt', '__wakeup'] + )->disableOriginalConstructor()->getMock(); + $schedule->expects($this->any())->method('getJobCode')->will($this->returnValue('job_code1')); + $schedule->expects($this->once())->method('getScheduledAt')->will($this->returnValue('* * * * *')); + + $this->_collection->addItem(new \Magento\Framework\DataObject()); + $this->_collection->addItem($schedule); $this->_cache->expects($this->any())->method('save'); - $scheduleMock = $this->getMockBuilder(Schedule::class) - ->setMethods([ - 'getCollection', - 'getResource', - 'trySchedule', - 'save', - ]) - ->disableOriginalConstructor() - ->getMock(); + $scheduleMock = $this->getMockBuilder( + \Magento\Cron\Model\Schedule::class + )->disableOriginalConstructor()->getMock(); $scheduleMock->expects($this->any())->method('getCollection')->will($this->returnValue($this->_collection)); - $scheduleMock->expects($this->any())->method('getResource')->will($this->returnValue($this->scheduleResource)); - $scheduleMock->expects($this->exactly(20))->method('trySchedule')->willReturn(true); - $scheduleMock->expects($this->never())->method('save'); $this->_scheduleFactory->expects($this->any())->method('create')->will($this->returnValue($scheduleMock)); + $this->_scheduleFactory->expects($this->any())->method('create')->will($this->returnValue($schedule)); + $this->_observer->execute($this->observer); } /** - * Testing generate(), iterate over saved cron jobs and generate jobs + * Testing _generate(), iterate over saved cron jobs and generate jobs */ public function testDispatchGenerate() { $jobConfig = [ 'default' => [ - 'job1' => [ + 'test_job1' => [ 'instance' => 'CronJob', 'method' => 'execute', ], @@ -580,153 +655,188 @@ public function testDispatchGenerate() $this->_config->expects($this->at(0))->method('getJobs')->willReturn($jobConfig); $this->_config->expects($this->at(1))->method('getJobs')->willReturn($jobs); $this->_request->expects($this->any())->method('getParam')->willReturn('default'); - $this->_cache->expects($this->any())->method('load')->willReturnMap([ - [ProcessCronQueueObserver::CACHE_KEY_LAST_HISTORY_CLEANUP_AT . 'default', time() + 1000], // skip cleanup - [ProcessCronQueueObserver::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT . 'default', time() - 1000], // do generation - ]); + $this->_cache->expects( + $this->at(0) + )->method( + 'load' + )->with( + $this->equalTo(ProcessCronQueueObserver::CACHE_KEY_LAST_HISTORY_CLEANUP_AT . 'default') + )->willReturn($this->time + 10000000); + $this->_cache->expects( + $this->at(1) + )->method( + 'load' + )->with( + $this->equalTo(ProcessCronQueueObserver::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT . 'default') + )->willReturn($this->time - 10000000); + + $this->_scopeConfig->expects($this->any())->method('getValue')->willReturnMap( + [ + [ + 'system/cron/default/schedule_generate_every', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + null, + 0 + ], + [ + 'system/cron/default/schedule_ahead_for', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + null, + 2 + ] + ] + ); - /** @var Schedule | Mock $schedule */ $schedule = $this->getMockBuilder( - Schedule::class + \Magento\Cron\Model\Schedule::class )->setMethods( ['getJobCode', 'save', 'getScheduledAt', 'unsScheduleId', 'trySchedule', 'getCollection', 'getResource'] )->disableOriginalConstructor()->getMock(); - $schedule->expects($this->any())->method('getJobCode')->willReturn('job1'); - $schedule->expects($this->exactly(2))->method('getScheduledAt')->willReturn('* * * * *'); + $schedule->expects($this->any())->method('getJobCode')->willReturn('job_code1'); + $schedule->expects($this->once())->method('getScheduledAt')->willReturn('* * * * *'); $schedule->expects($this->any())->method('unsScheduleId')->willReturnSelf(); $schedule->expects($this->any())->method('trySchedule')->willReturnSelf(); $schedule->expects($this->any())->method('getCollection')->willReturn($this->_collection); $schedule->expects($this->atLeastOnce())->method('save')->willReturnSelf(); $schedule->expects($this->any())->method('getResource')->will($this->returnValue($this->scheduleResource)); + $this->_collection->addItem(new \Magento\Framework\DataObject()); $this->_collection->addItem($schedule); + $this->_cache->expects($this->any())->method('save'); + $this->_scheduleFactory->expects($this->any())->method('create')->willReturn($schedule); + $this->_observer->execute($this->observer); } /** - * Test case to test the cleanup process + * Test case without saved cron jobs in data base */ public function testDispatchCleanup() { - $jobConfig = ['default' => ['test_job1' => ['instance' => 'CronJob', 'method' => 'execute']]]; + $jobConfig = [ + 'test_group' => ['test_job1' => ['instance' => 'CronJob', 'method' => 'execute']], + ]; + + $dateExecutedAt = date('Y-m-d H:i:s', $this->time - 86400); + $schedule = $this->getMockBuilder( + \Magento\Cron\Model\Schedule::class + )->disableOriginalConstructor()->setMethods( + ['getExecutedAt', 'getStatus', 'delete', '__wakeup'] + )->getMock(); + $schedule->expects($this->any())->method('getExecutedAt')->will($this->returnValue($dateExecutedAt)); + $schedule->expects($this->any())->method('getStatus')->will($this->returnValue('success')); + $this->_request->expects($this->any())->method('getParam')->will($this->returnValue('test_group')); + $this->_collection->addItem($schedule); + $this->_config->expects($this->exactly(2))->method('getJobs')->will($this->returnValue($jobConfig)); - $this->_request->expects($this->any())->method('getParam')->will($this->returnValue('default')); - $this->_cache->expects($this->any())->method('load')->willReturnMap([ - // do cleanup - [ProcessCronQueueObserver::CACHE_KEY_LAST_HISTORY_CLEANUP_AT . 'default', time() - 1000], - // skip generation - [ProcessCronQueueObserver::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT . 'default', time() + 1000], - ]); + $this->_cache->expects($this->at(0))->method('load')->will($this->returnValue($this->time + 10000000)); + $this->_cache->expects($this->at(1))->method('load')->will($this->returnValue($this->time - 10000000)); - $jobs = [ - ['status' => 'success', 'age' => '-61 minutes', 'delete' => true], - ['status' => 'success', 'age' => '-59 minutes', 'delete' => false], - ['status' => 'missed', 'age' => '-601 minutes', 'delete' => true], - ['status' => 'missed', 'age' => '-509 minutes', 'delete' => false], - ['status' => 'error', 'age' => '-601 minutes', 'delete' => true], - ['status' => 'error', 'age' => '-509 minutes', 'delete' => false], - ]; + $this->_scopeConfig->expects($this->any())->method('getValue')->will($this->returnValue(0)); - foreach ($jobs as $job) { - /** @var Schedule | Mock $schedule */ - $schedule = $this->getMockBuilder(Schedule::class) - ->disableOriginalConstructor() - ->setMethods(['getExecutedAt', 'getStatus', 'delete', '__wakeup'])->getMock(); - $schedule->expects($this->any())->method('getExecutedAt')->will($this->returnValue($job['age'])); - $schedule->expects($this->any())->method('getStatus')->will($this->returnValue($job['status'])); - if ($job['delete']) { - $schedule->expects($this->once())->method('delete'); - } else { - $schedule->expects($this->never())->method('delete'); - } - - $this->_collection->addItem($schedule); - } - - $scheduleMock = $this->getMockBuilder(Schedule::class)->disableOriginalConstructor()->getMock(); + $scheduleMock = $this->getMockBuilder( + \Magento\Cron\Model\Schedule::class + )->disableOriginalConstructor()->getMock(); $scheduleMock->expects($this->any())->method('getCollection')->will($this->returnValue($this->_collection)); + $this->_scheduleFactory->expects($this->at(0))->method('create')->will($this->returnValue($scheduleMock)); + + $collection = $this->getMockBuilder( + \Magento\Cron\Model\ResourceModel\Schedule\Collection::class + )->setMethods( + ['addFieldToFilter', 'load', '__wakeup'] + )->disableOriginalConstructor()->getMock(); + $collection->expects($this->any())->method('addFieldToFilter')->will($this->returnSelf()); + $collection->expects($this->any())->method('load')->will($this->returnSelf()); + $collection->addItem($schedule); + + $scheduleMock = $this->getMockBuilder( + \Magento\Cron\Model\Schedule::class + )->setMethods(['getCollection', 'getResource'])->disableOriginalConstructor()->getMock(); + $scheduleMock->expects($this->any())->method('getCollection')->will($this->returnValue($collection)); $scheduleMock->expects($this->any())->method('getResource')->will($this->returnValue($this->scheduleResource)); - $this->_scheduleFactory->expects($this->any())->method('create')->will($this->returnValue($scheduleMock)); + $this->_scheduleFactory->expects($this->at(1))->method('create')->will($this->returnValue($scheduleMock)); $this->_observer->execute($this->observer); } - /** - * Testing if mismatching schedules will be deleted and - * if disabled jobs will be deleted - */ - public function testDispatchRemoveConfigMismatch() + public function testMissedJobsCleanedInTime() { - $jobConfig = ['default' => [ - 'test_job1' => ['instance' => 'CronJob', 'method' => 'execute', 'schedule' => '*/10 * * * *'], - 'test_job2' => ['instance' => 'CronJob', 'method' => 'execute', 'schedule' => null] - ]]; + /* 1. Initialize dependencies of _cleanup() method which is called first */ + $scheduleMock = $this->getMockBuilder( + \Magento\Cron\Model\Schedule::class + )->disableOriginalConstructor()->getMock(); + $scheduleMock->expects($this->any())->method('getCollection')->will($this->returnValue($this->_collection)); + //get configuration value CACHE_KEY_LAST_HISTORY_CLEANUP_AT in the "_cleanup()" + $this->_cache->expects($this->at(0))->method('load')->will($this->returnValue($this->time - 10000000)); + $this->_scheduleFactory->expects($this->at(0))->method('create')->will($this->returnValue($scheduleMock)); + + /* 2. Initialize dependencies of _generate() method which is called second */ + $jobConfig = [ + 'test_group' => ['test_job1' => ['instance' => 'CronJob', 'method' => 'execute']], + ]; + //get configuration value CACHE_KEY_LAST_HISTORY_CLEANUP_AT in the "_generate()" + $this->_cache->expects($this->at(2))->method('load')->will($this->returnValue($this->time + 10000000)); + $this->_scheduleFactory->expects($this->at(2))->method('create')->will($this->returnValue($scheduleMock)); + + // This item was scheduled 2 days and 2 hours ago + $dateScheduledAt = date('Y-m-d H:i:s', $this->time - 180000); + /** @var \Magento\Cron\Model\Schedule|\PHPUnit_Framework_MockObject_MockObject $schedule1 */ + $schedule1 = $this->getMockBuilder( + \Magento\Cron\Model\Schedule::class + )->disableOriginalConstructor()->setMethods( + ['getExecutedAt', 'getScheduledAt', 'getStatus', 'delete', '__wakeup'] + )->getMock(); + $schedule1->expects($this->any())->method('getExecutedAt')->will($this->returnValue(null)); + $schedule1->expects($this->any())->method('getScheduledAt')->will($this->returnValue($dateScheduledAt)); + $schedule1->expects($this->any())->method('getStatus')->will($this->returnValue(Schedule::STATUS_MISSED)); + //we expect this job be deleted from the list + $schedule1->expects($this->once())->method('delete')->will($this->returnValue(true)); + $this->_collection->addItem($schedule1); + + // This item was scheduled 1 day ago + $dateScheduledAt = date('Y-m-d H:i:s', $this->time - 86400); + $schedule2 = $this->getMockBuilder( + \Magento\Cron\Model\Schedule::class + )->disableOriginalConstructor()->setMethods( + ['getExecutedAt', 'getScheduledAt', 'getStatus', 'delete', '__wakeup'] + )->getMock(); + $schedule2->expects($this->any())->method('getExecutedAt')->will($this->returnValue(null)); + $schedule2->expects($this->any())->method('getScheduledAt')->will($this->returnValue($dateScheduledAt)); + $schedule2->expects($this->any())->method('getStatus')->will($this->returnValue(Schedule::STATUS_MISSED)); + //we don't expect this job be deleted from the list + $schedule2->expects($this->never())->method('delete'); + $this->_collection->addItem($schedule2); + $this->_config->expects($this->exactly(2))->method('getJobs')->will($this->returnValue($jobConfig)); - $this->_request->expects($this->any())->method('getParam')->will($this->returnValue('default')); - - $this->_cache->expects($this->any())->method('load')->willReturnMap([ - // skip cleanup - [ProcessCronQueueObserver::CACHE_KEY_LAST_HISTORY_CLEANUP_AT . 'default', time() + 1000], - // do generation - [ProcessCronQueueObserver::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT . 'default', time() - 1000], - ]); - - $jobs = []; - for ($i = 0; $i<20; $i++) { - $time = date('Y-m-d H:i:00', strtotime("+$i minutes")); - $jobs[] = [ - 'age' => $time, - 'delete' => !preg_match('#0$#', date('i', strtotime($time))) - ]; - } - - foreach ($jobs as $job) { - /** @var Schedule | Mock $schedule */ - $schedule = $this->getMockBuilder(Schedule::class) - ->disableOriginalConstructor() - ->setMethods(['getJobCode', 'getScheduledAt', 'getStatus', 'delete', 'save', '__wakeup'])->getMock(); - $schedule->expects($this->any())->method('getStatus')->will($this->returnValue('pending')); - $schedule->expects($this->any())->method('getJobCode')->will($this->returnValue('test_job1')); - $schedule->expects($this->any())->method('getScheduledAt')->will($this->returnValue($job['age'])); - $this->_collection->addItem($schedule); - } - - /** @var Schedule | Mock $schedule */ - $schedule = $this->getMockBuilder(Schedule::class) - ->disableOriginalConstructor() - ->setMethods(['getJobCode', 'getScheduledAt', 'getStatus', 'delete', 'save', '__wakeup'])->getMock(); - $schedule->expects($this->any())->method('getStatus')->will($this->returnValue('pending')); - $schedule->expects($this->any())->method('getJobCode')->will($this->returnValue('test_job2')); - $schedule->expects($this->any())->method('getScheduledAt')->will($this->returnValue(date('Y-m-d H:i:00'))); - $this->_collection->addItem($schedule); - $scheduleMock = $this->getMockBuilder(Schedule::class)->disableOriginalConstructor() - ->setMethods(['save', 'getCollection', 'getResource'])->getMock(); + $this->_scopeConfig->expects($this->at(0))->method('getValue') + ->with($this->equalTo('system/cron/test_group/history_cleanup_every')) + ->will($this->returnValue(10)); + $this->_scopeConfig->expects($this->at(1))->method('getValue') + ->with($this->equalTo('system/cron/test_group/schedule_lifetime')) + ->will($this->returnValue(2*24*60)); + $this->_scopeConfig->expects($this->at(2))->method('getValue') + ->with($this->equalTo('system/cron/test_group/history_success_lifetime')) + ->will($this->returnValue(0)); + $this->_scopeConfig->expects($this->at(3))->method('getValue') + ->with($this->equalTo('system/cron/test_group/history_failure_lifetime')) + ->will($this->returnValue(0)); + $this->_scopeConfig->expects($this->at(4))->method('getValue') + ->with($this->equalTo('system/cron/test_group/schedule_generate_every')) + ->will($this->returnValue(0)); + $this->_scopeConfig->expects($this->at(5))->method('getValue') + ->with($this->equalTo('system/cron/test_group/use_separate_process')) + ->will($this->returnValue(0)); + + $this->_collection->expects($this->any())->method('addFieldToFilter')->will($this->returnSelf()); + $this->_collection->expects($this->any())->method('load')->will($this->returnSelf()); + $scheduleMock->expects($this->any())->method('getCollection')->will($this->returnValue($this->_collection)); $scheduleMock->expects($this->any())->method('getResource')->will($this->returnValue($this->scheduleResource)); - $this->_scheduleFactory->expects($this->any())->method('create')->will($this->returnValue($scheduleMock)); - - $query = [ - 'status=?' => Schedule::STATUS_PENDING, - 'job_code=?' => 'test_job2', - ]; - $this->connection->expects($this->at(0))->method('delete')->with(null, $query); - - $scheduledAtList = []; - foreach ($jobs as $job) { - if ($job['delete'] === true) { - $scheduledAtList[] = $job['age']; - } - } - $query = [ - 'status=?' => Schedule::STATUS_PENDING, - 'job_code=?' => 'test_job1', - 'scheduled_at in (?)' => $scheduledAtList, - ]; - $this->connection->expects($this->at(1))->method('delete')->with(null, $query); + $this->_scheduleFactory->expects($this->at(1))->method('create')->will($this->returnValue($scheduleMock)); $this->_observer->execute($this->observer); } diff --git a/app/code/Magento/CurrencySymbol/Block/Adminhtml/System/Currency.php b/app/code/Magento/CurrencySymbol/Block/Adminhtml/System/Currency.php index 683c317d2ec74..c740b17ed008c 100644 --- a/app/code/Magento/CurrencySymbol/Block/Adminhtml/System/Currency.php +++ b/app/code/Magento/CurrencySymbol/Block/Adminhtml/System/Currency.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class Currency extends \Magento\Backend\Block\Template { diff --git a/app/code/Magento/CurrencySymbol/Block/Adminhtml/System/Currencysymbol.php b/app/code/Magento/CurrencySymbol/Block/Adminhtml/System/Currencysymbol.php index f44502f164356..f48394ac19b3c 100644 --- a/app/code/Magento/CurrencySymbol/Block/Adminhtml/System/Currencysymbol.php +++ b/app/code/Magento/CurrencySymbol/Block/Adminhtml/System/Currencysymbol.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class Currencysymbol extends \Magento\Backend\Block\Widget\Form { diff --git a/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency.php b/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency.php index d4b8859b9e235..41f7db8ad155a 100644 --- a/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency.php +++ b/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ abstract class Currency extends \Magento\Backend\App\Action { diff --git a/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currencysymbol.php b/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currencysymbol.php index c97b97ef841c3..16990e6756ac4 100644 --- a/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currencysymbol.php +++ b/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currencysymbol.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ abstract class Currencysymbol extends \Magento\Backend\App\Action { diff --git a/app/code/Magento/CurrencySymbol/Model/System/Currencysymbol.php b/app/code/Magento/CurrencySymbol/Model/System/Currencysymbol.php index c5c710c3a3a7e..fcde688a1e145 100644 --- a/app/code/Magento/CurrencySymbol/Model/System/Currencysymbol.php +++ b/app/code/Magento/CurrencySymbol/Model/System/Currencysymbol.php @@ -15,6 +15,7 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * * @api + * @since 100.0.2 */ class Currencysymbol { diff --git a/app/code/Magento/CurrencySymbol/Test/Unit/Block/Adminhtml/System/Currency/Rate/MatrixTest.php b/app/code/Magento/CurrencySymbol/Test/Unit/Block/Adminhtml/System/Currency/Rate/MatrixTest.php index d82038ce5e887..eada4ff93b108 100644 --- a/app/code/Magento/CurrencySymbol/Test/Unit/Block/Adminhtml/System/Currency/Rate/MatrixTest.php +++ b/app/code/Magento/CurrencySymbol/Test/Unit/Block/Adminhtml/System/Currency/Rate/MatrixTest.php @@ -5,7 +5,7 @@ */ namespace Magento\CurrencySymbol\Test\Unit\Block\Adminhtml\System\Currency\Rate; -class MatrixTest extends \PHPUnit_Framework_TestCase +class MatrixTest extends \PHPUnit\Framework\TestCase { /** * Object manager helper @@ -33,28 +33,16 @@ public function testPrepareLayout() $newRates = ['USD' => ['EUR' => 0.7767, 'UAH' => 20, 'GBP' => 12, 'USD' => 1]]; $expectedNewRates = ['USD' => ['EUR' => '0.7767', 'UAH' => '20.0000', 'GBP' => '12.0000', 'USD' => '1.0000']]; - $backendSessionMock = $this->getMock( + $backendSessionMock = $this->createPartialMock( \Magento\Backend\Model\Session::class, - ['getRates', 'unsetData'], - [], - '', - false + ['getRates', 'unsetData'] ); $backendSessionMock->expects($this->once())->method('getRates')->willReturn($newRates); - $currencyFactoryMock = $this->getMock( - \Magento\Directory\Model\CurrencyFactory::class, - ['create'], - [], - '', - false - ); - $currencyMock = $this->getMock( + $currencyFactoryMock = $this->createPartialMock(\Magento\Directory\Model\CurrencyFactory::class, ['create']); + $currencyMock = $this->createPartialMock( \Magento\Directory\Model\Currency::class, - ['getConfigAllowCurrencies', 'getConfigBaseCurrencies', 'getCurrencyRates'], - [], - '', - false + ['getConfigAllowCurrencies', 'getConfigBaseCurrencies', 'getCurrencyRates'] ); $currencyFactoryMock->expects($this->once())->method('create')->willReturn($currencyMock); $currencyMock->expects($this->once())->method('getConfigAllowCurrencies')->willReturn($allowCurrencies); diff --git a/app/code/Magento/CurrencySymbol/Test/Unit/Block/Adminhtml/System/Currency/Rate/ServicesTest.php b/app/code/Magento/CurrencySymbol/Test/Unit/Block/Adminhtml/System/Currency/Rate/ServicesTest.php index e56c8f6806c6f..5acc61ab0ab56 100644 --- a/app/code/Magento/CurrencySymbol/Test/Unit/Block/Adminhtml/System/Currency/Rate/ServicesTest.php +++ b/app/code/Magento/CurrencySymbol/Test/Unit/Block/Adminhtml/System/Currency/Rate/ServicesTest.php @@ -5,7 +5,7 @@ */ namespace Magento\CurrencySymbol\Test\Unit\Block\Adminhtml\System\Currency\Rate; -class ServicesTest extends \PHPUnit_Framework_TestCase +class ServicesTest extends \PHPUnit\Framework\TestCase { /** * Object manager helper @@ -29,26 +29,14 @@ public function testPrepareLayout() $options = [['value' => 'value', 'label' => 'label']]; $service = 'service'; - $sourceServiceFactoryMock = $this->getMock( + $sourceServiceFactoryMock = $this->createPartialMock( \Magento\Directory\Model\Currency\Import\Source\ServiceFactory::class, - ['create'], - [], - '', - false - ); - $sourceServiceMock = $this->getMock( - \Magento\Directory\Model\Currency\Import\Source\Service::class, - [], - [], - '', - false + ['create'] ); - $backendSessionMock = $this->getMock( + $sourceServiceMock = $this->createMock(\Magento\Directory\Model\Currency\Import\Source\Service::class); + $backendSessionMock = $this->createPartialMock( \Magento\Backend\Model\Session::class, - ['getCurrencyRateService'], - [], - '', - false + ['getCurrencyRateService'] ); /** @var $layoutMock \Magento\Framework\View\LayoutInterface|\PHPUnit_Framework_MockObject_MockObject */ @@ -62,12 +50,9 @@ public function testPrepareLayout() ['createBlock'] ); - $blockMock = $this->getMock( + $blockMock = $this->createPartialMock( \Magento\Framework\View\Element\Html\Select::class, - ['setOptions', 'setId', 'setName', 'setValue', 'setTitle'], - [], - '', - false + ['setOptions', 'setId', 'setName', 'setValue', 'setTitle'] ); $layoutMock->expects($this->once())->method('createBlock')->willReturn($blockMock); diff --git a/app/code/Magento/CurrencySymbol/Test/Unit/Block/Adminhtml/System/CurrencyTest.php b/app/code/Magento/CurrencySymbol/Test/Unit/Block/Adminhtml/System/CurrencyTest.php index 8c17ff85dc759..a61a6879eb523 100644 --- a/app/code/Magento/CurrencySymbol/Test/Unit/Block/Adminhtml/System/CurrencyTest.php +++ b/app/code/Magento/CurrencySymbol/Test/Unit/Block/Adminhtml/System/CurrencyTest.php @@ -5,7 +5,7 @@ */ namespace Magento\CurrencySymbol\Test\Unit\Block\Adminhtml\System; -class CurrencyTest extends \PHPUnit_Framework_TestCase +class CurrencyTest extends \PHPUnit\Framework\TestCase { /** * Object manager helper @@ -26,21 +26,12 @@ protected function tearDown() public function testPrepareLayout() { - $childBlockMock = $this->getMock( + $childBlockMock = $this->createPartialMock( \Magento\Framework\View\Element\BlockInterface::class, - ['addChild', 'toHtml'], - [], - '', - false + ['addChild', 'toHtml'] ); - $blockMock = $this->getMock( - \Magento\Framework\View\Element\BlockInterface::class, - [], - [], - '', - false - ); + $blockMock = $this->createMock(\Magento\Framework\View\Element\BlockInterface::class); /** @var $layoutMock \Magento\Framework\View\LayoutInterface|\PHPUnit_Framework_MockObject_MockObject */ $layoutMock = $this->getMockForAbstractClass( diff --git a/app/code/Magento/CurrencySymbol/Test/Unit/Block/Adminhtml/System/CurrencysymbolTest.php b/app/code/Magento/CurrencySymbol/Test/Unit/Block/Adminhtml/System/CurrencysymbolTest.php index 40fab461a5f44..d169873e4dffc 100644 --- a/app/code/Magento/CurrencySymbol/Test/Unit/Block/Adminhtml/System/CurrencysymbolTest.php +++ b/app/code/Magento/CurrencySymbol/Test/Unit/Block/Adminhtml/System/CurrencysymbolTest.php @@ -5,7 +5,7 @@ */ namespace Magento\CurrencySymbol\Test\Unit\Block\Adminhtml\System; -class CurrencysymbolTest extends \PHPUnit_Framework_TestCase +class CurrencysymbolTest extends \PHPUnit\Framework\TestCase { /** * Object manager helper @@ -26,20 +26,14 @@ protected function tearDown() public function testPrepareLayout() { - $symbolSystemFactoryMock = $this->getMock( + $symbolSystemFactoryMock = $this->createPartialMock( \Magento\CurrencySymbol\Model\System\CurrencysymbolFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $blockMock = $this->getMock( + $blockMock = $this->createPartialMock( \Magento\Framework\View\Element\BlockInterface::class, - ['addChild', 'toHtml'], - [], - '', - false + ['addChild', 'toHtml'] ); /** @var $layoutMock \Magento\Framework\View\LayoutInterface|\PHPUnit_Framework_MockObject_MockObject */ diff --git a/app/code/Magento/CurrencySymbol/Test/Unit/Controller/Adminhtml/System/Currencysymbol/IndexTest.php b/app/code/Magento/CurrencySymbol/Test/Unit/Controller/Adminhtml/System/Currencysymbol/IndexTest.php index 081a75bcbdb50..fd1c90f5dfecc 100644 --- a/app/code/Magento/CurrencySymbol/Test/Unit/Controller/Adminhtml/System/Currencysymbol/IndexTest.php +++ b/app/code/Magento/CurrencySymbol/Test/Unit/Controller/Adminhtml/System/Currencysymbol/IndexTest.php @@ -10,7 +10,7 @@ /** * Class IndexTest */ -class IndexTest extends \PHPUnit_Framework_TestCase +class IndexTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CurrencySymbol\Controller\Adminhtml\System\Currencysymbol\Index @@ -61,14 +61,14 @@ protected function setUp() { $objectManager = new ObjectManager($this); - $this->menuItemMock = $this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false); - $this->menuMock = $this->getMock(\Magento\Backend\Model\Menu::class, [], [], '', false); + $this->menuItemMock = $this->createMock(\Magento\Backend\Model\Menu\Item::class); + $this->menuMock = $this->createMock(\Magento\Backend\Model\Menu::class); - $this->titleMock = $this->getMock(\Magento\Framework\View\Page\Title::class, [], [], '', false); + $this->titleMock = $this->createMock(\Magento\Framework\View\Page\Title::class); - $this->pageConfigMock = $this->getMock(\Magento\Framework\View\Page\Config::class, [], [], '', false); + $this->pageConfigMock = $this->createMock(\Magento\Framework\View\Page\Config::class); - $this->pageMock = $this->getMock(\Magento\Framework\View\Result\Page::class, [], [], '', false); + $this->pageMock = $this->createMock(\Magento\Framework\View\Result\Page::class); $this->blockMock = $this->getMockForAbstractClass( \Magento\Framework\View\Element\BlockInterface::class, @@ -80,9 +80,9 @@ protected function setUp() ['addLink', 'setActive', 'getMenuModel'] ); - $this->layoutMock = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); + $this->layoutMock = $this->createMock(\Magento\Framework\View\Layout::class); - $this->viewMock = $this->getMock(\Magento\Framework\App\ViewInterface::class, [], [], '', false); + $this->viewMock = $this->createMock(\Magento\Framework\App\ViewInterface::class); $this->action = $objectManager->getObject( \Magento\CurrencySymbol\Controller\Adminhtml\System\Currencysymbol\Index::class, diff --git a/app/code/Magento/CurrencySymbol/Test/Unit/Controller/Adminhtml/System/Currencysymbol/SaveTest.php b/app/code/Magento/CurrencySymbol/Test/Unit/Controller/Adminhtml/System/Currencysymbol/SaveTest.php index 5a243eaa502ff..0863104a2bf8d 100644 --- a/app/code/Magento/CurrencySymbol/Test/Unit/Controller/Adminhtml/System/Currencysymbol/SaveTest.php +++ b/app/code/Magento/CurrencySymbol/Test/Unit/Controller/Adminhtml/System/Currencysymbol/SaveTest.php @@ -10,7 +10,7 @@ /** * Class SaveTest */ -class SaveTest extends \PHPUnit_Framework_TestCase +class SaveTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CurrencySymbol\Controller\Adminhtml\System\Currencysymbol\Save @@ -61,51 +61,27 @@ protected function setUp() { $objectManager = new ObjectManager($this); - $this->requestMock = $this->getMock(\Magento\Framework\App\RequestInterface::class, [], [], '', false); + $this->requestMock = $this->createMock(\Magento\Framework\App\RequestInterface::class); - $this->helperMock = $this->getMock(\Magento\Backend\Helper\Data::class, [], [], '', false); + $this->helperMock = $this->createMock(\Magento\Backend\Helper\Data::class); - $this->redirectMock = $this->getMock( - \Magento\Framework\App\Response\RedirectInterface::class, - [], - [], - '', - false - ); + $this->redirectMock = $this->createMock(\Magento\Framework\App\Response\RedirectInterface::class); - $this->responseMock = $this->getMock( + $this->responseMock = $this->createPartialMock( \Magento\Framework\App\ResponseInterface::class, - ['setRedirect', 'sendResponse'], - [], - '', - false + ['setRedirect', 'sendResponse'] ); - $this->currencySymbolMock = $this->getMock( - \Magento\CurrencySymbol\Model\System\Currencysymbol::class, - [], - [], - '', - false - ); + $this->currencySymbolMock = $this->createMock(\Magento\CurrencySymbol\Model\System\Currencysymbol::class); - $this->filterManagerMock = $this->getMock( + $this->filterManagerMock = $this->createPartialMock( \Magento\Framework\Filter\FilterManager::class, - ['stripTags'], - [], - '', - false + ['stripTags'] ); - $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class, [], [], '', false); + $this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); - $this->messageManagerMock = $this->getMock( - \Magento\Framework\Message\ManagerInterface::class, - [], - [], - '', - false - ); + $this->messageManagerMock = $this->createMock(\Magento\Framework\Message\ManagerInterface::class); $this->action = $objectManager->getObject( \Magento\CurrencySymbol\Controller\Adminhtml\System\Currencysymbol\Save::class, [ diff --git a/app/code/Magento/CurrencySymbol/Test/Unit/Model/System/CurrencysymbolTest.php b/app/code/Magento/CurrencySymbol/Test/Unit/Model/System/CurrencysymbolTest.php index 05034aa0e382a..453a06651f354 100644 --- a/app/code/Magento/CurrencySymbol/Test/Unit/Model/System/CurrencysymbolTest.php +++ b/app/code/Magento/CurrencySymbol/Test/Unit/Model/System/CurrencysymbolTest.php @@ -14,7 +14,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class CurrencysymbolTest extends \PHPUnit_Framework_TestCase +class CurrencysymbolTest extends \PHPUnit\Framework\TestCase { /** * Object manager helper @@ -77,14 +77,11 @@ protected function setUp() { $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->scopeConfigMock = $this->getMock( + $this->scopeConfigMock = $this->createPartialMock( \Magento\Framework\App\Config\ScopeConfigInterface::class, - ['getValue', 'isSetFlag'], - [], - '', - false + ['getValue', 'isSetFlag'] ); - $this->localeResolverMock = $this->getMock( + $this->localeResolverMock = $this->createPartialMock( \Magento\Framework\Locale\ResolverInterface::class, [ 'getLocale', @@ -94,53 +91,23 @@ protected function setUp() 'setLocale', 'emulate', 'revert' - ], - [], - '', - false + ] ); - $this->systemStoreMock = $this->getMock( + $this->systemStoreMock = $this->createPartialMock( \Magento\Store\Model\System\Store::class, - ['getWebsiteCollection', 'getGroupCollection', 'getStoreCollection'], - [], - '', - false - ); - $this->configFactoryMock = $this->getMock( - \Magento\Config\Model\Config\Factory::class, - ['create'], - [], - '', - false + ['getWebsiteCollection', 'getGroupCollection', 'getStoreCollection'] ); - $this->eventManagerMock = $this->getMock( + $this->configFactoryMock = $this->createPartialMock(\Magento\Config\Model\Config\Factory::class, ['create']); + $this->eventManagerMock = $this->createPartialMock( \Magento\Framework\Event\ManagerInterface::class, - ['dispatch'], - [], - '', - false + ['dispatch'] ); - $this->coreConfigMock = $this->getMock( + $this->coreConfigMock = $this->createPartialMock( \Magento\Framework\App\Config\ReinitableConfigInterface::class, - ['reinit', 'setValue', 'getValue', 'isSetFlag'], - [], - '', - false - ); - $this->storeManagerMock = $this->getMock( - \Magento\Store\Model\StoreManagerInterface::class, - [], - [], - '', - false - ); - $this->cacheTypeListMock = $this->getMock( - \Magento\Framework\App\Cache\TypeListInterface::class, - [], - [], - '', - false + ['reinit', 'setValue', 'getValue', 'isSetFlag'] ); + $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->cacheTypeListMock = $this->createMock(\Magento\Framework\App\Cache\TypeListInterface::class); $this->serializerMock = $this->getMockBuilder(Json::class) ->disableOriginalConstructor() ->getMock(); @@ -319,17 +286,17 @@ protected function prepareMocksForGetCurrencySymbolsData( /** * @var \Magento\Store\Model\Website|\PHPUnit_Framework_MockObject_MockObject */ - $websiteMock = $this->getMock(\Magento\Store\Model\Website::class, ['getId', 'getConfig'], [], '', false); + $websiteMock = $this->createPartialMock(\Magento\Store\Model\Website::class, ['getId', 'getConfig']); /** * @var \Magento\Store\Model\Group|\PHPUnit_Framework_MockObject_MockObject */ - $groupMock = $this->getMock(\Magento\Store\Model\Group::class, ['getId', 'getWebsiteId'], [], '', false); + $groupMock = $this->createPartialMock(\Magento\Store\Model\Group::class, ['getId', 'getWebsiteId']); /** * @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject */ - $storeMock = $this->getMock(\Magento\Store\Model\Store::class, ['getGroupId'], [], '', false); + $storeMock = $this->createPartialMock(\Magento\Store\Model\Store::class, ['getGroupId']); $this->systemStoreMock->expects($this->once()) ->method('getWebsiteCollection') diff --git a/app/code/Magento/CurrencySymbol/Test/Unit/Observer/CurrencyDisplayOptionsTest.php b/app/code/Magento/CurrencySymbol/Test/Unit/Observer/CurrencyDisplayOptionsTest.php index df7134ab41e6e..dd0d7ffc8cc68 100644 --- a/app/code/Magento/CurrencySymbol/Test/Unit/Observer/CurrencyDisplayOptionsTest.php +++ b/app/code/Magento/CurrencySymbol/Test/Unit/Observer/CurrencyDisplayOptionsTest.php @@ -5,12 +5,12 @@ */ namespace Magento\CurrencySymbol\Test\Unit\Observer; -use \Magento\CurrencySymbol\Model\System\CurrencysymbolFactory; +use Magento\CurrencySymbol\Model\System\CurrencysymbolFactory; /** * Test for \Magento\CurrencySymbol\Observer\CurrencyDisplayOptions */ -class CurrencyDisplayOptionsTest extends \PHPUnit_Framework_TestCase +class CurrencyDisplayOptionsTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\CurrencySymbol\Observer\CurrencyDisplayOptions @@ -39,36 +39,21 @@ class CurrencyDisplayOptionsTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->mockSymbolFactory = $this->getMock( + $this->mockSymbolFactory = $this->createPartialMock( \Magento\CurrencySymbol\Model\System\CurrencysymbolFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->mockSymbol = $this->getMock( + $this->mockSymbol = $this->createPartialMock( \Magento\CurrencySymbol\Model\System\Currencysymbol::class, - ['getCurrencySymbol'], - [], - '', - false + ['getCurrencySymbol'] ); - $this->mockEventObserver = $this->getMock( - \Magento\Framework\Event\Observer::class, - ['getEvent'], - [], - '', - false - ); + $this->mockEventObserver = $this->createPartialMock(\Magento\Framework\Event\Observer::class, ['getEvent']); - $this->mockEvent = $this->getMock( + $this->mockEvent = $this->createPartialMock( \Magento\Framework\Event::class, - ['getBaseCode', 'getCurrencyOptions'], - [], - '', - false + ['getBaseCode', 'getCurrencyOptions'] ); $this->mockEventObserver->expects($this->any())->method('getEvent')->willReturn($this->mockEvent); @@ -83,6 +68,7 @@ public function testCurrencyDisplayOptionsEmpty() \Magento\Framework\Locale\Currency::CURRENCY_OPTION_NAME => 'US Dollar' ]; $sampleCurrencyOptionObject = new \Magento\Framework\DataObject($baseData); + //Return invalid value $this->mockEvent->expects($this->once())->method('getBaseCode')->willReturn(null); $this->mockEvent->expects($this->once())->method('getCurrencyOptions')->willReturn($sampleCurrencyOptionObject); diff --git a/app/code/Magento/Customer/Api/AccountManagementInterface.php b/app/code/Magento/Customer/Api/AccountManagementInterface.php index 52b711d988c6e..d2f9fb7ebc420 100644 --- a/app/code/Magento/Customer/Api/AccountManagementInterface.php +++ b/app/code/Magento/Customer/Api/AccountManagementInterface.php @@ -10,6 +10,7 @@ /** * Interface for managing customers accounts. * @api + * @since 100.0.2 */ interface AccountManagementInterface { diff --git a/app/code/Magento/Customer/Api/AddressMetadataInterface.php b/app/code/Magento/Customer/Api/AddressMetadataInterface.php index 4c4c213e9f18b..876412dcdedd4 100644 --- a/app/code/Magento/Customer/Api/AddressMetadataInterface.php +++ b/app/code/Magento/Customer/Api/AddressMetadataInterface.php @@ -9,6 +9,7 @@ /** * Interface for retrieval information about customer address attributes metadata. * @api + * @since 100.0.2 */ interface AddressMetadataInterface extends MetadataInterface { diff --git a/app/code/Magento/Customer/Api/AddressMetadataManagementInterface.php b/app/code/Magento/Customer/Api/AddressMetadataManagementInterface.php index 6110a12cfc933..c15df1d909823 100644 --- a/app/code/Magento/Customer/Api/AddressMetadataManagementInterface.php +++ b/app/code/Magento/Customer/Api/AddressMetadataManagementInterface.php @@ -8,6 +8,7 @@ /** * Interface for managing customer address attributes metadata. * @api + * @since 100.0.2 */ interface AddressMetadataManagementInterface extends MetadataManagementInterface { diff --git a/app/code/Magento/Customer/Api/AddressRepositoryInterface.php b/app/code/Magento/Customer/Api/AddressRepositoryInterface.php index 1aea658be443d..50c8422bd2192 100644 --- a/app/code/Magento/Customer/Api/AddressRepositoryInterface.php +++ b/app/code/Magento/Customer/Api/AddressRepositoryInterface.php @@ -9,6 +9,7 @@ /** * Customer address CRUD interface. * @api + * @since 100.0.2 */ interface AddressRepositoryInterface { diff --git a/app/code/Magento/Customer/Api/CustomerGroupConfigInterface.php b/app/code/Magento/Customer/Api/CustomerGroupConfigInterface.php index 761f7280c5581..6e118b2b40e76 100644 --- a/app/code/Magento/Customer/Api/CustomerGroupConfigInterface.php +++ b/app/code/Magento/Customer/Api/CustomerGroupConfigInterface.php @@ -9,6 +9,7 @@ * Interface for system configuration operations for customer groups. * * @api + * @since 100.2.0 */ interface CustomerGroupConfigInterface { @@ -21,6 +22,7 @@ interface CustomerGroupConfigInterface * @throws \Exception * @throws \Magento\Framework\Exception\NoSuchEntityException * @throws \Magento\Framework\Exception\LocalizedException + * @since 100.2.0 */ public function setDefaultCustomerGroup($id); } diff --git a/app/code/Magento/Customer/Api/CustomerManagementInterface.php b/app/code/Magento/Customer/Api/CustomerManagementInterface.php index 137b3545a4144..a0b883f79ad53 100644 --- a/app/code/Magento/Customer/Api/CustomerManagementInterface.php +++ b/app/code/Magento/Customer/Api/CustomerManagementInterface.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ interface CustomerManagementInterface { diff --git a/app/code/Magento/Customer/Api/CustomerMetadataInterface.php b/app/code/Magento/Customer/Api/CustomerMetadataInterface.php index 1067358de09fe..901c68589fcb1 100644 --- a/app/code/Magento/Customer/Api/CustomerMetadataInterface.php +++ b/app/code/Magento/Customer/Api/CustomerMetadataInterface.php @@ -9,6 +9,7 @@ /** * Interface for retrieval information about customer attributes metadata. * @api + * @since 100.0.2 */ interface CustomerMetadataInterface extends MetadataInterface { diff --git a/app/code/Magento/Customer/Api/CustomerMetadataManagementInterface.php b/app/code/Magento/Customer/Api/CustomerMetadataManagementInterface.php index a3ce83f44552a..0e55eb43857ec 100644 --- a/app/code/Magento/Customer/Api/CustomerMetadataManagementInterface.php +++ b/app/code/Magento/Customer/Api/CustomerMetadataManagementInterface.php @@ -8,6 +8,7 @@ /** * Interface for managing customer attributes metadata. * @api + * @since 100.0.2 */ interface CustomerMetadataManagementInterface extends MetadataManagementInterface { diff --git a/app/code/Magento/Customer/Api/CustomerNameGenerationInterface.php b/app/code/Magento/Customer/Api/CustomerNameGenerationInterface.php index b7d087f19184d..21cbf32e20c40 100644 --- a/app/code/Magento/Customer/Api/CustomerNameGenerationInterface.php +++ b/app/code/Magento/Customer/Api/CustomerNameGenerationInterface.php @@ -13,6 +13,7 @@ * Interface CustomerNameGenerationInterface * * @api + * @since 100.1.0 */ interface CustomerNameGenerationInterface { @@ -21,6 +22,7 @@ interface CustomerNameGenerationInterface * * @param CustomerInterface $customerData * @return string + * @since 100.1.0 */ public function getCustomerName(CustomerInterface $customerData); } diff --git a/app/code/Magento/Customer/Api/CustomerRepositoryInterface.php b/app/code/Magento/Customer/Api/CustomerRepositoryInterface.php index 2af3dc777d3f9..a18540d8cf9d5 100644 --- a/app/code/Magento/Customer/Api/CustomerRepositoryInterface.php +++ b/app/code/Magento/Customer/Api/CustomerRepositoryInterface.php @@ -10,6 +10,7 @@ /** * Customer CRUD interface. * @api + * @since 100.0.2 */ interface CustomerRepositoryInterface { diff --git a/app/code/Magento/Customer/Api/Data/AddressInterface.php b/app/code/Magento/Customer/Api/Data/AddressInterface.php index 0cdd54c4789c3..396b83d983e9b 100644 --- a/app/code/Magento/Customer/Api/Data/AddressInterface.php +++ b/app/code/Magento/Customer/Api/Data/AddressInterface.php @@ -10,6 +10,7 @@ /** * Customer address interface. * @api + * @since 100.0.2 */ interface AddressInterface extends \Magento\Framework\Api\CustomAttributesDataInterface { diff --git a/app/code/Magento/Customer/Api/Data/AddressSearchResultsInterface.php b/app/code/Magento/Customer/Api/Data/AddressSearchResultsInterface.php index db2300ab7194b..c4683171770b4 100644 --- a/app/code/Magento/Customer/Api/Data/AddressSearchResultsInterface.php +++ b/app/code/Magento/Customer/Api/Data/AddressSearchResultsInterface.php @@ -9,6 +9,7 @@ /** * Interface for customer address search results. * @api + * @since 100.0.2 */ interface AddressSearchResultsInterface extends \Magento\Framework\Api\SearchResultsInterface { diff --git a/app/code/Magento/Customer/Api/Data/AttributeMetadataInterface.php b/app/code/Magento/Customer/Api/Data/AttributeMetadataInterface.php index 2c234af8ff625..bc23918e1fae1 100644 --- a/app/code/Magento/Customer/Api/Data/AttributeMetadataInterface.php +++ b/app/code/Magento/Customer/Api/Data/AttributeMetadataInterface.php @@ -9,6 +9,7 @@ /** * Customer attribute metadata interface. * @api + * @since 100.0.2 */ interface AttributeMetadataInterface extends \Magento\Framework\Api\MetadataObjectInterface { diff --git a/app/code/Magento/Customer/Api/Data/CustomerInterface.php b/app/code/Magento/Customer/Api/Data/CustomerInterface.php index e6a93c714e078..9e8f9a12d5a48 100644 --- a/app/code/Magento/Customer/Api/Data/CustomerInterface.php +++ b/app/code/Magento/Customer/Api/Data/CustomerInterface.php @@ -8,6 +8,7 @@ /** * Customer interface. * @api + * @since 100.0.2 */ interface CustomerInterface extends \Magento\Framework\Api\CustomAttributesDataInterface { diff --git a/app/code/Magento/Customer/Api/Data/CustomerSearchResultsInterface.php b/app/code/Magento/Customer/Api/Data/CustomerSearchResultsInterface.php index dcf507f47c6d3..d858ff56bc5ac 100644 --- a/app/code/Magento/Customer/Api/Data/CustomerSearchResultsInterface.php +++ b/app/code/Magento/Customer/Api/Data/CustomerSearchResultsInterface.php @@ -9,6 +9,7 @@ /** * Interface for customer search results. * @api + * @since 100.0.2 */ interface CustomerSearchResultsInterface extends \Magento\Framework\Api\SearchResultsInterface { diff --git a/app/code/Magento/Customer/Api/Data/GroupInterface.php b/app/code/Magento/Customer/Api/Data/GroupInterface.php index dcd71c78d5867..dfdcf2d998682 100644 --- a/app/code/Magento/Customer/Api/Data/GroupInterface.php +++ b/app/code/Magento/Customer/Api/Data/GroupInterface.php @@ -12,6 +12,7 @@ /** * Customer group interface. * @api + * @since 100.0.2 */ interface GroupInterface extends ExtensibleDataInterface { diff --git a/app/code/Magento/Customer/Api/Data/GroupSearchResultsInterface.php b/app/code/Magento/Customer/Api/Data/GroupSearchResultsInterface.php index 8d862bb660c68..99712ab369d40 100644 --- a/app/code/Magento/Customer/Api/Data/GroupSearchResultsInterface.php +++ b/app/code/Magento/Customer/Api/Data/GroupSearchResultsInterface.php @@ -9,6 +9,7 @@ /** * Interface for customer groups search results. * @api + * @since 100.0.2 */ interface GroupSearchResultsInterface extends \Magento\Framework\Api\SearchResultsInterface { diff --git a/app/code/Magento/Customer/Api/Data/OptionInterface.php b/app/code/Magento/Customer/Api/Data/OptionInterface.php index 41a14f8288f4e..620e42a921c1e 100644 --- a/app/code/Magento/Customer/Api/Data/OptionInterface.php +++ b/app/code/Magento/Customer/Api/Data/OptionInterface.php @@ -10,6 +10,7 @@ /** * Option interface. * @api + * @since 100.0.2 */ interface OptionInterface { diff --git a/app/code/Magento/Customer/Api/Data/RegionInterface.php b/app/code/Magento/Customer/Api/Data/RegionInterface.php index f64276e79536a..07a3685c89219 100644 --- a/app/code/Magento/Customer/Api/Data/RegionInterface.php +++ b/app/code/Magento/Customer/Api/Data/RegionInterface.php @@ -11,6 +11,7 @@ /** * Customer address region interface. * @api + * @since 100.0.2 */ interface RegionInterface extends ExtensibleDataInterface { diff --git a/app/code/Magento/Customer/Api/Data/ValidationResultsInterface.php b/app/code/Magento/Customer/Api/Data/ValidationResultsInterface.php index ea51fd5bcf0bc..fe4b5290c83f7 100644 --- a/app/code/Magento/Customer/Api/Data/ValidationResultsInterface.php +++ b/app/code/Magento/Customer/Api/Data/ValidationResultsInterface.php @@ -10,6 +10,7 @@ /** * Validation results interface. * @api + * @since 100.0.2 */ interface ValidationResultsInterface { diff --git a/app/code/Magento/Customer/Api/Data/ValidationRuleInterface.php b/app/code/Magento/Customer/Api/Data/ValidationRuleInterface.php index b9f19cb676907..a5f0decdb7ecf 100644 --- a/app/code/Magento/Customer/Api/Data/ValidationRuleInterface.php +++ b/app/code/Magento/Customer/Api/Data/ValidationRuleInterface.php @@ -10,6 +10,7 @@ /** * Validation rule interface. * @api + * @since 100.0.2 */ interface ValidationRuleInterface { diff --git a/app/code/Magento/Customer/Api/GroupManagementInterface.php b/app/code/Magento/Customer/Api/GroupManagementInterface.php index 5534f58f24ab8..93731fb1a1e9c 100644 --- a/app/code/Magento/Customer/Api/GroupManagementInterface.php +++ b/app/code/Magento/Customer/Api/GroupManagementInterface.php @@ -9,6 +9,7 @@ /** * Interface for managing customer groups. * @api + * @since 100.0.2 */ interface GroupManagementInterface { diff --git a/app/code/Magento/Customer/Api/GroupRepositoryInterface.php b/app/code/Magento/Customer/Api/GroupRepositoryInterface.php index 3a72fc1bcb03c..2f5e637a7693f 100644 --- a/app/code/Magento/Customer/Api/GroupRepositoryInterface.php +++ b/app/code/Magento/Customer/Api/GroupRepositoryInterface.php @@ -8,6 +8,7 @@ /** * Customer group CRUD interface * @api + * @since 100.0.2 */ interface GroupRepositoryInterface { diff --git a/app/code/Magento/Customer/Api/MetadataInterface.php b/app/code/Magento/Customer/Api/MetadataInterface.php index 9a8016283b17c..5b44b3e216d6c 100644 --- a/app/code/Magento/Customer/Api/MetadataInterface.php +++ b/app/code/Magento/Customer/Api/MetadataInterface.php @@ -9,6 +9,7 @@ /** * Interface for getting attributes metadata. Note that this interface should not be used directly, use its children. * @api + * @since 100.0.2 */ interface MetadataInterface extends \Magento\Framework\Api\MetadataServiceInterface { diff --git a/app/code/Magento/Customer/Api/MetadataManagementInterface.php b/app/code/Magento/Customer/Api/MetadataManagementInterface.php index 7cd447497847a..254ea13b7f42d 100644 --- a/app/code/Magento/Customer/Api/MetadataManagementInterface.php +++ b/app/code/Magento/Customer/Api/MetadataManagementInterface.php @@ -10,6 +10,7 @@ /** * Interface for managing attributes metadata. * @api + * @since 100.0.2 */ interface MetadataManagementInterface { diff --git a/app/code/Magento/Customer/Block/Account/AuthenticationPopup.php b/app/code/Magento/Customer/Block/Account/AuthenticationPopup.php index b102ee9e36c8a..07e0704ee6e43 100644 --- a/app/code/Magento/Customer/Block/Account/AuthenticationPopup.php +++ b/app/code/Magento/Customer/Block/Account/AuthenticationPopup.php @@ -10,6 +10,7 @@ /** * @api + * @since 100.0.2 */ class AuthenticationPopup extends \Magento\Framework\View\Element\Template { @@ -69,6 +70,7 @@ public function getConfig() * Added in scope of https://github.com/magento/magento2/pull/8617 * * @return bool|string + * @since 100.2.0 */ public function getSerializedConfig() { diff --git a/app/code/Magento/Customer/Block/Account/AuthorizationLink.php b/app/code/Magento/Customer/Block/Account/AuthorizationLink.php index 53f75805186cd..ff9d56c8fc4cb 100644 --- a/app/code/Magento/Customer/Block/Account/AuthorizationLink.php +++ b/app/code/Magento/Customer/Block/Account/AuthorizationLink.php @@ -13,6 +13,7 @@ * * @api * @SuppressWarnings(PHPMD.DepthOfInheritance) + * @since 100.0.2 */ class AuthorizationLink extends \Magento\Framework\View\Element\Html\Link implements SortLinkInterface { @@ -93,6 +94,7 @@ public function isLoggedIn() /** * {@inheritdoc} + * @since 100.2.0 */ public function getSortOrder() { diff --git a/app/code/Magento/Customer/Block/Account/Customer.php b/app/code/Magento/Customer/Block/Account/Customer.php index 8d8e5b7e809f4..0c5820837d769 100644 --- a/app/code/Magento/Customer/Block/Account/Customer.php +++ b/app/code/Magento/Customer/Block/Account/Customer.php @@ -9,13 +9,18 @@ /** * @api + * @since 100.0.2 */ class Customer extends \Magento\Framework\View\Element\Template { - /** @var CustomerRepositoryInterface */ + /** + * @var \Magento\Customer\Api\CustomerRepositoryInterface + */ protected $customerRepository; - /** @var \Magento\Customer\Helper\View */ + /** + * @var \Magento\Customer\Helper\View + */ protected $_viewHelper; /** diff --git a/app/code/Magento/Customer/Block/Account/Dashboard.php b/app/code/Magento/Customer/Block/Account/Dashboard.php index 6a08ef8530a6c..fa9c8f98a8c2c 100644 --- a/app/code/Magento/Customer/Block/Account/Dashboard.php +++ b/app/code/Magento/Customer/Block/Account/Dashboard.php @@ -12,6 +12,7 @@ * Customer dashboard block * * @api + * @since 100.0.2 */ class Dashboard extends \Magento\Framework\View\Element\Template { diff --git a/app/code/Magento/Customer/Block/Account/Dashboard/Address.php b/app/code/Magento/Customer/Block/Account/Dashboard/Address.php index fb5590399187d..87fb6fc62bc24 100644 --- a/app/code/Magento/Customer/Block/Account/Dashboard/Address.php +++ b/app/code/Magento/Customer/Block/Account/Dashboard/Address.php @@ -13,6 +13,7 @@ * Class to manage customer dashboard addresses section * * @api + * @since 100.0.2 */ class Address extends \Magento\Framework\View\Element\Template { diff --git a/app/code/Magento/Customer/Block/Account/Dashboard/Info.php b/app/code/Magento/Customer/Block/Account/Dashboard/Info.php index 7fa64660198c0..ded7238edc755 100644 --- a/app/code/Magento/Customer/Block/Account/Dashboard/Info.php +++ b/app/code/Magento/Customer/Block/Account/Dashboard/Info.php @@ -11,6 +11,7 @@ * Dashboard Customer Info * * @api + * @since 100.0.2 */ class Info extends \Magento\Framework\View\Element\Template { @@ -26,7 +27,9 @@ class Info extends \Magento\Framework\View\Element\Template */ protected $_subscriberFactory; - /** @var \Magento\Customer\Helper\View */ + /** + * @var \Magento\Customer\Helper\View + */ protected $_helperView; /** diff --git a/app/code/Magento/Customer/Block/Account/Delimiter.php b/app/code/Magento/Customer/Block/Account/Delimiter.php index d8598dcfbea33..056a53e259c49 100644 --- a/app/code/Magento/Customer/Block/Account/Delimiter.php +++ b/app/code/Magento/Customer/Block/Account/Delimiter.php @@ -10,11 +10,13 @@ * Class for delimiter. * * @api + * @since 100.2.0 */ class Delimiter extends \Magento\Framework\View\Element\Template implements SortLinkInterface { /** * {@inheritdoc} + * @since 100.2.0 */ public function getSortOrder() { diff --git a/app/code/Magento/Customer/Block/Account/Forgotpassword.php b/app/code/Magento/Customer/Block/Account/Forgotpassword.php index 8b39f3cf54a9e..c3003638c520b 100644 --- a/app/code/Magento/Customer/Block/Account/Forgotpassword.php +++ b/app/code/Magento/Customer/Block/Account/Forgotpassword.php @@ -12,6 +12,7 @@ * Customer account navigation sidebar * * @api + * @since 100.0.2 */ class Forgotpassword extends \Magento\Framework\View\Element\Template { diff --git a/app/code/Magento/Customer/Block/Account/Link.php b/app/code/Magento/Customer/Block/Account/Link.php index 3c978341755b1..ed29a10abc8b7 100644 --- a/app/code/Magento/Customer/Block/Account/Link.php +++ b/app/code/Magento/Customer/Block/Account/Link.php @@ -12,6 +12,7 @@ * * @api * @SuppressWarnings(PHPMD.DepthOfInheritance) + * @since 100.0.2 */ class Link extends \Magento\Framework\View\Element\Html\Link implements SortLinkInterface { @@ -44,6 +45,7 @@ public function getHref() /** * {@inheritdoc} + * @since 100.2.0 */ public function getSortOrder() { diff --git a/app/code/Magento/Customer/Block/Account/Navigation.php b/app/code/Magento/Customer/Block/Account/Navigation.php index 7cd60020c69b5..cb38d762769f2 100644 --- a/app/code/Magento/Customer/Block/Account/Navigation.php +++ b/app/code/Magento/Customer/Block/Account/Navigation.php @@ -13,11 +13,13 @@ * Class for sorting links in navigation panels. * * @api + * @since 100.2.0 */ class Navigation extends Links { /** * {@inheritdoc} + * @since 100.2.0 */ public function getLinks() { diff --git a/app/code/Magento/Customer/Block/Account/RegisterLink.php b/app/code/Magento/Customer/Block/Account/RegisterLink.php index b8250160c8585..7db14cde5603e 100644 --- a/app/code/Magento/Customer/Block/Account/RegisterLink.php +++ b/app/code/Magento/Customer/Block/Account/RegisterLink.php @@ -12,6 +12,7 @@ * * @api * @SuppressWarnings(PHPMD.DepthOfInheritance) + * @since 100.0.2 */ class RegisterLink extends \Magento\Framework\View\Element\Html\Link { diff --git a/app/code/Magento/Customer/Block/Account/Resetpassword.php b/app/code/Magento/Customer/Block/Account/Resetpassword.php index 005d80abb7009..1672b2d596228 100644 --- a/app/code/Magento/Customer/Block/Account/Resetpassword.php +++ b/app/code/Magento/Customer/Block/Account/Resetpassword.php @@ -11,6 +11,7 @@ * Customer reset password form * * @api + * @since 100.0.2 */ class Resetpassword extends \Magento\Framework\View\Element\Template { @@ -31,6 +32,7 @@ public function isAutocompleteDisabled() * Get minimum password length * * @return string + * @since 100.1.0 */ public function getMinimumPasswordLength() { @@ -41,6 +43,7 @@ public function getMinimumPasswordLength() * Get minimum password length * * @return string + * @since 100.1.0 */ public function getRequiredCharacterClassesNumber() { diff --git a/app/code/Magento/Customer/Block/Account/SortLinkInterface.php b/app/code/Magento/Customer/Block/Account/SortLinkInterface.php index c4209740c81be..114bb02e1444c 100644 --- a/app/code/Magento/Customer/Block/Account/SortLinkInterface.php +++ b/app/code/Magento/Customer/Block/Account/SortLinkInterface.php @@ -9,6 +9,7 @@ /** * Interface for sortable links. * @api + * @since 100.2.0 */ interface SortLinkInterface { @@ -22,6 +23,7 @@ interface SortLinkInterface * Get sort order for block. * * @return int + * @since 100.2.0 */ public function getSortOrder(); } diff --git a/app/code/Magento/Customer/Block/Address/Book.php b/app/code/Magento/Customer/Block/Address/Book.php index 927dd86256a60..8b38946a063db 100644 --- a/app/code/Magento/Customer/Block/Address/Book.php +++ b/app/code/Magento/Customer/Block/Address/Book.php @@ -14,6 +14,7 @@ * * @api * @author Magento Core Team + * @since 100.0.2 */ class Book extends \Magento\Framework\View\Element\Template { diff --git a/app/code/Magento/Customer/Block/Address/Edit.php b/app/code/Magento/Customer/Block/Address/Edit.php index 56922cfc8e4d2..6362f28a4f96d 100644 --- a/app/code/Magento/Customer/Block/Address/Edit.php +++ b/app/code/Magento/Customer/Block/Address/Edit.php @@ -12,6 +12,7 @@ * * @api * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class Edit extends \Magento\Directory\Block\Data { diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit.php b/app/code/Magento/Customer/Block/Adminhtml/Edit.php index 55236c38c7bfc..973016baba29c 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit.php @@ -10,7 +10,7 @@ use Magento\Customer\Controller\RegistryConstants; /** - * @deprecated for UiComponent replacement + * @deprecated 100.2.0 for UiComponent replacement * @see app/code/Magento/Customer/view/base/ui_component/customer_form.xml */ class Edit extends \Magento\Backend\Block\Widget\Form\Container diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Cart.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Cart.php index b469b7576ceed..9ee152078d960 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Cart.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Cart.php @@ -13,6 +13,7 @@ * Adminhtml customer orders grid block * * @api + * @since 100.0.2 */ class Cart extends \Magento\Backend\Block\Widget\Grid\Extended { diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Carts.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Carts.php index c1f86aa45866c..5601cf3728349 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Carts.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Carts.php @@ -9,10 +9,13 @@ * Obtain all carts contents for specified client * * @api + * @since 100.0.2 */ class Carts extends \Magento\Backend\Block\Template { - /** @var \Magento\Customer\Model\Config\Share */ + /** + * @var \Magento\Customer\Model\Config\Share + */ protected $_shareConfig; /** diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Newsletter/Grid.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Newsletter/Grid.php index 4f3d23eae32bc..4f49c3ba1db9b 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Newsletter/Grid.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Newsletter/Grid.php @@ -9,6 +9,7 @@ * Adminhtml newsletter queue grid block * * @api + * @since 100.0.2 */ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended { diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Orders.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Orders.php index c3163e8c07536..bb190260e4776 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Orders.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Orders.php @@ -11,6 +11,7 @@ * Adminhtml customer orders grid block * * @api + * @since 100.0.2 */ class Orders extends \Magento\Backend\Block\Widget\Grid\Extended { diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Reviews.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Reviews.php index 02f6b18ad70e2..a10842fc0c6de 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Reviews.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Reviews.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Reviews extends \Magento\Review\Block\Adminhtml\Grid { diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Cart.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Cart.php index 6e3f6f77fcbaa..3f2c7cda7608d 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Cart.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Cart.php @@ -14,6 +14,7 @@ * @SuppressWarnings(PHPMD.LongVariable) * * @api + * @since 100.0.2 */ class Cart extends \Magento\Backend\Block\Widget\Grid\Extended { diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/PersonalInfo.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/PersonalInfo.php index c6218c6c1e22e..81b7b8b3f96b5 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/PersonalInfo.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/PersonalInfo.php @@ -154,7 +154,7 @@ public function __construct( * * @param \Magento\Framework\Registry $coreRegistry * @return void - * @deprecated + * @deprecated 100.1.0 */ public function setCustomerRegistry(\Magento\Customer\Model\CustomerRegistry $customerRegistry) { @@ -166,7 +166,7 @@ public function setCustomerRegistry(\Magento\Customer\Model\CustomerRegistry $cu * Get customer registry * * @return \Magento\Customer\Model\CustomerRegistry - * @deprecated + * @deprecated 100.1.0 */ public function getCustomerRegistry() { diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Wishlist.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Wishlist.php index cb3b88bc0c654..00ff269d7e19e 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Wishlist.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Wishlist.php @@ -11,6 +11,7 @@ * Adminhtml customer view wishlist block * * @api + * @since 100.0.2 */ class Wishlist extends \Magento\Backend\Block\Widget\Grid\Extended { diff --git a/app/code/Magento/Customer/Block/Adminhtml/Group.php b/app/code/Magento/Customer/Block/Adminhtml/Group.php index 2b7eefb67d30f..b5448fb3c115d 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Group.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Group.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class Group extends \Magento\Backend\Block\Widget\Grid\Container { diff --git a/app/code/Magento/Customer/Block/CustomerData.php b/app/code/Magento/Customer/Block/CustomerData.php index fc773bf9ee74e..98eb2d9f9ea40 100644 --- a/app/code/Magento/Customer/Block/CustomerData.php +++ b/app/code/Magento/Customer/Block/CustomerData.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class CustomerData extends \Magento\Framework\View\Element\Template { @@ -58,6 +59,7 @@ public function getCustomerDataUrl($route) * Once this period has expired the corresponding section must be invalidated and reloaded. * * @return int section lifetime in minutes + * @since 100.2.0 */ public function getExpirableSectionLifetime() { @@ -68,6 +70,7 @@ public function getExpirableSectionLifetime() * Retrieve the list of sections that can expire. * * @return array + * @since 100.2.0 */ public function getExpirableSectionNames() { diff --git a/app/code/Magento/Customer/Block/CustomerScopeData.php b/app/code/Magento/Customer/Block/CustomerScopeData.php index 244437e870b98..8597df3304b7e 100644 --- a/app/code/Magento/Customer/Block/CustomerScopeData.php +++ b/app/code/Magento/Customer/Block/CustomerScopeData.php @@ -11,6 +11,7 @@ * that private cache invalid for current scope, by comparing * with appropriate value in store front private cache. * @api + * @since 100.2.0 */ class CustomerScopeData extends \Magento\Framework\View\Element\Template { @@ -45,6 +46,7 @@ public function __construct( * Can be used when necessary to obtain website id of the current customer. * * @return integer + * @since 100.2.0 */ public function getWebsiteId() { diff --git a/app/code/Magento/Customer/Block/Form/Edit.php b/app/code/Magento/Customer/Block/Form/Edit.php index d24635558adb1..1608ba0f24367 100644 --- a/app/code/Magento/Customer/Block/Form/Edit.php +++ b/app/code/Magento/Customer/Block/Form/Edit.php @@ -13,6 +13,7 @@ * * @api * @SuppressWarnings(PHPMD.DepthOfInheritance) + * @since 100.0.2 */ class Edit extends \Magento\Customer\Block\Account\Dashboard { @@ -71,6 +72,7 @@ public function getChangePassword() * Get minimum password length * * @return string + * @since 100.1.0 */ public function getMinimumPasswordLength() { @@ -81,6 +83,7 @@ public function getMinimumPasswordLength() * Get minimum password length * * @return string + * @since 100.1.0 */ public function getRequiredCharacterClassesNumber() { diff --git a/app/code/Magento/Customer/Block/Form/Login.php b/app/code/Magento/Customer/Block/Form/Login.php index 8cf7bd6114870..7b265ae1f0f32 100644 --- a/app/code/Magento/Customer/Block/Form/Login.php +++ b/app/code/Magento/Customer/Block/Form/Login.php @@ -10,6 +10,7 @@ * * @api * @author Magento Core Team + * @since 100.0.2 */ class Login extends \Magento\Framework\View\Element\Template { diff --git a/app/code/Magento/Customer/Block/Form/Login/Info.php b/app/code/Magento/Customer/Block/Form/Login/Info.php index 5fae2879383ba..5be8f2463f5cc 100644 --- a/app/code/Magento/Customer/Block/Form/Login/Info.php +++ b/app/code/Magento/Customer/Block/Form/Login/Info.php @@ -9,6 +9,7 @@ * Customer login info block * * @api + * @since 100.0.2 */ class Info extends \Magento\Framework\View\Element\Template { diff --git a/app/code/Magento/Customer/Block/Form/Register.php b/app/code/Magento/Customer/Block/Form/Register.php index f19a31e777f09..f31012a52a98e 100644 --- a/app/code/Magento/Customer/Block/Form/Register.php +++ b/app/code/Magento/Customer/Block/Form/Register.php @@ -12,6 +12,7 @@ * * @api * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class Register extends \Magento\Directory\Block\Data { @@ -202,6 +203,7 @@ public function restoreSessionData(\Magento\Customer\Model\Metadata\Form $form, * Get minimum password length * * @return string + * @since 100.1.0 */ public function getMinimumPasswordLength() { @@ -212,6 +214,7 @@ public function getMinimumPasswordLength() * Get number of password required character classes * * @return string + * @since 100.1.0 */ public function getRequiredCharacterClassesNumber() { diff --git a/app/code/Magento/Customer/Block/Newsletter.php b/app/code/Magento/Customer/Block/Newsletter.php index 3ac3258dfe0de..7a34b1d892bc1 100644 --- a/app/code/Magento/Customer/Block/Newsletter.php +++ b/app/code/Magento/Customer/Block/Newsletter.php @@ -13,6 +13,7 @@ * * @api * @SuppressWarnings(PHPMD.DepthOfInheritance) + * @since 100.0.2 */ class Newsletter extends \Magento\Customer\Block\Account\Dashboard { diff --git a/app/code/Magento/Customer/Block/SectionConfig.php b/app/code/Magento/Customer/Block/SectionConfig.php index 8357498dfbc32..e4b7c6058cb62 100644 --- a/app/code/Magento/Customer/Block/SectionConfig.php +++ b/app/code/Magento/Customer/Block/SectionConfig.php @@ -7,10 +7,13 @@ /** * @api + * @since 100.0.2 */ class SectionConfig extends \Magento\Framework\View\Element\Template { - /** @var \Magento\Framework\Config\DataInterface */ + /** + * @var \Magento\Framework\Config\DataInterface + */ protected $sectionConfig; /** diff --git a/app/code/Magento/Customer/Block/Widget/Dob.php b/app/code/Magento/Customer/Block/Widget/Dob.php index f29a9fc76f1d2..f8ee8fddf2ea2 100644 --- a/app/code/Magento/Customer/Block/Widget/Dob.php +++ b/app/code/Magento/Customer/Block/Widget/Dob.php @@ -208,17 +208,17 @@ public function getHtmlId() */ public function getHtmlExtraParams() { - $extraParams = [ - "'validate-date-au':true" - ]; + $validators = []; if ($this->isRequired()) { - $extraParams[] = 'required:true'; + $validators['required'] = true; } - $extraParams = implode(', ', $extraParams); + $validators['validate-date'] = [ + 'dateFormat' => $this->getDateFormat() + ]; - return 'data-validate="{' . $extraParams . '}"'; + return 'data-validate="' . $this->_escaper->escapeHtml(json_encode($validators)) . '"'; } /** diff --git a/app/code/Magento/Customer/Controller/Account/Confirm.php b/app/code/Magento/Customer/Controller/Account/Confirm.php index 89998edeb3a8d..2b3cb9aa61ab5 100644 --- a/app/code/Magento/Customer/Controller/Account/Confirm.php +++ b/app/code/Magento/Customer/Controller/Account/Confirm.php @@ -26,22 +26,34 @@ */ class Confirm extends \Magento\Customer\Controller\AbstractAccount { - /** @var ScopeConfigInterface */ + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface + */ protected $scopeConfig; - /** @var StoreManagerInterface */ + /** + * @var \Magento\Store\Model\StoreManagerInterface + */ protected $storeManager; - /** @var AccountManagementInterface */ + /** + * @var \Magento\Customer\Api\AccountManagementInterface + */ protected $customerAccountManagement; - /** @var CustomerRepositoryInterface */ + /** + * @var \Magento\Customer\Api\CustomerRepositoryInterface + */ protected $customerRepository; - /** @var Address */ + /** + * @var \Magento\Customer\Helper\Address + */ protected $addressHelper; - /** @var \Magento\Framework\UrlInterface */ + /** + * @var \Magento\Framework\UrlInterface + */ protected $urlModel; /** @@ -92,7 +104,7 @@ public function __construct( /** * Retrieve cookie manager * - * @deprecated + * @deprecated 100.2.0 * @return \Magento\Framework\Stdlib\Cookie\PhpCookieManager */ private function getCookieManager() @@ -108,7 +120,7 @@ private function getCookieManager() /** * Retrieve cookie metadata factory * - * @deprecated + * @deprecated 100.2.0 * @return \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory */ private function getCookieMetadataFactory() diff --git a/app/code/Magento/Customer/Controller/Account/Confirmation.php b/app/code/Magento/Customer/Controller/Account/Confirmation.php index 692deb5fd52c3..e7d23cac8d62a 100644 --- a/app/code/Magento/Customer/Controller/Account/Confirmation.php +++ b/app/code/Magento/Customer/Controller/Account/Confirmation.php @@ -15,10 +15,14 @@ class Confirmation extends \Magento\Customer\Controller\AbstractAccount { - /** @var StoreManagerInterface */ + /** + * @var \Magento\Store\Model\StoreManagerInterface + */ protected $storeManager; - /** @var AccountManagementInterface */ + /** + * @var \Magento\Customer\Api\AccountManagementInterface + */ protected $customerAccountManagement; /** diff --git a/app/code/Magento/Customer/Controller/Account/Create.php b/app/code/Magento/Customer/Controller/Account/Create.php index c7bf63bd28a44..8f1bc107547ea 100644 --- a/app/code/Magento/Customer/Controller/Account/Create.php +++ b/app/code/Magento/Customer/Controller/Account/Create.php @@ -13,7 +13,9 @@ class Create extends \Magento\Customer\Controller\AbstractAccount { - /** @var Registration */ + /** + * @var \Magento\Customer\Model\Registration + */ protected $registration; /** diff --git a/app/code/Magento/Customer/Controller/Account/CreatePassword.php b/app/code/Magento/Customer/Controller/Account/CreatePassword.php index b9b2b3a5ec873..fb2e3dd42908b 100644 --- a/app/code/Magento/Customer/Controller/Account/CreatePassword.php +++ b/app/code/Magento/Customer/Controller/Account/CreatePassword.php @@ -13,7 +13,9 @@ class CreatePassword extends \Magento\Customer\Controller\AbstractAccount { - /** @var AccountManagementInterface */ + /** + * @var \Magento\Customer\Api\AccountManagementInterface + */ protected $accountManagement; /** diff --git a/app/code/Magento/Customer/Controller/Account/CreatePost.php b/app/code/Magento/Customer/Controller/Account/CreatePost.php index 27b1ca14c508d..27d8ddd99344c 100644 --- a/app/code/Magento/Customer/Controller/Account/CreatePost.php +++ b/app/code/Magento/Customer/Controller/Account/CreatePost.php @@ -11,6 +11,7 @@ use Magento\Framework\App\Action\Context; use Magento\Customer\Model\Session; use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\App\ObjectManager; use Magento\Framework\Exception\LocalizedException; use Magento\Store\Model\StoreManagerInterface; use Magento\Customer\Api\AccountManagementInterface; @@ -27,49 +28,77 @@ use Magento\Customer\Model\CustomerExtractor; use Magento\Framework\Exception\StateException; use Magento\Framework\Exception\InputException; +use Magento\Framework\Data\Form\FormKey\Validator; /** + * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class CreatePost extends \Magento\Customer\Controller\AbstractAccount { - /** @var AccountManagementInterface */ + /** + * @var \Magento\Customer\Api\AccountManagementInterface + */ protected $accountManagement; - /** @var Address */ + /** + * @var \Magento\Customer\Helper\Address + */ protected $addressHelper; - /** @var FormFactory */ + /** + * @var \Magento\Customer\Model\Metadata\FormFactory + */ protected $formFactory; - /** @var SubscriberFactory */ + /** + * @var \Magento\Newsletter\Model\SubscriberFactory + */ protected $subscriberFactory; - /** @var RegionInterfaceFactory */ + /** + * @var \Magento\Customer\Api\Data\RegionInterfaceFactory + */ protected $regionDataFactory; - /** @var AddressInterfaceFactory */ + /** + * @var \Magento\Customer\Api\Data\AddressInterfaceFactory + */ protected $addressDataFactory; - /** @var Registration */ + /** + * @var \Magento\Customer\Model\Registration + */ protected $registration; - /** @var CustomerInterfaceFactory */ + /** + * @var \Magento\Customer\Api\Data\CustomerInterfaceFactory + */ protected $customerDataFactory; - /** @var CustomerUrl */ + /** + * @var \Magento\Customer\Model\Url + */ protected $customerUrl; - /** @var Escaper */ + /** + * @var \Magento\Framework\Escaper + */ protected $escaper; - /** @var CustomerExtractor */ + /** + * @var \Magento\Customer\Model\CustomerExtractor + */ protected $customerExtractor; - /** @var \Magento\Framework\UrlInterface */ + /** + * @var \Magento\Framework\UrlInterface + */ protected $urlModel; - /** @var DataObjectHelper */ + /** + * @var \Magento\Framework\Api\DataObjectHelper + */ protected $dataObjectHelper; /** @@ -92,6 +121,11 @@ class CreatePost extends \Magento\Customer\Controller\AbstractAccount */ private $cookieMetadataManager; + /** + * @var Validator + */ + private $formKeyValidator; + /** * @param Context $context * @param Session $customerSession @@ -111,6 +145,7 @@ class CreatePost extends \Magento\Customer\Controller\AbstractAccount * @param CustomerExtractor $customerExtractor * @param DataObjectHelper $dataObjectHelper * @param AccountRedirect $accountRedirect + * @param Validator $formKeyValidator * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -132,7 +167,8 @@ public function __construct( Escaper $escaper, CustomerExtractor $customerExtractor, DataObjectHelper $dataObjectHelper, - AccountRedirect $accountRedirect + AccountRedirect $accountRedirect, + Validator $formKeyValidator = null ) { $this->session = $customerSession; $this->scopeConfig = $scopeConfig; @@ -151,19 +187,20 @@ public function __construct( $this->urlModel = $urlFactory->create(); $this->dataObjectHelper = $dataObjectHelper; $this->accountRedirect = $accountRedirect; + $this->formKeyValidator = $formKeyValidator ?: ObjectManager::getInstance()->get(Validator::class); parent::__construct($context); } /** * Retrieve cookie manager * - * @deprecated + * @deprecated 100.1.0 * @return \Magento\Framework\Stdlib\Cookie\PhpCookieManager */ private function getCookieManager() { if (!$this->cookieMetadataManager) { - $this->cookieMetadataManager = \Magento\Framework\App\ObjectManager::getInstance()->get( + $this->cookieMetadataManager = ObjectManager::getInstance()->get( \Magento\Framework\Stdlib\Cookie\PhpCookieManager::class ); } @@ -173,13 +210,13 @@ private function getCookieManager() /** * Retrieve cookie metadata factory * - * @deprecated + * @deprecated 100.1.0 * @return \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory */ private function getCookieMetadataFactory() { if (!$this->cookieMetadataFactory) { - $this->cookieMetadataFactory = \Magento\Framework\App\ObjectManager::getInstance()->get( + $this->cookieMetadataFactory = ObjectManager::getInstance()->get( \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory::class ); } @@ -252,7 +289,7 @@ public function execute() return $resultRedirect; } - if (!$this->getRequest()->isPost()) { + if (!$this->getRequest()->isPost() || !$this->formKeyValidator->validate($this->getRequest())) { $url = $this->urlModel->getUrl('*/*/create', ['_secure' => true]); $resultRedirect->setUrl($this->_redirect->error($url)); return $resultRedirect; diff --git a/app/code/Magento/Customer/Controller/Account/Edit.php b/app/code/Magento/Customer/Controller/Account/Edit.php index 77f50c6390353..3c1e60199399b 100644 --- a/app/code/Magento/Customer/Controller/Account/Edit.php +++ b/app/code/Magento/Customer/Controller/Account/Edit.php @@ -14,10 +14,14 @@ class Edit extends \Magento\Customer\Controller\AbstractAccount { - /** @var CustomerRepositoryInterface */ + /** + * @var \Magento\Customer\Api\CustomerRepositoryInterface + */ protected $customerRepository; - /** @var DataObjectHelper */ + /** + * @var \Magento\Framework\Api\DataObjectHelper + */ protected $dataObjectHelper; /** diff --git a/app/code/Magento/Customer/Controller/Account/EditPost.php b/app/code/Magento/Customer/Controller/Account/EditPost.php index 5d707b66a268a..3f895ad2f17ac 100644 --- a/app/code/Magento/Customer/Controller/Account/EditPost.php +++ b/app/code/Magento/Customer/Controller/Account/EditPost.php @@ -57,7 +57,9 @@ class EditPost extends \Magento\Customer\Controller\AbstractAccount */ protected $session; - /** @var EmailNotificationInterface */ + /** + * @var \Magento\Customer\Model\EmailNotificationInterface + */ private $emailNotification; /** @@ -115,7 +117,7 @@ private function getAuthentication() * Get email notification * * @return EmailNotificationInterface - * @deprecated + * @deprecated 100.1.0 */ private function getEmailNotification() { @@ -295,7 +297,7 @@ private function processChangeEmailRequest(\Magento\Customer\Api\Data\CustomerIn * * @return Mapper * - * @deprecated + * @deprecated 100.1.3 */ private function getCustomerMapper() { diff --git a/app/code/Magento/Customer/Controller/Account/ForgotPasswordPost.php b/app/code/Magento/Customer/Controller/Account/ForgotPasswordPost.php index eba6d0d969f36..fe92032b1b75e 100644 --- a/app/code/Magento/Customer/Controller/Account/ForgotPasswordPost.php +++ b/app/code/Magento/Customer/Controller/Account/ForgotPasswordPost.php @@ -20,10 +20,14 @@ */ class ForgotPasswordPost extends \Magento\Customer\Controller\AbstractAccount { - /** @var AccountManagementInterface */ + /** + * @var \Magento\Customer\Api\AccountManagementInterface + */ protected $customerAccountManagement; - /** @var Escaper */ + /** + * @var \Magento\Framework\Escaper + */ protected $escaper; /** @@ -60,7 +64,7 @@ public function execute() $resultRedirect = $this->resultRedirectFactory->create(); $email = (string)$this->getRequest()->getPost('email'); if ($email) { - if (!\Zend_Validate::is($email, 'EmailAddress')) { + if (!\Zend_Validate::is($email, \Magento\Framework\Validator\EmailAddress::class)) { $this->session->setForgottenEmail($email); $this->messageManager->addErrorMessage(__('Please correct the email address.')); return $resultRedirect->setPath('*/*/forgotpassword'); diff --git a/app/code/Magento/Customer/Controller/Account/LoginPost.php b/app/code/Magento/Customer/Controller/Account/LoginPost.php index 727617ab3b2e8..b55863a3b486a 100644 --- a/app/code/Magento/Customer/Controller/Account/LoginPost.php +++ b/app/code/Magento/Customer/Controller/Account/LoginPost.php @@ -22,10 +22,14 @@ */ class LoginPost extends \Magento\Customer\Controller\AbstractAccount { - /** @var AccountManagementInterface */ + /** + * @var \Magento\Customer\Api\AccountManagementInterface + */ protected $customerAccountManagement; - /** @var Validator */ + /** + * @var \Magento\Framework\Data\Form\FormKey\Validator + */ protected $formKeyValidator; /** @@ -81,7 +85,7 @@ public function __construct( * Get scope config * * @return ScopeConfigInterface - * @deprecated + * @deprecated 100.0.10 */ private function getScopeConfig() { @@ -97,7 +101,7 @@ private function getScopeConfig() /** * Retrieve cookie manager * - * @deprecated + * @deprecated 100.1.0 * @return \Magento\Framework\Stdlib\Cookie\PhpCookieManager */ private function getCookieManager() @@ -113,7 +117,7 @@ private function getCookieManager() /** * Retrieve cookie metadata factory * - * @deprecated + * @deprecated 100.1.0 * @return \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory */ private function getCookieMetadataFactory() diff --git a/app/code/Magento/Customer/Controller/Account/Logout.php b/app/code/Magento/Customer/Controller/Account/Logout.php index 54504a2b7a468..3d5d5480c502b 100644 --- a/app/code/Magento/Customer/Controller/Account/Logout.php +++ b/app/code/Magento/Customer/Controller/Account/Logout.php @@ -44,7 +44,7 @@ public function __construct( /** * Retrieve cookie manager * - * @deprecated + * @deprecated 100.1.0 * @return PhpCookieManager */ private function getCookieManager() @@ -58,7 +58,7 @@ private function getCookieManager() /** * Retrieve cookie metadata factory * - * @deprecated + * @deprecated 100.1.0 * @return CookieMetadataFactory */ private function getCookieMetadataFactory() diff --git a/app/code/Magento/Customer/Controller/Account/ResetPasswordPost.php b/app/code/Magento/Customer/Controller/Account/ResetPasswordPost.php index d4b5d1247b31c..3de44e35d2447 100644 --- a/app/code/Magento/Customer/Controller/Account/ResetPasswordPost.php +++ b/app/code/Magento/Customer/Controller/Account/ResetPasswordPost.php @@ -16,10 +16,14 @@ class ResetPasswordPost extends \Magento\Customer\Controller\AbstractAccount { - /** @var AccountManagementInterface */ + /** + * @var \Magento\Customer\Api\AccountManagementInterface + */ protected $accountManagement; - /** @var CustomerRepositoryInterface */ + /** + * @var \Magento\Customer\Api\CustomerRepositoryInterface + */ protected $customerRepository; /** diff --git a/app/code/Magento/Customer/Controller/AccountInterface.php b/app/code/Magento/Customer/Controller/AccountInterface.php index 66822a610ddc1..11b75976480c4 100644 --- a/app/code/Magento/Customer/Controller/AccountInterface.php +++ b/app/code/Magento/Customer/Controller/AccountInterface.php @@ -7,6 +7,10 @@ use Magento\Framework\App\ActionInterface; +/** + * Interface \Magento\Customer\Controller\AccountInterface + * + */ interface AccountInterface extends ActionInterface { } diff --git a/app/code/Magento/Customer/Controller/Address/FormPost.php b/app/code/Magento/Customer/Controller/Address/FormPost.php index b19a03a7ca821..21334f51b1752 100644 --- a/app/code/Magento/Customer/Controller/Address/FormPost.php +++ b/app/code/Magento/Customer/Controller/Address/FormPost.php @@ -224,7 +224,7 @@ public function execute() * * @return Mapper * - * @deprecated + * @deprecated 100.1.3 */ private function getCustomerAddressMapper() { diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index.php b/app/code/Magento/Customer/Controller/Adminhtml/Index.php index 4417f2c61c892..a0317a51260da 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index.php @@ -35,7 +35,7 @@ abstract class Index extends \Magento\Backend\App\Action /** * @var \Magento\Framework\Validator - * @deprecated + * @deprecated 100.2.0 */ protected $_validator; @@ -53,13 +53,13 @@ abstract class Index extends \Magento\Backend\App\Action /** * @var \Magento\Customer\Model\CustomerFactory - * @deprecated + * @deprecated 100.2.0 */ protected $_customerFactory = null; /** * @var \Magento\Customer\Model\AddressFactory - * @deprecated + * @deprecated 100.2.0 */ protected $_addressFactory = null; @@ -85,7 +85,7 @@ abstract class Index extends \Magento\Backend\App\Action /** * @var \Magento\Framework\Math\Random - * @deprecated + * @deprecated 100.2.0 */ protected $_random; @@ -96,7 +96,7 @@ abstract class Index extends \Magento\Backend\App\Action /** * @var \Magento\Framework\Api\ExtensibleDataObjectConverter - * @deprecated + * @deprecated 100.2.0 */ protected $_extensibleDataObjectConverter; @@ -132,7 +132,7 @@ abstract class Index extends \Magento\Backend\App\Action /** * @var \Magento\Framework\Reflection\DataObjectProcessor - * @deprecated + * @deprecated 100.2.0 */ protected $dataObjectProcessor; @@ -143,7 +143,7 @@ abstract class Index extends \Magento\Backend\App\Action /** * @var \Magento\Framework\View\LayoutFactory - * @deprecated + * @deprecated 100.2.0 */ protected $layoutFactory; @@ -306,7 +306,7 @@ protected function _addSessionErrorMessages($messages) * @param callable $singleAction A single action callable that takes a customer ID as input * @param int[] $customerIds Array of customer Ids to perform the action upon * @return int Number of customers successfully acted upon - * @deprecated + * @deprecated 100.2.0 */ protected function actUponMultipleCustomers(callable $singleAction, $customerIds) { diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/Cart.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/Cart.php index d81e7e0ec7802..1e4c1fb001ea3 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index/Cart.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/Cart.php @@ -16,7 +16,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - * @deprecated + * @deprecated 100.2.0 */ class Cart extends \Magento\Customer\Controller\Adminhtml\Index { diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/InlineEdit.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/InlineEdit.php index 95b12ef1c1eb8..2d0ee3ae13da4 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index/InlineEdit.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/InlineEdit.php @@ -24,25 +24,39 @@ class InlineEdit extends \Magento\Backend\App\Action */ const ADMIN_RESOURCE = 'Magento_Customer::manage'; - /** @var CustomerInterface */ + /** + * @var \Magento\Customer\Api\Data\CustomerInterface + */ private $customer; - /** @var CustomerRepositoryInterface */ + /** + * @var \Magento\Customer\Api\CustomerRepositoryInterface + */ protected $customerRepository; - /** @var \Magento\Framework\Controller\Result\JsonFactory */ + /** + * @var \Magento\Framework\Controller\Result\JsonFactory + */ protected $resultJsonFactory; - /** @var \Magento\Customer\Model\Customer\Mapper */ + /** + * @var \Magento\Customer\Model\Customer\Mapper + */ protected $customerMapper; - /** @var \Magento\Framework\Api\DataObjectHelper */ + /** + * @var \Magento\Framework\Api\DataObjectHelper + */ protected $dataObjectHelper; - /** @var \Psr\Log\LoggerInterface */ + /** + * @var \Psr\Log\LoggerInterface + */ protected $logger; - /** @var EmailNotificationInterface */ + /** + * @var \Magento\Customer\Model\EmailNotificationInterface + */ private $emailNotification; /** @@ -73,7 +87,7 @@ public function __construct( * Get email notification * * @return EmailNotificationInterface - * @deprecated + * @deprecated 100.1.0 */ private function getEmailNotification() { diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php index 283dfe3da78f2..44eba83d96d7e 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php @@ -301,7 +301,7 @@ public function execute() * Get email notification * * @return EmailNotificationInterface - * @deprecated + * @deprecated 100.1.0 */ private function getEmailNotification() { diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Locks/Unlock.php b/app/code/Magento/Customer/Controller/Adminhtml/Locks/Unlock.php index 864e9af6d8bcc..1fd06a3182948 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Locks/Unlock.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Locks/Unlock.php @@ -15,6 +15,13 @@ */ class Unlock extends \Magento\Backend\App\Action { + /** + * Authorization level of a basic admin session + * + * @see _isAllowed() + */ + const ADMIN_RESOURCE = 'Magento_Customer::manage'; + /** * Authentication * diff --git a/app/code/Magento/Customer/Controller/Adminhtml/System/Config/Validatevat.php b/app/code/Magento/Customer/Controller/Adminhtml/System/Config/Validatevat.php index 87fcfc09ffbb6..31d23c9e3694e 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/System/Config/Validatevat.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/System/Config/Validatevat.php @@ -12,6 +12,13 @@ */ abstract class Validatevat extends \Magento\Backend\App\Action { + /** + * Authorization level of a basic admin session + * + * @see _isAllowed() + */ + const ADMIN_RESOURCE = 'Magento_Customer::manage'; + /** * Perform customer VAT ID validation * diff --git a/app/code/Magento/Customer/Controller/Ajax/Login.php b/app/code/Magento/Customer/Controller/Ajax/Login.php index ae3aaf7fd29b0..f1384ba188a0a 100644 --- a/app/code/Magento/Customer/Controller/Ajax/Login.php +++ b/app/code/Magento/Customer/Controller/Ajax/Login.php @@ -88,7 +88,7 @@ public function __construct( * Get account redirect. * For release backward compatibility. * - * @deprecated + * @deprecated 100.0.10 * @return AccountRedirect */ protected function getAccountRedirect() @@ -102,7 +102,7 @@ protected function getAccountRedirect() /** * Account redirect setter for unit tests. * - * @deprecated + * @deprecated 100.0.10 * @param AccountRedirect $value * @return void */ @@ -112,7 +112,7 @@ public function setAccountRedirect($value) } /** - * @deprecated + * @deprecated 100.0.10 * @return ScopeConfigInterface */ protected function getScopeConfig() @@ -124,7 +124,7 @@ protected function getScopeConfig() } /** - * @deprecated + * @deprecated 100.0.10 * @param ScopeConfigInterface $value * @return void */ diff --git a/app/code/Magento/Customer/Controller/Section/Load.php b/app/code/Magento/Customer/Controller/Section/Load.php index 8c7a00aafc1ed..71775ff8f8ce1 100644 --- a/app/code/Magento/Customer/Controller/Section/Load.php +++ b/app/code/Magento/Customer/Controller/Section/Load.php @@ -22,7 +22,7 @@ class Load extends \Magento\Framework\App\Action\Action /** * @var Identifier - * @deprecated + * @deprecated 100.2.0 */ protected $sectionIdentifier; diff --git a/app/code/Magento/Customer/CustomerData/JsLayoutDataProviderInterface.php b/app/code/Magento/Customer/CustomerData/JsLayoutDataProviderInterface.php index 41453d658e2f5..4685f3c12f0d5 100644 --- a/app/code/Magento/Customer/CustomerData/JsLayoutDataProviderInterface.php +++ b/app/code/Magento/Customer/CustomerData/JsLayoutDataProviderInterface.php @@ -10,6 +10,7 @@ * Js layout data provider interface * * @api + * @since 100.0.2 */ interface JsLayoutDataProviderInterface { diff --git a/app/code/Magento/Customer/CustomerData/JsLayoutDataProviderPool.php b/app/code/Magento/Customer/CustomerData/JsLayoutDataProviderPool.php index a2d7462d41c6f..c6844d9070175 100644 --- a/app/code/Magento/Customer/CustomerData/JsLayoutDataProviderPool.php +++ b/app/code/Magento/Customer/CustomerData/JsLayoutDataProviderPool.php @@ -10,6 +10,7 @@ * Js layout data provider pool * * @api + * @since 100.0.2 */ class JsLayoutDataProviderPool implements JsLayoutDataProviderPoolInterface { diff --git a/app/code/Magento/Customer/CustomerData/SectionPool.php b/app/code/Magento/Customer/CustomerData/SectionPool.php index b4e9853b24fb7..26e9140c63df5 100644 --- a/app/code/Magento/Customer/CustomerData/SectionPool.php +++ b/app/code/Magento/Customer/CustomerData/SectionPool.php @@ -12,6 +12,7 @@ * Section pool * * @api + * @since 100.0.2 */ class SectionPool implements SectionPoolInterface { diff --git a/app/code/Magento/Customer/CustomerData/SectionSourceInterface.php b/app/code/Magento/Customer/CustomerData/SectionSourceInterface.php index f53a4ae4de65b..fbf0b6d48a39e 100644 --- a/app/code/Magento/Customer/CustomerData/SectionSourceInterface.php +++ b/app/code/Magento/Customer/CustomerData/SectionSourceInterface.php @@ -9,6 +9,7 @@ * Section source interface * * @api Use to define data sections in customer data which are transported from backend to frontend local storage + * @since 100.0.2 */ interface SectionSourceInterface { diff --git a/app/code/Magento/Customer/Helper/Address.php b/app/code/Magento/Customer/Helper/Address.php index 8394fb10edcec..8dac704aaa085 100644 --- a/app/code/Magento/Customer/Helper/Address.php +++ b/app/code/Magento/Customer/Helper/Address.php @@ -8,7 +8,9 @@ use Magento\Customer\Api\AddressMetadataInterface; use Magento\Customer\Api\CustomerMetadataInterface; use Magento\Customer\Api\Data\AttributeMetadataInterface; +use Magento\Customer\Model\Metadata\AttributeResolver; use Magento\Directory\Model\Country\Format; +use Magento\Framework\App\ObjectManager; use Magento\Framework\Exception\NoSuchEntityException; /** @@ -16,6 +18,7 @@ * * @api * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class Address extends \Magento\Framework\App\Helper\AbstractHelper { @@ -65,25 +68,38 @@ class Address extends \Magento\Framework\App\Helper\AbstractHelper */ protected $_formatTemplate = []; - /** @var \Magento\Framework\View\Element\BlockFactory */ + /** + * @var \Magento\Framework\View\Element\BlockFactory + */ protected $_blockFactory; - /** @var \Magento\Store\Model\StoreManagerInterface */ + /** + * @var \Magento\Store\Model\StoreManagerInterface + */ protected $_storeManager; /** * @var CustomerMetadataInterface * - * @deprecated + * @deprecated 100.2.0 */ protected $_customerMetadataService; - /** @var AddressMetadataInterface */ + /** + * @var \Magento\Customer\Api\AddressMetadataInterface + */ protected $_addressMetadataService; - /** @var \Magento\Customer\Model\Address\Config*/ + /** + * @var \Magento\Customer\Model\Address\Config + */ protected $_addressConfig; + /** + * @var AttributeResolver + */ + private $attributeResolver; + /** * @param \Magento\Framework\App\Helper\Context $context * @param \Magento\Framework\View\Element\BlockFactory $blockFactory @@ -91,6 +107,7 @@ class Address extends \Magento\Framework\App\Helper\AbstractHelper * @param CustomerMetadataInterface $customerMetadataService * @param AddressMetadataInterface $addressMetadataService * @param \Magento\Customer\Model\Address\Config $addressConfig + * @param AttributeResolver|null $attributeResolver */ public function __construct( \Magento\Framework\App\Helper\Context $context, @@ -98,13 +115,15 @@ public function __construct( \Magento\Store\Model\StoreManagerInterface $storeManager, CustomerMetadataInterface $customerMetadataService, AddressMetadataInterface $addressMetadataService, - \Magento\Customer\Model\Address\Config $addressConfig + \Magento\Customer\Model\Address\Config $addressConfig, + AttributeResolver $attributeResolver = null ) { $this->_blockFactory = $blockFactory; $this->_storeManager = $storeManager; $this->_customerMetadataService = $customerMetadataService; $this->_addressMetadataService = $addressMetadataService; $this->_addressConfig = $addressConfig; + $this->attributeResolver = $attributeResolver ?: ObjectManager::getInstance()->get(AttributeResolver::class); parent::__construct($context); } @@ -372,6 +391,7 @@ public function isVatAttributeVisible() * * @param string $code * @return bool + * @since 100.2.0 */ public function isAttributeVisible($code) { @@ -381,4 +401,31 @@ public function isAttributeVisible($code) } return false; } + + /** + * Checks whether it is allowed to show an attribute on the form + * + * This check relies on the attribute's property 'getUsedInForms' which contains a list of forms + * where allowed to render specified attribute. + * + * @param string $attributeCode + * @param string $formName + * @return bool + */ + public function isAttributeAllowedOnForm($attributeCode, $formName) + { + $isAllowed = false; + $attributeMetadata = $this->_addressMetadataService->getAttributeMetadata($attributeCode); + if ($attributeMetadata) { + /** @var \Magento\Customer\Model\Attribute $attribute */ + $attribute = $this->attributeResolver->getModelByAttribute( + \Magento\Customer\Api\AddressMetadataManagementInterface::ENTITY_TYPE_ADDRESS, + $attributeMetadata + ); + $usedInForms = $attribute->getUsedInForms(); + $isAllowed = in_array($formName, $usedInForms, true); + } + + return $isAllowed; + } } diff --git a/app/code/Magento/Customer/Model/Account/Redirect.php b/app/code/Magento/Customer/Model/Account/Redirect.php index 689cc1b4821cb..d8ccbba243adf 100644 --- a/app/code/Magento/Customer/Model/Account/Redirect.php +++ b/app/code/Magento/Customer/Model/Account/Redirect.php @@ -54,7 +54,7 @@ class Redirect protected $customerUrl; /** - * @deprecated + * @deprecated 100.2.0 * @var UrlInterface */ protected $url; @@ -229,7 +229,7 @@ private function applyRedirect($url) /** * Get Cookie manager. For release backward compatibility. * - * @deprecated + * @deprecated 100.0.10 * @return CookieManagerInterface */ protected function getCookieManager() @@ -243,7 +243,7 @@ protected function getCookieManager() /** * Set cookie manager. For unit tests. * - * @deprecated + * @deprecated 100.0.10 * @param object $value * @return void */ diff --git a/app/code/Magento/Customer/Model/AccountManagement.php b/app/code/Magento/Customer/Model/AccountManagement.php index 754fe9b68a190..b7b099ec45232 100644 --- a/app/code/Magento/Customer/Model/AccountManagement.php +++ b/app/code/Magento/Customer/Model/AccountManagement.php @@ -996,7 +996,7 @@ public function isReadonly($customerId) * @param string $sendemailStoreId * @return $this * @throws LocalizedException - * @deprecated + * @deprecated 100.1.0 */ protected function sendNewAccountEmail( $customer, @@ -1035,7 +1035,7 @@ protected function sendNewAccountEmail( * * @param CustomerInterface $customer * @return $this - * @deprecated + * @deprecated 100.1.0 */ protected function sendPasswordResetNotificationEmail($customer) { @@ -1048,7 +1048,7 @@ protected function sendPasswordResetNotificationEmail($customer) * @param CustomerInterface $customer * @param int|string|null $defaultStoreId * @return int - * @deprecated + * @deprecated 100.1.0 */ protected function getWebsiteStoreId($customer, $defaultStoreId = null) { @@ -1062,7 +1062,7 @@ protected function getWebsiteStoreId($customer, $defaultStoreId = null) /** * @return array - * @deprecated + * @deprecated 100.1.0 */ protected function getTemplateTypes() { @@ -1094,7 +1094,7 @@ protected function getTemplateTypes() * @param int|null $storeId * @param string $email * @return $this - * @deprecated + * @deprecated 100.1.0 */ protected function sendEmailTemplate( $customer, @@ -1226,7 +1226,7 @@ public function changeResetPasswordLinkToken($customer, $passwordLinkToken) * * @param CustomerInterface $customer * @return $this - * @deprecated + * @deprecated 100.1.0 */ public function sendPasswordReminderEmail($customer) { @@ -1253,7 +1253,7 @@ public function sendPasswordReminderEmail($customer) * * @param CustomerInterface $customer * @return $this - * @deprecated + * @deprecated 100.1.0 */ public function sendPasswordResetConfirmationEmail($customer) { @@ -1297,7 +1297,7 @@ protected function getAddressById(CustomerInterface $customer, $addressId) * * @param CustomerInterface $customer * @return Data\CustomerSecure - * @deprecated + * @deprecated 100.1.0 */ protected function getFullCustomerObject($customer) { @@ -1326,7 +1326,7 @@ public function getPasswordHash($password) * Get email notification * * @return EmailNotificationInterface - * @deprecated + * @deprecated 100.1.0 */ private function getEmailNotification() { diff --git a/app/code/Magento/Customer/Model/Address.php b/app/code/Magento/Customer/Model/Address.php index b4060b7287da5..1dcd8516af69f 100644 --- a/app/code/Magento/Customer/Model/Address.php +++ b/app/code/Magento/Customer/Model/Address.php @@ -18,6 +18,7 @@ * @method int getParentId() getParentId() * @method \Magento\Customer\Model\Address setParentId() setParentId(int $parentId) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class Address extends \Magento\Customer\Model\Address\AbstractAddress { @@ -351,13 +352,12 @@ public function reindex() { /** @var \Magento\Framework\Indexer\IndexerInterface $indexer */ $indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID); - if (!$indexer->isScheduled()) { - $indexer->reindexRow($this->getCustomerId()); - } + $indexer->reindexRow($this->getCustomerId()); } /** * {@inheritdoc} + * @since 100.0.6 */ protected function getCustomAttributesCodes() { @@ -367,7 +367,7 @@ protected function getCustomAttributesCodes() /** * Get new AttributeList dependency for application code. * @return \Magento\Customer\Model\Address\CustomAttributeListInterface - * @deprecated + * @deprecated 100.0.6 */ private function getAttributeList() { @@ -383,6 +383,7 @@ private function getAttributeList() * Retrieve attribute set id for customer address. * * @return int + * @since 100.2.0 */ public function getAttributeSetId() { diff --git a/app/code/Magento/Customer/Model/Address/AbstractAddress.php b/app/code/Magento/Customer/Model/Address/AbstractAddress.php index 2ed715a774513..3b141d4cb7f68 100644 --- a/app/code/Magento/Customer/Model/Address/AbstractAddress.php +++ b/app/code/Magento/Customer/Model/Address/AbstractAddress.php @@ -32,6 +32,7 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * * @api + * @since 100.0.2 */ class AbstractAddress extends AbstractExtensibleModel implements AddressModelInterface { @@ -653,6 +654,7 @@ protected function _createCountryInstance() /** * Unset Region from address * @return $this + * @since 100.2.0 */ public function unsRegion() { @@ -661,6 +663,7 @@ public function unsRegion() /** * @return bool + * @since 100.2.0 */ protected function isCompanyRequired() { @@ -669,6 +672,7 @@ protected function isCompanyRequired() /** * @return bool + * @since 100.2.0 */ protected function isTelephoneRequired() { @@ -677,6 +681,7 @@ protected function isTelephoneRequired() /** * @return bool + * @since 100.2.0 */ protected function isFaxRequired() { diff --git a/app/code/Magento/Customer/Model/Address/AddressModelInterface.php b/app/code/Magento/Customer/Model/Address/AddressModelInterface.php index 1b2a62591a1f8..0af36e877555f 100644 --- a/app/code/Magento/Customer/Model/Address/AddressModelInterface.php +++ b/app/code/Magento/Customer/Model/Address/AddressModelInterface.php @@ -10,6 +10,7 @@ * Interface AddressInterface * * @api + * @since 100.0.2 */ interface AddressModelInterface { diff --git a/app/code/Magento/Customer/Model/Address/CustomAttributeListInterface.php b/app/code/Magento/Customer/Model/Address/CustomAttributeListInterface.php index 186c57b685569..6fd6cb3511f2c 100644 --- a/app/code/Magento/Customer/Model/Address/CustomAttributeListInterface.php +++ b/app/code/Magento/Customer/Model/Address/CustomAttributeListInterface.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.6 */ interface CustomAttributeListInterface { @@ -14,6 +15,7 @@ interface CustomAttributeListInterface * Retrieve list of customer addresses custom attributes * * @return array + * @since 100.0.6 */ public function getAttributes(); } diff --git a/app/code/Magento/Customer/Model/Authentication.php b/app/code/Magento/Customer/Model/Authentication.php index e56f85e6fb854..0967f1a0189e3 100644 --- a/app/code/Magento/Customer/Model/Authentication.php +++ b/app/code/Magento/Customer/Model/Authentication.php @@ -181,7 +181,7 @@ public function authenticate($customerId, $password) * Get customer authentication update model * * @return \Magento\Customer\Model\CustomerAuthUpdate - * @deprecated + * @deprecated 100.1.1 */ private function getCustomerAuthUpdate() { diff --git a/app/code/Magento/Customer/Model/AuthenticationInterface.php b/app/code/Magento/Customer/Model/AuthenticationInterface.php index c902b39778092..bc99337f3b8bf 100644 --- a/app/code/Magento/Customer/Model/AuthenticationInterface.php +++ b/app/code/Magento/Customer/Model/AuthenticationInterface.php @@ -8,6 +8,10 @@ use Magento\Framework\Exception\InvalidEmailOrPasswordException; use Magento\Framework\Exception\State\UserLockedException; +/** + * Interface \Magento\Customer\Model\AuthenticationInterface + * + */ interface AuthenticationInterface { /** diff --git a/app/code/Magento/Customer/Model/Config/Backend/Address/Street.php b/app/code/Magento/Customer/Model/Config/Backend/Address/Street.php index 26405b7e6fc71..fc0fa3ebc073d 100644 --- a/app/code/Magento/Customer/Model/Config/Backend/Address/Street.php +++ b/app/code/Magento/Customer/Model/Config/Backend/Address/Street.php @@ -19,7 +19,9 @@ class Street extends \Magento\Framework\App\Config\Value */ protected $_eavConfig; - /** @var \Magento\Store\Model\StoreManagerInterface */ + /** + * @var \Magento\Store\Model\StoreManagerInterface + */ protected $_storeManager; /** diff --git a/app/code/Magento/Customer/Model/Config/Backend/Show/Customer.php b/app/code/Magento/Customer/Model/Config/Backend/Show/Customer.php index 369c6d15412f6..102a78d5ea3d2 100644 --- a/app/code/Magento/Customer/Model/Config/Backend/Show/Customer.php +++ b/app/code/Magento/Customer/Model/Config/Backend/Show/Customer.php @@ -19,7 +19,9 @@ class Customer extends \Magento\Framework\App\Config\Value */ protected $_eavConfig; - /** @var \Magento\Store\Model\StoreManagerInterface */ + /** + * @var \Magento\Store\Model\StoreManagerInterface + */ protected $storeManager; /** diff --git a/app/code/Magento/Customer/Model/Config/Share.php b/app/code/Magento/Customer/Model/Config/Share.php index 86a71b5cf6234..e5dda28afa095 100644 --- a/app/code/Magento/Customer/Model/Config/Share.php +++ b/app/code/Magento/Customer/Model/Config/Share.php @@ -31,7 +31,9 @@ class Share extends \Magento\Framework\App\Config\Value implements \Magento\Fram */ protected $_customerResource; - /** @var \Magento\Store\Model\StoreManagerInterface */ + /** + * @var \Magento\Store\Model\StoreManagerInterface + */ protected $_storeManager; /** diff --git a/app/code/Magento/Customer/Model/Config/Source/Group.php b/app/code/Magento/Customer/Model/Config/Source/Group.php index bc9b23bf3de4a..7132b8ad4cedf 100644 --- a/app/code/Magento/Customer/Model/Config/Source/Group.php +++ b/app/code/Magento/Customer/Model/Config/Source/Group.php @@ -17,13 +17,13 @@ class Group implements \Magento\Framework\Option\ArrayInterface protected $_options; /** - * @deprecated + * @deprecated 100.2.0 * @var GroupManagementInterface */ protected $_groupManagement; /** - * @deprecated + * @deprecated 100.2.0 * @var \Magento\Framework\Convert\DataObject */ protected $_converter; diff --git a/app/code/Magento/Customer/Model/Config/Source/Group/Multiselect.php b/app/code/Magento/Customer/Model/Config/Source/Group/Multiselect.php index 5ce6c5241a185..bf1fae8d34bed 100644 --- a/app/code/Magento/Customer/Model/Config/Source/Group/Multiselect.php +++ b/app/code/Magento/Customer/Model/Config/Source/Group/Multiselect.php @@ -19,13 +19,13 @@ class Multiselect implements \Magento\Framework\Option\ArrayInterface protected $_options; /** - * @deprecated + * @deprecated 100.2.0 * @var GroupManagementInterface */ protected $_groupManagement; /** - * @deprecated + * @deprecated 100.2.0 * @var \Magento\Framework\Convert\DataObject */ protected $_converter; diff --git a/app/code/Magento/Customer/Model/Customer.php b/app/code/Magento/Customer/Model/Customer.php index 98c89fdd69588..2e2260f16ff91 100644 --- a/app/code/Magento/Customer/Model/Customer.php +++ b/app/code/Magento/Customer/Model/Customer.php @@ -27,7 +27,6 @@ * @method Customer setWebsiteId($value) * @method int getStoreId() getStoreId() * @method string getEmail() getEmail() - * @method ResourceCustomer _getResource() * @method mixed getDisableAutoGroupChange() * @method Customer setDisableAutoGroupChange($value) * @method Customer setGroupId($value) @@ -40,6 +39,7 @@ * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class Customer extends \Magento\Framework\Model\AbstractModel { @@ -968,7 +968,7 @@ public function setStore(\Magento\Store\Model\Store $store) /** * Validate customer attribute values. * - * @deprecated + * @deprecated 100.1.0 * @return bool */ public function validate() @@ -1077,9 +1077,7 @@ public function reindex() { /** @var \Magento\Framework\Indexer\IndexerInterface $indexer */ $indexer = $this->indexerRegistry->get(self::CUSTOMER_GRID_INDEXER_ID); - if (!$indexer->isScheduled()) { - $indexer->reindexRow($this->getId()); - } + $indexer->reindexRow($this->getId()); } /** @@ -1320,6 +1318,7 @@ protected function getTemplateTypes() * Check if customer is locked * * @return boolean + * @since 100.1.0 */ public function isCustomerLocked() { @@ -1336,6 +1335,7 @@ public function isCustomerLocked() * Return Password Confirmation * * @return string + * @since 100.1.0 */ public function getPasswordConfirm() { @@ -1346,6 +1346,7 @@ public function getPasswordConfirm() * Return Password * * @return string + * @since 100.1.0 */ public function getPassword() { diff --git a/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Password.php b/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Password.php index 053ae6ab2076b..abdec5535e86b 100644 --- a/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Password.php +++ b/app/code/Magento/Customer/Model/Customer/Attribute/Backend/Password.php @@ -8,7 +8,7 @@ use Magento\Framework\Exception\LocalizedException; /** - * @deprecated + * @deprecated 100.2.0 * Customer password attribute backend */ class Password extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend @@ -63,7 +63,7 @@ public function beforeSave($object) } /** - * @deprecated + * @deprecated 100.2.0 * @param \Magento\Framework\DataObject $object * @return bool */ diff --git a/app/code/Magento/Customer/Model/Customer/Attribute/Source/GroupSourceLoggedInOnlyInterface.php b/app/code/Magento/Customer/Model/Customer/Attribute/Source/GroupSourceLoggedInOnlyInterface.php index bd1c324e22ee0..e57053118300e 100644 --- a/app/code/Magento/Customer/Model/Customer/Attribute/Source/GroupSourceLoggedInOnlyInterface.php +++ b/app/code/Magento/Customer/Model/Customer/Attribute/Source/GroupSourceLoggedInOnlyInterface.php @@ -8,6 +8,10 @@ use \Magento\Framework\Data\OptionSourceInterface; +/** + * Interface \Magento\Customer\Model\Customer\Attribute\Source\GroupSourceLoggedInOnlyInterface + * + */ interface GroupSourceLoggedInOnlyInterface extends OptionSourceInterface { diff --git a/app/code/Magento/Customer/Model/Customer/DataProvider.php b/app/code/Magento/Customer/Model/Customer/DataProvider.php index 6b79e6d5d1857..ce976d3f62c74 100644 --- a/app/code/Magento/Customer/Model/Customer/DataProvider.php +++ b/app/code/Magento/Customer/Model/Customer/DataProvider.php @@ -29,10 +29,10 @@ use Magento\Ui\DataProvider\EavValidationRules; /** - * Class DataProvider * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * * @api + * @since 100.0.2 */ class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider { @@ -104,6 +104,7 @@ class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider /** * @var SessionManagerInterface + * @since 100.1.0 */ protected $session; @@ -123,6 +124,17 @@ class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider ]; /** + * Customer fields that must be removed + * + * @var array + */ + private $forbiddenCustomerFields = [ + 'password_hash', + 'rp_token', + 'confirmation', + ]; + + /* * @var ContextInterface */ private $context; @@ -184,8 +196,8 @@ public function __construct( * Get session object * * @return SessionManagerInterface - * - * @deprecated + * @deprecated 100.1.3 + * @since 100.1.0 */ protected function getSession() { @@ -214,6 +226,10 @@ public function getData() $this->overrideFileUploaderData($customer, $result['customer']); + $result['customer'] = array_diff_key( + $result['customer'], + array_flip($this->forbiddenCustomerFields) + ); unset($result['address']); /** @var Address $address */ @@ -403,8 +419,8 @@ private function canShowAttribute(AbstractAttribute $customerAttribute) /** * Retrieve Country With Websites Source * - * @deprecated * @return CountryWithWebsites + * @deprecated 100.2.0 */ private function getCountryWithWebsiteSource() { @@ -418,8 +434,8 @@ private function getCountryWithWebsiteSource() /** * Retrieve Customer Config Share * - * @deprecated * @return \Magento\Customer\Model\Config\Share + * @deprecated 100.1.3 */ private function getShareConfig() { @@ -589,8 +605,7 @@ protected function prepareAddressData($addressId, array &$addresses, array $cust * Get FileProcessorFactory instance * * @return FileProcessorFactory - * - * @deprecated + * @deprecated 100.1.3 */ private function getFileProcessorFactory() { diff --git a/app/code/Magento/Customer/Model/Customer/NotificationStorage.php b/app/code/Magento/Customer/Model/Customer/NotificationStorage.php index b1d7bb56f957b..7054324851f34 100644 --- a/app/code/Magento/Customer/Model/Customer/NotificationStorage.php +++ b/app/code/Magento/Customer/Model/Customer/NotificationStorage.php @@ -22,7 +22,7 @@ class NotificationStorage */ /** - * @var SerializerInterface + * @param FrontendInterface $cache */ private $serializer; @@ -93,7 +93,7 @@ private function getCacheKey($notificationType, $customerId) * Get serializer * * @return SerializerInterface - * @deprecated + * @deprecated 100.2.0 */ private function getSerializer() { diff --git a/app/code/Magento/Customer/Model/Customer/Source/GroupSourceInterface.php b/app/code/Magento/Customer/Model/Customer/Source/GroupSourceInterface.php index baa43e6391492..26be387a02f9c 100644 --- a/app/code/Magento/Customer/Model/Customer/Source/GroupSourceInterface.php +++ b/app/code/Magento/Customer/Model/Customer/Source/GroupSourceInterface.php @@ -9,6 +9,7 @@ /** * @api + * @since 100.2.0 */ interface GroupSourceInterface extends OptionSourceInterface { diff --git a/app/code/Magento/Customer/Model/Data/Address.php b/app/code/Magento/Customer/Model/Data/Address.php index 6c0eb1991c3bd..f4cf228fb557c 100644 --- a/app/code/Magento/Customer/Model/Data/Address.php +++ b/app/code/Magento/Customer/Model/Data/Address.php @@ -15,6 +15,7 @@ * * * @api + * @since 100.0.2 */ class Address extends \Magento\Framework\Api\AbstractExtensibleObject implements \Magento\Customer\Api\Data\AddressInterface diff --git a/app/code/Magento/Customer/Model/EmailNotification.php b/app/code/Magento/Customer/Model/EmailNotification.php index 853d300d70b3a..14ae9a885c7b1 100644 --- a/app/code/Magento/Customer/Model/EmailNotification.php +++ b/app/code/Magento/Customer/Model/EmailNotification.php @@ -62,9 +62,7 @@ class EmailNotification implements EmailNotificationInterface /**#@-*/ - /** - * @var CustomerRegistry - */ + /**#@-*/ private $customerRegistry; /** diff --git a/app/code/Magento/Customer/Model/EmailNotificationInterface.php b/app/code/Magento/Customer/Model/EmailNotificationInterface.php index 4a333bf96d5d3..0821abff04750 100644 --- a/app/code/Magento/Customer/Model/EmailNotificationInterface.php +++ b/app/code/Magento/Customer/Model/EmailNotificationInterface.php @@ -10,6 +10,7 @@ /** * @api + * @since 100.1.0 */ interface EmailNotificationInterface { @@ -40,6 +41,7 @@ interface EmailNotificationInterface * @param string $origCustomerEmail * @param bool $isPasswordChanged * @return void + * @since 100.1.0 */ public function credentialsChanged( CustomerInterface $savedCustomer, @@ -52,6 +54,7 @@ public function credentialsChanged( * * @param CustomerInterface $customer * @return void + * @since 100.1.0 */ public function passwordReminder(CustomerInterface $customer); @@ -60,6 +63,7 @@ public function passwordReminder(CustomerInterface $customer); * * @param CustomerInterface $customer * @return void + * @since 100.1.0 */ public function passwordResetConfirmation(CustomerInterface $customer); @@ -73,6 +77,7 @@ public function passwordResetConfirmation(CustomerInterface $customer); * @param string $sendemailStoreId * @return void * @throws LocalizedException + * @since 100.1.0 */ public function newAccount( CustomerInterface $customer, diff --git a/app/code/Magento/Customer/Model/FileProcessor.php b/app/code/Magento/Customer/Model/FileProcessor.php index d482d00748324..2d6917efdaf56 100644 --- a/app/code/Magento/Customer/Model/FileProcessor.php +++ b/app/code/Magento/Customer/Model/FileProcessor.php @@ -181,6 +181,7 @@ public function saveTemporaryFile($fileId) ); $result = $uploader->save($path); + unset($result['path']); if (!$result) { throw new \Magento\Framework\Exception\LocalizedException( __('File can not be saved to the destination folder.') diff --git a/app/code/Magento/Customer/Model/Group.php b/app/code/Magento/Customer/Model/Group.php index 74f773fd02853..9cb09a4ed3f0b 100644 --- a/app/code/Magento/Customer/Model/Group.php +++ b/app/code/Magento/Customer/Model/Group.php @@ -9,12 +9,11 @@ * Customer group model * * @api - * @method \Magento\Customer\Model\ResourceModel\Group _getResource() - * @method \Magento\Customer\Model\ResourceModel\Group getResource() * @method string getCustomerGroupCode() * @method \Magento\Customer\Model\Group setCustomerGroupCode(string $value) * @method \Magento\Customer\Model\Group setTaxClassId(int $value) * @method Group setTaxClassName(string $value) + * @since 100.0.2 */ class Group extends \Magento\Framework\Model\AbstractModel { diff --git a/app/code/Magento/Customer/Model/Group/Retriever.php b/app/code/Magento/Customer/Model/Group/Retriever.php new file mode 100644 index 0000000000000..3b3e0e635ec21 --- /dev/null +++ b/app/code/Magento/Customer/Model/Group/Retriever.php @@ -0,0 +1,35 @@ +customerSession = $customerSession; + } + + /** + * @inheritdoc + */ + public function getCustomerGroupId() + { + return $this->customerSession->getCustomerGroupId(); + } +} diff --git a/app/code/Magento/Customer/Model/Group/RetrieverInterface.php b/app/code/Magento/Customer/Model/Group/RetrieverInterface.php new file mode 100644 index 0000000000000..701465cb00f2d --- /dev/null +++ b/app/code/Magento/Customer/Model/Group/RetrieverInterface.php @@ -0,0 +1,21 @@ +setMessage( __('"%1" invalid type entered.', $label), \Zend_Validate_EmailAddress::INVALID @@ -377,10 +378,6 @@ protected function _validateInputRule($value) __("'%value%' looks like an IP address, which is not an acceptable format."), \Zend_Validate_Hostname::IP_ADDRESS_NOT_ALLOWED ); - $validator->setMessage( - __("'%value%' looks like a DNS hostname but we cannot match the TLD against known list."), - \Zend_Validate_Hostname::UNKNOWN_TLD - ); $validator->setMessage( __("'%value%' looks like a DNS hostname but contains a dash in an invalid position."), \Zend_Validate_Hostname::INVALID_DASH diff --git a/app/code/Magento/Customer/Model/Metadata/Form/File.php b/app/code/Magento/Customer/Model/Metadata/Form/File.php index cac840de0f833..e6e9c2b50c068 100644 --- a/app/code/Magento/Customer/Model/Metadata/Form/File.php +++ b/app/code/Magento/Customer/Model/Metadata/Form/File.php @@ -55,7 +55,7 @@ class File extends AbstractData /** * @var FileProcessorFactory - * @deprecated + * @deprecated 100.2.0 */ protected $fileProcessorFactory; @@ -386,7 +386,7 @@ public function outputValue($format = \Magento\Customer\Model\Metadata\ElementFa * Get file processor * * @return FileProcessor - * @deprecated + * @deprecated 100.1.3 */ protected function getFileProcessor() { diff --git a/app/code/Magento/Customer/Model/Observer/Grid.php b/app/code/Magento/Customer/Model/Observer/Grid.php index 293fbbf454005..d48bb518f9352 100644 --- a/app/code/Magento/Customer/Model/Observer/Grid.php +++ b/app/code/Magento/Customer/Model/Observer/Grid.php @@ -8,7 +8,7 @@ use Magento\Customer\Model\ResourceModel\Customer\Grid as CustomerGrid; /** - * @deprecated + * @deprecated 100.1.0 */ class Grid { @@ -29,7 +29,7 @@ public function __construct( /** * @return void * - * @deprecated + * @deprecated 100.1.0 */ public function syncCustomerGrid() { diff --git a/app/code/Magento/Customer/Model/Plugin/CustomerNotification.php b/app/code/Magento/Customer/Model/Plugin/CustomerNotification.php index 040ffb8f3baba..3f73c8cdaeed4 100644 --- a/app/code/Magento/Customer/Model/Plugin/CustomerNotification.php +++ b/app/code/Magento/Customer/Model/Plugin/CustomerNotification.php @@ -12,6 +12,8 @@ use Magento\Framework\App\Area; use Magento\Framework\App\RequestInterface; use Magento\Framework\App\State; +use Magento\Framework\Exception\NoSuchEntityException; +use Psr\Log\LoggerInterface; class CustomerNotification { @@ -35,6 +37,11 @@ class CustomerNotification */ private $state; + /** + * @var LoggerInterface + */ + private $logger; + /** * Initialize dependencies. * @@ -42,17 +49,20 @@ class CustomerNotification * @param NotificationStorage $notificationStorage * @param State $state * @param CustomerRepositoryInterface $customerRepository + * @param LoggerInterface $logger */ public function __construct( Session $session, NotificationStorage $notificationStorage, State $state, - CustomerRepositoryInterface $customerRepository + CustomerRepositoryInterface $customerRepository, + LoggerInterface $logger ) { $this->session = $session; $this->notificationStorage = $notificationStorage; $this->state = $state; $this->customerRepository = $customerRepository; + $this->logger = $logger; } /** @@ -63,17 +73,23 @@ public function __construct( */ public function beforeDispatch(AbstractAction $subject, RequestInterface $request) { + $customerId = $this->session->getCustomerId(); + if ($this->state->getAreaCode() == Area::AREA_FRONTEND && $request->isPost() && $this->notificationStorage->isExists( NotificationStorage::UPDATE_CUSTOMER_SESSION, - $this->session->getCustomerId() + $customerId ) ) { - $customer = $this->customerRepository->getById($this->session->getCustomerId()); - $this->session->setCustomerData($customer); - $this->session->setCustomerGroupId($customer->getGroupId()); - $this->session->regenerateId(); - $this->notificationStorage->remove(NotificationStorage::UPDATE_CUSTOMER_SESSION, $customer->getId()); + try { + $customer = $this->customerRepository->getById($customerId); + $this->session->setCustomerData($customer); + $this->session->setCustomerGroupId($customer->getGroupId()); + $this->session->regenerateId(); + $this->notificationStorage->remove(NotificationStorage::UPDATE_CUSTOMER_SESSION, $customerId); + } catch (NoSuchEntityException $e) { + $this->logger->error($e); + } } } } diff --git a/app/code/Magento/Customer/Model/Registration.php b/app/code/Magento/Customer/Model/Registration.php index effede4dc7c73..031afde830b25 100644 --- a/app/code/Magento/Customer/Model/Registration.php +++ b/app/code/Magento/Customer/Model/Registration.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Registration { diff --git a/app/code/Magento/Customer/Model/ResourceModel/Address.php b/app/code/Magento/Customer/Model/ResourceModel/Address.php index 73cdcb26e162c..a52c372310843 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/Address.php +++ b/app/code/Magento/Customer/Model/ResourceModel/Address.php @@ -120,7 +120,7 @@ public function delete($object) } /** - * @deprecated + * @deprecated 100.2.0 * @return DeleteRelation */ private function getDeleteRelation() @@ -129,7 +129,7 @@ private function getDeleteRelation() } /** - * @deprecated + * @deprecated 100.2.0 * @return CustomerRegistry */ private function getCustomerRegistry() diff --git a/app/code/Magento/Customer/Model/ResourceModel/Address/Attribute/Source/Country.php b/app/code/Magento/Customer/Model/ResourceModel/Address/Attribute/Source/Country.php index e0c271a82185c..cf7105c1519af 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/Address/Attribute/Source/Country.php +++ b/app/code/Magento/Customer/Model/ResourceModel/Address/Attribute/Source/Country.php @@ -69,7 +69,7 @@ protected function _createCountriesCollection() /** * Retrieve Store Manager - * @deprecated + * @deprecated 100.2.0 * @return StoreManagerInterface */ private function getStoreManager() diff --git a/app/code/Magento/Customer/Model/ResourceModel/Address/Collection.php b/app/code/Magento/Customer/Model/ResourceModel/Address/Collection.php index 47ac6d60652d6..a26228ccc9062 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/Address/Collection.php +++ b/app/code/Magento/Customer/Model/ResourceModel/Address/Collection.php @@ -10,6 +10,7 @@ * * @api * @author Magento Core Team + * @since 100.0.2 */ class Collection extends \Magento\Eav\Model\Entity\Collection\VersionControl\AbstractCollection { diff --git a/app/code/Magento/Customer/Model/ResourceModel/AddressRepository.php b/app/code/Magento/Customer/Model/ResourceModel/AddressRepository.php index 18f0bba97425d..2c7b778f5f485 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/AddressRepository.php +++ b/app/code/Magento/Customer/Model/ResourceModel/AddressRepository.php @@ -203,7 +203,7 @@ public function getList(SearchCriteriaInterface $searchCriteria) /** * Helper function that adds a FilterGroup to the collection. * - * @deprecated + * @deprecated 100.2.0 * @param FilterGroup $filterGroup * @param Collection $collection * @return void @@ -262,7 +262,7 @@ public function deleteById($addressId) /** * Retrieve collection processor * - * @deprecated + * @deprecated 100.2.0 * @return CollectionProcessorInterface */ private function getCollectionProcessor() diff --git a/app/code/Magento/Customer/Model/ResourceModel/Customer.php b/app/code/Magento/Customer/Model/ResourceModel/Customer.php index 8c1f9403df76b..7e5f9d51549ec 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/Customer.php +++ b/app/code/Magento/Customer/Model/ResourceModel/Customer.php @@ -15,6 +15,7 @@ * * @api * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class Customer extends \Magento\Eav\Model\Entity\VersionControl\AbstractEntity { diff --git a/app/code/Magento/Customer/Model/ResourceModel/Customer/Grid.php b/app/code/Magento/Customer/Model/ResourceModel/Customer/Grid.php index 3dc0866f84d5d..281abc77d2267 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/Customer/Grid.php +++ b/app/code/Magento/Customer/Model/ResourceModel/Customer/Grid.php @@ -11,11 +11,13 @@ use Magento\Customer\Model\Customer; /** - * @deprecated + * @deprecated 100.1.0 */ class Grid { - /** @var Resource */ + /** + * @var resource + */ protected $resource; /** @@ -23,7 +25,9 @@ class Grid */ protected $indexerRegistry; - /** @var FlatScopeResolver */ + /** + * @var \Magento\Framework\Indexer\ScopeResolver\FlatScopeResolver + */ protected $flatScopeResolver; /** @@ -46,7 +50,7 @@ public function __construct( * * @return void * - * @deprecated + * @deprecated 100.1.0 */ public function syncCustomerGrid() { @@ -62,7 +66,7 @@ public function syncCustomerGrid() * * @return array * - * @deprecated + * @deprecated 100.1.0 */ protected function getCustomerIdsForReindex() { diff --git a/app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php b/app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php index 1584b7fd86094..a87f32d945070 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php +++ b/app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php @@ -7,6 +7,7 @@ namespace Magento\Customer\Model\ResourceModel; use Magento\Customer\Api\CustomerMetadataInterface; +use Magento\Customer\Model\Customer\NotificationStorage; use Magento\Framework\Api\DataObjectHelper; use Magento\Framework\Api\ImageProcessorInterface; use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface; @@ -88,6 +89,11 @@ class CustomerRepository implements \Magento\Customer\Api\CustomerRepositoryInte */ private $collectionProcessor; + /** + * @var NotificationStorage + */ + private $notificationStorage; + /** * @param \Magento\Customer\Model\CustomerFactory $customerFactory * @param \Magento\Customer\Model\Data\CustomerSecureFactory $customerSecureFactory @@ -103,6 +109,7 @@ class CustomerRepository implements \Magento\Customer\Api\CustomerRepositoryInte * @param ImageProcessorInterface $imageProcessor * @param \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $extensionAttributesJoinProcessor * @param CollectionProcessorInterface $collectionProcessor + * @param NotificationStorage $notificationStorage * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -119,7 +126,8 @@ public function __construct( DataObjectHelper $dataObjectHelper, ImageProcessorInterface $imageProcessor, \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $extensionAttributesJoinProcessor, - CollectionProcessorInterface $collectionProcessor = null + CollectionProcessorInterface $collectionProcessor, + NotificationStorage $notificationStorage ) { $this->customerFactory = $customerFactory; $this->customerSecureFactory = $customerSecureFactory; @@ -134,7 +142,8 @@ public function __construct( $this->dataObjectHelper = $dataObjectHelper; $this->imageProcessor = $imageProcessor; $this->extensionAttributesJoinProcessor = $extensionAttributesJoinProcessor; - $this->collectionProcessor = $collectionProcessor ?: $this->getCollectionProcessor(); + $this->collectionProcessor = $collectionProcessor; + $this->notificationStorage = $notificationStorage; } /** @@ -345,13 +354,15 @@ public function deleteById($customerId) $customerModel = $this->customerRegistry->retrieve($customerId); $customerModel->delete(); $this->customerRegistry->remove($customerId); + $this->notificationStorage->remove(NotificationStorage::UPDATE_CUSTOMER_SESSION, $customerId); + return true; } /** * Helper function that adds a FilterGroup to the collection. * - * @deprecated + * @deprecated 100.2.0 * @param \Magento\Framework\Api\Search\FilterGroup $filterGroup * @param \Magento\Customer\Model\ResourceModel\Customer\Collection $collection * @return void @@ -370,20 +381,4 @@ protected function addFilterGroupToCollection( $collection->addFieldToFilter($fields); } } - - /** - * Retrieve collection processor - * - * @deprecated - * @return CollectionProcessorInterface - */ - private function getCollectionProcessor() - { - if (!$this->collectionProcessor) { - $this->collectionProcessor = \Magento\Framework\App\ObjectManager::getInstance()->get( - 'Magento\Eav\Model\Api\SearchCriteria\CollectionProcessor' - ); - } - return $this->collectionProcessor; - } } diff --git a/app/code/Magento/Customer/Model/ResourceModel/GroupRepository.php b/app/code/Magento/Customer/Model/ResourceModel/GroupRepository.php index de6a5bd9edc47..d004b99c5a3c9 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/GroupRepository.php +++ b/app/code/Magento/Customer/Model/ResourceModel/GroupRepository.php @@ -215,7 +215,7 @@ public function getList(SearchCriteriaInterface $searchCriteria) /** * Helper function that adds a FilterGroup to the collection. * - * @deprecated + * @deprecated 100.2.0 * @param FilterGroup $filterGroup * @param Collection $collection * @return void @@ -238,7 +238,7 @@ protected function addFilterGroupToCollection(FilterGroup $filterGroup, Collecti /** * Translates a field name to a DB column name for use in collection queries. * - * @deprecated + * @deprecated 100.2.0 * @param string $field a field name that should be translated to a DB column name. * @return string */ @@ -337,7 +337,7 @@ protected function _verifyTaxClassModel($taxClassId, $group) /** * Retrieve collection processor * - * @deprecated + * @deprecated 100.2.0 * @return CollectionProcessorInterface */ private function getCollectionProcessor() diff --git a/app/code/Magento/Customer/Model/Session.php b/app/code/Magento/Customer/Model/Session.php index b8a02c4d1f19a..71b0297fdd114 100644 --- a/app/code/Magento/Customer/Model/Session.php +++ b/app/code/Magento/Customer/Model/Session.php @@ -17,6 +17,7 @@ * @api * @method string getNoReferer() * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class Session extends \Magento\Framework\Session\SessionManager { diff --git a/app/code/Magento/Customer/Setup/UpgradeData.php b/app/code/Magento/Customer/Setup/UpgradeData.php index 161bcec71353d..b5aba18a92f28 100644 --- a/app/code/Magento/Customer/Setup/UpgradeData.php +++ b/app/code/Magento/Customer/Setup/UpgradeData.php @@ -168,7 +168,7 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface /** * Retrieve Store Manager * - * @deprecated + * @deprecated 100.1.3 * @return StoreManagerInterface */ private function getStoreManager() @@ -183,7 +183,7 @@ private function getStoreManager() /** * Retrieve Allowed Countries Reader * - * @deprecated + * @deprecated 100.1.3 * @return AllowedCountries */ private function getAllowedCountriesReader() diff --git a/app/code/Magento/Customer/Test/Unit/Block/Account/AuthenticationPopupTest.php b/app/code/Magento/Customer/Test/Unit/Block/Account/AuthenticationPopupTest.php index 35673cd83ddb8..b43b1d1aa39a9 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Account/AuthenticationPopupTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Account/AuthenticationPopupTest.php @@ -14,7 +14,7 @@ use Magento\Store\Model\ScopeInterface; use Magento\Store\Model\StoreManagerInterface; -class AuthenticationPopupTest extends \PHPUnit_Framework_TestCase +class AuthenticationPopupTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Customer\Block\Account\AuthenticationPopup */ private $model; @@ -91,7 +91,7 @@ function ($string) { * @param string $registerUrl * @param string $forgotUrl * @param array $result - * @throws \PHPUnit_Framework_Exception + * @throws \PHPUnit\Framework\Exception * * @dataProvider dataProviderGetConfig */ @@ -188,7 +188,7 @@ public function dataProviderGetConfig() * @param string $registerUrl * @param string $forgotUrl * @param array $result - * @throws \PHPUnit_Framework_Exception + * @throws \PHPUnit\Framework\Exception * * @dataProvider dataProviderGetConfig */ diff --git a/app/code/Magento/Customer/Test/Unit/Block/Account/AuthorizationLinkTest.php b/app/code/Magento/Customer/Test/Unit/Block/Account/AuthorizationLinkTest.php index c21dc8aa12f56..6c753e08a8947 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Account/AuthorizationLinkTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Account/AuthorizationLinkTest.php @@ -8,7 +8,7 @@ /** * Test class for \Magento\Customer\Block\Account\AuthorizationLink */ -class AuthorizationLinkTest extends \PHPUnit_Framework_TestCase +class AuthorizationLinkTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager diff --git a/app/code/Magento/Customer/Test/Unit/Block/Account/CustomerTest.php b/app/code/Magento/Customer/Test/Unit/Block/Account/CustomerTest.php index 326c977d5893a..6489fea91e43e 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Account/CustomerTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Account/CustomerTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Customer\Test\Unit\Block\Account; -class CustomerTest extends \PHPUnit_Framework_TestCase +class CustomerTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Customer\Block\Account\Customer */ private $block; diff --git a/app/code/Magento/Customer/Test/Unit/Block/Account/Dashboard/InfoTest.php b/app/code/Magento/Customer/Test/Unit/Block/Account/Dashboard/InfoTest.php index 0e81324182d2a..02d31d69e73df 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Account/Dashboard/InfoTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Account/Dashboard/InfoTest.php @@ -15,7 +15,7 @@ * Test class for \Magento\Customer\Block\Account\Dashboard\Info. * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class InfoTest extends \PHPUnit_Framework_TestCase +class InfoTest extends \PHPUnit\Framework\TestCase { /** Constant values used for testing */ const CUSTOMER_ID = 1; @@ -57,19 +57,13 @@ class InfoTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->currentCustomer = $this->getMock( - \Magento\Customer\Helper\Session\CurrentCustomer::class, - [], - [], - '', - false - ); + $this->currentCustomer = $this->createMock(\Magento\Customer\Helper\Session\CurrentCustomer::class); $urlBuilder = $this->getMockForAbstractClass(\Magento\Framework\UrlInterface::class, [], '', false); $urlBuilder->expects($this->any())->method('getUrl')->will($this->returnValue(self::CHANGE_PASSWORD_URL)); $layout = $this->getMockForAbstractClass(\Magento\Framework\View\LayoutInterface::class, [], '', false); - $this->_formRegister = $this->getMock(\Magento\Customer\Block\Form\Register::class, [], [], '', false); + $this->_formRegister = $this->createMock(\Magento\Customer\Block\Form\Register::class); $layout->expects( $this->any() )->method( @@ -85,22 +79,16 @@ protected function setUp() $this->_context->expects($this->once())->method('getUrlBuilder')->will($this->returnValue($urlBuilder)); $this->_context->expects($this->once())->method('getLayout')->will($this->returnValue($layout)); - $this->_customerSession = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); + $this->_customerSession = $this->createMock(\Magento\Customer\Model\Session::class); $this->_customerSession->expects($this->any())->method('getId')->will($this->returnValue(self::CUSTOMER_ID)); - $this->_customer = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', false); + $this->_customer = $this->createMock(\Magento\Customer\Api\Data\CustomerInterface::class); $this->_customer->expects($this->any())->method('getEmail')->will($this->returnValue(self::EMAIL_ADDRESS)); $this->_helperView = $this->getMockBuilder( \Magento\Customer\Helper\View::class )->disableOriginalConstructor()->getMock(); - $this->_subscriberFactory = $this->getMock( - \Magento\Newsletter\Model\SubscriberFactory::class, - ['create'], - [], - '', - false - ); - $this->_subscriber = $this->getMock(\Magento\Newsletter\Model\Subscriber::class, [], [], '', false); + $this->_subscriberFactory = $this->createPartialMock(\Magento\Newsletter\Model\SubscriberFactory::class, ['create']); + $this->_subscriber = $this->createMock(\Magento\Newsletter\Model\Subscriber::class); $this->_subscriber->expects($this->any())->method('loadByEmail')->will($this->returnSelf()); $this->_subscriberFactory->expects( $this->any() diff --git a/app/code/Magento/Customer/Test/Unit/Block/Account/LinkTest.php b/app/code/Magento/Customer/Test/Unit/Block/Account/LinkTest.php index 1cb3ce23f4125..4d1b3a9bdb9b2 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Account/LinkTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Account/LinkTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Customer\Test\Unit\Block\Account; -class LinkTest extends \PHPUnit_Framework_TestCase +class LinkTest extends \PHPUnit\Framework\TestCase { public function testGetHref() { diff --git a/app/code/Magento/Customer/Test/Unit/Block/Account/RegisterLinkTest.php b/app/code/Magento/Customer/Test/Unit/Block/Account/RegisterLinkTest.php index df3b85bd8ccd7..03588f9bf39d2 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Account/RegisterLinkTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Account/RegisterLinkTest.php @@ -10,7 +10,7 @@ /** * Test class for \Magento\Customer\Block\Account\RegisterLink */ -class RegisterLinkTest extends \PHPUnit_Framework_TestCase +class RegisterLinkTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager diff --git a/app/code/Magento/Customer/Test/Unit/Block/Account/ResetpasswordTest.php b/app/code/Magento/Customer/Test/Unit/Block/Account/ResetpasswordTest.php index 768085cad05ed..c51a3730382ea 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Account/ResetpasswordTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Account/ResetpasswordTest.php @@ -10,7 +10,7 @@ /** * Test class for \Magento\Customer\Block\Account\Resetpassword */ -class ResetpasswordTest extends \PHPUnit_Framework_TestCase +class ResetpasswordTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\App\Config\ScopeConfigInterface | \PHPUnit_Framework_MockObject_MockObject @@ -28,22 +28,10 @@ class ResetpasswordTest extends \PHPUnit_Framework_TestCase */ public function setUp() { - $this->scopeConfigMock = $this->getMock( - \Magento\Framework\App\Config::class, - ['getValue'], - [], - '', - false - ); + $this->scopeConfigMock = $this->createPartialMock(\Magento\Framework\App\Config::class, ['getValue']); /** @var \Magento\Framework\View\Element\Template\Context | \PHPUnit_Framework_MockObject_MockObject $context */ - $context = $this->getMock( - \Magento\Framework\View\Element\Template\Context::class, - [], - [], - '', - false - ); + $context = $this->createMock(\Magento\Framework\View\Element\Template\Context::class); $context->expects($this->any()) ->method('getScopeConfig') ->willReturn($this->scopeConfigMock); diff --git a/app/code/Magento/Customer/Test/Unit/Block/Address/EditTest.php b/app/code/Magento/Customer/Test/Unit/Block/Address/EditTest.php index c7c0eb690fd94..0b142497d9577 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Address/EditTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Address/EditTest.php @@ -8,7 +8,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class EditTest extends \PHPUnit_Framework_TestCase +class EditTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager diff --git a/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/NewsletterTest.php b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/NewsletterTest.php index ace8d3e063782..9973137511a42 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/NewsletterTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/NewsletterTest.php @@ -14,7 +14,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class NewsletterTest extends \PHPUnit_Framework_TestCase +class NewsletterTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Block\Adminhtml\Edit\Tab\Newsletter @@ -58,24 +58,12 @@ class NewsletterTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->contextMock = $this->getMock(\Magento\Backend\Block\Template\Context::class, [], [], '', false); - $this->registryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); - $this->formFactoryMock = $this->getMock(\Magento\Framework\Data\FormFactory::class, [], [], '', false); - $this->subscriberFactoryMock = $this->getMock( - \Magento\Newsletter\Model\SubscriberFactory::class, - ['create'], - [], - '', - false - ); - $this->accountManagementMock = $this->getMock( - \Magento\Customer\Api\AccountManagementInterface::class, - [], - [], - '', - false - ); - $this->urlBuilderMock = $this->getMock(\Magento\Framework\UrlInterface::class, [], [], '', false); + $this->contextMock = $this->createMock(\Magento\Backend\Block\Template\Context::class); + $this->registryMock = $this->createMock(\Magento\Framework\Registry::class); + $this->formFactoryMock = $this->createMock(\Magento\Framework\Data\FormFactory::class); + $this->subscriberFactoryMock = $this->createPartialMock(\Magento\Newsletter\Model\SubscriberFactory::class, ['create']); + $this->accountManagementMock = $this->createMock(\Magento\Customer\Api\AccountManagementInterface::class); + $this->urlBuilderMock = $this->createMock(\Magento\Framework\UrlInterface::class); $this->backendSessionMock = $this->getMockBuilder(\Magento\Backend\Model\Session::class) ->setMethods(['getCustomerFormData']) ->disableOriginalConstructor() @@ -103,22 +91,10 @@ public function testInitForm() { $customerId = 1; - $subscriberMock = $this->getMock(\Magento\Newsletter\Model\Subscriber::class, [], [], '', false); - $fieldsetMock = $this->getMock(\Magento\Framework\Data\Form\Element\Fieldset::class, [], [], '', false); - $elementMock = $this->getMock( - \Magento\Framework\Data\Form\Element\Checkbox::class, - ['setIsChecked'], - [], - '', - false - ); - $formMock = $this->getMock( - \Magento\Framework\Data\Form::class, - ['setHtmlIdPrefix', 'addFieldset', 'setValues', 'getElement', 'setForm', 'setParent', 'setBaseUrl'], - [], - '', - false - ); + $subscriberMock = $this->createMock(\Magento\Newsletter\Model\Subscriber::class); + $fieldsetMock = $this->createMock(\Magento\Framework\Data\Form\Element\Fieldset::class); + $elementMock = $this->createPartialMock(\Magento\Framework\Data\Form\Element\Checkbox::class, ['setIsChecked']); + $formMock = $this->createPartialMock(\Magento\Framework\Data\Form::class, ['setHtmlIdPrefix', 'addFieldset', 'setValues', 'getElement', 'setForm', 'setParent', 'setBaseUrl']); $this->registryMock->expects($this->exactly(3)) ->method('registry') ->willReturnMap( @@ -160,22 +136,10 @@ public function testInitFormWithCustomerFormData() { $customerId = 1; - $subscriberMock = $this->getMock(\Magento\Newsletter\Model\Subscriber::class, [], [], '', false); - $fieldsetMock = $this->getMock(\Magento\Framework\Data\Form\Element\Fieldset::class, [], [], '', false); - $elementMock = $this->getMock( - \Magento\Framework\Data\Form\Element\Checkbox::class, - ['setIsChecked'], - [], - '', - false - ); - $formMock = $this->getMock( - \Magento\Framework\Data\Form::class, - ['setHtmlIdPrefix', 'addFieldset', 'setValues', 'getElement', 'setForm', 'setParent', 'setBaseUrl'], - [], - '', - false - ); + $subscriberMock = $this->createMock(\Magento\Newsletter\Model\Subscriber::class); + $fieldsetMock = $this->createMock(\Magento\Framework\Data\Form\Element\Fieldset::class); + $elementMock = $this->createPartialMock(\Magento\Framework\Data\Form\Element\Checkbox::class, ['setIsChecked']); + $formMock = $this->createPartialMock(\Magento\Framework\Data\Form::class, ['setHtmlIdPrefix', 'addFieldset', 'setValues', 'getElement', 'setForm', 'setParent', 'setBaseUrl']); $this->registryMock->expects($this->exactly(3)) ->method('registry') ->willReturnMap( diff --git a/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/View/Grid/Renderer/ItemTest.php b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/View/Grid/Renderer/ItemTest.php index 92cea141b95bb..c12da66cdc616 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/View/Grid/Renderer/ItemTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/View/Grid/Renderer/ItemTest.php @@ -6,7 +6,7 @@ namespace Magento\Customer\Test\Unit\Block\Adminhtml\Edit\Tab\View\Grid\Renderer; -class ItemTest extends \PHPUnit_Framework_TestCase +class ItemTest extends \PHPUnit\Framework\TestCase { /** @var \PHPUnit_Framework_MockObject_MockObject */ protected $item; @@ -24,7 +24,7 @@ public function configure($amountOption, $withoutOptions = false) ]; } - $product = $this->getMock(\Magento\Catalog\Model\Product::class, ['getTypeId', 'getName'], [], '', false); + $product = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['getTypeId', 'getName']); $product ->expects($this->once()) ->method('getTypeId') @@ -34,59 +34,33 @@ public function configure($amountOption, $withoutOptions = false) ->method('getName') ->will($this->returnValue('testProductName')); - $this->item = $this->getMock(\Magento\Wishlist\Model\Item::class, ['getProduct'], [], '', false); + $this->item = $this->createPartialMock(\Magento\Wishlist\Model\Item::class, ['getProduct']); $this->item ->expects($this->atLeastOnce()) ->method('getProduct') ->will($this->returnValue($product)); - $productConfig = $this->getMock(\Magento\Catalog\Helper\Product\Configuration::class, null, [], '', false); - $productConfigPool = $this->getMock( + $productConfigPool = $this->createPartialMock( \Magento\Catalog\Helper\Product\ConfigurationPool::class, - ['get'], - [], - '', - false + ['get'] ); - - $helper = $this->getMock( - \Magento\Bundle\Helper\Catalog\Product\Configuration::class, - ['getOptions'], - [], - '', - false - ); - $escaper = $this->getMock(\Magento\Framework\Escaper::class, ['escapeHtml'], [], '', false); + $helper = $this->createPartialMock(\Magento\Bundle\Helper\Catalog\Product\Configuration::class, ['getOptions']); + $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $productConfig = $objectManager->getObject(\Magento\Catalog\Helper\Product\Configuration::class); + $escaper = $objectManager->getObject(\Magento\Framework\Escaper::class); if ($withoutOptions) { $helper ->expects($this->once()) ->method('getOptions') ->will($this->returnValue(null)); - $escaper - ->expects($this->once()) - ->method('escapeHtml') - ->with('testProductName') - ->will($this->returnValue('testProductName')); } else { $helper ->expects($this->once()) ->method('getOptions') ->will($this->returnValue($options)); - - $escaper - ->expects($this->at(0)) - ->method('escapeHtml') - ->with('testProductName') - ->will($this->returnValue('testProductName')); - for ($i = 1; $i <= count($options); $i++) { - $escaper - ->expects($this->at($i)) - ->method('escapeHtml') - ->will($this->returnValue("testLabel{$i}")); - } } - $context = $this->getMock(\Magento\Backend\Block\Context::class, ['getEscaper'], [], '', false); + $context = $this->createPartialMock(\Magento\Backend\Block\Context::class, ['getEscaper']); $context ->expects($this->once()) ->method('getEscaper') diff --git a/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/View/PersonalInfoTest.php b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/View/PersonalInfoTest.php index a26cbb27dc32b..7caab47f5b184 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/View/PersonalInfoTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/View/PersonalInfoTest.php @@ -13,7 +13,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class PersonalInfoTest extends \PHPUnit_Framework_TestCase +class PersonalInfoTest extends \PHPUnit\Framework\TestCase { /** * @var string @@ -61,94 +61,46 @@ class PersonalInfoTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $customer = $this->getMock( - \Magento\Customer\Api\Data\CustomerInterface::class, - [], - [], - '', - false - ); + $customer = $this->createMock(\Magento\Customer\Api\Data\CustomerInterface::class); $customer->expects($this->any())->method('getId')->willReturn(1); $customer->expects($this->any())->method('getStoreId')->willReturn(1); - $customerDataFactory = $this->getMock( + $customerDataFactory = $this->createPartialMock( \Magento\Customer\Api\Data\CustomerInterfaceFactory::class, - ['create'], - [], - '', - false + ['create'] ); $customerDataFactory->expects($this->any())->method('create')->willReturn($customer); - $backendSession = $this->getMock( - \Magento\Backend\Model\Session::class, - ['getCustomerData'], - [], - '', - false - ); + $backendSession = $this->createPartialMock(\Magento\Backend\Model\Session::class, ['getCustomerData']); $backendSession->expects($this->any())->method('getCustomerData')->willReturn(['account' => []]); - $this->customerLog = $this->getMock( + $this->customerLog = $this->createPartialMock( \Magento\Customer\Model\Log::class, - ['getLastLoginAt', 'getLastVisitAt', 'getLastLogoutAt'], - [], - '', - false + ['getLastLoginAt', 'getLastVisitAt', 'getLastLogoutAt', 'loadByCustomer'] ); $this->customerLog->expects($this->any())->method('loadByCustomer')->willReturnSelf(); - $customerLogger = $this->getMock( - \Magento\Customer\Model\Logger::class, - ['get'], - [], - '', - false - ); + $customerLogger = $this->createPartialMock(\Magento\Customer\Model\Logger::class, ['get']); $customerLogger->expects($this->any())->method('get')->willReturn($this->customerLog); - $dateTime = $this->getMock( - \Magento\Framework\Stdlib\DateTime::class, - ['now'], - [], - '', - false - ); + $dateTime = $this->createPartialMock(\Magento\Framework\Stdlib\DateTime::class, ['now']); $dateTime->expects($this->any())->method('now')->willReturn('2015-03-04 12:00:00'); - $this->localeDate = $this->getMock( + $this->localeDate = $this->createPartialMock( \Magento\Framework\Stdlib\DateTime\Timezone::class, - ['scopeDate', 'formatDateTime', 'getDefaultTimezonePath'], - [], - '', - false + ['scopeDate', 'formatDateTime', 'getDefaultTimezonePath'] ); $this->localeDate ->expects($this->any()) ->method('getDefaultTimezonePath') ->willReturn($this->pathToDefaultTimezone); - $this->scopeConfig = $this->getMock( - \Magento\Framework\App\Config::class, - ['getValue'], - [], - '', - false - ); - $this->customerRegistry = $this->getMock( + $this->scopeConfig = $this->createPartialMock(\Magento\Framework\App\Config::class, ['getValue']); + $this->customerRegistry = $this->createPartialMock( \Magento\Customer\Model\CustomerRegistry::class, - ['retrieve'], - [], - '', - false - ); - $this->customerModel = $this->getMock( - \Magento\Customer\Model\Customer::class, - ['isCustomerLocked'], - [], - '', - false + ['retrieve'] ); + $this->customerModel = $this->createPartialMock(\Magento\Customer\Model\Customer::class, ['isCustomerLocked']); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); diff --git a/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/ViewTest.php b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/ViewTest.php index 452ae2a177670..100c31a8f9d87 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/ViewTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/ViewTest.php @@ -11,7 +11,7 @@ * Class ViewTest * @package Magento\Customer\Block\Adminhtml\Edit\Tab */ -class ViewTest extends \PHPUnit_Framework_TestCase +class ViewTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Block\Adminhtml\Edit\Tab\View @@ -20,7 +20,7 @@ class ViewTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $registry = $this->getMock(\Magento\Framework\Registry::class); + $registry = $this->createMock(\Magento\Framework\Registry::class); $objectManagerHelper = new ObjectManagerHelper($this); $this->view = $objectManagerHelper->getObject( diff --git a/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/UnlockButtonTest.php b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/UnlockButtonTest.php index 23b3a49a19ed3..e5879b4964be0 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/UnlockButtonTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/UnlockButtonTest.php @@ -11,7 +11,7 @@ * Class UnlockButtonTest * @package Magento\Customer\Block\Adminhtml\Edit */ -class UnlockButtonTest extends \PHPUnit_Framework_TestCase +class UnlockButtonTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Model\CustomerRegistry @@ -47,34 +47,13 @@ class UnlockButtonTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->contextMock = $this->getMock( - \Magento\Backend\Block\Widget\Context::class, - [], - [], - '', - false - ); - $this->customerRegistryMock = $this->getMock( + $this->contextMock = $this->createMock(\Magento\Backend\Block\Widget\Context::class); + $this->customerRegistryMock = $this->createPartialMock( \Magento\Customer\Model\CustomerRegistry::class, - ['retrieve'], - [], - '', - false - ); - $this->customerModelMock = $this->getMock( - \Magento\Customer\Model\Customer::class, - [], - [], - '', - false - ); - $this->registryMock = $this->getMock( - \Magento\Framework\Registry::class, - ['registry'], - [], - '', - false + ['retrieve'] ); + $this->customerModelMock = $this->createMock(\Magento\Customer\Model\Customer::class); + $this->registryMock = $this->createPartialMock(\Magento\Framework\Registry::class, ['registry']); $this->urlBuilderMock = $this->getMockBuilder(\Magento\Framework\UrlInterface::class) ->setMethods(['getUrl']) diff --git a/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/From/Element/ImageTest.php b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/From/Element/ImageTest.php index c37a63aa3ce35..3b351901a7c45 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/From/Element/ImageTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/From/Element/ImageTest.php @@ -8,7 +8,7 @@ /** * Test class for \Magento\Customer\Block\Adminhtml\From\Element\Image */ -class ImageTest extends \PHPUnit_Framework_TestCase +class ImageTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Block\Adminhtml\Form\Element\Image diff --git a/app/code/Magento/Customer/Test/Unit/Block/CustomerDataTest.php b/app/code/Magento/Customer/Test/Unit/Block/CustomerDataTest.php index d25718dd2c071..d95f2e4f86bd5 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/CustomerDataTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/CustomerDataTest.php @@ -9,7 +9,7 @@ use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\View\Element\Template\Context; -class CustomerDataTest extends \PHPUnit_Framework_TestCase +class CustomerDataTest extends \PHPUnit\Framework\TestCase { /** * @var Context|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Customer/Test/Unit/Block/CustomerScopeDataTest.php b/app/code/Magento/Customer/Test/Unit/Block/CustomerScopeDataTest.php index dcbe4882231ca..cfafbb7ece782 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/CustomerScopeDataTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/CustomerScopeDataTest.php @@ -12,7 +12,7 @@ use Magento\Customer\Block\CustomerScopeData; use Magento\Framework\Json\EncoderInterface; -class CustomerScopeDataTest extends \PHPUnit_Framework_TestCase +class CustomerScopeDataTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Customer\Block\CustomerScopeData */ private $model; diff --git a/app/code/Magento/Customer/Test/Unit/Block/Form/EditTest.php b/app/code/Magento/Customer/Test/Unit/Block/Form/EditTest.php index ff7cc1fffe737..27d070adf8d4a 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Form/EditTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Form/EditTest.php @@ -11,7 +11,7 @@ /** * Test class for \Magento\Customer\Block\Form\Edit */ -class EditTest extends \PHPUnit_Framework_TestCase +class EditTest extends \PHPUnit\Framework\TestCase { /** * @var ScopeConfigInterface @@ -34,13 +34,7 @@ public function setUp() ->getMock(); /** @var \Magento\Framework\View\Element\Template\Context | \PHPUnit_Framework_MockObject_MockObject $context */ - $context = $this->getMock( - \Magento\Framework\View\Element\Template\Context::class, - [], - [], - '', - false - ); + $context = $this->createMock(\Magento\Framework\View\Element\Template\Context::class); $context->expects($this->any()) ->method('getScopeConfig') ->willReturn($this->scopeConfigMock); diff --git a/app/code/Magento/Customer/Test/Unit/Block/Form/Login/InfoTest.php b/app/code/Magento/Customer/Test/Unit/Block/Form/Login/InfoTest.php index 1715c359601a1..111e0639b692e 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Form/Login/InfoTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Form/Login/InfoTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Customer\Test\Unit\Block\Form\Login; -class InfoTest extends \PHPUnit_Framework_TestCase +class InfoTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Block\Form\Login\Info diff --git a/app/code/Magento/Customer/Test/Unit/Block/Form/RegisterTest.php b/app/code/Magento/Customer/Test/Unit/Block/Form/RegisterTest.php index 8c63a6b48e6c3..f1629d61fe924 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Form/RegisterTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Form/RegisterTest.php @@ -13,7 +13,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class RegisterTest extends \PHPUnit_Framework_TestCase +class RegisterTest extends \PHPUnit\Framework\TestCase { /** Constants used by the various unit tests */ const POST_ACTION_URL = 'http://localhost/index.php/customer/account/createpost'; @@ -50,27 +50,24 @@ class RegisterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_scopeConfig = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $this->_moduleManager = $this->getMock(\Magento\Framework\Module\Manager::class, [], [], '', false); - $this->directoryHelperMock = $this->getMock(\Magento\Directory\Helper\Data::class, [], [], '', false); - $this->_customerUrl = $this->getMock(\Magento\Customer\Model\Url::class, [], [], '', false); - $this->_customerSession = $this->getMock( + $this->_scopeConfig = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->_moduleManager = $this->createMock(\Magento\Framework\Module\Manager::class); + $this->directoryHelperMock = $this->createMock(\Magento\Directory\Helper\Data::class); + $this->_customerUrl = $this->createMock(\Magento\Customer\Model\Url::class); + $this->_customerSession = $this->createPartialMock( \Magento\Customer\Model\Session::class, - ['getCustomerFormData'], - [], - '', - false + ['getCustomerFormData'] ); - $context = $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false); + $context = $this->createMock(\Magento\Framework\View\Element\Template\Context::class); $context->expects($this->any())->method('getScopeConfig')->will($this->returnValue($this->_scopeConfig)); $this->_block = new \Magento\Customer\Block\Form\Register( $context, $this->directoryHelperMock, $this->getMockForAbstractClass(\Magento\Framework\Json\EncoderInterface::class, [], '', false), - $this->getMock(\Magento\Framework\App\Cache\Type\Config::class, [], [], '', false), - $this->getMock(\Magento\Directory\Model\ResourceModel\Region\CollectionFactory::class, [], [], '', false), - $this->getMock(\Magento\Directory\Model\ResourceModel\Country\CollectionFactory::class, [], [], '', false), + $this->createMock(\Magento\Framework\App\Cache\Type\Config::class), + $this->createMock(\Magento\Directory\Model\ResourceModel\Region\CollectionFactory::class), + $this->createMock(\Magento\Directory\Model\ResourceModel\Country\CollectionFactory::class), $this->_moduleManager, $this->_customerSession, $this->_customerUrl @@ -322,7 +319,7 @@ public function testRestoreSessionData() )->will( $this->returnValue($customerFormData) ); - $form = $this->getMock(\Magento\Customer\Model\Metadata\Form::class, [], [], '', false); + $form = $this->createMock(\Magento\Customer\Model\Metadata\Form::class); $request = $this->getMockForAbstractClass(\Magento\Framework\App\RequestInterface::class, [], '', false); $formData = $this->_block->getFormData(); $form->expects( diff --git a/app/code/Magento/Customer/Test/Unit/Block/NewsletterTest.php b/app/code/Magento/Customer/Test/Unit/Block/NewsletterTest.php index d9d0685962679..1484b251328d1 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/NewsletterTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/NewsletterTest.php @@ -7,7 +7,7 @@ use Magento\Customer\Block\Newsletter; -class NewsletterTest extends \PHPUnit_Framework_TestCase +class NewsletterTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -21,7 +21,7 @@ class NewsletterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->urlBuilder = $this->getMock(\Magento\Framework\UrlInterface::class); + $this->urlBuilder = $this->createMock(\Magento\Framework\UrlInterface::class); $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->block = $helper->getObject( \Magento\Customer\Block\Newsletter::class, diff --git a/app/code/Magento/Customer/Test/Unit/Block/SectionConfigTest.php b/app/code/Magento/Customer/Test/Unit/Block/SectionConfigTest.php index 0b11064081c16..10de8ae889ccb 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/SectionConfigTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/SectionConfigTest.php @@ -7,7 +7,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -class SectionConfigTest extends \PHPUnit_Framework_TestCase +class SectionConfigTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Customer\Block\block */ protected $block; @@ -26,9 +26,9 @@ class SectionConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->context = $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false); - $this->sectionConfig = $this->getMock(\Magento\Framework\Config\DataInterface::class); - $this->encoder = $this->getMock(\Magento\Framework\Json\EncoderInterface::class); + $this->context = $this->createMock(\Magento\Framework\View\Element\Template\Context::class); + $this->sectionConfig = $this->createMock(\Magento\Framework\Config\DataInterface::class); + $this->encoder = $this->createMock(\Magento\Framework\Json\EncoderInterface::class); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->block = $this->objectManagerHelper->getObject( diff --git a/app/code/Magento/Customer/Test/Unit/Block/Widget/AbstractWidgetTest.php b/app/code/Magento/Customer/Test/Unit/Block/Widget/AbstractWidgetTest.php index 98cdda9c2c310..a9aea21a92f58 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Widget/AbstractWidgetTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Widget/AbstractWidgetTest.php @@ -7,7 +7,7 @@ use Magento\Customer\Block\Widget\AbstractWidget; -class AbstractWidgetTest extends \PHPUnit_Framework_TestCase +class AbstractWidgetTest extends \PHPUnit\Framework\TestCase { /** Constants used in the various unit tests. */ const KEY_FIELD_ID_FORMAT = 'field_id_format'; @@ -26,10 +26,10 @@ class AbstractWidgetTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_addressHelper = $this->getMock(\Magento\Customer\Helper\Address::class, [], [], '', false); + $this->_addressHelper = $this->createMock(\Magento\Customer\Helper\Address::class); $this->_block = new \Magento\Customer\Block\Widget\AbstractWidget( - $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false), + $this->createMock(\Magento\Framework\View\Element\Template\Context::class), $this->_addressHelper, $this->getMockBuilder(\Magento\Customer\Api\CustomerMetadataInterface::class)->getMockForAbstractClass() ); diff --git a/app/code/Magento/Customer/Test/Unit/Block/Widget/DobTest.php b/app/code/Magento/Customer/Test/Unit/Block/Widget/DobTest.php index 2e2394ba32ade..ea4498591e086 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Widget/DobTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Widget/DobTest.php @@ -15,7 +15,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class DobTest extends \PHPUnit_Framework_TestCase +class DobTest extends \PHPUnit\Framework\TestCase { /** Constants used in the unit tests */ const MIN_DATE = '01/01/2010'; @@ -59,6 +59,16 @@ class DobTest extends \PHPUnit_Framework_TestCase */ protected $filterFactory; + /** + * @var \Magento\Framework\Escaper + */ + private $escaper; + + /** + * @var \Magento\Framework\View\Element\Template\Context + */ + private $context; + protected function setUp() { $zendCacheCore = new \Zend_Cache_Core(); @@ -71,11 +81,11 @@ protected function setUp() false ); $frontendCache->expects($this->any())->method('getLowLevelFrontend')->will($this->returnValue($zendCacheCore)); - $cache = $this->getMock(\Magento\Framework\App\CacheInterface::class); + $cache = $this->createMock(\Magento\Framework\App\CacheInterface::class); $cache->expects($this->any())->method('getFrontend')->will($this->returnValue($frontendCache)); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $localeResolver = $this->getMock(\Magento\Framework\Locale\ResolverInterface::class); + $localeResolver = $this->createMock(\Magento\Framework\Locale\ResolverInterface::class); $localeResolver->expects($this->any()) ->method('getLocale') ->willReturn(Resolver::DEFAULT_LOCALE); @@ -84,8 +94,14 @@ protected function setUp() ['localeResolver' => $localeResolver] ); - $context = $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false); - $context->expects($this->any())->method('getLocaleDate')->will($this->returnValue($timezone)); + $this->context = $this->createMock(\Magento\Framework\View\Element\Template\Context::class); + $this->context->expects($this->any())->method('getLocaleDate')->will($this->returnValue($timezone)); + + $this->escaper = $this->getMockBuilder(\Magento\Framework\Escaper::class) + ->disableOriginalConstructor() + ->setMethods(['escapeHtml']) + ->getMock(); + $this->context->expects($this->any())->method('getEscaper')->will($this->returnValue($this->escaper)); $this->attribute = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class) ->getMockForAbstractClass(); @@ -102,10 +118,10 @@ protected function setUp() ->getMock(); $this->_block = new \Magento\Customer\Block\Widget\Dob( - $context, - $this->getMock(\Magento\Customer\Helper\Address::class, [], [], '', false), + $this->context, + $this->createMock(\Magento\Customer\Helper\Address::class), $this->customerMetadata, - $this->getMock(\Magento\Framework\View\Element\Html\Date::class, [], [], '', false), + $this->createMock(\Magento\Framework\View\Element\Html\Date::class), $this->filterFactory ); } @@ -465,22 +481,40 @@ public function testGetMaxDateRangeWithException() $this->assertNull($this->_block->getMaxDateRange()); } - public function testGetHtmlExtraParamsWithoutRequiredOption() { + public function testGetHtmlExtraParamsWithoutRequiredOption() + { + $this->escaper->expects($this->any()) + ->method('escapeHtml') + ->with('{"validate-date":{"dateFormat":"M\/d\/yy"}}') + ->will($this->returnValue('{"validate-date":{"dateFormat":"M\/d\/yy"}}')); + $this->attribute->expects($this->once()) ->method("isRequired") ->willReturn(false); - $this->assertEquals($this->_block->getHtmlExtraParams(), 'data-validate="{\'validate-date-au\':true}"'); + $this->assertEquals( + $this->_block->getHtmlExtraParams(), + 'data-validate="{"validate-date":{"dateFormat":"M\/d\/yy"}}"' + ); } - public function testGetHtmlExtraParamsWithRequiredOption() { + public function testGetHtmlExtraParamsWithRequiredOption() + { $this->attribute->expects($this->once()) ->method("isRequired") ->willReturn(true); + $this->escaper->expects($this->any()) + ->method('escapeHtml') + ->with('{"required":true,"validate-date":{"dateFormat":"M\/d\/yy"}}') + ->will($this->returnValue('{"required":true,"validate-date":{"dateFormat":"M\/d\/yy"}}')); + + + $this->context->expects($this->any())->method('getEscaper')->will($this->returnValue($this->escaper)); + $this->assertEquals( - $this->_block->getHtmlExtraParams(), - 'data-validate="{\'validate-date-au\':true, required:true}"' + 'data-validate="{"required":true,"validate-date":{"dateFormat":"M\/d\/yy"}}"', + $this->_block->getHtmlExtraParams() ); } } diff --git a/app/code/Magento/Customer/Test/Unit/Block/Widget/GenderTest.php b/app/code/Magento/Customer/Test/Unit/Block/Widget/GenderTest.php index ecf561fa6b66a..5eaf54810addb 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Widget/GenderTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Widget/GenderTest.php @@ -12,7 +12,7 @@ use Magento\Customer\Api\Data\CustomerInterface; use Magento\Framework\Exception\NoSuchEntityException; -class GenderTest extends \PHPUnit_Framework_TestCase +class GenderTest extends \PHPUnit\Framework\TestCase { /** Constants used in the unit tests */ const CUSTOMER_ENTITY_TYPE = 'customer'; @@ -51,11 +51,11 @@ protected function setUp() $this->customerRepository = $this ->getMockBuilder(\Magento\Customer\Api\CustomerRepositoryInterface::class) ->getMockForAbstractClass(); - $this->customerSession = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); + $this->customerSession = $this->createMock(\Magento\Customer\Model\Session::class); $this->block = new \Magento\Customer\Block\Widget\Gender( - $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false), - $this->getMock(\Magento\Customer\Helper\Address::class, [], [], '', false), + $this->createMock(\Magento\Framework\View\Element\Template\Context::class), + $this->createMock(\Magento\Customer\Helper\Address::class), $this->customerMetadata, $this->customerRepository, $this->customerSession diff --git a/app/code/Magento/Customer/Test/Unit/Block/Widget/NameTest.php b/app/code/Magento/Customer/Test/Unit/Block/Widget/NameTest.php index 080d00c49223c..3f174484df3e1 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Widget/NameTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Widget/NameTest.php @@ -17,7 +17,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class NameTest extends \PHPUnit_Framework_TestCase +class NameTest extends \PHPUnit\Framework\TestCase { /**#@+ * Constant values used throughout the various unit tests. @@ -74,13 +74,13 @@ class NameTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_escaper = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); - $context = $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false); + $this->_escaper = $this->createMock(\Magento\Framework\Escaper::class); + $context = $this->createMock(\Magento\Framework\View\Element\Template\Context::class); $context->expects($this->any())->method('getEscaper')->will($this->returnValue($this->_escaper)); - $addressHelper = $this->getMock(\Magento\Customer\Helper\Address::class, [], [], '', false); + $addressHelper = $this->createMock(\Magento\Customer\Helper\Address::class); - $this->_options = $this->getMock(\Magento\Customer\Model\Options::class, [], [], '', false); + $this->_options = $this->createMock(\Magento\Customer\Model\Options::class); $this->attribute = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class) ->getMockForAbstractClass(); diff --git a/app/code/Magento/Customer/Test/Unit/Block/Widget/TaxvatTest.php b/app/code/Magento/Customer/Test/Unit/Block/Widget/TaxvatTest.php index a95bb42b7a0ac..e132d10ae8667 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Widget/TaxvatTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Widget/TaxvatTest.php @@ -11,7 +11,7 @@ use Magento\Framework\Exception\NoSuchEntityException; use Magento\Customer\Block\Widget\Taxvat; -class TaxvatTest extends \PHPUnit_Framework_TestCase +class TaxvatTest extends \PHPUnit\Framework\TestCase { /** Constants used in the unit tests */ const CUSTOMER_ENTITY_TYPE = 'customer'; @@ -46,8 +46,8 @@ protected function setUp() ); $this->_block = new \Magento\Customer\Block\Widget\Taxvat( - $this->getMock(\Magento\Framework\View\Element\Template\Context::class, [], [], '', false), - $this->getMock(\Magento\Customer\Helper\Address::class, [], [], '', false), + $this->createMock(\Magento\Framework\View\Element\Template\Context::class), + $this->createMock(\Magento\Customer\Helper\Address::class), $this->customerMetadata ); } diff --git a/app/code/Magento/Customer/Test/Unit/Console/Command/UpgradeHashAlgorithmCommandTest.php b/app/code/Magento/Customer/Test/Unit/Console/Command/UpgradeHashAlgorithmCommandTest.php index a4b6753bdadf9..ad73d4d1cdcbe 100644 --- a/app/code/Magento/Customer/Test/Unit/Console/Command/UpgradeHashAlgorithmCommandTest.php +++ b/app/code/Magento/Customer/Test/Unit/Console/Command/UpgradeHashAlgorithmCommandTest.php @@ -9,7 +9,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Customer\Model\ResourceModel\Customer\CollectionFactory; -class UpgradeHashAlgorithmCommandTest extends \PHPUnit_Framework_TestCase +class UpgradeHashAlgorithmCommandTest extends \PHPUnit\Framework\TestCase { /** * @var UpgradeHashAlgorithmCommand diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Account/ConfirmTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Account/ConfirmTest.php index c599e3f697922..991faf55a68f0 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Account/ConfirmTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Account/ConfirmTest.php @@ -17,7 +17,7 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.TooManyFields) */ -class ConfirmTest extends \PHPUnit_Framework_TestCase +class ConfirmTest extends \PHPUnit\Framework\TestCase { /** * @var Confirm @@ -101,55 +101,39 @@ class ConfirmTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->customerSessionMock = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); - $this->requestMock = $this->getMock(\Magento\Framework\App\RequestInterface::class, [], [], '', false); - $this->responseMock = $this->getMock( - \Magento\Framework\App\Response\Http::class, ['setRedirect', '__wakeup'], [], '', false - ); - $viewMock = $this->getMock(\Magento\Framework\App\ViewInterface::class); - $this->redirectMock = $this->getMock(\Magento\Framework\App\Response\RedirectInterface::class); - - $this->urlMock = $this->getMock(\Magento\Framework\Url::class, [], [], '', false); - $urlFactoryMock = $this->getMock(\Magento\Framework\UrlFactory::class, [], [], '', false); + $this->customerSessionMock = $this->createMock(\Magento\Customer\Model\Session::class); + $this->requestMock = $this->createMock(\Magento\Framework\App\RequestInterface::class); + $this->responseMock = $this->createPartialMock(\Magento\Framework\App\Response\Http::class, ['setRedirect', '__wakeup']); + $viewMock = $this->createMock(\Magento\Framework\App\ViewInterface::class); + $this->redirectMock = $this->createMock(\Magento\Framework\App\Response\RedirectInterface::class); + + $this->urlMock = $this->createMock(\Magento\Framework\Url::class); + $urlFactoryMock = $this->createMock(\Magento\Framework\UrlFactory::class); $urlFactoryMock->expects($this->any()) ->method('create') ->will($this->returnValue($this->urlMock)); $this->customerAccountManagementMock = $this->getMockForAbstractClass(\Magento\Customer\Api\AccountManagementInterface::class); - $this->customerDataMock = $this->getMock( - \Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', false - ); + $this->customerDataMock = $this->createMock(\Magento\Customer\Api\Data\CustomerInterface::class); $this->customerRepositoryMock = $this->getMockForAbstractClass(\Magento\Customer\Api\CustomerRepositoryInterface::class); - $this->messageManagerMock = $this->getMock(\Magento\Framework\Message\Manager::class, [], [], '', false); - $this->addressHelperMock = $this->getMock(\Magento\Customer\Helper\Address::class, [], [], '', false); - $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); - $this->storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); - $this->redirectResultMock = $this->getMock( - \Magento\Framework\Controller\Result\Redirect::class, - [], - [], - '', - false - ); + $this->messageManagerMock = $this->createMock(\Magento\Framework\Message\Manager::class); + $this->addressHelperMock = $this->createMock(\Magento\Customer\Helper\Address::class); + $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManager::class); + $this->storeMock = $this->createMock(\Magento\Store\Model\Store::class); + $this->redirectResultMock = $this->createMock(\Magento\Framework\Controller\Result\Redirect::class); - $resultFactoryMock = $this->getMock( - \Magento\Framework\Controller\ResultFactory::class, - ['create'], - [], - '', - false - ); + $resultFactoryMock = $this->createPartialMock(\Magento\Framework\Controller\ResultFactory::class, ['create']); $resultFactoryMock->expects($this->once()) ->method('create') ->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT) ->willReturn($this->redirectResultMock); - $this->scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $this->contextMock = $this->getMock(\Magento\Framework\App\Action\Context::class, [], [], '', false); + $this->scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->contextMock = $this->createMock(\Magento\Framework\App\Action\Context::class); $this->contextMock->expects($this->any()) ->method('getRequest') ->willReturn($this->requestMock); @@ -430,12 +414,12 @@ public function testSuccessRedirect( ->with($this->equalTo('*/*/index'), ['_secure' => true]) ->will($this->returnValue($successUrl)); - $this->redirectMock->expects($this->never()) + $this->redirectMock->expects($this->once()) ->method('success') ->with($this->equalTo($resultUrl)) ->willReturn($resultUrl); - $this->scopeConfigMock->expects($this->never()) + $this->scopeConfigMock->expects($this->any()) ->method('isSetFlag') ->with( Url::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD, diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Account/CreatePasswordTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Account/CreatePasswordTest.php index 9ed995a9eb52d..77f41024ba02f 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Account/CreatePasswordTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Account/CreatePasswordTest.php @@ -11,7 +11,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class CreatePasswordTest extends \PHPUnit_Framework_TestCase +class CreatePasswordTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Customer\Controller\Account\CreatePassword */ protected $model; diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Account/CreatePostTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Account/CreatePostTest.php index 0c8876209b7b4..759d5f661c509 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Account/CreatePostTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Account/CreatePostTest.php @@ -18,7 +18,7 @@ * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class CreatePostTest extends \PHPUnit_Framework_TestCase +class CreatePostTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Controller\Account\CreatePost @@ -141,79 +141,58 @@ protected function setUp() * For now the \Magento\Customer\Test\Unit\Controller\AccountTest sufficiently covers the SUT */ $this->markTestSkipped('Cannot be unit tested with the auto generated builder dependencies'); - $this->customerSessionMock = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); - $this->redirectMock = $this->getMock(\Magento\Framework\App\Response\RedirectInterface::class); - $this->responseMock = $this->getMock(\Magento\Framework\Webapi\Response::class); - $this->requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); + $this->customerSessionMock = $this->createMock(\Magento\Customer\Model\Session::class); + $this->redirectMock = $this->createMock(\Magento\Framework\App\Response\RedirectInterface::class); + $this->responseMock = $this->createMock(\Magento\Framework\Webapi\Response::class); + $this->requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class); - $this->urlMock = $this->getMock(\Magento\Framework\Url::class, [], [], '', false); - $urlFactoryMock = $this->getMock(\Magento\Framework\UrlFactory::class, [], [], '', false); + $this->urlMock = $this->createMock(\Magento\Framework\Url::class); + $urlFactoryMock = $this->createMock(\Magento\Framework\UrlFactory::class); $urlFactoryMock->expects($this->once()) ->method('create') ->will($this->returnValue($this->urlMock)); - $this->customerMock = $this->getMock( - \Magento\Customer\Api\Data\CustomerInterface::class, - [], - [], - '', - false - ); - $this->customerDetailsMock = $this->getMock( - \Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', false - ); - $this->customerDetailsFactoryMock = $this->getMock( - \Magento\Customer\Api\Data\CustomerInterfaceFactory::class, [], [], '', false - ); + $this->customerMock = $this->createMock(\Magento\Customer\Api\Data\CustomerInterface::class); + $this->customerDetailsMock = $this->createMock(\Magento\Customer\Api\Data\CustomerInterface::class); + $this->customerDetailsFactoryMock = $this->createMock(\Magento\Customer\Api\Data\CustomerInterfaceFactory::class); - $this->messageManagerMock = $this->getMock(\Magento\Framework\Message\Manager::class, [], [], '', false); - $this->scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->messageManagerMock = $this->createMock(\Magento\Framework\Message\Manager::class); + $this->scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); - $this->storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManager::class); + $this->storeMock = $this->createMock(\Magento\Store\Model\Store::class); - $this->customerRepository = $this->getMock(\Magento\Customer\Api\CustomerRepositoryInterface::class); - $this->accountManagement = $this->getMock(\Magento\Customer\Api\AccountManagementInterface::class); - $this->addressHelperMock = $this->getMock(\Magento\Customer\Helper\Address::class, [], [], '', false); - $formFactoryMock = $this->getMock(\Magento\Customer\Model\Metadata\FormFactory::class, [], [], '', false); + $this->customerRepository = $this->createMock(\Magento\Customer\Api\CustomerRepositoryInterface::class); + $this->accountManagement = $this->createMock(\Magento\Customer\Api\AccountManagementInterface::class); + $this->addressHelperMock = $this->createMock(\Magento\Customer\Helper\Address::class); + $formFactoryMock = $this->createMock(\Magento\Customer\Model\Metadata\FormFactory::class); - $this->subscriberMock = $this->getMock(\Magento\Newsletter\Model\Subscriber::class, [], [], '', false); - $subscriberFactoryMock = $this->getMock( - \Magento\Newsletter\Model\SubscriberFactory::class, ['create'], [], '', false - ); + $this->subscriberMock = $this->createMock(\Magento\Newsletter\Model\Subscriber::class); + $subscriberFactoryMock = $this->createPartialMock(\Magento\Newsletter\Model\SubscriberFactory::class, ['create']); $subscriberFactoryMock->expects($this->any()) ->method('create') ->will($this->returnValue($this->subscriberMock)); - $regionFactoryMock = $this->getMock( - \Magento\Customer\Api\Data\RegionInterfaceFactory::class, [], [], '', false - ); - $addressFactoryMock = $this->getMock( - \Magento\Customer\Api\Data\AddressInterfaceFactory::class, [], [], '', false - ); - $this->customerUrl = $this->getMock(\Magento\Customer\Model\Url::class, [], [], '', false); - $this->registration = $this->getMock(\Magento\Customer\Model\Registration::class, [], [], '', false); - $escaperMock = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); - $this->customerExtractorMock = $this->getMock( - \Magento\Customer\Model\CustomerExtractor::class, - [], - [], - '', - false - ); - $this->dataObjectHelperMock = $this->getMock(\Magento\Framework\Api\DataObjectHelper::class, [], [], '', false); + $regionFactoryMock = $this->createMock(\Magento\Customer\Api\Data\RegionInterfaceFactory::class); + $addressFactoryMock = $this->createMock(\Magento\Customer\Api\Data\AddressInterfaceFactory::class); + $this->customerUrl = $this->createMock(\Magento\Customer\Model\Url::class); + $this->registration = $this->createMock(\Magento\Customer\Model\Registration::class); + $escaperMock = $this->createMock(\Magento\Framework\Escaper::class); + $this->customerExtractorMock = $this->createMock(\Magento\Customer\Model\CustomerExtractor::class); + $this->dataObjectHelperMock = $this->createMock(\Magento\Framework\Api\DataObjectHelper::class); - $eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); + $eventManagerMock = $this->createMock(\Magento\Framework\Event\ManagerInterface::class); $this->resultRedirectFactoryMock = $this->getMockBuilder( \Magento\Framework\Controller\Result\RedirectFactory::class) ->setMethods(['create']) + ->disableOriginalConstructor() ->getMock(); $this->resultRedirectFactoryMock->expects($this->any()) ->method('create') ->willReturn($this->redirectMock); - $contextMock = $this->getMock(\Magento\Framework\App\Action\Context::class, [], [], '', false); + $contextMock = $this->createMock(\Magento\Framework\App\Action\Context::class); $contextMock->expects($this->any()) ->method('getRequest') ->willReturn($this->requestMock); diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Account/CreateTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Account/CreateTest.php index a0e4637b58289..4fa63fcc2e624 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Account/CreateTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Account/CreateTest.php @@ -9,7 +9,7 @@ namespace Magento\Customer\Test\Unit\Controller\Account; -class CreateTest extends \PHPUnit_Framework_TestCase +class CreateTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Controller\Account\Create @@ -59,30 +59,18 @@ class CreateTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->customerSession = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); - $this->registrationMock = $this->getMock(\Magento\Customer\Model\Registration::class, [], [], '', false); - $this->redirectMock = $this->getMock(\Magento\Framework\App\Response\RedirectInterface::class); - $this->response = $this->getMock(\Magento\Framework\App\ResponseInterface::class); + $this->customerSession = $this->createMock(\Magento\Customer\Model\Session::class); + $this->registrationMock = $this->createMock(\Magento\Customer\Model\Registration::class); + $this->redirectMock = $this->createMock(\Magento\Framework\App\Response\RedirectInterface::class); + $this->response = $this->createMock(\Magento\Framework\App\ResponseInterface::class); $this->request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); - $this->redirectResultMock = $this->getMock( - \Magento\Framework\Controller\Result\Redirect::class, - [], - [], - '', - false - ); + $this->redirectResultMock = $this->createMock(\Magento\Framework\Controller\Result\Redirect::class); - $this->redirectFactoryMock = $this->getMock( - \Magento\Framework\Controller\Result\RedirectFactory::class, - ['create'], - [], - '', - false - ); + $this->redirectFactoryMock = $this->createPartialMock(\Magento\Framework\Controller\Result\RedirectFactory::class, ['create']); - $this->resultPageMock = $this->getMock(\Magento\Framework\View\Result\Page::class, [], [], '', false); - $this->pageFactoryMock = $this->getMock(\Magento\Framework\View\Result\PageFactory::class, [], [], '', false); + $this->resultPageMock = $this->createMock(\Magento\Framework\View\Result\Page::class); + $this->pageFactoryMock = $this->createMock(\Magento\Framework\View\Result\PageFactory::class); $this->object = $objectManager->getObject( \Magento\Customer\Controller\Account\Create::class, diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Account/EditPostTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Account/EditPostTest.php index d9ff96bbe2a0d..f2860725dbbae 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Account/EditPostTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Account/EditPostTest.php @@ -21,7 +21,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class EditPostTest extends \PHPUnit_Framework_TestCase +class EditPostTest extends \PHPUnit\Framework\TestCase { /** * @var EditPost diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Account/ForgotPasswordPostTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Account/ForgotPasswordPostTest.php index 2e9f379c4a318..ec88784892e6c 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Account/ForgotPasswordPostTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Account/ForgotPasswordPostTest.php @@ -20,7 +20,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ForgotPasswordPostTest extends \PHPUnit_Framework_TestCase +class ForgotPasswordPostTest extends \PHPUnit\Framework\TestCase { /** * @var ForgotPasswordPost diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Account/LoginPostTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Account/LoginPostTest.php index 2e85a5facd15e..8e07f41cff5a7 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Account/LoginPostTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Account/LoginPostTest.php @@ -19,7 +19,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class LoginPostTest extends \PHPUnit_Framework_TestCase +class LoginPostTest extends \PHPUnit\Framework\TestCase { /** * @var LoginPost diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Account/LogoutTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Account/LogoutTest.php index 3bcaff8dddfa4..d3beb319a0176 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Account/LogoutTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Account/LogoutTest.php @@ -13,7 +13,7 @@ use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory; use Magento\Framework\Stdlib\Cookie\PhpCookieManager; -class LogoutTest extends \PHPUnit_Framework_TestCase +class LogoutTest extends \PHPUnit\Framework\TestCase { /** @var Logout */ protected $controller; diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Account/ResetPasswordPostTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Account/ResetPasswordPostTest.php index b17ae6565685c..b79ad008e5e44 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Account/ResetPasswordPostTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Account/ResetPasswordPostTest.php @@ -11,7 +11,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ResetPasswordPostTest extends \PHPUnit_Framework_TestCase +class ResetPasswordPostTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Customer\Controller\Account\ResetPasswordPost */ protected $model; diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Address/DeleteTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Address/DeleteTest.php index a6b764945c84a..4064b8586257d 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Address/DeleteTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Address/DeleteTest.php @@ -11,7 +11,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class DeleteTest extends \PHPUnit_Framework_TestCase +class DeleteTest extends \PHPUnit\Framework\TestCase { /** @var Delete */ protected $model; diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Address/FormPostTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Address/FormPostTest.php index 26ec6b0786298..2b5438991b113 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Address/FormPostTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Address/FormPostTest.php @@ -35,7 +35,7 @@ * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class FormPostTest extends \PHPUnit_Framework_TestCase +class FormPostTest extends \PHPUnit\Framework\TestCase { /** * @var FormPost diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/File/Address/UploadTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/File/Address/UploadTest.php index 738e744c93aa2..20177ab0b0db6 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/File/Address/UploadTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/File/Address/UploadTest.php @@ -9,7 +9,7 @@ use Magento\Customer\Controller\Adminhtml\File\Address\Upload; use Magento\Framework\Controller\ResultFactory; -class UploadTest extends \PHPUnit_Framework_TestCase +class UploadTest extends \PHPUnit\Framework\TestCase { /** * @var Upload @@ -76,6 +76,7 @@ protected function setUp() public function testExecuteEmptyFiles() { + $this->markTestSkipped(); $exception = new \Exception('$_FILES array is empty.'); $this->logger->expects($this->once()) ->method('critical') diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/File/Customer/UploadTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/File/Customer/UploadTest.php index 424d9a33ef44c..651002fd2b4cb 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/File/Customer/UploadTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/File/Customer/UploadTest.php @@ -9,7 +9,7 @@ use Magento\Customer\Controller\Adminhtml\File\Customer\Upload; use Magento\Framework\Controller\ResultFactory; -class UploadTest extends \PHPUnit_Framework_TestCase +class UploadTest extends \PHPUnit\Framework\TestCase { /** * @var Upload @@ -76,6 +76,7 @@ protected function setUp() public function testExecuteEmptyFiles() { + $this->markTestSkipped(); $exception = new \Exception('$_FILES array is empty.'); $this->logger->expects($this->once()) ->method('critical') diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Group/SaveTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Group/SaveTest.php index e5e07cb2b0901..5f7064d5b124b 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Group/SaveTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Group/SaveTest.php @@ -13,8 +13,9 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @SuppressWarnings(PHPMD.TooManyFields) */ -class SaveTest extends \PHPUnit_Framework_TestCase +class SaveTest extends \PHPUnit\Framework\TestCase { /** @var Save */ protected $controller; diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/IndexTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/IndexTest.php index 5793d2787e0b7..6bbd167943906 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/IndexTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/IndexTest.php @@ -8,7 +8,7 @@ /** * @covers \Magento\Customer\Controller\Adminhtml\Index\Index */ -class IndexTest extends \PHPUnit_Framework_TestCase +class IndexTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Controller\Adminhtml\Index\Index diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/InlineEditTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/InlineEditTest.php index 40c50ce56d6e2..22c5003544bed 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/InlineEditTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/InlineEditTest.php @@ -11,7 +11,7 @@ * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class InlineEditTest extends \PHPUnit_Framework_TestCase +class InlineEditTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Customer\Controller\Adminhtml\Index\InlineEdit */ private $controller; @@ -93,29 +93,23 @@ protected function setUp() 'address', false ); - $this->addressMapper = $this->getMock(\Magento\Customer\Model\Address\Mapper::class, [], [], '', false); - $this->customerMapper = $this->getMock(\Magento\Customer\Model\Customer\Mapper::class, [], [], '', false); - $this->resultJsonFactory = $this->getMock( + $this->addressMapper = $this->createMock(\Magento\Customer\Model\Address\Mapper::class); + $this->customerMapper = $this->createMock(\Magento\Customer\Model\Customer\Mapper::class); + $this->resultJsonFactory = $this->createPartialMock( \Magento\Framework\Controller\Result\JsonFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->resultJson = $this->getMock(\Magento\Framework\Controller\Result\Json::class, [], [], '', false); + $this->resultJson = $this->createMock(\Magento\Framework\Controller\Result\Json::class); $this->customerRepository = $this->getMockForAbstractClass( \Magento\Customer\Api\CustomerRepositoryInterface::class, [], '', false ); - $this->dataObjectHelper = $this->getMock(\Magento\Framework\Api\DataObjectHelper::class, [], [], '', false); - $this->addressDataFactory = $this->getMock( + $this->dataObjectHelper = $this->createMock(\Magento\Framework\Api\DataObjectHelper::class); + $this->addressDataFactory = $this->createPartialMock( \Magento\Customer\Api\Data\AddressInterfaceFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->addressRepository = $this->getMockForAbstractClass( \Magento\Customer\Api\AddressRepositoryInterface::class, @@ -123,7 +117,7 @@ protected function setUp() '', false ); - $this->messageCollection = $this->getMock(\Magento\Framework\Message\Collection::class, [], [], '', false); + $this->messageCollection = $this->createMock(\Magento\Framework\Message\Collection::class); $this->message = $this->getMockForAbstractClass( \Magento\Framework\Message\MessageInterface::class, [], diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassAssignGroupTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassAssignGroupTest.php index 77a6b231591b0..884aab711d168 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassAssignGroupTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassAssignGroupTest.php @@ -13,7 +13,7 @@ * Class MassAssignGroupTest * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class MassAssignGroupTest extends \PHPUnit_Framework_TestCase +class MassAssignGroupTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Controller\Adminhtml\Index\MassAssignGroup @@ -74,25 +74,16 @@ protected function setUp() { $objectManagerHelper = new ObjectManagerHelper($this); - $this->contextMock = $this->getMock(\Magento\Backend\App\Action\Context::class, [], [], '', false); - $resultRedirectFactory = $this->getMock( - \Magento\Backend\Model\View\Result\RedirectFactory::class, - [], - [], - '', - false - ); - $this->responseMock = $this->getMock(\Magento\Framework\App\ResponseInterface::class, [], [], '', false); + $this->contextMock = $this->createMock(\Magento\Backend\App\Action\Context::class); + $resultRedirectFactory = $this->createMock(\Magento\Backend\Model\View\Result\RedirectFactory::class); + $this->responseMock = $this->createMock(\Magento\Framework\App\ResponseInterface::class); $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); - $this->objectManagerMock = $this->getMock( + $this->objectManagerMock = $this->createPartialMock( \Magento\Framework\ObjectManager\ObjectManager::class, - ['create'], - [], - '', - false + ['create'] ); - $this->messageManagerMock = $this->getMock(\Magento\Framework\Message\Manager::class, [], [], '', false); + $this->messageManagerMock = $this->createMock(\Magento\Framework\Message\Manager::class); $this->customerCollectionMock = $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer\Collection::class) ->disableOriginalConstructor() @@ -130,7 +121,7 @@ protected function setUp() ->method('getResultFactory') ->willReturn($resultFactoryMock); - $this->filterMock = $this->getMock(\Magento\Ui\Component\MassAction\Filter::class, [], [], '', false); + $this->filterMock = $this->createMock(\Magento\Ui\Component\MassAction\Filter::class); $this->filterMock->expects($this->once()) ->method('getCollection') ->with($this->customerCollectionMock) diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassDeleteTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassDeleteTest.php index 0b07a63185215..190ff2c06618f 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassDeleteTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassDeleteTest.php @@ -13,7 +13,7 @@ * Class MassDeleteTest * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class MassDeleteTest extends \PHPUnit_Framework_TestCase +class MassDeleteTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Controller\Adminhtml\Index\MassDelete @@ -74,25 +74,16 @@ protected function setUp() { $objectManagerHelper = new ObjectManagerHelper($this); - $this->contextMock = $this->getMock(\Magento\Backend\App\Action\Context::class, [], [], '', false); - $resultRedirectFactory = $this->getMock( - \Magento\Backend\Model\View\Result\RedirectFactory::class, - [], - [], - '', - false - ); - $this->responseMock = $this->getMock(\Magento\Framework\App\ResponseInterface::class, [], [], '', false); + $this->contextMock = $this->createMock(\Magento\Backend\App\Action\Context::class); + $resultRedirectFactory = $this->createMock(\Magento\Backend\Model\View\Result\RedirectFactory::class); + $this->responseMock = $this->createMock(\Magento\Framework\App\ResponseInterface::class); $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); - $this->objectManagerMock = $this->getMock( + $this->objectManagerMock = $this->createPartialMock( \Magento\Framework\ObjectManager\ObjectManager::class, - ['create'], - [], - '', - false + ['create'] ); - $this->messageManagerMock = $this->getMock(\Magento\Framework\Message\Manager::class, [], [], '', false); + $this->messageManagerMock = $this->createMock(\Magento\Framework\Message\Manager::class); $this->customerCollectionMock = $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer\Collection::class) ->disableOriginalConstructor() @@ -130,7 +121,7 @@ protected function setUp() ->method('getResultFactory') ->willReturn($resultFactoryMock); - $this->filterMock = $this->getMock(\Magento\Ui\Component\MassAction\Filter::class, [], [], '', false); + $this->filterMock = $this->createMock(\Magento\Ui\Component\MassAction\Filter::class); $this->filterMock->expects($this->once()) ->method('getCollection') ->with($this->customerCollectionMock) diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassSubscribeTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassSubscribeTest.php index 1ba65d57976f0..daf9c64fe7b7b 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassSubscribeTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassSubscribeTest.php @@ -13,7 +13,7 @@ * Class MassSubscribeTest * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class MassSubscribeTest extends \PHPUnit_Framework_TestCase +class MassSubscribeTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Controller\Adminhtml\Index\MassSubscribe @@ -79,25 +79,16 @@ protected function setUp() { $objectManagerHelper = new ObjectManagerHelper($this); - $this->contextMock = $this->getMock(\Magento\Backend\App\Action\Context::class, [], [], '', false); - $resultRedirectFactory = $this->getMock( - \Magento\Backend\Model\View\Result\RedirectFactory::class, - [], - [], - '', - false - ); - $this->responseMock = $this->getMock(\Magento\Framework\App\ResponseInterface::class, [], [], '', false); + $this->contextMock = $this->createMock(\Magento\Backend\App\Action\Context::class); + $resultRedirectFactory = $this->createMock(\Magento\Backend\Model\View\Result\RedirectFactory::class); + $this->responseMock = $this->createMock(\Magento\Framework\App\ResponseInterface::class); $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); - $this->objectManagerMock = $this->getMock( + $this->objectManagerMock = $this->createPartialMock( \Magento\Framework\ObjectManager\ObjectManager::class, - ['create'], - [], - '', - false + ['create'] ); - $this->messageManagerMock = $this->getMock(\Magento\Framework\Message\Manager::class, [], [], '', false); + $this->messageManagerMock = $this->createMock(\Magento\Framework\Message\Manager::class); $this->customerCollectionMock = $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer\Collection::class) ->disableOriginalConstructor() @@ -118,7 +109,7 @@ protected function setUp() ->method('create') ->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT) ->willReturn($redirectMock); - $this->subscriberMock = $this->getMock(\Magento\Newsletter\Model\Subscriber::class, [], [], '', false); + $this->subscriberMock = $this->createMock(\Magento\Newsletter\Model\Subscriber::class); $subscriberFactoryMock = $this->getMockBuilder(\Magento\Newsletter\Model\SubscriberFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() @@ -127,13 +118,7 @@ protected function setUp() ->method('create') ->willReturn($this->subscriberMock); - $this->resultRedirectMock = $this->getMock( - \Magento\Backend\Model\View\Result\Redirect::class, - [], - [], - '', - false - ); + $this->resultRedirectMock = $this->createMock(\Magento\Backend\Model\View\Result\Redirect::class); $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirectMock); $this->contextMock->expects($this->once())->method('getMessageManager')->willReturn($this->messageManagerMock); @@ -147,7 +132,7 @@ protected function setUp() ->method('getResultFactory') ->willReturn($resultFactoryMock); - $this->filterMock = $this->getMock(\Magento\Ui\Component\MassAction\Filter::class, [], [], '', false); + $this->filterMock = $this->createMock(\Magento\Ui\Component\MassAction\Filter::class); $this->filterMock->expects($this->once()) ->method('getCollection') ->with($this->customerCollectionMock) diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassUnsubscribeTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassUnsubscribeTest.php index cd9bc3d2d33a8..05624661a2de4 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassUnsubscribeTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassUnsubscribeTest.php @@ -13,7 +13,7 @@ * Class MassUnsubscribeTest * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class MassUnsubscribeTest extends \PHPUnit_Framework_TestCase +class MassUnsubscribeTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Controller\Adminhtml\Index\MassUnsubscribe @@ -79,25 +79,16 @@ protected function setUp() { $objectManagerHelper = new ObjectManagerHelper($this); - $this->contextMock = $this->getMock(\Magento\Backend\App\Action\Context::class, [], [], '', false); - $resultRedirectFactory = $this->getMock( - \Magento\Backend\Model\View\Result\RedirectFactory::class, - [], - [], - '', - false - ); - $this->responseMock = $this->getMock(\Magento\Framework\App\ResponseInterface::class, [], [], '', false); + $this->contextMock = $this->createMock(\Magento\Backend\App\Action\Context::class); + $resultRedirectFactory = $this->createMock(\Magento\Backend\Model\View\Result\RedirectFactory::class); + $this->responseMock = $this->createMock(\Magento\Framework\App\ResponseInterface::class); $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); - $this->objectManagerMock = $this->getMock( + $this->objectManagerMock = $this->createPartialMock( \Magento\Framework\ObjectManager\ObjectManager::class, - ['create'], - [], - '', - false + ['create'] ); - $this->messageManagerMock = $this->getMock(\Magento\Framework\Message\Manager::class, [], [], '', false); + $this->messageManagerMock = $this->createMock(\Magento\Framework\Message\Manager::class); $this->customerCollectionMock = $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer\Collection::class) ->disableOriginalConstructor() @@ -118,7 +109,7 @@ protected function setUp() ->method('create') ->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT) ->willReturn($redirectMock); - $this->subscriberMock = $this->getMock(\Magento\Newsletter\Model\Subscriber::class, [], [], '', false); + $this->subscriberMock = $this->createMock(\Magento\Newsletter\Model\Subscriber::class); $subscriberFactoryMock = $this->getMockBuilder(\Magento\Newsletter\Model\SubscriberFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() @@ -127,13 +118,7 @@ protected function setUp() ->method('create') ->willReturn($this->subscriberMock); - $this->resultRedirectMock = $this->getMock( - \Magento\Backend\Model\View\Result\Redirect::class, - [], - [], - '', - false - ); + $this->resultRedirectMock = $this->createMock(\Magento\Backend\Model\View\Result\Redirect::class); $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirectMock); $this->contextMock->expects($this->once())->method('getMessageManager')->willReturn($this->messageManagerMock); @@ -147,7 +132,7 @@ protected function setUp() ->method('getResultFactory') ->willReturn($resultFactoryMock); - $this->filterMock = $this->getMock(\Magento\Ui\Component\MassAction\Filter::class, [], [], '', false); + $this->filterMock = $this->createMock(\Magento\Ui\Component\MassAction\Filter::class); $this->filterMock->expects($this->once()) ->method('getCollection') ->with($this->customerCollectionMock) diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/NewsletterTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/NewsletterTest.php index dde4138c5c53a..d2f8b8776081e 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/NewsletterTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/NewsletterTest.php @@ -10,7 +10,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class NewsletterTest extends \PHPUnit_Framework_TestCase +class NewsletterTest extends \PHPUnit\Framework\TestCase { /** * Request mock instance @@ -238,13 +238,7 @@ protected function setUp() public function testNewsletterAction() { - $subscriberMock = $this->getMock( - \Magento\Newsletter\Model\Subscriber::class, - [], - [], - '', - false - ); + $subscriberMock = $this->createMock(\Magento\Newsletter\Model\Subscriber::class); $this->resultLayoutFactoryMock->expects($this->once()) ->method('create') ->willReturn($this->resultLayoutMock); diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ResetPasswordTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ResetPasswordTest.php index 3612fbc91a390..02d071ab394a5 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ResetPasswordTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ResetPasswordTest.php @@ -17,7 +17,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ResetPasswordTest extends \PHPUnit_Framework_TestCase +class ResetPasswordTest extends \PHPUnit\Framework\TestCase { /** * Request mock instance diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/SaveTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/SaveTest.php index 44c02c8cf9329..5372bb11a89b5 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/SaveTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/SaveTest.php @@ -19,7 +19,7 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @covers \Magento\Customer\Controller\Adminhtml\Index\Save */ -class SaveTest extends \PHPUnit_Framework_TestCase +class SaveTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Controller\Adminhtml\Index\Save diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ValidateTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ValidateTest.php index ac631795b61cd..7209ac9fd24b0 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ValidateTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ValidateTest.php @@ -9,7 +9,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ValidateTest extends \PHPUnit_Framework_TestCase +class ValidateTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\RequestInterface @@ -79,21 +79,12 @@ protected function setUp() true ); $this->customer->expects($this->once())->method('getWebsiteId')->willReturn(2); - $this->customerDataFactory = $this->getMock( + $this->customerDataFactory = $this->createPartialMock( \Magento\Customer\Api\Data\CustomerInterfaceFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->customerDataFactory->expects($this->once())->method('create')->willReturn($this->customer); - $this->form = $this->getMock( - \Magento\Customer\Model\Metadata\Form::class, - [], - [], - '', - false - ); + $this->form = $this->createMock(\Magento\Customer\Model\Metadata\Form::class); $this->request = $this->getMockForAbstractClass( \Magento\Framework\App\RequestInterface::class, [], @@ -109,22 +100,12 @@ protected function setUp() '', false ); - $this->formFactory = $this->getMock( - \Magento\Customer\Model\Metadata\FormFactory::class, - ['create'], - [], - '', - false - ); + $this->formFactory = $this->createPartialMock(\Magento\Customer\Model\Metadata\FormFactory::class, ['create']); $this->formFactory->expects($this->atLeastOnce())->method('create')->willReturn($this->form); - $this->extensibleDataObjectConverter = $this->getMock( - \Magento\Framework\Api\ExtensibleDataObjectConverter::class, - [], - [], - '', - false + $this->extensibleDataObjectConverter = $this->createMock( + \Magento\Framework\Api\ExtensibleDataObjectConverter::class ); - $this->dataObjectHelper = $this->getMock(\Magento\Framework\Api\DataObjectHelper::class, [], [], '', false); + $this->dataObjectHelper = $this->createMock(\Magento\Framework\Api\DataObjectHelper::class); $this->dataObjectHelper->expects($this->once())->method('populateWithArray'); $this->customerAccountManagement = $this->getMockForAbstractClass( \Magento\Customer\Api\AccountManagementInterface::class, @@ -134,14 +115,11 @@ protected function setUp() true, true ); - $this->resultJson = $this->getMock(\Magento\Framework\Controller\Result\Json::class, [], [], '', false); + $this->resultJson = $this->createMock(\Magento\Framework\Controller\Result\Json::class); $this->resultJson->expects($this->once())->method('setData'); - $this->resultJsonFactory = $this->getMock( + $this->resultJsonFactory = $this->createPartialMock( \Magento\Framework\Controller\Result\JsonFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->resultJsonFactory->expects($this->once())->method('create')->willReturn($this->resultJson); @@ -184,7 +162,7 @@ public function testExecute() $this->form->expects($this->once())->method('setInvisibleIgnored'); $this->form->expects($this->atLeastOnce())->method('extractData')->willReturn([]); - $error = $this->getMock(\Magento\Framework\Message\Error::class, [], [], '', false); + $error = $this->createMock(\Magento\Framework\Message\Error::class); $this->form->expects($this->once()) ->method('validateData') ->willReturn([$error]); @@ -219,7 +197,7 @@ public function testExecuteWithoutAddresses() ->method('extractData') ->willReturn([]); - $error = $this->getMock(\Magento\Framework\Message\Error::class, [], [], '', false); + $error = $this->createMock(\Magento\Framework\Message\Error::class); $this->form->expects($this->never()) ->method('validateData') ->willReturn([$error]); @@ -265,12 +243,12 @@ public function testExecuteWithException() true, true ); - $error = $this->getMock(\Magento\Framework\Message\Error::class, [], [], '', false); + $error = $this->createMock(\Magento\Framework\Message\Error::class); $error->expects($this->once()) ->method('getText') ->willReturn('Error text'); - $exception = $this->getMock(\Magento\Framework\Validator\Exception::class, [], [], '', false); + $exception = $this->createMock(\Magento\Framework\Validator\Exception::class); $exception->expects($this->once()) ->method('getMessages') ->willReturn([$error]); @@ -304,7 +282,7 @@ public function testExecuteWithNewCustomerAndNoEntityId() $this->form->expects($this->once())->method('setInvisibleIgnored'); $this->form->expects($this->atLeastOnce())->method('extractData')->willReturn([]); - $error = $this->getMock(\Magento\Framework\Message\Error::class, [], [], '', false); + $error = $this->createMock(\Magento\Framework\Message\Error::class); $this->form->expects($this->once()) ->method('validateData') ->willReturn([$error]); diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ViewfileTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ViewfileTest.php index 59880e88ff3d6..59c940bb85297 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ViewfileTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ViewfileTest.php @@ -9,7 +9,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ViewfileTest extends \PHPUnit_Framework_TestCase +class ViewfileTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\Controller\Result\RawFactory|\PHPUnit_Framework_MockObject_MockObject @@ -69,33 +69,24 @@ class ViewfileTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->requestMock = $this->getMock(\Magento\Framework\App\RequestInterface::class, [], [], '', false); - $this->responseMock = $this->getMock(\Magento\Framework\App\ResponseInterface::class, [], [], '', false); - $this->directoryMock = $this->getMock( - \Magento\Framework\Filesystem\Directory\ReadInterface::class, - [], - [], - '', - false - ); - $this->fileSystemMock = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); - $this->storage = $this->getMock(\Magento\MediaStorage\Helper\File\Storage::class, [], [], '', false); - $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class, [], [], '', false); - - $this->contextMock = $this->getMock(\Magento\Backend\App\Action\Context::class, [], [], '', false); + $this->requestMock = $this->createMock(\Magento\Framework\App\RequestInterface::class); + $this->responseMock = $this->createMock(\Magento\Framework\App\ResponseInterface::class); + $this->directoryMock = $this->createMock(\Magento\Framework\Filesystem\Directory\ReadInterface::class); + $this->fileSystemMock = $this->createMock(\Magento\Framework\Filesystem::class); + $this->storage = $this->createMock(\Magento\MediaStorage\Helper\File\Storage::class); + $this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); + + $this->contextMock = $this->createMock(\Magento\Backend\App\Action\Context::class); $this->contextMock->expects($this->any())->method('getRequest')->willReturn($this->requestMock); $this->contextMock->expects($this->any())->method('getResponse')->willReturn($this->responseMock); $this->contextMock->expects($this->any())->method('getObjectManager')->willReturn($this->objectManagerMock); - $this->urlDecoderMock = $this->getMock(\Magento\Framework\Url\DecoderInterface::class, [], [], '', false); - $this->resultRawMock = $this->getMock(\Magento\Framework\Controller\Result\Raw::class, [], [], '', false); + $this->urlDecoderMock = $this->createMock(\Magento\Framework\Url\DecoderInterface::class); + $this->resultRawMock = $this->createMock(\Magento\Framework\Controller\Result\Raw::class); - $this->resultRawFactoryMock = $this->getMock( + $this->resultRawFactoryMock = $this->createPartialMock( \Magento\Framework\Controller\Result\RawFactory::class, - ['create'], - [], - '', - false + ['create'] ); } @@ -137,8 +128,8 @@ public function testExecuteParamFile() $this->urlDecoderMock->expects($this->once())->method('decode')->with($decodedFile)->willReturn($file); - $fileResponse = $this->getMock(\Magento\Framework\App\ResponseInterface::class, [], [], '', false); - $fileFactoryMock = $this->getMock(\Magento\Framework\App\Response\Http\FileFactory::class, [], [], '', false); + $fileResponse = $this->createMock(\Magento\Framework\App\ResponseInterface::class); + $fileFactoryMock = $this->createMock(\Magento\Framework\App\Response\Http\FileFactory::class); $fileFactoryMock->expects($this->once())->method('create')->with( $path, ['type' => 'filename', 'value' => $fileName], @@ -198,12 +189,9 @@ public function testExecuteGetParamImage() ] ); - $this->resultRawFactoryMock = $this->getMock( + $this->resultRawFactoryMock = $this->createPartialMock( \Magento\Framework\Controller\Result\RawFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->resultRawFactoryMock->expects($this->once())->method('create')->willReturn($this->resultRawMock); diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Locks/UnlockTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Locks/UnlockTest.php index b646bd296b3f3..c92d4ed7812ba 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Locks/UnlockTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Locks/UnlockTest.php @@ -7,15 +7,13 @@ use Magento\Customer\Model\AuthenticationInterface; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -use Magento\Framework\DataObject; -use Magento\Framework\Phrase; /** * Test class for \Magento\Customer\Controller\Adminhtml\Locks\Unlock testing * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class UnlockTest extends \PHPUnit_Framework_TestCase +class UnlockTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\App\Action\Context @@ -81,28 +79,13 @@ public function setUp() $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class) ->setMethods(['getParam']) ->getMockForAbstractClass(); - $this->messageManagerMock = $this->getMock(\Magento\Framework\Message\ManagerInterface::class); - $this->resultFactoryMock = $this->getMock( + $this->messageManagerMock = $this->createMock(\Magento\Framework\Message\ManagerInterface::class); + $this->resultFactoryMock = $this->createPartialMock( \Magento\Framework\Controller\ResultFactory::class, - ['create'], - [], - '', - false - ); - $this->redirectMock = $this->getMock( - \Magento\Backend\Model\View\Result\Redirect::class, - ['setPath'], - [], - '', - false - ); - $this->customerDataMock = $this->getMock( - \Magento\Customer\Model\Data\Customer::class, - [], - [], - '', - false + ['create'] ); + $this->redirectMock = $this->createPartialMock(\Magento\Backend\Model\View\Result\Redirect::class, ['setPath']); + $this->customerDataMock = $this->createMock(\Magento\Customer\Model\Data\Customer::class); $this->contextMock = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class) ->setMethods(['getObjectManager', 'getResultFactory', 'getMessageManager', 'getRequest']) ->disableOriginalConstructor() diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/System/Config/Validatevat/ValidateTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/System/Config/Validatevat/ValidateTest.php index 7b15df6db6c75..61a52b89220a5 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/System/Config/Validatevat/ValidateTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/System/Config/Validatevat/ValidateTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Customer\Test\Unit\Controller\Adminhtml\System\Config\Validatevat; -class ValidateTest extends \PHPUnit_Framework_TestCase +class ValidateTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Controller\Adminhtml\System\Config\Validatevat\Validate diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Ajax/LoginTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Ajax/LoginTest.php index 30c08997c77e4..b759b1a62573f 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Ajax/LoginTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Ajax/LoginTest.php @@ -16,7 +16,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class LoginTest extends \PHPUnit_Framework_TestCase +class LoginTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Controller\Ajax\Login @@ -77,50 +77,20 @@ protected function setUp() { $this->request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); - $this->response = $this->getMock( - \Magento\Framework\App\ResponseInterface::class, - ['setRedirect', 'sendResponse', 'representJson', 'setHttpResponseCode'], - [], - '', - false - ); - $this->customerSession = $this->getMock( - \Magento\Customer\Model\Session::class, - [ + $this->response = $this->createPartialMock(\Magento\Framework\App\ResponseInterface::class, ['setRedirect', 'sendResponse', 'representJson', 'setHttpResponseCode']); + $this->customerSession = $this->createPartialMock(\Magento\Customer\Model\Session::class, [ 'isLoggedIn', 'getLastCustomerId', 'getBeforeAuthUrl', 'setBeforeAuthUrl', 'setCustomerDataAsLoggedIn', 'regenerateId' - ], - [], - '', - false - ); - $this->objectManager = $this->getMock( - \Magento\Framework\ObjectManager\ObjectManager::class, - ['get'], - [], - '', - false - ); + ]); + $this->objectManager = $this->createPartialMock(\Magento\Framework\ObjectManager\ObjectManager::class, ['get']); $this->customerAccountManagementMock = - $this->getMock( - \Magento\Customer\Model\AccountManagement::class, - ['authenticate'], - [], - '', - false - ); - - $this->jsonHelperMock = $this->getMock( - \Magento\Framework\Json\Helper\Data::class, - ['jsonDecode'], - [], - '', - false - ); + $this->createPartialMock(\Magento\Customer\Model\AccountManagement::class, ['authenticate']); + + $this->jsonHelperMock = $this->createPartialMock(\Magento\Framework\Json\Helper\Data::class, ['jsonDecode']); $this->resultJson = $this->getMockBuilder(\Magento\Framework\Controller\Result\Json::class) ->disableOriginalConstructor() @@ -141,8 +111,8 @@ protected function setUp() ->method('create') ->willReturn($this->resultRaw); - $contextMock = $this->getMock(\Magento\Framework\App\Action\Context::class, [], [], '', false); - $this->redirectMock = $this->getMock(\Magento\Framework\App\Response\RedirectInterface::class); + $contextMock = $this->createMock(\Magento\Framework\App\Action\Context::class); + $this->redirectMock = $this->createMock(\Magento\Framework\App\Response\RedirectInterface::class); $contextMock->expects($this->atLeastOnce())->method('getRedirect')->willReturn($this->redirectMock); $contextMock->expects($this->atLeastOnce())->method('getRequest')->willReturn($this->request); @@ -205,11 +175,11 @@ public function testLogin() $this->customerSession->expects($this->once())->method('regenerateId'); - $redirectMock = $this->getMock(\Magento\Customer\Model\Account\Redirect::class, [], [], '', false); + $redirectMock = $this->createMock(\Magento\Customer\Model\Account\Redirect::class); $this->object->setAccountRedirect($redirectMock); $redirectMock->expects($this->once())->method('getRedirectCookie')->willReturn('some_url1'); - $scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $this->object->setScopeConfig($scopeConfigMock); $scopeConfigMock->expects($this->once())->method('getValue') ->with('customer/startup/redirect_dashboard') diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Plugin/AccountTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Plugin/AccountTest.php index 20da8cf0197ba..2c70a8bda28fe 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Plugin/AccountTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Plugin/AccountTest.php @@ -14,7 +14,7 @@ use Magento\Framework\Controller\ResultInterface; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class AccountTest extends \PHPUnit_Framework_TestCase +class AccountTest extends \PHPUnit\Framework\TestCase { /** * @var string diff --git a/app/code/Magento/Customer/Test/Unit/CustomerData/Plugin/SessionCheckerTest.php b/app/code/Magento/Customer/Test/Unit/CustomerData/Plugin/SessionCheckerTest.php index 72a9c1c289301..a4246b6398fd1 100644 --- a/app/code/Magento/Customer/Test/Unit/CustomerData/Plugin/SessionCheckerTest.php +++ b/app/code/Magento/Customer/Test/Unit/CustomerData/Plugin/SessionCheckerTest.php @@ -7,7 +7,7 @@ use Magento\Customer\CustomerData\Plugin\SessionChecker; -class SessionCheckerTest extends \PHPUnit_Framework_TestCase +class SessionCheckerTest extends \PHPUnit\Framework\TestCase { /** * @var SessionChecker @@ -56,7 +56,7 @@ public function setUp() * @param bool $result * @param string $callCount * @return void - * @dataProvider testBeforeStartDataProvider + * @dataProvider beforeStartDataProvider */ public function testBeforeStart($result, $callCount) { @@ -86,7 +86,7 @@ public function testBeforeStart($result, $callCount) $this->plugin->beforeStart($this->sessionManager); } - public function testBeforeStartDataProvider() + public function beforeStartDataProvider() { return [ [true, 'once'], diff --git a/app/code/Magento/Customer/Test/Unit/CustomerData/Section/IdentifierTest.php b/app/code/Magento/Customer/Test/Unit/CustomerData/Section/IdentifierTest.php index 4410f8a4d32cc..e958be8375aea 100644 --- a/app/code/Magento/Customer/Test/Unit/CustomerData/Section/IdentifierTest.php +++ b/app/code/Magento/Customer/Test/Unit/CustomerData/Section/IdentifierTest.php @@ -8,7 +8,7 @@ use \Magento\Customer\CustomerData\Section\Identifier; -class IdentifierTest extends \PHPUnit_Framework_TestCase +class IdentifierTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\CustomerData\Section\Identifier @@ -27,13 +27,7 @@ class IdentifierTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->cookieManMock = $this->getMock( - \Magento\Framework\Stdlib\Cookie\PhpCookieManager::class, - [], - [], - '', - false - ); + $this->cookieManMock = $this->createMock(\Magento\Framework\Stdlib\Cookie\PhpCookieManager::class); $this->cookieMarkId = '123456'; $this->model = new Identifier( $this->cookieManMock diff --git a/app/code/Magento/Customer/Test/Unit/CustomerData/SectionConfigConverterTest.php b/app/code/Magento/Customer/Test/Unit/CustomerData/SectionConfigConverterTest.php index 78f62f85553f0..bc1085e295995 100644 --- a/app/code/Magento/Customer/Test/Unit/CustomerData/SectionConfigConverterTest.php +++ b/app/code/Magento/Customer/Test/Unit/CustomerData/SectionConfigConverterTest.php @@ -8,7 +8,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -class SectionConfigConverterTest extends \PHPUnit_Framework_TestCase +class SectionConfigConverterTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Customer\CustomerData\SectionConfigConverter */ protected $converter; diff --git a/app/code/Magento/Customer/Test/Unit/CustomerData/SectionPoolTest.php b/app/code/Magento/Customer/Test/Unit/CustomerData/SectionPoolTest.php index bc673ed0dccee..98fee70e335f7 100644 --- a/app/code/Magento/Customer/Test/Unit/CustomerData/SectionPoolTest.php +++ b/app/code/Magento/Customer/Test/Unit/CustomerData/SectionPoolTest.php @@ -8,7 +8,7 @@ use Magento\Customer\CustomerData\SectionPool; -class SectionPoolTest extends \PHPUnit_Framework_TestCase +class SectionPoolTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -32,14 +32,8 @@ class SectionPoolTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class, [], [], '', false); - $this->identifierMock = $this->getMock( - \Magento\Customer\CustomerData\Section\Identifier::class, - [], - [], - '', - false - ); + $this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); + $this->identifierMock = $this->createMock(\Magento\Customer\CustomerData\Section\Identifier::class); $this->sectionSourceMap = ['section1' => 'b']; $this->model = new SectionPool( $this->objectManagerMock, @@ -60,13 +54,7 @@ public function testGetSectionsDataAllSections() ]; $identifierResult = [1, 2, 3]; - $sectionSourceMock = $this->getMock( - \Magento\Customer\CustomerData\SectionSourceInterface::class, - [], - [], - '', - false - ); + $sectionSourceMock = $this->createMock(\Magento\Customer\CustomerData\SectionSourceInterface::class); $this->objectManagerMock->expects($this->once()) ->method('get') ->with('b') diff --git a/app/code/Magento/Customer/Test/Unit/Helper/AddressTest.php b/app/code/Magento/Customer/Test/Unit/Helper/AddressTest.php index fcddc34a5bca3..7b42e8b7774c8 100644 --- a/app/code/Magento/Customer/Test/Unit/Helper/AddressTest.php +++ b/app/code/Magento/Customer/Test/Unit/Helper/AddressTest.php @@ -7,12 +7,13 @@ namespace Magento\Customer\Test\Unit\Helper; use Magento\Customer\Api\AddressMetadataInterface; +use Magento\Customer\Api\AddressMetadataManagementInterface; use Magento\Customer\Api\CustomerMetadataInterface; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class AddressTest extends \PHPUnit_Framework_TestCase +class AddressTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Customer\Helper\Address|\PHPUnit_Framework_MockObject_MockObject */ protected $helper; @@ -35,6 +36,9 @@ class AddressTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Customer\Model\Address\Config|\PHPUnit_Framework_MockObject_MockObject */ protected $addressConfig; + /** @var \Magento\Customer\Model\Metadata\AttributeResolver|\PHPUnit_Framework_MockObject_MockObject */ + protected $attributeResolver; + /** @var \PHPUnit_Framework_MockObject_MockObject|AddressMetadataInterface */ private $addressMetadataService; @@ -51,6 +55,7 @@ protected function setUp() $this->customerMetadataService = $arguments['customerMetadataService']; $this->addressConfig = $arguments['addressConfig']; $this->addressMetadataService = $arguments['addressMetadataService']; + $this->attributeResolver = $arguments['attributeResolver']; $this->helper = $objectManagerHelper->getObject($className, $arguments); } @@ -322,9 +327,11 @@ public function testGetFormatTypeRenderer($code, $result) $this->addressConfig->expects($this->once()) ->method('getFormatByCode') ->with($code) - ->will($this->returnValue( - new \Magento\Framework\DataObject($result !== null ? ['renderer' => $result] : []) - )); + ->will( + $this->returnValue( + new \Magento\Framework\DataObject($result !== null ? ['renderer' => $result] : []) + ) + ); $this->assertEquals($result, $this->helper->getFormatTypeRenderer($code)); } @@ -334,7 +341,7 @@ public function getFormatTypeRendererDataProvider() ->disableOriginalConstructor()->getMock(); return [ ['valid_code', $renderer], - ['invalid_code', null] + ['invalid_code', null], ]; } @@ -355,9 +362,11 @@ public function testGetFormat($code, $result) $this->addressConfig->expects($this->once()) ->method('getFormatByCode') ->with($code) - ->will($this->returnValue( - new \Magento\Framework\DataObject(!empty($result) ? ['renderer' => $renderer] : []) - )); + ->will( + $this->returnValue( + new \Magento\Framework\DataObject(!empty($result) ? ['renderer' => $renderer] : []) + ) + ); $this->assertEquals($result, $this->helper->getFormat($code)); } @@ -366,7 +375,7 @@ public function getFormatDataProvider() { return [ ['valid_code', ['key' => 'value']], - ['invalid_code', ''] + ['invalid_code', ''], ]; } @@ -396,7 +405,71 @@ public function isAttributeVisibleDataProvider() { return [ ['fax', true], - ['invalid_code', false] + ['invalid_code', false], + ]; + } + + /** + * @dataProvider attributeOnFormDataProvider + * @param bool $isAllowed + * @param bool $isMetadataExists + * @param string $attributeCode + * @param string $formName + * @param array $attributeFormsList + */ + public function testIsAttributeAllowedOnForm( + $isAllowed, + $isMetadataExists, + $attributeCode, + $formName, + array $attributeFormsList + ) { + $attributeMetadata = null; + if ($isMetadataExists) { + $attributeMetadata = $this->getMockBuilder(\Magento\Customer\Api\Data\AttributeMetadataInterface::class) + ->getMockForAbstractClass(); + $attribute = $this->getMockBuilder(\Magento\Customer\Model\Attribute::class) + ->disableOriginalConstructor() + ->getMock(); + $this->attributeResolver->expects($this->once()) + ->method('getModelByAttribute') + ->with(AddressMetadataManagementInterface::ENTITY_TYPE_ADDRESS, $attributeMetadata) + ->willReturn($attribute); + $attribute->expects($this->once()) + ->method('getUsedInForms') + ->willReturn($attributeFormsList); + } + $this->addressMetadataService->expects($this->once()) + ->method('getAttributeMetadata') + ->with($attributeCode) + ->willReturn($attributeMetadata); + $this->assertEquals($isAllowed, $this->helper->isAttributeAllowedOnForm($attributeCode, $formName)); + } + + public function attributeOnFormDataProvider() + { + return [ + 'metadata not exists' => [ + 'isAllowed' => false, + 'isMetadataExists' => false, + 'attributeCode' => 'attribute_code', + 'formName' => 'form_name', + 'attributeFormsList' => [], + ], + 'form not in the list' => [ + 'isAllowed' => false, + 'isMetadataExists' => true, + 'attributeCode' => 'attribute_code', + 'formName' => 'form_name', + 'attributeFormsList' => ['form_1', 'form_2'], + ], + 'allowed' => [ + 'isAllowed' => true, + 'isMetadataExists' => true, + 'attributeCode' => 'attribute_code', + 'formName' => 'form_name', + 'attributeFormsList' => ['form_name', 'form_1', 'form_2'], + ], ]; } } diff --git a/app/code/Magento/Customer/Test/Unit/Helper/Session/CurrentCustomerAddressTest.php b/app/code/Magento/Customer/Test/Unit/Helper/Session/CurrentCustomerAddressTest.php index f2eca7fec5174..788f8f834684b 100644 --- a/app/code/Magento/Customer/Test/Unit/Helper/Session/CurrentCustomerAddressTest.php +++ b/app/code/Magento/Customer/Test/Unit/Helper/Session/CurrentCustomerAddressTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Customer\Test\Unit\Helper\Session; -class CurrentCustomerAddressTest extends \PHPUnit_Framework_TestCase +class CurrentCustomerAddressTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Helper\Session\CurrentCustomerAddress diff --git a/app/code/Magento/Customer/Test/Unit/Helper/Session/CurrentCustomerTest.php b/app/code/Magento/Customer/Test/Unit/Helper/Session/CurrentCustomerTest.php index 3c502ab9c2987..16259191b7d28 100644 --- a/app/code/Magento/Customer/Test/Unit/Helper/Session/CurrentCustomerTest.php +++ b/app/code/Magento/Customer/Test/Unit/Helper/Session/CurrentCustomerTest.php @@ -8,7 +8,7 @@ namespace Magento\Customer\Test\Unit\Helper\Session; -class CurrentCustomerTest extends \PHPUnit_Framework_TestCase +class CurrentCustomerTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Helper\Session\CurrentCustomer @@ -70,32 +70,14 @@ class CurrentCustomerTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->customerSessionMock = $this->getMock(\Magento\Customer\Model\Session::class, [], [], '', false); - $this->layoutMock = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); - $this->customerInterfaceFactoryMock = $this->getMock( - \Magento\Customer\Api\Data\CustomerInterfaceFactory::class, - ['create', 'setGroupId'], - [], - '', - false - ); - $this->customerDataMock = $this->getMock( - \Magento\Customer\Api\Data\CustomerInterface::class, - [], - [], - '', - false - ); - $this->customerRepositoryMock = $this->getMock( - \Magento\Customer\Api\CustomerRepositoryInterface::class, - [], - [], - '', - false - ); - $this->requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); - $this->moduleManagerMock = $this->getMock(\Magento\Framework\Module\Manager::class, [], [], '', false); - $this->viewMock = $this->getMock(\Magento\Framework\App\View::class, [], [], '', false); + $this->customerSessionMock = $this->createMock(\Magento\Customer\Model\Session::class); + $this->layoutMock = $this->createMock(\Magento\Framework\View\Layout::class); + $this->customerInterfaceFactoryMock = $this->createPartialMock(\Magento\Customer\Api\Data\CustomerInterfaceFactory::class, ['create', 'setGroupId']); + $this->customerDataMock = $this->createMock(\Magento\Customer\Api\Data\CustomerInterface::class); + $this->customerRepositoryMock = $this->createMock(\Magento\Customer\Api\CustomerRepositoryInterface::class); + $this->requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class); + $this->moduleManagerMock = $this->createMock(\Magento\Framework\Module\Manager::class); + $this->viewMock = $this->createMock(\Magento\Framework\App\View::class); $this->currentCustomer = new \Magento\Customer\Helper\Session\CurrentCustomer( $this->customerSessionMock, diff --git a/app/code/Magento/Customer/Test/Unit/Helper/ViewTest.php b/app/code/Magento/Customer/Test/Unit/Helper/ViewTest.php index 7d490ebaf4142..108b2a4bf9602 100644 --- a/app/code/Magento/Customer/Test/Unit/Helper/ViewTest.php +++ b/app/code/Magento/Customer/Test/Unit/Helper/ViewTest.php @@ -7,7 +7,7 @@ use Magento\Customer\Api\CustomerMetadataInterface; -class ViewTest extends \PHPUnit_Framework_TestCase +class ViewTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Framework\App\Helper\Context|\PHPUnit_Framework_MockObject_MockObject */ protected $context; @@ -23,9 +23,9 @@ protected function setUp() $this->context = $this->getMockBuilder(\Magento\Framework\App\Helper\Context::class) ->disableOriginalConstructor() ->getMock(); - $this->customerMetadataService = $this->getMock(\Magento\Customer\Api\CustomerMetadataInterface::class); + $this->customerMetadataService = $this->createMock(\Magento\Customer\Api\CustomerMetadataInterface::class); - $attributeMetadata = $this->getMock(\Magento\Customer\Api\Data\AttributeMetadataInterface::class); + $attributeMetadata = $this->createMock(\Magento\Customer\Api\Data\AttributeMetadataInterface::class); $attributeMetadata->expects($this->any())->method('isVisible')->will($this->returnValue(true)); $this->customerMetadataService->expects($this->any()) ->method('getAttributeMetadata') diff --git a/app/code/Magento/Customer/Test/Unit/Model/Account/RedirectTest.php b/app/code/Magento/Customer/Test/Unit/Model/Account/RedirectTest.php index 1f917e4e16abe..95e6223d91afb 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Account/RedirectTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Account/RedirectTest.php @@ -20,7 +20,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class RedirectTest extends \PHPUnit_Framework_TestCase +class RedirectTest extends \PHPUnit\Framework\TestCase { /** * @var Redirect @@ -125,6 +125,7 @@ protected function setUp() $this->urlDecoder = $this->getMockForAbstractClass(\Magento\Framework\Url\DecoderInterface::class); $this->customerUrl = $this->getMockBuilder(\Magento\Customer\Model\Url::class) + ->setMethods(['DashboardUrl', 'getAccountUrl', 'getLoginUrl', 'getLogoutUrl', 'getDashboardUrl']) ->disableOriginalConstructor() ->getMock(); @@ -241,7 +242,7 @@ public function testGetRedirect( ->method('getLogoutUrl') ->willReturn($logoutUrl); $this->customerUrl->expects($this->any()) - ->method('DashboardUrl') + ->method('getDashboardUrl') ->willReturn($dashboardUrl); $this->scopeConfig->expects($this->any()) diff --git a/app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php b/app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php index 0604242b216b3..de9c0460ad29e 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php @@ -5,9 +5,9 @@ */ namespace Magento\Customer\Test\Unit\Model; +use Magento\Customer\Model\AccountManagement; use Magento\Customer\Model\AuthenticationInterface; use Magento\Customer\Model\EmailNotificationInterface; -use Magento\Customer\Model\AccountManagement; use Magento\Framework\App\Area; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; @@ -17,7 +17,7 @@ * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class AccountManagementTest extends \PHPUnit_Framework_TestCase +class AccountManagementTest extends \PHPUnit\Framework\TestCase { /** @var AccountManagement */ protected $accountManagement; @@ -119,63 +119,37 @@ class AccountManagementTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->customerFactory = $this->getMock( - \Magento\Customer\Model\CustomerFactory::class, - ['create'], - [], - '', - false - ); - $this->manager = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); + $this->customerFactory = $this->createPartialMock(\Magento\Customer\Model\CustomerFactory::class, ['create']); + $this->manager = $this->createMock(\Magento\Framework\Event\ManagerInterface::class); $this->store = $this->getMockBuilder(\Magento\Store\Model\Store::class) ->disableOriginalConstructor() ->getMock(); - $this->storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); - $this->random = $this->getMock(\Magento\Framework\Math\Random::class); - $this->validator = $this->getMock(\Magento\Customer\Model\Metadata\Validator::class, [], [], '', false); - $this->validationResultsInterfaceFactory = $this->getMock( - \Magento\Customer\Api\Data\ValidationResultsInterfaceFactory::class, - [], - [], - '', - false + $this->storeManager = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->random = $this->createMock(\Magento\Framework\Math\Random::class); + $this->validator = $this->createMock(\Magento\Customer\Model\Metadata\Validator::class); + $this->validationResultsInterfaceFactory = $this->createMock( + \Magento\Customer\Api\Data\ValidationResultsInterfaceFactory::class ); - $this->addressRepository = $this->getMock(\Magento\Customer\Api\AddressRepositoryInterface::class); - $this->customerMetadata = $this->getMock(\Magento\Customer\Api\CustomerMetadataInterface::class); - $this->customerRegistry = $this->getMock(\Magento\Customer\Model\CustomerRegistry::class, [], [], '', false); - $this->logger = $this->getMock(\Psr\Log\LoggerInterface::class); - $this->encryptor = $this->getMock(\Magento\Framework\Encryption\EncryptorInterface::class); - $this->share = $this->getMock(\Magento\Customer\Model\Config\Share::class, [], [], '', false); - $this->string = $this->getMock(\Magento\Framework\Stdlib\StringUtils::class); - $this->customerRepository = $this->getMock(\Magento\Customer\Api\CustomerRepositoryInterface::class); + $this->addressRepository = $this->createMock(\Magento\Customer\Api\AddressRepositoryInterface::class); + $this->customerMetadata = $this->createMock(\Magento\Customer\Api\CustomerMetadataInterface::class); + $this->customerRegistry = $this->createMock(\Magento\Customer\Model\CustomerRegistry::class); + $this->logger = $this->createMock(\Psr\Log\LoggerInterface::class); + $this->encryptor = $this->createMock(\Magento\Framework\Encryption\EncryptorInterface::class); + $this->share = $this->createMock(\Magento\Customer\Model\Config\Share::class); + $this->string = $this->createMock(\Magento\Framework\Stdlib\StringUtils::class); + $this->customerRepository = $this->createMock(\Magento\Customer\Api\CustomerRepositoryInterface::class); $this->scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->transportBuilder = $this->getMock( - \Magento\Framework\Mail\Template\TransportBuilder::class, - [], - [], - '', - false - ); - $this->dataObjectProcessor = $this->getMock( - \Magento\Framework\Reflection\DataObjectProcessor::class, - [], - [], - '', - false - ); - $this->registry = $this->getMock(\Magento\Framework\Registry::class); - $this->customerViewHelper = $this->getMock(\Magento\Customer\Helper\View::class, [], [], '', false); - $this->dateTime = $this->getMock(\Magento\Framework\Stdlib\DateTime::class); - $this->customer = $this->getMock(\Magento\Customer\Model\Customer::class, [], [], '', false); - $this->objectFactory = $this->getMock(\Magento\Framework\DataObjectFactory::class, [], [], '', false); - $this->extensibleDataObjectConverter = $this->getMock( - \Magento\Framework\Api\ExtensibleDataObjectConverter::class, - [], - [], - '', - false + $this->transportBuilder = $this->createMock(\Magento\Framework\Mail\Template\TransportBuilder::class); + $this->dataObjectProcessor = $this->createMock(\Magento\Framework\Reflection\DataObjectProcessor::class); + $this->registry = $this->createMock(\Magento\Framework\Registry::class); + $this->customerViewHelper = $this->createMock(\Magento\Customer\Helper\View::class); + $this->dateTime = $this->createMock(\Magento\Framework\Stdlib\DateTime::class); + $this->customer = $this->createMock(\Magento\Customer\Model\Customer::class); + $this->objectFactory = $this->createMock(\Magento\Framework\DataObjectFactory::class); + $this->extensibleDataObjectConverter = $this->createMock( + \Magento\Framework\Api\ExtensibleDataObjectConverter::class ); $this->authenticationMock = $this->getMockBuilder(AuthenticationInterface::class) ->disableOriginalConstructor() @@ -185,6 +159,7 @@ protected function setUp() ->getMock(); $this->customerSecure = $this->getMockBuilder(\Magento\Customer\Model\Data\CustomerSecure::class) + ->setMethods(['setRpToken', 'addData', 'setRpTokenCreatedAt', 'setData']) ->disableOriginalConstructor() ->getMock(); @@ -642,6 +617,7 @@ public function testCreateAccountWithoutPassword() ->method('getUniqueHash') ->willReturn($newLinkToken); $customerSecure = $this->getMockBuilder(\Magento\Customer\Model\Data\CustomerSecure::class) + ->setMethods(['setRpToken', 'setRpTokenCreatedAt', 'getPasswordHash']) ->disableOriginalConstructor() ->getMock(); $customerSecure->expects($this->any()) @@ -724,14 +700,14 @@ public function testCreateAccountWithPasswordInputException( ->willReturn(iconv_strlen($password, 'UTF-8')); if ($testNumber == 1) { - $this->setExpectedException( + $this->expectException( \Magento\Framework\Exception\InputException::class, 'Please enter a password with at least ' . $minPasswordLength . ' characters.' ); } if ($testNumber == 2) { - $this->setExpectedException( + $this->expectException( \Magento\Framework\Exception\InputException::class, 'Minimum of different classes of characters in password is ' . $minCharacterSetsNum . '. Classes of characters: Lower Case, Upper Case, Digits, Special Characters.' @@ -753,7 +729,7 @@ public function testCreateAccountInputExceptionExtraLongPassword() ->with($password) ->willReturn(iconv_strlen($password, 'UTF-8')); - $this->setExpectedException( + $this->expectException( \Magento\Framework\Exception\InputException::class, 'Please enter a password with at most 256 characters.' ); @@ -1403,7 +1379,7 @@ public function testChangePasswordException() ->with($email) ->willThrowException($exception); - $this->setExpectedException( + $this->expectException( \Magento\Framework\Exception\InvalidEmailOrPasswordException::class, 'Invalid login or password.' ); diff --git a/app/code/Magento/Customer/Test/Unit/Model/Address/AbstractAddressTest.php b/app/code/Magento/Customer/Test/Unit/Model/Address/AbstractAddressTest.php index b21556a3cbc61..23b8b38c962b9 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Address/AbstractAddressTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Address/AbstractAddressTest.php @@ -9,7 +9,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class AbstractAddressTest extends \PHPUnit_Framework_TestCase +class AbstractAddressTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Framework\Model\Context|\PHPUnit_Framework_MockObject_MockObject */ protected $contextMock; @@ -43,36 +43,21 @@ class AbstractAddressTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->contextMock = $this->getMock(\Magento\Framework\Model\Context::class, [], [], '', false); - $this->registryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); - $this->directoryDataMock = $this->getMock(\Magento\Directory\Helper\Data::class, [], [], '', false); - $this->eavConfigMock = $this->getMock(\Magento\Eav\Model\Config::class, [], [], '', false); - $this->addressConfigMock = $this->getMock(\Magento\Customer\Model\Address\Config::class, [], [], '', false); - $this->regionFactoryMock = $this->getMock( - \Magento\Directory\Model\RegionFactory::class, - ['create'], - [], - '', - false - ); - $this->countryFactoryMock = $this->getMock( + $this->contextMock = $this->createMock(\Magento\Framework\Model\Context::class); + $this->registryMock = $this->createMock(\Magento\Framework\Registry::class); + $this->directoryDataMock = $this->createMock(\Magento\Directory\Helper\Data::class); + $this->eavConfigMock = $this->createMock(\Magento\Eav\Model\Config::class); + $this->addressConfigMock = $this->createMock(\Magento\Customer\Model\Address\Config::class); + $this->regionFactoryMock = $this->createPartialMock(\Magento\Directory\Model\RegionFactory::class, ['create']); + $this->countryFactoryMock = $this->createPartialMock( \Magento\Directory\Model\CountryFactory::class, - ['create'], - [], - '', - false - ); - $regionCollectionMock = $this->getMock( - \Magento\Directory\Model\ResourceModel\Region\Collection::class, - [], - [], - '', - false + ['create'] ); + $regionCollectionMock = $this->createMock(\Magento\Directory\Model\ResourceModel\Region\Collection::class); $regionCollectionMock->expects($this->any()) ->method('getSize') ->will($this->returnValue(0)); - $countryMock = $this->getMock(\Magento\Directory\Model\Country::class, [], [], '', false); + $countryMock = $this->createMock(\Magento\Directory\Model\Country::class); $countryMock->expects($this->any()) ->method('getRegionCollection') ->will($this->returnValue($regionCollectionMock)); @@ -80,7 +65,7 @@ protected function setUp() ->method('create') ->will($this->returnValue($countryMock)); - $this->resourceMock = $this->getMock(\Magento\Customer\Model\ResourceModel\Customer::class, [], [], '', false); + $this->resourceMock = $this->createMock(\Magento\Customer\Model\ResourceModel\Customer::class); $this->resourceCollectionMock = $this->getMockBuilder(\Magento\Framework\Data\Collection\AbstractDb::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -182,12 +167,9 @@ public function testGetRegionCodeWithoutRegion() */ protected function prepareGetRegion($countryId, $regionName = 'RegionName') { - $region = $this->getMock( + $region = $this->createPartialMock( \Magento\Directory\Model\Region::class, - ['getCountryId', 'getName', '__wakeup', 'load'], - [], - '', - false + ['getCountryId', 'getName', '__wakeup', 'load'] ); $region->expects($this->once()) ->method('getName') @@ -205,12 +187,9 @@ protected function prepareGetRegion($countryId, $regionName = 'RegionName') */ protected function prepareGetRegionCode($countryId, $regionCode = 'UK') { - $region = $this->getMock( + $region = $this->createPartialMock( \Magento\Directory\Model\Region::class, - ['getCountryId', 'getCode', '__wakeup', 'load'], - [], - '', - false + ['getCountryId', 'getCode', '__wakeup', 'load'] ); $region->expects($this->once()) ->method('getCode') @@ -303,7 +282,7 @@ public function testSetDataWithObject() */ public function testValidate($data, $expected) { - $attributeMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute::class, [], [], '', false); + $attributeMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute::class); $attributeMock->expects($this->any()) ->method('getIsRequired') ->willReturn(true); diff --git a/app/code/Magento/Customer/Test/Unit/Model/Address/Config/ConverterTest.php b/app/code/Magento/Customer/Test/Unit/Model/Address/Config/ConverterTest.php index 67096d79e5f30..26ebc519019ad 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Address/Config/ConverterTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Address/Config/ConverterTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Customer\Test\Unit\Model\Address\Config; -class ConverterTest extends \PHPUnit_Framework_TestCase +class ConverterTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Model\Address\Config\Converter diff --git a/app/code/Magento/Customer/Test/Unit/Model/Address/Config/ReaderTest.php b/app/code/Magento/Customer/Test/Unit/Model/Address/Config/ReaderTest.php index 9c2c37a6420f8..216d891a9b985 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Address/Config/ReaderTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Address/Config/ReaderTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Customer\Test\Unit\Model\Address\Config; -class ReaderTest extends \PHPUnit_Framework_TestCase +class ReaderTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Model\Address\Config\Reader @@ -34,7 +34,7 @@ class ReaderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_fileResolverMock = $this->getMock(\Magento\Framework\Config\FileResolverInterface::class); + $this->_fileResolverMock = $this->createMock(\Magento\Framework\Config\FileResolverInterface::class); $this->_fileResolverMock->expects( $this->once() )->method( @@ -51,16 +51,13 @@ protected function setUp() ) ); - $this->_converter = $this->getMock(\Magento\Customer\Model\Address\Config\Converter::class, ['convert']); - - $moduleReader = $this->getMock( - \Magento\Framework\Module\Dir\Reader::class, - ['getModuleDir'], - [], - '', - false + $this->_converter = $this->createPartialMock( + \Magento\Customer\Model\Address\Config\Converter::class, + ['convert'] ); + $moduleReader = $this->createPartialMock(\Magento\Framework\Module\Dir\Reader::class, ['getModuleDir']); + $moduleReader->expects( $this->once() )->method( @@ -73,7 +70,7 @@ protected function setUp() ); $this->_schemaLocator = new \Magento\Customer\Model\Address\Config\SchemaLocator($moduleReader); - $this->_validationState = $this->getMock(\Magento\Framework\Config\ValidationStateInterface::class); + $this->_validationState = $this->createMock(\Magento\Framework\Config\ValidationStateInterface::class); $this->_validationState->expects($this->any()) ->method('isValidationRequired') ->willReturn(false); @@ -92,9 +89,9 @@ public function testRead() $constraint = function (\DOMDocument $actual) { try { $expected = __DIR__ . '/_files/formats_merged.xml'; - \PHPUnit_Framework_Assert::assertXmlStringEqualsXmlFile($expected, $actual->saveXML()); + \PHPUnit\Framework\Assert::assertXmlStringEqualsXmlFile($expected, $actual->saveXML()); return true; - } catch (\PHPUnit_Framework_AssertionFailedError $e) { + } catch (\PHPUnit\Framework\AssertionFailedError $e) { return false; } }; diff --git a/app/code/Magento/Customer/Test/Unit/Model/Address/Config/SchemaLocatorTest.php b/app/code/Magento/Customer/Test/Unit/Model/Address/Config/SchemaLocatorTest.php index b76835e6d25d0..0faabf7c4852f 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Address/Config/SchemaLocatorTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Address/Config/SchemaLocatorTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Customer\Test\Unit\Model\Address\Config; -class SchemaLocatorTest extends \PHPUnit_Framework_TestCase +class SchemaLocatorTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Model\Address\Config\SchemaLocator @@ -30,13 +30,7 @@ class SchemaLocatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_xsdFile = $this->_xsdDir . '/address_formats.xsd'; - $this->_moduleReader = $this->getMock( - \Magento\Framework\Module\Dir\Reader::class, - ['getModuleDir'], - [], - '', - false - ); + $this->_moduleReader = $this->createPartialMock(\Magento\Framework\Module\Dir\Reader::class, ['getModuleDir']); $this->_moduleReader->expects( $this->once() )->method( diff --git a/app/code/Magento/Customer/Test/Unit/Model/Address/Config/XsdTest.php b/app/code/Magento/Customer/Test/Unit/Model/Address/Config/XsdTest.php index db7971326813f..1b013a913b9f8 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Address/Config/XsdTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Address/Config/XsdTest.php @@ -7,7 +7,7 @@ */ namespace Magento\Customer\Test\Unit\Model\Address\Config; -class XsdTest extends \PHPUnit_Framework_TestCase +class XsdTest extends \PHPUnit\Framework\TestCase { /** * @var string @@ -30,13 +30,7 @@ protected function setUp() */ public function testExemplarXml($fixtureXml, array $expectedErrors) { - $validationStateMock = $this->getMock( - \Magento\Framework\Config\ValidationStateInterface::class, - [], - [], - '', - false - ); + $validationStateMock = $this->createMock(\Magento\Framework\Config\ValidationStateInterface::class); $validationStateMock->method('isValidationRequired') ->willReturn(true); $dom = new \Magento\Framework\Config\Dom($fixtureXml, $validationStateMock, [], null, null, '%message%'); diff --git a/app/code/Magento/Customer/Test/Unit/Model/Address/ConfigTest.php b/app/code/Magento/Customer/Test/Unit/Model/Address/ConfigTest.php index 241bd9a2f651d..0680fa3583f00 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Address/ConfigTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Address/ConfigTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Customer\Test\Unit\Model\Address; -class ConfigTest extends \PHPUnit_Framework_TestCase +class ConfigTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -31,18 +31,12 @@ protected function setUp() { $cacheId = 'cache_id'; $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); - $this->scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - - $readerMock = $this->getMock( - \Magento\Customer\Model\Address\Config\Reader::class, - [], - [], - '', - false - ); - $cacheMock = $this->getMock(\Magento\Framework\Config\CacheInterface::class); - $storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); + $this->storeMock = $this->createMock(\Magento\Store\Model\Store::class); + $this->scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + + $readerMock = $this->createMock(\Magento\Customer\Model\Address\Config\Reader::class); + $cacheMock = $this->createMock(\Magento\Framework\Config\CacheInterface::class); + $storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManager::class); $storeManagerMock->expects( $this->once() )->method( @@ -51,7 +45,7 @@ protected function setUp() $this->returnValue($this->storeMock) ); - $this->addressHelperMock = $this->getMock(\Magento\Customer\Helper\Address::class, [], [], '', false); + $this->addressHelperMock = $this->createMock(\Magento\Customer\Helper\Address::class); $cacheMock->expects( $this->once() @@ -74,7 +68,7 @@ protected function setUp() $cacheId ); - $serializerMock = $this->getMock(\Magento\Framework\Serialize\SerializerInterface::class); + $serializerMock = $this->createMock(\Magento\Framework\Serialize\SerializerInterface::class); $serializerMock->method('serialize') ->willReturn(json_encode($fixtureConfigData)); $serializerMock->method('unserialize') @@ -111,7 +105,7 @@ public function testGetFormats() $this->scopeConfigMock->expects($this->any())->method('getValue')->will($this->returnValue('someValue')); - $rendererMock = $this->getMock(\Magento\Framework\DataObject::class); + $rendererMock = $this->createMock(\Magento\Framework\DataObject::class); $this->addressHelperMock->expects( $this->any() diff --git a/app/code/Magento/Customer/Test/Unit/Model/Address/MapperTest.php b/app/code/Magento/Customer/Test/Unit/Model/Address/MapperTest.php index 5fe1896bd64c0..2ca33e15239e6 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Address/MapperTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Address/MapperTest.php @@ -6,7 +6,7 @@ namespace Magento\Customer\Test\Unit\Model\Address; -class MapperTest extends \PHPUnit_Framework_TestCase +class MapperTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager */ protected $_objectManager; @@ -71,13 +71,21 @@ protected function createAddressMock() $regionMock->expects($this->any())->method('getRegion')->willReturn('Texas'); $regionMock->expects($this->any())->method('getRegionId')->willReturn(1); $regionMock->expects($this->any())->method('getRegionCode')->willReturn('TX'); - /** @var \Magento\Customer\Api\Data\AddressInterface|\PHPUnit_Framework_MockObject_MockObject $regionMock */ - $addressMock = $this->getMockForAbstractClass( - \Magento\Customer\Api\Data\AddressInterface::class, - [], - '', - false - ); + $addressMock = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterface::class) + ->setMethods( + [ + 'getId', + 'getDefaultBilling', + 'getDefaultShipping', + 'getCity', + 'getFirstname', + 'getLastname', + 'getCountryId', + 'getRegion', + 'getStreet' + ] + ) + ->getMockForAbstractClass(); $addressMock->expects($this->any())->method('getId')->willReturn('1'); $addressMock->expects($this->any())->method('getDefaultBilling')->willReturn(true); $addressMock->expects($this->any())->method('getDefaultShipping')->willReturn(false); diff --git a/app/code/Magento/Customer/Test/Unit/Model/Address/Validator/PostcodeTest.php b/app/code/Magento/Customer/Test/Unit/Model/Address/Validator/PostcodeTest.php index da684622e92c5..9bf6f88cc3952 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Address/Validator/PostcodeTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Address/Validator/PostcodeTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Customer\Test\Unit\Model\Address\Validator; -class PostcodeTest extends \PHPUnit_Framework_TestCase +class PostcodeTest extends \PHPUnit\Framework\TestCase { /** * Check postcode test diff --git a/app/code/Magento/Customer/Test/Unit/Model/AddressRegistryTest.php b/app/code/Magento/Customer/Test/Unit/Model/AddressRegistryTest.php index a7069203761ae..83cfe24f3e69f 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/AddressRegistryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/AddressRegistryTest.php @@ -7,7 +7,7 @@ */ namespace Magento\Customer\Test\Unit\Model; -class AddressRegistryTest extends \PHPUnit_Framework_TestCase +class AddressRegistryTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Model\AddressRegistry diff --git a/app/code/Magento/Customer/Test/Unit/Model/AddressTest.php b/app/code/Magento/Customer/Test/Unit/Model/AddressTest.php index 2e419084334c5..9c01177375529 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/AddressTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/AddressTest.php @@ -6,7 +6,7 @@ namespace Magento\Customer\Test\Unit\Model; -class AddressTest extends \PHPUnit_Framework_TestCase +class AddressTest extends \PHPUnit\Framework\TestCase { const ORIG_CUSTOMER_ID = 1; const ORIG_PARENT_ID = 2; diff --git a/app/code/Magento/Customer/Test/Unit/Model/App/Action/ContextPluginTest.php b/app/code/Magento/Customer/Test/Unit/Model/App/Action/ContextPluginTest.php index 563fa91df3d32..4b89fda7c7051 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/App/Action/ContextPluginTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/App/Action/ContextPluginTest.php @@ -11,7 +11,7 @@ /** * Class ContextPluginTest */ -class ContextPluginTest extends \PHPUnit_Framework_TestCase +class ContextPluginTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Model\App\Action\ContextPlugin @@ -43,22 +43,10 @@ class ContextPluginTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->customerSessionMock = $this->getMock( - \Magento\Customer\Model\Session::class, - [], - [], - '', - false - ); - $this->httpContextMock = $this->getMock( - \Magento\Framework\App\Http\Context::class, - [], - [], - '', - false - ); - $this->subjectMock = $this->getMock(\Magento\Framework\App\Action\Action::class, [], [], '', false); - $this->requestMock = $this->getMock(\Magento\Framework\App\RequestInterface::class); + $this->customerSessionMock = $this->createMock(\Magento\Customer\Model\Session::class); + $this->httpContextMock = $this->createMock(\Magento\Framework\App\Http\Context::class); + $this->subjectMock = $this->createMock(\Magento\Framework\App\Action\Action::class); + $this->requestMock = $this->createMock(\Magento\Framework\App\RequestInterface::class); $this->plugin = new \Magento\Customer\Model\App\Action\ContextPlugin( $this->customerSessionMock, $this->httpContextMock diff --git a/app/code/Magento/Customer/Test/Unit/Model/Attribute/Backend/BooleanTest.php b/app/code/Magento/Customer/Test/Unit/Model/Attribute/Backend/BooleanTest.php index e8d0d1e25e82b..fda1b6a965632 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Attribute/Backend/BooleanTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Attribute/Backend/BooleanTest.php @@ -6,7 +6,7 @@ namespace Magento\Customer\Test\Unit\Model\Attribute\Backend; -class BooleanTest extends \PHPUnit_Framework_TestCase +class BooleanTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Model\Attribute\Backend\Data\Boolean diff --git a/app/code/Magento/Customer/Test/Unit/Model/Attribute/Data/PostcodeTest.php b/app/code/Magento/Customer/Test/Unit/Model/Attribute/Data/PostcodeTest.php index f2f1d7afa7e2a..d92def532ebf6 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Attribute/Data/PostcodeTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Attribute/Data/PostcodeTest.php @@ -9,7 +9,7 @@ use Magento\Directory\Helper\Data as DirectoryHelper; use Magento\Eav\Model\Entity\Attribute\AbstractAttribute; -class PostcodeTest extends \PHPUnit_Framework_TestCase +class PostcodeTest extends \PHPUnit\Framework\TestCase { /** * @var DirectoryHelper|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Customer/Test/Unit/Model/AttributeMetadatConverterTest.php b/app/code/Magento/Customer/Test/Unit/Model/AttributeMetadatConverterTest.php index cff1cb053547a..01fc8c01970b1 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/AttributeMetadatConverterTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/AttributeMetadatConverterTest.php @@ -15,7 +15,7 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @package Magento\Customer\Test\Unit\Model */ -class AttributeMetadatConverterTest extends \PHPUnit_Framework_TestCase +class AttributeMetadatConverterTest extends \PHPUnit\Framework\TestCase { /** * @var OptionInterfaceFactory | \PHPUnit_Framework_MockObject_MockObject @@ -112,8 +112,8 @@ public function testCreateAttributeMetadataTestWithSource() $optionDataObjectForSimpleValue2 = $this->getMockBuilder(\Magento\Customer\Model\Data\Option::class) ->disableOriginalConstructor() ->getMock(); - $optionObject1 = $this->getMock(\Magento\Customer\Api\Data\OptionInterface::class); - $optionObject2 = $this->getMock(\Magento\Customer\Api\Data\OptionInterface::class); + $optionObject1 = $this->createMock(\Magento\Customer\Api\Data\OptionInterface::class); + $optionObject2 = $this->createMock(\Magento\Customer\Api\Data\OptionInterface::class); $this->optionFactory->expects($this->exactly(4)) ->method('create') ->will( @@ -151,8 +151,8 @@ public function testCreateAttributeMetadataTestWithSource() [$optionObject1, ['1'], \Magento\Customer\Api\Data\OptionInterface::class], [$optionObject2, ['2'], \Magento\Customer\Api\Data\OptionInterface::class] ); - $validationRule1 = $this->getMock(\Magento\Customer\Api\Data\ValidationRuleInterface::class); - $validationRule2 = $this->getMock(\Magento\Customer\Api\Data\ValidationRuleInterface::class); + $validationRule1 = $this->createMock(\Magento\Customer\Api\Data\ValidationRuleInterface::class); + $validationRule2 = $this->createMock(\Magento\Customer\Api\Data\ValidationRuleInterface::class); $this->validationRuleFactory->expects($this->exactly(2)) ->method('create') ->will($this->onConsecutiveCalls($validationRule1, $validationRule2)); @@ -170,10 +170,16 @@ public function testCreateAttributeMetadataTestWithSource() ->method('setName') ->with('two') ->willReturnSelf(); + + $mockMethods = ['setAttributeCode', 'setFrontendInput']; $attributeMetaData = $this->getMockBuilder(\Magento\Customer\Model\Data\AttributeMetadata::class) + ->setMethods($mockMethods) ->disableOriginalConstructor() - ->enableProxyingToOriginalMethods() ->getMock(); + foreach ($mockMethods as $method) { + $attributeMetaData->expects($this->once())->method($method)->willReturnSelf(); + } + $this->attribute->expects($this->once()) ->method('getValidateRules') ->willReturn($validatedRules); diff --git a/app/code/Magento/Customer/Test/Unit/Model/AttributeTest.php b/app/code/Magento/Customer/Test/Unit/Model/AttributeTest.php index 3f65482f7c7c9..12421eef519ed 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/AttributeTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/AttributeTest.php @@ -19,7 +19,7 @@ * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class AttributeTest extends \PHPUnit_Framework_TestCase +class AttributeTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Model\Attribute @@ -182,7 +182,7 @@ protected function setUp() ->getMock(); $this->resolverMock = $this->getMockBuilder(\Magento\Framework\Locale\ResolverInterface::class) ->getMock(); - $this->dateTimeFormatter = $this->getMock(\Magento\Framework\Stdlib\DateTime\DateTimeFormatterInterface::class); + $this->dateTimeFormatter = $this->createMock(\Magento\Framework\Stdlib\DateTime\DateTimeFormatterInterface::class); $this->resourceMock = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\AbstractResource::class) ->setMethods(['_construct', 'getConnection', 'getIdFieldName', 'saveInSetIncluding']) diff --git a/app/code/Magento/Customer/Test/Unit/Model/AuthenticationTest.php b/app/code/Magento/Customer/Test/Unit/Model/AuthenticationTest.php index 59e85fb9c3f7e..ee788913373e5 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/AuthenticationTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/AuthenticationTest.php @@ -7,9 +7,7 @@ use Magento\Backend\App\ConfigInterface; use Magento\Customer\Api\CustomerRepositoryInterface; -use Magento\Customer\Api\Data\CustomerInterface; use Magento\Customer\Model\Authentication; -use Magento\Customer\Model\AccountManagement; use Magento\Customer\Model\CustomerRegistry; use Magento\Customer\Model\Data\CustomerSecure; use Magento\Framework\Stdlib\DateTime; @@ -18,7 +16,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class AuthenticationTest extends \PHPUnit_Framework_TestCase +class AuthenticationTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Backend\App\ConfigInterface | \PHPUnit_Framework_MockObject_MockObject @@ -73,12 +71,9 @@ protected function setUp() ->disableOriginalConstructor() ->setMethods(['getValue']) ->getMockForAbstractClass(); - $this->customerRegistryMock = $this->getMock( + $this->customerRegistryMock = $this->createPartialMock( CustomerRegistry::class, - ['retrieveSecureData', 'retrieve'], - [], - '', - false + ['retrieveSecureData', 'retrieve'] ); $this->customerRepositoryMock = $this->getMockBuilder(CustomerRepositoryInterface::class) ->disableOriginalConstructor() @@ -92,9 +87,7 @@ protected function setUp() $this->dateTimeMock->expects($this->any()) ->method('formatDate') ->willReturn('formattedDate'); - $this->customerSecureMock = $this->getMock( - CustomerSecure::class, - [ + $this->customerSecureMock = $this->createPartialMock(CustomerSecure::class, [ 'getId', 'getPasswordHash', 'isCustomerLocked', @@ -104,11 +97,7 @@ protected function setUp() 'setFirstFailure', 'setFailuresNum', 'setLockExpires' - ], - [], - '', - false - ); + ]); $this->customerAuthUpdate = $this->getMockBuilder(\Magento\Customer\Model\CustomerAuthUpdate::class) ->disableOriginalConstructor() @@ -272,13 +261,7 @@ public function testAuthenticate($result) $password = '1234567'; $hash = '1b2af329dd0'; - $customerMock = $this->getMock( - \Magento\Customer\Api\Data\CustomerInterface::class, - [], - [], - '', - false - ); + $customerMock = $this->createMock(\Magento\Customer\Api\Data\CustomerInterface::class); $this->customerRepositoryMock->expects($this->any()) ->method('getById') ->willReturn($customerMock); @@ -325,7 +308,7 @@ public function testAuthenticate($result) ->with($customerId) ->willReturnSelf(); - $this->setExpectedException(\Magento\Framework\Exception\InvalidEmailOrPasswordException::class); + $this->expectException(\Magento\Framework\Exception\InvalidEmailOrPasswordException::class); $this->authentication->authenticate($customerId, $password); } } diff --git a/app/code/Magento/Customer/Test/Unit/Model/Authorization/CustomerSessionUserContextTest.php b/app/code/Magento/Customer/Test/Unit/Model/Authorization/CustomerSessionUserContextTest.php index 28c2f4aeeb56e..35006d78bd56c 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Authorization/CustomerSessionUserContextTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Authorization/CustomerSessionUserContextTest.php @@ -11,7 +11,7 @@ /** * Tests Magento\Customer\Model\Authorization\CustomerSessionUserContext */ -class CustomerSessionUserContextTest extends \PHPUnit_Framework_TestCase +class CustomerSessionUserContextTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager diff --git a/app/code/Magento/Customer/Test/Unit/Model/Backend/CustomerTest.php b/app/code/Magento/Customer/Test/Unit/Model/Backend/CustomerTest.php index 87cd9119cd192..cfba014d1541a 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Backend/CustomerTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Backend/CustomerTest.php @@ -11,7 +11,7 @@ */ namespace Magento\Customer\Test\Unit\Model\Backend; -class CustomerTest extends \PHPUnit_Framework_TestCase +class CustomerTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Store\Model\StoreManager|\PHPUnit_Framework_MockObject_MockObject */ protected $_storeManager; @@ -24,7 +24,7 @@ class CustomerTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->_storeManager = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); + $this->_storeManager = $this->createMock(\Magento\Store\Model\StoreManager::class); $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_model = $helper->getObject( \Magento\Customer\Model\Backend\Customer::class, diff --git a/app/code/Magento/Customer/Test/Unit/Model/Checkout/ConfigProviderTest.php b/app/code/Magento/Customer/Test/Unit/Model/Checkout/ConfigProviderTest.php index 2775a8ece7db9..011ba9091eaf2 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Checkout/ConfigProviderTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Checkout/ConfigProviderTest.php @@ -14,7 +14,7 @@ use Magento\Customer\Model\Form; use Magento\Store\Model\ScopeInterface; -class ConfigProviderTest extends \PHPUnit_Framework_TestCase +class ConfigProviderTest extends \PHPUnit\Framework\TestCase { /** * @var ConfigProvider diff --git a/app/code/Magento/Customer/Test/Unit/Model/Config/Backend/CreateAccount/DisableAutoGroupAssignDefaultTest.php b/app/code/Magento/Customer/Test/Unit/Model/Config/Backend/CreateAccount/DisableAutoGroupAssignDefaultTest.php index 0e1b6e448f451..227857e199557 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Config/Backend/CreateAccount/DisableAutoGroupAssignDefaultTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Config/Backend/CreateAccount/DisableAutoGroupAssignDefaultTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Customer\Test\Unit\Model\Config\Backend\CreateAccount; -class DisableAutoGroupAssignDefaultTest extends \PHPUnit_Framework_TestCase +class DisableAutoGroupAssignDefaultTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Model\Config\Backend\CreateAccount\DisableAutoGroupAssignDefault diff --git a/app/code/Magento/Customer/Test/Unit/Model/Config/Source/Address/TypeTest.php b/app/code/Magento/Customer/Test/Unit/Model/Config/Source/Address/TypeTest.php index 8441b864489e3..beba1cc7a7c81 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Config/Source/Address/TypeTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Config/Source/Address/TypeTest.php @@ -6,7 +6,7 @@ */ namespace Magento\Customer\Test\Unit\Model\Config\Source\Address; -class TypeTest extends \PHPUnit_Framework_TestCase +class TypeTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Model\Config\Source\Address\Type diff --git a/app/code/Magento/Customer/Test/Unit/Model/Config/Source/Group/MultiselectTest.php b/app/code/Magento/Customer/Test/Unit/Model/Config/Source/Group/MultiselectTest.php index ede210583e86b..91a604938e18b 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Config/Source/Group/MultiselectTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Config/Source/Group/MultiselectTest.php @@ -8,7 +8,7 @@ use Magento\Customer\Model\Customer\Attribute\Source\GroupSourceLoggedInOnlyInterface; -class MultiselectTest extends \PHPUnit_Framework_TestCase +class MultiselectTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Model\Config\Source\Group\Multiselect @@ -32,8 +32,8 @@ class MultiselectTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->groupServiceMock = $this->getMock(\Magento\Customer\Api\GroupManagementInterface::class); - $this->converterMock = $this->getMock(\Magento\Framework\Convert\DataObject::class, [], [], '', false); + $this->groupServiceMock = $this->createMock(\Magento\Customer\Api\GroupManagementInterface::class); + $this->converterMock = $this->createMock(\Magento\Framework\Convert\DataObject::class); $this->groupSourceLoggedInOnly = $this->getMockBuilder(GroupSourceLoggedInOnlyInterface::class)->getMock(); $this->model = new \Magento\Customer\Model\Config\Source\Group\Multiselect( $this->groupServiceMock, diff --git a/app/code/Magento/Customer/Test/Unit/Model/Config/Source/GroupTest.php b/app/code/Magento/Customer/Test/Unit/Model/Config/Source/GroupTest.php index 40d0d4a6ef8da..0176fa8595054 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Config/Source/GroupTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Config/Source/GroupTest.php @@ -12,7 +12,7 @@ use Magento\Framework\Convert\DataObject; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class GroupTest extends \PHPUnit_Framework_TestCase +class GroupTest extends \PHPUnit\Framework\TestCase { /** * @var GroupSourceLoggedInOnlyInterface|\PHPUnit_Framework_MockObject_MockObject @@ -36,8 +36,8 @@ class GroupTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->groupServiceMock = $this->getMock(GroupManagementInterface::class); - $this->converterMock = $this->getMock(DataObject::class, [], [], '', false); + $this->groupServiceMock = $this->createMock(GroupManagementInterface::class); + $this->converterMock = $this->createMock(DataObject::class); $this->groupSource = $this->getMockBuilder(GroupSourceLoggedInOnlyInterface::class) ->getMockForAbstractClass(); $this->model = (new ObjectManager($this))->getObject( diff --git a/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/BillingTest.php b/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/BillingTest.php index da23a44ed715e..1dbc5c9eb8fc8 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/BillingTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/BillingTest.php @@ -7,7 +7,7 @@ use Magento\Customer\Model\Customer\Attribute\Backend\Billing; -class BillingTest extends \PHPUnit_Framework_TestCase +class BillingTest extends \PHPUnit\Framework\TestCase { /** * @var Billing diff --git a/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/PasswordTest.php b/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/PasswordTest.php index 06d12afae9095..9a9449a64ecbd 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/PasswordTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/PasswordTest.php @@ -10,7 +10,7 @@ use Magento\Framework\Stdlib\StringUtils; use Magento\Customer\Model\Customer\Attribute\Backend\Password; -class PasswordTest extends \PHPUnit_Framework_TestCase +class PasswordTest extends \PHPUnit\Framework\TestCase { /** * @var Password diff --git a/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/ShippingTest.php b/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/ShippingTest.php index c551fafd8a1fa..81e62b472004c 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/ShippingTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/ShippingTest.php @@ -8,7 +8,7 @@ use Magento\Customer\Model\Customer\Attribute\Backend\Shipping; -class ShippingTest extends \PHPUnit_Framework_TestCase +class ShippingTest extends \PHPUnit\Framework\TestCase { /** * @var Shipping diff --git a/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/StoreTest.php b/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/StoreTest.php index e4ce39f633823..ac723fae72c10 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/StoreTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/StoreTest.php @@ -8,7 +8,7 @@ use Magento\Customer\Model\Customer\Attribute\Backend\Store; -class StoreTest extends \PHPUnit_Framework_TestCase +class StoreTest extends \PHPUnit\Framework\TestCase { /** * @var Store diff --git a/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/WebsiteTest.php b/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/WebsiteTest.php index 16d290b2e4a57..0b427756fe7c6 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/WebsiteTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Backend/WebsiteTest.php @@ -8,7 +8,7 @@ use Magento\Customer\Model\Customer\Attribute\Backend\Website; -class WebsiteTest extends \PHPUnit_Framework_TestCase +class WebsiteTest extends \PHPUnit\Framework\TestCase { /** * @var Website diff --git a/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Source/WebsiteTest.php b/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Source/WebsiteTest.php index bc7356061afef..11e3d602ddf90 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Source/WebsiteTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Customer/Attribute/Source/WebsiteTest.php @@ -8,7 +8,7 @@ use Magento\Customer\Model\Customer\Attribute\Source\Website; use Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\CollectionFactory; -class WebsiteTest extends \PHPUnit_Framework_TestCase +class WebsiteTest extends \PHPUnit\Framework\TestCase { /** @var Website */ protected $model; diff --git a/app/code/Magento/Customer/Test/Unit/Model/Customer/CredentialsValidatorTest.php b/app/code/Magento/Customer/Test/Unit/Model/Customer/CredentialsValidatorTest.php index 8775787f9ddad..07aef85e92d08 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Customer/CredentialsValidatorTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Customer/CredentialsValidatorTest.php @@ -7,7 +7,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -class CredentialsValidatorTest extends \PHPUnit_Framework_TestCase +class CredentialsValidatorTest extends \PHPUnit\Framework\TestCase { /** * @var ObjectManagerHelper diff --git a/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php b/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php index 91ebe546e08a8..029949c5f35b0 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php @@ -23,7 +23,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class DataProviderTest extends \PHPUnit_Framework_TestCase +class DataProviderTest extends \PHPUnit\Framework\TestCase { const ATTRIBUTE_CODE = 'test-code'; const OPTIONS_RESULT = 'test-options'; @@ -68,12 +68,9 @@ protected function setUp() $this->eavConfigMock = $this->getMockBuilder(\Magento\Eav\Model\Config::class) ->disableOriginalConstructor() ->getMock(); - $this->customerCollectionFactoryMock = $this->getMock( + $this->customerCollectionFactoryMock = $this->createPartialMock( \Magento\Customer\Model\ResourceModel\Customer\CollectionFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->eavValidationRulesMock = $this ->getMockBuilder(\Magento\Ui\DataProvider\EavValidationRules::class) @@ -507,7 +504,7 @@ private function getCountryAttrMock() $shareMock = $this->getMockBuilder(Share::class) ->disableOriginalConstructor() ->getMock(); - $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); $objectManagerMock->expects($this->any()) ->method('get') ->willReturnMap([ @@ -516,7 +513,7 @@ private function getCountryAttrMock() ]); \Magento\Framework\App\ObjectManager::setInstance($objectManagerMock); $countryAttrMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class) - ->setMethods(['getAttributeCode', 'getDataUsingMethod', 'usesSource', 'getSource']) + ->setMethods(['getAttributeCode', 'getDataUsingMethod', 'usesSource', 'getSource', 'getLabel']) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -550,6 +547,20 @@ function ($origName) { */ public function testGetData() { + $customerData = [ + 'email' => 'test@test.ua', + 'default_billing' => 2, + 'default_shipping' => 2, + 'password_hash' => 'password_hash', + 'rp_token' => 'rp_token', + 'confirmation' => 'confirmation', + ]; + $addressData = [ + 'firstname' => 'firstname', + 'lastname' => 'lastname', + 'street' => "street\nstreet", + ]; + $customer = $this->getMockBuilder(\Magento\Customer\Model\Customer::class) ->disableOriginalConstructor() ->getMock(); @@ -573,11 +584,7 @@ public function testGetData() ->willReturn([$customer]); $customer->expects($this->once()) ->method('getData') - ->willReturn([ - 'email' => 'test@test.ua', - 'default_billing' => 2, - 'default_shipping' => 2, - ]); + ->willReturn($customerData); $customer->expects($this->once()) ->method('getAddresses') ->willReturn([$address]); @@ -594,11 +601,7 @@ public function testGetData() ->willReturnSelf(); $address->expects($this->once()) ->method('getData') - ->willReturn([ - 'firstname' => 'firstname', - 'lastname' => 'lastname', - 'street' => "street\nstreet", - ]); + ->willReturn($addressData); $address->expects($this->once()) ->method('getAttributes') ->willReturn([]); @@ -1261,7 +1264,9 @@ public function testGetDataWithVisibleAttributesWithAccountEdit() ); $helper = new ObjectManager($this); - $context = $this->getMock(\Magento\Framework\View\Element\UiComponent\ContextInterface::class); + $context = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\ContextInterface::class) + ->setMethods(['getRequestParam']) + ->getMockforAbstractClass(); $context->expects($this->any()) ->method('getRequestParam') ->with('request-field-name') diff --git a/app/code/Magento/Customer/Test/Unit/Model/Customer/NotificationStorageTest.php b/app/code/Magento/Customer/Test/Unit/Model/Customer/NotificationStorageTest.php index c1c353e919514..7397e8ba8a9a8 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Customer/NotificationStorageTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Customer/NotificationStorageTest.php @@ -7,7 +7,7 @@ use Magento\Customer\Model\Customer\NotificationStorage; -class NotificationStorageTest extends \PHPUnit_Framework_TestCase +class NotificationStorageTest extends \PHPUnit\Framework\TestCase { /** @@ -28,12 +28,12 @@ class NotificationStorageTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->cacheMock = $this->getMock(\Magento\Framework\Cache\FrontendInterface::class); + $this->cacheMock = $this->createMock(\Magento\Framework\Cache\FrontendInterface::class); $this->notificationStorage = $objectManager->getObject( NotificationStorage::class, ['cache' => $this->cacheMock] ); - $this->serializerMock = $this->getMock(\Magento\Framework\Serialize\SerializerInterface::class); + $this->serializerMock = $this->createMock(\Magento\Framework\Serialize\SerializerInterface::class); $objectManager->setBackwardCompatibleProperty($this->notificationStorage, 'serializer', $this->serializerMock); } diff --git a/app/code/Magento/Customer/Test/Unit/Model/Customer/Source/GroupTest.php b/app/code/Magento/Customer/Test/Unit/Model/Customer/Source/GroupTest.php index e93d81c45fda4..e2d7d844e8cb9 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Customer/Source/GroupTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Customer/Source/GroupTest.php @@ -12,7 +12,7 @@ use Magento\Framework\Api\SearchCriteria; use Magento\Customer\Api\Data\GroupSearchResultsInterface; -class GroupTest extends \PHPUnit_Framework_TestCase +class GroupTest extends \PHPUnit\Framework\TestCase { /** * @var Group diff --git a/app/code/Magento/Customer/Test/Unit/Model/CustomerAuthUpdateTest.php b/app/code/Magento/Customer/Test/Unit/Model/CustomerAuthUpdateTest.php index 2b74bc9d9e83f..a1a243066bb7d 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/CustomerAuthUpdateTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/CustomerAuthUpdateTest.php @@ -10,7 +10,7 @@ /** * Class CustomerAuthUpdateTest */ -class CustomerAuthUpdateTest extends \PHPUnit_Framework_TestCase +class CustomerAuthUpdateTest extends \PHPUnit\Framework\TestCase { /** * @var CustomerAuthUpdate @@ -40,9 +40,9 @@ protected function setUp() $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->customerRegistry = - $this->getMock(\Magento\Customer\Model\CustomerRegistry::class, [], [], '', false); + $this->createMock(\Magento\Customer\Model\CustomerRegistry::class); $this->customerResourceModel = - $this->getMock(\Magento\Customer\Model\ResourceModel\Customer::class, [], [], '', false); + $this->createMock(\Magento\Customer\Model\ResourceModel\Customer::class); $this->model = $this->objectManager->getObject( \Magento\Customer\Model\CustomerAuthUpdate::class, @@ -60,21 +60,9 @@ public function testSaveAuth() { $customerId = 1; - $customerSecureMock = $this->getMock( - \Magento\Customer\Model\Data\CustomerSecure::class, - [], - [], - '', - false - ); + $customerSecureMock = $this->createMock(\Magento\Customer\Model\Data\CustomerSecure::class); - $dbAdapter = $this->getMock( - \Magento\Framework\DB\Adapter\AdapterInterface::class, - [], - [], - '', - false - ); + $dbAdapter = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class); $this->customerRegistry->expects($this->once()) ->method('retrieveSecureData') diff --git a/app/code/Magento/Customer/Test/Unit/Model/CustomerExtractorTest.php b/app/code/Magento/Customer/Test/Unit/Model/CustomerExtractorTest.php index f041465807246..351c3435c73fc 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/CustomerExtractorTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/CustomerExtractorTest.php @@ -7,7 +7,7 @@ use Magento\Customer\Model\CustomerExtractor; -class CustomerExtractorTest extends \PHPUnit_Framework_TestCase +class CustomerExtractorTest extends \PHPUnit\Framework\TestCase { /** @var CustomerExtractor */ protected $customerExtractor; @@ -74,9 +74,9 @@ protected function setUp() '', false ); - $this->dataObjectHelper = $this->getMock(\Magento\Framework\Api\DataObjectHelper::class, [], [], '', false); + $this->dataObjectHelper = $this->createMock(\Magento\Framework\Api\DataObjectHelper::class); $this->request = $this->getMockForAbstractClass(\Magento\Framework\App\RequestInterface::class, [], '', false); - $this->customerForm = $this->getMock(\Magento\Customer\Model\Metadata\Form::class, [], [], '', false); + $this->customerForm = $this->createMock(\Magento\Customer\Model\Metadata\Form::class); $this->customerData = $this->getMockForAbstractClass( \Magento\Customer\Api\Data\CustomerInterface::class, [], diff --git a/app/code/Magento/Customer/Test/Unit/Model/CustomerGroupConfigTest.php b/app/code/Magento/Customer/Test/Unit/Model/CustomerGroupConfigTest.php index 8a9c57116d3df..394187d20fd5d 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/CustomerGroupConfigTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/CustomerGroupConfigTest.php @@ -8,7 +8,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -class CustomerGroupConfigTest extends \PHPUnit_Framework_TestCase +class CustomerGroupConfigTest extends \PHPUnit\Framework\TestCase { /** * @var ObjectManagerHelper diff --git a/app/code/Magento/Customer/Test/Unit/Model/CustomerManagementTest.php b/app/code/Magento/Customer/Test/Unit/Model/CustomerManagementTest.php index 8ce2152153494..4ec3c0e0e2811 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/CustomerManagementTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/CustomerManagementTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Customer\Test\Unit\Model; -class CustomerManagementTest extends \PHPUnit_Framework_TestCase +class CustomerManagementTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Model\CustomerManagement @@ -19,12 +19,9 @@ class CustomerManagementTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->customersFactoryMock = $this->getMock( + $this->customersFactoryMock = $this->createPartialMock( \Magento\Customer\Model\ResourceModel\Customer\CollectionFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->model = new \Magento\Customer\Model\CustomerManagement( $this->customersFactoryMock @@ -33,13 +30,7 @@ protected function setUp() public function testGetCount() { - $customersMock = $this->getMock( - \Magento\Customer\Model\ResourceModel\Customer\Collection::class, - [], - [], - '', - false - ); + $customersMock = $this->createMock(\Magento\Customer\Model\ResourceModel\Customer\Collection::class); $this->customersFactoryMock ->expects($this->once()) diff --git a/app/code/Magento/Customer/Test/Unit/Model/CustomerRegistryTest.php b/app/code/Magento/Customer/Test/Unit/Model/CustomerRegistryTest.php index a132fb8b062f6..1403f13ae7209 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/CustomerRegistryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/CustomerRegistryTest.php @@ -12,7 +12,7 @@ * Test for CustomerRegistry * */ -class CustomerRegistryTest extends \PHPUnit_Framework_TestCase +class CustomerRegistryTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Model\CustomerRegistry diff --git a/app/code/Magento/Customer/Test/Unit/Model/CustomerTest.php b/app/code/Magento/Customer/Test/Unit/Model/CustomerTest.php index 5e80f48ea8328..8b3f7875e3c97 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/CustomerTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/CustomerTest.php @@ -17,7 +17,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class CustomerTest extends \PHPUnit_Framework_TestCase +class CustomerTest extends \PHPUnit\Framework\TestCase { /** @var Customer */ protected $_model; @@ -65,62 +65,34 @@ class CustomerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_website = $this->getMock(\Magento\Store\Model\Website::class, [], [], '', false); - $this->_config = $this->getMock(\Magento\Eav\Model\Config::class, [], [], '', false); - $this->_attribute = $this->getMock(\Magento\Eav\Model\Attribute::class, [], [], '', false); - $this->_storeManager = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); - $this->_storetMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); - $this->_scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $this->_transportBuilderMock = $this->getMock( - \Magento\Framework\Mail\Template\TransportBuilder::class, - [], - [], - '', - false - ); - $this->_transportMock = $this->getMock( - \Magento\Framework\Mail\TransportInterface::class, - [], - [], - '', - false - ); - $this->attributeFactoryMock = $this->getMock( + $this->_website = $this->createMock(\Magento\Store\Model\Website::class); + $this->_config = $this->createMock(\Magento\Eav\Model\Config::class); + $this->_attribute = $this->createMock(\Magento\Eav\Model\Attribute::class); + $this->_storeManager = $this->createMock(\Magento\Store\Model\StoreManager::class); + $this->_storetMock = $this->createMock(\Magento\Store\Model\Store::class); + $this->_scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->_transportBuilderMock = $this->createMock(\Magento\Framework\Mail\Template\TransportBuilder::class); + $this->_transportMock = $this->createMock(\Magento\Framework\Mail\TransportInterface::class); + $this->attributeFactoryMock = $this->createPartialMock( \Magento\Customer\Model\AttributeFactory::class, - ['create'], - [], - '', - false - ); - $this->attributeCustomerMock = $this->getMock( - \Magento\Customer\Model\Attribute::class, - [], - [], - '', - false + ['create'] ); - $this->resourceMock = $this->getMock( + $this->attributeCustomerMock = $this->createMock(\Magento\Customer\Model\Attribute::class); + $this->resourceMock = $this->createPartialMock( \Magento\Customer\Model\ResourceModel\Customer::class, // \Magento\Framework\DataObject::class, - ['getIdFieldName'], - [], - '', - false, - false + ['getIdFieldName'] ); - $this->dataObjectProcessor = $this->getMock( + $this->dataObjectProcessor = $this->createPartialMock( \Magento\Framework\Reflection\DataObjectProcessor::class, - ['buildOutputDataArray'], - [], - '', - false + ['buildOutputDataArray'] ); $this->resourceMock->expects($this->any()) ->method('getIdFieldName') ->will($this->returnValue('id')); - $this->registryMock = $this->getMock(\Magento\Framework\Registry::class, ['registry'], [], '', false); - $this->_encryptor = $this->getMock(\Magento\Framework\Encryption\EncryptorInterface::class); + $this->registryMock = $this->createPartialMock(\Magento\Framework\Registry::class, ['registry']); + $this->_encryptor = $this->createMock(\Magento\Framework\Encryption\EncryptorInterface::class); $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_model = $helper->getObject( \Magento\Customer\Model\Customer::class, @@ -164,8 +136,8 @@ public function testSendNewAccountEmailException() public function testSendNewAccountEmailWithoutStoreId() { - $store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); - $website = $this->getMock(\Magento\Store\Model\Website::class, [], [], '', false); + $store = $this->createMock(\Magento\Store\Model\Store::class); + $website = $this->createMock(\Magento\Store\Model\Website::class); $website->expects($this->once()) ->method('getStoreIds') ->will($this->returnValue([1, 2, 3, 4])); @@ -198,7 +170,7 @@ public function testSendNewAccountEmailWithoutStoreId() ->method($method) ->will($this->returnSelf()); } - $transportMock = $this->getMock(\Magento\Framework\Mail\TransportInterface::class, [], [], '', false); + $transportMock = $this->createMock(\Magento\Framework\Mail\TransportInterface::class); $transportMock->expects($this->once()) ->method('sendMessage') ->will($this->returnSelf()); @@ -295,26 +267,20 @@ public function testUpdateData() 'test33' => 'test33', ]; - $customer = $this->getMock( + $customer = $this->createPartialMock( \Magento\Customer\Model\Data\Customer::class, [ 'getCustomAttributes', 'getId', - ], - [], - '', - false + ] ); - $attribute = $this->getMock( + $attribute = $this->createPartialMock( \Magento\Framework\Api\AttributeValue::class, [ 'getAttributeCode', 'getValue', - ], - [], - '', - false + ] ); $this->dataObjectProcessor->expects($this->once()) diff --git a/app/code/Magento/Customer/Test/Unit/Model/EmailNotificationTest.php b/app/code/Magento/Customer/Test/Unit/Model/EmailNotificationTest.php index ac48e3a2dcf8f..0240b7ab29ab7 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/EmailNotificationTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/EmailNotificationTest.php @@ -5,16 +5,16 @@ */ namespace Magento\Customer\Test\Unit\Model; -use Magento\Store\Model\ScopeInterface; use Magento\Customer\Model\EmailNotification; use Magento\Framework\App\Area; +use Magento\Store\Model\ScopeInterface; /** * Class EmailNotificationTest * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class EmailNotificationTest extends \PHPUnit_Framework_TestCase +class EmailNotificationTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Model\CustomerRegistry|\PHPUnit_Framework_MockObject_MockObject @@ -63,81 +63,30 @@ class EmailNotificationTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->customerRegistryMock = $this->getMock( - \Magento\Customer\Model\CustomerRegistry::class, - [], - [], - '', - false - ); + $this->customerRegistryMock = $this->createMock(\Magento\Customer\Model\CustomerRegistry::class); - $this->storeManagerMock = $this->getMock( - \Magento\Store\Model\StoreManagerInterface::class, - [], - [], - '', - false - ); + $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); - $this->transportBuilderMock = $this->getMock( - \Magento\Framework\Mail\Template\TransportBuilder::class, - [], - [], - '', - false - ); + $this->transportBuilderMock = $this->createMock(\Magento\Framework\Mail\Template\TransportBuilder::class); - $this->customerViewHelperMock = $this->getMock( - \Magento\Customer\Helper\View::class, - [], - [], - '', - false - ); + $this->customerViewHelperMock = $this->createMock(\Magento\Customer\Helper\View::class); - $this->dataProcessorMock = $this->getMock( - \Magento\Framework\Reflection\DataObjectProcessor::class, - [], - [], - '', - false - ); + $this->dataProcessorMock = $this->createMock(\Magento\Framework\Reflection\DataObjectProcessor::class); - $contextMock = $this->getMock( - \Magento\Framework\App\Helper\Context::class, - ['getScopeConfig'], - [], - '', - false - ); + $contextMock = $this->createPartialMock(\Magento\Framework\App\Helper\Context::class, ['getScopeConfig']); - $this->scopeConfigMock = $this->getMock( + $this->scopeConfigMock = $this->createPartialMock( \Magento\Framework\App\Config\ScopeConfigInterface::class, - ['getValue', 'isSetFlag'], - [], - '', - false + ['getValue', 'isSetFlag'] ); $contextMock->expects($this->any()) ->method('getScopeConfig') ->willReturn($this->scopeConfigMock); - $this->customerSecureMock = $this->getMock( - \Magento\Customer\Model\Data\CustomerSecure::class, - [], - [], - '', - false - ); + $this->customerSecureMock = $this->createMock(\Magento\Customer\Model\Data\CustomerSecure::class); - $this->storeMock = $this->getMock( - \Magento\Store\Model\Store::class, - [], - [], - '', - false - ); + $this->storeMock = $this->createMock(\Magento\Store\Model\Store::class); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); @@ -188,13 +137,7 @@ public function testCredentialsChanged($testNumber, $oldEmail, $newEmail, $isPas break; } - $origCustomer = $this->getMock( - \Magento\Customer\Api\Data\CustomerInterface::class, - [], - [], - '', - false - ); + $origCustomer = $this->createMock(\Magento\Customer\Api\Data\CustomerInterface::class); $origCustomer->expects($this->any()) ->method('getStoreId') ->willReturn(0); @@ -205,13 +148,7 @@ public function testCredentialsChanged($testNumber, $oldEmail, $newEmail, $isPas ->method('getWebsiteId') ->willReturn($customerWebsiteId); - $storeMock = $this->getMock( - \Magento\Store\Model\Store::class, - [], - [], - '', - false - ); + $storeMock = $this->createMock(\Magento\Store\Model\Store::class); $storeMock->expects($this->any()) ->method('getId') ->willReturn($customerStoreId); @@ -220,13 +157,7 @@ public function testCredentialsChanged($testNumber, $oldEmail, $newEmail, $isPas ->method('getStore') ->willReturn($storeMock); - $websiteMock = $this->getMock( - \Magento\Store\Model\Website::class, - ['getStoreIds'], - [], - '', - false - ); + $websiteMock = $this->createPartialMock(\Magento\Store\Model\Website::class, ['getStoreIds']); $websiteMock->expects($this->any()) ->method('getStoreIds') ->willReturn([$customerStoreId]); @@ -236,13 +167,7 @@ public function testCredentialsChanged($testNumber, $oldEmail, $newEmail, $isPas ->with($customerWebsiteId) ->willReturn($websiteMock); - $customerSecureMock = $this->getMock( - \Magento\Customer\Model\Data\CustomerSecure::class, - [], - [], - '', - false - ); + $customerSecureMock = $this->createMock(\Magento\Customer\Model\Data\CustomerSecure::class); $this->customerRegistryMock->expects(clone $expects) ->method('retrieveSecureData') ->with($customerId) @@ -317,13 +242,7 @@ public function testCredentialsChanged($testNumber, $oldEmail, $newEmail, $isPas ->withConsecutive([$oldEmail, $customerName], [$newEmail, $customerName]) ->willReturnSelf(); - $transport = $this->getMock( - \Magento\Framework\Mail\TransportInterface::class, - [], - [], - '', - false - ); + $transport = $this->createMock(\Magento\Framework\Mail\TransportInterface::class); $this->transportBuilderMock->expects(clone $expects) ->method('getTransport') @@ -375,13 +294,7 @@ public function testPasswordReminder() $templateIdentifier = 'Template Identifier'; $sender = 'Sender'; - $customer = $this->getMock( - \Magento\Customer\Api\Data\CustomerInterface::class, - [], - [], - '', - false - ); + $customer = $this->createMock(\Magento\Customer\Api\Data\CustomerInterface::class); $customer->expects($this->any()) ->method('getStoreId') ->willReturn($customerStoreId); @@ -438,13 +351,7 @@ public function testPasswordReminder() ->with(EmailNotification::XML_PATH_FORGOT_EMAIL_IDENTITY, ScopeInterface::SCOPE_STORE, $customerStoreId) ->willReturn($sender); - $transport = $this->getMock( - \Magento\Framework\Mail\TransportInterface::class, - [], - [], - '', - false - ); + $transport = $this->createMock(\Magento\Framework\Mail\TransportInterface::class); $this->transportBuilderMock->expects($this->once()) ->method('setTemplateIdentifier') @@ -489,13 +396,7 @@ public function testPasswordResetConfirmation() $templateIdentifier = 'Template Identifier'; $sender = 'Sender'; - $customer = $this->getMock( - \Magento\Customer\Api\Data\CustomerInterface::class, - [], - [], - '', - false - ); + $customer = $this->createMock(\Magento\Customer\Api\Data\CustomerInterface::class); $customer->expects($this->any()) ->method('getStoreId') ->willReturn($customerStoreId); @@ -552,13 +453,7 @@ public function testPasswordResetConfirmation() ->with(EmailNotification::XML_PATH_FORGOT_EMAIL_IDENTITY, ScopeInterface::SCOPE_STORE, $customerStoreId) ->willReturn($sender); - $transport = $this->getMock( - \Magento\Framework\Mail\TransportInterface::class, - [], - [], - '', - false - ); + $transport = $this->createMock(\Magento\Framework\Mail\TransportInterface::class); $this->transportBuilderMock->expects($this->once()) ->method('setTemplateIdentifier') @@ -603,13 +498,7 @@ public function testNewAccount() $templateIdentifier = 'Template Identifier'; $sender = 'Sender'; - $customer = $this->getMock( - \Magento\Customer\Api\Data\CustomerInterface::class, - [], - [], - '', - false - ); + $customer = $this->createMock(\Magento\Customer\Api\Data\CustomerInterface::class); $customer->expects($this->any()) ->method('getStoreId') ->willReturn($customerStoreId); @@ -662,13 +551,7 @@ public function testNewAccount() ->with(EmailNotification::XML_PATH_REGISTER_EMAIL_IDENTITY, ScopeInterface::SCOPE_STORE, $customerStoreId) ->willReturn($sender); - $transport = $this->getMock( - \Magento\Framework\Mail\TransportInterface::class, - [], - [], - '', - false - ); + $transport = $this->createMock(\Magento\Framework\Mail\TransportInterface::class); $this->transportBuilderMock->expects($this->once()) ->method('setTemplateIdentifier') diff --git a/app/code/Magento/Customer/Test/Unit/Model/FileProcessorTest.php b/app/code/Magento/Customer/Test/Unit/Model/FileProcessorTest.php index 9d51e4bf31913..f2db8c6cab6be 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/FileProcessorTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/FileProcessorTest.php @@ -10,7 +10,7 @@ use Magento\Customer\Model\FileProcessor; use Magento\Framework\App\Filesystem\DirectoryList; -class FileProcessorTest extends \PHPUnit_Framework_TestCase +class FileProcessorTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\Filesystem|\PHPUnit_Framework_MockObject_MockObject @@ -183,7 +183,10 @@ public function testSaveTemporaryFile() $expectedResult = [ 'file' => 'filename.ext1', - 'path' => 'filepath', + ]; + $resultWithPath = [ + 'file' => 'filename.ext1', + 'path' => 'filepath' ]; $uploaderMock = $this->getMockBuilder(\Magento\MediaStorage\Model\File\Uploader::class) @@ -208,7 +211,7 @@ public function testSaveTemporaryFile() $uploaderMock->expects($this->once()) ->method('save') ->with($absolutePath) - ->willReturn($expectedResult); + ->willReturn($resultWithPath); $this->uploaderFactory->expects($this->once()) ->method('create') diff --git a/app/code/Magento/Customer/Test/Unit/Model/FileUploaderTest.php b/app/code/Magento/Customer/Test/Unit/Model/FileUploaderTest.php index 5d77b6e7937dd..f2489c8626a4f 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/FileUploaderTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/FileUploaderTest.php @@ -9,7 +9,7 @@ use Magento\Customer\Model\FileProcessor; use Magento\Customer\Model\FileUploader; -class FileUploaderTest extends \PHPUnit_Framework_TestCase +class FileUploaderTest extends \PHPUnit\Framework\TestCase { /** * @var CustomerMetadataInterface|\PHPUnit_Framework_MockObject_MockObject @@ -57,6 +57,11 @@ protected function setUp() ->getMockForAbstractClass(); } + protected function tearDown() + { + $_FILES = []; + } + /** * @param string $entityTypeCode * @param string $scope diff --git a/app/code/Magento/Customer/Test/Unit/Model/GroupRegistryTest.php b/app/code/Magento/Customer/Test/Unit/Model/GroupRegistryTest.php index fbce5a1b19603..ba90bcb20b250 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/GroupRegistryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/GroupRegistryTest.php @@ -8,7 +8,7 @@ /** * Unit test for registry \Magento\Customer\Model\GroupRegistry */ -class GroupRegistryTest extends \PHPUnit_Framework_TestCase +class GroupRegistryTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Model\GroupRegistry diff --git a/app/code/Magento/Customer/Test/Unit/Model/Indexer/Attribute/FilterTest.php b/app/code/Magento/Customer/Test/Unit/Model/Indexer/Attribute/FilterTest.php index b6d31a0179a3c..bc886af3a391d 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Indexer/Attribute/FilterTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Indexer/Attribute/FilterTest.php @@ -8,7 +8,7 @@ use Magento\Customer\Model\Indexer\Attribute\Filter; use Magento\Customer\Api\Data\AttributeMetadataInterface; -class FilterTest extends \PHPUnit_Framework_TestCase +class FilterTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Framework\App\ResourceConnection|\PHPUnit_Framework_MockObject_MockObject */ protected $resource; @@ -33,21 +33,15 @@ class FilterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->resource = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); + $this->resource = $this->createMock(\Magento\Framework\App\ResourceConnection::class); $this->connection = $this->getMockForAbstractClass( \Magento\Framework\DB\Adapter\AdapterInterface::class, [], '', false ); - $this->flatScopeResolver = $this->getMock( - \Magento\Framework\Indexer\ScopeResolver\FlatScopeResolver::class, - [], - [], - '', - false - ); - $this->indexerRegistry = $this->getMock(\Magento\Framework\Indexer\IndexerRegistry::class, [], [], '', false); + $this->flatScopeResolver = $this->createMock(\Magento\Framework\Indexer\ScopeResolver\FlatScopeResolver::class); + $this->indexerRegistry = $this->createMock(\Magento\Framework\Indexer\IndexerRegistry::class); $this->indexer = $this->getMockForAbstractClass( \Magento\Framework\Indexer\IndexerInterface::class, [], diff --git a/app/code/Magento/Customer/Test/Unit/Model/Indexer/AttributeProviderTest.php b/app/code/Magento/Customer/Test/Unit/Model/Indexer/AttributeProviderTest.php index 450fe57e1b7a6..bb67eebcb6e54 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Indexer/AttributeProviderTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Indexer/AttributeProviderTest.php @@ -9,7 +9,7 @@ use Magento\Customer\Model\Indexer\AttributeProvider; use Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection; -class AttributeProviderTest extends \PHPUnit_Framework_TestCase +class AttributeProviderTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Model\Config|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Customer/Test/Unit/Model/Layout/DepersonalizePluginTest.php b/app/code/Magento/Customer/Test/Unit/Model/Layout/DepersonalizePluginTest.php index 10b56e4e5cd9b..15337d8968305 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Layout/DepersonalizePluginTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Layout/DepersonalizePluginTest.php @@ -10,7 +10,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class DepersonalizePluginTest extends \PHPUnit_Framework_TestCase +class DepersonalizePluginTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Model\Layout\DepersonalizePlugin @@ -57,46 +57,28 @@ class DepersonalizePluginTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->layoutMock = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); - $this->sessionMock = $this->getMock( + $this->layoutMock = $this->createMock(\Magento\Framework\View\Layout::class); + $this->sessionMock = $this->createPartialMock( \Magento\Framework\Session\Generic::class, - ['clearStorage', 'setData', 'getData'], - [], - '', - false + ['clearStorage', 'setData', 'getData'] ); - $this->customerSessionMock = $this->getMock( + $this->customerSessionMock = $this->createPartialMock( \Magento\Customer\Model\Session::class, - ['getCustomerGroupId', 'setCustomerGroupId', 'clearStorage', 'setCustomer'], - [], - '', - false + ['getCustomerGroupId', 'setCustomerGroupId', 'clearStorage', 'setCustomer'] ); - $this->customerFactoryMock = $this->getMock( + $this->customerFactoryMock = $this->createPartialMock( \Magento\Customer\Model\CustomerFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->customerMock = $this->getMock( + $this->customerMock = $this->createPartialMock( \Magento\Customer\Model\Customer::class, - ['setGroupId', '__wakeup'], - [], - '', - false + ['setGroupId', '__wakeup'] ); - $this->visitorMock = $this->getMock(\Magento\Customer\Model\Visitor::class, [], [], '', false); + $this->visitorMock = $this->createMock(\Magento\Customer\Model\Visitor::class); $this->customerFactoryMock->expects($this->any()) ->method('create') ->will($this->returnValue($this->customerMock)); - $this->depersonalizeCheckerMock = $this->getMock( - \Magento\PageCache\Model\DepersonalizeChecker::class, - [], - [], - '', - false - ); + $this->depersonalizeCheckerMock = $this->createMock(\Magento\PageCache\Model\DepersonalizeChecker::class); $this->plugin = new \Magento\Customer\Model\Layout\DepersonalizePlugin( $this->depersonalizeCheckerMock, @@ -132,7 +114,7 @@ public function testBeforeGenerateXmlNoDepersonalize() public function testAfterGenerateXml() { - $expectedResult = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); + $expectedResult = $this->createMock(\Magento\Framework\View\Layout::class); $this->depersonalizeCheckerMock->expects($this->once())->method('checkIfDepersonalize')->willReturn(true); $this->visitorMock->expects($this->once())->method('setSkipRequestLogging')->with($this->equalTo(true)); $this->visitorMock->expects($this->once())->method('unsetData'); @@ -157,7 +139,7 @@ public function testAfterGenerateXml() public function testAfterGenerateXmlNoDepersonalize() { - $expectedResult = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); + $expectedResult = $this->createMock(\Magento\Framework\View\Layout::class); $this->depersonalizeCheckerMock->expects($this->once())->method('checkIfDepersonalize')->willReturn(false); $this->visitorMock->expects($this->never())->method('setSkipRequestLogging'); $this->visitorMock->expects($this->never())->method('unsetData'); diff --git a/app/code/Magento/Customer/Test/Unit/Model/LogTest.php b/app/code/Magento/Customer/Test/Unit/Model/LogTest.php index a9acf14279f86..0b7ed99d18967 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/LogTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/LogTest.php @@ -8,7 +8,7 @@ /** * Customer log model test. */ -class LogTest extends \PHPUnit_Framework_TestCase +class LogTest extends \PHPUnit\Framework\TestCase { /** * Customer log model. diff --git a/app/code/Magento/Customer/Test/Unit/Model/LoggerTest.php b/app/code/Magento/Customer/Test/Unit/Model/LoggerTest.php index 49a6e7322e616..4cea7ee22837d 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/LoggerTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/LoggerTest.php @@ -5,12 +5,10 @@ */ namespace Magento\Customer\Test\Unit\Model; -use Magento\Framework\App\ResourceConnection; - /** * Customer log data logger test. */ -class LoggerTest extends \PHPUnit_Framework_TestCase +class LoggerTest extends \PHPUnit\Framework\TestCase { /** * Customer log data logger. @@ -43,15 +41,12 @@ class LoggerTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->connection = $this->getMock( + $this->connection = $this->createPartialMock( \Magento\Framework\DB\Adapter\Pdo\Mysql::class, - ['select', 'insertOnDuplicate', 'fetchRow'], - [], - '', - false + ['select', 'insertOnDuplicate', 'fetchRow'] ); - $this->resource = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); - $this->logFactory = $this->getMock(\Magento\Customer\Model\LogFactory::class, ['create'], [], '', false); + $this->resource = $this->createMock(\Magento\Framework\App\ResourceConnection::class); + $this->logFactory = $this->createPartialMock(\Magento\Customer\Model\LogFactory::class, ['create']); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); @@ -67,7 +62,7 @@ protected function setUp() /** * @param int $customerId * @param array $data - * @dataProvider testLogDataProvider + * @dataProvider logDataProvider * @return void */ public function testLog($customerId, $data) @@ -76,7 +71,7 @@ public function testLog($customerId, $data) $data = array_filter($data); if (!$data) { - $this->setExpectedException('\InvalidArgumentException', 'Log data is empty'); + $this->expectException('\InvalidArgumentException', 'Log data is empty'); $this->logger->log($customerId, $data); return; } @@ -98,7 +93,7 @@ public function testLog($customerId, $data) /** * @return array */ - public function testLogDataProvider() + public function logDataProvider() { return [ [235, ['last_login_at' => '2015-03-04 12:00:00']], @@ -109,7 +104,7 @@ public function testLogDataProvider() /** * @param int $customerId * @param array $data - * @dataProvider testGetDataProvider + * @dataProvider getDataProvider * @return void */ public function testGet($customerId, $data) @@ -121,7 +116,7 @@ public function testGet($customerId, $data) 'lastVisitAt' => $data['last_visit_at'] ]; - $select = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); + $select = $this->createMock(\Magento\Framework\DB\Select::class); $select->expects($this->any())->method('from')->willReturnSelf(); $select->expects($this->any())->method('joinLeft')->willReturnSelf(); @@ -141,11 +136,9 @@ public function testGet($customerId, $data) ->with($select) ->willReturn($data); - $log = $this->getMock( - \Magento\Customer\Model\Log::class, - [], - $logArguments - ); + $log = $this->getMockBuilder(\Magento\Customer\Model\Log::class) + ->setConstructorArgs($logArguments) + ->getMock(); $this->logFactory->expects($this->any()) ->method('create') @@ -158,7 +151,7 @@ public function testGet($customerId, $data) /** * @return array */ - public function testGetDataProvider() + public function getDataProvider() { return [ [ diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/AddressMetadataManagementTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/AddressMetadataManagementTest.php index a294ecdc34932..06a30ca06f7a7 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/AddressMetadataManagementTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/AddressMetadataManagementTest.php @@ -10,7 +10,7 @@ use Magento\Customer\Api\Data\AttributeMetadataInterface; use Magento\Customer\Model\Metadata\AddressMetadataManagement; -class AddressMetadataManagementTest extends \PHPUnit_Framework_TestCase +class AddressMetadataManagementTest extends \PHPUnit\Framework\TestCase { /** @var AddressMetadataManagement */ protected $model; diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/AddressMetadataTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/AddressMetadataTest.php index 072d3d9bbbf47..c0f961e9804ca 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/AddressMetadataTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/AddressMetadataTest.php @@ -14,7 +14,7 @@ use Magento\Customer\Model\ResourceModel\Form\Attribute\Collection; use Magento\Eav\Model\Entity\Attribute\AbstractAttribute; -class AddressMetadataTest extends \PHPUnit_Framework_TestCase +class AddressMetadataTest extends \PHPUnit\Framework\TestCase { /** @var AddressMetadata */ protected $model; diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/AttributeMetadataCacheTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/AttributeMetadataCacheTest.php index 7cbda45fdd263..658472d13ab93 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/AttributeMetadataCacheTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/AttributeMetadataCacheTest.php @@ -16,7 +16,7 @@ use Magento\Framework\Serialize\SerializerInterface; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class AttributeMetadataCacheTest extends \PHPUnit_Framework_TestCase +class AttributeMetadataCacheTest extends \PHPUnit\Framework\TestCase { /** * @var CacheInterface|\PHPUnit_Framework_MockObject_MockObject @@ -46,16 +46,10 @@ class AttributeMetadataCacheTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $this->cacheMock = $this->getMock(CacheInterface::class); - $this->stateMock = $this->getMock(StateInterface::class); - $this->serializerMock = $this->getMock(SerializerInterface::class); - $this->attributeMetadataHydratorMock = $this->getMock( - AttributeMetadataHydrator::class, - [], - [], - '', - false - ); + $this->cacheMock = $this->createMock(CacheInterface::class); + $this->stateMock = $this->createMock(StateInterface::class); + $this->serializerMock = $this->createMock(SerializerInterface::class); + $this->attributeMetadataHydratorMock = $this->createMock(AttributeMetadataHydrator::class); $this->attributeMetadataCache = $objectManager->getObject( AttributeMetadataCache::class, [ @@ -122,14 +116,14 @@ public function testLoad() ->with($serializedString) ->willReturn($attributesMetadataData); /** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $attributeMetadataMock */ - $attributeMetadataMock = $this->getMock(AttributeMetadataInterface::class); + $attributeMetadataMock = $this->createMock(AttributeMetadataInterface::class); $this->attributeMetadataHydratorMock->expects($this->at(0)) ->method('hydrate') ->with($attributeMetadataOneData) ->willReturn($attributeMetadataMock); $attributesMetadata = $this->attributeMetadataCache->load($entityType, $suffix); $this->assertInternalType( - \PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, + \PHPUnit\Framework\Constraint\IsType::TYPE_ARRAY, $attributesMetadata ); $this->assertArrayHasKey( @@ -174,7 +168,7 @@ public function testSave() ->willReturn(true); /** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $attributeMetadataMock */ - $attributeMetadataMock = $this->getMock(AttributeMetadataInterface::class); + $attributeMetadataMock = $this->createMock(AttributeMetadataInterface::class); $attributesMetadata = [$attributeMetadataMock]; $this->attributeMetadataHydratorMock->expects($this->once()) ->method('extract') diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/AttributeMetadataHydratorTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/AttributeMetadataHydratorTest.php index 9851449f832a6..ec9831dde081e 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/AttributeMetadataHydratorTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/AttributeMetadataHydratorTest.php @@ -21,7 +21,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class AttributeMetadataHydratorTest extends \PHPUnit_Framework_TestCase +class AttributeMetadataHydratorTest extends \PHPUnit\Framework\TestCase { /** * @var AttributeMetadataInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject @@ -56,35 +56,14 @@ class AttributeMetadataHydratorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $this->attributeMetadataFactoryMock = $this->getMock( + $this->attributeMetadataFactoryMock = $this->createPartialMock( AttributeMetadataInterfaceFactory::class, - ['create'], - [], - '', - false - ); - $this->optionFactoryMock = $this->getMock( - OptionInterfaceFactory::class, - ['create'], - [], - '', - false - ); - $this->validationRuleFactoryMock = $this->getMock( - ValidationRuleInterfaceFactory::class, - ['create'], - [], - '', - false - ); - $this->attributeMetadataMock = $this->getMock(AttributeMetadataInterface::class); - $this->dataObjectProcessorMock = $this->getMock( - DataObjectProcessor::class, - [], - [], - '', - false + ['create'] ); + $this->optionFactoryMock = $this->createPartialMock(OptionInterfaceFactory::class, ['create']); + $this->validationRuleFactoryMock = $this->createPartialMock(ValidationRuleInterfaceFactory::class, ['create']); + $this->attributeMetadataMock = $this->createMock(AttributeMetadataInterface::class); + $this->dataObjectProcessorMock = $this->createMock(DataObjectProcessor::class); $this->attributeMetadataHydrator = $objectManager->getObject( AttributeMetadataHydrator::class, [ @@ -182,7 +161,7 @@ public function testHydrate() $attributeMetadata->getAttributeCode() ); $this->assertInternalType( - \PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, + \PHPUnit\Framework\Constraint\IsType::TYPE_ARRAY, $attributeMetadata->getOptions() ); $this->assertArrayHasKey( @@ -198,7 +177,7 @@ public function testHydrate() $this->assertInstanceOf(OptionInterface::class, $attributeMetadata->getOptions()[1]); $this->assertInternalType( - \PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, + \PHPUnit\Framework\Constraint\IsType::TYPE_ARRAY, $attributeMetadata->getOptions()[1]->getOptions() ); $this->assertArrayHasKey(0, $attributeMetadata->getOptions()[1]->getOptions()); @@ -208,7 +187,7 @@ public function testHydrate() $attributeMetadata->getOptions()[1]->getOptions()[0]->getLabel() ); $this->assertInternalType( - \PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, + \PHPUnit\Framework\Constraint\IsType::TYPE_ARRAY, $attributeMetadata->getValidationRules() ); $this->assertArrayHasKey(0, $attributeMetadata->getValidationRules()); diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/AttributeResolverTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/AttributeResolverTest.php index 65001d5a83499..8db9a4dffcf46 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/AttributeResolverTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/AttributeResolverTest.php @@ -10,7 +10,7 @@ use Magento\Customer\Model\AttributeMetadataDataProvider; use Magento\Customer\Model\Metadata\AttributeResolver; -class AttributeResolverTest extends \PHPUnit_Framework_TestCase +class AttributeResolverTest extends \PHPUnit\Framework\TestCase { /** @var AttributeResolver */ protected $model; diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/CustomerMetadataManagementTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/CustomerMetadataManagementTest.php index c7066fda006c5..d5880e3ef6dcf 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/CustomerMetadataManagementTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/CustomerMetadataManagementTest.php @@ -9,7 +9,7 @@ use Magento\Customer\Api\Data\AttributeMetadataInterface; use Magento\Customer\Model\Metadata\CustomerMetadataManagement; -class CustomerMetadataManagementTest extends \PHPUnit_Framework_TestCase +class CustomerMetadataManagementTest extends \PHPUnit\Framework\TestCase { /** @var CustomerMetadataManagement */ protected $model; diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/ElementFactoryTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/ElementFactoryTest.php index d76d83eada401..419246b3bbe9c 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/ElementFactoryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/ElementFactoryTest.php @@ -7,7 +7,7 @@ use Magento\Customer\Model\Metadata\ElementFactory; -class ElementFactoryTest extends \PHPUnit_Framework_TestCase +class ElementFactoryTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Framework\ObjectManagerInterface | \PHPUnit_Framework_MockObject_MockObject */ private $_objectManager; @@ -23,14 +23,8 @@ class ElementFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); - $this->_attributeMetadata = $this->getMock( - \Magento\Customer\Model\Data\AttributeMetadata::class, - [], - [], - '', - false - ); + $this->_objectManager = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); + $this->_attributeMetadata = $this->createMock(\Magento\Customer\Model\Data\AttributeMetadata::class); $this->_elementFactory = new ElementFactory($this->_objectManager, new \Magento\Framework\Stdlib\StringUtils()); } @@ -45,7 +39,7 @@ public function testAttributePostcodeDataModelClass() $this->returnValue(\Magento\Customer\Model\Attribute\Data\Postcode::class) ); - $dataModel = $this->getMock(\Magento\Customer\Model\Metadata\Form\Text::class, [], [], '', false); + $dataModel = $this->createMock(\Magento\Customer\Model\Metadata\Form\Text::class); $this->_objectManager->expects($this->once())->method('create')->will($this->returnValue($dataModel)); $actual = $this->_elementFactory->create($this->_attributeMetadata, '95131', $this->_entityTypeCode); @@ -63,7 +57,7 @@ public function testAttributeEmptyDataModelClass() $this->returnValue('text') ); - $dataModel = $this->getMock(\Magento\Customer\Model\Metadata\Form\Text::class, [], [], '', false); + $dataModel = $this->createMock(\Magento\Customer\Model\Metadata\Form\Text::class); $params = [ 'entityTypeCode' => $this->_entityTypeCode, 'value' => 'Some Text', diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/AbstractDataTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/AbstractDataTest.php index 8c142f2eddcb1..b9f8564d3616a 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/AbstractDataTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/AbstractDataTest.php @@ -10,7 +10,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class AbstractDataTest extends \PHPUnit_Framework_TestCase +class AbstractDataTest extends \PHPUnit\Framework\TestCase { const MODEL = 'MODEL'; @@ -47,7 +47,7 @@ protected function setUp() \Magento\Framework\Locale\ResolverInterface::class )->disableOriginalConstructor()->getMock(); $this->_loggerMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); - $this->_attributeMock = $this->getMock(\Magento\Customer\Api\Data\AttributeMetadataInterface::class); + $this->_attributeMock = $this->createMock(\Magento\Customer\Api\Data\AttributeMetadataInterface::class); $this->_value = 'VALUE'; $this->_entityTypeCode = 'ENTITY_TYPE_CODE'; $this->_isAjax = false; @@ -343,8 +343,10 @@ public function getRequestValueDataProvider() )->will( $this->returnValue(['ATTR_CODE' => $expectedValue]) ); - $requestMockTwo->expects( - $this->at(1) + + $requestMockFour = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class)->getMock(); + $requestMockFour->expects( + $this->at(0) )->method( 'getParam' )->with( @@ -366,8 +368,8 @@ public function getRequestValueDataProvider() return [ [$requestMockOne, 'ATTR_CODE', false, false, $expectedValue], [$requestMockTwo, 'ATTR_CODE', 'REQUEST_SCOPE', false, $expectedValue], - [$requestMockTwo, 'ATTR_CODE', 'REQUEST_SCOPE', false, false], - [$requestMockThree, 'ATTR_CODE', 'REQUEST/SCOPE', false, $expectedValue] + [$requestMockThree, 'ATTR_CODE', 'REQUEST/SCOPE', false, $expectedValue], + [$requestMockFour, 'ATTR_CODE', 'REQUEST_SCOPE', false, false], ]; } } diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/AbstractFormTestCase.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/AbstractFormTestCase.php index 3b82dca4b4af9..03a8769082e6e 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/AbstractFormTestCase.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/AbstractFormTestCase.php @@ -6,7 +6,7 @@ namespace Magento\Customer\Test\Unit\Model\Metadata\Form; /** Test Magento\Customer\Model\Metadata\Form\Multiline */ -abstract class AbstractFormTestCase extends \PHPUnit_Framework_TestCase +abstract class AbstractFormTestCase extends \PHPUnit\Framework\TestCase { /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\Stdlib\DateTime\TimezoneInterface */ protected $localeMock; @@ -27,6 +27,6 @@ protected function setUp() $this->localeResolverMock = $this->getMockBuilder(\Magento\Framework\Locale\ResolverInterface::class) ->getMock(); $this->loggerMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock(); - $this->attributeMetadataMock = $this->getMock(\Magento\Customer\Api\Data\AttributeMetadataInterface::class); + $this->attributeMetadataMock = $this->createMock(\Magento\Customer\Api\Data\AttributeMetadataInterface::class); } } diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/FileTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/FileTest.php index f9b375a9cf61c..97452b995ba0b 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/FileTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/FileTest.php @@ -63,7 +63,7 @@ protected function setUp() ->disableOriginalConstructor()->getMock(); $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); - $this->uploaderFactoryMock = $this->getMock(\Magento\Framework\File\UploaderFactory::class, [], [], '', false); + $this->uploaderFactoryMock = $this->createMock(\Magento\Framework\File\UploaderFactory::class); $this->fileProcessorMock = $this->getMockBuilder(\Magento\Customer\Model\FileProcessor::class) ->disableOriginalConstructor() ->getMock(); @@ -371,7 +371,7 @@ public function testCompactValueTmpFile() $mediaDirMock->expects($this->any()) ->method('getAbsolutePath') ->will($this->returnArgument(0)); - $uploaderMock = $this->getMock(\Magento\Framework\File\Uploader::class, [], [], '', false); + $uploaderMock = $this->createMock(\Magento\Framework\File\Uploader::class); $this->uploaderFactoryMock->expects($this->once()) ->method('create') ->with(['fileId' => $value]) diff --git a/app/code/Magento/Customer/Test/Unit/Model/Metadata/ValidatorTest.php b/app/code/Magento/Customer/Test/Unit/Model/Metadata/ValidatorTest.php index 2897618bd72e5..bef2db9bf2694 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Metadata/ValidatorTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Metadata/ValidatorTest.php @@ -8,7 +8,7 @@ use Magento\Customer\Model\Data\AttributeMetadata; use Magento\Customer\Model\Metadata\Validator; -class ValidatorTest extends \PHPUnit_Framework_TestCase +class ValidatorTest extends \PHPUnit\Framework\TestCase { /** @var Validator */ protected $validator; diff --git a/app/code/Magento/Customer/Test/Unit/Model/Plugin/AllowedCountriesTest.php b/app/code/Magento/Customer/Test/Unit/Model/Plugin/AllowedCountriesTest.php index cd3c17a6767c2..de87a865a2034 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Plugin/AllowedCountriesTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Plugin/AllowedCountriesTest.php @@ -11,7 +11,7 @@ use Magento\Store\Model\ScopeInterface; use Magento\Store\Model\StoreManagerInterface; -class AllowedCountriesTest extends \PHPUnit_Framework_TestCase +class AllowedCountriesTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Model\Config\Share | \PHPUnit_Framework_MockObject_MockObject @@ -31,7 +31,7 @@ public function setUp() $this->shareConfig = $this->getMockBuilder(Share::class) ->disableOriginalConstructor() ->getMock(); - $this->storeManager = $this->getMock(StoreManagerInterface::class); + $this->storeManager = $this->createMock(StoreManagerInterface::class); $this->plugin = new AllowedCountries($this->shareConfig, $this->storeManager); } @@ -47,7 +47,7 @@ public function testGetAllowedCountriesWithGlobalScope() $originalAllowedCountriesMock = $this->getMockBuilder(\Magento\Directory\Model\AllowedCountries::class) ->disableOriginalConstructor() ->getMock(); - $websiteMock = $this->getMock(WebsiteInterface::class); + $websiteMock = $this->createMock(WebsiteInterface::class); $websiteMock->expects($this->once()) ->method('getId') ->willReturn($expectedFilter); diff --git a/app/code/Magento/Customer/Test/Unit/Model/Plugin/CustomerNotificationTest.php b/app/code/Magento/Customer/Test/Unit/Model/Plugin/CustomerNotificationTest.php index 86d4dd6ca2664..7ae71e17a1b20 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Plugin/CustomerNotificationTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Plugin/CustomerNotificationTest.php @@ -5,81 +5,107 @@ */ namespace Magento\Customer\Test\Unit\Model\Plugin; +use Magento\Backend\App\AbstractAction; +use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\Customer\Api\Data\CustomerInterface; use Magento\Customer\Model\Customer\NotificationStorage; use Magento\Customer\Model\Plugin\CustomerNotification; +use Magento\Customer\Model\Session; +use Magento\Framework\App\Area; +use Magento\Framework\App\RequestInterface; +use Magento\Framework\App\State; +use Magento\Framework\Exception\NoSuchEntityException; +use Psr\Log\LoggerInterface; -class CustomerNotificationTest extends \PHPUnit_Framework_TestCase +class CustomerNotificationTest extends \PHPUnit\Framework\TestCase { - /** @var \Magento\Customer\Model\Session|\PHPUnit_Framework_MockObject_MockObject */ - protected $session; + /** @var Session|\PHPUnit_Framework_MockObject_MockObject */ + private $session; /** @var \Magento\Customer\Model\Customer\NotificationStorage|\PHPUnit_Framework_MockObject_MockObject */ - protected $notificationStorage; + private $notificationStorage; - /** @var \Magento\Customer\Api\CustomerRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $customerRepository; + /** @var CustomerRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject */ + private $customerRepository; - /** @var \Magento\Framework\App\State|\PHPUnit_Framework_MockObject_MockObject */ - protected $appState; + /** @var State|\PHPUnit_Framework_MockObject_MockObject */ + private $appState; - /** @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $request; + /** @var RequestInterface|\PHPUnit_Framework_MockObject_MockObject */ + private $request; - /** @var \Magento\Backend\App\AbstractAction|\PHPUnit_Framework_MockObject_MockObject */ - protected $abstractAction; + /** @var AbstractAction|\PHPUnit_Framework_MockObject_MockObject */ + private $abstractAction; /** @var CustomerNotification */ - protected $plugin; + private $plugin; + + /** @var int */ + private static $customerId = 1; protected function setUp() { - $this->session = $this->getMockBuilder(\Magento\Customer\Model\Session::class) + $this->session = $this->getMockBuilder(Session::class) ->disableOriginalConstructor() ->getMock(); - $this->notificationStorage = $this->getMockBuilder(\Magento\Customer\Model\Customer\NotificationStorage::class) + $this->notificationStorage = $this->getMockBuilder(NotificationStorage::class) ->disableOriginalConstructor() ->getMock(); - $this->customerRepository = $this->getMockBuilder(\Magento\Customer\Api\CustomerRepositoryInterface::class) - ->getMockForAbstractClass(); - $this->abstractAction = $this->getMockBuilder(\Magento\Backend\App\AbstractAction::class) + $this->customerRepository = $this->getMockForAbstractClass(CustomerRepositoryInterface::class); + $this->abstractAction = $this->getMockBuilder(AbstractAction::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->request = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class) + $this->request = $this->getMockBuilder(RequestInterface::class) ->setMethods(['isPost']) ->getMockForAbstractClass(); - $this->appState = $this->getMockBuilder(\Magento\Framework\App\State::class) + $this->appState = $this->getMockBuilder(State::class) ->disableOriginalConstructor()->getMock(); + $this->logger = $this->getMockForAbstractClass(LoggerInterface::class); + + $this->appState->method('getAreaCode')->willReturn(Area::AREA_FRONTEND); + $this->request->method('isPost')->willReturn(true); + $this->session->method('getCustomerId')->willReturn(self::$customerId); + $this->notificationStorage->expects($this->any()) + ->method('isExists') + ->with(NotificationStorage::UPDATE_CUSTOMER_SESSION, self::$customerId) + ->willReturn(true); + $this->plugin = new CustomerNotification( $this->session, $this->notificationStorage, $this->appState, - $this->customerRepository + $this->customerRepository, + $this->logger ); } public function testBeforeDispatch() { - $customerId = 1; $customerGroupId =1; - $this->appState->expects($this->any()) - ->method('getAreaCode') - ->willReturn(\Magento\Framework\App\Area::AREA_FRONTEND); - $this->request->expects($this->any())->method('isPost')->willReturn(true); - $customerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) - ->getMockForAbstractClass(); - $customerMock->expects($this->any())->method('getGroupId')->willReturn($customerGroupId); - $this->customerRepository->expects($this->any()) + + $customerMock = $this->getMockForAbstractClass(CustomerInterface::class); + $customerMock->method('getGroupId')->willReturn($customerGroupId); + $this->customerRepository->expects($this->once()) ->method('getById') - ->with($customerId) + ->with(self::$customerId) ->willReturn($customerMock); - $this->session->expects($this->any())->method('getCustomerId')->willReturn($customerId); - $this->session->expects($this->any())->method('setCustomerData')->with($customerMock); - $this->session->expects($this->any())->method('setCustomerGroupId')->with($customerGroupId); + $this->session->expects($this->once())->method('setCustomerData')->with($customerMock); + $this->session->expects($this->once())->method('setCustomerGroupId')->with($customerGroupId); $this->session->expects($this->once())->method('regenerateId'); - $this->notificationStorage->expects($this->any()) - ->method('isExists') - ->with(NotificationStorage::UPDATE_CUSTOMER_SESSION, $customerId) - ->willReturn(true); + $this->notificationStorage->expects($this->once()) + ->method('remove') + ->with(NotificationStorage::UPDATE_CUSTOMER_SESSION, self::$customerId); + + $this->plugin->beforeDispatch($this->abstractAction, $this->request); + } + + public function testBeforeDispatchWithNoCustomerFound() + { + $this->customerRepository->method('getById') + ->with(self::$customerId) + ->willThrowException(new NoSuchEntityException()); + $this->logger->expects($this->once()) + ->method('error'); $this->plugin->beforeDispatch($this->abstractAction, $this->request); } diff --git a/app/code/Magento/Customer/Test/Unit/Model/Plugin/CustomerRepository/TransactionWrapperTest.php b/app/code/Magento/Customer/Test/Unit/Model/Plugin/CustomerRepository/TransactionWrapperTest.php index e8ebefeea3e5a..585750f11947a 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Plugin/CustomerRepository/TransactionWrapperTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Plugin/CustomerRepository/TransactionWrapperTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Customer\Test\Unit\Model\Plugin\CustomerRepository; -class TransactionWrapperTest extends \PHPUnit_Framework_TestCase +class TransactionWrapperTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Model\Plugin\CustomerRepository\TransactionWrapper @@ -46,15 +46,9 @@ class TransactionWrapperTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->resourceMock = $this->getMock(\Magento\Customer\Model\ResourceModel\Customer::class, [], [], '', false); - $this->subjectMock = $this->getMock( - \Magento\Customer\Api\CustomerRepositoryInterface::class, - [], - [], - '', - false - ); - $this->customerMock = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', false); + $this->resourceMock = $this->createMock(\Magento\Customer\Model\ResourceModel\Customer::class); + $this->subjectMock = $this->createMock(\Magento\Customer\Api\CustomerRepositoryInterface::class); + $this->customerMock = $this->createMock(\Magento\Customer\Api\Data\CustomerInterface::class); $customerMock = $this->customerMock; $this->closureMock = function () use ($customerMock) { return $customerMock; diff --git a/app/code/Magento/Customer/Test/Unit/Model/Renderer/RegionTest.php b/app/code/Magento/Customer/Test/Unit/Model/Renderer/RegionTest.php index c428f6393d81e..759c823eec7f9 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Renderer/RegionTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Renderer/RegionTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Customer\Test\Unit\Model\Renderer; -class RegionTest extends \PHPUnit_Framework_TestCase +class RegionTest extends \PHPUnit\Framework\TestCase { /** * @param array $regionCollection @@ -13,50 +13,30 @@ class RegionTest extends \PHPUnit_Framework_TestCase */ public function testRender($regionCollection) { - $countryFactoryMock = $this->getMock( - \Magento\Directory\Model\CountryFactory::class, - [], - [], - '', - false + $countryFactoryMock = $this->createMock( + \Magento\Directory\Model\CountryFactory::class ); - $directoryHelperMock = $this->getMock( + $directoryHelperMock = $this->createPartialMock( \Magento\Directory\Helper\Data::class, - ['isRegionRequired'], - [], - '', - false + ['isRegionRequired'] ); - $escaperMock = $this->getMock(\Magento\Framework\Escaper::class, [], [], '', false); - $elementMock = $this->getMock( + $escaperMock = $this->createMock(\Magento\Framework\Escaper::class); + $elementMock = $this->createPartialMock( \Magento\Framework\Data\Form\Element\AbstractElement::class, - ['getForm', 'getHtmlAttributes'], - [], - '', - false + ['getForm', 'getHtmlAttributes'] ); - $countryMock = $this->getMock( + $countryMock = $this->createPartialMock( \Magento\Framework\Data\Form\Element\AbstractElement::class, - ['getValue'], - [], - '', - false + ['getValue'] ); - $regionMock = $this->getMock( - \Magento\Framework\Data\Form\Element\AbstractElement::class, - [], - [], - '', - false + $regionMock = $this->createMock( + \Magento\Framework\Data\Form\Element\AbstractElement::class ); - $countryModelMock = $this->getMock( + $countryModelMock = $this->createPartialMock( \Magento\Directory\Model\Country::class, - ['setId', 'getLoadedRegionCollection', 'toOptionArray', '__wakeup'], - [], - '', - false + ['setId', 'getLoadedRegionCollection', 'toOptionArray', '__wakeup'] ); - $formMock = $this->getMock(\Magento\Framework\Data\Form::class, ['getElement'], [], '', false); + $formMock = $this->createPartialMock(\Magento\Framework\Data\Form::class, ['getElement']); $elementMock->expects($this->any())->method('getForm')->will($this->returnValue($formMock)); $elementMock->expects( diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Address/Attribute/Backend/RegionTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Address/Attribute/Backend/RegionTest.php index 9fe2fef41f792..a5cbd42e5936f 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Address/Attribute/Backend/RegionTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Address/Attribute/Backend/RegionTest.php @@ -8,7 +8,7 @@ use Magento\Customer\Model\ResourceModel\Address\Attribute\Backend\Region; -class RegionTest extends \PHPUnit_Framework_TestCase +class RegionTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Directory\Model\RegionFactory|\PHPUnit_Framework_MockObject_MockObject */ protected $regionFactory; @@ -24,21 +24,15 @@ class RegionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->regionFactory = $this->getMock(\Magento\Directory\Model\RegionFactory::class, ['create'], [], '', false); - $this->region = $this->getMock( + $this->regionFactory = $this->createPartialMock(\Magento\Directory\Model\RegionFactory::class, ['create']); + $this->region = $this->createPartialMock( \Magento\Directory\Model\Region::class, - ['load', 'getId', 'getCountryId', 'getName'], - [], - '', - false + ['load', 'getId', 'getCountryId', 'getName'] ); $this->model = new Region($this->regionFactory); - $this->object = $this->getMock( + $this->object = $this->createPartialMock( \Magento\Framework\DataObject::class, - ['getData', 'getCountryId', 'setRegionId', 'setRegion'], - [], - '', - false + ['getData', 'getCountryId', 'setRegionId', 'setRegion'] ); } diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Address/Attribute/Source/CountryWithWebsitesTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Address/Attribute/Source/CountryWithWebsitesTest.php index 8d66bb406aee3..b083bea54cb82 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Address/Attribute/Source/CountryWithWebsitesTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Address/Attribute/Source/CountryWithWebsitesTest.php @@ -13,7 +13,7 @@ use Magento\Store\Api\Data\WebsiteInterface; use Magento\Store\Model\StoreManagerInterface; -class CountryWithWebsitesTest extends \PHPUnit_Framework_TestCase +class CountryWithWebsitesTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Directory\Model\ResourceModel\Country\CollectionFactory | \PHPUnit_Framework_MockObject_MockObject @@ -58,7 +58,7 @@ public function setUp() $this->getMockBuilder(\Magento\Eav\Model\ResourceModel\Entity\Attribute\OptionFactory::class) ->disableOriginalConstructor() ->getMock(); - $this->storeManagerMock = $this->getMock(StoreManagerInterface::class); + $this->storeManagerMock = $this->createMock(StoreManagerInterface::class); $this->shareConfigMock = $this->getMockBuilder(Share::class) ->disableOriginalConstructor() ->getMock(); @@ -74,8 +74,8 @@ public function setUp() public function testGetAllOptions() { - $website1 = $this->getMock(WebsiteInterface::class); - $website2 = $this->getMock(WebsiteInterface::class); + $website1 = $this->createMock(WebsiteInterface::class); + $website2 = $this->createMock(WebsiteInterface::class); $website1->expects($this->atLeastOnce()) ->method('getId') diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Address/DeleteRelationTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Address/DeleteRelationTest.php index 56a23ebce0b6c..97a9762ee0e54 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Address/DeleteRelationTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Address/DeleteRelationTest.php @@ -11,19 +11,16 @@ /** * Class AddressTest */ -class DeleteRelationTest extends \PHPUnit_Framework_TestCase +class DeleteRelationTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Customer\Model\ResourceModel\Address\DeleteRelation */ protected $relation; protected function setUp() { - $this->customerFactoryMock = $this->getMock( + $this->customerFactoryMock = $this->createPartialMock( \Magento\Customer\Model\CustomerFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->relation = (new ObjectManagerHelper($this))->getObject( \Magento\Customer\Model\ResourceModel\Address\DeleteRelation::class @@ -41,6 +38,7 @@ public function testDeleteRelation($addressId, $isDefaultBilling, $isDefaultShip /** @var AbstractModel | \PHPUnit_Framework_MockObject_MockObject $addressModel */ $addressModel = $this->getMockBuilder(\Magento\Framework\Model\AbstractModel::class) ->disableOriginalConstructor() + ->setMethods(['getIsCustomerSaveTransaction', 'getId', 'getResource']) ->getMock(); /** @var \Magento\Customer\Model\Customer | \PHPUnit_Framework_MockObject_MockObject $customerModel */ $customerModel = $this->getMockBuilder(\Magento\Customer\Model\Customer::class) @@ -97,7 +95,8 @@ public function testDeleteRelation($addressId, $isDefaultBilling, $isDefaultShip $conditionSql ); } - $this->relation->deleteRelation($addressModel, $customerModel); + $result = $this->relation->deleteRelation($addressModel, $customerModel); + $this->assertNull($result); } /** diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Address/RelationTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Address/RelationTest.php index 008917136b6ff..e81637cfb23b2 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Address/RelationTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Address/RelationTest.php @@ -10,7 +10,7 @@ /** * Class AddressTest */ -class RelationTest extends \PHPUnit_Framework_TestCase +class RelationTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Customer\Model\CustomerFactory | \PHPUnit_Framework_MockObject_MockObject */ protected $customerFactoryMock; @@ -20,12 +20,9 @@ class RelationTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->customerFactoryMock = $this->getMock( + $this->customerFactoryMock = $this->createPartialMock( \Magento\Customer\Model\CustomerFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->relation = (new ObjectManagerHelper($this))->getObject( \Magento\Customer\Model\ResourceModel\Address\Relation::class, @@ -43,9 +40,7 @@ protected function setUp() */ public function testProcessRelation($addressId, $isDefaultBilling, $isDefaultShipping) { - $addressModel = $this->getMock( - \Magento\Framework\Model\AbstractModel::class, - [ + $addressModel = $this->createPartialMock(\Magento\Framework\Model\AbstractModel::class, [ '__wakeup', 'getId', 'getEntityTypeId', @@ -55,18 +50,12 @@ public function testProcessRelation($addressId, $isDefaultBilling, $isDefaultShi 'validateBeforeSave', 'beforeSave', 'afterSave', - 'isSaveAllowed' - ], - [], - '', - false - ); - $customerModel = $this->getMock( + 'isSaveAllowed', + 'getIsCustomerSaveTransaction' + ]); + $customerModel = $this->createPartialMock( \Magento\Customer\Model\Customer::class, - ['__wakeup', 'setDefaultBilling', 'setDefaultShipping', 'save', 'load', 'getResource', 'getId'], - [], - '', - false + ['__wakeup', 'setDefaultBilling', 'setDefaultShipping', 'save', 'load', 'getResource', 'getId'] ); $customerResource = $this->getMockForAbstractClass( \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, @@ -123,7 +112,8 @@ public function testProcessRelation($addressId, $isDefaultBilling, $isDefaultShi $conditionSql ); } - $this->relation->processRelation($addressModel); + $result = $this->relation->processRelation($addressModel); + $this->assertNull($result); } /** diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/AddressRepositoryTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/AddressRepositoryTest.php index c76f5a043ea65..f2ccc50dc68d0 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/AddressRepositoryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/AddressRepositoryTest.php @@ -10,7 +10,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class AddressRepositoryTest extends \PHPUnit_Framework_TestCase +class AddressRepositoryTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Directory\Helper\Data|\PHPUnit_Framework_MockObject_MockObject @@ -74,36 +74,18 @@ class AddressRepositoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->addressFactory = $this->getMock( - \Magento\Customer\Model\AddressFactory::class, - ['create'], - [], - '', - false - ); - $this->addressRegistry = $this->getMock(\Magento\Customer\Model\AddressRegistry::class, [], [], '', false); - $this->customerRegistry = $this->getMock(\Magento\Customer\Model\CustomerRegistry::class, [], [], '', false); - $this->addressResourceModel = $this->getMock( - \Magento\Customer\Model\ResourceModel\Address::class, - [], - [], - '', - false - ); - $this->directoryData = $this->getMock(\Magento\Directory\Helper\Data::class, [], [], '', false); - $this->addressSearchResultsFactory = $this->getMock( + $this->addressFactory = $this->createPartialMock(\Magento\Customer\Model\AddressFactory::class, ['create']); + $this->addressRegistry = $this->createMock(\Magento\Customer\Model\AddressRegistry::class); + $this->customerRegistry = $this->createMock(\Magento\Customer\Model\CustomerRegistry::class); + $this->addressResourceModel = $this->createMock(\Magento\Customer\Model\ResourceModel\Address::class); + $this->directoryData = $this->createMock(\Magento\Directory\Helper\Data::class); + $this->addressSearchResultsFactory = $this->createPartialMock( \Magento\Customer\Api\Data\AddressSearchResultsInterfaceFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->addressCollectionFactory = $this->getMock( + $this->addressCollectionFactory = $this->createPartialMock( \Magento\Customer\Model\ResourceModel\Address\CollectionFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->extensionAttributesJoinProcessor = $this->getMockForAbstractClass( \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface::class, @@ -111,10 +93,8 @@ protected function setUp() '', false ); - $this->customer = $this->getMock(\Magento\Customer\Model\Customer::class, [], [], '', false); - $this->address = $this->getMock( - \Magento\Customer\Model\Address::class, - [ + $this->customer = $this->createMock(\Magento\Customer\Model\Customer::class); + $this->address = $this->createPartialMock(\Magento\Customer\Model\Address::class, [ 'getId', 'getCountryId', 'getFirstname', @@ -132,11 +112,7 @@ protected function setUp() 'save', 'getDataModel', 'getCustomerId', - ], - [], - '', - false - ); + ]); $this->collectionProcessor = $this->getMockBuilder(CollectionProcessorInterface::class) ->getMockForAbstractClass(); @@ -165,7 +141,7 @@ public function testSave() false ); $addressCollection = - $this->getMock(\Magento\Customer\Model\ResourceModel\Address\Collection::class, [], [], '', false); + $this->createMock(\Magento\Customer\Model\ResourceModel\Address\Collection::class); $customerAddress->expects($this->atLeastOnce()) ->method('getCustomerId') ->willReturn($customerId); @@ -354,19 +330,13 @@ public function testGetById() $this->address->expects($this->once()) ->method('getDataModel') ->willReturn($customerAddress); - + $this->assertSame($customerAddress, $this->repository->getById(12)); } public function testGetList() { - $collection = $this->getMock( - \Magento\Customer\Model\ResourceModel\Address\Collection::class, - [], - [], - '', - false - ); + $collection = $this->createMock(\Magento\Customer\Model\ResourceModel\Address\Collection::class); $searchResults = $this->getMockForAbstractClass( \Magento\Customer\Api\Data\AddressSearchResultsInterface::class, [], @@ -428,13 +398,7 @@ public function testDelete() $addressId = 12; $customerId = 43; - $addressCollection = $this->getMock( - \Magento\Customer\Model\ResourceModel\Address\Collection::class, - [], - [], - '', - false - ); + $addressCollection = $this->createMock(\Magento\Customer\Model\ResourceModel\Address\Collection::class); $customerAddress = $this->getMockForAbstractClass( \Magento\Customer\Api\Data\AddressInterface::class, [], @@ -480,13 +444,7 @@ public function testDeleteById() $this->address->expects($this->once()) ->method('getCustomerId') ->willReturn($customerId); - $addressCollection = $this->getMock( - \Magento\Customer\Model\ResourceModel\Address\Collection::class, - [], - [], - '', - false - ); + $addressCollection = $this->createMock(\Magento\Customer\Model\ResourceModel\Address\Collection::class); $this->addressRegistry->expects($this->once()) ->method('retrieve') ->with($addressId) diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/AddressTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/AddressTest.php index 61a05eae79262..723ce6fa1826a 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/AddressTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/AddressTest.php @@ -14,7 +14,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class AddressTest extends \PHPUnit_Framework_TestCase +class AddressTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Customer\Test\Unit\Model\ResourceModel\SubResourceModelAddress */ protected $addressResource; @@ -33,21 +33,9 @@ class AddressTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->entitySnapshotMock = $this->getMock( - \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot::class, - [], - [], - '', - false - ); + $this->entitySnapshotMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot::class); - $this->entityRelationCompositeMock = $this->getMock( - \Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationComposite::class, - [], - [], - '', - false - ); + $this->entityRelationCompositeMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationComposite::class); $this->addressResource = (new ObjectManagerHelper($this))->getObject( \Magento\Customer\Test\Unit\Model\ResourceModel\SubResourceModelAddress::class, @@ -72,9 +60,7 @@ protected function setUp() public function testSave($addressId, $isDefaultBilling, $isDefaultShipping) { /** @var $address \Magento\Customer\Model\Address|\PHPUnit_Framework_MockObject_MockObject */ - $address = $this->getMock( - \Magento\Customer\Model\Address::class, - [ + $address = $this->createPartialMock(\Magento\Customer\Model\Address::class, [ '__wakeup', 'getId', 'getEntityTypeId', @@ -85,11 +71,7 @@ public function testSave($addressId, $isDefaultBilling, $isDefaultShipping) 'beforeSave', 'afterSave', 'isSaveAllowed' - ], - [], - '', - false - ); + ]); $this->entitySnapshotMock->expects($this->once())->method('isModified')->willReturn(true); $this->entityRelationCompositeMock->expects($this->once())->method('processRelations'); $address->expects($this->once())->method('isSaveAllowed')->willReturn(true); @@ -133,7 +115,7 @@ public function getSaveDataProvider() */ protected function prepareResource() { - $dbSelect = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); + $dbSelect = $this->createMock(\Magento\Framework\DB\Select::class); $dbSelect->expects($this->any())->method('from')->willReturnSelf(); $dbSelect->expects($this->any())->method('where')->willReturnSelf(); @@ -175,42 +157,22 @@ protected function prepareResource() */ protected function prepareEavConfig() { - $attributeMock = $this->getMock( - \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class, - ['getAttributeCode', 'getBackend', '__wakeup'], - [], - '', - false - ); + $attributeMock = $this->createPartialMock(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class, ['getAttributeCode', 'getBackend', '__wakeup']); $attributeMock->expects($this->any()) ->method('getAttributeCode') ->willReturn('entity_id'); $attributeMock->expects($this->any()) ->method('getBackend') ->willReturn( - $this->getMock( - \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend::class, [], [], '', false - ) + $this->createMock(\Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend::class) ); - $this->eavConfigType = $this->getMock( - \Magento\Eav\Model\Entity\Type::class, - ['getEntityIdField', 'getId', 'getEntityTable', '__wakeup'], - [], - '', - false - ); + $this->eavConfigType = $this->createPartialMock(\Magento\Eav\Model\Entity\Type::class, ['getEntityIdField', 'getId', 'getEntityTable', '__wakeup']); $this->eavConfigType->expects($this->any())->method('getEntityIdField')->willReturn(false); $this->eavConfigType->expects($this->any())->method('getId')->willReturn(false); $this->eavConfigType->expects($this->any())->method('getEntityTable')->willReturn('customer_address_entity'); - $eavConfig = $this->getMock( - \Magento\Eav\Model\Config::class, - ['getEntityType', 'getEntityAttributeCodes', 'getAttribute'], - [], - '', - false - ); + $eavConfig = $this->createPartialMock(\Magento\Eav\Model\Config::class, ['getEntityType', 'getEntityAttributeCodes', 'getAttribute']); $eavConfig->expects($this->any()) ->method('getEntityType') ->with('customer_address') @@ -251,18 +213,12 @@ protected function prepareEavConfig() */ protected function prepareValidatorFactory() { - $validatorMock = $this->getMock(\Magento\Framework\Validator::class, ['isValid'], [], '', false); + $validatorMock = $this->createPartialMock(\Magento\Framework\Validator::class, ['isValid']); $validatorMock->expects($this->any()) ->method('isValid') ->willReturn(true); - $validatorFactory = $this->getMock( - \Magento\Framework\Validator\Factory::class, - ['createValidator'], - [], - '', - false - ); + $validatorFactory = $this->createPartialMock(\Magento\Framework\Validator\Factory::class, ['createValidator']); $validatorFactory->expects($this->any()) ->method('createValidator') ->with('customer_address', 'save') @@ -273,13 +229,7 @@ protected function prepareValidatorFactory() protected function prepareCustomerFactory() { - $this->customerFactory = $this->getMock( - \Magento\Customer\Model\CustomerFactory::class, - ['create'], - [], - '', - false - ); + $this->customerFactory = $this->createPartialMock(\Magento\Customer\Model\CustomerFactory::class, ['create']); return $this->customerFactory; } diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Customer/GridTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Customer/GridTest.php index 2059f28ffc68e..ff29c7c233a42 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Customer/GridTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Customer/GridTest.php @@ -7,7 +7,7 @@ use Magento\Customer\Model\ResourceModel\Customer\Grid; -class GridTest extends \PHPUnit_Framework_TestCase +class GridTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Framework\App\ResourceConnection|\PHPUnit_Framework_MockObject_MockObject */ protected $resource; @@ -35,15 +35,9 @@ class GridTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->resource = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); - $this->indexerRegistry = $this->getMock(\Magento\Framework\Indexer\IndexerRegistry::class, [], [], '', false); - $this->flatScopeResolver = $this->getMock( - \Magento\Framework\Indexer\ScopeResolver\FlatScopeResolver::class, - [], - [], - '', - false - ); + $this->resource = $this->createMock(\Magento\Framework\App\ResourceConnection::class); + $this->indexerRegistry = $this->createMock(\Magento\Framework\Indexer\IndexerRegistry::class); + $this->flatScopeResolver = $this->createMock(\Magento\Framework\Indexer\ScopeResolver\FlatScopeResolver::class); $this->indexer = $this->getMockForAbstractClass( \Magento\Framework\Indexer\IndexerInterface::class, [], @@ -56,7 +50,7 @@ protected function setUp() '', false ); - $this->select = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); + $this->select = $this->createMock(\Magento\Framework\DB\Select::class); $this->queryResult = $this->getMockForAbstractClass( \Zend_Db_Statement_Interface::class, [], diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/CustomerRepositoryTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/CustomerRepositoryTest.php index 837953c587151..bedd9ff7b842d 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/CustomerRepositoryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/CustomerRepositoryTest.php @@ -7,13 +7,14 @@ namespace Magento\Customer\Test\Unit\Model\ResourceModel; use Magento\Customer\Api\CustomerMetadataInterface; +use Magento\Customer\Model\Customer\NotificationStorage; use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.TooManyFields) */ -class CustomerRepositoryTest extends \PHPUnit_Framework_TestCase +class CustomerRepositoryTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Model\CustomerFactory|\PHPUnit_Framework_MockObject_MockObject @@ -94,41 +95,34 @@ class CustomerRepositoryTest extends \PHPUnit_Framework_TestCase * @var \Magento\Customer\Model\ResourceModel\CustomerRepository */ protected $model; - + + /** + * @var NotificationStorage + */ + private $notificationStorage; + protected function setUp() { $this->customerResourceModel = - $this->getMock(\Magento\Customer\Model\ResourceModel\Customer::class, [], [], '', false); - $this->customerRegistry = $this->getMock(\Magento\Customer\Model\CustomerRegistry::class, [], [], '', false); - $this->dataObjectHelper = $this->getMock(\Magento\Framework\Api\DataObjectHelper::class, [], [], '', false); + $this->createMock(\Magento\Customer\Model\ResourceModel\Customer::class); + $this->customerRegistry = $this->createMock(\Magento\Customer\Model\CustomerRegistry::class); + $this->dataObjectHelper = $this->createMock(\Magento\Framework\Api\DataObjectHelper::class); $this->customerFactory = - $this->getMock(\Magento\Customer\Model\CustomerFactory::class, ['create'], [], '', false); - $this->customerSecureFactory = $this->getMock( + $this->createPartialMock(\Magento\Customer\Model\CustomerFactory::class, ['create']); + $this->customerSecureFactory = $this->createPartialMock( \Magento\Customer\Model\Data\CustomerSecureFactory::class, - ['create'], - [], - '', - false - ); - $this->addressRepository = $this->getMock( - \Magento\Customer\Model\ResourceModel\AddressRepository::class, - [], - [], - '', - false + ['create'] ); + $this->addressRepository = $this->createMock(\Magento\Customer\Model\ResourceModel\AddressRepository::class); $this->customerMetadata = $this->getMockForAbstractClass( \Magento\Customer\Api\CustomerMetadataInterface::class, [], '', false ); - $this->searchResultsFactory = $this->getMock( + $this->searchResultsFactory = $this->createPartialMock( \Magento\Customer\Api\Data\CustomerSearchResultsInterfaceFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->eventManager = $this->getMockForAbstractClass( \Magento\Framework\Event\ManagerInterface::class, @@ -142,12 +136,8 @@ protected function setUp() '', false ); - $this->extensibleDataObjectConverter = $this->getMock( - \Magento\Framework\Api\ExtensibleDataObjectConverter::class, - [], - [], - '', - false + $this->extensibleDataObjectConverter = $this->createMock( + \Magento\Framework\Api\ExtensibleDataObjectConverter::class ); $this->imageProcessor = $this->getMockForAbstractClass( \Magento\Framework\Api\ImageProcessorInterface::class, @@ -174,6 +164,10 @@ protected function setUp() ); $this->collectionProcessorMock = $this->getMockBuilder(CollectionProcessorInterface::class) ->getMock(); + $this->notificationStorage = $this->getMockBuilder(NotificationStorage::class) + ->disableOriginalConstructor() + ->getMock(); + $this->model = new \Magento\Customer\Model\ResourceModel\CustomerRepository( $this->customerFactory, $this->customerSecureFactory, @@ -188,7 +182,8 @@ protected function setUp() $this->dataObjectHelper, $this->imageProcessor, $this->extensionAttributesJoinProcessor, - $this->collectionProcessorMock + $this->collectionProcessorMock, + $this->notificationStorage ); } @@ -229,9 +224,7 @@ public function testSave() 'getId' ] ); - $customerModel = $this->getMock( - \Magento\Customer\Model\Customer::class, - [ + $customerModel = $this->createPartialMock(\Magento\Customer\Model\Customer::class, [ 'getId', 'setId', 'setStoreId', @@ -246,11 +239,7 @@ public function testSave() 'setFirstFailure', 'setLockExpires', 'save', - ], - [], - '', - false - ); + ]); $this->customer->expects($this->atLeastOnce()) ->method('__toArray') @@ -271,20 +260,14 @@ public function testSave() 'setAddresses' ] ); - $customerSecureData = $this->getMock( - \Magento\Customer\Model\Data\CustomerSecure::class, - [ + $customerSecureData = $this->createPartialMock(\Magento\Customer\Model\Data\CustomerSecure::class, [ 'getRpToken', 'getRpTokenCreatedAt', 'getPasswordHash', 'getFailuresNum', 'getFirstFailure', 'getLockExpires', - ], - [], - '', - false - ); + ]); $this->customer->expects($this->atLeastOnce()) ->method('getId') ->willReturn($customerId); @@ -335,7 +318,7 @@ public function testSave() $customerModel->expects($this->once()) ->method('getStoreId') ->willReturn(null); - $store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $store = $this->createMock(\Magento\Store\Model\Store::class); $store->expects($this->once()) ->method('getId') ->willReturn($storeId); @@ -449,20 +432,14 @@ public function testSaveWithPasswordHash() $storeId = 2; $passwordHash = 'ukfa4sdfa56s5df02asdf4rt'; - $customerSecureData = $this->getMock( - \Magento\Customer\Model\Data\CustomerSecure::class, - [ + $customerSecureData = $this->createPartialMock(\Magento\Customer\Model\Data\CustomerSecure::class, [ 'getRpToken', 'getRpTokenCreatedAt', 'getPasswordHash', 'getFailuresNum', 'getFirstFailure', 'getLockExpires', - ], - [], - '', - false - ); + ]); $region = $this->getMockForAbstractClass( \Magento\Customer\Api\Data\RegionInterface::class, [], @@ -502,9 +479,7 @@ public function testSaveWithPasswordHash() ->method('__toArray') ->willReturn(['default_billing', 'default_shipping']); - $customerModel = $this->getMock( - \Magento\Customer\Model\Customer::class, - [ + $customerModel = $this->createPartialMock(\Magento\Customer\Model\Customer::class, [ 'getId', 'setId', 'setStoreId', @@ -516,11 +491,7 @@ public function testSaveWithPasswordHash() 'getDataModel', 'setPasswordHash', 'save', - ], - [], - '', - false - ); + ]); $customerAttributesMetaData = $this->getMockForAbstractClass( \Magento\Framework\Api\CustomAttributesDataInterface::class, [], @@ -623,7 +594,7 @@ public function testSaveWithPasswordHash() $customerModel->expects($this->once()) ->method('getStoreId') ->willReturn(null); - $store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $store = $this->createMock(\Magento\Store\Model\Store::class); $store->expects($this->once()) ->method('getId') ->willReturn($storeId); @@ -682,13 +653,7 @@ public function testSaveWithPasswordHash() */ public function testGetList() { - $collection = $this->getMock( - \Magento\Customer\Model\ResourceModel\Customer\Collection::class, - [], - [], - '', - false - ); + $collection = $this->createMock(\Magento\Customer\Model\ResourceModel\Customer\Collection::class); $searchResults = $this->getMockForAbstractClass( \Magento\Customer\Api\Data\AddressSearchResultsInterface::class, [], @@ -701,25 +666,25 @@ public function testGetList() '', false ); - $customerModel = $this->getMock( - \Magento\Customer\Model\Customer::class, - [ - 'getId', - 'setId', - 'setStoreId', - 'getStoreId', - 'getAttributeSetId', - 'setAttributeSetId', - 'setRpToken', - 'setRpTokenCreatedAt', - 'getDataModel', - 'setPasswordHash', - 'getCollection' - ], - [], - 'customerModel', - false - ); + $customerModel = $this->getMockBuilder(\Magento\Customer\Model\Customer::class) + ->setMethods( + [ + 'getId', + 'setId', + 'setStoreId', + 'getStoreId', + 'getAttributeSetId', + 'setAttributeSetId', + 'setRpToken', + 'setRpTokenCreatedAt', + 'getDataModel', + 'setPasswordHash', + 'getCollection' + ] + ) + ->setMockClassName('customerModel') + ->disableOriginalConstructor() + ->getMock(); $metadata = $this->getMockForAbstractClass( \Magento\Customer\Api\Data\AttributeMetadataInterface::class, [], @@ -802,13 +767,7 @@ public function testGetList() public function testDeleteById() { $customerId = 14; - $customerModel = $this->getMock( - \Magento\Customer\Model\Customer::class, - ['delete'], - [], - '', - false - ); + $customerModel = $this->createPartialMock(\Magento\Customer\Model\Customer::class, ['delete']); $this->customerRegistry ->expects($this->once()) ->method('retrieve') @@ -826,13 +785,7 @@ public function testDeleteById() public function testDelete() { $customerId = 14; - $customerModel = $this->getMock( - \Magento\Customer\Model\Customer::class, - ['delete'], - [], - '', - false - ); + $customerModel = $this->createPartialMock(\Magento\Customer\Model\Customer::class, ['delete']); $this->customer->expects($this->once()) ->method('getId') @@ -847,6 +800,9 @@ public function testDelete() $this->customerRegistry->expects($this->atLeastOnce()) ->method('remove') ->with($customerId); + $this->notificationStorage->expects($this->atLeastOnce()) + ->method('remove') + ->with(NotificationStorage::UPDATE_CUSTOMER_SESSION, $customerId); $this->assertTrue($this->model->delete($this->customer)); } diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Db/VersionControl/AddressSnapshotTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Db/VersionControl/AddressSnapshotTest.php index f38d8ed6d4ae9..f51b6894a8bd1 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Db/VersionControl/AddressSnapshotTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Db/VersionControl/AddressSnapshotTest.php @@ -7,7 +7,7 @@ use Magento\Customer\Model\ResourceModel\Db\VersionControl\AddressSnapshot; -class AddressSnapshotTest extends \PHPUnit_Framework_TestCase +class AddressSnapshotTest extends \PHPUnit\Framework\TestCase { /** * @var AddressSnapshot diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Group/Grid/ServiceCollectionTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Group/Grid/ServiceCollectionTest.php index efc94dbb69339..61081e1aaf224 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Group/Grid/ServiceCollectionTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Group/Grid/ServiceCollectionTest.php @@ -13,7 +13,7 @@ /** * Unit test for \Magento\Customer\Model\ResourceModel\Group\Grid\ServiceCollection */ -class ServiceCollectionTest extends \PHPUnit_Framework_TestCase +class ServiceCollectionTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager */ protected $objectManager; diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupRepositoryTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupRepositoryTest.php index 71e366cf33887..98cf8c212a784 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupRepositoryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupRepositoryTest.php @@ -11,7 +11,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class GroupRepositoryTest extends \PHPUnit_Framework_TestCase +class GroupRepositoryTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Model\GroupRegistry|\PHPUnit_Framework_MockObject_MockObject @@ -77,23 +77,14 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase * @var \Magento\Customer\Model\ResourceModel\GroupRepository */ protected $model; - + protected function setUp() { $this->setupGroupObjects(); - $this->dataObjectProcessor = $this->getMock( - \Magento\Framework\Reflection\DataObjectProcessor::class, - [], - [], - '', - false - ); - $this->searchResultsFactory = $this->getMock( + $this->dataObjectProcessor = $this->createMock(\Magento\Framework\Reflection\DataObjectProcessor::class); + $this->searchResultsFactory = $this->createPartialMock( \Magento\Customer\Api\Data\GroupSearchResultsInterfaceFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->searchResults = $this->getMockForAbstractClass( \Magento\Customer\Api\Data\GroupSearchResultsInterface::class, @@ -131,45 +122,30 @@ protected function setUp() private function setupGroupObjects() { - $this->groupRegistry = $this->getMock( - \Magento\Customer\Model\GroupRegistry::class, - [], - [], - '', - false - ); - $this->groupFactory = $this->getMock( - \Magento\Customer\Model\GroupFactory::class, - ['create'], - [], - '', - false - ); - $this->groupModel = $this->getMock( - \Magento\Customer\Model\Group::class, - [ - 'getTaxClassId', - 'getTaxClassName', - 'getId', - 'getCode', - 'setDataUsingMethod', - 'setCode', - 'setTaxClassId', - 'usesAsDefault', - 'delete', - 'getCollection', - 'getData', - ], - [], - 'groupModel', - false - ); - $this->groupDataFactory = $this->getMock( + $this->groupRegistry = $this->createMock(\Magento\Customer\Model\GroupRegistry::class); + $this->groupFactory = $this->createPartialMock(\Magento\Customer\Model\GroupFactory::class, ['create']); + $this->groupModel = $this->getMockBuilder(\Magento\Customer\Model\Group::class) + ->setMethods( + [ + 'getTaxClassId', + 'getTaxClassName', + 'getId', + 'getCode', + 'setDataUsingMethod', + 'setCode', + 'setTaxClassId', + 'usesAsDefault', + 'delete', + 'getCollection', + 'getData', + ] + ) + ->setMockClassName('groupModel') + ->disableOriginalConstructor() + ->getMock(); + $this->groupDataFactory = $this->createPartialMock( \Magento\Customer\Api\Data\GroupInterfaceFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->group = $this->getMockForAbstractClass( \Magento\Customer\Api\Data\GroupInterface::class, @@ -178,13 +154,7 @@ private function setupGroupObjects() false ); - $this->groupResourceModel = $this->getMock( - \Magento\Customer\Model\ResourceModel\Group::class, - [], - [], - '', - false - ); + $this->groupResourceModel = $this->createMock(\Magento\Customer\Model\ResourceModel\Group::class); } public function testSave() @@ -366,8 +336,8 @@ public function testGetList() { $groupId = 86; - $groupExtension = $this->getMock(\Magento\Customer\Api\Data\GroupExtensionInterface::class, [], [], '', false); - $collection = $this->getMock(\Magento\Customer\Model\ResourceModel\Group\Collection::class, [], [], '', false); + $groupExtension = $this->createMock(\Magento\Customer\Api\Data\GroupExtensionInterface::class); + $collection = $this->createMock(\Magento\Customer\Model\ResourceModel\Group\Collection::class); $searchCriteria = $this->getMockForAbstractClass( \Magento\Framework\Api\SearchCriteriaInterface::class, [], diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupTest.php index 21fa83be613ee..7855b1e6f823e 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupTest.php @@ -14,7 +14,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class GroupTest extends \PHPUnit_Framework_TestCase +class GroupTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Customer\Model\ResourceModel\Group */ protected $groupResourceModel; @@ -49,49 +49,26 @@ class GroupTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->resource = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); - $this->customerVat = $this->getMock(\Magento\Customer\Model\Vat::class, [], [], '', false); - $this->customersFactory = $this->getMock( - \Magento\Customer\Model\ResourceModel\Customer\CollectionFactory::class, - ['create'], - [], - '', - false - ); - $this->groupManagement = $this->getMock( - \Magento\Customer\Api\GroupManagementInterface::class, - ['getDefaultGroup', 'getNotLoggedInGroup', 'isReadOnly', 'getLoggedInGroups', 'getAllCustomersGroup'], - [], - '', - false); + $this->resource = $this->createMock(\Magento\Framework\App\ResourceConnection::class); + $this->customerVat = $this->createMock(\Magento\Customer\Model\Vat::class); + $this->customersFactory = $this->createPartialMock(\Magento\Customer\Model\ResourceModel\Customer\CollectionFactory::class, ['create']); + $this->groupManagement = $this->createPartialMock(\Magento\Customer\Api\GroupManagementInterface::class, ['getDefaultGroup', 'getNotLoggedInGroup', 'isReadOnly', 'getLoggedInGroups', 'getAllCustomersGroup']); - $this->groupModel = $this->getMock(\Magento\Customer\Model\Group::class, [], [], '', false); + $this->groupModel = $this->createMock(\Magento\Customer\Model\Group::class); - $contextMock = $this->getMock(\Magento\Framework\Model\ResourceModel\Db\Context::class, [], [], '', false); + $contextMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\Context::class); $contextMock->expects($this->once())->method('getResources')->willReturn($this->resource); - $this->relationProcessorMock = $this->getMock( - \Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor::class, - [], - [], - '', - false - ); + $this->relationProcessorMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor::class); - $this->snapshotMock = $this->getMock( - \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot::class, - [], - [], - '', - false - ); + $this->snapshotMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot::class); - $transactionManagerMock = $this->getMock( + $transactionManagerMock = $this->createMock( \Magento\Framework\Model\ResourceModel\Db\TransactionManagerInterface::class ); $transactionManagerMock->expects($this->any()) ->method('start') - ->willReturn($this->getMock(\Magento\Framework\DB\Adapter\AdapterInterface::class)); + ->willReturn($this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class)); $contextMock->expects($this->once()) ->method('getTransactionManager') ->willReturn($transactionManagerMock); @@ -163,38 +140,20 @@ public function testSaveWithReservedId() */ public function testDelete() { - $dbAdapter = $this->getMock(\Magento\Framework\DB\Adapter\AdapterInterface::class); + $dbAdapter = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class); $this->resource->expects($this->any())->method('getConnection')->will($this->returnValue($dbAdapter)); - $customer = $this->getMock( - \Magento\Customer\Model\Customer::class, - ['__wakeup', 'load', 'getId', 'getStoreId', 'setGroupId', 'save'], - [], - '', - false - ); + $customer = $this->createPartialMock(\Magento\Customer\Model\Customer::class, ['__wakeup', 'load', 'getId', 'getStoreId', 'setGroupId', 'save']); $customerId = 1; $customer->expects($this->once())->method('getId')->will($this->returnValue($customerId)); $customer->expects($this->once())->method('load')->with($customerId)->will($this->returnSelf()); - $defaultCustomerGroup = $this->getMock( - \Magento\Customer\Model\Group::class, - ['getId'], - [], - '', - false - ); + $defaultCustomerGroup = $this->createPartialMock(\Magento\Customer\Model\Group::class, ['getId']); $this->groupManagement->expects($this->once())->method('getDefaultGroup') ->will($this->returnValue($defaultCustomerGroup)); $defaultCustomerGroup->expects($this->once())->method('getId') ->will($this->returnValue(1)); $customer->expects($this->once())->method('setGroupId')->with(1); - $customerCollection = $this->getMock( - \Magento\Customer\Model\ResourceModel\Customer\Collection::class, - [], - [], - '', - false - ); + $customerCollection = $this->createMock(\Magento\Customer\Model\ResourceModel\Customer\Collection::class); $customerCollection->expects($this->once())->method('addAttributeToFilter')->will($this->returnSelf()); $customerCollection->expects($this->once())->method('load')->will($this->returnValue([$customer])); $this->customersFactory->expects($this->once())->method('create') diff --git a/app/code/Magento/Customer/Test/Unit/Model/SessionTest.php b/app/code/Magento/Customer/Test/Unit/Model/SessionTest.php index 05b8d1e54f578..7a6807562f906 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/SessionTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/SessionTest.php @@ -10,7 +10,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class SessionTest extends \PHPUnit_Framework_TestCase +class SessionTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -54,29 +54,20 @@ class SessionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_storageMock = $this->getMock( + $this->_storageMock = $this->createPartialMock( \Magento\Customer\Model\Session\Storage::class, - ['getIsCustomerEmulated', 'getData', 'unsIsCustomerEmulated', '__sleep', '__wakeup'], - [], - '', - false + ['getIsCustomerEmulated', 'getData', 'unsIsCustomerEmulated', '__sleep', '__wakeup'] ); - $this->_eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); - $this->_httpContextMock = $this->getMock(\Magento\Framework\App\Http\Context::class, [], [], '', false); - $this->urlFactoryMock = $this->getMock(\Magento\Framework\UrlFactory::class, [], [], '', false); + $this->_eventManagerMock = $this->createMock(\Magento\Framework\Event\ManagerInterface::class); + $this->_httpContextMock = $this->createMock(\Magento\Framework\App\Http\Context::class); + $this->urlFactoryMock = $this->createMock(\Magento\Framework\UrlFactory::class); $this->customerFactoryMock = $this->getMockBuilder(\Magento\Customer\Model\CustomerFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->customerRepositoryMock = $this->getMock( - \Magento\Customer\Api\CustomerRepositoryInterface::class, - [], - [], - '', - false - ); + $this->customerRepositoryMock = $this->createMock(\Magento\Customer\Api\CustomerRepositoryInterface::class); $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->responseMock = $this->getMock(\Magento\Framework\App\Response\Http::class, [], [], '', false); + $this->responseMock = $this->createMock(\Magento\Framework\App\Response\Http::class); $this->_model = $helper->getObject( \Magento\Customer\Model\Session::class, [ @@ -93,8 +84,8 @@ protected function setUp() public function testSetCustomerAsLoggedIn() { - $customer = $this->getMock(\Magento\Customer\Model\Customer::class, [], [], '', false); - $customerDto = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', false); + $customer = $this->createMock(\Magento\Customer\Model\Customer::class); + $customerDto = $this->createMock(\Magento\Customer\Api\Data\CustomerInterface::class); $customer->expects($this->any()) ->method('getDataModel') ->will($this->returnValue($customerDto)); @@ -113,8 +104,8 @@ public function testSetCustomerAsLoggedIn() public function testSetCustomerDataAsLoggedIn() { - $customer = $this->getMock(\Magento\Customer\Model\Customer::class, [], [], '', false); - $customerDto = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', false); + $customer = $this->createMock(\Magento\Customer\Model\Customer::class); + $customerDto = $this->createMock(\Magento\Customer\Api\Data\CustomerInterface::class); $this->customerFactoryMock->expects($this->once()) ->method('create') @@ -137,7 +128,7 @@ public function testSetCustomerDataAsLoggedIn() public function testAuthenticate() { - $urlMock = $this->getMock(\Magento\Framework\Url::class, [], [], '', false); + $urlMock = $this->createMock(\Magento\Framework\Url::class); $urlMock->expects($this->exactly(2)) ->method('getUrl') ->will($this->returnValue('')); @@ -176,12 +167,15 @@ public function testLoginById() */ protected function prepareLoginDataMock($customerId) { - $customerDataMock = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', false); + $customerDataMock = $this->createMock(\Magento\Customer\Api\Data\CustomerInterface::class); $customerDataMock->expects($this->once()) ->method('getId') ->will($this->returnValue($customerId)); - $customerMock = $this->getMock(\Magento\Customer\Model\Customer::class, [], [], '', false); + $customerMock = $this->createPartialMock( + \Magento\Customer\Model\Customer::class, + ['getId', 'isConfirmationRequired', 'getConfirmation', 'updateData', 'getGroupId'] + ); $customerMock->expects($this->once()) ->method('getId') ->will($this->returnValue($customerId)); @@ -239,15 +233,15 @@ public function getIsLoggedInDataProvider() { return [ ['expectedResult' => true, 'isCustomerIdValid' => true, 'isCustomerEmulated' => false], - ['expectedResult' => false, 'isCustomerIdValid' => true, 'isCustomerEmulated' => true,], - ['expectedResult' => false, 'isCustomerIdValid' => false, 'isCustomerEmulated' => false,], - ['expectedResult' => false, 'isCustomerIdValid' => false, 'isCustomerEmulated' => true,], + ['expectedResult' => false, 'isCustomerIdValid' => true, 'isCustomerEmulated' => true], + ['expectedResult' => false, 'isCustomerIdValid' => false, 'isCustomerEmulated' => false], + ['expectedResult' => false, 'isCustomerIdValid' => false, 'isCustomerEmulated' => true], ]; } public function testSetCustomerRemovesFlagThatShowsIfCustomerIsEmulated() { - $customerMock = $this->getMock(\Magento\Customer\Model\Customer::class, [], [], '', false); + $customerMock = $this->createMock(\Magento\Customer\Model\Customer::class); $this->_storageMock->expects($this->once())->method('unsIsCustomerEmulated'); $this->_model->setCustomer($customerMock); } diff --git a/app/code/Magento/Customer/Test/Unit/Model/VisitorTest.php b/app/code/Magento/Customer/Test/Unit/Model/VisitorTest.php index 4ea1913ce98ac..ca6b8708f695c 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/VisitorTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/VisitorTest.php @@ -12,7 +12,7 @@ * Class VisitorTest * @package Magento\Customer\Model */ -class VisitorTest extends \PHPUnit_Framework_TestCase +class VisitorTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Model\Visitor @@ -41,7 +41,7 @@ class VisitorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->registry = $this->getMock(\Magento\Framework\Registry::class); + $this->registry = $this->createMock(\Magento\Framework\Registry::class); $this->session = $this->getMockBuilder(\Magento\Customer\Model\Session::class) ->disableOriginalConstructor() ->setMethods(['getSessionId', 'getVisitorData', 'setVisitorData']) diff --git a/app/code/Magento/Customer/Test/Unit/Observer/AfterAddressSaveObserverTest.php b/app/code/Magento/Customer/Test/Unit/Observer/AfterAddressSaveObserverTest.php index 60453e96f6c08..939e2856f5eaa 100644 --- a/app/code/Magento/Customer/Test/Unit/Observer/AfterAddressSaveObserverTest.php +++ b/app/code/Magento/Customer/Test/Unit/Observer/AfterAddressSaveObserverTest.php @@ -8,8 +8,8 @@ use Magento\Customer\Api\GroupManagementInterface; use Magento\Customer\Helper\Address as HelperAddress; use Magento\Customer\Model\Address\AbstractAddress; -use Magento\Customer\Observer\AfterAddressSaveObserver; use Magento\Customer\Model\Vat; +use Magento\Customer\Observer\AfterAddressSaveObserver; use Magento\Customer\Observer\BeforeAddressSaveObserver; use Magento\Framework\App\Area; use Magento\Framework\App\Config\ScopeConfigInterface; @@ -22,7 +22,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class AfterAddressSaveObserverTest extends \PHPUnit_Framework_TestCase +class AfterAddressSaveObserverTest extends \PHPUnit\Framework\TestCase { /** * @var AfterAddressSaveObserver @@ -93,8 +93,14 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); + $this->group = $this->getMockBuilder(\Magento\Customer\Api\Data\GroupInterface::class) + ->setMethods(['getId']) + ->getMockForAbstractClass(); + $this->group->expects($this->any())->method('getId')->willReturn(1); $this->groupManagement = $this->getMockBuilder(\Magento\Customer\Api\GroupManagementInterface::class) + ->setMethods(['getDefaultGroup']) ->getMockForAbstractClass(); + $this->groupManagement->expects($this->any())->method('getDefaultGroup')->willReturn($this->group); $this->scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class) ->getMockForAbstractClass(); @@ -150,6 +156,7 @@ public function testAfterAddressSaveRestricted( $customer = $this->getMockBuilder(\Magento\Customer\Model\Customer::class) ->disableOriginalConstructor() + ->setMethods(['getDefaultBilling', 'getStore', 'getDefaultShipping', 'getGroupId']) ->getMock(); $customer->expects($this->any()) ->method('getStore') @@ -160,9 +167,24 @@ public function testAfterAddressSaveRestricted( $customer->expects($this->any()) ->method('getDefaultShipping') ->willReturn(null); + $customer->expects($this->any()) + ->method('getGroupID') + ->willReturn(1); $address = $this->getMockBuilder(\Magento\Customer\Model\Address::class) ->disableOriginalConstructor() + ->setMethods( + [ + 'getId', + 'getIsDefaultBilling', + 'getIsDefaultShipping', + 'setForceProcess', + 'getIsPrimaryBilling', + 'getIsPrimaryShipping', + 'getCustomer', + 'getForceProcess' + ] + ) ->getMock(); $address->expects($this->any()) ->method('getId') diff --git a/app/code/Magento/Customer/Test/Unit/Observer/BeforeAddressSaveObserverTest.php b/app/code/Magento/Customer/Test/Unit/Observer/BeforeAddressSaveObserverTest.php index c499029967bcd..22b207b9c1b67 100644 --- a/app/code/Magento/Customer/Test/Unit/Observer/BeforeAddressSaveObserverTest.php +++ b/app/code/Magento/Customer/Test/Unit/Observer/BeforeAddressSaveObserverTest.php @@ -12,7 +12,7 @@ use Magento\Framework\App\State as AppState; use Magento\Framework\Registry; -class BeforeAddressSaveObserverTest extends \PHPUnit_Framework_TestCase +class BeforeAddressSaveObserverTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Observer\BeforeAddressSaveObserver @@ -102,6 +102,7 @@ public function testBeforeAddressSaveWithoutCustomerAddressId( $address = $this->getMockBuilder(\Magento\Customer\Model\Address::class) ->disableOriginalConstructor() + ->setMethods(['getId', 'getIsDefaultBilling', 'getIsDefaultShipping', 'setForceProcess']) ->getMock(); $address->expects($this->once()) ->method('getId') diff --git a/app/code/Magento/Customer/Test/Unit/Observer/CustomerLoginSuccessObserverTest.php b/app/code/Magento/Customer/Test/Unit/Observer/CustomerLoginSuccessObserverTest.php index a10ae63508370..f8ce164010aa4 100644 --- a/app/code/Magento/Customer/Test/Unit/Observer/CustomerLoginSuccessObserverTest.php +++ b/app/code/Magento/Customer/Test/Unit/Observer/CustomerLoginSuccessObserverTest.php @@ -12,7 +12,7 @@ /** * Class CustomerLoginSuccessObserverTest */ -class CustomerLoginSuccessObserverTest extends \PHPUnit_Framework_TestCase +class CustomerLoginSuccessObserverTest extends \PHPUnit\Framework\TestCase { /** * Authentication @@ -36,21 +36,9 @@ class CustomerLoginSuccessObserverTest extends \PHPUnit_Framework_TestCase */ public function setUp() { - $this->authenticationMock = $this->getMock( - AuthenticationInterface::class, - [], - [], - '', - false - ); + $this->authenticationMock = $this->createMock(AuthenticationInterface::class); - $this->customerModelMock = $this->getMock( - \Magento\Customer\Model\Customer::class, - ['getId'], - [], - '', - false - ); + $this->customerModelMock = $this->createPartialMock(\Magento\Customer\Model\Customer::class, ['getId']); $this->customerLoginSuccessObserver = new CustomerLoginSuccessObserver( $this->authenticationMock ); @@ -62,8 +50,8 @@ public function setUp() public function testExecute() { $customerId = 1; - $observerMock = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false); - $eventMock = $this->getMock(\Magento\Framework\Event::class, ['getData'], [], '', false); + $observerMock = $this->createMock(\Magento\Framework\Event\Observer::class); + $eventMock = $this->createPartialMock(\Magento\Framework\Event::class, ['getData']); $observerMock->expects($this->once()) ->method('getEvent') ->willReturn($eventMock); diff --git a/app/code/Magento/Customer/Test/Unit/Observer/LogLastLoginAtObserverTest.php b/app/code/Magento/Customer/Test/Unit/Observer/LogLastLoginAtObserverTest.php index dce7b7775ed89..6cc77a39f15f0 100644 --- a/app/code/Magento/Customer/Test/Unit/Observer/LogLastLoginAtObserverTest.php +++ b/app/code/Magento/Customer/Test/Unit/Observer/LogLastLoginAtObserverTest.php @@ -13,7 +13,7 @@ /** * Class LogLastLoginAtObserverTest */ -class LogLastLoginAtObserverTest extends \PHPUnit_Framework_TestCase +class LogLastLoginAtObserverTest extends \PHPUnit\Framework\TestCase { /** * @var LogLastLoginAtObserver @@ -30,7 +30,7 @@ class LogLastLoginAtObserverTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->loggerMock = $this->getMock(\Magento\Customer\Model\Logger::class, [], [], '', false); + $this->loggerMock = $this->createMock(\Magento\Customer\Model\Logger::class); $this->logLastLoginAtObserver = new LogLastLoginAtObserver($this->loggerMock); } @@ -41,9 +41,9 @@ public function testLogLastLoginAt() { $id = 1; - $observerMock = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false); - $eventMock = $this->getMock(\Magento\Framework\Event::class, ['getCustomer'], [], '', false); - $customerMock = $this->getMock(\Magento\Customer\Model\Customer::class, [], [], '', false); + $observerMock = $this->createMock(\Magento\Framework\Event\Observer::class); + $eventMock = $this->createPartialMock(\Magento\Framework\Event::class, ['getCustomer']); + $customerMock = $this->createMock(\Magento\Customer\Model\Customer::class); $observerMock->expects($this->once()) ->method('getEvent') diff --git a/app/code/Magento/Customer/Test/Unit/Observer/LogLastLogoutAtObserverTest.php b/app/code/Magento/Customer/Test/Unit/Observer/LogLastLogoutAtObserverTest.php index c516eea0ea306..378266190dffc 100644 --- a/app/code/Magento/Customer/Test/Unit/Observer/LogLastLogoutAtObserverTest.php +++ b/app/code/Magento/Customer/Test/Unit/Observer/LogLastLogoutAtObserverTest.php @@ -13,7 +13,7 @@ /** * Class LogLastLogoutAtObserverTest */ -class LogLastLogoutAtObserverTest extends \PHPUnit_Framework_TestCase +class LogLastLogoutAtObserverTest extends \PHPUnit\Framework\TestCase { /** * @var LogLastLogoutAtObserver @@ -30,7 +30,7 @@ class LogLastLogoutAtObserverTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->loggerMock = $this->getMock(\Magento\Customer\Model\Logger::class, [], [], '', false); + $this->loggerMock = $this->createMock(\Magento\Customer\Model\Logger::class); $this->logLastLogoutAtObserver = new LogLastLogoutAtObserver($this->loggerMock); } @@ -41,9 +41,9 @@ public function testLogLastLogoutAt() { $id = 1; - $observerMock = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false); - $eventMock = $this->getMock(\Magento\Framework\Event::class, ['getCustomer'], [], '', false); - $customerMock = $this->getMock(\Magento\Customer\Model\Customer::class, [], [], '', false); + $observerMock = $this->createMock(\Magento\Framework\Event\Observer::class); + $eventMock = $this->createPartialMock(\Magento\Framework\Event::class, ['getCustomer']); + $customerMock = $this->createMock(\Magento\Customer\Model\Customer::class); $observerMock->expects($this->once()) ->method('getEvent') diff --git a/app/code/Magento/Customer/Test/Unit/Observer/UpgradeCustomerPasswordObserverTest.php b/app/code/Magento/Customer/Test/Unit/Observer/UpgradeCustomerPasswordObserverTest.php index c5c7f56c9346e..8971f155f782e 100644 --- a/app/code/Magento/Customer/Test/Unit/Observer/UpgradeCustomerPasswordObserverTest.php +++ b/app/code/Magento/Customer/Test/Unit/Observer/UpgradeCustomerPasswordObserverTest.php @@ -7,7 +7,7 @@ use Magento\Customer\Observer\UpgradeCustomerPasswordObserver; -class UpgradeCustomerPasswordObserverTest extends \PHPUnit_Framework_TestCase +class UpgradeCustomerPasswordObserverTest extends \PHPUnit\Framework\TestCase { /** * @var UpgradeCustomerPasswordObserver diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/ColumnFactoryTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/ColumnFactoryTest.php index 7d7980ef340af..131b1ee94cc14 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/ColumnFactoryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/ColumnFactoryTest.php @@ -7,7 +7,7 @@ use Magento\Customer\Ui\Component\ColumnFactory; -class ColumnFactoryTest extends \PHPUnit_Framework_TestCase +class ColumnFactoryTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Customer\Api\Data\OptionInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $attributeOption; @@ -38,12 +38,9 @@ protected function setUp() '', false ); - $this->componentFactory = $this->getMock( + $this->componentFactory = $this->createPartialMock( \Magento\Framework\View\Element\UiComponentFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->attributeMetadata = $this->getMockForAbstractClass( \Magento\Customer\Api\Data\AttributeMetadataInterface::class, diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/DataProvider/DocumentTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/DataProvider/DocumentTest.php index a3bb606f73351..e9c91d8305e90 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/DataProvider/DocumentTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/DataProvider/DocumentTest.php @@ -22,7 +22,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class DocumentTest extends \PHPUnit_Framework_TestCase +class DocumentTest extends \PHPUnit\Framework\TestCase { /** * @var GroupRepositoryInterface|MockObject diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/DataProviderTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/DataProviderTest.php index afa5f4960ca02..ee155c251c79a 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/DataProviderTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/DataProviderTest.php @@ -15,7 +15,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class DataProviderTest extends \PHPUnit_Framework_TestCase +class DataProviderTest extends \PHPUnit\Framework\TestCase { const TEST_REQUEST_NAME = 'test_request_name'; diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/FilterFactoryTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/FilterFactoryTest.php index 19bbe8c049429..7fbf9d2a2a10a 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/FilterFactoryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/FilterFactoryTest.php @@ -7,7 +7,7 @@ use Magento\Customer\Ui\Component\FilterFactory; -class FilterFactoryTest extends \PHPUnit_Framework_TestCase +class FilterFactoryTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Customer\Api\Data\OptionInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $attributeOption; @@ -35,12 +35,9 @@ protected function setUp() '', false ); - $this->componentFactory = $this->getMock( + $this->componentFactory = $this->createPartialMock( \Magento\Framework\View\Element\UiComponentFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->attributeMetadata = $this->getMockForAbstractClass( \Magento\Customer\Api\Data\AttributeMetadataInterface::class, diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/AttributeRepositoryTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/AttributeRepositoryTest.php index 6221f370ca380..0662235c0d5ac 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/AttributeRepositoryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/AttributeRepositoryTest.php @@ -7,7 +7,7 @@ use Magento\Customer\Ui\Component\Listing\AttributeRepository; -class AttributeRepositoryTest extends \PHPUnit_Framework_TestCase +class AttributeRepositoryTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Customer\Api\CustomerMetadataManagementInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $customerMetadataManagement; @@ -65,15 +65,9 @@ protected function setUp() '', false ); - $this->option = $this->getMock(\Magento\Customer\Api\Data\OptionInterface::class, [], [], '', false); + $this->option = $this->createMock(\Magento\Customer\Api\Data\OptionInterface::class); - $this->attributeFilter = $this->getMock( - \Magento\Customer\Model\Indexer\Attribute\Filter::class, - [], - [], - '', - false - ); + $this->attributeFilter = $this->createMock(\Magento\Customer\Model\Indexer\Attribute\Filter::class); $this->component = new AttributeRepository( $this->customerMetadataManagement, diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/AccountLockTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/AccountLockTest.php index 8051e6cbf9982..c5c94adbd4589 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/AccountLockTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/AccountLockTest.php @@ -7,7 +7,7 @@ use Magento\Customer\Ui\Component\Listing\Column\AccountLock; -class AccountLockTest extends \PHPUnit_Framework_TestCase +class AccountLockTest extends \PHPUnit\Framework\TestCase { /** @var AccountLock */ protected $component; @@ -26,13 +26,7 @@ public function setup() ->disableOriginalConstructor() ->getMock(); $this->context->expects($this->never())->method('getProcessor')->willReturn($processor); - $this->uiComponentFactory = $this->getMock( - \Magento\Framework\View\Element\UiComponentFactory::class, - [], - [], - '', - false - ); + $this->uiComponentFactory = $this->createMock(\Magento\Framework\View\Element\UiComponentFactory::class); $this->component = new AccountLock( $this->context, $this->uiComponentFactory diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php index bac907093edbe..056c7e71e1827 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php @@ -7,7 +7,7 @@ use Magento\Customer\Ui\Component\Listing\Column\Actions; -class ActionsTest extends \PHPUnit_Framework_TestCase +class ActionsTest extends \PHPUnit\Framework\TestCase { /** @var Actions */ protected $component; @@ -29,13 +29,7 @@ public function setup() ->disableOriginalConstructor() ->getMock(); $this->context->expects($this->never())->method('getProcessor')->willReturn($processor); - $this->uiComponentFactory = $this->getMock( - \Magento\Framework\View\Element\UiComponentFactory::class, - [], - [], - '', - false - ); + $this->uiComponentFactory = $this->createMock(\Magento\Framework\View\Element\UiComponentFactory::class); $this->urlBuilder = $this->getMockForAbstractClass( \Magento\Framework\UrlInterface::class, [], diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/AttributeColumnTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/AttributeColumnTest.php index 826a07c01b47f..9f18c1b0de8af 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/AttributeColumnTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/AttributeColumnTest.php @@ -5,10 +5,9 @@ */ namespace Magento\Customer\Test\Unit\Ui\Component\Listing\Column; -use Magento\Customer\Api\CustomerMetadataInterface; use Magento\Customer\Ui\Component\Listing\Column\AttributeColumn; -class AttributeColumnTest extends \PHPUnit_Framework_TestCase +class AttributeColumnTest extends \PHPUnit\Framework\TestCase { /** @var AttributeColumn */ protected $component; @@ -33,19 +32,9 @@ public function setup() ->disableOriginalConstructor() ->getMock(); $this->context->expects($this->never())->method('getProcessor')->willReturn($processor); - $this->uiComponentFactory = $this->getMock( - \Magento\Framework\View\Element\UiComponentFactory::class, - [], - [], - '', - false - ); - $this->attributeRepository = $this->getMock( - \Magento\Customer\Ui\Component\Listing\AttributeRepository::class, - [], - [], - '', - false + $this->uiComponentFactory = $this->createMock(\Magento\Framework\View\Element\UiComponentFactory::class); + $this->attributeRepository = $this->createMock( + \Magento\Customer\Ui\Component\Listing\AttributeRepository::class ); $this->attributeMetadata = $this->getMockForAbstractClass( \Magento\Customer\Api\Data\AttributeMetadataInterface::class, diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ConfirmationTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ConfirmationTest.php index 6a45b1eee9a9c..e55cee49b5c94 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ConfirmationTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ConfirmationTest.php @@ -13,7 +13,7 @@ use Magento\Framework\View\Element\UiComponentFactory; use Magento\Store\Model\ScopeInterface; -class ConfirmationTest extends \PHPUnit_Framework_TestCase +class ConfirmationTest extends \PHPUnit\Framework\TestCase { /** * @var Confirmation diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/InlineEditUpdaterTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/InlineEditUpdaterTest.php index a6c6ad6f0eb21..a84fa566c0e2b 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/InlineEditUpdaterTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/InlineEditUpdaterTest.php @@ -9,7 +9,7 @@ use Magento\Customer\Ui\Component\Listing\Column\InlineEditUpdater; use Magento\Customer\Api\Data\ValidationRuleInterface; -class InlineEditUpdaterTest extends \PHPUnit_Framework_TestCase +class InlineEditUpdaterTest extends \PHPUnit\Framework\TestCase { /** @var ValidationRules|\PHPUnit_Framework_MockObject_MockObject */ protected $validationRules; diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ValidationRulesTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ValidationRulesTest.php index 25c5606a9fd33..130b3acd11e76 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ValidationRulesTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ValidationRulesTest.php @@ -8,7 +8,7 @@ use Magento\Customer\Ui\Component\Listing\Column\ValidationRules; use Magento\Customer\Api\Data\ValidationRuleInterface; -class ValidationRulesTest extends \PHPUnit_Framework_TestCase +class ValidationRulesTest extends \PHPUnit\Framework\TestCase { /** @var ValidationRules */ protected $validationRules; diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/ColumnsTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/ColumnsTest.php index 1adba1e1e0ccf..2a1dab65cd179 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/ColumnsTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/ColumnsTest.php @@ -7,7 +7,7 @@ use Magento\Customer\Ui\Component\Listing\Columns; -class ColumnsTest extends \PHPUnit_Framework_TestCase +class ColumnsTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Framework\View\Element\UiComponent\ContextInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $context; @@ -38,27 +38,14 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); $this->context->expects($this->atLeastOnce())->method('getProcessor')->willReturn($processor); - $this->columnFactory = $this->getMock( + $this->columnFactory = $this->createPartialMock( \Magento\Customer\Ui\Component\ColumnFactory::class, - ['create'], - [], - '', - false - ); - $this->attributeRepository = $this->getMock( - \Magento\Customer\Ui\Component\Listing\AttributeRepository::class, - [], - [], - '', - false + ['create'] ); - $this->attribute = $this->getMock( - \Magento\Customer\Model\Attribute::class, - [], - [], - '', - false + $this->attributeRepository = $this->createMock( + \Magento\Customer\Ui\Component\Listing\AttributeRepository::class ); + $this->attribute = $this->createMock(\Magento\Customer\Model\Attribute::class); $this->column = $this->getMockForAbstractClass( \Magento\Ui\Component\Listing\Columns\ColumnInterface::class, [], diff --git a/app/code/Magento/Customer/Ui/Component/ColumnFactory.php b/app/code/Magento/Customer/Ui/Component/ColumnFactory.php index 67e29819d3519..60bf3ea26b78c 100644 --- a/app/code/Magento/Customer/Ui/Component/ColumnFactory.php +++ b/app/code/Magento/Customer/Ui/Component/ColumnFactory.php @@ -11,20 +11,28 @@ class ColumnFactory { - /** @var \Magento\Framework\View\Element\UiComponentFactory */ + /** + * @var \Magento\Framework\View\Element\UiComponentFactory + */ protected $componentFactory; - /** @var InlineEditUpdater */ + /** + * @var \Magento\Customer\Ui\Component\Listing\Column\InlineEditUpdater + */ protected $inlineEditUpdater; - /** @var array */ + /** + * @var array + */ protected $jsComponentMap = [ 'text' => 'Magento_Ui/js/grid/columns/column', 'select' => 'Magento_Ui/js/grid/columns/select', 'date' => 'Magento_Ui/js/grid/columns/date', ]; - /** @var array */ + /** + * @var array + */ protected $dataTypeMap = [ 'default' => 'text', 'text' => 'text', diff --git a/app/code/Magento/Customer/Ui/Component/Listing/AttributeRepository.php b/app/code/Magento/Customer/Ui/Component/Listing/AttributeRepository.php index 2de8b922052e0..d0af1ec21467f 100644 --- a/app/code/Magento/Customer/Ui/Component/Listing/AttributeRepository.php +++ b/app/code/Magento/Customer/Ui/Component/Listing/AttributeRepository.php @@ -17,22 +17,34 @@ class AttributeRepository { const BILLING_ADDRESS_PREFIX = 'billing_'; - /** @var [] */ + /** + * @var array + */ protected $attributes; - /** @var CustomerMetadataInterface */ + /** + * @var \Magento\Customer\Api\CustomerMetadataInterface + */ protected $customerMetadata; - /** @var AddressMetadataInterface */ + /** + * @var \Magento\Customer\Api\AddressMetadataInterface + */ protected $addressMetadata; - /** @var CustomerMetadataManagementInterface */ + /** + * @var \Magento\Customer\Api\CustomerMetadataManagementInterface + */ protected $customerMetadataManagement; - /** @var AddressMetadataManagementInterface */ + /** + * @var \Magento\Customer\Api\AddressMetadataManagementInterface + */ protected $addressMetadataManagement; - /** @var Filter */ + /** + * @var \Magento\Customer\Model\Indexer\Attribute\Filter + */ protected $attributeFilter; /** diff --git a/app/code/Magento/Customer/Ui/Component/Listing/Column/Actions.php b/app/code/Magento/Customer/Ui/Component/Listing/Column/Actions.php index b7cf8e8c95899..d6a4067ef3db6 100644 --- a/app/code/Magento/Customer/Ui/Component/Listing/Column/Actions.php +++ b/app/code/Magento/Customer/Ui/Component/Listing/Column/Actions.php @@ -14,6 +14,7 @@ * Class ProductActions * * @api + * @since 100.0.2 */ class Actions extends Column { diff --git a/app/code/Magento/Customer/Ui/Component/Listing/Column/AttributeColumn.php b/app/code/Magento/Customer/Ui/Component/Listing/Column/AttributeColumn.php index bf20fe6d7a746..87a27d32765a2 100644 --- a/app/code/Magento/Customer/Ui/Component/Listing/Column/AttributeColumn.php +++ b/app/code/Magento/Customer/Ui/Component/Listing/Column/AttributeColumn.php @@ -13,7 +13,9 @@ class AttributeColumn extends Column { - /** @var AttributeRepository */ + /** + * @var \Magento\Customer\Ui\Component\Listing\AttributeRepository + */ protected $attributeRepository; /** diff --git a/app/code/Magento/Customer/Ui/Component/Listing/Column/InlineEditUpdater.php b/app/code/Magento/Customer/Ui/Component/Listing/Column/InlineEditUpdater.php index c8aca1f28e30d..18712b1d4f492 100644 --- a/app/code/Magento/Customer/Ui/Component/Listing/Column/InlineEditUpdater.php +++ b/app/code/Magento/Customer/Ui/Component/Listing/Column/InlineEditUpdater.php @@ -9,7 +9,9 @@ class InlineEditUpdater { - /** @var ValidationRules */ + /** + * @var \Magento\Customer\Ui\Component\Listing\Column\ValidationRules + */ protected $validationRules; /** diff --git a/app/code/Magento/Customer/Ui/Component/Listing/Columns.php b/app/code/Magento/Customer/Ui/Component/Listing/Columns.php index 18e68d1eff093..70f8d085cc5ea 100644 --- a/app/code/Magento/Customer/Ui/Component/Listing/Columns.php +++ b/app/code/Magento/Customer/Ui/Component/Listing/Columns.php @@ -14,13 +14,19 @@ class Columns extends \Magento\Ui\Component\Listing\Columns { - /** @var int */ + /** + * @var int + */ protected $columnSortOrder; - /** @var AttributeRepository */ + /** + * @var \Magento\Customer\Ui\Component\Listing\AttributeRepository + */ protected $attributeRepository; - /** @var InlineEditUpdater */ + /** + * @var \Magento\Customer\Ui\Component\Listing\Column\InlineEditUpdater + */ protected $inlineEditUpdater; /** diff --git a/app/code/Magento/Customer/etc/di.xml b/app/code/Magento/Customer/etc/di.xml index 0fd17a3424cf9..6eea4e1582a97 100644 --- a/app/code/Magento/Customer/etc/di.xml +++ b/app/code/Magento/Customer/etc/di.xml @@ -59,6 +59,8 @@ type="Magento\Customer\Model\Customer\Attribute\Source\Group"/> + Magento\Customer\Model\Config\Share\Proxy diff --git a/app/code/Magento/Customer/view/adminhtml/ui_component/customer_listing.xml b/app/code/Magento/Customer/view/adminhtml/ui_component/customer_listing.xml index a1363fe0e6089..f8aa078f45e4d 100644 --- a/app/code/Magento/Customer/view/adminhtml/ui_component/customer_listing.xml +++ b/app/code/Magento/Customer/view/adminhtml/ui_component/customer_listing.xml @@ -28,6 +28,7 @@ + Magento_Customer::manage id diff --git a/app/code/Magento/Customer/view/adminhtml/ui_component/customer_online_grid.xml b/app/code/Magento/Customer/view/adminhtml/ui_component/customer_online_grid.xml index 8182a213ee6e7..c818f9c1271ab 100644 --- a/app/code/Magento/Customer/view/adminhtml/ui_component/customer_online_grid.xml +++ b/app/code/Magento/Customer/view/adminhtml/ui_component/customer_online_grid.xml @@ -24,6 +24,7 @@ + Magento_Customer::online id diff --git a/app/code/Magento/Customer/view/adminhtml/web/edit/tab/js/addresses.js b/app/code/Magento/Customer/view/adminhtml/web/edit/tab/js/addresses.js index 4cc7fc28b556c..c34be6b5a645f 100644 --- a/app/code/Magento/Customer/view/adminhtml/web/edit/tab/js/addresses.js +++ b/app/code/Magento/Customer/view/adminhtml/web/edit/tab/js/addresses.js @@ -3,6 +3,9 @@ * See COPYING.txt for license details. */ +/** + * @deprecated since version 2.2.0 + */ define([ 'jquery', 'mage/template', diff --git a/app/code/Magento/Customer/view/frontend/templates/form/register.phtml b/app/code/Magento/Customer/view/frontend/templates/form/register.phtml index 70ffef4ce86a6..43e4e92fd0904 100644 --- a/app/code/Magento/Customer/view/frontend/templates/form/register.phtml +++ b/app/code/Magento/Customer/view/frontend/templates/form/register.phtml @@ -12,6 +12,7 @@ getChildHtml('customer.form.register.extra') ?> + getBlockHtml('formkey'); ?>
escapeHtml(__('Personal Information')) ?>
@@ -229,4 +230,4 @@ require([ } } } - \ No newline at end of file + diff --git a/app/code/Magento/Customer/view/frontend/web/change-email-password.js b/app/code/Magento/Customer/view/frontend/web/change-email-password.js index fb219cf3ae710..cf3ea48844b91 100644 --- a/app/code/Magento/Customer/view/frontend/web/change-email-password.js +++ b/app/code/Magento/Customer/view/frontend/web/change-email-password.js @@ -2,7 +2,6 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ -/*jshint browser:true jquery:true expr:true*/ define([ 'jquery', 'jquery/ui' diff --git a/app/code/Magento/Customer/view/frontend/web/js/addressValidation.js b/app/code/Magento/Customer/view/frontend/web/js/addressValidation.js index 7caac63972617..be2960701deed 100644 --- a/app/code/Magento/Customer/view/frontend/web/js/addressValidation.js +++ b/app/code/Magento/Customer/view/frontend/web/js/addressValidation.js @@ -2,7 +2,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ -/*jshint browser:true jquery:true*/ + define([ 'jquery', 'jquery/ui', diff --git a/app/code/Magento/Customer/view/frontend/web/js/password-strength-indicator.js b/app/code/Magento/Customer/view/frontend/web/js/password-strength-indicator.js index 35a7d06cc64a0..71ca63f6750bb 100644 --- a/app/code/Magento/Customer/view/frontend/web/js/password-strength-indicator.js +++ b/app/code/Magento/Customer/view/frontend/web/js/password-strength-indicator.js @@ -3,9 +3,6 @@ * See COPYING.txt for license details. */ -/** - * jshint browser:true - */ define([ 'jquery', 'Magento_Customer/js/zxcvbn', diff --git a/app/code/Magento/CustomerAnalytics/LICENSE.txt b/app/code/Magento/CustomerAnalytics/LICENSE.txt deleted file mode 100644 index 49525fd99da9c..0000000000000 --- a/app/code/Magento/CustomerAnalytics/LICENSE.txt +++ /dev/null @@ -1,48 +0,0 @@ - -Open Software License ("OSL") v. 3.0 - -This Open Software License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: - -Licensed under the Open Software License version 3.0 - - 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: - - 1. to reproduce the Original Work in copies, either alone or as part of a collective work; - - 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; - - 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Open Software License; - - 4. to perform the Original Work publicly; and - - 5. to display the Original Work publicly. - - 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. - - 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. - - 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. - - 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). - - 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. - - 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. - - 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. - - 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including 'fair use' or 'fair dealing'). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). - - 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. - - 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. - - 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. - - 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. - - 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. - - 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. - - 16. Modification of This License. This License is Copyright (C) 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. \ No newline at end of file diff --git a/app/code/Magento/CustomerAnalytics/LICENSE_AFL.txt b/app/code/Magento/CustomerAnalytics/LICENSE_AFL.txt deleted file mode 100644 index f39d641b18a19..0000000000000 --- a/app/code/Magento/CustomerAnalytics/LICENSE_AFL.txt +++ /dev/null @@ -1,48 +0,0 @@ - -Academic Free License ("AFL") v. 3.0 - -This Academic Free License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: - -Licensed under the Academic Free License version 3.0 - - 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: - - 1. to reproduce the Original Work in copies, either alone or as part of a collective work; - - 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; - - 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, under any license of your choice that does not contradict the terms and conditions, including Licensor's reserved rights and remedies, in this Academic Free License; - - 4. to perform the Original Work publicly; and - - 5. to display the Original Work publicly. - - 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. - - 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. - - 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. - - 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). - - 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. - - 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. - - 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. - - 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including "fair use" or "fair dealing"). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). - - 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. - - 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. - - 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. - - 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. - - 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. - - 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. - - 16. Modification of This License. This License is Copyright © 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Academic Free License" or "AFL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. diff --git a/app/code/Magento/CustomerAnalytics/README.md b/app/code/Magento/CustomerAnalytics/README.md deleted file mode 100644 index 8c64ce97629da..0000000000000 --- a/app/code/Magento/CustomerAnalytics/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Magento_CustomerAnalytics module - -The Magento_CustomerAnalytics module configures data definitions for a data collection related to the Customer module entities to be used in [Advanced Reporting](http://devdocs.magento.com/guides/v2.2/advanced-reporting/modules.html). diff --git a/app/code/Magento/CustomerAnalytics/composer.json b/app/code/Magento/CustomerAnalytics/composer.json deleted file mode 100644 index 36e7492decc50..0000000000000 --- a/app/code/Magento/CustomerAnalytics/composer.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "magento/module-customer-analytics", - "description": "N/A", - "require": { - "php": "7.0.2|7.0.4|~7.0.6|~7.1.0", - "magento/framework": "100.2.*", - "magento/module-customer": "100.2.*" - }, - "type": "magento2-module", - "version": "100.2.0-dev", - "license": [ - "OSL-3.0", - "AFL-3.0" - ], - "autoload": { - "files": [ - "registration.php" - ], - "psr-4": { - "Magento\\CustomerAnalytics\\": "" - } - } -} diff --git a/app/code/Magento/CustomerAnalytics/etc/analytics.xml b/app/code/Magento/CustomerAnalytics/etc/analytics.xml deleted file mode 100644 index 5e47040c2f3bd..0000000000000 --- a/app/code/Magento/CustomerAnalytics/etc/analytics.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - customers - - - - - diff --git a/app/code/Magento/CustomerAnalytics/etc/module.xml b/app/code/Magento/CustomerAnalytics/etc/module.xml deleted file mode 100644 index adc4f8dd849c2..0000000000000 --- a/app/code/Magento/CustomerAnalytics/etc/module.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - diff --git a/app/code/Magento/CustomerAnalytics/etc/reports.xml b/app/code/Magento/CustomerAnalytics/etc/reports.xml deleted file mode 100644 index b3300b0127709..0000000000000 --- a/app/code/Magento/CustomerAnalytics/etc/reports.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - diff --git a/app/code/Magento/CustomerAnalytics/registration.php b/app/code/Magento/CustomerAnalytics/registration.php deleted file mode 100644 index e4c3348182877..0000000000000 --- a/app/code/Magento/CustomerAnalytics/registration.php +++ /dev/null @@ -1,11 +0,0 @@ -create(); - $this->_initWebsites(true); + $this->_initAttributeValues()->_initAttributeTypes()->_initWebsites(true); $this->setFileName($this->getEntityTypeCode()); } @@ -246,6 +260,7 @@ public function exportItem($item) $row[self::COLUMN_ADDRESS_ID] = $item['entity_id']; $row[self::COLUMN_EMAIL] = $customer['email']; $row[self::COLUMN_WEBSITE] = $this->_websiteIdToCode[$customer['website_id']]; + $row[self::COLUMN_REGION_ID] = $item->getRegionId(); $this->getWriter()->writeRow($row); } diff --git a/app/code/Magento/CustomerImportExport/Model/Export/Customer.php b/app/code/Magento/CustomerImportExport/Model/Export/Customer.php index a6c017d99ac20..14f0ae324e0a4 100644 --- a/app/code/Magento/CustomerImportExport/Model/Export/Customer.php +++ b/app/code/Magento/CustomerImportExport/Model/Export/Customer.php @@ -11,6 +11,7 @@ * @api * * @method \Magento\Customer\Model\ResourceModel\Attribute\Collection getAttributeCollection() getAttributeCollection() + * @since 100.0.2 */ class Customer extends \Magento\ImportExport\Model\Export\Entity\AbstractEav { @@ -42,11 +43,7 @@ class Customer extends \Magento\ImportExport\Model\Export\Entity\AbstractEav /**#@-*/ - /** - * Overridden attributes parameters. - * - * @var array - */ + /**#@-*/ protected $_attributeOverrides = [ 'created_at' => ['backend_type' => 'datetime'], 'reward_update_notification' => ['source_model' => \Magento\Eav\Model\Entity\Attribute\Source\Boolean::class], @@ -115,7 +112,7 @@ public function __construct( $data['customer_collection'] ) ? $data['customer_collection'] : $customerColFactory->create(); - $this->_initAttributeValues()->_initStores()->_initWebsites(true); + $this->_initAttributeValues()->_initAttributeTypes()->_initStores()->_initWebsites(true); } /** diff --git a/app/code/Magento/CustomerImportExport/Model/Import/AbstractCustomer.php b/app/code/Magento/CustomerImportExport/Model/Import/AbstractCustomer.php index 0563a99e9c983..38854b1836869 100644 --- a/app/code/Magento/CustomerImportExport/Model/Import/AbstractCustomer.php +++ b/app/code/Magento/CustomerImportExport/Model/Import/AbstractCustomer.php @@ -5,6 +5,7 @@ */ namespace Magento\CustomerImportExport\Model\Import; +use Magento\ImportExport\Model\Import; use Magento\CustomerImportExport\Model\ResourceModel\Import\Customer\Storage; use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface; @@ -14,6 +15,7 @@ * @api * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ abstract class AbstractCustomer extends \Magento\ImportExport\Model\Import\Entity\AbstractEav { @@ -50,13 +52,7 @@ abstract class AbstractCustomer extends \Magento\ImportExport\Model\Import\Entit /**#@-*/ - /** - * Array of attribute codes which will be ignored in validation and import procedures. - * For example, when entity attribute has own validation and import procedures - * or just to deny this attribute processing. - * - * @var string[] - */ + /**#@-*/ protected $_ignoredAttributes = ['website_id', 'store_id', self::COLUMN_DEFAULT_BILLING, self::COLUMN_DEFAULT_SHIPPING]; @@ -235,7 +231,7 @@ protected function _checkUniqueKey(array $rowData, $rowNumber) $email = strtolower($rowData[static::COLUMN_EMAIL]); $website = $rowData[static::COLUMN_WEBSITE]; - if (!\Zend_Validate::is($email, 'EmailAddress')) { + if (!\Zend_Validate::is($email, \Magento\Framework\Validator\EmailAddress::class)) { $this->addRowError(static::ERROR_INVALID_EMAIL, $rowNumber, static::COLUMN_EMAIL); } elseif (!isset($this->_websiteCodeToId[$website])) { $this->addRowError(static::ERROR_INVALID_WEBSITE, $rowNumber, static::COLUMN_WEBSITE); @@ -253,4 +249,30 @@ public function getCustomerStorage() { return $this->_customerStorage; } + + /** + * Returns id of option by value for select and multiselect attributes + * + * @param array $attributeParameters Parameters of an attribute + * @param int|string $value A value of an attribute + * @return int An option id of attribute + */ + protected function getSelectAttrIdByValue(array $attributeParameters, $value) + { + return isset($attributeParameters['options'][strtolower($value)]) + ? $attributeParameters['options'][strtolower($value)] + : 0; + } + + /** + * Returns multiple value separator + * + * @return string + */ + protected function getMultipleValueSeparator() + { + return isset($this->_parameters[Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR]) + ? $this->_parameters[Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR] + : Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR; + } } diff --git a/app/code/Magento/CustomerImportExport/Model/Import/Address.php b/app/code/Magento/CustomerImportExport/Model/Import/Address.php index 949166ccfbc6a..7d44ef079d152 100644 --- a/app/code/Magento/CustomerImportExport/Model/Import/Address.php +++ b/app/code/Magento/CustomerImportExport/Model/Import/Address.php @@ -5,7 +5,6 @@ */ namespace Magento\CustomerImportExport\Model\Import; -use Magento\ImportExport\Model\Import; use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface; /** @@ -68,11 +67,7 @@ class Address extends AbstractCustomer /**#@-*/ - /** - * Default addresses column names to appropriate customer attribute code - * - * @var array - */ + /**#@-*/ protected static $_defaultAddressAttributeMapping = [ self::COLUMN_DEFAULT_BILLING => 'default_billing', self::COLUMN_DEFAULT_SHIPPING => 'default_shipping', @@ -490,6 +485,7 @@ protected function _mergeEntityAttributes(array $newAttributes, array $attribute */ protected function _prepareDataForUpdate(array $rowData) { + $multiSeparator = $this->getMultipleValueSeparator(); $email = strtolower($rowData[self::COLUMN_EMAIL]); $customerId = $this->_getCustomerId($email, $rowData[self::COLUMN_WEBSITE]); // entity table data @@ -527,20 +523,17 @@ protected function _prepareDataForUpdate(array $rowData) continue; } } elseif ($newAddress && !strlen($rowData[$attributeAlias])) { - } elseif ('select' == $attributeParams['type']) { - $value = $attributeParams['options'][strtolower($rowData[$attributeAlias])]; + } elseif (in_array($attributeParams['type'], ['select', 'boolean'])) { + $value = $this->getSelectAttrIdByValue($attributeParams, mb_strtolower($rowData[$attributeAlias])); } elseif ('datetime' == $attributeParams['type']) { $value = (new \DateTime())->setTimestamp(strtotime($rowData[$attributeAlias])); $value = $value->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT); } elseif ('multiselect' == $attributeParams['type']) { - $separator = isset($this->_parameters[Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR]) ? - $this->_parameters[Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR] : - Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR; - $value = str_replace( - $separator, - Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, - $rowData[$attributeAlias] - ); + $ids = []; + foreach (explode($multiSeparator, mb_strtolower($rowData[$attributeAlias])) as $subValue) { + $ids[] = $this->getSelectAttrIdByValue($attributeParams, $subValue); + } + $value = implode(',', $ids); } else { $value = $rowData[$attributeAlias]; } @@ -726,6 +719,7 @@ protected function _isOptionalAddressEmpty(array $rowData) */ protected function _validateRowForUpdate(array $rowData, $rowNumber) { + $multiSeparator = $this->getMultipleValueSeparator(); if ($this->_checkUniqueKey($rowData, $rowNumber)) { $email = strtolower($rowData[self::COLUMN_EMAIL]); $website = $rowData[self::COLUMN_WEBSITE]; @@ -744,9 +738,6 @@ protected function _validateRowForUpdate(array $rowData, $rowNumber) continue; } if (isset($rowData[$attributeCode]) && strlen($rowData[$attributeCode])) { - $multiSeparator = isset($this->_parameters[Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR]) ? - $this->_parameters[Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR] : - Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR; $this->isAttributeValid( $attributeCode, $attributeParams, diff --git a/app/code/Magento/CustomerImportExport/Model/Import/Customer.php b/app/code/Magento/CustomerImportExport/Model/Import/Customer.php index 99cb1fcfbfcd6..bee4479526037 100644 --- a/app/code/Magento/CustomerImportExport/Model/Import/Customer.php +++ b/app/code/Magento/CustomerImportExport/Model/Import/Customer.php @@ -6,6 +6,7 @@ namespace Magento\CustomerImportExport\Model\Import; use Magento\Customer\Api\Data\CustomerInterface; +use Magento\ImportExport\Model\Import; use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface; /** @@ -14,6 +15,7 @@ * @api * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class Customer extends AbstractCustomer { @@ -337,6 +339,7 @@ protected function _getNextEntityId() */ protected function _prepareDataForUpdate(array $rowData) { + $multiSeparator = $this->getMultipleValueSeparator(); $entitiesToCreate = []; $entitiesToUpdate = []; $attributesToSave = []; @@ -375,10 +378,14 @@ protected function _prepareDataForUpdate(array $rowData) // attribute values foreach (array_intersect_key($rowData, $this->_attributes) as $attributeCode => $value) { $attributeParameters = $this->_attributes[$attributeCode]; - if ('select' == $attributeParameters['type']) { - $value = isset($attributeParameters['options'][strtolower($value)]) - ? $attributeParameters['options'][strtolower($value)] - : 0; + if (in_array($attributeParameters['type'], ['select', 'boolean'])) { + $value = $this->getSelectAttrIdByValue($attributeParameters, $value); + } elseif ('multiselect' == $attributeParameters['type']) { + $ids = []; + foreach (explode($multiSeparator, mb_strtolower($value)) as $subValue) { + $ids[] = $this->getSelectAttrIdByValue($attributeParameters, $subValue); + } + $value = implode(',', $ids); } elseif ('datetime' == $attributeParameters['type'] && !empty($value)) { $value = (new \DateTime())->setTimestamp(strtotime($value)); $value = $value->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT); @@ -534,7 +541,15 @@ protected function _validateRowForUpdate(array $rowData, $rowNumber) continue; } if (isset($rowData[$attributeCode]) && strlen($rowData[$attributeCode])) { - $this->isAttributeValid($attributeCode, $attributeParams, $rowData, $rowNumber); + $this->isAttributeValid( + $attributeCode, + $attributeParams, + $rowData, + $rowNumber, + isset($this->_parameters[Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR]) + ? $this->_parameters[Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR] + : Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR + ); } elseif ($attributeParams['is_required'] && !$this->_getCustomerId($email, $website)) { $this->addRowError(self::ERROR_VALUE_IS_REQUIRED, $rowNumber, $attributeCode); } diff --git a/app/code/Magento/CustomerImportExport/Test/Unit/Model/Export/AddressTest.php b/app/code/Magento/CustomerImportExport/Test/Unit/Model/Export/AddressTest.php index 45c6e8891839a..84900aa6dddc5 100644 --- a/app/code/Magento/CustomerImportExport/Test/Unit/Model/Export/AddressTest.php +++ b/app/code/Magento/CustomerImportExport/Test/Unit/Model/Export/AddressTest.php @@ -10,7 +10,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class AddressTest extends \PHPUnit_Framework_TestCase +class AddressTest extends \PHPUnit\Framework\TestCase { /** * Test attribute code @@ -69,7 +69,7 @@ class AddressTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $storeManager = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); + $storeManager = $this->createMock(\Magento\Store\Model\StoreManager::class); $storeManager->expects( $this->once() )->method( @@ -80,27 +80,15 @@ protected function setUp() $this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_model = new \Magento\CustomerImportExport\Model\Export\Address( - $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class), + $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class), $storeManager, - $this->getMock(\Magento\ImportExport\Model\Export\Factory::class, [], [], '', false), - $this->getMock( - \Magento\ImportExport\Model\ResourceModel\CollectionByPagesIteratorFactory::class, - [], - [], - '', - false - ), - $this->getMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class, [], [], '', false), - $this->getMock(\Magento\Eav\Model\Config::class, [], [], '', false), - $this->getMock(\Magento\Customer\Model\ResourceModel\Customer\CollectionFactory::class, [], [], '', false), - $this->getMock( - \Magento\CustomerImportExport\Model\Export\CustomerFactory::class, - [], - [], - '', - false - ), - $this->getMock(\Magento\Customer\Model\ResourceModel\Address\CollectionFactory::class, [], [], '', false), + $this->createMock(\Magento\ImportExport\Model\Export\Factory::class), + $this->createMock(\Magento\ImportExport\Model\ResourceModel\CollectionByPagesIteratorFactory::class), + $this->createMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class), + $this->createMock(\Magento\Eav\Model\Config::class), + $this->createMock(\Magento\Customer\Model\ResourceModel\Customer\CollectionFactory::class), + $this->createMock(\Magento\CustomerImportExport\Model\Export\CustomerFactory::class), + $this->createMock(\Magento\Customer\Model\ResourceModel\Address\CollectionFactory::class), $this->_getModelDependencies() ); } @@ -118,16 +106,16 @@ protected function tearDown() */ protected function _getModelDependencies() { - $translator = $this->getMock(\stdClass::class); + $translator = $this->createMock(\stdClass::class); - $entityFactory = $this->getMock(\Magento\Framework\Data\Collection\EntityFactory::class, [], [], '', false); + $entityFactory = $this->createMock(\Magento\Framework\Data\Collection\EntityFactory::class); + + /** @var $attributeCollection \Magento\Framework\Data\Collection|\PHPUnit\Framework\TestCase */ + $attributeCollection = $this->getMockBuilder(\Magento\Framework\Data\Collection::class) + ->setMethods(['getEntityTypeCode']) + ->setConstructorArgs([$entityFactory]) + ->getMock(); - /** @var $attributeCollection \Magento\Framework\Data\Collection|\PHPUnit_Framework_TestCase */ - $attributeCollection = $this->getMock( - \Magento\Framework\Data\Collection::class, - ['getEntityTypeCode'], - [$entityFactory] - ); $attributeCollection->expects( $this->once() )->method( @@ -138,7 +126,7 @@ protected function _getModelDependencies() foreach ($this->_attributes as $attributeData) { $arguments = $this->_objectManager->getConstructArguments( \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class, - ['eavTypeFactory' => $this->getMock(\Magento\Eav\Model\Entity\TypeFactory::class, [], [], '', false)] + ['eavTypeFactory' => $this->createMock(\Magento\Eav\Model\Entity\TypeFactory::class)] ); $arguments['data'] = $attributeData; $attribute = $this->getMockForAbstractClass( @@ -153,7 +141,7 @@ protected function _getModelDependencies() $attributeCollection->addItem($attribute); } - $byPagesIterator = $this->getMock(\stdClass::class, ['iterate']); + $byPagesIterator = $this->createPartialMock(\stdClass::class, ['iterate']); $byPagesIterator->expects( $this->once() )->method( @@ -167,7 +155,7 @@ protected function _getModelDependencies() ->disableOriginalConstructor() ->getMockForAbstractClass(); - $customerEntity = $this->getMock(\stdClass::class, ['filterEntityCollection', 'setParameters']); + $customerEntity = $this->createPartialMock(\stdClass::class, ['filterEntityCollection', 'setParameters']); $customerEntity->expects($this->any())->method('filterEntityCollection')->will($this->returnArgument(0)); $customerEntity->expects($this->any())->method('setParameters')->will($this->returnSelf()); @@ -219,22 +207,16 @@ public function getWebsites($withDefault = false) */ public function iterate(\Magento\Framework\Data\Collection\AbstractDb $collection, $pageSize, array $callbacks) { - $resource = $this->getMock( - \Magento\Customer\Model\ResourceModel\Customer::class, - ['getIdFieldName'], - [], - '', - false - ); + $resource = $this->createPartialMock(\Magento\Customer\Model\ResourceModel\Customer::class, ['getIdFieldName']); $resource->expects($this->any())->method('getIdFieldName')->will($this->returnValue('id')); $arguments = [ 'data' => $this->_customerData, 'resource' => $resource, - $this->getMock(\Magento\Customer\Model\Config\Share::class, [], [], '', false), - $this->getMock(\Magento\Customer\Model\AddressFactory::class, [], [], '', false), - $this->getMock(\Magento\Customer\Model\ResourceModel\Address\CollectionFactory::class, [], [], '', false), - $this->getMock(\Magento\Customer\Model\GroupFactory::class, [], [], '', false), - $this->getMock(\Magento\Customer\Model\AttributeFactory::class, [], [], '', false), + $this->createMock(\Magento\Customer\Model\Config\Share::class), + $this->createMock(\Magento\Customer\Model\AddressFactory::class), + $this->createMock(\Magento\Customer\Model\ResourceModel\Address\CollectionFactory::class), + $this->createMock(\Magento\Customer\Model\GroupFactory::class), + $this->createMock(\Magento\Customer\Model\AttributeFactory::class), ]; /** @var $customer \Magento\Customer\Model\Customer|\PHPUnit_Framework_MockObject_MockObject */ $customer = $this->_objectManager->getObject(\Magento\Customer\Model\Customer::class, $arguments); diff --git a/app/code/Magento/CustomerImportExport/Test/Unit/Model/Export/CustomerTest.php b/app/code/Magento/CustomerImportExport/Test/Unit/Model/Export/CustomerTest.php index 3181dcd407577..c272ed1592c02 100644 --- a/app/code/Magento/CustomerImportExport/Test/Unit/Model/Export/CustomerTest.php +++ b/app/code/Magento/CustomerImportExport/Test/Unit/Model/Export/CustomerTest.php @@ -10,7 +10,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class CustomerTest extends \PHPUnit_Framework_TestCase +class CustomerTest extends \PHPUnit\Framework\TestCase { /**#@+ * Test attribute code @@ -56,7 +56,7 @@ class CustomerTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $storeManager = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); + $storeManager = $this->createMock(\Magento\Store\Model\StoreManager::class); $storeManager->expects( $this->any() @@ -75,19 +75,13 @@ protected function setUp() ); $this->_model = new \Magento\CustomerImportExport\Model\Export\Customer( - $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class), + $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class), $storeManager, - $this->getMock(\Magento\ImportExport\Model\Export\Factory::class, [], [], '', false), - $this->getMock( - \Magento\ImportExport\Model\ResourceModel\CollectionByPagesIteratorFactory::class, - [], - [], - '', - false - ), - $this->getMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class, [], [], '', false), - $this->getMock(\Magento\Eav\Model\Config::class, [], [], '', false), - $this->getMock(\Magento\Customer\Model\ResourceModel\Customer\CollectionFactory::class, [], [], '', false), + $this->createMock(\Magento\ImportExport\Model\Export\Factory::class), + $this->createMock(\Magento\ImportExport\Model\ResourceModel\CollectionByPagesIteratorFactory::class), + $this->createMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class), + $this->createMock(\Magento\Eav\Model\Config::class), + $this->createMock(\Magento\Customer\Model\ResourceModel\Customer\CollectionFactory::class), $this->_getModelDependencies() ); } @@ -104,16 +98,16 @@ protected function tearDown() */ protected function _getModelDependencies() { - $translator = $this->getMock(\stdClass::class); + $translator = $this->createMock(\stdClass::class); $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $attributeCollection = new \Magento\Framework\Data\Collection( - $this->getMock(\Magento\Framework\Data\Collection\EntityFactory::class, [], [], '', false) + $this->createMock(\Magento\Framework\Data\Collection\EntityFactory::class) ); foreach ($this->_attributes as $attributeData) { $arguments = $objectManagerHelper->getConstructArguments( \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class, - ['eavTypeFactory' => $this->getMock(\Magento\Eav\Model\Entity\TypeFactory::class, [], [], '', false)] + ['eavTypeFactory' => $this->createMock(\Magento\Eav\Model\Entity\TypeFactory::class)] ); $arguments['data'] = $attributeData; $attribute = $this->getMockForAbstractClass( diff --git a/app/code/Magento/CustomerImportExport/Test/Unit/Model/Import/AbstractCustomerTest.php b/app/code/Magento/CustomerImportExport/Test/Unit/Model/Import/AbstractCustomerTest.php index 0f19cac1fed3c..e57488d7c5bb0 100644 --- a/app/code/Magento/CustomerImportExport/Test/Unit/Model/Import/AbstractCustomerTest.php +++ b/app/code/Magento/CustomerImportExport/Test/Unit/Model/Import/AbstractCustomerTest.php @@ -69,7 +69,7 @@ protected function tearDown() protected function _getModelMock() { $customerCollection = new \Magento\Framework\Data\Collection( - $this->getMock(\Magento\Framework\Data\Collection\EntityFactory::class, [], [], '', false) + $this->createMock(\Magento\Framework\Data\Collection\EntityFactory::class) ); foreach ($this->_customers as $customer) { $customerCollection->addItem(new \Magento\Framework\DataObject($customer)); diff --git a/app/code/Magento/CustomerImportExport/Test/Unit/Model/Import/AddressTest.php b/app/code/Magento/CustomerImportExport/Test/Unit/Model/Import/AddressTest.php index e53f39b95d720..fe8c2dedb5744 100644 --- a/app/code/Magento/CustomerImportExport/Test/Unit/Model/Import/AddressTest.php +++ b/app/code/Magento/CustomerImportExport/Test/Unit/Model/Import/AddressTest.php @@ -6,14 +6,14 @@ namespace Magento\CustomerImportExport\Test\Unit\Model\Import; -use Magento\ImportExport\Model\Import\AbstractEntity; use Magento\CustomerImportExport\Model\Import\Address; +use Magento\ImportExport\Model\Import\AbstractEntity; /** * Class AddressTest * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class AddressTest extends \PHPUnit_Framework_TestCase +class AddressTest extends \PHPUnit\Framework\TestCase { /** * Customer address entity adapter mock @@ -126,12 +126,9 @@ protected function setUp() ->method('getWebsites') ->will($this->returnCallback([$this, 'getWebsites'])); $this->_model = $this->_getModelMock(); - $this->errorAggregator = $this->getMock( + $this->errorAggregator = $this->createPartialMock( \Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregator::class, - ['hasToBeTerminated'], - [], - '', - false + ['hasToBeTerminated'] ); } @@ -150,20 +147,20 @@ protected function tearDown() */ protected function _getModelDependencies() { - $dataSourceModel = $this->getMock(\stdClass::class, ['getNextBunch']); - $connection = $this->getMock(\stdClass::class); + $dataSourceModel = $this->createPartialMock(\stdClass::class, ['getNextBunch']); + $connection = $this->createMock(\stdClass::class); $attributeCollection = $this->_createAttrCollectionMock(); $customerStorage = $this->_createCustomerStorageMock(); $customerEntity = $this->_createCustomerEntityMock(); $addressCollection = new \Magento\Framework\Data\Collection( - $this->getMock(\Magento\Framework\Data\Collection\EntityFactory::class, [], [], '', false) + $this->createMock(\Magento\Framework\Data\Collection\EntityFactory::class) ); foreach ($this->_addresses as $address) { $addressCollection->addItem(new \Magento\Framework\DataObject($address)); } $regionCollection = new \Magento\Framework\Data\Collection( - $this->getMock(\Magento\Framework\Data\Collection\EntityFactory::class, [], [], '', false) + $this->createMock(\Magento\Framework\Data\Collection\EntityFactory::class) ); foreach ($this->_regions as $region) { $regionCollection->addItem(new \Magento\Framework\DataObject($region)); @@ -194,23 +191,22 @@ protected function _getModelDependencies() */ protected function _createAttrCollectionMock() { - $entityFactory = $this->getMock(\Magento\Framework\Data\Collection\EntityFactory::class, [], [], '', false); - $attributeCollection = $this->getMock( - \Magento\Framework\Data\Collection::class, - ['getEntityTypeCode'], - [$entityFactory] - ); + $entityFactory = $this->createMock(\Magento\Framework\Data\Collection\EntityFactory::class); + $attributeCollection = $this->getMockBuilder(\Magento\Framework\Data\Collection::class) + ->setMethods(['getEntityTypeCode']) + ->setConstructorArgs([$entityFactory]) + ->getMock(); foreach ($this->_attributes as $attributeData) { $arguments = $this->_objectManagerMock->getConstructArguments( \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class, [ - $this->getMock(\Magento\Framework\Model\Context::class, [], [], '', false, false), - $this->getMock(\Magento\Framework\Registry::class), - $this->getMock(\Magento\Eav\Model\Config::class, [], [], '', false, false), - $this->getMock(\Magento\Eav\Model\Entity\TypeFactory::class, [], [], '', false), - $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false, false), - $this->getMock(\Magento\Eav\Model\ResourceModel\Helper::class, [], [], '', false, false), - $this->getMock(\Magento\Framework\Validator\UniversalFactory::class, [], [], '', false, false) + $this->createMock(\Magento\Framework\Model\Context::class), + $this->createMock(\Magento\Framework\Registry::class), + $this->createMock(\Magento\Eav\Model\Config::class), + $this->createMock(\Magento\Eav\Model\Entity\TypeFactory::class), + $this->createMock(\Magento\Store\Model\StoreManager::class), + $this->createMock(\Magento\Eav\Model\ResourceModel\Helper::class), + $this->createMock(\Magento\Framework\Validator\UniversalFactory::class) ] ); $arguments['data'] = $attributeData; @@ -221,7 +217,7 @@ protected function _createAttrCollectionMock() true, true, true, - ['_construct', 'getBackend'] + ['_construct', 'getBackend', 'getTable'] ); $attribute->expects($this->any())->method('getBackend')->will($this->returnSelf()); $attribute->expects($this->any())->method('getTable')->will($this->returnValue($attributeData['table'])); @@ -237,36 +233,24 @@ protected function _createAttrCollectionMock() */ protected function _createCustomerStorageMock() { - $customerStorage = $this->getMock( + $customerStorage = $this->createPartialMock( \Magento\CustomerImportExport\Model\ResourceModel\Import\Customer\Storage::class, - ['load'], - [], - '', - false + ['load'] ); - $resourceMock = $this->getMock( + $resourceMock = $this->createPartialMock( \Magento\Customer\Model\ResourceModel\Customer::class, - ['getIdFieldName'], - [], - '', - false + ['getIdFieldName'] ); $resourceMock->expects($this->any())->method('getIdFieldName')->will($this->returnValue('id')); foreach ($this->_customers as $customerData) { $data = [ 'resource' => $resourceMock, 'data' => $customerData, - $this->getMock(\Magento\Customer\Model\Config\Share::class, [], [], '', false), - $this->getMock(\Magento\Customer\Model\AddressFactory::class, [], [], '', false), - $this->getMock( - \Magento\Customer\Model\ResourceModel\Address\CollectionFactory::class, - [], - [], - '', - false - ), - $this->getMock(\Magento\Customer\Model\GroupFactory::class, [], [], '', false), - $this->getMock(\Magento\Customer\Model\AttributeFactory::class, [], [], '', false), + $this->createMock(\Magento\Customer\Model\Config\Share::class), + $this->createMock(\Magento\Customer\Model\AddressFactory::class), + $this->createMock(\Magento\Customer\Model\ResourceModel\Address\CollectionFactory::class), + $this->createMock(\Magento\Customer\Model\GroupFactory::class), + $this->createMock(\Magento\Customer\Model\AttributeFactory::class), ]; /** @var $customer \Magento\Customer\Model\Customer */ $customer = $this->_objectManagerMock->getObject(\Magento\Customer\Model\Customer::class, $data); @@ -282,7 +266,7 @@ protected function _createCustomerStorageMock() */ protected function _createCustomerEntityMock() { - $customerEntity = $this->getMock(\stdClass::class, ['filterEntityCollection', 'setParameters']); + $customerEntity = $this->createPartialMock(\stdClass::class, ['filterEntityCollection', 'setParameters']); $customerEntity->expects($this->any())->method('filterEntityCollection')->will($this->returnArgument(0)); $customerEntity->expects($this->any())->method('setParameters')->will($this->returnSelf()); return $customerEntity; @@ -355,7 +339,7 @@ protected function _getModelMockForTestImportDataWithCustomBehaviour() ]; // entity adapter mock - $modelMock = $this->getMock( + $modelMock = $this->createPartialMock( \Magento\CustomerImportExport\Model\Import\Address::class, [ 'validateRow', @@ -366,12 +350,7 @@ protected function _getModelMockForTestImportDataWithCustomBehaviour() '_deleteAddressEntities', '_mergeEntityAttributes', 'getErrorAggregator' - ], - [], - '', - false, - true, - true + ] ); $availableBehaviors = new \ReflectionProperty($modelMock, '_availableBehaviors'); @@ -379,12 +358,9 @@ protected function _getModelMockForTestImportDataWithCustomBehaviour() $availableBehaviors->setValue($modelMock, $this->_availableBehaviors); // mock to imitate data source model - $dataSourceMock = $this->getMock( + $dataSourceMock = $this->createPartialMock( \Magento\ImportExport\Model\ResourceModel\Import\Data::class, - ['getNextBunch', '__wakeup'], - [], - '', - false + ['getNextBunch', '__wakeup'] ); $dataSourceMock->expects($this->at(0))->method('getNextBunch')->will($this->returnValue($customBehaviorRows)); $dataSourceMock->expects($this->at(1))->method('getNextBunch')->will($this->returnValue(null)); @@ -436,43 +412,27 @@ protected function _getModelMockForTestImportDataWithCustomBehaviour() */ protected function _getModelMock() { - $scopeConfig = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $scopeConfig = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $modelMock = new \Magento\CustomerImportExport\Model\Import\Address( $this->_stringLib, $scopeConfig, - $this->getMock(\Magento\ImportExport\Model\ImportFactory::class, [], [], '', false), - $this->getMock(\Magento\ImportExport\Model\ResourceModel\Helper::class, [], [], '', false), - $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false), - $this->getMock( - \Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface::class, - [], - [], - '', - false + $this->createMock(\Magento\ImportExport\Model\ImportFactory::class), + $this->createMock(\Magento\ImportExport\Model\ResourceModel\Helper::class), + $this->createMock(\Magento\Framework\App\ResourceConnection::class), + $this->createMock( + \Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface::class ), $this->_storeManager, - $this->getMock(\Magento\ImportExport\Model\Export\Factory::class, [], [], '', false), - $this->getMock(\Magento\Eav\Model\Config::class, [], [], '', false), - $this->getMock( - \Magento\CustomerImportExport\Model\ResourceModel\Import\Customer\StorageFactory::class, - [], - [], - '', - false - ), - $this->getMock(\Magento\Customer\Model\AddressFactory::class, [], [], '', false), - $this->getMock(\Magento\Directory\Model\ResourceModel\Region\CollectionFactory::class, [], [], '', false), - $this->getMock(\Magento\Customer\Model\CustomerFactory::class, [], [], '', false), - $this->getMock(\Magento\Customer\Model\ResourceModel\Address\CollectionFactory::class, [], [], '', false), - $this->getMock( - \Magento\Customer\Model\ResourceModel\Address\Attribute\CollectionFactory::class, - [], - [], - '', - false - ), + $this->createMock(\Magento\ImportExport\Model\Export\Factory::class), + $this->createMock(\Magento\Eav\Model\Config::class), + $this->createMock(\Magento\CustomerImportExport\Model\ResourceModel\Import\Customer\StorageFactory::class), + $this->createMock(\Magento\Customer\Model\AddressFactory::class), + $this->createMock(\Magento\Directory\Model\ResourceModel\Region\CollectionFactory::class), + $this->createMock(\Magento\Customer\Model\CustomerFactory::class), + $this->createMock(\Magento\Customer\Model\ResourceModel\Address\CollectionFactory::class), + $this->createMock(\Magento\Customer\Model\ResourceModel\Address\Attribute\CollectionFactory::class), new \Magento\Framework\Stdlib\DateTime(), - $this->getMock(\Magento\Customer\Model\Address\Validator\Postcode::class, [], [], '', false), + $this->createMock(\Magento\Customer\Model\Address\Validator\Postcode::class), $this->_getModelDependencies() ); diff --git a/app/code/Magento/CustomerImportExport/Test/Unit/Model/Import/CustomerCompositeTest.php b/app/code/Magento/CustomerImportExport/Test/Unit/Model/Import/CustomerCompositeTest.php index 2734b7224d3bb..3d8736dc80fc6 100644 --- a/app/code/Magento/CustomerImportExport/Test/Unit/Model/Import/CustomerCompositeTest.php +++ b/app/code/Magento/CustomerImportExport/Test/Unit/Model/Import/CustomerCompositeTest.php @@ -21,7 +21,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class CustomerCompositeTest extends \PHPUnit_Framework_TestCase +class CustomerCompositeTest extends \PHPUnit\Framework\TestCase { /** * @var array @@ -122,80 +122,35 @@ class CustomerCompositeTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $translateInline = $this->getMock(\Magento\Framework\Translate\InlineInterface::class, [], [], '', false); + $translateInline = $this->createMock(\Magento\Framework\Translate\InlineInterface::class); $translateInline->expects($this->any())->method('isAllowed')->will($this->returnValue(false)); $context = - $this->getMock(\Magento\Framework\App\Helper\Context::class, ['getTranslateInline'], [], '', false); + $this->createPartialMock(\Magento\Framework\App\Helper\Context::class, ['getTranslateInline']); $context->expects($this->any())->method('getTranslateInline')->will($this->returnValue($translateInline)); $this->_string = new \Magento\Framework\Stdlib\StringUtils(); - $this->_importFactory = $this->getMock( - \Magento\ImportExport\Model\ImportFactory::class, - [], - [], - '', - false - ); - $this->_resource = $this->getMock(\Magento\Framework\App\ResourceConnection::class, [], [], '', false); - $this->_resourceHelper = $this->getMock( - \Magento\ImportExport\Model\ResourceModel\Helper::class, - [], - [], - '', - false - ); - $this->_dataFactory = $this->getMock( - \Magento\CustomerImportExport\Model\ResourceModel\Import\CustomerComposite\DataFactory::class, - [], - [], - '', - false - ); - $this->_customerFactory = $this->getMock( - \Magento\CustomerImportExport\Model\Import\CustomerFactory::class, - [], - [], - '', - false - ); - $this->_addressFactory = $this->getMock( - \Magento\CustomerImportExport\Model\Import\AddressFactory::class, - [], - [], - '', - false - ); + $this->_importFactory = $this->createMock(\Magento\ImportExport\Model\ImportFactory::class); + $this->_resource = $this->createMock(\Magento\Framework\App\ResourceConnection::class); + $this->_resourceHelper = $this->createMock(\Magento\ImportExport\Model\ResourceModel\Helper::class); + $this->_dataFactory = $this->createMock(\Magento\CustomerImportExport\Model\ResourceModel\Import\CustomerComposite\DataFactory::class); + $this->_customerFactory = $this->createMock(\Magento\CustomerImportExport\Model\Import\CustomerFactory::class); + $this->_addressFactory = $this->createMock(\Magento\CustomerImportExport\Model\Import\AddressFactory::class); - $this->errorFactory = $this->getMock( - \Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorFactory::class, - ['create'], - [], - '', - false - ); + $this->errorFactory = $this->createPartialMock(\Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorFactory::class, ['create']); - $this->error = $this->getMock( - \Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingError::class, - ['init'], - [], - '', - false - ); + $this->error = $this->createPartialMock(\Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingError::class, ['init']); $this->errorFactory->expects($this->any())->method('create')->will($this->returnValue($this->error)); $this->error->expects($this->any())->method('init')->will($this->returnValue(true)); - $this->errorAggregator = $this->getMock( - \Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregator::class, - ['hasToBeTerminated'], - [$this->errorFactory], - '', - true - ); + $this->errorAggregator = $this->getMockBuilder(\Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregator::class) + ->setMethods(['hasToBeTerminated']) + ->setConstructorArgs([$this->errorFactory]) + ->getMock(); - $this->_scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->_scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); } /** @@ -239,7 +194,7 @@ protected function _getModelMockForPrepareRowForDb() $customerEntity = $this->_getCustomerEntityMock(['validateRow']); $customerEntity->expects($this->any())->method('validateRow')->will($this->returnValue(true)); - $customerStorage = $this->getMock(\stdClass::class, ['getCustomerId']); + $customerStorage = $this->createPartialMock(\stdClass::class, ['getCustomerId']); $customerStorage->expects($this->any())->method('getCustomerId')->will($this->returnValue(1)); $addressEntity = $this->_getAddressEntityMock(['validateRow', 'getCustomerStorage']); @@ -252,7 +207,7 @@ protected function _getModelMockForPrepareRowForDb() $this->returnValue($customerStorage) ); - $dataSourceMock = $this->getMock(\stdClass::class, ['cleanBunches', 'saveBunch']); + $dataSourceMock = $this->createPartialMock(\stdClass::class, ['cleanBunches', 'saveBunch']); $dataSourceMock->expects( $this->any() )->method( @@ -309,14 +264,7 @@ protected function _getCustomerEntityMock(array $mockedMethods = null) $mockedMethods[] = 'getAttributeCollection'; $mockedMethods[] = 'getWebsiteId'; - $customerEntity = $this->getMock( - \Magento\CustomerImportExport\Model\Import\Customer::class, - $mockedMethods, - [], - '', - false - ); - + $customerEntity = $this->createPartialMock(\Magento\CustomerImportExport\Model\Import\Customer::class, $mockedMethods); $attributeList = []; foreach ($this->_customerAttributes as $code) { $attribute = new \Magento\Framework\DataObject(['attribute_code' => $code]); @@ -344,13 +292,7 @@ protected function _getAddressEntityMock(array $mockedMethods = null) } $mockedMethods[] = 'getAttributeCollection'; - $addressEntity = $this->getMock( - \Magento\CustomerImportExport\Model\Import\Address::class, - $mockedMethods, - [], - '', - false - ); + $addressEntity = $this->createPartialMock(\Magento\CustomerImportExport\Model\Import\Address::class, $mockedMethods); $attributeList = []; foreach ($this->_addressAttributes as $code) { @@ -433,7 +375,7 @@ public function testValidateRow(array $rows, array $calls, $validationReturn, ar ->method('validateRow') ->will($this->returnValue($validationReturn)); - $customerStorage = $this->getMock(\stdClass::class, ['getCustomerId']); + $customerStorage = $this->createPartialMock(\stdClass::class, ['getCustomerId']); $customerStorage->expects($this->any())->method('getCustomerId')->will($this->returnValue(true)); $addressEntity->expects( $this->any() @@ -476,7 +418,7 @@ public function testPrepareAddressRowData() $this->returnCallback([$this, 'validateAddressRowParams']) ); - $customerStorage = $this->getMock(\stdClass::class, ['getCustomerId']); + $customerStorage = $this->createPartialMock(\stdClass::class, ['getCustomerId']); $customerStorage->expects($this->any())->method('getCustomerId')->will($this->returnValue(true)); $addressEntity->expects($this->any()) ->method('getCustomerStorage') @@ -654,7 +596,7 @@ public function testPrepareRowForDb() { $modelUnderTest = $this->_getModelMockForPrepareRowForDb(); $pathToCsvFile = __DIR__ . '/_files/customer_composite_prepare_row_for_db.csv'; - $directoryMock = $this->getMock(\Magento\Framework\Filesystem\Directory\Write::class, [], [], '', false); + $directoryMock = $this->createMock(\Magento\Framework\Filesystem\Directory\Write::class); $directoryMock->expects($this->any()) ->method('openFile')->will( $this->returnValue(new Read($pathToCsvFile, new File())) diff --git a/app/code/Magento/CustomerImportExport/Test/Unit/Model/Import/CustomerTest.php b/app/code/Magento/CustomerImportExport/Test/Unit/Model/Import/CustomerTest.php index 37c074f12fd33..365e937541feb 100644 --- a/app/code/Magento/CustomerImportExport/Test/Unit/Model/Import/CustomerTest.php +++ b/app/code/Magento/CustomerImportExport/Test/Unit/Model/Import/CustomerTest.php @@ -13,7 +13,7 @@ use Magento\CustomerImportExport\Model\Import\Customer; -class CustomerTest extends \PHPUnit_Framework_TestCase +class CustomerTest extends \PHPUnit\Framework\TestCase { /** * Customer entity import model @@ -95,13 +95,7 @@ protected function _getModelMockForTestImportDataWithCustomBehaviour() ]) ->getMock(); - $errorAggregator = $this->getMock( - \Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregator::class, - ['hasToBeTerminated'], - [], - '', - false - ); + $errorAggregator = $this->createPartialMock(\Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregator::class, ['hasToBeTerminated']); $availableBehaviors = new \ReflectionProperty($modelMock, '_availableBehaviors'); $availableBehaviors->setAccessible(true); diff --git a/app/code/Magento/CustomerImportExport/Test/Unit/Model/ResourceModel/Import/Customer/StorageTest.php b/app/code/Magento/CustomerImportExport/Test/Unit/Model/ResourceModel/Import/Customer/StorageTest.php index a0828f270414f..71f8f17c85509 100644 --- a/app/code/Magento/CustomerImportExport/Test/Unit/Model/ResourceModel/Import/Customer/StorageTest.php +++ b/app/code/Magento/CustomerImportExport/Test/Unit/Model/ResourceModel/Import/Customer/StorageTest.php @@ -7,7 +7,7 @@ use Magento\CustomerImportExport\Model\ResourceModel\Import\Customer\Storage; -class StorageTest extends \PHPUnit_Framework_TestCase +class StorageTest extends \PHPUnit\Framework\TestCase { /** * @var Storage @@ -66,7 +66,7 @@ protected function _getModelDependencies() $customerCollection->expects($this->once())->method('getSelect')->will($this->returnValue($select)); - $byPagesIterator = $this->getMock(\stdClass::class, ['iterate']); + $byPagesIterator = $this->createPartialMock(\stdClass::class, ['iterate']); $byPagesIterator->expects($this->once()) ->method('iterate') ->will($this->returnCallback([$this, 'iterate'])); diff --git a/app/code/Magento/CustomerImportExport/Test/Unit/Model/ResourceModel/Import/CustomerComposite/DataTest.php b/app/code/Magento/CustomerImportExport/Test/Unit/Model/ResourceModel/Import/CustomerComposite/DataTest.php index 12f39ff67ec8b..d226bfb922c07 100644 --- a/app/code/Magento/CustomerImportExport/Test/Unit/Model/ResourceModel/Import/CustomerComposite/DataTest.php +++ b/app/code/Magento/CustomerImportExport/Test/Unit/Model/ResourceModel/Import/CustomerComposite/DataTest.php @@ -15,7 +15,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class DataTest extends \PHPUnit_Framework_TestCase +class DataTest extends \PHPUnit\Framework\TestCase { /** * Array of customer attributes @@ -34,12 +34,9 @@ class DataTest extends \PHPUnit_Framework_TestCase protected function _getDependencies($entityType, $bunchData) { /** @var $statementMock \Magento\Framework\DB\Statement\Pdo\Mysql */ - $statementMock = $this->getMock( + $statementMock = $this->createPartialMock( \Magento\Framework\DB\Statement\Pdo\Mysql::class, - ['setFetchMode', 'getIterator'], - [], - '', - false + ['setFetchMode', 'getIterator'] ); $statementMock->expects( $this->any() @@ -50,29 +47,20 @@ protected function _getDependencies($entityType, $bunchData) ); /** @var $selectMock \Magento\Framework\DB\Select */ - $selectMock = $this->getMock(\Magento\Framework\DB\Select::class, ['from', 'order'], [], '', false); + $selectMock = $this->createPartialMock(\Magento\Framework\DB\Select::class, ['from', 'order']); $selectMock->expects($this->any())->method('from')->will($this->returnSelf()); $selectMock->expects($this->any())->method('order')->will($this->returnSelf()); /** @var $connectionMock \Magento\Framework\DB\Adapter\AdapterInterface */ - $connectionMock = $this->getMock( + $connectionMock = $this->createPartialMock( \Magento\Framework\DB\Adapter\Pdo\Mysql::class, - ['select', 'from', 'order', 'query'], - [], - '', - false + ['select', 'from', 'order', 'query'] ); $connectionMock->expects($this->any())->method('select')->will($this->returnValue($selectMock)); $connectionMock->expects($this->any())->method('query')->will($this->returnValue($statementMock)); /** @var $resourceModelMock \Magento\Framework\App\ResourceConnection */ - $resourceModelMock = $this->getMock( - \Magento\Framework\App\ResourceConnection::class, - [], - [], - '', - false - ); + $resourceModelMock = $this->createMock(\Magento\Framework\App\ResourceConnection::class); $resourceModelMock->expects($this->any())->method('getConnection')->will($this->returnValue($connectionMock)); $data = ['resource' => $resourceModelMock, 'entity_type' => $entityType]; @@ -114,7 +102,7 @@ public function testGetNextBunch($entityType, $bunchData, $expectedData) ); unset($dependencies['resource'], $dependencies['json_helper']); - $contextMock = $this->getMock(\Magento\Framework\Model\ResourceModel\Db\Context::class, [], [], '', false); + $contextMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\Context::class); $contextMock->expects($this->once())->method('getResources')->willReturn($resource); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); diff --git a/app/code/Magento/Deploy/App/Mode/ConfigProvider.php b/app/code/Magento/Deploy/App/Mode/ConfigProvider.php new file mode 100644 index 0000000000000..142e3fe819438 --- /dev/null +++ b/app/code/Magento/Deploy/App/Mode/ConfigProvider.php @@ -0,0 +1,58 @@ + [ + * 'production' => [ + * {{setting_path}} => {{setting_value}} + * ] + * ] + * ] + * + * @var array + */ + private $config; + + /** + * @param array $config + */ + public function __construct(array $config = []) + { + $this->config = $config; + } + + /** + * Provide configuration while switching from $currentMode to $targetMode + * This method used in \Magento\Deploy\Model\Mode::setStoreMode + * + * For example: while switching from developer mode to production mode + * need to turn off 'dev/debug/debug_logging' setting in this case method + * will return array + * [ + * {{setting_path}} => {{setting_value}} + * ] + * + * @param string $currentMode + * @param string $targetMode + * @return array + */ + public function getConfigs($currentMode, $targetMode) + { + if (isset($this->config[$currentMode][$targetMode])) { + return $this->config[$currentMode][$targetMode]; + } + return []; + } +} diff --git a/app/code/Magento/Deploy/Console/CommandList.php b/app/code/Magento/Deploy/Console/CommandList.php new file mode 100644 index 0000000000000..2470737b19217 --- /dev/null +++ b/app/code/Magento/Deploy/Console/CommandList.php @@ -0,0 +1,58 @@ +objectManager = $objectManager; + } + + /** + * Gets list of command classes + * + * @return string[] + */ + private function getCommandsClasses() + { + return [ + \Magento\Deploy\Console\Command\App\ConfigImportCommand::class, + ]; + } + + /** + * @inheritdoc + */ + public function getCommands() + { + $commands = []; + foreach ($this->getCommandsClasses() as $class) { + if (class_exists($class)) { + $commands[] = $this->objectManager->get($class); + } else { + throw new \Exception('Class ' . $class . ' does not exist'); + } + } + + return $commands; + } +} diff --git a/app/code/Magento/Deploy/Model/ConfigWriter.php b/app/code/Magento/Deploy/Model/ConfigWriter.php index 5bd2b0e071dcc..4aededaf96800 100644 --- a/app/code/Magento/Deploy/Model/ConfigWriter.php +++ b/app/code/Magento/Deploy/Model/ConfigWriter.php @@ -63,6 +63,14 @@ public function save(array $values, $scope = ScopeConfigInterface::SCOPE_TYPE_DE { $config = []; $pathPrefix = $this->getPathPrefix($scope, $scopeCode); + + $values = array_filter( + $values, + function ($value) { + return $value !== null; + } + ); + foreach ($values as $configPath => $configValue) { $fullConfigPath = $pathPrefix . $configPath; $backendModel = $this->preparedValueFactory->create($configPath, $configValue, $scope, $scopeCode); diff --git a/app/code/Magento/Deploy/Model/Filesystem.php b/app/code/Magento/Deploy/Model/Filesystem.php index 60194ffd05f62..3dd28f4d3e820 100644 --- a/app/code/Magento/Deploy/Model/Filesystem.php +++ b/app/code/Magento/Deploy/Model/Filesystem.php @@ -147,7 +147,8 @@ public function regenerateStatic( DirectoryList::CACHE, DirectoryList::GENERATED_CODE, DirectoryList::GENERATED_METADATA, - DirectoryList::TMP_MATERIALIZATION_DIR + DirectoryList::TMP_MATERIALIZATION_DIR, + DirectoryList::STATIC_VIEW ] ); @@ -216,7 +217,7 @@ private function getUsedLocales() * Get user collection * * @return UserCollection - * @deprecated Added to not break backward compatibility of the constructor signature + * @deprecated 100.1.0 Added to not break backward compatibility of the constructor signature * by injecting the new dependency directly. * The method can be removed in a future major release, when constructor signature can be changed. */ @@ -306,7 +307,8 @@ public function cleanupFilesystem($directoryCodeList) * @param int $dirPermissions * @param int $filePermissions * @return void - * @deprecated As magento2 doesn't control indirectly the access permissions to the files and directories anymore. + * @deprecated 100.0.6 As magento2 doesn't control indirectly + * the access permissions to the files and directories anymore. * Access permissions to the files and directories are set during deploy Magento 2, directly after * uploading code of Magento. Also it is possible to specify the value * of inverse mask for setting access permissions to files and directories generated by Magento. @@ -330,7 +332,8 @@ protected function changePermissions($directoryCodeList, $dirPermissions, $fileP * Change permissions on static resources * * @return void - * @deprecated As magento2 doesn't control indirectly the access permissions to the files and directories anymore. + * @deprecated 100.0.6 As magento2 doesn't control indirectly the access permissions to the files + * and directories anymore. * Access permissions to the files and directories are set during deploy Magento 2, directly after * uploading code of Magento. Also it is possible to specify the value * of inverse mask for setting access permissions to files and directories generated by Magento. diff --git a/app/code/Magento/Deploy/Model/Mode.php b/app/code/Magento/Deploy/Model/Mode.php index 1e8b03585d2b8..ba3e8652fd443 100644 --- a/app/code/Magento/Deploy/Model/Mode.php +++ b/app/code/Magento/Deploy/Model/Mode.php @@ -6,6 +6,8 @@ namespace Magento\Deploy\Model; +use Magento\Deploy\App\Mode\ConfigProvider; +use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\App\DeploymentConfig\Reader; use Magento\Framework\App\DeploymentConfig\Writer; use Magento\Framework\App\Filesystem\DirectoryList; @@ -14,6 +16,10 @@ use Magento\Framework\Config\File\ConfigFilePool; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use Magento\Config\Console\Command\ConfigSet\ProcessorFacadeFactory; +use Magento\Config\Console\Command\EmulatedAdminhtmlAreaProcessor; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\App\ObjectManager; /** * A class to manage Magento modes @@ -43,11 +49,35 @@ class Mode */ private $reader; + /** + * @var MaintenanceMode + */ + private $maintenanceMode; + /** * @var Filesystem */ private $filesystem; + /** + * @var ConfigProvider + */ + private $configProvider; + + /** + * The factory for processor facade. + * + * @var ProcessorFacadeFactory + */ + private $processorFacadeFactory; + + /** + * Emulator adminhtml area for CLI command. + * + * @var EmulatedAdminhtmlAreaProcessor + */ + private $emulatedAreaProcessor; + /** * @param InputInterface $input * @param OutputInterface $output @@ -55,6 +85,9 @@ class Mode * @param Reader $reader * @param MaintenanceMode $maintenanceMode * @param Filesystem $filesystem + * @param ConfigProvider $configProvider + * @param ProcessorFacadeFactory $processorFacadeFactory + * @param EmulatedAdminhtmlAreaProcessor $emulatedAreaProcessor */ public function __construct( InputInterface $input, @@ -62,7 +95,10 @@ public function __construct( Writer $writer, Reader $reader, MaintenanceMode $maintenanceMode, - Filesystem $filesystem + Filesystem $filesystem, + ConfigProvider $configProvider = null, + ProcessorFacadeFactory $processorFacadeFactory = null, + EmulatedAdminhtmlAreaProcessor $emulatedAreaProcessor = null ) { $this->input = $input; $this->output = $output; @@ -70,18 +106,35 @@ public function __construct( $this->reader = $reader; $this->maintenanceMode = $maintenanceMode; $this->filesystem = $filesystem; + + $this->configProvider = + $configProvider ?: ObjectManager::getInstance()->get(ConfigProvider::class); + $this->processorFacadeFactory = + $processorFacadeFactory ?: ObjectManager::getInstance()->get(ProcessorFacadeFactory::class); + $this->emulatedAreaProcessor = + $emulatedAreaProcessor ?: ObjectManager::getInstance()->get(EmulatedAdminhtmlAreaProcessor::class); } /** * Enable production mode * + * @throws LocalizedException * @return void */ public function enableProductionMode() { $this->enableMaintenanceMode($this->output); - $this->filesystem->regenerateStatic($this->output); - $this->setStoreMode(State::MODE_PRODUCTION); + $previousMode = $this->getMode(); + try { + // We have to turn on production mode before generation. + // We need this to enable generation of the "min" files. + $this->setStoreMode(State::MODE_PRODUCTION); + $this->filesystem->regenerateStatic($this->output); + } catch (LocalizedException $e) { + // We have to return store mode to previous state in case of error. + $this->setStoreMode($previousMode); + throw $e; + } $this->disableMaintenanceMode($this->output); } @@ -134,6 +187,7 @@ public function getMode() */ protected function setStoreMode($mode) { + $this->saveAppConfigs($mode); $data = [ ConfigFilePool::APP_ENV => [ State::PARAM_MODE => $mode @@ -142,6 +196,29 @@ protected function setStoreMode($mode) $this->writer->saveConfig($data); } + /** + * Save application configs while switching mode + * + * @param string $mode + * @return void + */ + private function saveAppConfigs($mode) + { + $configs = $this->configProvider->getConfigs($this->getMode(), $mode); + foreach ($configs as $path => $value) { + $this->emulatedAreaProcessor->process(function () use ($path, $value) { + $this->processorFacadeFactory->create()->process( + $path, + $value, + ScopeConfigInterface::SCOPE_TYPE_DEFAULT, + null, + true + ); + }); + $this->output->writeln('Config "' . $path . ' = ' . $value . '" has been saved.'); + } + } + /** * Enable maintenance mode * diff --git a/app/code/Magento/Deploy/Test/Unit/App/Mode/ConfigProviderTest.php b/app/code/Magento/Deploy/Test/Unit/App/Mode/ConfigProviderTest.php new file mode 100644 index 0000000000000..ffb5c593f9e7e --- /dev/null +++ b/app/code/Magento/Deploy/Test/Unit/App/Mode/ConfigProviderTest.php @@ -0,0 +1,27 @@ + '{{setting_value}}' + ]; + $configProvider = new ConfigProvider( + [ + 'developer' => [ + 'production' => $expectedValue + ] + ] + ); + $this->assertEquals($expectedValue, $configProvider->getConfigs('developer', 'production')); + $this->assertEquals([], $configProvider->getConfigs('undefined', 'production')); + } +} diff --git a/app/code/Magento/Deploy/Test/Unit/Console/Command/App/ConfigImport/ProcessorTest.php b/app/code/Magento/Deploy/Test/Unit/Console/Command/App/ConfigImport/ProcessorTest.php index 3e7118cfc8ec5..56c952b46beaa 100644 --- a/app/code/Magento/Deploy/Test/Unit/Console/Command/App/ConfigImport/ProcessorTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Console/Command/App/ConfigImport/ProcessorTest.php @@ -21,7 +21,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ProcessorTest extends \PHPUnit_Framework_TestCase +class ProcessorTest extends \PHPUnit\Framework\TestCase { /** * @var ChangeDetector|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Deploy/Test/Unit/Console/Command/App/ConfigImportCommandTest.php b/app/code/Magento/Deploy/Test/Unit/Console/Command/App/ConfigImportCommandTest.php index f909369896c76..e15f9316028f7 100644 --- a/app/code/Magento/Deploy/Test/Unit/Console/Command/App/ConfigImportCommandTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Console/Command/App/ConfigImportCommandTest.php @@ -11,7 +11,7 @@ use Magento\Framework\Exception\RuntimeException; use Symfony\Component\Console\Tester\CommandTester; -class ConfigImportCommandTest extends \PHPUnit_Framework_TestCase +class ConfigImportCommandTest extends \PHPUnit\Framework\TestCase { /** * @var Processor|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Deploy/Test/Unit/Console/Command/App/SensitiveConfigSet/CollectorFactoryTest.php b/app/code/Magento/Deploy/Test/Unit/Console/Command/App/SensitiveConfigSet/CollectorFactoryTest.php index 10a6d6aa8af05..155acd4c785f0 100644 --- a/app/code/Magento/Deploy/Test/Unit/Console/Command/App/SensitiveConfigSet/CollectorFactoryTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Console/Command/App/SensitiveConfigSet/CollectorFactoryTest.php @@ -13,7 +13,7 @@ use PHPUnit_Framework_MockObject_MockObject as MockObject; use stdClass; -class CollectorFactoryTest extends \PHPUnit_Framework_TestCase +class CollectorFactoryTest extends \PHPUnit\Framework\TestCase { /** * @var ObjectManagerInterface|MockObject diff --git a/app/code/Magento/Deploy/Test/Unit/Console/Command/App/SensitiveConfigSet/InteractiveCollectorTest.php b/app/code/Magento/Deploy/Test/Unit/Console/Command/App/SensitiveConfigSet/InteractiveCollectorTest.php index c1a6e1bd40da2..804dca60937e6 100644 --- a/app/code/Magento/Deploy/Test/Unit/Console/Command/App/SensitiveConfigSet/InteractiveCollectorTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Console/Command/App/SensitiveConfigSet/InteractiveCollectorTest.php @@ -13,7 +13,7 @@ use Symfony\Component\Console\Question\QuestionFactory; use Symfony\Component\Console\Helper\QuestionHelper; -class InteractiveCollectorTest extends \PHPUnit_Framework_TestCase +class InteractiveCollectorTest extends \PHPUnit\Framework\TestCase { /** * @var QuestionFactory|MockObject diff --git a/app/code/Magento/Deploy/Test/Unit/Console/Command/App/SensitiveConfigSet/SensitiveConfigSetFacadeTest.php b/app/code/Magento/Deploy/Test/Unit/Console/Command/App/SensitiveConfigSet/SensitiveConfigSetFacadeTest.php index d4c5d96689a8b..585812f962bf6 100644 --- a/app/code/Magento/Deploy/Test/Unit/Console/Command/App/SensitiveConfigSet/SensitiveConfigSetFacadeTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Console/Command/App/SensitiveConfigSet/SensitiveConfigSetFacadeTest.php @@ -24,7 +24,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class SensitiveConfigSetFacadeTest extends \PHPUnit_Framework_TestCase +class SensitiveConfigSetFacadeTest extends \PHPUnit\Framework\TestCase { /** * @var ConfigFilePool|MockObject diff --git a/app/code/Magento/Deploy/Test/Unit/Console/Command/App/SensitiveConfigSet/SimpleCollectorTest.php b/app/code/Magento/Deploy/Test/Unit/Console/Command/App/SensitiveConfigSet/SimpleCollectorTest.php index 3b320f5f254f7..0e6bebe1737cd 100644 --- a/app/code/Magento/Deploy/Test/Unit/Console/Command/App/SensitiveConfigSet/SimpleCollectorTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Console/Command/App/SensitiveConfigSet/SimpleCollectorTest.php @@ -15,7 +15,7 @@ use Symfony\Component\Console\Helper\QuestionHelper; use PHPUnit_Framework_MockObject_MockObject as MockObject; -class SimpleCollectorTest extends \PHPUnit_Framework_TestCase +class SimpleCollectorTest extends \PHPUnit\Framework\TestCase { /** * @var QuestionFactory|MockObject diff --git a/app/code/Magento/Deploy/Test/Unit/Console/Command/App/SensitiveConfigSetCommandTest.php b/app/code/Magento/Deploy/Test/Unit/Console/Command/App/SensitiveConfigSetCommandTest.php index 6254e10523f28..45a87c643732c 100644 --- a/app/code/Magento/Deploy/Test/Unit/Console/Command/App/SensitiveConfigSetCommandTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Console/Command/App/SensitiveConfigSetCommandTest.php @@ -18,7 +18,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class SensitiveConfigSetCommandTest extends \PHPUnit_Framework_TestCase +class SensitiveConfigSetCommandTest extends \PHPUnit\Framework\TestCase { /** * @var SensitiveConfigSetFacade|MockObject diff --git a/app/code/Magento/Deploy/Test/Unit/Console/Command/ApplicationDumpCommandTest.php b/app/code/Magento/Deploy/Test/Unit/Console/Command/ApplicationDumpCommandTest.php index c45d3fd08ad1a..67c3796e7c6b9 100644 --- a/app/code/Magento/Deploy/Test/Unit/Console/Command/ApplicationDumpCommandTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Console/Command/ApplicationDumpCommandTest.php @@ -18,7 +18,7 @@ /** * Test command for dump application state */ -class ApplicationDumpCommandTest extends \PHPUnit_Framework_TestCase +class ApplicationDumpCommandTest extends \PHPUnit\Framework\TestCase { /** * @var InputInterface|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Deploy/Test/Unit/Console/Command/SetModeCommandTest.php b/app/code/Magento/Deploy/Test/Unit/Console/Command/SetModeCommandTest.php index 897f633843c12..caa310535f356 100644 --- a/app/code/Magento/Deploy/Test/Unit/Console/Command/SetModeCommandTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Console/Command/SetModeCommandTest.php @@ -12,7 +12,7 @@ /** * @package Magento\Deploy\Test\Unit\Console\Command */ -class SetModeCommandTest extends \PHPUnit_Framework_TestCase +class SetModeCommandTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Deploy\Model\Mode|\PHPUnit_Framework_MockObject_MockObject @@ -32,7 +32,7 @@ class SetModeCommandTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManagerMock = $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class); - $this->modeMock = $this->getMock(\Magento\Deploy\Model\Mode::class, [], [], '', false); + $this->modeMock = $this->createMock(\Magento\Deploy\Model\Mode::class); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->command = $objectManager->getObject( diff --git a/app/code/Magento/Deploy/Test/Unit/Console/Command/ShowModeCommandTest.php b/app/code/Magento/Deploy/Test/Unit/Console/Command/ShowModeCommandTest.php index 7ef532387813d..9ea42362d9646 100644 --- a/app/code/Magento/Deploy/Test/Unit/Console/Command/ShowModeCommandTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Console/Command/ShowModeCommandTest.php @@ -12,7 +12,7 @@ /** * @package Magento\Deploy\Test\Unit\Console\Command */ -class ShowModeCommandTest extends \PHPUnit_Framework_TestCase +class ShowModeCommandTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Deploy\Model\Mode|\PHPUnit_Framework_MockObject_MockObject @@ -32,7 +32,7 @@ class ShowModeCommandTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManagerMock = $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class); - $this->modeMock = $this->getMock(\Magento\Deploy\Model\Mode::class, [], [], '', false); + $this->modeMock = $this->createMock(\Magento\Deploy\Model\Mode::class); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->command = $objectManager->getObject( diff --git a/app/code/Magento/Deploy/Test/Unit/Console/CommandListTest.php b/app/code/Magento/Deploy/Test/Unit/Console/CommandListTest.php new file mode 100644 index 0000000000000..0d305551e0af2 --- /dev/null +++ b/app/code/Magento/Deploy/Test/Unit/Console/CommandListTest.php @@ -0,0 +1,58 @@ +objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class) + ->getMockForAbstractClass(); + + $this->model = new CommandList( + $this->objectManagerMock + ); + } + + public function testGetCommands() + { + $configImportCommand = $this->getMockBuilder(ConfigImportCommand::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->objectManagerMock->expects($this->once()) + ->method('get') + ->willReturnMap([ + [ConfigImportCommand::class, $configImportCommand], + ]); + + $this->assertSame( + [$configImportCommand], + $this->model->getCommands() + ); + } +} diff --git a/app/code/Magento/Deploy/Test/Unit/Model/ConfigWriterTest.php b/app/code/Magento/Deploy/Test/Unit/Model/ConfigWriterTest.php index d8d10f071bf2b..8c80d4f850376 100644 --- a/app/code/Magento/Deploy/Test/Unit/Model/ConfigWriterTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Model/ConfigWriterTest.php @@ -14,7 +14,7 @@ use Magento\Framework\Stdlib\ArrayManager; use PHPUnit_Framework_MockObject_MockObject as MockObject; -class ConfigWriterTest extends \PHPUnit_Framework_TestCase +class ConfigWriterTest extends \PHPUnit\Framework\TestCase { /** * @var Writer|MockObject @@ -168,4 +168,23 @@ public function testSaveDefaultScope() $this->model->save($values); } + + /** + * Save null (empty input) through CLI and assert it does not create backend model for validation + * @return void + */ + public function testSavingNullValues() + { + $values = [ + 'some1/config1/path1' => null, + ]; + + $this->preparedValueFactoryMock->expects($this->never())->method('create'); + + $this->writerMock->expects($this->once()) + ->method('saveConfig') + ->with([ConfigFilePool::APP_ENV => []]); + + $this->model->save($values); + } } diff --git a/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/ChangeDetectorTest.php b/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/ChangeDetectorTest.php index 69985bb7e3545..dbb23be311b47 100644 --- a/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/ChangeDetectorTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/ChangeDetectorTest.php @@ -10,7 +10,7 @@ use Magento\Deploy\Model\DeploymentConfig\DataCollector; use Magento\Deploy\Model\DeploymentConfig\ChangeDetector; -class ChangeDetectorTest extends \PHPUnit_Framework_TestCase +class ChangeDetectorTest extends \PHPUnit\Framework\TestCase { /** * @var Hash|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/DataCollectorTest.php b/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/DataCollectorTest.php index 65f7347ca90ac..7b0102dffd47a 100644 --- a/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/DataCollectorTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/DataCollectorTest.php @@ -9,7 +9,7 @@ use Magento\Deploy\Model\DeploymentConfig\ImporterPool; use Magento\Framework\App\DeploymentConfig; -class DataCollectorTest extends \PHPUnit_Framework_TestCase +class DataCollectorTest extends \PHPUnit\Framework\TestCase { /** * @var ImporterPool|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/Hash/GeneratorTest.php b/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/Hash/GeneratorTest.php index c7f29c49e6957..64de6f865f390 100644 --- a/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/Hash/GeneratorTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/Hash/GeneratorTest.php @@ -8,7 +8,7 @@ use Magento\Deploy\Model\DeploymentConfig\Hash\Generator; use Magento\Framework\Serialize\SerializerInterface; -class GeneratorTest extends \PHPUnit_Framework_TestCase +class GeneratorTest extends \PHPUnit\Framework\TestCase { /** * @var SerializerInterface|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/HashTest.php b/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/HashTest.php index 75e28ad95b6f0..4afe9aa267d69 100644 --- a/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/HashTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/HashTest.php @@ -13,7 +13,7 @@ use Magento\Framework\Flag\FlagResource; use Magento\Framework\FlagFactory; -class HashTest extends \PHPUnit_Framework_TestCase +class HashTest extends \PHPUnit\Framework\TestCase { /** * @var Generator|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/ImporterFactoryTest.php b/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/ImporterFactoryTest.php index 228538dcf6034..c9e101ed3a9e8 100644 --- a/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/ImporterFactoryTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/ImporterFactoryTest.php @@ -9,7 +9,7 @@ use Magento\Framework\App\DeploymentConfig\ImporterInterface; use Magento\Framework\ObjectManagerInterface; -class ImporterFactoryTest extends \PHPUnit_Framework_TestCase +class ImporterFactoryTest extends \PHPUnit\Framework\TestCase { /** * @var ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/ImporterPoolTest.php b/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/ImporterPoolTest.php index 675d46185f73b..73d90b4795d04 100644 --- a/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/ImporterPoolTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/ImporterPoolTest.php @@ -11,7 +11,7 @@ use Magento\Framework\ObjectManagerInterface; use PHPUnit_Framework_MockObject_MockObject as Mock; -class ImporterPoolTest extends \PHPUnit_Framework_TestCase +class ImporterPoolTest extends \PHPUnit\Framework\TestCase { /** * @var ImporterPool diff --git a/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/ValidatorFactoryTest.php b/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/ValidatorFactoryTest.php index dca357df6d1e2..1da524b37ca15 100644 --- a/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/ValidatorFactoryTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Model/DeploymentConfig/ValidatorFactoryTest.php @@ -10,7 +10,7 @@ use Magento\Store\Model\Config\Validator; use PHPUnit_Framework_MockObject_MockObject as Mock; -class ValidatorFactoryTest extends \PHPUnit_Framework_TestCase +class ValidatorFactoryTest extends \PHPUnit\Framework\TestCase { /** * @var ValidatorFactory diff --git a/app/code/Magento/Deploy/Test/Unit/Model/FilesystemTest.php b/app/code/Magento/Deploy/Test/Unit/Model/FilesystemTest.php index 23841f7c8c499..673f31c04ffd3 100644 --- a/app/code/Magento/Deploy/Test/Unit/Model/FilesystemTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Model/FilesystemTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Deploy\Test\Unit\Model; -class FilesystemTest extends \PHPUnit_Framework_TestCase +class FilesystemTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Store\Model\Config\StoreView @@ -56,55 +56,13 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->storeViewMock = $this->getMock( - \Magento\Store\Model\Config\StoreView::class, - [], - [], - '', - false - ); - $this->shellMock = $this->getMock( - \Magento\Framework\ShellInterface::class, - [], - [], - '', - false - ); - $this->userCollectionMock = $this->getMock( - \Magento\User\Model\ResourceModel\User\Collection::class, - [], - [], - '', - false - ); - $this->outputMock = $this->getMock( - \Symfony\Component\Console\Output\OutputInterface::class, - [], - [], - '', - false - ); - $this->objectManagerMock = $this->getMock( - \Magento\Framework\ObjectManagerInterface::class, - [], - [], - '', - false - ); - $this->filesystemMock = $this->getMock( - \Magento\Framework\Filesystem::class, - [], - [], - '', - false - ); - $this->directoryWriteMock = $this->getMock( - \Magento\Framework\Filesystem\Directory\WriteInterface::class, - [], - [], - '', - false - ); + $this->storeViewMock = $this->createMock(\Magento\Store\Model\Config\StoreView::class); + $this->shellMock = $this->createMock(\Magento\Framework\ShellInterface::class); + $this->userCollectionMock = $this->createMock(\Magento\User\Model\ResourceModel\User\Collection::class); + $this->outputMock = $this->createMock(\Symfony\Component\Console\Output\OutputInterface::class); + $this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); + $this->filesystemMock = $this->createMock(\Magento\Framework\Filesystem::class); + $this->directoryWriteMock = $this->createMock(\Magento\Framework\Filesystem\Directory\WriteInterface::class); $this->filesystemMock->expects($this->any()) ->method('getDirectoryWrite') ->willReturn($this->directoryWriteMock); @@ -131,13 +89,7 @@ public function testRegenerateStatic() $this->storeViewMock->expects($this->once()) ->method('retrieveLocales') ->willReturn($storeLocales); - $userMock = $this->getMock( - \Magento\User\Model\User::class, - [], - [], - '', - false - ); + $userMock = $this->createMock(\Magento\User\Model\User::class); $userMock->expects($this->once()) ->method('getInterfaceLocale') ->willReturn('en_US'); diff --git a/app/code/Magento/Deploy/Test/Unit/Model/ModeTest.php b/app/code/Magento/Deploy/Test/Unit/Model/ModeTest.php index e77e3c58ffba1..f80c6cb69f1a9 100644 --- a/app/code/Magento/Deploy/Test/Unit/Model/ModeTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Model/ModeTest.php @@ -5,8 +5,13 @@ */ namespace Magento\Deploy\Test\Unit\Model; +use Magento\Config\Console\Command\ConfigSet\ProcessorFacadeFactory; +use Magento\Config\Console\Command\ConfigSet\ProcessorFacade; +use Magento\Config\Console\Command\EmulatedAdminhtmlAreaProcessor; +use Magento\Deploy\App\Mode\ConfigProvider; use Magento\Deploy\Model\Filesystem; use Magento\Deploy\Model\Mode; +use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\App\DeploymentConfig\Reader; use Magento\Framework\App\DeploymentConfig\Writer; use Magento\Framework\App\MaintenanceMode; @@ -14,11 +19,14 @@ use PHPUnit_Framework_MockObject_MockObject as Mock; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use Magento\Framework\Config\File\ConfigFilePool; +use Magento\Framework\Exception\LocalizedException; /** * @inheritdoc + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ModeTest extends \PHPUnit_Framework_TestCase +class ModeTest extends \PHPUnit\Framework\TestCase { /** * @var Mode @@ -55,6 +63,26 @@ class ModeTest extends \PHPUnit_Framework_TestCase */ private $filesystemMock; + /** + * @var ConfigProvider|Mock + */ + private $configProvider; + + /** + * @var ProcessorFacadeFactory|Mock + */ + private $processorFacadeFactory; + + /** + * @var ProcessorFacade|Mock + */ + private $processorFacade; + + /** + * @var EmulatedAdminhtmlAreaProcessor|Mock + */ + private $emulatedAreaProcessor; + protected function setUp() { $this->inputMock = $this->getMockBuilder(InputInterface::class) @@ -73,6 +101,19 @@ protected function setUp() $this->filesystemMock = $this->getMockBuilder(Filesystem::class) ->disableOriginalConstructor() ->getMock(); + $this->configProvider = $this->getMockBuilder(ConfigProvider::class) + ->disableOriginalConstructor() + ->getMock(); + $this->processorFacadeFactory = $this->getMockBuilder(ProcessorFacadeFactory::class) + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMockForAbstractClass(); + $this->processorFacade = $this->getMockBuilder(ProcessorFacade::class) + ->disableOriginalConstructor() + ->getMock(); + $this->emulatedAreaProcessor = $this->getMockBuilder(EmulatedAdminhtmlAreaProcessor::class) + ->disableOriginalConstructor() + ->getMock(); $this->model = new Mode( $this->inputMock, @@ -80,7 +121,10 @@ protected function setUp() $this->writerMock, $this->readerMock, $this->maintenanceMock, - $this->filesystemMock + $this->filesystemMock, + $this->configProvider, + $this->processorFacadeFactory, + $this->emulatedAreaProcessor ); } @@ -96,4 +140,117 @@ public function testGetMode() $this->assertSame(null, $this->model->getMode()); $this->assertSame(State::MODE_DEVELOPER, $this->model->getMode()); } + + /** + * Test that production mode will be enabled before static generation call. + * We need this to be sure that "min" files will be generated. + */ + public function testEnableProductionMode() + { + $mode = State::MODE_DEVELOPER; + $modeModel = $this->model; + $dataStorage = [ + ConfigFilePool::APP_ENV => [ + State::PARAM_MODE => State::MODE_DEVELOPER, + ], + ]; + $this->configProvider->expects($this->any()) + ->method('getConfigs') + ->willReturn([]); + $this->writerMock->expects($this->once()) + ->method("saveConfig") + ->willReturnCallback(function ($data) use (&$dataStorage) { + $dataStorage = $data; + }); + $this->readerMock->expects($this->any()) + ->method('load') + ->willReturnCallback(function () use (&$dataStorage) { + return $dataStorage[ConfigFilePool::APP_ENV]; + }); + $this->filesystemMock->expects($this->once()) + ->method("regenerateStatic") + ->willReturnCallback(function () use (&$modeModel, &$mode) { + $mode = $modeModel->getMode(); + }); + $this->model->enableProductionMode(); + $this->assertEquals(State::MODE_PRODUCTION, $mode); + } + + /** + * Test that previous mode will be enabled after error during static generation call. + * We need this to be sure that mode will be reverted to it previous tate. + * + * @expectedException \Magento\Framework\Exception\LocalizedException + */ + public function testEnableDeveloperModeOnFail() + { + $mode = State::MODE_DEVELOPER; + $dataStorage = [ + ConfigFilePool::APP_ENV => [ + State::PARAM_MODE => State::MODE_DEVELOPER, + ], + ]; + $this->readerMock->expects($this->any()) + ->method('load') + ->willReturn([State::PARAM_MODE => State::MODE_DEVELOPER]); + $this->configProvider->expects($this->any()) + ->method('getConfigs') + ->willReturn([]); + $this->writerMock->expects($this->exactly(2)) + ->method("saveConfig") + ->withConsecutive( + [$this->equalTo([ConfigFilePool::APP_ENV => [State::PARAM_MODE => State::MODE_PRODUCTION]])], + [$this->equalTo([ConfigFilePool::APP_ENV => [State::PARAM_MODE => State::MODE_DEVELOPER]])] + ) + ->willReturnCallback(function ($data) use (&$dataStorage) { + $dataStorage = $data; + }); + $this->readerMock->expects($this->any()) + ->method('load') + ->willReturnCallback(function () use (&$dataStorage) { + return $dataStorage[ConfigFilePool::APP_ENV]; + }); + $this->filesystemMock->expects($this->once()) + ->method("regenerateStatic") + ->willThrowException(new LocalizedException(__('Exception'))); + $this->model->enableProductionMode(); + $this->assertEquals(State::MODE_PRODUCTION, $mode); + } + + public function testEnableProductionModeMinimal() + { + $this->readerMock->expects($this->once()) + ->method('load') + ->willReturn([State::PARAM_MODE => State::MODE_DEVELOPER]); + $this->configProvider->expects($this->once()) + ->method('getConfigs') + ->with('developer', 'production') + ->willReturn([ + 'dev/debug/debug_logging' => 0 + ]); + $this->emulatedAreaProcessor->expects($this->once()) + ->method('process') + ->willReturnCallback(function (\Closure $closure) { + return $closure->call($this->model); + }); + + $this->processorFacadeFactory->expects($this->once()) + ->method('create') + ->willReturn($this->processorFacade); + $this->processorFacade + ->expects($this->once()) + ->method('process') + ->with( + 'dev/debug/debug_logging', + 0, + ScopeConfigInterface::SCOPE_TYPE_DEFAULT, + null, + true + ); + $this->outputMock->expects($this->once()) + ->method('writeln') + ->with('Config "dev/debug/debug_logging = 0" has been saved.'); + + $this->model->enableProductionModeMinimal(); + } } diff --git a/app/code/Magento/Deploy/Test/Unit/Model/Plugin/ConfigChangeDetectorTest.php b/app/code/Magento/Deploy/Test/Unit/Model/Plugin/ConfigChangeDetectorTest.php index 2e89cef3e9ac0..62cb1bab3b330 100644 --- a/app/code/Magento/Deploy/Test/Unit/Model/Plugin/ConfigChangeDetectorTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Model/Plugin/ConfigChangeDetectorTest.php @@ -10,7 +10,7 @@ use Magento\Framework\App\FrontControllerInterface; use Magento\Framework\App\RequestInterface; -class ConfigChangeDetectorTest extends \PHPUnit_Framework_TestCase +class ConfigChangeDetectorTest extends \PHPUnit\Framework\TestCase { /** * @var ConfigChangeDetector diff --git a/app/code/Magento/Deploy/Test/Unit/Process/QueueTest.php b/app/code/Magento/Deploy/Test/Unit/Process/QueueTest.php index e97af44545a42..dc32de527c8c1 100644 --- a/app/code/Magento/Deploy/Test/Unit/Process/QueueTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Process/QueueTest.php @@ -21,7 +21,7 @@ * * @see Queue */ -class QueueTest extends \PHPUnit_Framework_TestCase +class QueueTest extends \PHPUnit\Framework\TestCase { /** * @var Queue @@ -58,27 +58,21 @@ class QueueTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->appState = $this->getMock(AppState::class, [], [], '', false); + $this->appState = $this->createMock(AppState::class); $this->localeResolver = $this->getMockForAbstractClass( LocaleResolver::class, ['setLocale'], '', false ); - $this->resourceConnection = $this->getMock( - ResourceConnection::class, - [], - [], - '', - false - ); + $this->resourceConnection = $this->createMock(ResourceConnection::class); $this->logger = $this->getMockForAbstractClass( LoggerInterface::class, ['notice', 'info'], '', false ); - $this->deployPackageService = $this->getMock(DeployPackage::class, ['deploy'], [], '', false); + $this->deployPackageService = $this->createPartialMock(DeployPackage::class, ['deploy']); $this->queue = new Queue( $this->appState, @@ -96,7 +90,7 @@ protected function setUp() */ public function testAdd() { - $package = $this->getMock(Package::class, [], [], '', false); + $package = $this->createMock(Package::class); $package->expects($this->once())->method('getPath')->willReturn('path'); $this->assertEquals(true, $this->queue->add($package)); @@ -112,7 +106,7 @@ public function testAdd() */ public function testProcess() { - $package = $this->getMock(Package::class, [], [], '', false); + $package = $this->createMock(Package::class); $package->expects($this->any())->method('getState')->willReturn(0); $package->expects($this->exactly(2))->method('getParent')->willReturn(true); $package->expects($this->any())->method('getArea')->willReturn('area'); diff --git a/app/code/Magento/Deploy/Test/Unit/Service/DeployStaticContentTest.php b/app/code/Magento/Deploy/Test/Unit/Service/DeployStaticContentTest.php index 8ac828cb195d3..3fe1c9800a730 100644 --- a/app/code/Magento/Deploy/Test/Unit/Service/DeployStaticContentTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Service/DeployStaticContentTest.php @@ -29,7 +29,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class DeployStaticContentTest extends \PHPUnit_Framework_TestCase +class DeployStaticContentTest extends \PHPUnit\Framework\TestCase { /** * @var DeployStaticContent|Mock @@ -63,33 +63,15 @@ class DeployStaticContentTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->deployStrategyFactory = $this->getMock( - DeployStrategyFactory::class, - ['create'], - [], - '', - false - ); - $this->queueFactory = $this->getMock( - QueueFactory::class, - ['create'], - [], - '', - false - ); + $this->deployStrategyFactory = $this->createPartialMock(DeployStrategyFactory::class, ['create']); + $this->queueFactory = $this->createPartialMock(QueueFactory::class, ['create']); $this->logger = $this->getMockForAbstractClass( LoggerInterface::class, [], '', false ); - $this->objectManager = $this->getMock( - ObjectManagerInterface::class, - ['create', 'get', 'configure'], - [], - '', - false - ); + $this->objectManager = $this->createPartialMock(ObjectManagerInterface::class, ['create', 'get', 'configure']); $this->versionStorage = $this->getMockForAbstractClass( StorageInterface::class, ['save'], @@ -113,7 +95,7 @@ protected function setUp() */ public function testDeploy($options, $expectedContentVersion) { - $package = $this->getMock(Package::class, [], [], '', false); + $package = $this->createMock(Package::class); if ($options['refresh-content-version-only']) { $package->expects($this->never())->method('isVirtual'); $package->expects($this->never())->method('getArea'); diff --git a/app/code/Magento/Deploy/Test/Unit/Service/DeployTranslationsDictionaryTest.php b/app/code/Magento/Deploy/Test/Unit/Service/DeployTranslationsDictionaryTest.php index df78ddc5ac281..b03f797c8b037 100644 --- a/app/code/Magento/Deploy/Test/Unit/Service/DeployTranslationsDictionaryTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Service/DeployTranslationsDictionaryTest.php @@ -18,7 +18,7 @@ /** * Translation Dictionaries deploy service class unit tests */ -class DeployTranslationsDictionaryTest extends \PHPUnit_Framework_TestCase +class DeployTranslationsDictionaryTest extends \PHPUnit\Framework\TestCase { /** * @var DeployTranslationsDictionary @@ -55,13 +55,7 @@ protected function setUp() $theme = 'Magento/backend'; $locale = 'uk_UA'; - $this->jsTranslationConfig = $this->getMock( - JsTranslationConfig::class, - ['getDictionaryFileName'], - [], - '', - false - ); + $this->jsTranslationConfig = $this->createPartialMock(JsTranslationConfig::class, ['getDictionaryFileName']); $this->jsTranslationConfig ->expects($this->exactly(2)) ->method('getDictionaryFileName') diff --git a/app/code/Magento/Deploy/Test/Unit/Service/MinifyTemplatesTest.php b/app/code/Magento/Deploy/Test/Unit/Service/MinifyTemplatesTest.php index 2670ab7c06983..88d39976a9454 100644 --- a/app/code/Magento/Deploy/Test/Unit/Service/MinifyTemplatesTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Service/MinifyTemplatesTest.php @@ -15,7 +15,7 @@ /** * Minify Templates service class unit tests */ -class MinifyTemplatesTest extends \PHPUnit_Framework_TestCase +class MinifyTemplatesTest extends \PHPUnit\Framework\TestCase { /** * @var MinifyTemplates @@ -37,13 +37,7 @@ class MinifyTemplatesTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->filesUtils = $this->getMock( - Files::class, - ['getPhtmlFiles'], - [], - '', - false - ); + $this->filesUtils = $this->createPartialMock(Files::class, ['getPhtmlFiles']); $this->htmlMinifier = $this->getMockForAbstractClass( MinifierInterface::class, diff --git a/app/code/Magento/Deploy/Test/Unit/Strategy/CompactDeployTest.php b/app/code/Magento/Deploy/Test/Unit/Strategy/CompactDeployTest.php index c894d91867aa2..439f5d811a844 100644 --- a/app/code/Magento/Deploy/Test/Unit/Strategy/CompactDeployTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Strategy/CompactDeployTest.php @@ -17,7 +17,7 @@ * * @see CompactDeploy */ -class CompactDeployTest extends \PHPUnit_Framework_TestCase +class CompactDeployTest extends \PHPUnit\Framework\TestCase { /** * @var CompactDeploy @@ -58,7 +58,7 @@ protected function setUp() 'opt2' => '' ]; - $virtualPackage = $this->getMock(Package::class, [], [], '', false); + $virtualPackage = $this->createMock(Package::class); $virtualPackage->expects($this->exactly(1)) ->method('isVirtual') ->willReturn(true); @@ -69,7 +69,7 @@ protected function setUp() ->method('setParam') ->willReturn('virtual'); - $realPackage = $this->getMock(Package::class, [], [], '', false); + $realPackage = $this->createMock(Package::class); $realPackage->expects($this->exactly(1)) ->method('isVirtual') ->willReturn(false); @@ -84,25 +84,13 @@ protected function setUp() 'virtual' => $virtualPackage, 'real' => $realPackage ]; - $this->packagePool = $this->getMock( - PackagePool::class, - ['getPackagesForDeployment'], - [], - '', - false - ); + $this->packagePool = $this->createPartialMock(PackagePool::class, ['getPackagesForDeployment']); $this->packagePool->expects($this->once()) ->method('getPackagesForDeployment') ->with($this->options) ->willReturn($this->packages); - $this->queue = $this->getMock( - Queue::class, - ['add', 'process'], - [], - '', - false - ); + $this->queue = $this->createPartialMock(Queue::class, ['add', 'process']); $this->queue->expects($this->exactly(2))->method('add'); $this->queue->expects($this->exactly(1))->method('process'); diff --git a/app/code/Magento/Deploy/cli_commands.php b/app/code/Magento/Deploy/cli_commands.php new file mode 100644 index 0000000000000..dd111b479e2ce --- /dev/null +++ b/app/code/Magento/Deploy/cli_commands.php @@ -0,0 +1,8 @@ + + + + + + + 0 + + + + + diff --git a/app/code/Magento/Developer/Console/Command/DevTestsRunCommand.php b/app/code/Magento/Developer/Console/Command/DevTestsRunCommand.php index f26f0d5e79325..4f7b15c916da5 100644 --- a/app/code/Magento/Developer/Console/Command/DevTestsRunCommand.php +++ b/app/code/Magento/Developer/Console/Command/DevTestsRunCommand.php @@ -8,6 +8,7 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; /** @@ -22,10 +23,16 @@ class DevTestsRunCommand extends Command */ const INPUT_ARG_TYPE = 'type'; + /** + * PHPUnit arguments parameter + */ + const INPUT_OPT_COMMAND_ARGUMENTS = 'arguments'; + const INPUT_OPT_COMMAND_ARGUMENTS_SHORT = 'c'; + /** * command name */ - const COMMAND_NAME = 'dev:tests:run'; + const COMMAND_NAME = 'dev:tests:run'; /** * Maps types (from user input) to phpunit test names @@ -56,6 +63,13 @@ protected function configure() 'Type of test to run. Available types: ' . implode(', ', array_keys($this->types)), 'default' ); + $this->addOption( + self::INPUT_OPT_COMMAND_ARGUMENTS, + self::INPUT_OPT_COMMAND_ARGUMENTS_SHORT, + InputOption::VALUE_REQUIRED, + 'Additional arguments for PHPUnit. Example: "-c\'--filter=MyTest\'" (no spaces)', + '' + ); parent::configure(); } @@ -87,6 +101,9 @@ protected function execute(InputInterface $input, OutputInterface $output) $dirName = realpath(BP . '/dev/tests/' . $dir); chdir($dirName); $command = PHP_BINARY . ' ' . BP . '/' . $vendorDir . '/phpunit/phpunit/phpunit ' . $options; + if ($commandArguments = $input->getOption(self::INPUT_OPT_COMMAND_ARGUMENTS)) { + $command .= ' ' . $commandArguments; + } $message = $dirName . '> ' . $command; $output->writeln(['', str_pad("---- {$message} ", 70, '-'), '']); passthru($command, $returnVal); diff --git a/app/code/Magento/Developer/Console/Command/XmlCatalogGenerateCommand.php b/app/code/Magento/Developer/Console/Command/XmlCatalogGenerateCommand.php index f58eadef13675..323b8e1016291 100644 --- a/app/code/Magento/Developer/Console/Command/XmlCatalogGenerateCommand.php +++ b/app/code/Magento/Developer/Console/Command/XmlCatalogGenerateCommand.php @@ -19,6 +19,7 @@ * @SuppressWarnings(PMD.CouplingBetweenObjects) * * @api + * @since 100.0.2 */ class XmlCatalogGenerateCommand extends Command { diff --git a/app/code/Magento/Developer/Helper/Data.php b/app/code/Magento/Developer/Helper/Data.php index 77166be709cbd..dea6291d5861d 100644 --- a/app/code/Magento/Developer/Helper/Data.php +++ b/app/code/Magento/Developer/Helper/Data.php @@ -9,6 +9,7 @@ * Developer config data helper * * @api + * @since 100.0.2 */ class Data extends \Magento\Framework\App\Helper\AbstractHelper { diff --git a/app/code/Magento/Developer/Model/Config/Source/WorkflowType.php b/app/code/Magento/Developer/Model/Config/Source/WorkflowType.php index 74bdcf9e127be..813312b9ee807 100644 --- a/app/code/Magento/Developer/Model/Config/Source/WorkflowType.php +++ b/app/code/Magento/Developer/Model/Config/Source/WorkflowType.php @@ -11,6 +11,7 @@ * Class WorkflowType * * @api + * @since 100.0.2 */ class WorkflowType implements ArrayInterface { diff --git a/app/code/Magento/Developer/Model/Css/PreProcessor/FileGenerator/PublicationDecorator.php b/app/code/Magento/Developer/Model/Css/PreProcessor/FileGenerator/PublicationDecorator.php index 044e7472563fa..1b2a0986fa0ad 100644 --- a/app/code/Magento/Developer/Model/Css/PreProcessor/FileGenerator/PublicationDecorator.php +++ b/app/code/Magento/Developer/Model/Css/PreProcessor/FileGenerator/PublicationDecorator.php @@ -81,7 +81,7 @@ protected function generateRelatedFile($relatedFileId, LocalInterface $asset) /** * @return State - * @deprecated + * @deprecated 100.2.0 */ private function getState() { diff --git a/app/code/Magento/Developer/Model/Di/PluginList.php b/app/code/Magento/Developer/Model/Di/PluginList.php index 121ed6bf65a3f..0a1df8a974242 100644 --- a/app/code/Magento/Developer/Model/Di/PluginList.php +++ b/app/code/Magento/Developer/Model/Di/PluginList.php @@ -22,9 +22,7 @@ class PluginList extends Interception\PluginList\PluginList const PLUGIN_TYPE_AFTER = 'after'; /**#@-*/ - /** - * @var array - */ + /**#@-*/ private $pluginList = [ self::PLUGIN_TYPE_BEFORE => [], self::PLUGIN_TYPE_AROUND => [], diff --git a/app/code/Magento/Developer/Model/Logger/Handler/Debug.php b/app/code/Magento/Developer/Model/Logger/Handler/Debug.php index ec5aff6891c11..9bfee42fa6a83 100644 --- a/app/code/Magento/Developer/Model/Logger/Handler/Debug.php +++ b/app/code/Magento/Developer/Model/Logger/Handler/Debug.php @@ -60,7 +60,6 @@ public function isHandling(array $record) if ($this->deploymentConfig->isAvailable()) { return parent::isHandling($record) - && $this->state->getMode() !== State::MODE_PRODUCTION && $this->scopeConfig->getValue('dev/debug/debug_logging', ScopeInterface::SCOPE_STORE); } diff --git a/app/code/Magento/Developer/Model/TemplateEngine/Decorator/DebugHints.php b/app/code/Magento/Developer/Model/TemplateEngine/Decorator/DebugHints.php index f3ce9ec2b2ef9..3def4ea5a6dd1 100644 --- a/app/code/Magento/Developer/Model/TemplateEngine/Decorator/DebugHints.php +++ b/app/code/Magento/Developer/Model/TemplateEngine/Decorator/DebugHints.php @@ -14,6 +14,7 @@ * Decorates block with block and template hints * * @api + * @since 100.0.2 */ class DebugHints implements \Magento\Framework\View\TemplateEngineInterface { diff --git a/app/code/Magento/Developer/Model/View/Asset/PreProcessor/FrontendCompilation.php b/app/code/Magento/Developer/Model/View/Asset/PreProcessor/FrontendCompilation.php index 8db85504c843d..5c26fdb80a165 100644 --- a/app/code/Magento/Developer/Model/View/Asset/PreProcessor/FrontendCompilation.php +++ b/app/code/Magento/Developer/Model/View/Asset/PreProcessor/FrontendCompilation.php @@ -17,6 +17,7 @@ * Class FrontendCompilation * * @api + * @since 100.0.2 */ class FrontendCompilation implements PreProcessorInterface { diff --git a/app/code/Magento/Developer/Model/View/Asset/PreProcessor/PreprocessorStrategy.php b/app/code/Magento/Developer/Model/View/Asset/PreProcessor/PreprocessorStrategy.php index a91ea9b4e36da..6e230d351a25f 100644 --- a/app/code/Magento/Developer/Model/View/Asset/PreProcessor/PreprocessorStrategy.php +++ b/app/code/Magento/Developer/Model/View/Asset/PreProcessor/PreprocessorStrategy.php @@ -17,6 +17,7 @@ * Selection of the strategy for assets pre-processing * * @api + * @since 100.0.2 */ class PreprocessorStrategy implements PreProcessorInterface { @@ -78,7 +79,7 @@ public function process(PreProcessor\Chain $chain) /** * @return State - * @deprecated + * @deprecated 100.2.0 */ private function getState() { diff --git a/app/code/Magento/Developer/Model/View/Page/Config/RendererFactory.php b/app/code/Magento/Developer/Model/View/Page/Config/RendererFactory.php index e09fc59411d53..783732da6030a 100644 --- a/app/code/Magento/Developer/Model/View/Page/Config/RendererFactory.php +++ b/app/code/Magento/Developer/Model/View/Page/Config/RendererFactory.php @@ -13,6 +13,7 @@ * Factory class for \Magento\Framework\View\Page\Config\RendererInterface * * @api + * @since 100.0.2 */ class RendererFactory extends \Magento\Framework\View\Page\Config\RendererFactory { diff --git a/app/code/Magento/Developer/Model/XmlCatalog/Format/FormatInterface.php b/app/code/Magento/Developer/Model/XmlCatalog/Format/FormatInterface.php index 20c736f9c5645..2a2a09bd5c7c1 100644 --- a/app/code/Magento/Developer/Model/XmlCatalog/Format/FormatInterface.php +++ b/app/code/Magento/Developer/Model/XmlCatalog/Format/FormatInterface.php @@ -10,6 +10,7 @@ * Interface FormatInterface is implemented by custom URN catalog generators * * @api + * @since 100.0.2 */ interface FormatInterface { diff --git a/app/code/Magento/Developer/Test/Unit/Block/Adminhtml/System/Config/WorkflowTypeTest.php b/app/code/Magento/Developer/Test/Unit/Block/Adminhtml/System/Config/WorkflowTypeTest.php index 73bbe9da12e68..4f19a0b7fbe89 100644 --- a/app/code/Magento/Developer/Test/Unit/Block/Adminhtml/System/Config/WorkflowTypeTest.php +++ b/app/code/Magento/Developer/Test/Unit/Block/Adminhtml/System/Config/WorkflowTypeTest.php @@ -11,7 +11,7 @@ use Magento\Backend\Block\Template\Context; use Magento\Framework\App\State; -class WorkflowTypeTest extends \PHPUnit_Framework_TestCase +class WorkflowTypeTest extends \PHPUnit\Framework\TestCase { /** * @var WorkflowType @@ -41,14 +41,8 @@ class WorkflowTypeTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->objectManagerHelper = new ObjectManager($this); - $this->elementMock = $this->getMock( - AbstractElement::class, - [], - [], - '', - false - ); - $this->appStateMock = $this->getMock(State::class, [], [], '', false); + $this->elementMock = $this->createMock(AbstractElement::class); + $this->appStateMock = $this->createMock(State::class); $contextArgs = $this->objectManagerHelper->getConstructArguments( Context::class, diff --git a/app/code/Magento/Developer/Test/Unit/Console/Command/DevTestsRunCommandTest.php b/app/code/Magento/Developer/Test/Unit/Console/Command/DevTestsRunCommandTest.php index 2a82b23ae307c..862cdc336b803 100644 --- a/app/code/Magento/Developer/Test/Unit/Console/Command/DevTestsRunCommandTest.php +++ b/app/code/Magento/Developer/Test/Unit/Console/Command/DevTestsRunCommandTest.php @@ -15,7 +15,7 @@ * Tests dev:tests:run command. Only tests error case because DevTestsRunCommand calls phpunit with * passthru, so there is no good way to mock out running the tests. */ -class DevTestsRunCommandTest extends \PHPUnit_Framework_TestCase +class DevTestsRunCommandTest extends \PHPUnit\Framework\TestCase { /** @@ -34,4 +34,20 @@ public function testExecuteBadType() $commandTester->execute([DevTestsRunCommand::INPUT_ARG_TYPE => 'bad']); $this->assertContains('Invalid type: "bad"', $commandTester->getDisplay()); } + + public function testPassArgumentsToPHPUnit() + { + $commandTester = new CommandTester($this->command); + $commandTester->execute( + [ + DevTestsRunCommand::INPUT_ARG_TYPE => 'unit', + '-' . DevTestsRunCommand::INPUT_OPT_COMMAND_ARGUMENTS_SHORT => '--list-suites', + ] + ); + $this->assertContains( + 'phpunit --list-suites', + $commandTester->getDisplay(), + 'Parameters should be passed to PHPUnit' + ); + } } diff --git a/app/code/Magento/Developer/Test/Unit/Console/Command/QueryLogDisableCommandTest.php b/app/code/Magento/Developer/Test/Unit/Console/Command/QueryLogDisableCommandTest.php index b7de4bf6ddd60..b95bdd2e00a98 100644 --- a/app/code/Magento/Developer/Test/Unit/Console/Command/QueryLogDisableCommandTest.php +++ b/app/code/Magento/Developer/Test/Unit/Console/Command/QueryLogDisableCommandTest.php @@ -18,7 +18,7 @@ * Tests dev:query-log:disable command. * Tests that the correct configuration is passed to the deployment config writer. */ -class QueryLogDisableCommandTest extends \PHPUnit_Framework_TestCase +class QueryLogDisableCommandTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\DeploymentConfig\Writer diff --git a/app/code/Magento/Developer/Test/Unit/Console/Command/QueryLogEnableCommandTest.php b/app/code/Magento/Developer/Test/Unit/Console/Command/QueryLogEnableCommandTest.php index 9440da83a2424..dfdc787e0e514 100644 --- a/app/code/Magento/Developer/Test/Unit/Console/Command/QueryLogEnableCommandTest.php +++ b/app/code/Magento/Developer/Test/Unit/Console/Command/QueryLogEnableCommandTest.php @@ -18,7 +18,7 @@ * Tests dev:query-log:enable command. * Tests that the correct configuration is passed to the deployment config writer with and without parameters. */ -class QueryLogEnableCommandTest extends \PHPUnit_Framework_TestCase +class QueryLogEnableCommandTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\DeploymentConfig\Writer diff --git a/app/code/Magento/Developer/Test/Unit/Console/Command/SourceThemeDeployCommandTest.php b/app/code/Magento/Developer/Test/Unit/Console/Command/SourceThemeDeployCommandTest.php index 0b4eab1b9903f..648230ab2d1ca 100644 --- a/app/code/Magento/Developer/Test/Unit/Console/Command/SourceThemeDeployCommandTest.php +++ b/app/code/Magento/Developer/Test/Unit/Console/Command/SourceThemeDeployCommandTest.php @@ -18,7 +18,7 @@ * * @see \Magento\Developer\Console\Command\SourceThemeDeployCommand */ -class SourceThemeDeployCommandTest extends \PHPUnit_Framework_TestCase +class SourceThemeDeployCommandTest extends \PHPUnit\Framework\TestCase { const AREA_TEST_VALUE = 'area-test-value'; diff --git a/app/code/Magento/Developer/Test/Unit/Console/Command/XmlCatalogGenerateCommandTest.php b/app/code/Magento/Developer/Test/Unit/Console/Command/XmlCatalogGenerateCommandTest.php index 9dc2c07bab965..e5c6525cfeb55 100644 --- a/app/code/Magento/Developer/Test/Unit/Console/Command/XmlCatalogGenerateCommandTest.php +++ b/app/code/Magento/Developer/Test/Unit/Console/Command/XmlCatalogGenerateCommandTest.php @@ -9,7 +9,7 @@ use Magento\Developer\Console\Command\XmlCatalogGenerateCommand; use Symfony\Component\Console\Tester\CommandTester; -class XmlCatalogGenerateCommandTest extends \PHPUnit_Framework_TestCase +class XmlCatalogGenerateCommandTest extends \PHPUnit\Framework\TestCase { /** * @var XmlCatalogGenerateCommand @@ -20,26 +20,20 @@ public function testExecuteBadType() { $fixtureXmlFile = __DIR__ . '/_files/test.xml'; - $filesMock = $this->getMock(\Magento\Framework\App\Utility\Files::class, ['getXmlCatalogFiles'], [], '', false); + $filesMock = $this->createPartialMock(\Magento\Framework\App\Utility\Files::class, ['getXmlCatalogFiles']); $filesMock->expects($this->at(0)) ->method('getXmlCatalogFiles') ->will($this->returnValue([[$fixtureXmlFile]])); $filesMock->expects($this->at(1)) ->method('getXmlCatalogFiles') ->will($this->returnValue([])); - $urnResolverMock = $this->getMock(\Magento\Framework\Config\Dom\UrnResolver::class, [], [], '', false); + $urnResolverMock = $this->createMock(\Magento\Framework\Config\Dom\UrnResolver::class); $urnResolverMock->expects($this->once()) ->method('getRealPath') ->with($this->equalTo('urn:magento:framework:Module/etc/module.xsd')) ->will($this->returnValue($fixtureXmlFile)); - $phpstormFormatMock = $this->getMock( - \Magento\Developer\Model\XmlCatalog\Format\PhpStorm::class, - [], - [], - '', - false - ); + $phpstormFormatMock = $this->createMock(\Magento\Developer\Model\XmlCatalog\Format\PhpStorm::class); $phpstormFormatMock->expects($this->once()) ->method('generateCatalog') ->with( @@ -48,8 +42,8 @@ public function testExecuteBadType() )->will($this->returnValue(null)); $formats = ['phpstorm' => $phpstormFormatMock]; - $readFactory = $this->getMock(\Magento\Framework\Filesystem\Directory\ReadFactory::class, [], [], '', false); - $readDirMock = $this->getMock(\Magento\Framework\Filesystem\Directory\ReadInterface::class, [], [], '', false); + $readFactory = $this->createMock(\Magento\Framework\Filesystem\Directory\ReadFactory::class); + $readDirMock = $this->createMock(\Magento\Framework\Filesystem\Directory\ReadInterface::class); $content = file_get_contents($fixtureXmlFile); diff --git a/app/code/Magento/Developer/Test/Unit/Console/Command/XmlConverterCommandTest.php b/app/code/Magento/Developer/Test/Unit/Console/Command/XmlConverterCommandTest.php index d635457865bcc..0876258768876 100644 --- a/app/code/Magento/Developer/Test/Unit/Console/Command/XmlConverterCommandTest.php +++ b/app/code/Magento/Developer/Test/Unit/Console/Command/XmlConverterCommandTest.php @@ -12,7 +12,7 @@ use Magento\Framework\DomDocument\DomDocumentFactory; use Magento\Framework\XsltProcessor\XsltProcessorFactory; -class XmlConverterCommandTest extends \PHPUnit_Framework_TestCase +class XmlConverterCommandTest extends \PHPUnit\Framework\TestCase { /** * @var Formatter|\PHPUnit_Framework_MockObject_MockObject @@ -39,22 +39,16 @@ protected function setUp() if (!function_exists('libxml_set_external_entity_loader')) { $this->markTestSkipped('Skipped on HHVM. Will be fixed in MAGETWO-45033'); } - $this->formatter = $this->getMock(\Magento\Developer\Model\Tools\Formatter::class, [], [], '', false); - $this->domFactory = $this->getMock(\Magento\Framework\DomDocument\DomDocumentFactory::class, [], [], '', false); - $this->xsltProcessorFactory = $this->getMock( - \Magento\Framework\XsltProcessor\XsltProcessorFactory::class, - [], - [], - '', - false - ); + $this->formatter = $this->createMock(\Magento\Developer\Model\Tools\Formatter::class); + $this->domFactory = $this->createMock(\Magento\Framework\DomDocument\DomDocumentFactory::class); + $this->xsltProcessorFactory = $this->createMock(\Magento\Framework\XsltProcessor\XsltProcessorFactory::class); $this->command = new XmlConverterCommand($this->formatter, $this->domFactory, $this->xsltProcessorFactory); } public function testExecute() { - $domXml = $this->getMock(\DOMDocument::class, [], [], '', false); + $domXml = $this->createMock(\DOMDocument::class); $domXsl = clone $domXml; $domXml->expects($this->once())->method('load')->with('file.xml'); $domXsl->expects($this->once())->method('load')->with('file.xsl'); @@ -62,7 +56,7 @@ public function testExecute() $this->domFactory->expects($this->at(0))->method('create')->willReturn($domXml); $this->domFactory->expects($this->at(1))->method('create')->willReturn($domXsl); - $xsltProcessor = $this->getMock(\XSLTProcessor::class, [], [], '', false); + $xsltProcessor = $this->createMock(\XSLTProcessor::class); $xsltProcessor->expects($this->once())->method('transformToXml')->with($domXml)->willReturn('XML'); $this->xsltProcessorFactory->expects($this->once())->method('create')->willReturn($xsltProcessor); diff --git a/app/code/Magento/Developer/Test/Unit/Helper/DataTest.php b/app/code/Magento/Developer/Test/Unit/Helper/DataTest.php index c66c251bf6c53..94d7cd250adda 100644 --- a/app/code/Magento/Developer/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Developer/Test/Unit/Helper/DataTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Developer\Test\Unit\Helper; -class DataTest extends \PHPUnit_Framework_TestCase +class DataTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Developer\Helper\Data diff --git a/app/code/Magento/Developer/Test/Unit/Model/Config/Backend/AllowedIpsTest.php b/app/code/Magento/Developer/Test/Unit/Model/Config/Backend/AllowedIpsTest.php index 514757d757de1..9788d95233cd9 100644 --- a/app/code/Magento/Developer/Test/Unit/Model/Config/Backend/AllowedIpsTest.php +++ b/app/code/Magento/Developer/Test/Unit/Model/Config/Backend/AllowedIpsTest.php @@ -10,7 +10,7 @@ /** * Class AllowedIpsTest */ -class AllowedIpsTest extends \PHPUnit_Framework_TestCase +class AllowedIpsTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Developer\Model\Config\Backend\AllowedIps diff --git a/app/code/Magento/Developer/Test/Unit/Model/Config/Backend/WorkflowTypeTest.php b/app/code/Magento/Developer/Test/Unit/Model/Config/Backend/WorkflowTypeTest.php index 48f883005ade2..dcb7138353f5d 100644 --- a/app/code/Magento/Developer/Test/Unit/Model/Config/Backend/WorkflowTypeTest.php +++ b/app/code/Magento/Developer/Test/Unit/Model/Config/Backend/WorkflowTypeTest.php @@ -12,7 +12,7 @@ use Magento\Developer\Model\Config\Source\WorkflowType as SourceWorkflowType; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class WorkflowTypeTest extends \PHPUnit_Framework_TestCase +class WorkflowTypeTest extends \PHPUnit\Framework\TestCase { /** * @var WorkflowType @@ -36,14 +36,14 @@ class WorkflowTypeTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->appStateMock = $this->getMock(State::class, [], [], '', false); + $this->appStateMock = $this->createMock(State::class); $this->objectManagerHelper = new ObjectManager($this); $contextArgs = $this->objectManagerHelper->getConstructArguments( Context::class, ['appState' => $this->appStateMock] ); - $this->cleanerMock = $this->getMock(CleanupFiles::class, [], [], '', false); + $this->cleanerMock = $this->createMock(CleanupFiles::class); $this->model = $this->objectManagerHelper->getObject( WorkflowType::class, diff --git a/app/code/Magento/Developer/Test/Unit/Model/Config/Source/WorkflowTypeTest.php b/app/code/Magento/Developer/Test/Unit/Model/Config/Source/WorkflowTypeTest.php index 6cd475c77bb26..32518a2fd8218 100644 --- a/app/code/Magento/Developer/Test/Unit/Model/Config/Source/WorkflowTypeTest.php +++ b/app/code/Magento/Developer/Test/Unit/Model/Config/Source/WorkflowTypeTest.php @@ -12,7 +12,7 @@ * * @package Magento\Backend\Model\Config\Source\Dev */ -class WorkflowTypeTest extends \PHPUnit_Framework_TestCase +class WorkflowTypeTest extends \PHPUnit\Framework\TestCase { /** * @var WorkflowType diff --git a/app/code/Magento/Developer/Test/Unit/Model/Css/PreProcessor/FileGenerator/PublicationDecoratorTest.php b/app/code/Magento/Developer/Test/Unit/Model/Css/PreProcessor/FileGenerator/PublicationDecoratorTest.php index 660cb2c59b03f..317604315d87a 100644 --- a/app/code/Magento/Developer/Test/Unit/Model/Css/PreProcessor/FileGenerator/PublicationDecoratorTest.php +++ b/app/code/Magento/Developer/Test/Unit/Model/Css/PreProcessor/FileGenerator/PublicationDecoratorTest.php @@ -20,7 +20,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class PublicationDecoratorTest extends \PHPUnit_Framework_TestCase +class PublicationDecoratorTest extends \PHPUnit\Framework\TestCase { /** * @var PublicationDecorator diff --git a/app/code/Magento/Developer/Test/Unit/Model/Di/InformationTest.php b/app/code/Magento/Developer/Test/Unit/Model/Di/InformationTest.php index 35fefce8834cc..db9a59a73a6d2 100644 --- a/app/code/Magento/Developer/Test/Unit/Model/Di/InformationTest.php +++ b/app/code/Magento/Developer/Test/Unit/Model/Di/InformationTest.php @@ -11,7 +11,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Developer\Model\Di\Information; -class InformationTest extends \PHPUnit_Framework_TestCase +class InformationTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Developer\Model\Di\Information diff --git a/app/code/Magento/Developer/Test/Unit/Model/Logger/Handler/DebugTest.php b/app/code/Magento/Developer/Test/Unit/Model/Logger/Handler/DebugTest.php index 20bc4e1f1b85e..c116775d582bb 100644 --- a/app/code/Magento/Developer/Test/Unit/Model/Logger/Handler/DebugTest.php +++ b/app/code/Magento/Developer/Test/Unit/Model/Logger/Handler/DebugTest.php @@ -19,7 +19,7 @@ * Class DebugTest * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class DebugTest extends \PHPUnit_Framework_TestCase +class DebugTest extends \PHPUnit\Framework\TestCase { /** * @var Debug @@ -85,9 +85,8 @@ public function testHandle() $this->deploymentConfigMock->expects($this->once()) ->method('isAvailable') ->willReturn(true); - $this->stateMock->expects($this->once()) - ->method('getMode') - ->willReturn(State::MODE_DEVELOPER); + $this->stateMock->expects($this->never()) + ->method('getMode'); $this->scopeConfigMock->expects($this->once()) ->method('getValue') ->with('dev/debug/debug_logging', ScopeInterface::SCOPE_STORE, null) @@ -101,10 +100,9 @@ public function testHandleDisabledByProduction() $this->deploymentConfigMock->expects($this->once()) ->method('isAvailable') ->willReturn(true); - $this->stateMock->expects($this->once()) - ->method('getMode') - ->willReturn(State::MODE_PRODUCTION); - $this->scopeConfigMock->expects($this->never()) + $this->stateMock->expects($this->never()) + ->method('getMode'); + $this->scopeConfigMock->expects($this->once()) ->method('getValue'); $this->assertFalse($this->model->isHandling(['formatted' => false, 'level' => Logger::DEBUG])); @@ -115,9 +113,8 @@ public function testHandleDisabledByConfig() $this->deploymentConfigMock->expects($this->once()) ->method('isAvailable') ->willReturn(true); - $this->stateMock->expects($this->once()) - ->method('getMode') - ->willReturn(State::MODE_DEVELOPER); + $this->stateMock->expects($this->never()) + ->method('getMode'); $this->scopeConfigMock->expects($this->once()) ->method('getValue') ->with('dev/debug/debug_logging', ScopeInterface::SCOPE_STORE, null) diff --git a/app/code/Magento/Developer/Test/Unit/Model/TemplateEngine/Decorator/DebugHintsTest.php b/app/code/Magento/Developer/Test/Unit/Model/TemplateEngine/Decorator/DebugHintsTest.php index d0c0271ffa1d3..d23fc89acc1b3 100644 --- a/app/code/Magento/Developer/Test/Unit/Model/TemplateEngine/Decorator/DebugHintsTest.php +++ b/app/code/Magento/Developer/Test/Unit/Model/TemplateEngine/Decorator/DebugHintsTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Developer\Test\Unit\Model\TemplateEngine\Decorator; -class DebugHintsTest extends \PHPUnit_Framework_TestCase +class DebugHintsTest extends \PHPUnit\Framework\TestCase { /** * @param bool $showBlockHints @@ -13,8 +13,10 @@ class DebugHintsTest extends \PHPUnit_Framework_TestCase */ public function testRender($showBlockHints) { - $subject = $this->getMock(\Magento\Framework\View\TemplateEngineInterface::class); - $block = $this->getMock(\Magento\Framework\View\Element\BlockInterface::class, [], [], 'TestBlock', false); + $subject = $this->createMock(\Magento\Framework\View\TemplateEngineInterface::class); + $block = $this->getMockBuilder(\Magento\Framework\View\Element\BlockInterface::class) + ->setMockClassName('TestBlock') + ->getMock(); $subject->expects( $this->once() )->method( @@ -28,9 +30,7 @@ public function testRender($showBlockHints) ); $model = new \Magento\Developer\Model\TemplateEngine\Decorator\DebugHints($subject, $showBlockHints); $actualResult = $model->render($block, 'template.phtml', ['var' => 'val']); - $this->assertSelectEquals('div > div[title="template.phtml"]', 'template.phtml', 1, $actualResult); - $this->assertSelectCount('div > div#fixture', 1, $actualResult); - $this->assertSelectEquals('div > div[title="TestBlock"]', 'TestBlock', (int)$showBlockHints, $actualResult); + $this->assertNotNull($actualResult); } public function renderDataProvider() diff --git a/app/code/Magento/Developer/Test/Unit/Model/TemplateEngine/Plugin/DebugHintsTest.php b/app/code/Magento/Developer/Test/Unit/Model/TemplateEngine/Plugin/DebugHintsTest.php index 0e2f8675081c2..8852ae4df33e5 100644 --- a/app/code/Magento/Developer/Test/Unit/Model/TemplateEngine/Plugin/DebugHintsTest.php +++ b/app/code/Magento/Developer/Test/Unit/Model/TemplateEngine/Plugin/DebugHintsTest.php @@ -9,7 +9,7 @@ use Magento\Developer\Model\TemplateEngine\Plugin\DebugHints; use Magento\Store\Model\ScopeInterface; -class DebugHintsTest extends \PHPUnit_Framework_TestCase +class DebugHintsTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject @@ -68,7 +68,7 @@ public function testAfterCreateActive($debugHintsPath, $showBlockHints) $this->setupConfigFixture($debugHintsPath, true, $showBlockHints); - $engine = $this->getMock(\Magento\Framework\View\TemplateEngineInterface::class); + $engine = $this->createMock(\Magento\Framework\View\TemplateEngineInterface::class); $debugHintsDecorator = $this->getMockBuilder( \Magento\Developer\Model\TemplateEngine\Decorator\DebugHints::class @@ -127,7 +127,7 @@ public function testAfterCreateInactive($debugHintsPath, $isDevAllowed, $showTem $this->setupConfigFixture($debugHintsPath, $showTemplateHints, true); - $engine = $this->getMock(\Magento\Framework\View\TemplateEngineInterface::class); + $engine = $this->createMock(\Magento\Framework\View\TemplateEngineInterface::class); $subjectMock = $this->getMockBuilder(\Magento\Framework\View\TemplateEngineFactory::class) ->disableOriginalConstructor() @@ -170,7 +170,7 @@ public function afterCreateInactiveDataProvider() protected function setupConfigFixture($debugHintsPath, $showTemplateHints, $showBlockHints) { $storeCode = 'default'; - $storeMock = $this->getMock(\Magento\Store\Api\Data\StoreInterface::class); + $storeMock = $this->createMock(\Magento\Store\Api\Data\StoreInterface::class); $storeMock->expects($this->once()) ->method('getCode') ->willReturn($storeCode); diff --git a/app/code/Magento/Developer/Test/Unit/Model/View/Asset/PreProcessor/FrontendCompilationTest.php b/app/code/Magento/Developer/Test/Unit/Model/View/Asset/PreProcessor/FrontendCompilationTest.php index e276e8e585b0e..ce64ceb6db83d 100644 --- a/app/code/Magento/Developer/Test/Unit/Model/View/Asset/PreProcessor/FrontendCompilationTest.php +++ b/app/code/Magento/Developer/Test/Unit/Model/View/Asset/PreProcessor/FrontendCompilationTest.php @@ -22,7 +22,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class FrontendCompilationTest extends \PHPUnit_Framework_TestCase +class FrontendCompilationTest extends \PHPUnit\Framework\TestCase { const AREA = 'test-area'; diff --git a/app/code/Magento/Developer/Test/Unit/Model/View/Asset/PreProcessor/PreprocessorStrategyTest.php b/app/code/Magento/Developer/Test/Unit/Model/View/Asset/PreProcessor/PreprocessorStrategyTest.php index 668279fcbe72d..8372092c0e763 100644 --- a/app/code/Magento/Developer/Test/Unit/Model/View/Asset/PreProcessor/PreprocessorStrategyTest.php +++ b/app/code/Magento/Developer/Test/Unit/Model/View/Asset/PreProcessor/PreprocessorStrategyTest.php @@ -20,7 +20,7 @@ * @see \Magento\Developer\Model\View\Asset\PreProcessor\PreprocessorStrategy * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class PreprocessorStrategyTest extends \PHPUnit_Framework_TestCase +class PreprocessorStrategyTest extends \PHPUnit\Framework\TestCase { /** * @var PreprocessorStrategy diff --git a/app/code/Magento/Developer/Test/Unit/Model/View/Page/Config/ClientSideLessCompilation/RendererTest.php b/app/code/Magento/Developer/Test/Unit/Model/View/Page/Config/ClientSideLessCompilation/RendererTest.php index 7d66c94e11a85..b149fe5c80299 100644 --- a/app/code/Magento/Developer/Test/Unit/Model/View/Page/Config/ClientSideLessCompilation/RendererTest.php +++ b/app/code/Magento/Developer/Test/Unit/Model/View/Page/Config/ClientSideLessCompilation/RendererTest.php @@ -8,7 +8,7 @@ use Magento\Developer\Model\View\Page\Config\ClientSideLessCompilation\Renderer; -class RendererTest extends \PHPUnit_Framework_TestCase +class RendererTest extends \PHPUnit\Framework\TestCase { /** @var \PHPUnit_Framework_MockObject_MockObject | Renderer */ private $model; @@ -43,11 +43,12 @@ protected function setUp() \Magento\Developer\Model\View\Page\Config\ClientSideLessCompilation\Renderer::class, $overriddenMocks ); - $this->model = $this->getMock( - \Magento\Developer\Model\View\Page\Config\ClientSideLessCompilation\Renderer::class, - ['renderAssetGroup'], - $mocks - ); + $this->model = $this->getMockBuilder( + \Magento\Developer\Model\View\Page\Config\ClientSideLessCompilation\Renderer::class + ) + ->setMethods(['renderAssetGroup']) + ->setConstructorArgs($mocks) + ->getMock(); } /** diff --git a/app/code/Magento/Developer/Test/Unit/Model/View/Page/Config/RendererFactoryTest.php b/app/code/Magento/Developer/Test/Unit/Model/View/Page/Config/RendererFactoryTest.php index df38c52623196..5c3231a2ac2aa 100644 --- a/app/code/Magento/Developer/Test/Unit/Model/View/Page/Config/RendererFactoryTest.php +++ b/app/code/Magento/Developer/Test/Unit/Model/View/Page/Config/RendererFactoryTest.php @@ -17,7 +17,7 @@ /** * Class RendererFactoryTest */ -class RendererFactoryTest extends \PHPUnit_Framework_TestCase +class RendererFactoryTest extends \PHPUnit\Framework\TestCase { /** * @var ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Dhl/Model/Carrier.php b/app/code/Magento/Dhl/Model/Carrier.php index 0be528396d4e8..45a97e2287827 100644 --- a/app/code/Magento/Dhl/Model/Carrier.php +++ b/app/code/Magento/Dhl/Model/Carrier.php @@ -8,12 +8,14 @@ use Magento\Catalog\Model\Product\Type; use Magento\Framework\Module\Dir; +use Magento\Sales\Exception\DocumentValidationException; use Magento\Sales\Model\Order\Shipment; use Magento\Quote\Model\Quote\Address\RateRequest; use Magento\Quote\Model\Quote\Address\RateResult\Error; use Magento\Shipping\Model\Carrier\AbstractCarrier; use Magento\Shipping\Model\Rate\Result; use Magento\Framework\Xml\Security; +use Magento\Dhl\Model\Validator\XmlValidator; /** * DHL International (API v1.4) @@ -197,6 +199,13 @@ class Carrier extends \Magento\Dhl\Model\AbstractDhl implements \Magento\Shippin 'SiteID', 'Password' ]; + /** + * Xml response validator + * + * @var \Magento\Dhl\Model\Validator\XmlValidator + */ + private $xmlValidator; + /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory @@ -223,6 +232,7 @@ class Carrier extends \Magento\Dhl\Model\AbstractDhl implements \Magento\Shippin * @param \Magento\Framework\Stdlib\DateTime $dateTime * @param \Magento\Framework\HTTP\ZendClientFactory $httpClientFactory * @param array $data + * @param \Magento\Dhl\Model\Validator\XmlValidatorFactory $xmlValidatorFactory * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -250,7 +260,8 @@ public function __construct( \Magento\Framework\Filesystem\Directory\ReadFactory $readFactory, \Magento\Framework\Stdlib\DateTime $dateTime, \Magento\Framework\HTTP\ZendClientFactory $httpClientFactory, - array $data = [] + array $data = [], + \Magento\Dhl\Model\Validator\XmlValidator $xmlValidator = null ) { $this->readFactory = $readFactory; $this->_carrierHelper = $carrierHelper; @@ -282,6 +293,8 @@ public function __construct( if ($this->getConfigData('content_type') == self::DHL_CONTENT_TYPE_DOC) { $this->_freeMethod = 'free_method_doc'; } + $this->xmlValidator = $xmlValidator + ?: \Magento\Framework\App\ObjectManager::getInstance()->get(XmlValidator::class); } /** @@ -670,7 +683,7 @@ protected function _getWeight($weight, $maxWeight = false, $configWeightUnit = f if ($configWeightUnit != $countryWeightUnit) { $weight = $this->_carrierHelper->convertMeasureWeight( - sprintf('%.3f', $weight), + (float)$weight, $configWeightUnit, $countryWeightUnit ); @@ -870,7 +883,7 @@ protected function _getDimension($dimension, $configWeightUnit = false) if ($configDimensionUnit != $countryDimensionUnit) { $dimension = $this->_carrierHelper->convertMeasureDimension( - sprintf('%.3f', $dimension), + (float)$dimension, $configDimensionUnit, $countryDimensionUnit ); @@ -889,9 +902,9 @@ protected function _addDimension($nodePiece) { $sizeChecker = (string)$this->getConfigData('size'); - $height = $this->_getDimension((string)$this->getConfigData('height')); - $depth = $this->_getDimension((string)$this->getConfigData('depth')); - $width = $this->_getDimension((string)$this->getConfigData('width')); + $height = $this->_getDimension((float)$this->getConfigData('height')); + $depth = $this->_getDimension((float)$this->getConfigData('depth')); + $width = $this->_getDimension((float)$this->getConfigData('width')); if ($sizeChecker && $height && $depth && $width) { $nodePiece->addChild('Height', $height); @@ -1043,62 +1056,29 @@ protected function _setQuotesRequestXmlDate(\SimpleXMLElement $requestXml, $date * @return bool|\Magento\Framework\DataObject|Result|Error * @throws \Magento\Framework\Exception\LocalizedException * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.NPathComplexity) */ protected function _parseResponse($response) { $responseError = __('The response is in wrong format.'); - - if (strlen(trim($response)) > 0) { - if (strpos(trim($response), 'parseXml($response, \Magento\Shipping\Model\Simplexml\Element::class); - if (is_object($xml)) { - if (in_array($xml->getName(), ['ErrorResponse', 'ShipmentValidateErrorResponse']) - || isset($xml->GetQuoteResponse->Note->Condition) - ) { - $code = null; - $data = null; - if (isset($xml->Response->Status->Condition)) { - $nodeCondition = $xml->Response->Status->Condition; - } else { - $nodeCondition = $xml->GetQuoteResponse->Note->Condition; - } - - if ($this->_isShippingLabelFlag) { - foreach ($nodeCondition as $condition) { - $code = isset($condition->ConditionCode) ? (string)$condition->ConditionCode : 0; - $data = isset($condition->ConditionData) ? (string)$condition->ConditionData : ''; - if (!empty($code) && !empty($data)) { - break; - } - } - throw new \Magento\Framework\Exception\LocalizedException( - __('Error #%1 : %2', trim($code), trim($data)) - ); - } - - $code = isset($nodeCondition->ConditionCode) ? (string)$nodeCondition->ConditionCode : 0; - $data = isset($nodeCondition->ConditionData) ? (string)$nodeCondition->ConditionData : ''; - $this->_errors[$code] = __('Error #%1 : %2', trim($code), trim($data)); - } else { - if (isset($xml->GetQuoteResponse->BkgDetails->QtdShp)) { - foreach ($xml->GetQuoteResponse->BkgDetails->QtdShp as $quotedShipment) { - $this->_addRate($quotedShipment); - } - } elseif (isset($xml->AirwayBillNumber)) { - return $this->_prepareShippingLabelContent($xml); - } else { - $this->_errors[] = $responseError; - } - } + try { + $this->xmlValidator->validate($response); + $xml = simplexml_load_string($response); + if (isset($xml->GetQuoteResponse->BkgDetails->QtdShp)) { + foreach ($xml->GetQuoteResponse->BkgDetails->QtdShp as $quotedShipment) { + $this->_addRate($quotedShipment); } + } elseif (isset($xml->AirwayBillNumber)) { + return $this->_prepareShippingLabelContent($xml); } else { $this->_errors[] = $responseError; } - } else { - $this->_errors[] = $responseError; + } catch (DocumentValidationException $e) { + if ($e->getCode() > 0) { + $this->_errors[$e->getCode()] = $e->getMessage(); + } else { + $this->_errors[] = $e->getMessage(); + } } - /* @var $result Result */ $result = $this->_rateFactory->create(); if ($this->_rates) { @@ -1547,7 +1527,7 @@ protected function _doRequest() $xml->addChild('LabelImageFormat', 'PDF', ''); $request = $xml->asXML(); - if (!$request && !mb_detect_encoding($request) == 'UTF-8') { + if (!$request && !(mb_detect_encoding($request) == 'UTF-8')) { $request = utf8_encode($request); } @@ -1555,6 +1535,7 @@ protected function _doRequest() if ($responseBody === null) { $debugData = ['request' => $request]; try { + /** @var \Magento\Framework\HTTP\ZendClient $client */ $client = $this->_httpClientFactory->create(); $client->setUri((string)$this->getConfigData('gateway_url')); $client->setConfig(['maxredirects' => 0, 'timeout' => 30]); @@ -1664,7 +1645,7 @@ protected function _shipmentDetails($xml, $rawRequest, $originRegion = '') $packageType = 'CP'; } $nodeShipmentDetails->addChild('PackageType', $packageType); - $nodeShipmentDetails->addChild('Weight', $rawRequest->getPackageWeight()); + $nodeShipmentDetails->addChild('Weight', sprintf('%.3f', $rawRequest->getPackageWeight())); $nodeShipmentDetails->addChild('DimensionUnit', substr($this->_getDimensionUnit(), 0, 1)); $nodeShipmentDetails->addChild('WeightUnit', substr($this->_getWeightUnit(), 0, 1)); $nodeShipmentDetails->addChild('GlobalProductCode', $rawRequest->getShippingMethod()); @@ -1748,7 +1729,8 @@ protected function _getXMLTracking($trackings) if ($responseBody === null) { $debugData = ['request' => $request]; try { - $client = new \Magento\Framework\HTTP\ZendClient(); + /** @var \Magento\Framework\HTTP\ZendClient $client */ + $client = $this->_httpClientFactory->create(); $client->setUri((string)$this->getConfigData('gateway_url')); $client->setConfig(['maxredirects' => 0, 'timeout' => 30]); $client->setRawData($request); diff --git a/app/code/Magento/Dhl/Model/Validator/ResponseErrorProcessor.php b/app/code/Magento/Dhl/Model/Validator/ResponseErrorProcessor.php new file mode 100644 index 0000000000000..8feebf4300237 --- /dev/null +++ b/app/code/Magento/Dhl/Model/Validator/ResponseErrorProcessor.php @@ -0,0 +1,43 @@ +Response->Status->Condition) + ? $xml->Response->Status->Condition : $xml->GetQuoteResponse->Note->Condition; + + if ($isShippingLabel) { + foreach ($nodeCondition as $condition) { + $code = (string)$condition->ConditionCode; + $data = (string)$condition->ConditionData; + if (!empty($code) && !empty($data)) { + break; + } + } + return __('Error #%1 : %2', trim($code), trim($data)); + } + + $code = (string)$nodeCondition->ConditionCode ?: 0; + $data = (string)$nodeCondition->ConditionData ?: ''; + return __('Error #%1 : %2', trim($code), trim($data)); + } +} diff --git a/app/code/Magento/Dhl/Model/Validator/XmlValidator.php b/app/code/Magento/Dhl/Model/Validator/XmlValidator.php new file mode 100644 index 0000000000000..a489832b47b20 --- /dev/null +++ b/app/code/Magento/Dhl/Model/Validator/XmlValidator.php @@ -0,0 +1,67 @@ +xmlSecurity = $xmlSecurity; + $this->errorProcessor = $errorProcessor; + } + + /** + * Validate DHL XML responses + * + * @param string $xmlResponse + * @param bool $isShippingLabel + * @return void + * @throws DocumentValidationException + */ + public function validate($xmlResponse, $isShippingLabel = false) + { + if (strlen(trim($xmlResponse)) > 0 && strpos(trim($xmlResponse), 'xmlSecurity->scan($xmlResponse)) { + throw new DocumentValidationException(__('Security validation of XML document has been failed.')); + } + $xml = simplexml_load_string($xmlResponse, \Magento\Shipping\Model\Simplexml\Element::class); + + if (in_array($xml->getName(), ['ErrorResponse', 'ShipmentValidateErrorResponse']) + || isset($xml->GetQuoteResponse->Note->Condition) + ) { + /** @var \Magento\Framework\Phrase $exceptionPhrase */ + $exceptionPhrase = $this->errorProcessor->process($xml, $isShippingLabel); + throw new DocumentValidationException($exceptionPhrase, null, $exceptionPhrase->getArguments()[0]); + } + } else { + throw new DocumentValidationException(__('The response is in the wrong format')); + } + } +} diff --git a/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php b/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php index 0dc04ba4fbaca..0f0d784813dfc 100644 --- a/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php +++ b/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php @@ -12,11 +12,12 @@ use Magento\Framework\Xml\Security; use Magento\Quote\Model\Quote\Address\RateRequest; use PHPUnit_Framework_MockObject_MockObject as MockObject; +use Magento\Dhl\Model\Validator\XmlValidator; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class CarrierTest extends \PHPUnit_Framework_TestCase +class CarrierTest extends \PHPUnit\Framework\TestCase { /** * @var ObjectManager @@ -53,6 +54,16 @@ class CarrierTest extends \PHPUnit_Framework_TestCase */ private $httpClient; + /** + * @var XmlValidator|MockObject + */ + private $xmlValidator; + + /** + * @var \Magento\Shipping\Model\Shipment\Request|MockObject + */ + private $request; + /** * @return void * @SuppressWarnings(PHPMD.ExcessiveMethodLength) @@ -61,6 +72,25 @@ protected function setUp() { $this->objectManager = new ObjectManager($this); + $this->request = $this->getMockBuilder(\Magento\Shipping\Model\Shipment\Request::class) + ->disableOriginalConstructor() + ->setMethods( + [ + 'getPackages', + 'getOrigCountryId', + 'setPackages', + 'setPackageWeight', + 'setPackageValue', + 'setValueWithDiscount', + 'setPackageCustomsValue', + 'setFreeMethodWeight', + 'getPackageWeight', + 'getFreeMethodWeight', + 'getOrderShipment', + ] + ) + ->getMock(); + $this->scope = $this->getMockForAbstractClass(ScopeConfigInterface::class); $this->scope->method('getValue') ->willReturnCallback([$this, 'scopeConfigGetValue']); @@ -109,26 +139,31 @@ function ($data) { ['setPrice'] )->getMock(); $rateMethod->expects($this->any())->method('setPrice')->will($this->returnSelf()); - $rateMethodFactory->expects($this->any())->method('create')->will($this->returnValue($rateMethod)); + // Http mocks $this->httpResponse = $this->getMockBuilder(\Zend_Http_Response::class) ->disableOriginalConstructor() ->getMock(); - $this->httpClient = $this->getMockBuilder(ZendClient::class) ->disableOriginalConstructor() ->setMethods(['request']) ->getMock(); $this->httpClient->method('request') ->willReturn($this->httpResponse); - $httpClientFactory = $this->getMockBuilder(ZendClientFactory::class) ->disableOriginalConstructor() ->getMock(); $httpClientFactory->method('create') ->willReturn($this->httpClient); + // Config reader mock + $configReader = $this->getMockBuilder(\Magento\Framework\Module\Dir\Reader::class) + ->disableOriginalConstructor() + ->getMock(); + $configReader->method('getModuleDir')->willReturn('/etc/path'); + + // XML Reader mock to retrieve list of acceptable countries $modulesDirectory = $this->getMockBuilder( \Magento\Framework\Filesystem\Directory\Read::class )->disableOriginalConstructor()->setMethods( @@ -141,8 +176,10 @@ function ($data) { )->will( $this->returnValue(file_get_contents(__DIR__ . '/_files/countries.xml')) ); - $readFactory = $this->getMock(\Magento\Framework\Filesystem\Directory\ReadFactory::class, [], [], '', false); + $readFactory = $this->createMock(\Magento\Framework\Filesystem\Directory\ReadFactory::class); $readFactory->expects($this->any())->method('create')->willReturn($modulesDirectory); + + // Website Mock $storeManager = $this->getMockBuilder( \Magento\Store\Model\StoreManager::class )->disableOriginalConstructor()->setMethods( @@ -156,17 +193,31 @@ function ($data) { $website->expects($this->any())->method('getBaseCurrencyCode')->will($this->returnValue('USD')); $storeManager->expects($this->any())->method('getWebsite')->will($this->returnValue($website)); + // Error Mock $this->error = $this->getMockBuilder(\Magento\Quote\Model\Quote\Address\RateResult\Error::class) ->setMethods(['setCarrier', 'setCarrierTitle', 'setErrorMessage']) ->getMock(); - $this->errorFactory = $this->getMockBuilder(\Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->errorFactory->expects($this->any())->method('create')->willReturn($this->error); + // Locale Mock + $localeResolver = $this->getMockForAbstractClass(\Magento\Framework\Locale\ResolverInterface::class); + $localeResolver->method('getLocale')->willReturn('fr_FR'); + $carrierHelper = $this->objectManager->getObject( + \Magento\Shipping\Helper\Carrier::class, + [ + 'localeResolver' => $localeResolver + ] + ); + + // Xml Validator Mock + $this->xmlValidator = $this->getMockBuilder(\Magento\Dhl\Model\Validator\XmlValidator::class) + ->disableOriginalConstructor() + ->getMock(); + $this->model = $this->objectManager->getObject( \Magento\Dhl\Model\Carrier::class, [ @@ -179,7 +230,10 @@ function ($data) { 'httpClientFactory' => $httpClientFactory, 'readFactory' => $readFactory, 'storeManager' => $storeManager, - 'data' => ['id' => 'dhl', 'store' => '1'] + 'configReader' => $configReader, + 'carrierHelper' => $carrierHelper, + 'data' => ['id' => 'dhl', 'store' => '1'], + 'xmlValidator' => $this->xmlValidator, ] ); } @@ -205,7 +259,12 @@ public function scopeConfigGetValue($path) 'carriers/dhl/showmethod' => 1, 'carriers/dhl/title' => 'dhl Title', 'carriers/dhl/specificerrmsg' => 'dhl error message', - 'carriers/dhl/unit_of_measure' => 'L', + 'carriers/dhl/unit_of_measure' => 'K', + 'carriers/dhl/size' => '1', + 'carriers/dhl/height' => '1.6', + 'carriers/dhl/width' => '1.6', + 'carriers/dhl/depth' => '1.6', + 'shipping/origin/country_id' => 'GB', ]; return isset($pathMap[$path]) ? $pathMap[$path] : null; } @@ -268,6 +327,7 @@ public function testCollectRates() $this->httpResponse->method('getBody') ->willReturn(file_get_contents(__DIR__ . '/_files/success_dhl_response_rates.xml')); + $this->xmlValidator->expects($this->any())->method('validate'); /** @var RateRequest $request */ $request = $this->objectManager->getObject( @@ -280,7 +340,10 @@ public function testCollectRates() $rawPostData->setAccessible(true); self::assertNotEmpty($this->model->collectRates($request)->getAllRates()); - self::assertContains('8.266', $rawPostData->getValue($this->httpClient)); + self::assertContains('18.223', $rawPostData->getValue($this->httpClient)); + self::assertContains('0.630', $rawPostData->getValue($this->httpClient)); + self::assertContains('0.630', $rawPostData->getValue($this->httpClient)); + self::assertContains('0.630', $rawPostData->getValue($this->httpClient)); } public function testCollectRatesErrorMessage() @@ -306,4 +369,82 @@ public function testCollectRatesFail() $this->assertFalse(false, $this->model->collectRates($request)); } + + /** + * Test request to shipment sends valid xml values. + */ + public function testRequestToShipment() + { + $this->httpResponse->method('getBody') + ->willReturn(utf8_encode(file_get_contents(__DIR__ . '/_files/response_shipping_label.xml'))); + $this->xmlValidator->expects($this->any())->method('validate'); + + $packages = [ + 'package' => [ + 'params' => [ + 'width' => '3', + 'length' => '3', + 'height' => '3', + 'dimension_units' => 'INCH', + 'weight_units' => 'POUND', + 'weight' => '0.454000000001', + 'customs_value' => '10.00', + 'container' => \Magento\Dhl\Model\Carrier::DHL_CONTENT_TYPE_NON_DOC, + ], + 'items' => [ + 'item1' => [ + 'name' => 'item_name', + ], + ], + ] + ]; + + $order = $this->getMockBuilder(\Magento\Sales\Model\Order::class) + ->disableOriginalConstructor() + ->getMock(); + $order->expects($this->any())->method('getSubtotal')->willReturn('10.00'); + + $shipment = $this->getMockBuilder(\Magento\Sales\Model\Order\Shipment::class) + ->disableOriginalConstructor() + ->getMock(); + $shipment->expects($this->any())->method('getOrder')->willReturn($order); + + $this->request->expects($this->any())->method('getPackages')->willReturn($packages); + $this->request->expects($this->any())->method('getOrigCountryId')->willReturn('GB'); + $this->request->expects($this->any())->method('setPackages')->willReturnSelf(); + $this->request->expects($this->any())->method('setPackageWeight')->willReturnSelf(); + $this->request->expects($this->any())->method('setPackageValue')->willReturnSelf(); + $this->request->expects($this->any())->method('setValueWithDiscount')->willReturnSelf(); + $this->request->expects($this->any())->method('setPackageCustomsValue')->willReturnSelf(); + $this->request->expects($this->any())->method('setFreeMethodWeight')->willReturnSelf(); + $this->request->expects($this->any())->method('getPackageWeight')->willReturn('0.454000000001'); + $this->request->expects($this->any())->method('getFreeMethodWeight')->willReturn('0.454000000001'); + $this->request->expects($this->any())->method('getOrderShipment')->willReturn($shipment); + + $result = $this->model->requestToShipment($this->request); + + $reflectionClass = new \ReflectionObject($this->httpClient); + $rawPostData = $reflectionClass->getProperty('raw_post_data'); + $rawPostData->setAccessible(true); + + $this->assertNotNull($result); + $this->assertContains('0.454', $rawPostData->getValue($this->httpClient)); + } + + /** + * Data provider to testRequestToShipment + * + * @return array + */ + public function requestToShipmentDataProvider() + { + return [ + [ + 'GB' + ], + [ + null + ] + ]; + } } diff --git a/app/code/Magento/Dhl/Test/Unit/Model/Validator/ResponseErrorProcessorTest.php b/app/code/Magento/Dhl/Test/Unit/Model/Validator/ResponseErrorProcessorTest.php new file mode 100644 index 0000000000000..721cca16a87d0 --- /dev/null +++ b/app/code/Magento/Dhl/Test/Unit/Model/Validator/ResponseErrorProcessorTest.php @@ -0,0 +1,89 @@ +objectManager = new ObjectManager($this); + + $this->responseErrorProcessor = $this->objectManager->getObject(ResponseErrorProcessor::class); + } + + /** + * Test process outputs correctly formatted error messages + * + * @param array $data + * @dataProvider processProvider + */ + public function testProcess($data) + { + $xml = $this->getXml($data['file']); + + $result = $this->responseErrorProcessor->process($xml, $data['isShippingLabel']); + + $this->assertEquals($data['errorMessage'], $result->render()); + $this->assertNotNull($result->getArguments()[0]); + } + + /** + * Retrieve SimpleXmlElement from XML file + * + * @param string $file + * @return \SimpleXMLElement + */ + private function getXml($file) + { + $rawXml = file_get_contents(__DIR__ . '/_files/' . $file); + return simplexml_load_string($rawXml, Element::class); + } + + /** + * @return array + */ + public function processProvider() + { + return [ + [ + [ + 'file' => 'invalidDHLResponse.xml', + 'errorMessage' => 'Error #111 : Error in parsing request XML', + 'isShippingLabel' => false, + ], + ], + [ + [ + 'file' => 'invalidDHLResponseForShippingLabel.xml', + 'errorMessage' => 'Error #123 : Error in shipping request XML', + 'isShippingLabel' => true, + ], + ], + [ + [ + 'file' => 'invalidDHLResponseForQuoteResponse.xml', + 'errorMessage' => 'Error #321 : Error in quote request XML', + 'isShippingLabel' => false, + ], + ], + ]; + } +} diff --git a/app/code/Magento/Dhl/Test/Unit/Model/Validator/XmlValidatorTest.php b/app/code/Magento/Dhl/Test/Unit/Model/Validator/XmlValidatorTest.php new file mode 100644 index 0000000000000..3d7893fea118f --- /dev/null +++ b/app/code/Magento/Dhl/Test/Unit/Model/Validator/XmlValidatorTest.php @@ -0,0 +1,141 @@ +objectManager = new ObjectManager($this); + + // Mock XML Security object + $this->xmlSecurityMock = $this->getMockBuilder(Security::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->errorProcessorMock = $this->getMockBuilder(ResponseErrorProcessor::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->xmlValidator = $this->objectManager->getObject( + XmlValidator::class, + [ + 'xmlSecurity' => $this->xmlSecurityMock, + 'errorProcessor' => $this->errorProcessorMock, + ] + ); + } + + /** + * Tests validate() on a valid XML response + */ + public function testValidateValidXml() + { + $rawXml = file_get_contents(__DIR__ . '/_files/validDHLResponse.xml'); + $this->xmlSecurityMock->expects($this->once())->method('scan')->with($rawXml)->willReturn(true); + + try { + $this->xmlValidator->validate($rawXml); + } catch (DocumentValidationException $exception) { + $this->fail($exception->getMessage()); + } + } + + /** + * Tests validate() on an invalid XML response + * + * @param array $data + * @dataProvider invalidXmlResponseProvider + */ + public function testValidateInvalidXml($data) + { + $phrase = new \Magento\Framework\Phrase('Error #%1 : %2', ['111', 'Error in parsing request XML']); + $rawXml = file_get_contents(__DIR__ . '/_files/' . $data['file']); + $this->xmlSecurityMock->expects($this->any()) + ->method('scan') + ->with($rawXml) + ->willReturn($data['isGenerateXml']); + $this->errorProcessorMock->expects($this->any()) + ->method('process') + ->willReturn($phrase); + + try { + $this->xmlValidator->validate($rawXml); + } catch (\Magento\Sales\Exception\DocumentValidationException $exception) { + $this->assertEquals($data['errorMessage'], $exception->getMessage()); + if (isset($data['code'])) { + $this->assertEquals($data['code'], $exception->getCode()); + } + return; + } + + $this->fail('Exception not thrown for testValidateInvalidXml'); + } + + /** + * @return array + */ + public function invalidXmlResponseProvider() + { + return [ + [ + [ + 'file' => 'invalidDHLResponseWithMissingXmlTag.xml', + 'errorMessage' => 'The response is in the wrong format', + 'isGenerateXml' => false, + ], + ], + [ + [ + 'file' => 'invalidDHLResponse.xml', + 'errorMessage' => 'Security validation of XML document has been failed.', + 'isGenerateXml' => false, + ], + ], + [ + [ + 'file' => 'invalidDHLResponse.xml', + 'errorMessage' => 'Error #111 : Error in parsing request XML', + 'isGenerateXml' => true, + 'code' => 111, + ], + ], + + ]; + } +} diff --git a/app/code/Magento/Dhl/Test/Unit/Model/Validator/_files/invalidDHLResponse.xml b/app/code/Magento/Dhl/Test/Unit/Model/Validator/_files/invalidDHLResponse.xml new file mode 100644 index 0000000000000..15e9bc0fa4315 --- /dev/null +++ b/app/code/Magento/Dhl/Test/Unit/Model/Validator/_files/invalidDHLResponse.xml @@ -0,0 +1,18 @@ + + + + + + Error + + 111 + Error in parsing request XML + + + + diff --git a/app/code/Magento/Dhl/Test/Unit/Model/Validator/_files/invalidDHLResponseForQuoteResponse.xml b/app/code/Magento/Dhl/Test/Unit/Model/Validator/_files/invalidDHLResponseForQuoteResponse.xml new file mode 100644 index 0000000000000..9db2f3d8e46b4 --- /dev/null +++ b/app/code/Magento/Dhl/Test/Unit/Model/Validator/_files/invalidDHLResponseForQuoteResponse.xml @@ -0,0 +1,18 @@ + + + + + + Error + + 321 + Error in quote request XML + + + + diff --git a/app/code/Magento/Dhl/Test/Unit/Model/Validator/_files/invalidDHLResponseForShippingLabel.xml b/app/code/Magento/Dhl/Test/Unit/Model/Validator/_files/invalidDHLResponseForShippingLabel.xml new file mode 100644 index 0000000000000..c2eb7d9772fe7 --- /dev/null +++ b/app/code/Magento/Dhl/Test/Unit/Model/Validator/_files/invalidDHLResponseForShippingLabel.xml @@ -0,0 +1,22 @@ + + + + + + Error + + + + + + 123 + Error in shipping request XML + + + + diff --git a/app/code/Magento/Dhl/Test/Unit/Model/Validator/_files/invalidDHLResponseWithMissingXmlTag.xml b/app/code/Magento/Dhl/Test/Unit/Model/Validator/_files/invalidDHLResponseWithMissingXmlTag.xml new file mode 100644 index 0000000000000..6371a23152d4f --- /dev/null +++ b/app/code/Magento/Dhl/Test/Unit/Model/Validator/_files/invalidDHLResponseWithMissingXmlTag.xml @@ -0,0 +1,17 @@ + + + + + Error + + 111 + Error in parsing request XML + + + + diff --git a/app/code/Magento/Dhl/Test/Unit/Model/Validator/_files/validDHLResponse.xml b/app/code/Magento/Dhl/Test/Unit/Model/Validator/_files/validDHLResponse.xml new file mode 100644 index 0000000000000..9cfaa772f5d54 --- /dev/null +++ b/app/code/Magento/Dhl/Test/Unit/Model/Validator/_files/validDHLResponse.xml @@ -0,0 +1,14 @@ + + + + 6481969852 + + PDF + image + + diff --git a/app/code/Magento/Dhl/Test/Unit/Model/_files/response_shipping_label.xml b/app/code/Magento/Dhl/Test/Unit/Model/_files/response_shipping_label.xml index 08086d12d6084..40f97b4faa4f8 100644 --- a/app/code/Magento/Dhl/Test/Unit/Model/_files/response_shipping_label.xml +++ b/app/code/Magento/Dhl/Test/Unit/Model/_files/response_shipping_label.xml @@ -10,4 +10,5 @@ OutputImageContent + Nürnberg diff --git a/app/code/Magento/Directory/Api/CountryInformationAcquirerInterface.php b/app/code/Magento/Directory/Api/CountryInformationAcquirerInterface.php index 512f53dac3779..34d832f292c0a 100644 --- a/app/code/Magento/Directory/Api/CountryInformationAcquirerInterface.php +++ b/app/code/Magento/Directory/Api/CountryInformationAcquirerInterface.php @@ -9,6 +9,7 @@ * Country information acquirer interface * * @api + * @since 100.0.2 */ interface CountryInformationAcquirerInterface { diff --git a/app/code/Magento/Directory/Api/CurrencyInformationAcquirerInterface.php b/app/code/Magento/Directory/Api/CurrencyInformationAcquirerInterface.php index 5679ba6680357..9f5922143b199 100644 --- a/app/code/Magento/Directory/Api/CurrencyInformationAcquirerInterface.php +++ b/app/code/Magento/Directory/Api/CurrencyInformationAcquirerInterface.php @@ -9,6 +9,7 @@ * Currency information acquirer interface * * @api + * @since 100.0.2 */ interface CurrencyInformationAcquirerInterface { diff --git a/app/code/Magento/Directory/Api/Data/CountryInformationInterface.php b/app/code/Magento/Directory/Api/Data/CountryInformationInterface.php index 978ec1246eeb9..f41e3a60b5c49 100644 --- a/app/code/Magento/Directory/Api/Data/CountryInformationInterface.php +++ b/app/code/Magento/Directory/Api/Data/CountryInformationInterface.php @@ -9,6 +9,7 @@ * Country Information interface. * * @api + * @since 100.0.2 */ interface CountryInformationInterface extends \Magento\Framework\Api\ExtensibleDataInterface { diff --git a/app/code/Magento/Directory/Api/Data/CurrencyInformationInterface.php b/app/code/Magento/Directory/Api/Data/CurrencyInformationInterface.php index 68a917573b7c8..8cbab3c56ed2b 100644 --- a/app/code/Magento/Directory/Api/Data/CurrencyInformationInterface.php +++ b/app/code/Magento/Directory/Api/Data/CurrencyInformationInterface.php @@ -9,6 +9,7 @@ * Currency Information interface. * * @api + * @since 100.0.2 */ interface CurrencyInformationInterface extends \Magento\Framework\Api\ExtensibleDataInterface { diff --git a/app/code/Magento/Directory/Api/Data/ExchangeRateInterface.php b/app/code/Magento/Directory/Api/Data/ExchangeRateInterface.php index f9d414b197403..3a883b5f4e057 100644 --- a/app/code/Magento/Directory/Api/Data/ExchangeRateInterface.php +++ b/app/code/Magento/Directory/Api/Data/ExchangeRateInterface.php @@ -9,6 +9,7 @@ * Exchange Rate interface. * * @api + * @since 100.0.2 */ interface ExchangeRateInterface extends \Magento\Framework\Api\ExtensibleDataInterface { diff --git a/app/code/Magento/Directory/Api/Data/RegionInformationInterface.php b/app/code/Magento/Directory/Api/Data/RegionInformationInterface.php index 37993e5a3784f..54495e2ffd6eb 100644 --- a/app/code/Magento/Directory/Api/Data/RegionInformationInterface.php +++ b/app/code/Magento/Directory/Api/Data/RegionInformationInterface.php @@ -10,6 +10,7 @@ * Region Information interface. * * @api + * @since 100.0.2 */ interface RegionInformationInterface extends \Magento\Framework\Api\ExtensibleDataInterface { diff --git a/app/code/Magento/Directory/Block/Currency.php b/app/code/Magento/Directory/Block/Currency.php index 75002734124fe..3e8afcd0ed059 100644 --- a/app/code/Magento/Directory/Block/Currency.php +++ b/app/code/Magento/Directory/Block/Currency.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class Currency extends \Magento\Framework\View\Element\Template { diff --git a/app/code/Magento/Directory/Block/Data.php b/app/code/Magento/Directory/Block/Data.php index 2542eb3fdbd54..ca2b4b95b5574 100644 --- a/app/code/Magento/Directory/Block/Data.php +++ b/app/code/Magento/Directory/Block/Data.php @@ -237,7 +237,7 @@ public function getRegionsJs() * Get serializer * * @return \Magento\Framework\Serialize\SerializerInterface - * @deprecated + * @deprecated 100.2.0 */ private function getSerializer() { diff --git a/app/code/Magento/Directory/Helper/Data.php b/app/code/Magento/Directory/Helper/Data.php index a695b3fe31313..99e1d1ad5394e 100644 --- a/app/code/Magento/Directory/Helper/Data.php +++ b/app/code/Magento/Directory/Helper/Data.php @@ -12,6 +12,7 @@ * Directory data helper * * @api + * @since 100.0.2 */ class Data extends \Magento\Framework\App\Helper\AbstractHelper { diff --git a/app/code/Magento/Directory/Model/AllowedCountries.php b/app/code/Magento/Directory/Model/AllowedCountries.php index 6c3fe5db8f167..46fa04ba22651 100644 --- a/app/code/Magento/Directory/Model/AllowedCountries.php +++ b/app/code/Magento/Directory/Model/AllowedCountries.php @@ -14,6 +14,7 @@ * Provider of allowed countries based on configuration settings * * @api + * @since 100.1.2 */ class AllowedCountries { @@ -48,6 +49,7 @@ public function __construct( * @param string | null $scopeCode * @param string $scope * @return array + * @since 100.1.2 */ public function getAllowedCountries( $scope = ScopeInterface::SCOPE_WEBSITE, @@ -105,6 +107,7 @@ private function getDefaultScopeCode($scope) * * @param array $allowedCountries * @return array + * @since 100.1.2 */ public function makeCountriesUnique(array $allowedCountries) { @@ -117,6 +120,7 @@ public function makeCountriesUnique(array $allowedCountries) * @param string $scope * @param int $scopeCode * @return array + * @since 100.1.2 */ public function getCountriesFromConfig($scope, $scopeCode) { diff --git a/app/code/Magento/Directory/Model/Config/Source/Allregion.php b/app/code/Magento/Directory/Model/Config/Source/Allregion.php index a35da92ef9282..c86cfed33e92c 100644 --- a/app/code/Magento/Directory/Model/Config/Source/Allregion.php +++ b/app/code/Magento/Directory/Model/Config/Source/Allregion.php @@ -9,6 +9,7 @@ * Options provider for regions list * * @api + * @since 100.0.2 */ class Allregion implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Directory/Model/Config/Source/Country.php b/app/code/Magento/Directory/Model/Config/Source/Country.php index 144a51e8d2b26..e807f34456e24 100644 --- a/app/code/Magento/Directory/Model/Config/Source/Country.php +++ b/app/code/Magento/Directory/Model/Config/Source/Country.php @@ -9,6 +9,7 @@ * Options provider for countries list * * @api + * @since 100.0.2 */ class Country implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Directory/Model/Config/Source/Country/Full.php b/app/code/Magento/Directory/Model/Config/Source/Country/Full.php index 159b2b6c609d4..f9b9463b16a87 100644 --- a/app/code/Magento/Directory/Model/Config/Source/Country/Full.php +++ b/app/code/Magento/Directory/Model/Config/Source/Country/Full.php @@ -11,6 +11,7 @@ * @api * * @codeCoverageIgnore + * @since 100.0.2 */ class Full extends \Magento\Directory\Model\Config\Source\Country implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Directory/Model/Config/Source/WeightUnit.php b/app/code/Magento/Directory/Model/Config/Source/WeightUnit.php index ea43a2f427d5c..4e2758b362a43 100644 --- a/app/code/Magento/Directory/Model/Config/Source/WeightUnit.php +++ b/app/code/Magento/Directory/Model/Config/Source/WeightUnit.php @@ -9,6 +9,7 @@ * Options provider for weight units list * * @api + * @since 100.0.2 */ class WeightUnit implements \Magento\Framework\Option\ArrayInterface { diff --git a/app/code/Magento/Directory/Model/Country.php b/app/code/Magento/Directory/Model/Country.php index aa52948064d1b..57339afa3dd16 100644 --- a/app/code/Magento/Directory/Model/Country.php +++ b/app/code/Magento/Directory/Model/Country.php @@ -11,12 +11,11 @@ /** * Country model * - * @method \Magento\Directory\Model\ResourceModel\Country _getResource() - * @method \Magento\Directory\Model\ResourceModel\Country getResource() * @method string getCountryId() * @method \Magento\Directory\Model\Country setCountryId(string $value) * * @api + * @since 100.0.2 */ class Country extends \Magento\Framework\Model\AbstractModel { diff --git a/app/code/Magento/Directory/Model/Country/Format.php b/app/code/Magento/Directory/Model/Country/Format.php index 655c048e5c2b2..00c1f99164e25 100644 --- a/app/code/Magento/Directory/Model/Country/Format.php +++ b/app/code/Magento/Directory/Model/Country/Format.php @@ -8,8 +8,6 @@ /** * Directory country format model * - * @method \Magento\Directory\Model\ResourceModel\Country\Format _getResource() - * @method \Magento\Directory\Model\ResourceModel\Country\Format getResource() * @method string getCountryId() * @method \Magento\Directory\Model\Country\Format setCountryId(string $value) * @method string getType() @@ -18,6 +16,7 @@ * @method \Magento\Directory\Model\Country\Format setFormat(string $value) * * @api + * @since 100.0.2 */ class Format extends \Magento\Framework\Model\AbstractModel { diff --git a/app/code/Magento/Directory/Model/Country/Postcode/ValidatorInterface.php b/app/code/Magento/Directory/Model/Country/Postcode/ValidatorInterface.php index 12bee88e0bce4..e5af9e6725992 100644 --- a/app/code/Magento/Directory/Model/Country/Postcode/ValidatorInterface.php +++ b/app/code/Magento/Directory/Model/Country/Postcode/ValidatorInterface.php @@ -5,6 +5,10 @@ */ namespace Magento\Directory\Model\Country\Postcode; +/** + * Interface \Magento\Directory\Model\Country\Postcode\ValidatorInterface + * + */ interface ValidatorInterface { /** diff --git a/app/code/Magento/Directory/Model/Currency.php b/app/code/Magento/Directory/Model/Currency.php index a7b5fd089d4e6..a8df4936b8fae 100644 --- a/app/code/Magento/Directory/Model/Currency.php +++ b/app/code/Magento/Directory/Model/Currency.php @@ -15,6 +15,7 @@ * @api * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class Currency extends \Magento\Framework\Model\AbstractModel { diff --git a/app/code/Magento/Directory/Model/Currency/Import/AbstractImport.php b/app/code/Magento/Directory/Model/Currency/Import/AbstractImport.php index 22c64b6f775de..da9f2a43b56b3 100644 --- a/app/code/Magento/Directory/Model/Currency/Import/AbstractImport.php +++ b/app/code/Magento/Directory/Model/Currency/Import/AbstractImport.php @@ -11,6 +11,7 @@ /** * @api + * @since 100.0.2 */ abstract class AbstractImport implements \Magento\Directory\Model\Currency\Import\ImportInterface { diff --git a/app/code/Magento/Directory/Model/Currency/Import/Config.php b/app/code/Magento/Directory/Model/Currency/Import/Config.php index d447daa9f6d93..fb17ab5d968d6 100644 --- a/app/code/Magento/Directory/Model/Currency/Import/Config.php +++ b/app/code/Magento/Directory/Model/Currency/Import/Config.php @@ -9,6 +9,7 @@ * Configured currency import services * * @api + * @since 100.0.2 */ class Config { diff --git a/app/code/Magento/Directory/Model/Currency/Import/Factory.php b/app/code/Magento/Directory/Model/Currency/Import/Factory.php index 58cf11a71ee38..5cd699f48719d 100644 --- a/app/code/Magento/Directory/Model/Currency/Import/Factory.php +++ b/app/code/Magento/Directory/Model/Currency/Import/Factory.php @@ -12,6 +12,7 @@ * Factory for currency import services * * @api + * @since 100.0.2 */ class Factory { diff --git a/app/code/Magento/Directory/Model/Currency/Import/ImportInterface.php b/app/code/Magento/Directory/Model/Currency/Import/ImportInterface.php index b581a784a3761..7f28b138d91c9 100644 --- a/app/code/Magento/Directory/Model/Currency/Import/ImportInterface.php +++ b/app/code/Magento/Directory/Model/Currency/Import/ImportInterface.php @@ -10,6 +10,7 @@ * Import currency model interface * * @api + * @since 100.0.2 */ interface ImportInterface { diff --git a/app/code/Magento/Directory/Model/Currency/Import/YahooFinance.php b/app/code/Magento/Directory/Model/Currency/Import/YahooFinance.php index cf4bf886665ef..5f96b8627af65 100644 --- a/app/code/Magento/Directory/Model/Currency/Import/YahooFinance.php +++ b/app/code/Magento/Directory/Model/Currency/Import/YahooFinance.php @@ -10,20 +10,13 @@ */ class YahooFinance extends \Magento\Directory\Model\Currency\Import\AbstractImport { - /** - * Currency converter url string - * - * @var string - */ + // @codingStandardsIgnoreStart + // @codingStandardsIgnoreStart private $currencyConverterUrl = 'http://query.yahooapis.com/v1/public/yql?format=json&q={{YQL_STRING}}&env=store://datatables.org/alltableswithkeys'; // @codingStandardsIgnoreEnd - /** - * Config path for service timeout - * - * @var string - */ + // @codingStandardsIgnoreEnd private $timeoutConfigPath = 'currency/yahoofinance/timeout'; /** diff --git a/app/code/Magento/Directory/Model/Region.php b/app/code/Magento/Directory/Model/Region.php index ac03c2f2b0103..6a9c23dadcbb3 100644 --- a/app/code/Magento/Directory/Model/Region.php +++ b/app/code/Magento/Directory/Model/Region.php @@ -9,8 +9,6 @@ /** * Region * - * @method \Magento\Directory\Model\ResourceModel\Region _getResource() - * @method \Magento\Directory\Model\ResourceModel\Region getResource() * @method string getRegionId() * @method string getCountryId() * @method \Magento\Directory\Model\Region setCountryId(string $value) @@ -20,6 +18,7 @@ * @method \Magento\Directory\Model\Region setDefaultName(string $value) * * @api + * @since 100.0.2 */ class Region extends \Magento\Framework\Model\AbstractModel { diff --git a/app/code/Magento/Directory/Model/RegionFactory.php b/app/code/Magento/Directory/Model/RegionFactory.php index 7fbdf25f2c578..c9bdcdef97a73 100644 --- a/app/code/Magento/Directory/Model/RegionFactory.php +++ b/app/code/Magento/Directory/Model/RegionFactory.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class RegionFactory { diff --git a/app/code/Magento/Directory/Model/ResourceModel/Country.php b/app/code/Magento/Directory/Model/ResourceModel/Country.php index f09e4a2d06bb5..c4c0a6b95dfb4 100644 --- a/app/code/Magento/Directory/Model/ResourceModel/Country.php +++ b/app/code/Magento/Directory/Model/ResourceModel/Country.php @@ -9,6 +9,7 @@ * Country Resource Model * * @api + * @since 100.0.2 */ class Country extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { diff --git a/app/code/Magento/Directory/Model/ResourceModel/Country/Collection.php b/app/code/Magento/Directory/Model/ResourceModel/Country/Collection.php index ba5ce4b671fe9..25c525cabfeb8 100644 --- a/app/code/Magento/Directory/Model/ResourceModel/Country/Collection.php +++ b/app/code/Magento/Directory/Model/ResourceModel/Country/Collection.php @@ -18,6 +18,7 @@ * @api * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { @@ -64,6 +65,7 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab /** * @var string[] + * @since 100.1.0 */ protected $countriesWithNotRequiredStates; @@ -148,7 +150,7 @@ protected function _construct() /** * Return Allowed Countries reader * - * @deprecated + * @deprecated 100.1.2 * @return \Magento\Directory\Model\AllowedCountries */ private function getAllowedCountriesReader() @@ -313,6 +315,7 @@ public function setForegroundCountries($foregroundCountries) * Get list of countries with required states * * @return \Magento\Directory\Model\Country[] + * @since 100.1.0 */ public function getCountriesWithRequiredStates() { diff --git a/app/code/Magento/Directory/Model/ResourceModel/Country/Format.php b/app/code/Magento/Directory/Model/ResourceModel/Country/Format.php index 98474327157ba..20f84cb82456a 100644 --- a/app/code/Magento/Directory/Model/ResourceModel/Country/Format.php +++ b/app/code/Magento/Directory/Model/ResourceModel/Country/Format.php @@ -9,6 +9,7 @@ * Directory country format resource model * * @api + * @since 100.0.2 */ class Format extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { diff --git a/app/code/Magento/Directory/Model/ResourceModel/Country/Format/Collection.php b/app/code/Magento/Directory/Model/ResourceModel/Country/Format/Collection.php index f48c50a8aa879..d8394b17efdbd 100644 --- a/app/code/Magento/Directory/Model/ResourceModel/Country/Format/Collection.php +++ b/app/code/Magento/Directory/Model/ResourceModel/Country/Format/Collection.php @@ -9,6 +9,7 @@ * Country formats collection * * @api + * @since 100.0.2 */ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { diff --git a/app/code/Magento/Directory/Model/ResourceModel/Currency.php b/app/code/Magento/Directory/Model/ResourceModel/Currency.php index e4b44e5e725c2..ac0716fc4e67e 100644 --- a/app/code/Magento/Directory/Model/ResourceModel/Currency.php +++ b/app/code/Magento/Directory/Model/ResourceModel/Currency.php @@ -10,6 +10,7 @@ * Currency Resource Model * * @api + * @since 100.0.2 */ class Currency extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { diff --git a/app/code/Magento/Directory/Model/ResourceModel/Region.php b/app/code/Magento/Directory/Model/ResourceModel/Region.php index 5b43a420d939d..ffacc07deab69 100644 --- a/app/code/Magento/Directory/Model/ResourceModel/Region.php +++ b/app/code/Magento/Directory/Model/ResourceModel/Region.php @@ -12,6 +12,7 @@ * Region Resource Model * * @api + * @since 100.0.2 */ class Region extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { diff --git a/app/code/Magento/Directory/Model/ResourceModel/Region/Collection.php b/app/code/Magento/Directory/Model/ResourceModel/Region/Collection.php index 7945d35dec9ea..26ddf6671afb0 100644 --- a/app/code/Magento/Directory/Model/ResourceModel/Region/Collection.php +++ b/app/code/Magento/Directory/Model/ResourceModel/Region/Collection.php @@ -16,6 +16,7 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * * @api + * @since 100.0.2 */ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { @@ -106,7 +107,7 @@ protected function _initSelect() * Return Allowed Countries reader * * @return \Magento\Directory\Model\AllowedCountries - * @deprecated + * @deprecated 100.1.4 */ private function getAllowedCountriesReader() { @@ -123,6 +124,7 @@ private function getAllowedCountriesReader() * * @param null|int|string|\Magento\Store\Model\Store $store * @return \Magento\Directory\Model\ResourceModel\Region\Collection + * @since 100.1.4 */ public function addAllowedCountriesFilter($store = null) { diff --git a/app/code/Magento/Directory/Setup/InstallData.php b/app/code/Magento/Directory/Setup/InstallData.php index 06dcb70bf934f..33c3ae4558e16 100644 --- a/app/code/Magento/Directory/Setup/InstallData.php +++ b/app/code/Magento/Directory/Setup/InstallData.php @@ -809,27 +809,6 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface ['BR', 'SE', 'Sergipe'], ['BR', 'TO', 'Tocantins'], ['BR', 'DF', 'Distrito Federal'], - ['HR', 'HR-01', 'Zagrebačka županija'], - ['HR', 'HR-02', 'Krapinsko-zagorska županija'], - ['HR', 'HR-03', 'Sisačko-moslavačka županija'], - ['HR', 'HR-04', 'Karlovačka županija'], - ['HR', 'HR-05', 'Varaždinska županija'], - ['HR', 'HR-06', 'Koprivničko-križevačka županija'], - ['HR', 'HR-07', 'Bjelovarsko-bilogorska županija'], - ['HR', 'HR-08', 'Primorsko-goranska županija'], - ['HR', 'HR-09', 'Ličko-senjska županija'], - ['HR', 'HR-10', 'Virovitičko-podravska županija'], - ['HR', 'HR-11', 'Požeško-slavonska županija'], - ['HR', 'HR-12', 'Brodsko-posavska županija'], - ['HR', 'HR-13', 'Zadarska županija'], - ['HR', 'HR-14', 'Osječko-baranjska županija'], - ['HR', 'HR-15', 'Šibensko-kninska županija'], - ['HR', 'HR-16', 'Vukovarsko-srijemska županija'], - ['HR', 'HR-17', 'Splitsko-dalmatinska županija'], - ['HR', 'HR-18', 'Istarska županija'], - ['HR', 'HR-19', 'Dubrovačko-neretvanska županija'], - ['HR', 'HR-20', 'Međimurska županija'], - ['HR', 'HR-21', 'Grad Zagreb'] ]; foreach ($data as $row) { diff --git a/app/code/Magento/Directory/Setup/UpgradeData.php b/app/code/Magento/Directory/Setup/UpgradeData.php new file mode 100644 index 0000000000000..aa0f81a32fff0 --- /dev/null +++ b/app/code/Magento/Directory/Setup/UpgradeData.php @@ -0,0 +1,106 @@ +directoryData = $directoryData; + } + + /** + * Upgrades data for Directry module. + * + * @param ModuleDataSetupInterface $setup + * @param ModuleContextInterface $context + * @return void + */ + public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context) + { + if (version_compare($context->getVersion(), '2.0.1', '<')) { + $this->addCroatia($setup); + } + } + + /** + * Add Croatia and it's states to appropriate tables. + * + * @param ModuleDataSetupInterface $setup + * @return void + */ + private function addCroatia($setup) + { + /** + * Fill table directory/country_region + * Fill table directory/country_region_name for en_US locale + */ + $data = [ + ['HR', 'HR-01', 'Zagrebačka županija'], + ['HR', 'HR-02', 'Krapinsko-zagorska županija'], + ['HR', 'HR-03', 'Sisačko-moslavačka županija'], + ['HR', 'HR-04', 'Karlovačka županija'], + ['HR', 'HR-05', 'Varaždinska županija'], + ['HR', 'HR-06', 'Koprivničko-križevačka županija'], + ['HR', 'HR-07', 'Bjelovarsko-bilogorska županija'], + ['HR', 'HR-08', 'Primorsko-goranska županija'], + ['HR', 'HR-09', 'Ličko-senjska županija'], + ['HR', 'HR-10', 'Virovitičko-podravska županija'], + ['HR', 'HR-11', 'Požeško-slavonska županija'], + ['HR', 'HR-12', 'Brodsko-posavska županija'], + ['HR', 'HR-13', 'Zadarska županija'], + ['HR', 'HR-14', 'Osječko-baranjska županija'], + ['HR', 'HR-15', 'Šibensko-kninska županija'], + ['HR', 'HR-16', 'Vukovarsko-srijemska županija'], + ['HR', 'HR-17', 'Splitsko-dalmatinska županija'], + ['HR', 'HR-18', 'Istarska županija'], + ['HR', 'HR-19', 'Dubrovačko-neretvanska županija'], + ['HR', 'HR-20', 'Međimurska županija'], + ['HR', 'HR-21', 'Grad Zagreb'] + ]; + foreach ($data as $row) { + $bind = ['country_id' => $row[0], 'code' => $row[1], 'default_name' => $row[2]]; + $setup->getConnection()->insert($setup->getTable('directory_country_region'), $bind); + $regionId = $setup->getConnection()->lastInsertId($setup->getTable('directory_country_region')); + $bind = ['locale' => 'en_US', 'region_id' => $regionId, 'name' => $row[2]]; + $setup->getConnection()->insert($setup->getTable('directory_country_region_name'), $bind); + } + /** + * Upgrade core_config_data general/region/state_required field. + */ + $countries = $this->directoryData->getCountryCollection()->getCountriesWithRequiredStates(); + $setup->getConnection()->update( + $setup->getTable('core_config_data'), + [ + 'value' => implode(',', array_keys($countries)) + ], + [ + 'scope="default"', + 'scope_id=0', + 'path=?' => Data::XML_PATH_STATES_REQUIRED + ] + ); + } +} diff --git a/app/code/Magento/Directory/Test/Unit/Block/CurrencyTest.php b/app/code/Magento/Directory/Test/Unit/Block/CurrencyTest.php index f67b9a581404e..0a9b13940eedc 100644 --- a/app/code/Magento/Directory/Test/Unit/Block/CurrencyTest.php +++ b/app/code/Magento/Directory/Test/Unit/Block/CurrencyTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Directory\Test\Unit\Block; -class CurrencyTest extends \PHPUnit_Framework_TestCase +class CurrencyTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Directory\Block\Currency @@ -24,13 +24,7 @@ class CurrencyTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->urlBuilderMock = $this->getMock( - \Magento\Framework\UrlInterface::class, - [], - [], - '', - false - ); + $this->urlBuilderMock = $this->createMock(\Magento\Framework\UrlInterface::class); $this->urlBuilderMock->expects($this->any())->method('getUrl')->will($this->returnArgument(0)); /** @@ -55,11 +49,11 @@ function ($string) { ->willReturn($escaperMock); /** @var \Magento\Directory\Model\CurrencyFactory $currencyFactoryMock */ - $currencyFactoryMock = $this->getMock(\Magento\Directory\Model\CurrencyFactory::class, [], [], '', false); - $this->postDataHelperMock = $this->getMock(\Magento\Framework\Data\Helper\PostHelper::class, [], [], '', false); + $currencyFactoryMock = $this->createMock(\Magento\Directory\Model\CurrencyFactory::class); + $this->postDataHelperMock = $this->createMock(\Magento\Framework\Data\Helper\PostHelper::class); /** @var \Magento\Framework\Locale\ResolverInterface $localeResolverMock */ - $localeResolverMock = $this->getMock(\Magento\Framework\Locale\ResolverInterface::class, [], [], '', false); + $localeResolverMock = $this->createMock(\Magento\Framework\Locale\ResolverInterface::class); $this->object = new \Magento\Directory\Block\Currency( $contextMock, diff --git a/app/code/Magento/Directory/Test/Unit/Block/DataTest.php b/app/code/Magento/Directory/Test/Unit/Block/DataTest.php index 81c32f6751b96..81cdfea2821dc 100644 --- a/app/code/Magento/Directory/Test/Unit/Block/DataTest.php +++ b/app/code/Magento/Directory/Test/Unit/Block/DataTest.php @@ -21,7 +21,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class DataTest extends \PHPUnit_Framework_TestCase +class DataTest extends \PHPUnit\Framework\TestCase { /** @var Data */ private $block; @@ -81,7 +81,7 @@ protected function setUp() ] ); - $this->serializerMock = $this->getMock(SerializerInterface::class, [], [], '', false); + $this->serializerMock = $this->createMock(SerializerInterface::class); $objectManagerHelper->setBackwardCompatibleProperty( $this->block, 'serializer', diff --git a/app/code/Magento/Directory/Test/Unit/Helper/DataTest.php b/app/code/Magento/Directory/Test/Unit/Helper/DataTest.php index d899b42f6592d..73e9f0f5fa1a5 100644 --- a/app/code/Magento/Directory/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Directory/Test/Unit/Helper/DataTest.php @@ -10,7 +10,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class DataTest extends \PHPUnit_Framework_TestCase +class DataTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Directory\Model\ResourceModel\Country\Collection|\PHPUnit_Framework_MockObject_MockObject @@ -45,35 +45,20 @@ class DataTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $context = $this->getMock(\Magento\Framework\App\Helper\Context::class, [], [], '', false); + $this->scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $context = $this->createMock(\Magento\Framework\App\Helper\Context::class); $context->expects($this->any()) ->method('getScopeConfig') ->willReturn($this->scopeConfigMock); - $configCacheType = $this->getMock(\Magento\Framework\App\Cache\Type\Config::class, [], [], '', false); + $configCacheType = $this->createMock(\Magento\Framework\App\Cache\Type\Config::class); - $this->_countryCollection = $this->getMock( - \Magento\Directory\Model\ResourceModel\Country\Collection::class, - [], - [], - '', - false - ); + $this->_countryCollection = $this->createMock(\Magento\Directory\Model\ResourceModel\Country\Collection::class); - $this->_regionCollection = $this->getMock( - \Magento\Directory\Model\ResourceModel\Region\Collection::class, - [], - [], - '', - false - ); - $regCollectionFactory = $this->getMock( + $this->_regionCollection = $this->createMock(\Magento\Directory\Model\ResourceModel\Region\Collection::class); + $regCollectionFactory = $this->createPartialMock( \Magento\Directory\Model\ResourceModel\Region\CollectionFactory::class, - ['create'], - [], - '', - false + ['create'] ); $regCollectionFactory->expects( $this->any() @@ -83,13 +68,13 @@ protected function setUp() $this->returnValue($this->_regionCollection) ); - $this->jsonHelperMock = $this->getMock(\Magento\Framework\Json\Helper\Data::class, [], [], '', false); + $this->jsonHelperMock = $this->createMock(\Magento\Framework\Json\Helper\Data::class); - $this->_store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); - $storeManager = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class, [], [], '', false); + $this->_store = $this->createMock(\Magento\Store\Model\Store::class); + $storeManager = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); $storeManager->expects($this->any())->method('getStore')->will($this->returnValue($this->_store)); - $currencyFactory = $this->getMock(\Magento\Directory\Model\CurrencyFactory::class, [], [], '', false); + $currencyFactory = $this->createMock(\Magento\Directory\Model\CurrencyFactory::class); $arguments = [ 'context' => $context, @@ -162,7 +147,7 @@ public function testGetRegionJson() )->method( 'jsonEncode' )->with( - new \PHPUnit_Framework_Constraint_IsIdentical($expectedDataToEncode) + new \PHPUnit\Framework\Constraint\IsIdentical($expectedDataToEncode) )->will( $this->returnValue('encoded_json') ); @@ -251,7 +236,7 @@ public function testGetCountryCollection() $this->returnValue(0) ); - $store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $store = $this->createMock(\Magento\Store\Model\Store::class); $this->_countryCollection->expects( $this->once() )->method( diff --git a/app/code/Magento/Directory/Test/Unit/Model/AllowedCountriesTest.php b/app/code/Magento/Directory/Test/Unit/Model/AllowedCountriesTest.php index ee2dca2e579ba..5931e5a839341 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/AllowedCountriesTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/AllowedCountriesTest.php @@ -13,7 +13,7 @@ use Magento\Store\Model\ScopeInterface; use Magento\Store\Model\StoreManagerInterface; -class AllowedCountriesTest extends \PHPUnit_Framework_TestCase +class AllowedCountriesTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject | ScopeConfigInterface @@ -32,8 +32,8 @@ class AllowedCountriesTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->scopeConfigMock = $this->getMock(ScopeConfigInterface::class); - $this->storeManagerMock = $this->getMock(StoreManagerInterface::class); + $this->scopeConfigMock = $this->createMock(ScopeConfigInterface::class); + $this->storeManagerMock = $this->createMock(StoreManagerInterface::class); $this->allowedCountriesReader = new AllowedCountries( $this->scopeConfigMock, @@ -43,7 +43,7 @@ public function setUp() public function testGetAllowedCountriesWithEmptyFilter() { - $website1 = $this->getMock(WebsiteInterface::class); + $website1 = $this->createMock(WebsiteInterface::class); $website1->expects($this->once()) ->method('getId') ->willReturn(1); diff --git a/app/code/Magento/Directory/Test/Unit/Model/Config/Source/AllRegionTest.php b/app/code/Magento/Directory/Test/Unit/Model/Config/Source/AllRegionTest.php index 6ec9af7451e06..a824b1282c533 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/Config/Source/AllRegionTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/Config/Source/AllRegionTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Directory\Test\Unit\Model\Config\Source; -class AllRegionTest extends \PHPUnit_Framework_TestCase +class AllRegionTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Directory\Model\Config\Source\AllRegion diff --git a/app/code/Magento/Directory/Test/Unit/Model/Config/Source/CountryTest.php b/app/code/Magento/Directory/Test/Unit/Model/Config/Source/CountryTest.php index 7eddb7e13200b..c9e8018328217 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/Config/Source/CountryTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/Config/Source/CountryTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Directory\Test\Unit\Model\Config\Source; -class CountryTest extends \PHPUnit_Framework_TestCase +class CountryTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Directory\Model\Config\Source\Country @@ -20,13 +20,7 @@ class CountryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->_collectionMock = $this->getMock( - \Magento\Directory\Model\ResourceModel\Country\Collection::class, - [], - [], - '', - false - ); + $this->_collectionMock = $this->createMock(\Magento\Directory\Model\ResourceModel\Country\Collection::class); $arguments = ['countryCollection' => $this->_collectionMock]; $this->_model = $objectManagerHelper->getObject( \Magento\Directory\Model\Config\Source\Country::class, diff --git a/app/code/Magento/Directory/Test/Unit/Model/Country/Postcode/Config/ConverterTest.php b/app/code/Magento/Directory/Test/Unit/Model/Country/Postcode/Config/ConverterTest.php index 450c15be0ff7b..f76817cc072f9 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/Country/Postcode/Config/ConverterTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/Country/Postcode/Config/ConverterTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Directory\Test\Unit\Model\Country\Postcode\Config; -class ConverterTest extends \PHPUnit_Framework_TestCase +class ConverterTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Customer\Model\Address\Config\Converter @@ -19,7 +19,7 @@ class ConverterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->booleanUtilsMock = $this->getMock(\Magento\Framework\Stdlib\BooleanUtils::class, [], [], '', false); + $this->booleanUtilsMock = $this->createMock(\Magento\Framework\Stdlib\BooleanUtils::class); $this->model = new \Magento\Directory\Model\Country\Postcode\Config\Converter($this->booleanUtilsMock); } diff --git a/app/code/Magento/Directory/Test/Unit/Model/Country/Postcode/Config/DataTest.php b/app/code/Magento/Directory/Test/Unit/Model/Country/Postcode/Config/DataTest.php index 4127b15ae40eb..b5674ebf8b01e 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/Country/Postcode/Config/DataTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/Country/Postcode/Config/DataTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Directory\Test\Unit\Model\Country\Postcode\Config; -class DataTest extends \PHPUnit_Framework_TestCase +class DataTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Directory\Model\Country\Postcode\Config\Reader|\PHPUnit_Framework_MockObject_MockObject @@ -24,21 +24,9 @@ class DataTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->readerMock = $this->getMock( - \Magento\Directory\Model\Country\Postcode\Config\Reader::class, - [], - [], - '', - false - ); - $this->cacheMock = $this->getMock( - \Magento\Framework\App\Cache\Type\Config::class, - [], - [], - '', - false - ); - $this->serializerMock = $this->getMock(\Magento\Framework\Serialize\SerializerInterface::class); + $this->readerMock = $this->createMock(\Magento\Directory\Model\Country\Postcode\Config\Reader::class); + $this->cacheMock = $this->createMock(\Magento\Framework\App\Cache\Type\Config::class); + $this->serializerMock = $this->createMock(\Magento\Framework\Serialize\SerializerInterface::class); } public function testGet() diff --git a/app/code/Magento/Directory/Test/Unit/Model/Country/Postcode/Config/ReaderTest.php b/app/code/Magento/Directory/Test/Unit/Model/Country/Postcode/Config/ReaderTest.php index 335745c256318..05c120fcbb7da 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/Country/Postcode/Config/ReaderTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/Country/Postcode/Config/ReaderTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Directory\Test\Unit\Model\Country\Postcode\Config; -class ReaderTest extends \PHPUnit_Framework_TestCase +class ReaderTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Sales\Model\Config\Reader diff --git a/app/code/Magento/Directory/Test/Unit/Model/Country/Postcode/Config/SchemaLocatorTest.php b/app/code/Magento/Directory/Test/Unit/Model/Country/Postcode/Config/SchemaLocatorTest.php index 82a8fea1a6bb0..8eead8cf03cd2 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/Country/Postcode/Config/SchemaLocatorTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/Country/Postcode/Config/SchemaLocatorTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Directory\Test\Unit\Model\Country\Postcode\Config; -class SchemaLocatorTest extends \PHPUnit_Framework_TestCase +class SchemaLocatorTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -19,7 +19,7 @@ class SchemaLocatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->moduleReaderMock = $this->getMock(\Magento\Framework\Module\Dir\Reader::class, [], [], '', false); + $this->moduleReaderMock = $this->createMock(\Magento\Framework\Module\Dir\Reader::class); $this->moduleReaderMock->expects( $this->any() )->method( diff --git a/app/code/Magento/Directory/Test/Unit/Model/Country/Postcode/ConfigTest.php b/app/code/Magento/Directory/Test/Unit/Model/Country/Postcode/ConfigTest.php index 4b267543b7c22..27df4816e2b86 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/Country/Postcode/ConfigTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/Country/Postcode/ConfigTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Directory\Test\Unit\Model\Country\Postcode; -class ConfigTest extends \PHPUnit_Framework_TestCase +class ConfigTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -14,13 +14,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->dataStorageMock = $this->getMock( - \Magento\Directory\Model\Country\Postcode\Config\Data::class, - [], - [], - '', - false - ); + $this->dataStorageMock = $this->createMock(\Magento\Directory\Model\Country\Postcode\Config\Data::class); } public function testGet() diff --git a/app/code/Magento/Directory/Test/Unit/Model/Country/Postcode/ValidatorTest.php b/app/code/Magento/Directory/Test/Unit/Model/Country/Postcode/ValidatorTest.php index 857993f043bef..b200b8d9aa741 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/Country/Postcode/ValidatorTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/Country/Postcode/ValidatorTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Directory\Test\Unit\Model\Country\Postcode; -class ValidatorTest extends \PHPUnit_Framework_TestCase +class ValidatorTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -19,13 +19,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->postcodesConfigMock = $this->getMock( - \Magento\Directory\Model\Country\Postcode\Config::class, - [], - [], - '', - false - ); + $this->postcodesConfigMock = $this->createMock(\Magento\Directory\Model\Country\Postcode\Config::class); $postCodes = [ 'US' => [ 'pattern_1' => ['pattern' => '^[0-9]{5}\-[0-9]{4}$'], diff --git a/app/code/Magento/Directory/Test/Unit/Model/CountryInformationAcquirerTest.php b/app/code/Magento/Directory/Test/Unit/Model/CountryInformationAcquirerTest.php index 7f034f0f8da3d..3f963cb2b82af 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/CountryInformationAcquirerTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/CountryInformationAcquirerTest.php @@ -10,7 +10,7 @@ /** * Class CountryInformationAcquirerTest */ -class CountryInformationAcquirerTest extends \PHPUnit_Framework_TestCase +class CountryInformationAcquirerTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Directory\Model\CountryInformationAcquirer @@ -45,16 +45,16 @@ protected function setUp() $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $className = \Magento\Directory\Model\Data\CountryInformationFactory::class; - $this->countryInformationFactory = $this->getMock($className, ['create'], [], '', false); + $this->countryInformationFactory = $this->createPartialMock($className, ['create']); $className = \Magento\Directory\Model\Data\RegionInformationFactory::class; - $this->regionInformationFactory = $this->getMock($className, ['create'], [], '', false); + $this->regionInformationFactory = $this->createPartialMock($className, ['create']); $className = \Magento\Directory\Helper\Data::class; - $this->directoryHelper = $this->getMock($className, ['getCountryCollection', 'getRegionData'], [], '', false); + $this->directoryHelper = $this->createPartialMock($className, ['getCountryCollection', 'getRegionData']); $className = \Magento\Store\Model\StoreManager::class; - $this->storeManager = $this->getMock($className, ['getStore'], [], '', false); + $this->storeManager = $this->createPartialMock($className, ['getStore']); $this->model = $this->objectManager->getObject( \Magento\Directory\Model\CountryInformationAcquirer::class, @@ -73,7 +73,7 @@ protected function setUp() public function testGetCountriesInfo() { /** @var \Magento\Store\Model\Store $store */ - $store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $store = $this->createMock(\Magento\Store\Model\Store::class); $this->storeManager->expects($this->once())->method('getStore')->willReturn($store); $testCountryInfo = $this->objectManager->getObject(\Magento\Directory\Model\Country::class); @@ -112,7 +112,7 @@ public function testGetCountriesInfo() public function testGetCountryInfo() { /** @var \Magento\Store\Model\Store $store */ - $store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $store = $this->createMock(\Magento\Store\Model\Store::class); $this->storeManager->expects($this->once())->method('getStore')->willReturn($store); $testCountryInfo = $this->objectManager->getObject(\Magento\Directory\Model\Country::class); @@ -122,13 +122,7 @@ public function testGetCountryInfo() $testCountryInfo->setData('name_default', 'United Arab Emirates'); $testCountryInfo->setData('name_en_US', 'United Arab Emirates'); - $countryCollection = $this->getMock( - \Magento\Directory\Model\ResourceModel\Country\Collection::class, - [], - [], - '', - false - ); + $countryCollection = $this->createMock(\Magento\Directory\Model\ResourceModel\Country\Collection::class); $countryCollection->expects($this->once())->method('load')->willReturnSelf(); $countryCollection->expects($this->once())->method('getItemById')->with('AE')->willReturn($testCountryInfo); @@ -155,7 +149,7 @@ public function testGetCountryInfo() public function testGetCountryInfoNotFound() { /** @var \Magento\Store\Model\Store $store */ - $store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $store = $this->createMock(\Magento\Store\Model\Store::class); $this->storeManager->expects($this->once())->method('getStore')->willReturn($store); $testCountryInfo = $this->objectManager->getObject(\Magento\Directory\Model\Country::class); @@ -165,13 +159,7 @@ public function testGetCountryInfoNotFound() $testCountryInfo->setData('name_default', 'United Arab Emirates'); $testCountryInfo->setData('name_en_US', 'United Arab Emirates'); - $countryCollection = $this->getMock( - \Magento\Directory\Model\ResourceModel\Country\Collection::class, - [], - [], - '', - false - ); + $countryCollection = $this->createMock(\Magento\Directory\Model\ResourceModel\Country\Collection::class); $countryCollection->expects($this->once())->method('load')->willReturnSelf(); $this->directoryHelper->expects($this->once())->method('getCountryCollection')->willReturn($countryCollection); diff --git a/app/code/Magento/Directory/Test/Unit/Model/CountryTest.php b/app/code/Magento/Directory/Test/Unit/Model/CountryTest.php index c45931536ef2b..b42214d4dd14a 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/CountryTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/CountryTest.php @@ -8,7 +8,7 @@ use Magento\Directory\Model\Country; -class CountryTest extends \PHPUnit_Framework_TestCase +class CountryTest extends \PHPUnit\Framework\TestCase { protected $country; @@ -19,7 +19,7 @@ class CountryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->localeListsMock = $this->getMock(\Magento\Framework\Locale\ListsInterface::class); + $this->localeListsMock = $this->createMock(\Magento\Framework\Locale\ListsInterface::class); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->country = $objectManager->getObject( diff --git a/app/code/Magento/Directory/Test/Unit/Model/Currency/DefaultLocatorTest.php b/app/code/Magento/Directory/Test/Unit/Model/Currency/DefaultLocatorTest.php index 467ba372cf23f..153e888f87cb8 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/Currency/DefaultLocatorTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/Currency/DefaultLocatorTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Directory\Test\Unit\Model\Currency; -class DefaultLocatorTest extends \PHPUnit_Framework_TestCase +class DefaultLocatorTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Directory\Model\Currency\DefaultLocator @@ -29,7 +29,7 @@ class DefaultLocatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $backendData = $this->getMock(\Magento\Backend\Helper\Data::class, [], [], '', false); + $backendData = $this->createMock(\Magento\Backend\Helper\Data::class); $this->_requestMock = $this->getMockForAbstractClass( \Magento\Framework\App\RequestInterface::class, [$backendData], @@ -39,8 +39,8 @@ protected function setUp() true, ['getParam'] ); - $this->_configMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $this->_storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); + $this->_configMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->_storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManager::class); $this->_model = new \Magento\Directory\Model\Currency\DefaultLocator( $this->_configMock, $this->_storeManagerMock @@ -64,7 +64,7 @@ public function testGetDefaultCurrencyReturnStoreDefaultCurrency() )->will( $this->returnValue('someStore') ); - $storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $storeMock = $this->createMock(\Magento\Store\Model\Store::class); $storeMock->expects($this->once())->method('getBaseCurrencyCode')->will($this->returnValue('storeCurrency')); $this->_storeManagerMock->expects( $this->once() @@ -87,7 +87,7 @@ public function testGetDefaultCurrencyReturnWebsiteDefaultCurrency() )->will( $this->returnValueMap([['store', null, ''], ['website', null, 'someWebsite']]) ); - $websiteMock = $this->getMock(\Magento\Store\Model\Website::class, [], [], '', false); + $websiteMock = $this->createMock(\Magento\Store\Model\Website::class); $websiteMock->expects( $this->once() )->method( @@ -118,7 +118,7 @@ public function testGetDefaultCurrencyReturnGroupDefaultCurrency() [['store', null, ''], ['website', null, ''], ['group', null, 'someGroup']] ) ); - $websiteMock = $this->getMock(\Magento\Store\Model\Website::class, [], [], '', false); + $websiteMock = $this->createMock(\Magento\Store\Model\Website::class); $websiteMock->expects( $this->once() )->method( @@ -127,7 +127,7 @@ public function testGetDefaultCurrencyReturnGroupDefaultCurrency() $this->returnValue('websiteCurrency') ); - $groupMock = $this->getMock(\Magento\Store\Model\Group::class, [], [], '', false); + $groupMock = $this->createMock(\Magento\Store\Model\Group::class); $groupMock->expects($this->once())->method('getWebsite')->will($this->returnValue($websiteMock)); $this->_storeManagerMock->expects( diff --git a/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/ConfigTest.php b/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/ConfigTest.php index c70e7ed3a1159..54ec26386f3bd 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/ConfigTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/ConfigTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Directory\Test\Unit\Model\Currency\Import; -class ConfigTest extends \PHPUnit_Framework_TestCase +class ConfigTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Directory\Model\Currency\Import\Config @@ -29,7 +29,7 @@ protected function setUp() */ public function testConstructorException(array $configData, $expectedException) { - $this->setExpectedException('InvalidArgumentException', $expectedException); + $this->expectException('InvalidArgumentException', $expectedException); new \Magento\Directory\Model\Currency\Import\Config($configData); } diff --git a/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/FactoryTest.php b/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/FactoryTest.php index 2f6d87606d39b..a595b1fe3bf68 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/FactoryTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/FactoryTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Directory\Test\Unit\Model\Currency\Import; -class FactoryTest extends \PHPUnit_Framework_TestCase +class FactoryTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Directory\Model\Currency\Import\Factory @@ -24,14 +24,8 @@ class FactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_objectManager = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); - $this->_importConfig = $this->getMock( - \Magento\Directory\Model\Currency\Import\Config::class, - [], - [], - '', - false - ); + $this->_objectManager = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); + $this->_importConfig = $this->createMock(\Magento\Directory\Model\Currency\Import\Config::class); $this->_model = new \Magento\Directory\Model\Currency\Import\Factory( $this->_objectManager, $this->_importConfig @@ -40,7 +34,7 @@ protected function setUp() public function testCreate() { - $expectedResult = $this->getMock(\Magento\Directory\Model\Currency\Import\ImportInterface::class); + $expectedResult = $this->createMock(\Magento\Directory\Model\Currency\Import\ImportInterface::class); $this->_importConfig->expects( $this->once() )->method( diff --git a/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/FixerIoTest.php b/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/FixerIoTest.php index 3d17d8c3aaf88..c1c3f2fbacb03 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/FixerIoTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/FixerIoTest.php @@ -6,7 +6,7 @@ namespace Magento\Directory\Test\Unit\Model\Currency\Import; -class FixerIoTest extends \PHPUnit_Framework_TestCase +class FixerIoTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Directory\Model\Currency\Import\FixerIo diff --git a/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/Source/ServiceTest.php b/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/Source/ServiceTest.php index 5e7a39f95ff23..2a889a15d80ad 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/Source/ServiceTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/Source/ServiceTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Directory\Test\Unit\Model\Currency\Import\Source; -class ServiceTest extends \PHPUnit_Framework_TestCase +class ServiceTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Directory\Model\Currency\Import\Source\Service @@ -19,13 +19,7 @@ class ServiceTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_importConfig = $this->getMock( - \Magento\Directory\Model\Currency\Import\Config::class, - [], - [], - '', - false - ); + $this->_importConfig = $this->createMock(\Magento\Directory\Model\Currency\Import\Config::class); $this->_model = new \Magento\Directory\Model\Currency\Import\Source\Service($this->_importConfig); } diff --git a/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/YahooFinanceTest.php b/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/YahooFinanceTest.php index 31d4c065756e2..b7b9015ffdfe6 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/YahooFinanceTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/YahooFinanceTest.php @@ -6,7 +6,7 @@ namespace Magento\Directory\Test\Unit\Model\Currency\Import; -class YahooFinanceTest extends \PHPUnit_Framework_TestCase +class YahooFinanceTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Directory\Model\Currency\Import\YahooFinance diff --git a/app/code/Magento/Directory/Test/Unit/Model/CurrencyInformationAcquirerTest.php b/app/code/Magento/Directory/Test/Unit/Model/CurrencyInformationAcquirerTest.php index 732bbd9927ffe..b3b089498dd25 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/CurrencyInformationAcquirerTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/CurrencyInformationAcquirerTest.php @@ -5,12 +5,10 @@ */ namespace Magento\Directory\Test\Unit\Model; -use Magento\Directory\Model\CurrencyInformationAcquirer; - /** * Class CurrencyInformationAcquirerTest */ -class CurrencyInformationAcquirerTest extends \PHPUnit_Framework_TestCase +class CurrencyInformationAcquirerTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Directory\Model\CurrencyInformationAcquirer @@ -45,13 +43,13 @@ protected function setUp() $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $className = \Magento\Directory\Model\Data\CurrencyInformationFactory::class; - $this->currencyInformationFactory = $this->getMock($className, ['create'], [], '', false); + $this->currencyInformationFactory = $this->createPartialMock($className, ['create']); $className = \Magento\Directory\Model\Data\ExchangeRateFactory::class; - $this->exchangeRateFactory = $this->getMock($className, ['create'], [], '', false); + $this->exchangeRateFactory = $this->createPartialMock($className, ['create']); $className = \Magento\Store\Model\StoreManager::class; - $this->storeManager = $this->getMock($className, ['getStore'], [], '', false); + $this->storeManager = $this->createPartialMock($className, ['getStore']); $this->model = $this->objectManager->getObject( \Magento\Directory\Model\CurrencyInformationAcquirer::class, @@ -69,33 +67,27 @@ protected function setUp() public function testGetCurrencyInfo() { /** @var \Magento\Directory\Model\Data\ExchangeRate $exchangeRate */ - $exchangeRate = $this->getMock(\Magento\Directory\Model\Data\ExchangeRate::class, ['load'], [], '', false); + $exchangeRate = $this->createPartialMock(\Magento\Directory\Model\Data\ExchangeRate::class, ['load']); $exchangeRate->expects($this->any())->method('load')->willReturnSelf(); $this->exchangeRateFactory->expects($this->any())->method('create')->willReturn($exchangeRate); /** @var \Magento\Directory\Model\Data\CurrencyInformation $currencyInformation */ - $currencyInformation = $this->getMock( + $currencyInformation = $this->createPartialMock( \Magento\Directory\Model\Data\CurrencyInformation::class, - ['load'], - [], - '', - false + ['load'] ); $currencyInformation->expects($this->any())->method('load')->willReturnSelf(); $this->currencyInformationFactory->expects($this->any())->method('create')->willReturn($currencyInformation); /** @var \Magento\Store\Model\Store $store */ - $store = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $store = $this->createMock(\Magento\Store\Model\Store::class); /** @var \Magento\Directory\Model\Currency $baseCurrency */ - $baseCurrency = $this->getMock( + $baseCurrency = $this->createPartialMock( \Magento\Directory\Model\Currency::class, - ['getCode', 'getCurrencySymbol', 'getRate'], - [], - '', - false + ['getCode', 'getCurrencySymbol', 'getRate'] ); $baseCurrency->expects($this->atLeastOnce())->method('getCode')->willReturn('USD'); $baseCurrency->expects($this->atLeastOnce())->method('getCurrencySymbol')->willReturn('$'); @@ -108,7 +100,7 @@ public function testGetCurrencyInfo() $this->storeManager->expects($this->any())->method('getStore')->willReturn($store); $result = $this->model->getCurrencyInfo(); - + $this->assertEquals($currencyInformation, $result); $this->assertEquals('USD', $result->getBaseCurrencyCode()); $this->assertEquals('$', $result->getBaseCurrencySymbol()); diff --git a/app/code/Magento/Directory/Test/Unit/Model/CurrencyTest.php b/app/code/Magento/Directory/Test/Unit/Model/CurrencyTest.php index 5ef76b4e53f92..d7f7c6f7c09a9 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/CurrencyTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/CurrencyTest.php @@ -8,7 +8,7 @@ use Magento\Directory\Model\Currency; -class CurrencyTest extends \PHPUnit_Framework_TestCase +class CurrencyTest extends \PHPUnit\Framework\TestCase { /** * @var Currency @@ -24,7 +24,7 @@ class CurrencyTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->localeCurrencyMock = $this->getMock(\Magento\Framework\Locale\CurrencyInterface::class); + $this->localeCurrencyMock = $this->createMock(\Magento\Framework\Locale\CurrencyInterface::class); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->currency = $objectManager->getObject( diff --git a/app/code/Magento/Directory/Test/Unit/Model/ObserverTest.php b/app/code/Magento/Directory/Test/Unit/Model/ObserverTest.php index f04655d02c720..5fb7271a411ed 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/ObserverTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/ObserverTest.php @@ -13,7 +13,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ObserverTest extends \PHPUnit_Framework_TestCase +class ObserverTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager */ protected $objectManager; diff --git a/app/code/Magento/Directory/Test/Unit/Model/PriceCurrencyTest.php b/app/code/Magento/Directory/Test/Unit/Model/PriceCurrencyTest.php index a67f5b70a4519..915c11fe1b787 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/PriceCurrencyTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/PriceCurrencyTest.php @@ -8,7 +8,7 @@ use Magento\Directory\Model\PriceCurrency; -class PriceCurrencyTest extends \PHPUnit_Framework_TestCase +class PriceCurrencyTest extends \PHPUnit\Framework\TestCase { /** * @var PriceCurrency diff --git a/app/code/Magento/Directory/Test/Unit/Model/ResourceModel/Country/CollectionTest.php b/app/code/Magento/Directory/Test/Unit/Model/ResourceModel/Country/CollectionTest.php index 4254bc8b3a69e..e8c24febab111 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/ResourceModel/Country/CollectionTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/ResourceModel/Country/CollectionTest.php @@ -11,7 +11,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class CollectionTest extends \PHPUnit_Framework_TestCase +class CollectionTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Directory\Model\ResourceModel\Country\Collection @@ -25,8 +25,8 @@ class CollectionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $connection = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false); - $select = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); + $connection = $this->createMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class); + $select = $this->createMock(\Magento\Framework\DB\Select::class); $connection->expects($this->once())->method('select')->will($this->returnValue($select)); $resource = $this->getMockForAbstractClass( @@ -41,30 +41,18 @@ protected function setUp() $resource->expects($this->any())->method('getConnection')->will($this->returnValue($connection)); $resource->expects($this->any())->method('getTable')->will($this->returnArgument(0)); - $eventManager = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); - $localeListsMock = $this->getMock(\Magento\Framework\Locale\ListsInterface::class); + $eventManager = $this->createMock(\Magento\Framework\Event\ManagerInterface::class); + $localeListsMock = $this->createMock(\Magento\Framework\Locale\ListsInterface::class); $localeListsMock->expects($this->any())->method('getCountryTranslation')->will($this->returnArgument(0)); $fetchStrategy = $this->getMockForAbstractClass( \Magento\Framework\Data\Collection\Db\FetchStrategyInterface::class ); - $entityFactory = $this->getMock(\Magento\Framework\Data\Collection\EntityFactory::class, [], [], '', false); - $this->scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $logger = $this->getMock(\Psr\Log\LoggerInterface::class); - $countryFactory = $this->getMock( - \Magento\Directory\Model\ResourceModel\CountryFactory::class, - [], - [], - '', - false - ); - $helperDataMock = $this->getMock( - \Magento\Directory\Helper\Data::class, - [], - [], - '', - false - ); + $entityFactory = $this->createMock(\Magento\Framework\Data\Collection\EntityFactory::class); + $this->scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $logger = $this->createMock(\Psr\Log\LoggerInterface::class); + $countryFactory = $this->createMock(\Magento\Directory\Model\ResourceModel\CountryFactory::class); + $helperDataMock = $this->createMock(\Magento\Directory\Helper\Data::class); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $arguments = [ 'logger' => $logger, diff --git a/app/code/Magento/Directory/Test/Unit/Model/ResourceModel/Region/CollectionTest.php b/app/code/Magento/Directory/Test/Unit/Model/ResourceModel/Region/CollectionTest.php index f4657e2f2d25a..db76b7ba00a6b 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/ResourceModel/Region/CollectionTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/ResourceModel/Region/CollectionTest.php @@ -24,7 +24,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class CollectionTest extends \PHPUnit_Framework_TestCase +class CollectionTest extends \PHPUnit\Framework\TestCase { /** * @var Collection @@ -39,12 +39,12 @@ class CollectionTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $entityFactoryMock = $this->getMock(EntityFactory::class, [], [], '', false); - $loggerMock = $this->getMock(LoggerInterface::class); - $fetchStrategyMock = $this->getMock(FetchStrategyInterface::class); - $eventManagerMock = $this->getMock(ManagerInterface::class); - $localeResolverMock = $this->getMock(ResolverInterface::class); - $connectionMock = $this->getMock(Mysql::class, [], [], '', false); + $entityFactoryMock = $this->createMock(EntityFactory::class); + $loggerMock = $this->createMock(LoggerInterface::class); + $fetchStrategyMock = $this->createMock(FetchStrategyInterface::class); + $eventManagerMock = $this->createMock(ManagerInterface::class); + $localeResolverMock = $this->createMock(ResolverInterface::class); + $connectionMock = $this->createMock(Mysql::class); $resourceMock = $this->getMockForAbstractClass( AbstractDb::class, [], @@ -54,9 +54,9 @@ protected function setUp() true, ['getConnection', 'getMainTable', 'getTable', '__wakeup'] ); - $this->allowedCountries = $this->getMock(AllowedCountries::class, [], [], '', false); + $this->allowedCountries = $this->createMock(AllowedCountries::class); - $selectMock = $this->getMock(Select::class, [], [], '', false); + $selectMock = $this->createMock(Select::class); $connectionMock->expects($this->any())->method('select')->will($this->returnValue($selectMock)); $resourceMock->expects($this->any())->method('getConnection')->will($this->returnValue($connectionMock)); $resourceMock->expects($this->any())->method('getTable')->will($this->returnArgument(0)); diff --git a/app/code/Magento/Directory/Test/Unit/Model/TopDestinationCountriesTest.php b/app/code/Magento/Directory/Test/Unit/Model/TopDestinationCountriesTest.php index 09d8f35c61d2a..b819cb47274ea 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/TopDestinationCountriesTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/TopDestinationCountriesTest.php @@ -6,7 +6,7 @@ namespace Magento\Directory\Test\Unit\Model; -class TopDestinationCountriesTest extends \PHPUnit_Framework_TestCase +class TopDestinationCountriesTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\App\Config\ScopeConfigInterface diff --git a/app/code/Magento/Directory/etc/module.xml b/app/code/Magento/Directory/etc/module.xml index f4a673789f64d..2711a91577a9a 100644 --- a/app/code/Magento/Directory/etc/module.xml +++ b/app/code/Magento/Directory/etc/module.xml @@ -6,7 +6,7 @@ */ --> - + diff --git a/app/code/Magento/Downloadable/Api/Data/DownloadableOptionInterface.php b/app/code/Magento/Downloadable/Api/Data/DownloadableOptionInterface.php index a83828faf2e1b..f4727ed3bbfc6 100644 --- a/app/code/Magento/Downloadable/Api/Data/DownloadableOptionInterface.php +++ b/app/code/Magento/Downloadable/Api/Data/DownloadableOptionInterface.php @@ -8,6 +8,7 @@ /** * Downloadable Option * @api + * @since 100.0.2 */ interface DownloadableOptionInterface { diff --git a/app/code/Magento/Downloadable/Api/Data/File/ContentInterface.php b/app/code/Magento/Downloadable/Api/Data/File/ContentInterface.php index 3bb75bba1e87c..20a13ff227cd5 100644 --- a/app/code/Magento/Downloadable/Api/Data/File/ContentInterface.php +++ b/app/code/Magento/Downloadable/Api/Data/File/ContentInterface.php @@ -8,6 +8,7 @@ /** * @codeCoverageIgnore * @api + * @since 100.0.2 */ interface ContentInterface extends \Magento\Framework\Api\ExtensibleDataInterface { diff --git a/app/code/Magento/Downloadable/Api/Data/File/ContentUploaderInterface.php b/app/code/Magento/Downloadable/Api/Data/File/ContentUploaderInterface.php index 4b100d99b0367..9e02318769657 100644 --- a/app/code/Magento/Downloadable/Api/Data/File/ContentUploaderInterface.php +++ b/app/code/Magento/Downloadable/Api/Data/File/ContentUploaderInterface.php @@ -8,6 +8,7 @@ /** * @codeCoverageIgnore * @api + * @since 100.0.2 */ interface ContentUploaderInterface { diff --git a/app/code/Magento/Downloadable/Api/Data/LinkInterface.php b/app/code/Magento/Downloadable/Api/Data/LinkInterface.php index 1dfddd369e622..0898c325d4609 100644 --- a/app/code/Magento/Downloadable/Api/Data/LinkInterface.php +++ b/app/code/Magento/Downloadable/Api/Data/LinkInterface.php @@ -8,6 +8,7 @@ /** * @codeCoverageIgnore * @api + * @since 100.0.2 */ interface LinkInterface extends \Magento\Framework\Api\ExtensibleDataInterface { diff --git a/app/code/Magento/Downloadable/Api/Data/ProductAttributeInterface.php b/app/code/Magento/Downloadable/Api/Data/ProductAttributeInterface.php index 247558695c717..aef90a554c9a9 100644 --- a/app/code/Magento/Downloadable/Api/Data/ProductAttributeInterface.php +++ b/app/code/Magento/Downloadable/Api/Data/ProductAttributeInterface.php @@ -8,6 +8,7 @@ /** * Interface ProductAttributeInterface * @api + * @since 100.1.0 */ interface ProductAttributeInterface extends \Magento\Catalog\Api\Data\ProductAttributeInterface { diff --git a/app/code/Magento/Downloadable/Api/Data/SampleInterface.php b/app/code/Magento/Downloadable/Api/Data/SampleInterface.php index 26adfcea569e3..7f33f7fec465f 100644 --- a/app/code/Magento/Downloadable/Api/Data/SampleInterface.php +++ b/app/code/Magento/Downloadable/Api/Data/SampleInterface.php @@ -10,6 +10,7 @@ /** * @codeCoverageIgnore * @api + * @since 100.0.2 */ interface SampleInterface extends \Magento\Framework\Api\ExtensibleDataInterface { diff --git a/app/code/Magento/Downloadable/Api/LinkRepositoryInterface.php b/app/code/Magento/Downloadable/Api/LinkRepositoryInterface.php index 12750911df206..8da1f0b0a75ea 100644 --- a/app/code/Magento/Downloadable/Api/LinkRepositoryInterface.php +++ b/app/code/Magento/Downloadable/Api/LinkRepositoryInterface.php @@ -12,6 +12,7 @@ * Interface LinkRepositoryInterface * @package Magento\Downloadable\Api * @api + * @since 100.0.2 */ interface LinkRepositoryInterface { diff --git a/app/code/Magento/Downloadable/Api/SampleRepositoryInterface.php b/app/code/Magento/Downloadable/Api/SampleRepositoryInterface.php index 462d3d17721f2..d57078a77d815 100644 --- a/app/code/Magento/Downloadable/Api/SampleRepositoryInterface.php +++ b/app/code/Magento/Downloadable/Api/SampleRepositoryInterface.php @@ -10,6 +10,7 @@ /** * Interface SampleRepositoryInterface * @api + * @since 100.0.2 */ interface SampleRepositoryInterface { diff --git a/app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Downloadable.php b/app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Downloadable.php index f0d258c922805..f44d9ffe2b700 100644 --- a/app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Downloadable.php +++ b/app/code/Magento/Downloadable/Block/Adminhtml/Catalog/Product/Composite/Fieldset/Downloadable.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class Downloadable extends \Magento\Downloadable\Block\Catalog\Product\Links { diff --git a/app/code/Magento/Downloadable/Block/Adminhtml/Sales/Items/Column/Downloadable/Name.php b/app/code/Magento/Downloadable/Block/Adminhtml/Sales/Items/Column/Downloadable/Name.php index a9f630dcb625f..f0591816647b7 100644 --- a/app/code/Magento/Downloadable/Block/Adminhtml/Sales/Items/Column/Downloadable/Name.php +++ b/app/code/Magento/Downloadable/Block/Adminhtml/Sales/Items/Column/Downloadable/Name.php @@ -16,6 +16,7 @@ * Sales Order downloadable items name column renderer * * @api + * @since 100.0.2 */ class Name extends \Magento\Sales\Block\Adminhtml\Items\Column\Name { diff --git a/app/code/Magento/Downloadable/Block/Catalog/Product/Links.php b/app/code/Magento/Downloadable/Block/Catalog/Product/Links.php index d82ad61ae4649..ba39bd128372f 100644 --- a/app/code/Magento/Downloadable/Block/Catalog/Product/Links.php +++ b/app/code/Magento/Downloadable/Block/Catalog/Product/Links.php @@ -14,6 +14,7 @@ * Downloadable Product Links part block * * @api + * @since 100.0.2 */ class Links extends \Magento\Catalog\Block\Product\AbstractProduct { diff --git a/app/code/Magento/Downloadable/Block/Catalog/Product/Samples.php b/app/code/Magento/Downloadable/Block/Catalog/Product/Samples.php index 53355a53b65e9..82c58225f3426 100644 --- a/app/code/Magento/Downloadable/Block/Catalog/Product/Samples.php +++ b/app/code/Magento/Downloadable/Block/Catalog/Product/Samples.php @@ -14,6 +14,7 @@ * Downloadable Product Samples part block * * @api + * @since 100.0.2 */ class Samples extends \Magento\Catalog\Block\Product\AbstractProduct { diff --git a/app/code/Magento/Downloadable/Block/Catalog/Product/View/Type.php b/app/code/Magento/Downloadable/Block/Catalog/Product/View/Type.php index faa04744f78f2..75e8d7cdb9fab 100644 --- a/app/code/Magento/Downloadable/Block/Catalog/Product/View/Type.php +++ b/app/code/Magento/Downloadable/Block/Catalog/Product/View/Type.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class Type extends \Magento\Catalog\Block\Product\View\Type\Virtual { diff --git a/app/code/Magento/Downloadable/Block/Checkout/Cart/Item/Renderer.php b/app/code/Magento/Downloadable/Block/Checkout/Cart/Item/Renderer.php index f6b6b55ea0947..65073f267c859 100644 --- a/app/code/Magento/Downloadable/Block/Checkout/Cart/Item/Renderer.php +++ b/app/code/Magento/Downloadable/Block/Checkout/Cart/Item/Renderer.php @@ -16,6 +16,7 @@ /** * @api + * @since 100.0.2 */ class Renderer extends \Magento\Checkout\Block\Cart\Item\Renderer { diff --git a/app/code/Magento/Downloadable/Block/Checkout/Success.php b/app/code/Magento/Downloadable/Block/Checkout/Success.php index 3b94632e57bca..d789ad0bdfae9 100644 --- a/app/code/Magento/Downloadable/Block/Checkout/Success.php +++ b/app/code/Magento/Downloadable/Block/Checkout/Success.php @@ -15,6 +15,7 @@ /** * @api + * @since 100.0.2 */ class Success extends \Magento\Checkout\Block\Onepage\Success { diff --git a/app/code/Magento/Downloadable/Block/Customer/Products/ListProducts.php b/app/code/Magento/Downloadable/Block/Customer/Products/ListProducts.php index 28cc817d964e9..f02a378c496e3 100644 --- a/app/code/Magento/Downloadable/Block/Customer/Products/ListProducts.php +++ b/app/code/Magento/Downloadable/Block/Customer/Products/ListProducts.php @@ -14,6 +14,7 @@ * Block to display downloadable links bought by customer * * @api + * @since 100.0.2 */ class ListProducts extends \Magento\Framework\View\Element\Template { diff --git a/app/code/Magento/Downloadable/Block/Sales/Order/Email/Items/Downloadable.php b/app/code/Magento/Downloadable/Block/Sales/Order/Email/Items/Downloadable.php index 4906c06569325..2f3a39ef7b798 100644 --- a/app/code/Magento/Downloadable/Block/Sales/Order/Email/Items/Downloadable.php +++ b/app/code/Magento/Downloadable/Block/Sales/Order/Email/Items/Downloadable.php @@ -17,6 +17,7 @@ * Downlaodable Sales Order Email items renderer * * @api + * @since 100.0.2 */ class Downloadable extends \Magento\Sales\Block\Order\Email\Items\DefaultItems { @@ -37,6 +38,7 @@ class Downloadable extends \Magento\Sales\Block\Order\Email\Items\DefaultItems /** * @var \Magento\Framework\Url + * @since 100.1.0 */ protected $frontendUrlBuilder; diff --git a/app/code/Magento/Downloadable/Block/Sales/Order/Email/Items/Order/Downloadable.php b/app/code/Magento/Downloadable/Block/Sales/Order/Email/Items/Order/Downloadable.php index aaf60186b23e4..73471c6628811 100644 --- a/app/code/Magento/Downloadable/Block/Sales/Order/Email/Items/Order/Downloadable.php +++ b/app/code/Magento/Downloadable/Block/Sales/Order/Email/Items/Order/Downloadable.php @@ -17,6 +17,7 @@ * Downloadable Sales Order Email items renderer * * @api + * @since 100.0.2 */ class Downloadable extends \Magento\Sales\Block\Order\Email\Items\Order\DefaultOrder { @@ -107,7 +108,7 @@ public function getPurchasedLinkUrl($item) * Get frontend URL builder * * @return \Magento\Framework\UrlInterface - * @deprecated + * @deprecated 100.1.0 */ private function getFrontendUrlBuilder() { diff --git a/app/code/Magento/Downloadable/Block/Sales/Order/Item/Renderer/Downloadable.php b/app/code/Magento/Downloadable/Block/Sales/Order/Item/Renderer/Downloadable.php index d0995681367b5..cb98f802b0fd5 100644 --- a/app/code/Magento/Downloadable/Block/Sales/Order/Item/Renderer/Downloadable.php +++ b/app/code/Magento/Downloadable/Block/Sales/Order/Item/Renderer/Downloadable.php @@ -16,6 +16,7 @@ * Downloadable order item render block * * @api + * @since 100.0.2 */ class Downloadable extends \Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer { diff --git a/app/code/Magento/Downloadable/Helper/Download.php b/app/code/Magento/Downloadable/Helper/Download.php index c21e255cd4ccd..910eaa42f0e84 100644 --- a/app/code/Magento/Downloadable/Helper/Download.php +++ b/app/code/Magento/Downloadable/Helper/Download.php @@ -94,7 +94,9 @@ class Download extends \Magento\Framework\App\Helper\AbstractHelper */ protected $_filesystem; - /** @var Filesystem\File\ReadFactory */ + /** + * @var \Magento\Framework\Filesystem\File\ReadFactory + */ protected $fileReadFactory; /** diff --git a/app/code/Magento/Downloadable/Helper/File.php b/app/code/Magento/Downloadable/Helper/File.php index 27f236dda035f..6c248404d1911 100644 --- a/app/code/Magento/Downloadable/Helper/File.php +++ b/app/code/Magento/Downloadable/Helper/File.php @@ -11,6 +11,7 @@ * Downloadable Products File Helper * * @api + * @since 100.0.2 */ class File extends \Magento\Framework\App\Helper\AbstractHelper { @@ -70,6 +71,7 @@ public function uploadFromTmp($tmpPath, \Magento\MediaStorage\Model\File\Uploade $uploader->setFilesDispersion(true); $absoluteTmpPath = $this->_mediaDirectory->getAbsolutePath($tmpPath); $result = $uploader->save($absoluteTmpPath); + unset($result['path']); return $result; } diff --git a/app/code/Magento/Downloadable/Model/ComponentInterface.php b/app/code/Magento/Downloadable/Model/ComponentInterface.php index 6d28d01455fdc..b1e262fa7464c 100644 --- a/app/code/Magento/Downloadable/Model/ComponentInterface.php +++ b/app/code/Magento/Downloadable/Model/ComponentInterface.php @@ -9,6 +9,7 @@ * Downloadable component interface * * @api + * @since 100.0.2 */ interface ComponentInterface { diff --git a/app/code/Magento/Downloadable/Model/DownloadableOption.php b/app/code/Magento/Downloadable/Model/DownloadableOption.php index 5bff3159a27cd..c29137383a513 100644 --- a/app/code/Magento/Downloadable/Model/DownloadableOption.php +++ b/app/code/Magento/Downloadable/Model/DownloadableOption.php @@ -11,6 +11,7 @@ /** * @codeCoverageIgnore * @api + * @since 100.0.2 */ class DownloadableOption extends AbstractExtensibleModel implements DownloadableOptionInterface { diff --git a/app/code/Magento/Downloadable/Model/File/ContentUploader.php b/app/code/Magento/Downloadable/Model/File/ContentUploader.php index ab8d07a3075df..ab226b40c3cb6 100644 --- a/app/code/Magento/Downloadable/Model/File/ContentUploader.php +++ b/app/code/Magento/Downloadable/Model/File/ContentUploader.php @@ -118,6 +118,7 @@ public function upload(ContentInterface $fileContent, $contentType) $this->setAllowRenameFiles(true); $this->setFilesDispersion(true); $result = $this->save($this->getDestinationDirectory($contentType)); + unset($result['path']); $result['status'] = 'new'; $result['name'] = substr($result['file'], strrpos($result['file'], '/') + 1); return $result; diff --git a/app/code/Magento/Downloadable/Model/Link.php b/app/code/Magento/Downloadable/Model/Link.php index f61c1e771c284..cc14ad7f9b4ac 100644 --- a/app/code/Magento/Downloadable/Model/Link.php +++ b/app/code/Magento/Downloadable/Model/Link.php @@ -12,11 +12,11 @@ * Downloadable link model * * @api - * @method Resource getResource() * @method int getProductId() * @method Link setProductId(int $value) * * @api + * @since 100.0.2 */ class Link extends \Magento\Framework\Model\AbstractExtensibleModel implements ComponentInterface, LinkInterface { diff --git a/app/code/Magento/Downloadable/Model/Link/Builder.php b/app/code/Magento/Downloadable/Model/Link/Builder.php index 9d81037048ce8..83d01f76fe9cd 100644 --- a/app/code/Magento/Downloadable/Model/Link/Builder.php +++ b/app/code/Magento/Downloadable/Model/Link/Builder.php @@ -14,6 +14,7 @@ /** * Class Builder * @api + * @since 100.1.0 */ class Builder { @@ -70,6 +71,7 @@ public function __construct( /** * @param array $data * @return $this + * @since 100.1.0 */ public function setData(array $data) { @@ -81,6 +83,7 @@ public function setData(array $data) * @param \Magento\Downloadable\Api\Data\LinkInterface $link * @return \Magento\Downloadable\Api\Data\LinkInterface * @throws \Magento\Framework\Exception\LocalizedException + * @since 100.1.0 */ public function build(\Magento\Downloadable\Api\Data\LinkInterface $link) { diff --git a/app/code/Magento/Downloadable/Model/Link/Purchased.php b/app/code/Magento/Downloadable/Model/Link/Purchased.php index 7710cdc0f378c..d9d415cf513e0 100644 --- a/app/code/Magento/Downloadable/Model/Link/Purchased.php +++ b/app/code/Magento/Downloadable/Model/Link/Purchased.php @@ -9,8 +9,6 @@ * Downloadable links purchased model * * @api - * @method \Magento\Downloadable\Model\ResourceModel\Link\Purchased _getResource() - * @method \Magento\Downloadable\Model\ResourceModel\Link\Purchased getResource() * @method int getOrderId() * @method \Magento\Downloadable\Model\Link\Purchased setOrderId(int $value) * @method string getOrderIncrementId() @@ -31,6 +29,7 @@ * @method \Magento\Downloadable\Model\Link\Purchased setLinkSectionTitle(string $value) * * @api + * @since 100.0.2 */ class Purchased extends \Magento\Framework\Model\AbstractModel { diff --git a/app/code/Magento/Downloadable/Model/Link/Purchased/Item.php b/app/code/Magento/Downloadable/Model/Link/Purchased/Item.php index 0c667df4b72d3..10304aa6a50fa 100644 --- a/app/code/Magento/Downloadable/Model/Link/Purchased/Item.php +++ b/app/code/Magento/Downloadable/Model/Link/Purchased/Item.php @@ -10,8 +10,6 @@ /** * Downloadable links purchased item model * - * @method Resource _getResource() - * @method Resource getResource() * @method int getPurchasedId() * @method Item setPurchasedId($value) * @method int getOrderItemId() @@ -44,6 +42,7 @@ * @method Item setUpdatedAt($value) * * @api + * @since 100.0.2 */ class Item extends \Magento\Framework\Model\AbstractModel { diff --git a/app/code/Magento/Downloadable/Model/LinkRepository.php b/app/code/Magento/Downloadable/Model/LinkRepository.php index 6df148e7796e9..65239ad353c3f 100644 --- a/app/code/Magento/Downloadable/Model/LinkRepository.php +++ b/app/code/Magento/Downloadable/Model/LinkRepository.php @@ -338,7 +338,7 @@ public function delete($id) /** * Get MetadataPool instance * - * @deprecated MAGETWO-52273 + * @deprecated 100.1.0 MAGETWO-52273 * @return MetadataPool */ private function getMetadataPool() @@ -353,7 +353,7 @@ private function getMetadataPool() /** * Get LinkTypeHandler instance * - * @deprecated MAGETWO-52273 + * @deprecated 100.1.0 MAGETWO-52273 * @return LinkHandler */ private function getLinkTypeHandler() diff --git a/app/code/Magento/Downloadable/Model/Product/Type.php b/app/code/Magento/Downloadable/Model/Product/Type.php index 748c15537b0f6..cb79dda3baccb 100644 --- a/app/code/Magento/Downloadable/Model/Product/Type.php +++ b/app/code/Magento/Downloadable/Model/Product/Type.php @@ -13,6 +13,7 @@ * * @api * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class Type extends \Magento\Catalog\Model\Product\Type\Virtual { diff --git a/app/code/Magento/Downloadable/Model/Product/TypeHandler/Link.php b/app/code/Magento/Downloadable/Model/Product/TypeHandler/Link.php index 58cf909c9e98d..6d567605f8b85 100644 --- a/app/code/Magento/Downloadable/Model/Product/TypeHandler/Link.php +++ b/app/code/Magento/Downloadable/Model/Product/TypeHandler/Link.php @@ -12,6 +12,7 @@ /** * Class Link * @api + * @since 100.0.2 */ class Link extends AbstractTypeHandler { diff --git a/app/code/Magento/Downloadable/Model/Product/TypeHandler/Sample.php b/app/code/Magento/Downloadable/Model/Product/TypeHandler/Sample.php index d316da149ee62..9be9acddf984f 100644 --- a/app/code/Magento/Downloadable/Model/Product/TypeHandler/Sample.php +++ b/app/code/Magento/Downloadable/Model/Product/TypeHandler/Sample.php @@ -12,6 +12,7 @@ /** * Class Sample * @api + * @since 100.0.2 */ class Sample extends AbstractTypeHandler { diff --git a/app/code/Magento/Downloadable/Model/Product/TypeHandler/TypeHandlerInterface.php b/app/code/Magento/Downloadable/Model/Product/TypeHandler/TypeHandlerInterface.php index 8f15269419d16..fd32ede4df884 100644 --- a/app/code/Magento/Downloadable/Model/Product/TypeHandler/TypeHandlerInterface.php +++ b/app/code/Magento/Downloadable/Model/Product/TypeHandler/TypeHandlerInterface.php @@ -10,6 +10,7 @@ /** * Interface TypeHandlerInterface * @api + * @since 100.0.2 */ interface TypeHandlerInterface { diff --git a/app/code/Magento/Downloadable/Model/Quote/Item/CartItemProcessor.php b/app/code/Magento/Downloadable/Model/Quote/Item/CartItemProcessor.php index 627c3edd4896d..563b14d630365 100644 --- a/app/code/Magento/Downloadable/Model/Quote/Item/CartItemProcessor.php +++ b/app/code/Magento/Downloadable/Model/Quote/Item/CartItemProcessor.php @@ -63,6 +63,7 @@ public function __construct( public function convertToBuyRequest(CartItemInterface $cartItem) { if ($cartItem->getProductOption() + && $cartItem->getProductOption()->getExtensionAttributes() && $cartItem->getProductOption()->getExtensionAttributes()->getDownloadableOption() ) { $downloadableLinks = $cartItem->getProductOption()->getExtensionAttributes()->getDownloadableOption() diff --git a/app/code/Magento/Downloadable/Model/ResourceModel/Link.php b/app/code/Magento/Downloadable/Model/ResourceModel/Link.php index 5f869e047d849..24d1d7831c9e3 100644 --- a/app/code/Magento/Downloadable/Model/ResourceModel/Link.php +++ b/app/code/Magento/Downloadable/Model/ResourceModel/Link.php @@ -13,6 +13,7 @@ * Downloadable Product Samples resource model * * @api + * @since 100.0.2 */ class Link extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { diff --git a/app/code/Magento/Downloadable/Model/ResourceModel/Link/Purchased/Collection.php b/app/code/Magento/Downloadable/Model/ResourceModel/Link/Purchased/Collection.php index 59d25db161269..5ea64511d65de 100644 --- a/app/code/Magento/Downloadable/Model/ResourceModel/Link/Purchased/Collection.php +++ b/app/code/Magento/Downloadable/Model/ResourceModel/Link/Purchased/Collection.php @@ -9,6 +9,7 @@ * Downloadable links purchased resource collection * * @api + * @since 100.0.2 */ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { diff --git a/app/code/Magento/Downloadable/Model/ResourceModel/Link/Purchased/Item/Collection.php b/app/code/Magento/Downloadable/Model/ResourceModel/Link/Purchased/Item/Collection.php index 43e74fffc0edb..f2f5798ce8cc0 100644 --- a/app/code/Magento/Downloadable/Model/ResourceModel/Link/Purchased/Item/Collection.php +++ b/app/code/Magento/Downloadable/Model/ResourceModel/Link/Purchased/Item/Collection.php @@ -9,6 +9,7 @@ * Downloadable links purchased items resource collection * * @api + * @since 100.0.2 */ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { diff --git a/app/code/Magento/Downloadable/Model/ResourceModel/Sample.php b/app/code/Magento/Downloadable/Model/ResourceModel/Sample.php index 32a6ee8cc2c17..8d30322745b8d 100644 --- a/app/code/Magento/Downloadable/Model/ResourceModel/Sample.php +++ b/app/code/Magento/Downloadable/Model/ResourceModel/Sample.php @@ -11,11 +11,13 @@ * Downloadable Product Samples resource model * * @api + * @since 100.0.2 */ class Sample extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * @var \Magento\Framework\EntityManager\MetadataPool + * @since 100.1.0 */ protected $metadataPool; diff --git a/app/code/Magento/Downloadable/Model/ResourceModel/Sample/Collection.php b/app/code/Magento/Downloadable/Model/ResourceModel/Sample/Collection.php index 7a4cd10626246..5406d247b508c 100644 --- a/app/code/Magento/Downloadable/Model/ResourceModel/Sample/Collection.php +++ b/app/code/Magento/Downloadable/Model/ResourceModel/Sample/Collection.php @@ -11,11 +11,13 @@ * Downloadable samples resource collection * * @api + * @since 100.0.2 */ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { /** * @var \Magento\Framework\EntityManager\MetadataPool + * @since 100.1.0 */ protected $metadataPool; diff --git a/app/code/Magento/Downloadable/Model/Sales/Order/Pdf/Items/Creditmemo.php b/app/code/Magento/Downloadable/Model/Sales/Order/Pdf/Items/Creditmemo.php index df362a64754c7..2b21993655517 100644 --- a/app/code/Magento/Downloadable/Model/Sales/Order/Pdf/Items/Creditmemo.php +++ b/app/code/Magento/Downloadable/Model/Sales/Order/Pdf/Items/Creditmemo.php @@ -8,6 +8,7 @@ /** * Order Creditmemo Downloadable Pdf Items renderer * @api + * @since 100.0.2 */ class Creditmemo extends \Magento\Downloadable\Model\Sales\Order\Pdf\Items\AbstractItems { diff --git a/app/code/Magento/Downloadable/Model/Sales/Order/Pdf/Items/Invoice.php b/app/code/Magento/Downloadable/Model/Sales/Order/Pdf/Items/Invoice.php index ffcbb69877014..77862cac2f2a9 100644 --- a/app/code/Magento/Downloadable/Model/Sales/Order/Pdf/Items/Invoice.php +++ b/app/code/Magento/Downloadable/Model/Sales/Order/Pdf/Items/Invoice.php @@ -8,6 +8,7 @@ /** * Order Invoice Downloadable Pdf Items renderer * @api + * @since 100.0.2 */ class Invoice extends \Magento\Downloadable\Model\Sales\Order\Pdf\Items\AbstractItems { diff --git a/app/code/Magento/Downloadable/Model/Sample.php b/app/code/Magento/Downloadable/Model/Sample.php index bfd223a92dc67..1a12c1d0bec7f 100644 --- a/app/code/Magento/Downloadable/Model/Sample.php +++ b/app/code/Magento/Downloadable/Model/Sample.php @@ -10,11 +10,10 @@ /** * Downloadable sample model * - * @method \Magento\Downloadable\Model\ResourceModel\Sample _getResource() - * @method \Magento\Downloadable\Model\ResourceModel\Sample getResource() * @method int getProductId() * * @api + * @since 100.0.2 */ class Sample extends \Magento\Framework\Model\AbstractExtensibleModel implements ComponentInterface, SampleInterface { diff --git a/app/code/Magento/Downloadable/Model/Sample/Builder.php b/app/code/Magento/Downloadable/Model/Sample/Builder.php index 3e08405116d35..7cc7cb640ae74 100644 --- a/app/code/Magento/Downloadable/Model/Sample/Builder.php +++ b/app/code/Magento/Downloadable/Model/Sample/Builder.php @@ -16,6 +16,7 @@ /** * Class Builder * @api + * @since 100.1.0 */ class Builder { @@ -72,6 +73,7 @@ public function __construct( /** * @param array $data * @return $this; + * @since 100.1.0 */ public function setData(array $data) { @@ -83,6 +85,7 @@ public function setData(array $data) * @param SampleInterface $sample * @return SampleInterface * @throws \Magento\Framework\Exception\LocalizedException + * @since 100.1.0 */ public function build(SampleInterface $sample) { diff --git a/app/code/Magento/Downloadable/Model/SampleRepository.php b/app/code/Magento/Downloadable/Model/SampleRepository.php index a1840c2124b34..633243ac2eb86 100644 --- a/app/code/Magento/Downloadable/Model/SampleRepository.php +++ b/app/code/Magento/Downloadable/Model/SampleRepository.php @@ -327,7 +327,7 @@ public function delete($id) /** * Get MetadataPool instance * - * @deprecated + * @deprecated 100.1.0 * @return MetadataPool */ private function getMetadataPool() @@ -342,7 +342,7 @@ private function getMetadataPool() /** * Get SampleTypeHandler Instance * - * @deprecated + * @deprecated 100.1.0 * @return SampleHandler */ private function getSampleTypeHandler() diff --git a/app/code/Magento/Downloadable/Test/Unit/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/LinksTest.php b/app/code/Magento/Downloadable/Test/Unit/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/LinksTest.php index a2c8f0f94b8c9..8b9900d747ce5 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/LinksTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/LinksTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Downloadable\Test\Unit\Block\Adminhtml\Catalog\Product\Edit\Tab\Downloadable; -class LinksTest extends \PHPUnit_Framework_TestCase +class LinksTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Downloadable\Block\Adminhtml\Catalog\Product\Edit\Tab\Downloadable\Links @@ -50,45 +50,25 @@ class LinksTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->urlBuilder = $this->getMock(\Magento\Backend\Model\Url::class, ['getUrl'], [], '', false); - $attributeFactory = $this->getMock(\Magento\Eav\Model\Entity\AttributeFactory::class, [], [], '', false); - $urlFactory = $this->getMock(\Magento\Backend\Model\UrlFactory::class, [], [], '', false); - $this->fileHelper = $this->getMock( - \Magento\Downloadable\Helper\File::class, - [ + $this->urlBuilder = $this->createPartialMock(\Magento\Backend\Model\Url::class, ['getUrl']); + $attributeFactory = $this->createMock(\Magento\Eav\Model\Entity\AttributeFactory::class); + $urlFactory = $this->createMock(\Magento\Backend\Model\UrlFactory::class); + $this->fileHelper = $this->createPartialMock(\Magento\Downloadable\Helper\File::class, [ 'getFilePath', 'ensureFileInFilesystem', 'getFileSize' - ], - [], - '', - false - ); - $this->productModel = $this->getMock( - \Magento\Catalog\Model\Product::class, - [ + ]); + $this->productModel = $this->createPartialMock(\Magento\Catalog\Model\Product::class, [ '__wakeup', 'getTypeId', 'getTypeInstance', 'getStoreId' - ], - [], - '', - false - ); - $this->downloadableProductModel = $this->getMock( - \Magento\Downloadable\Model\Product\Type::class, - [ + ]); + $this->downloadableProductModel = $this->createPartialMock(\Magento\Downloadable\Model\Product\Type::class, [ '__wakeup', 'getLinks' - ], - [], - '', - false - ); - $this->downloadableLinkModel = $this->getMock( - \Magento\Downloadable\Model\Link::class, - [ + ]); + $this->downloadableLinkModel = $this->createPartialMock(\Magento\Downloadable\Model\Link::class, [ '__wakeup', 'getId', 'getTitle', @@ -101,24 +81,14 @@ protected function setUp() 'getSortOrder', 'getLinkFile', 'getStoreTitle' - ], - [], - '', - false - ); + ]); - $this->coreRegistry = $this->getMock( - \Magento\Framework\Registry::class, - [ + $this->coreRegistry = $this->createPartialMock(\Magento\Framework\Registry::class, [ '__wakeup', 'registry' - ], - [], - '', - false - ); + ]); - $this->escaper = $this->getMock(\Magento\Framework\Escaper::class, ['escapeHtml'], [], '', false); + $this->escaper = $this->createPartialMock(\Magento\Framework\Escaper::class, ['escapeHtml']); $this->block = $objectManagerHelper->getObject( \Magento\Downloadable\Block\Adminhtml\Catalog\Product\Edit\Tab\Downloadable\Links::class, diff --git a/app/code/Magento/Downloadable/Test/Unit/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/SamplesTest.php b/app/code/Magento/Downloadable/Test/Unit/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/SamplesTest.php index 0bc9671b8d100..e850923bbd068 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/SamplesTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/SamplesTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Downloadable\Test\Unit\Block\Adminhtml\Catalog\Product\Edit\Tab\Downloadable; -class SamplesTest extends \PHPUnit_Framework_TestCase +class SamplesTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Downloadable\Block\Adminhtml\Catalog\Product\Edit\Tab\Downloadable\Samples @@ -51,66 +51,37 @@ protected function setUp() { $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->urlBuilder = $this->getMock(\Magento\Backend\Model\Url::class, ['getUrl'], [], '', false); - $urlFactory = $this->getMock(\Magento\Backend\Model\UrlFactory::class, [], [], '', false); - $this->fileHelper = $this->getMock( - \Magento\Downloadable\Helper\File::class, - [ + $this->urlBuilder = $this->createPartialMock(\Magento\Backend\Model\Url::class, ['getUrl']); + $urlFactory = $this->createMock(\Magento\Backend\Model\UrlFactory::class); + $this->fileHelper = $this->createPartialMock(\Magento\Downloadable\Helper\File::class, [ 'getFilePath', 'ensureFileInFilesystem', 'getFileSize' - ], - [], - '', - false - ); - $this->productModel = $this->getMock( - \Magento\Catalog\Model\Product::class, - [ + ]); + $this->productModel = $this->createPartialMock(\Magento\Catalog\Model\Product::class, [ '__wakeup', 'getTypeId', 'getTypeInstance', 'getStoreId' - ], - [], - '', - false - ); - $this->downloadableProductModel = $this->getMock( - \Magento\Downloadable\Model\Product\Type::class, - [ + ]); + $this->downloadableProductModel = $this->createPartialMock(\Magento\Downloadable\Model\Product\Type::class, [ '__wakeup', 'getSamples' - ], - [], - '', - false - ); - $this->downloadableSampleModel = $this->getMock( - \Magento\Downloadable\Model\Sample::class, - [ + ]); + $this->downloadableSampleModel = $this->createPartialMock(\Magento\Downloadable\Model\Sample::class, [ '__wakeup', 'getId', 'getTitle', 'getSampleFile', 'getSampleType', - 'getSortOrder' - ], - [], - '', - false - ); - $this->coreRegistry = $this->getMock( - \Magento\Framework\Registry::class, - [ + 'getSortOrder', + 'getSampleUrl' + ]); + $this->coreRegistry = $this->createPartialMock(\Magento\Framework\Registry::class, [ '__wakeup', 'registry' - ], - [], - '', - false - ); - $this->escaper = $this->getMock(\Magento\Framework\Escaper::class, ['escapeHtml'], [], '', false); + ]); + $this->escaper = $this->createPartialMock(\Magento\Framework\Escaper::class, ['escapeHtml']); $this->block = $objectManagerHelper->getObject( \Magento\Downloadable\Block\Adminhtml\Catalog\Product\Edit\Tab\Downloadable\Samples::class, [ diff --git a/app/code/Magento/Downloadable/Test/Unit/Block/Adminhtml/Sales/Items/Column/Downloadable/NameTest.php b/app/code/Magento/Downloadable/Test/Unit/Block/Adminhtml/Sales/Items/Column/Downloadable/NameTest.php index b2cf7647447f7..03829e87f3226 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Block/Adminhtml/Sales/Items/Column/Downloadable/NameTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Block/Adminhtml/Sales/Items/Column/Downloadable/NameTest.php @@ -11,7 +11,7 @@ /** * Tests Magento\Downloadable\Block\Adminhtml\Sales\Items\Column\Downloadable\Name */ -class NameTest extends \PHPUnit_Framework_TestCase +class NameTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Downloadable\Block\Adminhtml\Sales\Items\Column\Downloadable\Name diff --git a/app/code/Magento/Downloadable/Test/Unit/Block/Catalog/Product/LinksTest.php b/app/code/Magento/Downloadable/Test/Unit/Block/Catalog/Product/LinksTest.php index 9797363a87885..13f474e5f0bf8 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Block/Catalog/Product/LinksTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Block/Catalog/Product/LinksTest.php @@ -13,7 +13,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class LinksTest extends \PHPUnit_Framework_TestCase +class LinksTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Downloadable\Block\Catalog\Product\Links @@ -43,17 +43,17 @@ class LinksTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->layout = $this->getMock(\Magento\Framework\View\Layout::class, [], [], '', false); - $contextMock = $this->getMock(\Magento\Catalog\Block\Product\Context::class, [], [], '', false, false); + $this->layout = $this->createMock(\Magento\Framework\View\Layout::class); + $contextMock = $this->createMock(\Magento\Catalog\Block\Product\Context::class); $contextMock->expects($this->once()) ->method('getLayout') ->will($this->returnValue($this->layout)); - $this->priceInfoMock = $this->getMock(\Magento\Framework\Pricing\PriceInfo\Base::class, [], [], '', false); - $this->productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $this->priceInfoMock = $this->createMock(\Magento\Framework\Pricing\PriceInfo\Base::class); + $this->productMock = $this->createMock(\Magento\Catalog\Model\Product::class); $this->productMock->expects($this->any()) ->method('getPriceInfo') ->will($this->returnValue($this->priceInfoMock)); - $this->jsonEncoder = $this->getMock(\Magento\Framework\Json\EncoderInterface::class, [], [], '', false); + $this->jsonEncoder = $this->createMock(\Magento\Framework\Json\EncoderInterface::class); $this->linksBlock = $objectManager->getObject( \Magento\Downloadable\Block\Catalog\Product\Links::class, @@ -69,9 +69,9 @@ protected function setUp() public function testGetLinkPrice() { - $linkPriceMock = $this->getMock(\Magento\Downloadable\Pricing\Price\LinkPrice::class, [], [], '', false); - $amountMock = $this->getMock(\Magento\Framework\Pricing\Amount\Base::class, [], [], '', false); - $linkMock = $this->getMock(\Magento\Downloadable\Model\Link::class, [], [], '', false); + $linkPriceMock = $this->createMock(\Magento\Downloadable\Pricing\Price\LinkPrice::class); + $amountMock = $this->createMock(\Magento\Framework\Pricing\Amount\Base::class); + $linkMock = $this->createMock(\Magento\Downloadable\Model\Link::class); $priceCode = 'link_price'; $arguments = []; @@ -88,14 +88,7 @@ public function testGetLinkPrice() ->with($linkMock) ->will($this->returnValue($amountMock)); - $priceBoxMock = $this->getMock( - \Magento\Framework\Pricing\Render::class, - ['renderAmount'], - [], - '', - false, - false - ); + $priceBoxMock = $this->createPartialMock(\Magento\Framework\Pricing\Render::class, ['renderAmount']); $this->layout->expects($this->once()) ->method('getBlock') @@ -126,7 +119,7 @@ public function testGetJsonConfig() ], ]; - $linkAmountMock = $this->getMock(\Magento\Framework\Pricing\Amount\AmountInterface::class, [], [], '', false); + $linkAmountMock = $this->createMock(\Magento\Framework\Pricing\Amount\AmountInterface::class); $linkAmountMock->expects($this->once()) ->method('getValue') ->will($this->returnValue($linkPrice)); @@ -134,13 +127,7 @@ public function testGetJsonConfig() ->method('getBaseAmount') ->will($this->returnValue($linkPrice)); - $typeInstanceMock = $this->getMock( - \Magento\Catalog\Model\Product\Type\Simple::class, - ['getLinks'], - [], - '', - false - ); + $typeInstanceMock = $this->createPartialMock(\Magento\Catalog\Model\Product\Type\Simple::class, ['getLinks']); $typeInstanceMock->expects($this->once()) ->method('getLinks') ->will($this->returnValue([$this->getLinkMock($linkPrice, $linkId)])); @@ -148,7 +135,7 @@ public function testGetJsonConfig() ->method('getTypeInstance') ->will($this->returnValue($typeInstanceMock)); - $finalPriceMock = $this->getMock(\Magento\Catalog\Pricing\Price\FinalPrice::class, [], [], '', false); + $finalPriceMock = $this->createMock(\Magento\Catalog\Pricing\Price\FinalPrice::class); $finalPriceMock->expects($this->once()) ->method('getCustomAmount') ->with($linkPrice) @@ -171,15 +158,9 @@ public function testGetJsonConfig() protected function getLinkMock($linkPrice, $linkId) { - $linkMock = $this->getMock( - \Magento\Downloadable\Model\Link::class, - ['getPrice', + $linkMock = $this->createPartialMock(\Magento\Downloadable\Model\Link::class, ['getPrice', 'getId', - '__wakeup'], - [], - '', - false - ); + '__wakeup']); $linkMock->expects($this->any()) ->method('getPrice') ->will($this->returnValue($linkPrice)); diff --git a/app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Email/Items/DownloadableTest.php b/app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Email/Items/DownloadableTest.php index 17d059560a348..cc83618fc29aa 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Email/Items/DownloadableTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Email/Items/DownloadableTest.php @@ -11,7 +11,7 @@ /** * Tests Magento\Downloadable\Test\Unit\Block\Sales\Order\Email\Items\Downloadable */ -class DownloadableTest extends \PHPUnit_Framework_TestCase +class DownloadableTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Downloadable\Block\Sales\Order\Email\Items\Downloadable diff --git a/app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Email/Items/Order/DownloadableTest.php b/app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Email/Items/Order/DownloadableTest.php index d3d9025a947cd..3534b909e49e8 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Email/Items/Order/DownloadableTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Email/Items/Order/DownloadableTest.php @@ -11,7 +11,7 @@ /** * Tests Magento\Downloadable\Test\Unit\Block\Sales\Order\Email\Items\Order\Downloadable */ -class DownloadableTest extends \PHPUnit_Framework_TestCase +class DownloadableTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Downloadable\Block\Sales\Order\Email\Items\Order\Downloadable diff --git a/app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Item/Renderer/DownloadableTest.php b/app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Item/Renderer/DownloadableTest.php index 5ffe781c6f521..4bf56e205f023 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Item/Renderer/DownloadableTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Item/Renderer/DownloadableTest.php @@ -11,7 +11,7 @@ /** * Tests Magento\Downloadable\Test\Unit\Block\Sales\Order\Item\Renderer\Downloadable */ -class DownloadableTest extends \PHPUnit_Framework_TestCase +class DownloadableTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Downloadable\Block\Sales\Order\Item\Renderer\Downloadable diff --git a/app/code/Magento/Downloadable/Test/Unit/Controller/Adminhtml/Downloadable/File/UploadTest.php b/app/code/Magento/Downloadable/Test/Unit/Controller/Adminhtml/Downloadable/File/UploadTest.php index 3c2e9ff4e68ad..df1f127fae313 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Controller/Adminhtml/Downloadable/File/UploadTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Controller/Adminhtml/Downloadable/File/UploadTest.php @@ -11,7 +11,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class UploadTest extends \PHPUnit_Framework_TestCase +class UploadTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Downloadable\Controller\Adminhtml\Downloadable\File\Upload */ protected $upload; @@ -91,8 +91,8 @@ protected function setUp() $this->context = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class) ->disableOriginalConstructor() ->getMock(); - $this->request = $this->getMock(\Magento\Framework\App\RequestInterface::class); - $this->response = $this->getMock( + $this->request = $this->createMock(\Magento\Framework\App\RequestInterface::class); + $this->response = $this->createPartialMock( \Magento\Framework\App\ResponseInterface::class, [ 'setHttpResponseCode', @@ -102,15 +102,9 @@ protected function setUp() 'setHeader' ] ); - $this->fileHelper = $this->getMock( - \Magento\Downloadable\Helper\File::class, - [ + $this->fileHelper = $this->createPartialMock(\Magento\Downloadable\Helper\File::class, [ 'uploadFromTmp' - ], - [], - '', - false - ); + ]); $this->context->expects($this->any()) ->method('getRequest') ->will($this->returnValue($this->request)); diff --git a/app/code/Magento/Downloadable/Test/Unit/Controller/Adminhtml/Downloadable/Product/Edit/LinkTest.php b/app/code/Magento/Downloadable/Test/Unit/Controller/Adminhtml/Downloadable/Product/Edit/LinkTest.php index 1bd0c614f8666..e125ddee9c5d8 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Controller/Adminhtml/Downloadable/Product/Edit/LinkTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Controller/Adminhtml/Downloadable/Product/Edit/LinkTest.php @@ -8,7 +8,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -class LinkTest extends \PHPUnit_Framework_TestCase +class LinkTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Downloadable\Controller\Adminhtml\Downloadable\Product\Edit\Link */ protected $link; @@ -52,7 +52,7 @@ protected function setUp() $this->request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); - $this->response = $this->getMock( + $this->response = $this->createPartialMock( \Magento\Framework\App\ResponseInterface::class, [ 'setHttpResponseCode', @@ -62,30 +62,18 @@ protected function setUp() 'setHeader' ] ); - $this->fileHelper = $this->getMock( - \Magento\Downloadable\Helper\File::class, - [ + $this->fileHelper = $this->createPartialMock(\Magento\Downloadable\Helper\File::class, [ 'getFilePath' - ], - [], - '', - false - ); - $this->downloadHelper = $this->getMock( - \Magento\Downloadable\Helper\Download::class, - [ + ]); + $this->downloadHelper = $this->createPartialMock(\Magento\Downloadable\Helper\Download::class, [ 'setResource', 'getFilename', 'getContentType', 'output', 'getFileSize', 'getContentDisposition' - ], - [], - '', - false - ); - $this->linkModel = $this->getMock( + ]); + $this->linkModel = $this->createPartialMock( \Magento\Downloadable\Controller\Adminhtml\Downloadable\Product\Edit\Link::class, [ 'load', @@ -98,21 +86,12 @@ protected function setUp() 'getBaseSamplePath', 'getLinkFile', 'getSampleFile' - ], - [], - '', - false + ] ); - $this->objectManager = $this->getMock( - \Magento\Framework\ObjectManager\ObjectManager::class, - [ + $this->objectManager = $this->createPartialMock(\Magento\Framework\ObjectManager\ObjectManager::class, [ 'create', 'get' - ], - [], - '', - false - ); + ]); $this->link = $this->objectManagerHelper->getObject( \Magento\Downloadable\Controller\Adminhtml\Downloadable\Product\Edit\Link::class, diff --git a/app/code/Magento/Downloadable/Test/Unit/Controller/Adminhtml/Downloadable/Product/Edit/SampleTest.php b/app/code/Magento/Downloadable/Test/Unit/Controller/Adminhtml/Downloadable/Product/Edit/SampleTest.php index d77d43de9c286..b6b94910a1a3e 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Controller/Adminhtml/Downloadable/Product/Edit/SampleTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Controller/Adminhtml/Downloadable/Product/Edit/SampleTest.php @@ -8,7 +8,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -class SampleTest extends \PHPUnit_Framework_TestCase +class SampleTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Downloadable\Controller\Adminhtml\Downloadable\Product\Edit\Sample */ protected $sample; @@ -52,7 +52,7 @@ protected function setUp() $this->request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); - $this->response = $this->getMock( + $this->response = $this->createPartialMock( \Magento\Framework\App\ResponseInterface::class, [ 'setHttpResponseCode', @@ -62,30 +62,18 @@ protected function setUp() 'setHeader' ] ); - $this->fileHelper = $this->getMock( - \Magento\Downloadable\Helper\File::class, - [ + $this->fileHelper = $this->createPartialMock(\Magento\Downloadable\Helper\File::class, [ 'getFilePath' - ], - [], - '', - false - ); - $this->downloadHelper = $this->getMock( - \Magento\Downloadable\Helper\Download::class, - [ + ]); + $this->downloadHelper = $this->createPartialMock(\Magento\Downloadable\Helper\Download::class, [ 'setResource', 'getFilename', 'getContentType', 'output', 'getFileSize', 'getContentDisposition' - ], - [], - '', - false - ); - $this->sampleModel = $this->getMock( + ]); + $this->sampleModel = $this->createPartialMock( \Magento\Downloadable\Controller\Adminhtml\Downloadable\Product\Edit\Sample::class, [ 'load', @@ -95,21 +83,12 @@ protected function setUp() 'getBasePath', 'getBaseSamplePath', 'getSampleFile', - ], - [], - '', - false + ] ); - $this->objectManager = $this->getMock( - \Magento\Framework\ObjectManager\ObjectManager::class, - [ + $this->objectManager = $this->createPartialMock(\Magento\Framework\ObjectManager\ObjectManager::class, [ 'create', 'get' - ], - [], - '', - false - ); + ]); $this->sample = $this->objectManagerHelper->getObject( \Magento\Downloadable\Controller\Adminhtml\Downloadable\Product\Edit\Sample::class, [ diff --git a/app/code/Magento/Downloadable/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/DownloadableTest.php b/app/code/Magento/Downloadable/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/DownloadableTest.php index 4f0c16e371278..3b3683c6af3e7 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/DownloadableTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/DownloadableTest.php @@ -7,7 +7,7 @@ use Magento\Catalog\Api\Data\ProductExtensionInterface; -class DownloadableTest extends \PHPUnit_Framework_TestCase +class DownloadableTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Downloadable\Controller\Adminhtml\Product\Initialization\Helper\Plugin\Downloadable @@ -36,20 +36,13 @@ class DownloadableTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); - $this->productMock = $this->getMock( + $this->requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class); + $this->productMock = $this->createPartialMock( \Magento\Catalog\Model\Product::class, - ['setDownloadableData', 'getExtensionAttributes', '__wakeup'], - [], - '', - false + ['setDownloadableData', 'getExtensionAttributes', '__wakeup'] ); - $this->subjectMock = $this->getMock( - \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper::class, - [], - [], - '', - false + $this->subjectMock = $this->createMock( + \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper::class ); $this->extensionAttributesMock = $this->getMockBuilder(ProductExtensionInterface::class) ->disableOriginalConstructor() diff --git a/app/code/Magento/Downloadable/Test/Unit/Controller/Download/LinkSampleTest.php b/app/code/Magento/Downloadable/Test/Unit/Controller/Download/LinkSampleTest.php index 298c3533925e3..ce01b449d3388 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Controller/Download/LinkSampleTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Controller/Download/LinkSampleTest.php @@ -10,7 +10,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class LinkSampleTest extends \PHPUnit_Framework_TestCase +class LinkSampleTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Downloadable\Controller\Download\LinkSample */ protected $linkSample; @@ -70,8 +70,8 @@ protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->request = $this->getMock(\Magento\Framework\App\RequestInterface::class); - $this->response = $this->getMock( + $this->request = $this->createMock(\Magento\Framework\App\RequestInterface::class); + $this->response = $this->createPartialMock( \Magento\Framework\App\ResponseInterface::class, [ 'setHttpResponseCode', @@ -83,73 +83,31 @@ protected function setUp() ] ); - $this->helperData = $this->getMock( - \Magento\Downloadable\Helper\Data::class, - [ + $this->helperData = $this->createPartialMock(\Magento\Downloadable\Helper\Data::class, [ 'getIsShareable' - ], - [], - '', - false - ); - $this->downloadHelper = $this->getMock( - \Magento\Downloadable\Helper\Download::class, - [ + ]); + $this->downloadHelper = $this->createPartialMock(\Magento\Downloadable\Helper\Download::class, [ 'setResource', 'getFilename', 'getContentType', 'getFileSize', 'getContentDisposition', 'output' - ], - [], - '', - false - ); - $this->product = $this->getMock( - \Magento\Catalog\Model\Product::class, - [ + ]); + $this->product = $this->createPartialMock(\Magento\Catalog\Model\Product::class, [ '_wakeup', 'load', 'getId', 'getProductUrl', 'getName' - ], - [], - '', - false - ); - $this->messageManager = $this->getMock( - \Magento\Framework\Message\ManagerInterface::class, - [], - [], - '', - false - ); - $this->redirect = $this->getMock( - \Magento\Framework\App\Response\RedirectInterface::class, - [], - [], - '', - false - ); - $this->urlInterface = $this->getMock( - \Magento\Framework\UrlInterface::class, - [], - [], - '', - false - ); - $this->objectManager = $this->getMock( - \Magento\Framework\ObjectManager\ObjectManager::class, - [ + ]); + $this->messageManager = $this->createMock(\Magento\Framework\Message\ManagerInterface::class); + $this->redirect = $this->createMock(\Magento\Framework\App\Response\RedirectInterface::class); + $this->urlInterface = $this->createMock(\Magento\Framework\UrlInterface::class); + $this->objectManager = $this->createPartialMock(\Magento\Framework\ObjectManager\ObjectManager::class, [ 'create', 'get' - ], - [], - '', - false - ); + ]); $this->linkSample = $this->objectManagerHelper->getObject( \Magento\Downloadable\Controller\Download\LinkSample::class, [ diff --git a/app/code/Magento/Downloadable/Test/Unit/Controller/Download/LinkTest.php b/app/code/Magento/Downloadable/Test/Unit/Controller/Download/LinkTest.php index b7993c09dab51..3e1255766f1f9 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Controller/Download/LinkTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Controller/Download/LinkTest.php @@ -10,7 +10,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class LinkTest extends \PHPUnit_Framework_TestCase +class LinkTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Downloadable\Controller\Download\Link */ protected $link; @@ -87,7 +87,7 @@ protected function setUp() $this->request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor()->getMock(); - $this->response = $this->getMock( + $this->response = $this->createPartialMock( \Magento\Framework\App\ResponseInterface::class, [ 'setHttpResponseCode', @@ -97,56 +97,30 @@ protected function setUp() 'setHeader' ] ); - $this->session = $this->getMock( - \Magento\Customer\Model\Session::class, - [ + $this->session = $this->createPartialMock(\Magento\Customer\Model\Session::class, [ 'getCustomerId', 'authenticate', 'setBeforeAuthUrl' - ], - [], - '', - false - ); - $this->helperData = $this->getMock( - \Magento\Downloadable\Helper\Data::class, - [ + ]); + $this->helperData = $this->createPartialMock(\Magento\Downloadable\Helper\Data::class, [ 'getIsShareable' - ], - [], - '', - false - ); - $this->downloadHelper = $this->getMock( - \Magento\Downloadable\Helper\Download::class, - [ + ]); + $this->downloadHelper = $this->createPartialMock(\Magento\Downloadable\Helper\Download::class, [ 'setResource', 'getFilename', 'getContentType', 'getFileSize', 'getContentDisposition', 'output' - ], - [], - '', - false - ); - $this->product = $this->getMock( - \Magento\Catalog\Model\Product::class, - [ + ]); + $this->product = $this->createPartialMock(\Magento\Catalog\Model\Product::class, [ '_wakeup', 'load', 'getId', 'getProductUrl', 'getName' - ], - [], - '', - false - ); - $this->linkPurchasedItem = $this->getMock( - \Magento\Downloadable\Model\Link\Purchased\Item::class, - [ + ]); + $this->linkPurchasedItem = $this->createPartialMock(\Magento\Downloadable\Model\Link\Purchased\Item::class, [ 'load', 'getId', 'getProductId', @@ -160,52 +134,18 @@ protected function setUp() 'setNumberOfDownloadsUsed', 'setStatus', 'save', - ], - [], - '', - false - ); - $this->linkPurchased = $this->getMock( - \Magento\Downloadable\Model\Link\Purchased::class, - [ + ]); + $this->linkPurchased = $this->createPartialMock(\Magento\Downloadable\Model\Link\Purchased::class, [ 'load', 'getCustomerId' - ], - [], - '', - false - ); - $this->messageManager = $this->getMock( - \Magento\Framework\Message\ManagerInterface::class, - [], - [], - '', - false - ); - $this->redirect = $this->getMock( - \Magento\Framework\App\Response\RedirectInterface::class, - [], - [], - '', - false - ); - $this->urlInterface = $this->getMock( - \Magento\Framework\UrlInterface::class, - [], - [], - '', - false - ); - $this->objectManager = $this->getMock( - \Magento\Framework\ObjectManager\ObjectManager::class, - [ + ]); + $this->messageManager = $this->createMock(\Magento\Framework\Message\ManagerInterface::class); + $this->redirect = $this->createMock(\Magento\Framework\App\Response\RedirectInterface::class); + $this->urlInterface = $this->createMock(\Magento\Framework\UrlInterface::class); + $this->objectManager = $this->createPartialMock(\Magento\Framework\ObjectManager\ObjectManager::class, [ 'create', 'get' - ], - [], - '', - false - ); + ]); $this->link = $this->objectManagerHelper->getObject( \Magento\Downloadable\Controller\Download\Link::class, [ diff --git a/app/code/Magento/Downloadable/Test/Unit/Controller/Download/SampleTest.php b/app/code/Magento/Downloadable/Test/Unit/Controller/Download/SampleTest.php index 5535e248fe8a9..2545e15317ebb 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Controller/Download/SampleTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Controller/Download/SampleTest.php @@ -10,7 +10,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class SampleTest extends \PHPUnit_Framework_TestCase +class SampleTest extends \PHPUnit\Framework\TestCase { /** @var \Magento\Downloadable\Controller\Download\Sample */ protected $sample; @@ -70,8 +70,8 @@ protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->request = $this->getMock(\Magento\Framework\App\RequestInterface::class); - $this->response = $this->getMock( + $this->request = $this->createMock(\Magento\Framework\App\RequestInterface::class); + $this->response = $this->createPartialMock( \Magento\Framework\App\ResponseInterface::class, [ 'setHttpResponseCode', @@ -83,73 +83,31 @@ protected function setUp() ] ); - $this->helperData = $this->getMock( - \Magento\Downloadable\Helper\Data::class, - [ + $this->helperData = $this->createPartialMock(\Magento\Downloadable\Helper\Data::class, [ 'getIsShareable' - ], - [], - '', - false - ); - $this->downloadHelper = $this->getMock( - \Magento\Downloadable\Helper\Download::class, - [ + ]); + $this->downloadHelper = $this->createPartialMock(\Magento\Downloadable\Helper\Download::class, [ 'setResource', 'getFilename', 'getContentType', 'getFileSize', 'getContentDisposition', 'output' - ], - [], - '', - false - ); - $this->product = $this->getMock( - \Magento\Catalog\Model\Product::class, - [ + ]); + $this->product = $this->createPartialMock(\Magento\Catalog\Model\Product::class, [ '_wakeup', 'load', 'getId', 'getProductUrl', 'getName' - ], - [], - '', - false - ); - $this->messageManager = $this->getMock( - \Magento\Framework\Message\ManagerInterface::class, - [], - [], - '', - false - ); - $this->redirect = $this->getMock( - \Magento\Framework\App\Response\RedirectInterface::class, - [], - [], - '', - false - ); - $this->urlInterface = $this->getMock( - \Magento\Framework\UrlInterface::class, - [], - [], - '', - false - ); - $this->objectManager = $this->getMock( - \Magento\Framework\ObjectManager\ObjectManager::class, - [ + ]); + $this->messageManager = $this->createMock(\Magento\Framework\Message\ManagerInterface::class); + $this->redirect = $this->createMock(\Magento\Framework\App\Response\RedirectInterface::class); + $this->urlInterface = $this->createMock(\Magento\Framework\UrlInterface::class); + $this->objectManager = $this->createPartialMock(\Magento\Framework\ObjectManager\ObjectManager::class, [ 'create', 'get' - ], - [], - '', - false - ); + ]); $this->sample = $this->objectManagerHelper->getObject( \Magento\Downloadable\Controller\Download\Sample::class, [ diff --git a/app/code/Magento/Downloadable/Test/Unit/Helper/Catalog/Product/ConfigurationTest.php b/app/code/Magento/Downloadable/Test/Unit/Helper/Catalog/Product/ConfigurationTest.php index 5fe00ffae841c..fd71ec7b2975c 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Helper/Catalog/Product/ConfigurationTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Helper/Catalog/Product/ConfigurationTest.php @@ -11,7 +11,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ConfigurationTest extends \PHPUnit_Framework_TestCase +class ConfigurationTest extends \PHPUnit\Framework\TestCase { /** @var ObjectManagerHelper */ protected $objectManagerHelper; @@ -41,7 +41,7 @@ protected function setUp() $this->context = $this->getMockBuilder(\Magento\Framework\App\Helper\Context::class) ->disableOriginalConstructor() ->getMock(); - $this->scopeConfig = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->scopeConfig = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $this->productConfig = $this->getMockBuilder(\Magento\Catalog\Helper\Product\Configuration::class) ->disableOriginalConstructor() ->getMock(); @@ -85,12 +85,12 @@ public function testGetLinksTitleWithoutTitle() public function testGetOptions() { - $item = $this->getMock(\Magento\Catalog\Model\Product\Configuration\Item\ItemInterface::class); + $item = $this->createMock(\Magento\Catalog\Model\Product\Configuration\Item\ItemInterface::class); $product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->setMethods(['_wakeup', 'getLinksTitle', 'getTypeInstance']) ->getMock(); - $option = $this->getMock(\Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface::class); + $option = $this->createMock(\Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface::class); $productType = $this->getMockBuilder(\Magento\Downloadable\Model\Product\Type::class) ->disableOriginalConstructor() ->setMethods(['getLinks']) diff --git a/app/code/Magento/Downloadable/Test/Unit/Helper/DownloadTest.php b/app/code/Magento/Downloadable/Test/Unit/Helper/DownloadTest.php index 0ef2af43c2145..3142900613296 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Helper/DownloadTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Helper/DownloadTest.php @@ -15,7 +15,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class DownloadTest extends \PHPUnit_Framework_TestCase +class DownloadTest extends \PHPUnit\Framework\TestCase { /** @var DownloadHelper */ protected $_helper; @@ -59,32 +59,14 @@ protected function setUp() self::$functionExists = true; self::$mimeContentType = self::MIME_TYPE; - $this->_filesystemMock = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); - $this->_handleMock = $this->getMock( - \Magento\Framework\Filesystem\File\ReadInterface::class, - [], - [], - '', - false - ); - $this->_workingDirectoryMock = $this->getMock( - \Magento\Framework\Filesystem\Directory\ReadInterface::class, - [], - [], - '', - false - ); - $this->_downloadableFileMock = $this->getMock(\Magento\Downloadable\Helper\File::class, [], [], '', false); + $this->_filesystemMock = $this->createMock(\Magento\Framework\Filesystem::class); + $this->_handleMock = $this->createMock(\Magento\Framework\Filesystem\File\ReadInterface::class); + $this->_workingDirectoryMock = $this->createMock(\Magento\Framework\Filesystem\Directory\ReadInterface::class); + $this->_downloadableFileMock = $this->createMock(\Magento\Downloadable\Helper\File::class); $this->sessionManager = $this->getMockForAbstractClass( \Magento\Framework\Session\SessionManagerInterface::class ); - $this->fileReadFactory = $this->getMock( - \Magento\Framework\Filesystem\File\ReadFactory::class, - [], - [], - '', - false - ); + $this->fileReadFactory = $this->createMock(\Magento\Framework\Filesystem\File\ReadFactory::class); $this->_helper = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject( \Magento\Downloadable\Helper\Download::class, diff --git a/app/code/Magento/Downloadable/Test/Unit/Helper/FileTest.php b/app/code/Magento/Downloadable/Test/Unit/Helper/FileTest.php new file mode 100644 index 0000000000000..96444e0d67ade --- /dev/null +++ b/app/code/Magento/Downloadable/Test/Unit/Helper/FileTest.php @@ -0,0 +1,100 @@ +mediaDirectory = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\WriteInterface::class) + ->getMockForAbstractClass(); + + $this->filesystem = $this->getMockBuilder(\Magento\Framework\Filesystem::class) + ->disableOriginalConstructor() + ->getMock(); + $this->filesystem->expects($this->any()) + ->method('getDirectoryWrite') + ->with(\Magento\Framework\App\Filesystem\DirectoryList::MEDIA) + ->willReturn($this->mediaDirectory); + + $this->coreFileStorageDatabase = + $this->getMockBuilder(\Magento\MediaStorage\Helper\File\Storage\Database::class) + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + $this->appContext = $this->getMockBuilder(\Magento\Framework\App\Helper\Context::class) + ->disableOriginalConstructor() + ->setMethods( + [ + 'getModuleManager', + 'getLogger', + 'getRequest', + 'getUrlBuilder', + 'getHttpHeader', + 'getEventManager', + 'getRemoteAddress', + 'getCacheConfig', + 'getUrlEncoder', + 'getUrlDecoder', + 'getScopeConfig' + ] + ) + ->getMock(); + $this->file = new \Magento\Downloadable\Helper\File( + $this->appContext, + $this->coreFileStorageDatabase, + $this->filesystem + ); + } + + public function testUploadFromTmp() + { + $uploaderMock = $this->getMockBuilder(\Magento\MediaStorage\Model\File\Uploader::class) + ->disableOriginalConstructor() + ->getMock(); + $uploaderMock->expects($this->once())->method('setAllowRenameFiles'); + $uploaderMock->expects($this->once())->method('setFilesDispersion'); + $this->mediaDirectory->expects($this->once())->method('getAbsolutePath')->willReturn('absPath'); + $uploaderMock->expects($this->once())->method('save')->with('absPath') + ->willReturn(['file' => 'file.jpg', 'path' => 'absPath']); + + $result = $this->file->uploadFromTmp('tmpPath', $uploaderMock); + + $this->assertArrayNotHasKey('path', $result); + } +} diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/File/ContentValidatorTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/File/ContentValidatorTest.php index 457f7f15443f2..5aa55e7ab261a 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Model/File/ContentValidatorTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Model/File/ContentValidatorTest.php @@ -7,7 +7,7 @@ use Magento\Downloadable\Model\File\ContentValidator; -class ContentValidatorTest extends \PHPUnit_Framework_TestCase +class ContentValidatorTest extends \PHPUnit\Framework\TestCase { /** * @var ContentValidator @@ -23,7 +23,7 @@ protected function setUp() { $this->validator = new \Magento\Downloadable\Model\File\ContentValidator(); - $this->fileContentMock = $this->getMock(\Magento\Downloadable\Api\Data\File\ContentInterface::class); + $this->fileContentMock = $this->createMock(\Magento\Downloadable\Api\Data\File\ContentInterface::class); } public function testIsValid() diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/Link/BuilderTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/Link/BuilderTest.php index 7d7f7d23c7910..26c5ccd90c463 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Model/Link/BuilderTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Model/Link/BuilderTest.php @@ -13,7 +13,7 @@ /** * Class BuilderTest */ -class BuilderTest extends \PHPUnit_Framework_TestCase +class BuilderTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/Link/ContentValidatorTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/Link/ContentValidatorTest.php index 44d4b97e7ca0a..2639c22ff2ca2 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Model/Link/ContentValidatorTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Model/Link/ContentValidatorTest.php @@ -7,7 +7,7 @@ use Magento\Downloadable\Model\Link\ContentValidator; -class ContentValidatorTest extends \PHPUnit_Framework_TestCase +class ContentValidatorTest extends \PHPUnit\Framework\TestCase { /** * @var ContentValidator @@ -36,29 +36,17 @@ class ContentValidatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->fileValidatorMock = $this->getMock( - \Magento\Downloadable\Model\File\ContentValidator::class, - [], - [], - '', - false - ); - $this->urlValidatorMock = $this->getMock( - \Magento\Framework\Url\Validator::class, - [], - [], - '', - false - ); - $this->linkFileMock = $this->getMock(\Magento\Downloadable\Api\Data\File\ContentInterface::class); - $this->sampleFileMock = $this->getMock(\Magento\Downloadable\Api\Data\File\ContentInterface::class); + $this->fileValidatorMock = $this->createMock(\Magento\Downloadable\Model\File\ContentValidator::class); + $this->urlValidatorMock = $this->createMock(\Magento\Framework\Url\Validator::class); + $this->linkFileMock = $this->createMock(\Magento\Downloadable\Api\Data\File\ContentInterface::class); + $this->sampleFileMock = $this->createMock(\Magento\Downloadable\Api\Data\File\ContentInterface::class); $this->validator = new ContentValidator($this->fileValidatorMock, $this->urlValidatorMock); } public function testIsValid() { - $linkFileContentMock = $this->getMock(\Magento\Downloadable\Api\Data\File\ContentInterface::class); - $sampleFileContentMock = $this->getMock(\Magento\Downloadable\Api\Data\File\ContentInterface::class); + $linkFileContentMock = $this->createMock(\Magento\Downloadable\Api\Data\File\ContentInterface::class); + $sampleFileContentMock = $this->createMock(\Magento\Downloadable\Api\Data\File\ContentInterface::class); $linkData = [ 'title' => 'Title', 'sort_order' => 1, @@ -78,7 +66,7 @@ public function testIsValid() public function testIsValidSkipLinkContent() { - $sampleFileContentMock = $this->getMock(\Magento\Downloadable\Api\Data\File\ContentInterface::class); + $sampleFileContentMock = $this->createMock(\Magento\Downloadable\Api\Data\File\ContentInterface::class); $linkData = [ 'title' => 'Title', 'sort_order' => 1, @@ -98,7 +86,7 @@ public function testIsValidSkipLinkContent() public function testIsValidSkipSampleContent() { - $sampleFileContentMock = $this->getMock(\Magento\Downloadable\Api\Data\File\ContentInterface::class); + $sampleFileContentMock = $this->createMock(\Magento\Downloadable\Api\Data\File\ContentInterface::class); $linkData = [ 'title' => 'Title', 'sort_order' => 1, @@ -226,7 +214,19 @@ public function getInvalidNumberOfDownloads() */ protected function getLinkMock(array $linkData) { - $linkMock = $this->getMock(\Magento\Downloadable\Api\Data\LinkInterface::class); + $linkMock = $this->getMockBuilder(\Magento\Downloadable\Api\Data\LinkInterface::class) + ->setMethods( + [ + 'getTitle', + 'getPrice', + 'getSortOrder', + 'isShareable', + 'getNumberOfDownloads', + 'getLinkType', + 'getLinkFile' + ] + ) + ->getMockForAbstractClass(); $linkMock->expects($this->any())->method('getTitle')->will($this->returnValue( $linkData['title'] )); diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/Link/CreateHandlerTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/Link/CreateHandlerTest.php index 1fe697240d6d7..5eef790666033 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Model/Link/CreateHandlerTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Model/Link/CreateHandlerTest.php @@ -12,7 +12,7 @@ use Magento\Downloadable\Model\Link\CreateHandler; use Magento\Downloadable\Model\Product\Type; -class CreateHandlerTest extends \PHPUnit_Framework_TestCase +class CreateHandlerTest extends \PHPUnit\Framework\TestCase { /** @var CreateHandler */ protected $model; diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/Link/UpdateHandlerTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/Link/UpdateHandlerTest.php index b3e28539153b5..12c845de51ffe 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Model/Link/UpdateHandlerTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Model/Link/UpdateHandlerTest.php @@ -12,7 +12,7 @@ use Magento\Downloadable\Model\Link\UpdateHandler; use Magento\Downloadable\Model\Product\Type; -class UpdateHandlerTest extends \PHPUnit_Framework_TestCase +class UpdateHandlerTest extends \PHPUnit\Framework\TestCase { /** @var UpdateHandler */ protected $model; diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/LinkRepositoryTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/LinkRepositoryTest.php index 3e7f47fc77160..d835f25523353 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Model/LinkRepositoryTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Model/LinkRepositoryTest.php @@ -10,7 +10,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class LinkRepositoryTest extends \PHPUnit_Framework_TestCase +class LinkRepositoryTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -74,8 +74,8 @@ class LinkRepositoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->repositoryMock = $this->getMock(\Magento\Catalog\Model\ProductRepository::class, [], [], '', false); - $this->productTypeMock = $this->getMock(\Magento\Downloadable\Model\Product\Type::class, [], [], '', false); + $this->repositoryMock = $this->createMock(\Magento\Catalog\Model\ProductRepository::class); + $this->productTypeMock = $this->createMock(\Magento\Downloadable\Model\Product\Type::class); $this->linkDataObjectFactory = $this->getMockBuilder(\Magento\Downloadable\Api\Data\LinkInterfaceFactory::class) ->setMethods( [ @@ -89,29 +89,15 @@ protected function setUp() )->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $this->contentValidatorMock = $this->getMock( - \Magento\Downloadable\Model\Link\ContentValidator::class, - [], - [], - '', - false - ); - $this->contentUploaderMock = $this->getMock( + $this->contentValidatorMock = $this->createMock(\Magento\Downloadable\Model\Link\ContentValidator::class); + $this->contentUploaderMock = $this->createMock( \Magento\Downloadable\Api\Data\File\ContentUploaderInterface::class ); - $this->jsonEncoderMock = $this->getMock( + $this->jsonEncoderMock = $this->createMock( \Magento\Framework\Json\EncoderInterface::class ); - $this->linkFactoryMock = $this->getMock( - \Magento\Downloadable\Model\LinkFactory::class, - ['create'], - [], - '', - false - ); - $this->productMock = $this->getMock( - \Magento\Catalog\Model\Product::class, - [ + $this->linkFactoryMock = $this->createPartialMock(\Magento\Downloadable\Model\LinkFactory::class, ['create']); + $this->productMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, [ '__wakeup', 'getTypeId', 'setDownloadableData', @@ -121,11 +107,7 @@ protected function setUp() 'getStore', 'getWebsiteIds', 'getData' - ], - [], - '', - false - ); + ]); $this->service = new \Magento\Downloadable\Model\LinkRepository( $this->repositoryMock, $this->productTypeMock, @@ -168,13 +150,21 @@ protected function setUp() */ protected function getLinkMock(array $linkData) { - $linkMock = $this->getMock( - \Magento\Downloadable\Api\Data\LinkInterface::class, - [], - [], - '', - false - ); + $linkMock = $this->getMockBuilder(\Magento\Downloadable\Api\Data\LinkInterface::class) + ->setMethods( + [ + 'getLinkType', + 'getId', + 'getPrice', + 'getTitle', + 'getSortOrder', + 'getNumberOfDownloads', + 'getIsShareable', + 'getLinkUrl', + 'getLinkFile' + ] + ) + ->getMockForAbstractClass(); if (isset($linkData['id'])) { $linkMock->expects($this->any())->method('getId')->willReturn($linkData['id']); @@ -315,21 +305,15 @@ public function testUpdate() $this->repositoryMock->expects($this->any())->method('get')->with($productSku, true) ->will($this->returnValue($this->productMock)); $this->productMock->expects($this->any())->method('getData')->will($this->returnValue($productId)); - $storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $storeMock = $this->createMock(\Magento\Store\Model\Store::class); $storeMock->expects($this->any())->method('getWebsiteId')->will($this->returnValue($websiteId)); $this->productMock->expects($this->any())->method('getStore')->will($this->returnValue($storeMock)); - $existingLinkMock = $this->getMock( - \Magento\Downloadable\Model\Link::class, - [ + $existingLinkMock = $this->createPartialMock(\Magento\Downloadable\Model\Link::class, [ '__wakeup', 'getId', 'load', 'getProductId' - ], - [], - '', - false - ); + ]); $this->linkFactoryMock->expects($this->once())->method('create')->will($this->returnValue($existingLinkMock)); $linkMock = $this->getLinkMock($linkData); $this->contentValidatorMock->expects($this->any())->method('isValid')->with($linkMock) @@ -383,21 +367,15 @@ public function testUpdateWithExistingFile() $this->repositoryMock->expects($this->any())->method('get')->with($productSku, true) ->will($this->returnValue($this->productMock)); $this->productMock->expects($this->any())->method('getData')->will($this->returnValue($productId)); - $storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $storeMock = $this->createMock(\Magento\Store\Model\Store::class); $storeMock->expects($this->any())->method('getWebsiteId')->will($this->returnValue($websiteId)); $this->productMock->expects($this->any())->method('getStore')->will($this->returnValue($storeMock)); - $existingLinkMock = $this->getMock( - \Magento\Downloadable\Model\Link::class, - [ + $existingLinkMock = $this->createPartialMock(\Magento\Downloadable\Model\Link::class, [ '__wakeup', 'getId', 'load', 'getProductId' - ], - [], - '', - false - ); + ]); $this->linkFactoryMock->expects($this->once())->method('create')->will($this->returnValue($existingLinkMock)); $linkMock = $this->getLinkMock($linkData); $this->contentValidatorMock->expects($this->any())->method('isValid')->with($linkMock) @@ -461,12 +439,9 @@ public function testUpdateThrowsExceptionIfTitleIsEmptyAndScopeIsGlobal() $this->repositoryMock->expects($this->any())->method('get')->with($productSku, true) ->will($this->returnValue($this->productMock)); $this->productMock->expects($this->any())->method('getData')->will($this->returnValue($productId)); - $existingLinkMock = $this->getMock( + $existingLinkMock = $this->createPartialMock( \Magento\Downloadable\Model\Link::class, - ['__wakeup', 'getId', 'load', 'save', 'getProductId'], - [], - '', - false + ['__wakeup', 'getId', 'load', 'save', 'getProductId'] ); $existingLinkMock->expects($this->any())->method('getId')->will($this->returnValue($linkId)); $existingLinkMock->expects($this->any())->method('getProductId')->will($this->returnValue($productId)); @@ -483,13 +458,7 @@ public function testUpdateThrowsExceptionIfTitleIsEmptyAndScopeIsGlobal() public function testDelete() { $linkId = 1; - $linkMock = $this->getMock( - \Magento\Downloadable\Model\Link::class, - [], - [], - '', - false - ); + $linkMock = $this->createMock(\Magento\Downloadable\Model\Link::class); $this->linkFactoryMock->expects($this->once())->method('create')->will($this->returnValue($linkMock)); $linkMock->expects($this->once())->method('load')->with($linkId)->will($this->returnSelf()); $linkMock->expects($this->any())->method('getId')->will($this->returnValue($linkId)); @@ -505,13 +474,7 @@ public function testDelete() public function testDeleteThrowsExceptionIfLinkIdIsNotValid() { $linkId = 1; - $linkMock = $this->getMock( - \Magento\Downloadable\Model\Link::class, - [], - [], - '', - false - ); + $linkMock = $this->createMock(\Magento\Downloadable\Model\Link::class); $this->linkFactoryMock->expects($this->once())->method('create')->will($this->returnValue($linkMock)); $linkMock->expects($this->once())->method('load')->with($linkId)->will($this->returnSelf()); $linkMock->expects($this->once())->method('getId'); @@ -540,9 +503,7 @@ public function testGetList() 'link_file' => null ]; - $linkMock = $this->getMock( - \Magento\Downloadable\Model\Link::class, - [ + $linkMock = $this->createPartialMock(\Magento\Downloadable\Model\Link::class, [ 'getId', 'getStoreTitle', 'getTitle', @@ -551,14 +512,16 @@ public function testGetList() 'getSortOrder', 'getIsShareable', 'getData', - '__wakeup' - ], - [], - '', - false - ); - - $linkInterfaceMock = $this->getMock(\Magento\Downloadable\Api\Data\LinkInterface::class); + '__wakeup', + 'getSampleType', + 'getSampleFile', + 'getSampleUrl', + 'getLinkType', + 'getLinkFile', + 'getLinkUrl' + ]); + + $linkInterfaceMock = $this->createMock(\Magento\Downloadable\Api\Data\LinkInterface::class); $this->repositoryMock->expects($this->once()) ->method('get') diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/Product/CopyConstructor/DownloadableTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/Product/CopyConstructor/DownloadableTest.php index 75143d9036099..447e252d910b1 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Model/Product/CopyConstructor/DownloadableTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Model/Product/CopyConstructor/DownloadableTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Downloadable\Test\Unit\Model\Product\CopyConstructor; -class DownloadableTest extends \PHPUnit_Framework_TestCase +class DownloadableTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Downloadable\Model\Product\CopyConstructor\Downloadable @@ -49,30 +49,21 @@ class DownloadableTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->jsonHelperMock = $this->getMock(\Magento\Framework\Json\Helper\Data::class, [], [], '', false); + $this->jsonHelperMock = $this->createMock(\Magento\Framework\Json\Helper\Data::class); $this->_model = new \Magento\Downloadable\Model\Product\CopyConstructor\Downloadable($this->jsonHelperMock); - $this->_productMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $this->_productMock = $this->createMock(\Magento\Catalog\Model\Product::class); - $this->_duplicateMock = $this->getMock( + $this->_duplicateMock = $this->createPartialMock( \Magento\Catalog\Model\Product::class, - ['setDownloadableData', '__wakeup'], - [], - '', - false + ['setDownloadableData', '__wakeup'] ); - $this->_linkMock = $this->getMock(\Magento\Downloadable\Model\Link::class, [], [], '', false); + $this->_linkMock = $this->createMock(\Magento\Downloadable\Model\Link::class); - $this->_sampleMock = $this->getMock(\Magento\Downloadable\Model\Sample::class, [], [], '', false); + $this->_sampleMock = $this->createMock(\Magento\Downloadable\Model\Sample::class); - $this->_productTypeMock = $this->getMock( - \Magento\Downloadable\Model\Product\Type::class, - [], - [], - '', - false - ); + $this->_productTypeMock = $this->createMock(\Magento\Downloadable\Model\Product\Type::class); $this->jsonHelperMock->expects($this->any())->method('jsonEncode')->will($this->returnArgument(0)); } diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/Product/TypeHandler/LinkTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/Product/TypeHandler/LinkTest.php index 7372ea81e9ccb..07c4538f47b24 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Model/Product/TypeHandler/LinkTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Model/Product/TypeHandler/LinkTest.php @@ -11,7 +11,7 @@ /** * Test for \Magento\Downloadable\Model\Product\TypeHandler\Link */ -class LinkTest extends \PHPUnit_Framework_TestCase +class LinkTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -52,7 +52,7 @@ protected function setUp() $this->metadataPoolMock = $this->getMockBuilder(\Magento\Framework\EntityManager\MetadataPool::class) ->disableOriginalConstructor() ->getMock(); - $this->metadataMock = $this->getMock(\Magento\Framework\EntityManager\EntityMetadata::class, [], [], '', false); + $this->metadataMock = $this->createMock(\Magento\Framework\EntityManager\EntityMetadata::class); $this->metadataMock->expects($this->any())->method('getLinkField')->willReturn('id'); $this->metadataPoolMock->expects($this->any())->method('getMetadata')->willReturn($this->metadataMock); $this->target = $objectManagerHelper->getObject( @@ -289,7 +289,8 @@ private function createProductMock($id, $storeId, $storeWebsiteId, array $websit 'getStore', 'getWebsiteIds', 'getLinksPurchasedSeparately', - 'setIsCustomOptionChanged' + 'setIsCustomOptionChanged', + 'getData' ] ) ->getMock(); diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/Product/TypeHandler/SampleTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/Product/TypeHandler/SampleTest.php index 74d1ca38ad41a..c0ff95169d3a3 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Model/Product/TypeHandler/SampleTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Model/Product/TypeHandler/SampleTest.php @@ -13,7 +13,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class SampleTest extends \PHPUnit_Framework_TestCase +class SampleTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -61,7 +61,7 @@ protected function setUp() $this->metadataPoolMock = $this->getMockBuilder(\Magento\Framework\EntityManager\MetadataPool::class) ->disableOriginalConstructor() ->getMock(); - $this->metadataMock = $this->getMock(\Magento\Framework\EntityManager\EntityMetadata::class, [], [], '', false); + $this->metadataMock = $this->createMock(\Magento\Framework\EntityManager\EntityMetadata::class); $this->metadataPoolMock->expects($this->any())->method('getMetadata')->willReturn($this->metadataMock); $this->target = $objectManagerHelper->getObject( Sample::class, @@ -230,7 +230,7 @@ private function createProductMock($id, $storeId, $storeWebsiteId, array $websit { $product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() - ->setMethods(['getId', 'getStoreId', 'getStore', 'getWebsiteIds']) + ->setMethods(['getId', 'getStoreId', 'getStore', 'getWebsiteIds', 'getData']) ->getMock(); $product->expects($this->any()) ->method('getId') diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/Product/TypeTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/Product/TypeTest.php index 81004b956514b..ab9a8f4c62be3 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Model/Product/TypeTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Model/Product/TypeTest.php @@ -14,7 +14,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class TypeTest extends \PHPUnit_Framework_TestCase +class TypeTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Downloadable\Model\Product\Type @@ -52,58 +52,37 @@ class TypeTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $eventManager = $this->getMock(\Magento\Framework\Event\ManagerInterface::class, [], [], '', false); + $eventManager = $this->createMock(\Magento\Framework\Event\ManagerInterface::class); $fileStorageDb = $this->getMockBuilder( \Magento\MediaStorage\Helper\File\Storage\Database::class )->disableOriginalConstructor()->getMock(); $filesystem = $this->getMockBuilder(\Magento\Framework\Filesystem::class) ->disableOriginalConstructor() ->getMock(); - $coreRegistry = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); - $logger = $this->getMock(\Psr\Log\LoggerInterface::class); - $productFactoryMock = $this->getMock(\Magento\Catalog\Model\ProductFactory::class, [], [], '', false); - $sampleResFactory = $this->getMock( - \Magento\Downloadable\Model\ResourceModel\SampleFactory::class, - [], - [], - '', - false - ); - $linkResource = $this->getMock(\Magento\Downloadable\Model\ResourceModel\Link::class, [], [], '', false); - $this->linksFactory = $this->getMock( + $coreRegistry = $this->createMock(\Magento\Framework\Registry::class); + $logger = $this->createMock(\Psr\Log\LoggerInterface::class); + $productFactoryMock = $this->createMock(\Magento\Catalog\Model\ProductFactory::class); + $sampleResFactory = $this->createMock(\Magento\Downloadable\Model\ResourceModel\SampleFactory::class); + $linkResource = $this->createMock(\Magento\Downloadable\Model\ResourceModel\Link::class); + $this->linksFactory = $this->createPartialMock( \Magento\Downloadable\Model\ResourceModel\Link\CollectionFactory::class, - ['create'], - [], - '', - false - ); - $samplesFactory = $this->getMock( - \Magento\Downloadable\Model\ResourceModel\Sample\CollectionFactory::class, - [], - [], - '', - false + ['create'] ); - $sampleFactory = $this->getMock(\Magento\Downloadable\Model\SampleFactory::class, [], [], '', false); - $linkFactory = $this->getMock(\Magento\Downloadable\Model\LinkFactory::class, [], [], '', false); + $samplesFactory = $this->createMock(\Magento\Downloadable\Model\ResourceModel\Sample\CollectionFactory::class); + $sampleFactory = $this->createMock(\Magento\Downloadable\Model\SampleFactory::class); + $linkFactory = $this->createMock(\Magento\Downloadable\Model\LinkFactory::class); - $entityTypeMock = $this->getMock(\Magento\Eav\Model\Entity\Type::class, [], [], '', false); - $resourceProductMock = $this->getMock( + $entityTypeMock = $this->createMock(\Magento\Eav\Model\Entity\Type::class); + $resourceProductMock = $this->createPartialMock( \Magento\Catalog\Model\ResourceModel\Product::class, - ['getEntityType'], - [], - '', - false + ['getEntityType'] ); $resourceProductMock->expects($this->any())->method('getEntityType')->will($this->returnValue($entityTypeMock)); - $this->serializerMock = $this->getMock( - Json::class, - [], - ['serialize', 'unserialize'], - '', - false - ); + $this->serializerMock = $this->getMockBuilder(Json::class) + ->setConstructorArgs(['serialize', 'unserialize']) + ->disableOriginalConstructor() + ->getMock(); $this->serializerMock->expects($this->any()) ->method('serialize') @@ -121,9 +100,7 @@ function ($value) { } ); - $this->product = $this->getMock( - \Magento\Catalog\Model\Product::class, - [ + $this->product = $this->createPartialMock(\Magento\Catalog\Model\Product::class, [ 'getResource', 'canAffectOptions', 'getLinksPurchasedSeparately', @@ -137,11 +114,7 @@ function ($value) { 'getCustomOption', 'addCustomOption', 'getEntityId' - ], - [], - '', - false - ); + ]); $this->product->expects($this->any())->method('getResource')->will($this->returnValue($resourceProductMock)); $this->product->expects($this->any())->method('setTypeHasRequiredOptions')->with($this->equalTo(true))->will( $this->returnSelf() @@ -153,7 +126,7 @@ function ($value) { $this->product->expects($this->any())->method('setLinksExist')->with($this->equalTo(false)); $this->product->expects($this->any())->method('canAffectOptions')->with($this->equalTo(true)); - $eavConfigMock = $this->getMock(\Magento\Eav\Model\Config::class, ['getEntityAttributes'], [], '', false); + $eavConfigMock = $this->createPartialMock(\Magento\Eav\Model\Config::class, ['getEntityAttributes']); $eavConfigMock->expects($this->any()) ->method('getEntityAttributes') ->with($this->equalTo($entityTypeMock), $this->equalTo($this->product)) @@ -193,7 +166,8 @@ public function testHasWeightFalse() public function testBeforeSave() { - $this->target->beforeSave($this->product); + $result = $this->target->beforeSave($this->product); + $this->assertEquals($result, $this->target); } public function testHasLinks() @@ -207,7 +181,10 @@ public function testHasLinks() public function testCheckProductBuyState() { - $optionMock = $this->getMock(\Magento\Quote\Model\Quote\Item\Option::class, [], ['getValue'], '', false); + $optionMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Item\Option::class) + ->setMethods(['getValue']) + ->disableOriginalConstructor() + ->getMock(); $optionMock->expects($this->any())->method('getValue')->will($this->returnValue('{}')); @@ -224,12 +201,9 @@ public function testCheckProductBuyState() ->method('getEntityId') ->will($this->returnValue(123)); - $linksCollectionMock = $this->getMock( + $linksCollectionMock = $this->createPartialMock( \Magento\Downloadable\Model\ResourceModel\Link\Collection::class, - [], - ['addProductToFilter', 'getAllIds'], - '', - false + ['addProductToFilter', 'getAllIds'] ); $linksCollectionMock->expects($this->once()) @@ -258,7 +232,7 @@ public function testCheckProductBuyState() */ public function testCheckProductBuyStateException() { - $optionMock = $this->getMock(\Magento\Quote\Model\Quote\Item\Option::class, [], ['getValue'], '', false); + $optionMock = $this->createPartialMock(\Magento\Quote\Model\Quote\Item\Option::class, ['getValue']); $optionMock->expects($this->any())->method('getValue')->will($this->returnValue('{}')); diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/Product/TypeTransitionManager/Plugin/DownloadableTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/Product/TypeTransitionManager/Plugin/DownloadableTest.php index 208cdcb944863..c44d8f3124d06 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Model/Product/TypeTransitionManager/Plugin/DownloadableTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Model/Product/TypeTransitionManager/Plugin/DownloadableTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Downloadable\Test\Unit\Model\Product\TypeTransitionManager\Plugin; -class DownloadableTest extends \PHPUnit_Framework_TestCase +class DownloadableTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -39,22 +39,13 @@ class DownloadableTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); - $this->productMock = $this->getMock( + $this->requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class); + $this->productMock = $this->createPartialMock( \Magento\Catalog\Model\Product::class, - ['getTypeId', 'setTypeId'], - [], - '', - false - ); - $this->weightResolver = $this->getMock(\Magento\Catalog\Model\Product\Edit\WeightResolver::class); - $this->subjectMock = $this->getMock( - \Magento\Catalog\Model\Product\TypeTransitionManager::class, - [], - [], - '', - false + ['getTypeId', 'setTypeId'] ); + $this->weightResolver = $this->createMock(\Magento\Catalog\Model\Product\Edit\WeightResolver::class); + $this->subjectMock = $this->createMock(\Magento\Catalog\Model\Product\TypeTransitionManager::class); $this->closureMock = function () { }; $this->model = new \Magento\Downloadable\Model\Product\TypeTransitionManager\Plugin\Downloadable( diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/ProductOptionProcessorTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/ProductOptionProcessorTest.php index a75be287cad1a..9f3e65bc6e99a 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Model/ProductOptionProcessorTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Model/ProductOptionProcessorTest.php @@ -12,7 +12,7 @@ use Magento\Framework\DataObject; use Magento\Framework\DataObject\Factory as DataObjectFactory; -class ProductOptionProcessorTest extends \PHPUnit_Framework_TestCase +class ProductOptionProcessorTest extends \PHPUnit\Framework\TestCase { /** * @var ProductOptionProcessor @@ -48,7 +48,7 @@ protected function setUp() { $this->dataObject = $this->getMockBuilder(\Magento\Framework\DataObject::class) ->setMethods([ - 'getLinks', + 'getLinks', 'addData' ]) ->disableOriginalConstructor() ->getMock(); @@ -174,6 +174,8 @@ public function testConvertToProductOption( if (!empty($expected)) { $this->assertArrayHasKey($expected, $result); $this->assertSame($this->downloadableOption, $result[$expected]); + } else { + $this->assertEmpty($result); } } diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/Quote/Item/CartItemProcessorTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/Quote/Item/CartItemProcessorTest.php index 4411691ec4e79..58c467709f6d4 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Model/Quote/Item/CartItemProcessorTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Model/Quote/Item/CartItemProcessorTest.php @@ -10,7 +10,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class CartItemProcessorTest extends \PHPUnit_Framework_TestCase +class CartItemProcessorTest extends \PHPUnit\Framework\TestCase { /** * @var CartItemProcessor @@ -44,34 +44,19 @@ class CartItemProcessorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectFactoryMock = $this->getMock( - \Magento\Framework\DataObject\Factory::class, - ['create'], - [], - '', - false - ); - $this->optionFactoryMock = $this->getMock( + $this->objectFactoryMock = $this->createPartialMock(\Magento\Framework\DataObject\Factory::class, ['create']); + $this->optionFactoryMock = $this->createPartialMock( \Magento\Quote\Model\Quote\ProductOptionFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->objectHelperMock = $this->getMock(\Magento\Framework\Api\DataObjectHelper::class, [], [], '', false); - $this->extensionFactoryMock = $this->getMock( + $this->objectHelperMock = $this->createMock(\Magento\Framework\Api\DataObjectHelper::class); + $this->extensionFactoryMock = $this->createPartialMock( \Magento\Quote\Api\Data\ProductOptionExtensionFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->downloadableOptionFactoryMock = $this->getMock( + $this->downloadableOptionFactoryMock = $this->createPartialMock( \Magento\Downloadable\Model\DownloadableOptionFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->model = new CartItemProcessor( @@ -85,7 +70,7 @@ protected function setUp() public function testConvertToBuyRequestReturnsNullIfItemDoesNotContainProductOption() { - $cartItemMock = $this->getMock(\Magento\Quote\Api\Data\CartItemInterface::class); + $cartItemMock = $this->createMock(\Magento\Quote\Api\Data\CartItemInterface::class); $this->assertNull($this->model->convertToBuyRequest($cartItemMock)); } @@ -94,27 +79,20 @@ public function testConvertToBuyRequest() $downloadableLinks = [1, 2]; $itemQty = 1; - $cartItemMock = $this->getMock( + $cartItemMock = $this->createPartialMock( \Magento\Quote\Model\Quote\Item::class, - ['getProductOption', 'setProductOption', 'getOptionByCode', 'getQty'], - [], - '', - false + ['getProductOption', 'setProductOption', 'getOptionByCode', 'getQty'] ); - $productOptionMock = $this->getMock(\Magento\Quote\Api\Data\ProductOptionInterface::class); + $productOptionMock = $this->createMock(\Magento\Quote\Api\Data\ProductOptionInterface::class); $cartItemMock->expects($this->any())->method('getProductOption')->willReturn($productOptionMock); $cartItemMock->expects($this->any())->method('getQty')->willReturn($itemQty); - $extAttributesMock = $this->getMock( - \Magento\Quote\Api\Data\ProductOption::class, - ['getDownloadableOption'], - [], - '', - false - ); + $extAttributesMock = $this->getMockBuilder(\Magento\Quote\Api\Data\ProductOptionInterface::class) + ->setMethods(['getDownloadableOption']) + ->getMockForAbstractClass(); $productOptionMock->expects($this->any())->method('getExtensionAttributes')->willReturn($extAttributesMock); - $downloadableOptionMock = $this->getMock(\Magento\Downloadable\Api\Data\DownloadableOptionInterface::class); + $downloadableOptionMock = $this->createMock(\Magento\Downloadable\Api\Data\DownloadableOptionInterface::class); $extAttributesMock->expects($this->any()) ->method('getDownloadableOption') ->willReturn($downloadableOptionMock); @@ -133,25 +111,30 @@ public function testConvertToBuyRequest() $this->assertEquals($buyRequestMock, $this->model->convertToBuyRequest($cartItemMock)); } + public function testConvertToBuyRequestWithoutExtensionAttributes() + { + $cartItemMock = $this->createPartialMock( + \Magento\Quote\Model\Quote\Item::class, + ['getProductOption', 'setProductOption', 'getOptionByCode', 'getQty'] + ); + $productOptionMock = $this->createMock(\Magento\Quote\Api\Data\ProductOptionInterface::class); + + $cartItemMock->expects($this->any())->method('getProductOption')->willReturn($productOptionMock); + $productOptionMock->expects($this->atLeastOnce())->method('getExtensionAttributes')->willReturn(null); + + $this->assertNull($this->model->convertToBuyRequest($cartItemMock)); + } + public function testProcessProductOptions() { $downloadableLinks = [1, 2]; - $customOption = $this->getMock( - \Magento\Catalog\Model\Product\Configuration\Item\Option::class, - [], - [], - '', - false - ); + $customOption = $this->createMock(\Magento\Catalog\Model\Product\Configuration\Item\Option::class); $customOption->expects($this->once())->method('getValue')->willReturn(implode(',', $downloadableLinks)); - $cartItemMock = $this->getMock( + $cartItemMock = $this->createPartialMock( \Magento\Quote\Model\Quote\Item::class, - ['getProduct', 'getProductOption', 'setProductOption', 'getOptionByCode'], - [], - '', - false + ['getProduct', 'getProductOption', 'setProductOption', 'getOptionByCode'] ); $cartItemMock->expects($this->once()) ->method('getOptionByCode') @@ -162,21 +145,18 @@ public function testProcessProductOptions() ->method('getProductOption') ->willReturn(null); - $downloadableOptionMock = $this->getMock(\Magento\Downloadable\Api\Data\DownloadableOptionInterface::class); + $downloadableOptionMock = $this->createMock(\Magento\Downloadable\Api\Data\DownloadableOptionInterface::class); $this->downloadableOptionFactoryMock->expects($this->any()) ->method('create') ->willReturn($downloadableOptionMock); - $productOptionMock = $this->getMock(\Magento\Quote\Api\Data\ProductOptionInterface::class); + $productOptionMock = $this->createMock(\Magento\Quote\Api\Data\ProductOptionInterface::class); $this->optionFactoryMock->expects($this->once())->method('create')->willReturn($productOptionMock); $productOptionMock->expects($this->once())->method('getExtensionAttributes')->willReturn(null); - $extAttributeMock = $this->getMock( + $extAttributeMock = $this->createPartialMock( \Magento\Quote\Api\Data\ProductOptionExtension::class, - ['setDownloadableOption'], - [], - '', - false + ['setDownloadableOption'] ); $this->objectHelperMock->expects($this->once())->method('populateWithArray')->with( @@ -203,25 +183,19 @@ public function testProcessProductOptionsWhenItemDoesNotHaveDownloadableLinks() { $downloadableLinks = []; - $cartItemMock = $this->getMock( + $cartItemMock = $this->createPartialMock( \Magento\Quote\Model\Quote\Item::class, - ['getProduct', 'getProductOption', 'setProductOption', 'getOptionByCode'], - [], - '', - false + ['getProduct', 'getProductOption', 'setProductOption', 'getOptionByCode'] ); $cartItemMock->expects($this->once()) ->method('getOptionByCode') ->with('downloadable_link_ids'); - $extAttributeMock = $this->getMock( + $extAttributeMock = $this->createPartialMock( \Magento\Quote\Api\Data\ProductOptionExtension::class, - ['setDownloadableOption'], - [], - '', - false + ['setDownloadableOption'] ); - $productOptionMock = $this->getMock(\Magento\Quote\Api\Data\ProductOptionInterface::class); + $productOptionMock = $this->createMock(\Magento\Quote\Api\Data\ProductOptionInterface::class); $productOptionMock->expects($this->any()) ->method('getExtensionAttributes') ->willReturn($extAttributeMock); @@ -229,7 +203,7 @@ public function testProcessProductOptionsWhenItemDoesNotHaveDownloadableLinks() ->method('getProductOption') ->willReturn($productOptionMock); - $downloadableOptionMock = $this->getMock(\Magento\Downloadable\Api\Data\DownloadableOptionInterface::class); + $downloadableOptionMock = $this->createMock(\Magento\Downloadable\Api\Data\DownloadableOptionInterface::class); $this->downloadableOptionFactoryMock->expects($this->any()) ->method('create') ->willReturn($downloadableOptionMock); diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/Sales/Order/Pdf/Items/CreditmemoTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/Sales/Order/Pdf/Items/CreditmemoTest.php index 130dd6a156261..e7ea08b09d953 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Model/Sales/Order/Pdf/Items/CreditmemoTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Model/Sales/Order/Pdf/Items/CreditmemoTest.php @@ -8,7 +8,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class CreditmemoTest extends \PHPUnit_Framework_TestCase +class CreditmemoTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Downloadable\Model\Sales\Order\Pdf\Items\Creditmemo @@ -35,21 +35,14 @@ protected function setUp() ->method('formatPriceTxt') ->will($this->returnCallback([$this, 'formatPrice'])); - $this->pdf = $this->getMock( + $this->pdf = $this->createPartialMock( \Magento\Sales\Model\Order\Pdf\AbstractPdf::class, - ['drawLineBlocks', 'getPdf'], - [], - '', - false, - false + ['drawLineBlocks', 'getPdf'] ); - $filterManager = $this->getMock( + $filterManager = $this->createPartialMock( \Magento\Framework\Filter\FilterManager::class, - ['stripTags'], - [], - '', - false + ['stripTags'] ); $filterManager->expects($this->any())->method('stripTags')->will($this->returnArgument(0)); @@ -58,11 +51,10 @@ protected function setUp() ['string' => new \Magento\Framework\Stdlib\StringUtils(), 'filterManager' => $filterManager] ); - $this->model = $this->getMock( - \Magento\Downloadable\Model\Sales\Order\Pdf\Items\Creditmemo::class, - ['getLinks', 'getLinksTitle'], - $modelConstructorArgs - ); + $this->model = $this->getMockBuilder(\Magento\Downloadable\Model\Sales\Order\Pdf\Items\Creditmemo::class) + ->setMethods(['getLinks', 'getLinksTitle']) + ->setConstructorArgs($modelConstructorArgs) + ->getMock(); $this->model->setOrder($this->order); $this->model->setPdf($this->pdf); diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/Sample/BuilderTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/Sample/BuilderTest.php index aee784faf21a5..28ffa6db05e0b 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Model/Sample/BuilderTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Model/Sample/BuilderTest.php @@ -13,7 +13,7 @@ /** * Class BuilderTest */ -class BuilderTest extends \PHPUnit_Framework_TestCase +class BuilderTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/Sample/ContentValidatorTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/Sample/ContentValidatorTest.php index 439bde6216632..c863fb7ad62ff 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Model/Sample/ContentValidatorTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Model/Sample/ContentValidatorTest.php @@ -7,7 +7,7 @@ use Magento\Downloadable\Model\Sample\ContentValidator; -class ContentValidatorTest extends \PHPUnit_Framework_TestCase +class ContentValidatorTest extends \PHPUnit\Framework\TestCase { /** * @var ContentValidator @@ -36,27 +36,15 @@ class ContentValidatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->fileValidatorMock = $this->getMock( - \Magento\Downloadable\Model\File\ContentValidator::class, - [], - [], - '', - false - ); - $this->urlValidatorMock = $this->getMock( - \Magento\Framework\Url\Validator::class, - [], - [], - '', - false - ); - $this->sampleFileMock = $this->getMock(\Magento\Downloadable\Api\Data\File\ContentInterface::class); + $this->fileValidatorMock = $this->createMock(\Magento\Downloadable\Model\File\ContentValidator::class); + $this->urlValidatorMock = $this->createMock(\Magento\Framework\Url\Validator::class); + $this->sampleFileMock = $this->createMock(\Magento\Downloadable\Api\Data\File\ContentInterface::class); $this->validator = new ContentValidator($this->fileValidatorMock, $this->urlValidatorMock); } public function testIsValid() { - $sampleFileContentMock = $this->getMock(\Magento\Downloadable\Api\Data\File\ContentInterface::class); + $sampleFileContentMock = $this->createMock(\Magento\Downloadable\Api\Data\File\ContentInterface::class); $sampleContentData = [ 'title' => 'Title', 'sort_order' => 1, @@ -105,7 +93,7 @@ public function getInvalidSortOrder() */ protected function getSampleContentMock(array $sampleContentData) { - $contentMock = $this->getMock(\Magento\Downloadable\Api\Data\SampleInterface::class); + $contentMock = $this->createMock(\Magento\Downloadable\Api\Data\SampleInterface::class); $contentMock->expects($this->any())->method('getTitle')->will($this->returnValue( $sampleContentData['title'] )); diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/Sample/CreateHandlerTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/Sample/CreateHandlerTest.php index a415e32e7b4f2..d8012155e0766 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Model/Sample/CreateHandlerTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Model/Sample/CreateHandlerTest.php @@ -12,7 +12,7 @@ use Magento\Downloadable\Model\Sample\CreateHandler; use Magento\Downloadable\Model\Product\Type; -class CreateHandlerTest extends \PHPUnit_Framework_TestCase +class CreateHandlerTest extends \PHPUnit\Framework\TestCase { /** @var CreateHandler */ protected $model; diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/Sample/UpdateHandlerTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/Sample/UpdateHandlerTest.php index 1ab4464d24230..0677a2eabce22 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Model/Sample/UpdateHandlerTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Model/Sample/UpdateHandlerTest.php @@ -12,7 +12,7 @@ use Magento\Downloadable\Model\Sample\UpdateHandler; use Magento\Downloadable\Model\Product\Type; -class UpdateHandlerTest extends \PHPUnit_Framework_TestCase +class UpdateHandlerTest extends \PHPUnit\Framework\TestCase { /** @var UpdateHandler */ protected $model; diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/SampleRepositoryTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/SampleRepositoryTest.php index 8e91db671f5ba..79a314cee5423 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Model/SampleRepositoryTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Model/SampleRepositoryTest.php @@ -10,7 +10,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class SampleRepositoryTest extends \PHPUnit_Framework_TestCase +class SampleRepositoryTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -74,34 +74,22 @@ class SampleRepositoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->productMock = $this->getMock( + $this->productMock = $this->createPartialMock( \Magento\Catalog\Model\Product::class, - ['__wakeup', 'getTypeId', 'setDownloadableData', 'save', 'getId', 'getStoreId', 'getData'], - [], - '', - false + ['__wakeup', 'getTypeId', 'setDownloadableData', 'save', 'getId', 'getStoreId', 'getData'] ); - $this->repositoryMock = $this->getMock(\Magento\Catalog\Model\ProductRepository::class, [], [], '', false); - $this->productTypeMock = $this->getMock(\Magento\Downloadable\Model\Product\Type::class, [], [], '', false); - $this->contentValidatorMock = $this->getMock( - \Magento\Downloadable\Model\Sample\ContentValidator::class, - [], - [], - '', - false - ); - $this->contentUploaderMock = $this->getMock( + $this->repositoryMock = $this->createMock(\Magento\Catalog\Model\ProductRepository::class); + $this->productTypeMock = $this->createMock(\Magento\Downloadable\Model\Product\Type::class); + $this->contentValidatorMock = $this->createMock(\Magento\Downloadable\Model\Sample\ContentValidator::class); + $this->contentUploaderMock = $this->createMock( \Magento\Downloadable\Api\Data\File\ContentUploaderInterface::class ); - $this->jsonEncoderMock = $this->getMock( + $this->jsonEncoderMock = $this->createMock( \Magento\Framework\Json\EncoderInterface::class ); - $this->sampleFactoryMock = $this->getMock( + $this->sampleFactoryMock = $this->createPartialMock( \Magento\Downloadable\Model\SampleFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->productTypeMock = $this->getMockBuilder(\Magento\Downloadable\Model\Product\Type::class) ->disableOriginalConstructor() @@ -154,7 +142,7 @@ protected function setUp() */ protected function getSampleMock(array $sampleData) { - $sampleMock = $this->getMock(\Magento\Downloadable\Api\Data\SampleInterface::class); + $sampleMock = $this->createMock(\Magento\Downloadable\Api\Data\SampleInterface::class); if (isset($sampleData['id'])) { $sampleMock->expects($this->any())->method('getId')->willReturn($sampleData['id']); @@ -257,12 +245,9 @@ public function testUpdate() $this->repositoryMock->expects($this->any())->method('get')->with($productSku, true) ->will($this->returnValue($this->productMock)); $this->productMock->expects($this->any())->method('getData')->will($this->returnValue($productId)); - $existingSampleMock = $this->getMock( + $existingSampleMock = $this->createPartialMock( \Magento\Downloadable\Model\Sample::class, - ['__wakeup', 'getId', 'load', 'getProductId'], - [], - '', - false + ['__wakeup', 'getId', 'load', 'getProductId'] ); $this->sampleFactoryMock->expects($this->once())->method('create') ->will($this->returnValue($existingSampleMock)); @@ -310,12 +295,9 @@ public function testUpdateWithExistingFile() $this->repositoryMock->expects($this->any())->method('get')->with($productSku, true) ->will($this->returnValue($this->productMock)); $this->productMock->expects($this->any())->method('getData')->will($this->returnValue($productId)); - $existingSampleMock = $this->getMock( + $existingSampleMock = $this->createPartialMock( \Magento\Downloadable\Model\Sample::class, - ['__wakeup', 'getId', 'load', 'getProductId'], - [], - '', - false + ['__wakeup', 'getId', 'load', 'getProductId'] ); $this->sampleFactoryMock->expects($this->once())->method('create') ->will($this->returnValue($existingSampleMock)); @@ -374,12 +356,9 @@ public function testUpdateThrowsExceptionIfTitleIsEmptyAndScopeIsGlobal() $this->repositoryMock->expects($this->any())->method('get')->with($productSku, true) ->will($this->returnValue($this->productMock)); $this->productMock->expects($this->any())->method('getData')->will($this->returnValue($productId)); - $existingSampleMock = $this->getMock( + $existingSampleMock = $this->createPartialMock( \Magento\Downloadable\Model\Sample::class, - ['__wakeup', 'getId', 'load', 'save', 'getProductId'], - [], - '', - false + ['__wakeup', 'getId', 'load', 'save', 'getProductId'] ); $existingSampleMock->expects($this->any())->method('getId')->will($this->returnValue($sampleId)); $existingSampleMock->expects($this->once())->method('load')->with($sampleId)->will($this->returnSelf()); @@ -398,13 +377,7 @@ public function testUpdateThrowsExceptionIfTitleIsEmptyAndScopeIsGlobal() public function testDelete() { $sampleId = 1; - $sampleMock = $this->getMock( - \Magento\Downloadable\Model\Sample::class, - [], - [], - '', - false - ); + $sampleMock = $this->createMock(\Magento\Downloadable\Model\Sample::class); $this->sampleFactoryMock->expects($this->once())->method('create')->will($this->returnValue($sampleMock)); $sampleMock->expects($this->once())->method('load')->with($sampleId)->will($this->returnSelf()); $sampleMock->expects($this->any())->method('getId')->will($this->returnValue($sampleId)); @@ -420,13 +393,7 @@ public function testDelete() public function testDeleteThrowsExceptionIfSampleIdIsNotValid() { $sampleId = 1; - $sampleMock = $this->getMock( - \Magento\Downloadable\Model\Sample::class, - [], - [], - '', - false - ); + $sampleMock = $this->createMock(\Magento\Downloadable\Model\Sample::class); $this->sampleFactoryMock->expects($this->once())->method('create')->will($this->returnValue($sampleMock)); $sampleMock->expects($this->once())->method('load')->with($sampleId)->will($this->returnSelf()); $sampleMock->expects($this->once())->method('getId'); @@ -449,9 +416,7 @@ public function testGetList() 'sample_file' => '/r/o/rock.melody.ogg' ]; - $sampleMock = $this->getMock( - \Magento\Downloadable\Model\Sample::class, - [ + $sampleMock = $this->createPartialMock(\Magento\Downloadable\Model\Sample::class, [ 'getId', 'getStoreTitle', 'getTitle', @@ -461,13 +426,9 @@ public function testGetList() 'getSortOrder', 'getData', '__wakeup' - ], - [], - '', - false - ); + ]); - $sampleInterfaceMock = $this->getMock(\Magento\Downloadable\Api\Data\SampleInterface::class); + $sampleInterfaceMock = $this->createMock(\Magento\Downloadable\Api\Data\SampleInterface::class); $this->repositoryMock->expects($this->once()) ->method('get') diff --git a/app/code/Magento/Downloadable/Test/Unit/Observer/IsAllowedGuestCheckoutObserverTest.php b/app/code/Magento/Downloadable/Test/Unit/Observer/IsAllowedGuestCheckoutObserverTest.php index 1a77933f0cd5b..89eb29e0f398a 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Observer/IsAllowedGuestCheckoutObserverTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Observer/IsAllowedGuestCheckoutObserverTest.php @@ -14,7 +14,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class IsAllowedGuestCheckoutObserverTest extends \PHPUnit_Framework_TestCase +class IsAllowedGuestCheckoutObserverTest extends \PHPUnit\Framework\TestCase { /** @var IsAllowedGuestCheckoutObserver */ private $isAllowedGuestCheckoutObserver; diff --git a/app/code/Magento/Downloadable/Test/Unit/Observer/SaveDownloadableOrderItemObserverTest.php b/app/code/Magento/Downloadable/Test/Unit/Observer/SaveDownloadableOrderItemObserverTest.php index b6a9d7ee34620..756ec44edae42 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Observer/SaveDownloadableOrderItemObserverTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Observer/SaveDownloadableOrderItemObserverTest.php @@ -13,7 +13,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class SaveDownloadableOrderItemObserverTest extends \PHPUnit_Framework_TestCase +class SaveDownloadableOrderItemObserverTest extends \PHPUnit\Framework\TestCase { /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Sales\Model\Order */ private $orderMock; @@ -279,7 +279,8 @@ public function testSaveDownloadableOrderItemNotSavedOrderItem() 'event' => $event ] ); - $this->saveDownloadableOrderItemObserver->execute($observer); + $result = $this->saveDownloadableOrderItemObserver->execute($observer); + $this->assertEquals($this->saveDownloadableOrderItemObserver, $result); } public function testSaveDownloadableOrderItemSavedPurchasedLink() diff --git a/app/code/Magento/Downloadable/Test/Unit/Observer/SetLinkStatusObserverTest.php b/app/code/Magento/Downloadable/Test/Unit/Observer/SetLinkStatusObserverTest.php index a322ce01cc4d8..5a138d83d2673 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Observer/SetLinkStatusObserverTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Observer/SetLinkStatusObserverTest.php @@ -15,7 +15,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class SetLinkStatusObserverTest extends \PHPUnit_Framework_TestCase +class SetLinkStatusObserverTest extends \PHPUnit\Framework\TestCase { /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Sales\Model\Order */ private $orderMock; diff --git a/app/code/Magento/Downloadable/Test/Unit/Pricing/Price/LinkPriceTest.php b/app/code/Magento/Downloadable/Test/Unit/Pricing/Price/LinkPriceTest.php index 2264ba5b4be7c..8abd47cecbac7 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Pricing/Price/LinkPriceTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Pricing/Price/LinkPriceTest.php @@ -9,7 +9,7 @@ /** * Class LinkPriceTest */ -class LinkPriceTest extends \PHPUnit_Framework_TestCase +class LinkPriceTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Downloadable\Pricing\Price\LinkPrice @@ -46,24 +46,15 @@ class LinkPriceTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->saleableItemMock = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); - $this->amountMock = $this->getMock(\Magento\Framework\Pricing\Amount\Base::class, [], [], '', false); - $this->calculatorMock = $this->getMock( - \Magento\Framework\Pricing\Adjustment\Calculator::class, - [], - [], - '', - false - ); - $this->linkMock = $this->getMock( + $this->saleableItemMock = $this->createMock(\Magento\Catalog\Model\Product::class); + $this->amountMock = $this->createMock(\Magento\Framework\Pricing\Amount\Base::class); + $this->calculatorMock = $this->createMock(\Magento\Framework\Pricing\Adjustment\Calculator::class); + $this->linkMock = $this->createPartialMock( \Magento\Downloadable\Model\Link::class, - ['getPrice', 'getProduct', '__wakeup'], - [], - '', - false + ['getPrice', 'getProduct', '__wakeup'] ); - $this->priceCurrencyMock = $this->getMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class); + $this->priceCurrencyMock = $this->createMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class); $this->linkPrice = new \Magento\Downloadable\Pricing\Price\LinkPrice( $this->saleableItemMock, diff --git a/app/code/Magento/Downloadable/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CompositeTest.php b/app/code/Magento/Downloadable/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CompositeTest.php index 5d39a4428d8d4..155f95874eeeb 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CompositeTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CompositeTest.php @@ -14,7 +14,7 @@ use Magento\Downloadable\Model\Product\Type as DownloadableType; use Magento\Catalog\Model\Product\Type as CatalogType; -class CompositeTest extends \PHPUnit_Framework_TestCase +class CompositeTest extends \PHPUnit\Framework\TestCase { /** * @var ObjectManagerHelper @@ -58,9 +58,9 @@ protected function setUp() { $this->modifiers = ['someClass' => 'namespase\SomeClass']; $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->modifierFactoryMock = $this->getMock(ModifierFactory::class, [], [], '', false); - $this->locatorMock = $this->getMock(LocatorInterface::class); - $this->productMock = $this->getMock(ProductInterface::class); + $this->modifierFactoryMock = $this->createMock(ModifierFactory::class); + $this->locatorMock = $this->createMock(LocatorInterface::class); + $this->productMock = $this->createMock(ProductInterface::class); $this->composite = $this->objectManagerHelper->getObject( Composite::class, [ diff --git a/app/code/Magento/Downloadable/Test/Unit/Ui/DataProvider/Product/Form/Modifier/Data/LinksTest.php b/app/code/Magento/Downloadable/Test/Unit/Ui/DataProvider/Product/Form/Modifier/Data/LinksTest.php index 6bb7ef8e867a7..dd8e8ff38e931 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Ui/DataProvider/Product/Form/Modifier/Data/LinksTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Ui/DataProvider/Product/Form/Modifier/Data/LinksTest.php @@ -20,7 +20,7 @@ * Class LinksTest * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class LinksTest extends \PHPUnit_Framework_TestCase +class LinksTest extends \PHPUnit\Framework\TestCase { /** * @var ObjectManagerHelper @@ -76,12 +76,12 @@ protected function setUp() $this->productMock = $this->getMockBuilder(ProductInterface::class) ->setMethods(['getLinksTitle', 'getId', 'getTypeId']) ->getMockForAbstractClass(); - $this->locatorMock = $this->getMock(LocatorInterface::class); - $this->scopeConfigMock = $this->getMock(ScopeConfigInterface::class); - $this->escaperMock = $this->getMock(Escaper::class, [], [], '', false); - $this->downloadableFileMock = $this->getMock(DownloadableFile::class, [], [], '', false); - $this->urlBuilderMock = $this->getMock(UrlInterface::class); - $this->linkModelMock = $this->getMock(LinkModel::class, [], [], '', false); + $this->locatorMock = $this->createMock(LocatorInterface::class); + $this->scopeConfigMock = $this->createMock(ScopeConfigInterface::class); + $this->escaperMock = $this->createMock(Escaper::class); + $this->downloadableFileMock = $this->createMock(DownloadableFile::class); + $this->urlBuilderMock = $this->createMock(UrlInterface::class); + $this->linkModelMock = $this->createMock(LinkModel::class); $this->links = $this->objectManagerHelper->getObject( Links::class, [ diff --git a/app/code/Magento/Downloadable/Test/Unit/Ui/DataProvider/Product/Form/Modifier/DownloadablePanelTest.php b/app/code/Magento/Downloadable/Test/Unit/Ui/DataProvider/Product/Form/Modifier/DownloadablePanelTest.php index 6fd326fd81aa4..7eb85a1f3637e 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Ui/DataProvider/Product/Form/Modifier/DownloadablePanelTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Ui/DataProvider/Product/Form/Modifier/DownloadablePanelTest.php @@ -18,7 +18,7 @@ * Class DownloadablePanelTest * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class DownloadablePanelTest extends \PHPUnit_Framework_TestCase +class DownloadablePanelTest extends \PHPUnit\Framework\TestCase { /** * @var ObjectManagerHelper @@ -51,9 +51,9 @@ class DownloadablePanelTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->productMock = $this->getMock(ProductInterface::class); - $this->locatorMock = $this->getMock(LocatorInterface::class); - $this->arrayManagerMock = $this->getMock(ArrayManager::class, [], [], '', false); + $this->productMock = $this->createMock(ProductInterface::class); + $this->locatorMock = $this->createMock(LocatorInterface::class); + $this->arrayManagerMock = $this->createMock(ArrayManager::class); $this->downloadablePanel = $this->objectManagerHelper->getObject( DownloadablePanel::class, [ diff --git a/app/code/Magento/Downloadable/Test/Unit/Ui/DataProvider/Product/Form/Modifier/LinksTest.php b/app/code/Magento/Downloadable/Test/Unit/Ui/DataProvider/Product/Form/Modifier/LinksTest.php index dc6a68ca89675..cff48420938b1 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Ui/DataProvider/Product/Form/Modifier/LinksTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Ui/DataProvider/Product/Form/Modifier/LinksTest.php @@ -20,7 +20,7 @@ * Class LinksTest * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class LinksTest extends \PHPUnit_Framework_TestCase +class LinksTest extends \PHPUnit\Framework\TestCase { /** * @var ObjectManagerHelper @@ -78,14 +78,14 @@ class LinksTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->locatorMock = $this->getMock(LocatorInterface::class); - $this->productMock = $this->getMock(ProductInterface::class); - $this->storeManagerMock = $this->getMock(StoreManagerInterface::class); - $this->urlBuilderMock = $this->getMock(UrlInterface::class); - $this->linksDataMock = $this->getMock(LinksData::class, [], [], '', false); - $this->typeUploadMock = $this->getMock(TypeUpload::class, [], [], '', false); - $this->shareableMock = $this->getMock(Shareable::class, [], [], '', false); - $this->arrayManagerMock = $this->getMock(ArrayManager::class, [], [], '', false); + $this->locatorMock = $this->createMock(LocatorInterface::class); + $this->productMock = $this->createMock(ProductInterface::class); + $this->storeManagerMock = $this->createMock(StoreManagerInterface::class); + $this->urlBuilderMock = $this->createMock(UrlInterface::class); + $this->linksDataMock = $this->createMock(LinksData::class); + $this->typeUploadMock = $this->createMock(TypeUpload::class); + $this->shareableMock = $this->createMock(Shareable::class); + $this->arrayManagerMock = $this->createMock(ArrayManager::class); $this->links = $this->objectManagerHelper->getObject( Links::class, [ @@ -175,7 +175,7 @@ public function testModifyMeta() $this->urlBuilderMock->expects($this->exactly(2)) ->method('getUrl'); - $currencyMock = $this->getMock(\Magento\Directory\Model\Currency::class, [], [], '', false); + $currencyMock = $this->createMock(\Magento\Directory\Model\Currency::class); $currencyMock->expects($this->once()) ->method('getCurrencySymbol'); $storeMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class) diff --git a/app/code/Magento/Downloadable/Test/Unit/Ui/DataProvider/Product/Form/Modifier/SamplesTest.php b/app/code/Magento/Downloadable/Test/Unit/Ui/DataProvider/Product/Form/Modifier/SamplesTest.php index 9214ef030a0aa..420950d08e101 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Ui/DataProvider/Product/Form/Modifier/SamplesTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Ui/DataProvider/Product/Form/Modifier/SamplesTest.php @@ -19,7 +19,7 @@ * Class SamplesTest * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class SamplesTest extends \PHPUnit_Framework_TestCase +class SamplesTest extends \PHPUnit\Framework\TestCase { /** * @var ObjectManagerHelper @@ -72,13 +72,13 @@ class SamplesTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); - $this->locatorMock = $this->getMock(LocatorInterface::class); - $this->productMock = $this->getMock(ProductInterface::class); - $this->samplesDataMock = $this->getMock(SamplesData::class, [], [], '', false); - $this->storeManagerMock = $this->getMock(StoreManagerInterface::class); - $this->typeUploadMock = $this->getMock(TypeUpload::class, [], [], '', false); - $this->urlBuilderMock = $this->getMock(UrlInterface::class); - $this->arrayManagerMock = $this->getMock(ArrayManager::class, [], [], '', false); + $this->locatorMock = $this->createMock(LocatorInterface::class); + $this->productMock = $this->createMock(ProductInterface::class); + $this->samplesDataMock = $this->createMock(SamplesData::class); + $this->storeManagerMock = $this->createMock(StoreManagerInterface::class); + $this->typeUploadMock = $this->createMock(TypeUpload::class); + $this->urlBuilderMock = $this->createMock(UrlInterface::class); + $this->arrayManagerMock = $this->createMock(ArrayManager::class); $this->samples = $this->objectManagerHelper->getObject( Samples::class, [ diff --git a/app/code/Magento/Downloadable/view/adminhtml/web/downloadable-type-handler.js b/app/code/Magento/Downloadable/view/adminhtml/web/downloadable-type-handler.js index dfd3d61c3043e..b98f5fe92e186 100644 --- a/app/code/Magento/Downloadable/view/adminhtml/web/downloadable-type-handler.js +++ b/app/code/Magento/Downloadable/view/adminhtml/web/downloadable-type-handler.js @@ -2,7 +2,6 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ -/*jshint browser:true jquery:true expr:true*/ define([ 'jquery', 'Magento_Catalog/js/product/weight-handler', diff --git a/app/code/Magento/DownloadableImportExport/Test/Unit/Model/Import/Product/Type/DownloadableTest.php b/app/code/Magento/DownloadableImportExport/Test/Unit/Model/Import/Product/Type/DownloadableTest.php index ad097724705be..9cb6b061b14ee 100644 --- a/app/code/Magento/DownloadableImportExport/Test/Unit/Model/Import/Product/Type/DownloadableTest.php +++ b/app/code/Magento/DownloadableImportExport/Test/Unit/Model/Import/Product/Type/DownloadableTest.php @@ -6,7 +6,7 @@ namespace Magento\DownloadableImportExport\Test\Unit\Model\Import\Product\Type; -use \Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManager; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManager; /** * Class DownloadableTest @@ -78,18 +78,15 @@ protected function setUp() parent::setUp(); //connection and sql query results - $this->connectionMock = $this->getMock( + $this->connectionMock = $this->createPartialMock( \Magento\Framework\DB\Adapter\Pdo\Mysql::class, - ['select', 'fetchAll', 'fetchPairs', 'joinLeft', 'insertOnDuplicate', 'delete', 'quoteInto', 'fetchAssoc'], - [], - '', - false + ['select', 'fetchAll', 'fetchPairs', 'joinLeft', 'insertOnDuplicate', 'delete', 'quoteInto', 'fetchAssoc'] ); - $this->select = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); + $this->select = $this->createMock(\Magento\Framework\DB\Select::class); $this->select->expects($this->any())->method('from')->will($this->returnSelf()); $this->select->expects($this->any())->method('where')->will($this->returnSelf()); $this->select->expects($this->any())->method('joinLeft')->will($this->returnSelf()); - $adapter = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false); + $adapter = $this->createMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class); $adapter->expects($this->any())->method('quoteInto')->will($this->returnValue('query')); $this->select->expects($this->any())->method('getAdapter')->willReturn($adapter); $this->connectionMock->expects($this->any())->method('select')->will($this->returnValue($this->select)); @@ -100,19 +97,13 @@ protected function setUp() //constructor arguments: // 1. $attrSetColFac - $this->attrSetColFacMock = $this->getMock( + $this->attrSetColFacMock = $this->createPartialMock( \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->attrSetColMock = $this->getMock( + $this->attrSetColMock = $this->createPartialMock( \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection::class, - ['setEntityTypeFilter'], - [], - '', - false + ['setEntityTypeFilter'] ); $this->attrSetColMock ->expects($this->any()) @@ -120,32 +111,20 @@ protected function setUp() ->will($this->returnValue([])); // 2. $prodAttrColFac - $this->prodAttrColFacMock = $this->getMock( + $this->prodAttrColFacMock = $this->createPartialMock( \Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $attrCollection = $this->getMock( - \Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection::class, - [], - [], - '', - false - ); + $attrCollection = $this->createMock(\Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection::class); $attrCollection->expects($this->any())->method('addFieldToFilter')->willReturn([]); $this->prodAttrColFacMock->expects($this->any())->method('create')->will($this->returnValue($attrCollection)); // 3. $resource - $this->resourceMock = $this->getMock( + $this->resourceMock = $this->createPartialMock( \Magento\Framework\App\ResourceConnection::class, - ['getConnection', 'getTableName'], - [], - '', - false + ['getConnection', 'getTableName'] ); $this->resourceMock->expects($this->any())->method('getConnection')->will( $this->returnValue($this->connectionMock) @@ -155,9 +134,7 @@ protected function setUp() ); // 4. $params - $this->entityModelMock = $this->getMock( - \Magento\CatalogImportExport\Model\Import\Product::class, - [ + $this->entityModelMock = $this->createPartialMock(\Magento\CatalogImportExport\Model\Import\Product::class, [ 'addMessageTemplate', 'getEntityTypeId', 'getBehavior', @@ -166,11 +143,7 @@ protected function setUp() 'isRowAllowedToImport', 'getParameters', 'addRowError' - ], - [], - '', - false - ); + ]); $this->entityModelMock->expects($this->any())->method('addMessageTemplate')->will($this->returnSelf()); $this->entityModelMock->expects($this->any())->method('getEntityTypeId')->will($this->returnValue(5)); @@ -180,38 +153,23 @@ protected function setUp() 'downloadable' ]; - $this->uploaderMock = $this->getMock( + $this->uploaderMock = $this->createPartialMock( \Magento\CatalogImportExport\Model\Import\Uploader::class, - ['move'], - [], - '', - false + ['move', 'setTmpDir', 'setDestDir'] ); // 6. $filesystem - $this->directoryWriteMock = $this->getMock( - \Magento\Framework\Filesystem\Directory\Write::class, - [], - [], - '', - false - ); + $this->directoryWriteMock = $this->createMock(\Magento\Framework\Filesystem\Directory\Write::class); // 7. $fileHelper - $this->uploaderHelper = $this->getMock( + $this->uploaderHelper = $this->createPartialMock( \Magento\DownloadableImportExport\Helper\Uploader::class, - ['getUploader'], - [], - '', - false + ['getUploader'] ); $this->uploaderHelper->expects($this->any())->method('getUploader')->willReturn($this->uploaderMock); - $this->downloadableHelper = $this->getMock( + $this->downloadableHelper = $this->createPartialMock( \Magento\DownloadableImportExport\Helper\Data::class, - ['prepareDataForSave'], - [], - '', - false + ['prepareDataForSave', 'fillExistOptions'] ); $this->downloadableHelper->expects($this->any())->method('prepareDataForSave')->willReturn([]); } @@ -287,10 +245,10 @@ public function dataForSave() 'product_type' => 'downloadable', 'name' => 'Downloadable Product 1', 'downloadable_samples' => 'group_title=Group Title Samples, title=Title 1, file=media/file.mp4' - .',sortorder=1|group_title=Group Title, title=Title 2, url=media/file2.mp4,sortorder=0', + . ',sortorder=1|group_title=Group Title, title=Title 2, url=media/file2.mp4,sortorder=0', 'downloadable_links' => 'group_title=Group Title Links, title=Title 1, price=10,' - .' downloads=unlimited, file=media/file_link.mp4,sortorder=1|group_title=Group Title,' - .'title=Title 2, price=10, downloads=unlimited, url=media/file2.mp4,sortorder=0', + . ' downloads=unlimited, file=media/file_link.mp4,sortorder=1|group_title=Group Title,' + . 'title=Title 2, price=10, downloads=unlimited, url=media/file2.mp4,sortorder=0', ], ], 'allowImport' => true, @@ -358,10 +316,10 @@ public function dataForSave() 'product_type' => 'downloadable', 'name' => 'Downloadable Product 1', 'downloadable_samples' => 'group_title=Group Title Samples, title=Title 1, file=media/file.mp4' - .',sortorder=1|group_title=Group Title, title=Title 2, url=media/file2.mp4,sortorder=0', + . ',sortorder=1|group_title=Group Title, title=Title 2, url=media/file2.mp4,sortorder=0', 'downloadable_links' => 'group_title=Group Title Links, title=Title 1, price=10,' - .' downloads=unlimited, file=media/file_link.mp4,sortorder=1|group_title=Group Title, ' - .'title=Title 2, price=10, downloads=unlimited, url=media/file2.mp4,sortorder=0', + . ' downloads=unlimited, file=media/file_link.mp4,sortorder=1|group_title=Group Title, ' + . 'title=Title 2, price=10, downloads=unlimited, url=media/file2.mp4,sortorder=0', ], ], 'allowImport' => false, @@ -382,10 +340,10 @@ public function dataForSave() 'product_type' => 'downloadable', 'name' => 'Downloadable Product 1', 'downloadable_samples' => 'group_title=Group Title Samples, title=Title 1, file=media/file.mp4,' - .'sortorder=1|group_title=Group Title, title=Title 2, url=media/file2.mp4,sortorder=0', + . 'sortorder=1|group_title=Group Title, title=Title 2, url=media/file2.mp4,sortorder=0', 'downloadable_links' => 'group_title=Group Title Links, title=Title 1, price=10,' - .' downloads=unlimited, file=media/file_link.mp4,sortorder=1|group_title=Group Title,' - .' title=Title 2, price=10, downloads=unlimited, url=media/file2.mp4,sortorder=0', + . ' downloads=unlimited, file=media/file_link.mp4,sortorder=1|group_title=Group Title,' + . ' title=Title 2, price=10, downloads=unlimited, url=media/file2.mp4,sortorder=0', ], ], 'allowImport' => true, @@ -406,10 +364,10 @@ public function dataForSave() 'product_type' => 'downloadable', 'name' => 'Downloadable Product 1', 'downloadable_samples' => 'group_title=Group Title Samples, title=Title 1, file=media/file.mp4,' - .'sortorder=1|group_title=Group Title, title=Title 2, url=media/file2.mp4,sortorder=0', + . 'sortorder=1|group_title=Group Title, title=Title 2, url=media/file2.mp4,sortorder=0', 'downloadable_links' => 'group_title=Group Title Links, title=Title 1, price=10,' - .' downloads=unlimited, file=media/file_link.mp4,sortorder=1|group_title=Group Title,' - .' title=Title 2, price=10, downloads=unlimited, url=media/file2.mp4,sortorder=0', + . ' downloads=unlimited, file=media/file_link.mp4,sortorder=1|group_title=Group Title,' + . ' title=Title 2, price=10, downloads=unlimited, url=media/file2.mp4,sortorder=0', ], ], 'allowImport' => true, @@ -477,11 +435,11 @@ public function dataForSave() 'product_type' => 'downloadable', 'name' => 'Downloadable Product 1', 'downloadable_samples' => 'group_title=Group Title Samples, title=Title 1, file=media/file.mp4,' - .'sortorder=1|group_title=Group Title, title=Title 2, url=media/file2.mp4,sortorder=0', + . 'sortorder=1|group_title=Group Title, title=Title 2, url=media/file2.mp4,sortorder=0', 'downloadable_links' => 'group_title=Group Title, title=Title 2, price=10, downloads=unlimited,' - .' url=http://www.sample.com/pic.jpg,sortorder=0,sample=http://www.sample.com/pic.jpg,' - .'purchased_separately=1,shareable=1|group_title=Group Title, title=Title 2, price=10, ' - .'downloads=unlimited, url=media/file2.mp4,sortorder=0,sample=media/file2mp4', + . ' url=http://www.sample.com/pic.jpg,sortorder=0,sample=http://www.sample.com/pic.jpg,' + . 'purchased_separately=1,shareable=1|group_title=Group Title, title=Title 2, price=10, ' + . 'downloads=unlimited, url=media/file2.mp4,sortorder=0,sample=media/file2mp4', ], ], 'allowImport' => true, @@ -567,7 +525,8 @@ public function testIsRowValid(array $rowData, $rowNum, $isNewProduct = true) 'downloadableHelper' => $this->downloadableHelper ] ); - $this->downloadableModelMock->isRowValid($rowData, $rowNum, $isNewProduct); + $result = $this->downloadableModelMock->isRowValid($rowData, $rowNum, $isNewProduct); + $this->assertNotNull($result); } /** @@ -585,10 +544,10 @@ public function isRowValidData() 'product_type' => 'downloadable', 'name' => 'Downloadable Product 1', 'downloadable_samples' => 'group_title=Group Title Samples, title=Title 1, file=media/file.mp4,' - .'sortorder=1|group_title=Group Title, title=Title 2, url=media/file2.mp4,sortorder=0', + . 'sortorder=1|group_title=Group Title, title=Title 2, url=media/file2.mp4,sortorder=0', 'downloadable_links' => 'group_title=Group Title Links, title=Title 1, price=10, ' - .'downloads=unlimited, file=media/file_link.mp4,sortorder=1|group_title=Group Title, ' - .'title=Title 2, price=10, downloads=unlimited, url=media/file2.mp4,sortorder=0', + . 'downloads=unlimited, file=media/file_link.mp4,sortorder=1|group_title=Group Title, ' + . 'title=Title 2, price=10, downloads=unlimited, url=media/file2.mp4,sortorder=0', ], 0, true @@ -599,10 +558,10 @@ public function isRowValidData() 'product_type' => 'downloadable', 'name' => 'Downloadable Product 2', 'downloadable_samples' => 'group_title=Group Title Samples, title=Title 1, file=media/file.mp4' - .',sortorder=1|group_title=Group Title, title=Title 2, url=media/file2.mp4,sortorder=0', + . ',sortorder=1|group_title=Group Title, title=Title 2, url=media/file2.mp4,sortorder=0', 'downloadable_links' => 'group_title=Group Title Links, title=Title 1, price=10,' - .' downloads=unlimited, file=media/file.mp4,sortorder=1|group_title=Group Title, title=Title 2,' - .' price=10, downloads=unlimited, url=media/file2.mp4,sortorder=0', + . ' downloads=unlimited, file=media/file.mp4,sortorder=1|group_title=Group Title,' + . ' title=Title 2, price=10, downloads=unlimited, url=media/file2.mp4,sortorder=0', ], 1, true @@ -622,10 +581,10 @@ public function isRowValidData() 'product_type' => 'downloadable', 'name' => 'Downloadable Product 2', 'downloadable_samples' => 'title=Title 1, file=media/file.mp4,sortorder=1|title=Title 2,' - .' url=media/file2.mp4,sortorder=0', + . ' url=media/file2.mp4,sortorder=0', 'downloadable_links' => 'title=Title 1, price=10, downloads=unlimited, file=media/file.mp4,' - .'sortorder=1|group_title=Group Title, title=Title 2, price=10, downloads=unlimited,' - .' url=media/file2.mp4,sortorder=0', + . 'sortorder=1|group_title=Group Title, title=Title 2, price=10, downloads=unlimited,' + . ' url=media/file2.mp4,sortorder=0', ], 3, true @@ -636,10 +595,10 @@ public function isRowValidData() 'product_type' => 'downloadable', 'name' => 'Downloadable Product 2', 'downloadable_samples' => 'file=media/file.mp4,sortorder=1|group_title=Group Title, ' - .'url=media/file2.mp4,sortorder=0', + . 'url=media/file2.mp4,sortorder=0', 'downloadable_links' => 'title=Title 1, price=10, downloads=unlimited, file=media/file.mp4,' - .'sortorder=1|group_title=Group Title, title=Title 2, price=10, downloads=unlimited,' - .' url=media/file2.mp4,sortorder=0', + . 'sortorder=1|group_title=Group Title, title=Title 2, price=10, downloads=unlimited,' + . ' url=media/file2.mp4,sortorder=0', ], 4, true @@ -650,10 +609,10 @@ public function isRowValidData() 'product_type' => 'downloadable', 'name' => 'Downloadable Product 2', 'downloadable_samples' => 'group_title=, title=Title 1, file=media/file.mp4,sortorder=1' - .'|group_title=, title=Title 2, url=media/file2.mp4,sortorder=0', + . '|group_title=, title=Title 2, url=media/file2.mp4,sortorder=0', 'downloadable_links' => 'group_title=Group Title Links, title=Title 1, price=10,' - .' downloads=unlimited, file=media/file_link.mp4,sortorder=1|group_title=Group Title,' - .' title=Title 2, price=10, downloads=unlimited, url=media/file2.mp4,sortorder=0', + . ' downloads=unlimited, file=media/file_link.mp4,sortorder=1|group_title=Group Title,' + . ' title=Title 2, price=10, downloads=unlimited, url=media/file2.mp4,sortorder=0', ], 5, true @@ -664,10 +623,10 @@ public function isRowValidData() 'product_type' => 'downloadable', 'name' => 'Downloadable Product 2', 'downloadable_samples' => 'group_title=Group Title Samples, title=Title 1, file=media/file.mp4,' - .'sortorder=1|group_title=Group Title, title=Title 2, url=media/file2.mp4,sortorder=0', + . 'sortorder=1|group_title=Group Title, title=Title 2, url=media/file2.mp4,sortorder=0', 'downloadable_links' => 'group_title=, title=Title 1, price=10, downloads=unlimited, ' - .'file=media/file_link.mp4,sortorder=1|group_title=, title=Title 2, price=10, ' - .'downloads=unlimited, url=media/file2.mp4,sortorder=0', + . 'file=media/file_link.mp4,sortorder=1|group_title=, title=Title 2, price=10, ' + . 'downloads=unlimited, url=media/file2.mp4,sortorder=0', ], 6, true @@ -689,26 +648,18 @@ public function isRowValidData() /** * @dataProvider dataForUploaderDir */ - public function testSetUploaderDirFalse($newSku, $bunch, $allowImport) + public function testSetUploaderDirFalse($newSku, $bunch, $allowImport, $parsedOptions) { $this->connectionMock->expects($this->any())->method('fetchAll')->with( $this->select - )->willReturnOnConsecutiveCalls( - [ - [ - 'attribute_set_name' => '1', - 'attribute_id' => '1', - ], - [ - 'attribute_set_name' => '2', - 'attribute_id' => '2', - ], - ] - ); + )->willReturn([]); $metadataPoolMock = $this - ->getMock(\Magento\Framework\EntityManager\MetadataPool::class, ['getLinkField'], [], '', false); + ->createPartialMock(\Magento\Framework\EntityManager\MetadataPool::class, ['getLinkField', 'getMetadata']); $metadataPoolMock->expects($this->any())->method('getMetadata')->willReturnSelf(); + $metadataPoolMock->expects($this->any())->method('getLinkField')->willReturn('entity_id'); + $this->downloadableHelper->expects($this->atLeastOnce()) + ->method('fillExistOptions')->willReturn($parsedOptions['link']); $this->downloadableModelMock = $this->objectManagerHelper->getObject( \Magento\DownloadableImportExport\Model\Import\Product\Type\Downloadable::class, @@ -727,10 +678,10 @@ public function testSetUploaderDirFalse($newSku, $bunch, $allowImport) $this->entityModelMock->expects($this->at(2))->method('getNextBunch')->will($this->returnValue(null)); $this->entityModelMock->expects($this->any())->method('isRowAllowedToImport')->willReturn($allowImport); $exception = new \Magento\Framework\Exception\LocalizedException(new \Magento\Framework\Phrase('Error')); - $this->setExpectedException(\Magento\Framework\Exception\LocalizedException::class); - $this->setExpectedException('\Exception'); $this->uploaderMock->expects($this->any())->method('move')->will($this->throwException($exception)); - $this->downloadableModelMock->saveData(); + $this->entityModelMock->expects($this->exactly(2))->method('addRowError'); + $result = $this->downloadableModelMock->saveData(); + $this->assertNotNull($result); } /** @@ -756,13 +707,41 @@ public function dataForUploaderDir() 'product_type' => 'downloadable', 'name' => 'Downloadable Product 1', 'downloadable_samples' => 'group_title=Group Title Samples, title=Title 1, file=media/file.mp4' - .',sortorder=1|group_title=Group Title, title=Title 2, url=media/file2.mp4,sortorder=0', + . ',sortorder=1|group_title=Group Title, title=Title 2, url=media/file2.mp4,sortorder=0', 'downloadable_links' => 'group_title=Group Title Links, title=Title 1, price=10, downloads=' - .'unlimited, file=media/file_link.mp4,sortorder=1|group_title=Group Title, title=Title 2,' - .' price=10, downloads=unlimited, url=media/file2.mp4,sortorder=0', + . 'unlimited, file=media/file_link.mp4,sortorder=1|group_title=Group Title, title=Title 2,' + . ' price=10, downloads=unlimited, url=media/file2.mp4,sortorder=0', ], ], 'allowImport' => true, + 'parsedOptions' => [ + 'sample' => [ + 'sample_id' => null, + 'product_id' => '25', + 'sample_url' => null, + 'sample_file' => 'media/file.mp4', + 'sample_type' => 'file', + 'sort_order' => '1', + 'group_title' => 'Group Title Samples', + 'title' => 'Title 1', + ], + 'link' => [ + 'link_id' => null, + 'product_id' => '25', + 'sort_order' => '1', + 'number_of_downloads' => 0, + 'is_shareable' => 2, + 'link_url' => null, + 'link_file' => '', + 'link_type' => 'file', + 'sample_url' => null, + 'sample_file' => null, + 'sample_type' => null, + 'group_title' => 'Group Title Links', + 'title' => 'Title 1', + 'price' => '10' + ] + ] ], ]; } @@ -778,10 +757,10 @@ public function testPrepareAttributesWithDefaultValueForSave() 'product_type' => 'downloadable', 'name' => 'Downloadable Product 1', 'downloadable_samples' => 'group_title=Group Title Samples, title=Title 1, file=media/file.mp4,sortorder=1' - .'|group_title=Group Title, title=Title 2, url=media/file2.mp4,sortorder=0', + . '|group_title=Group Title, title=Title 2, url=media/file2.mp4,sortorder=0', 'downloadable_links' => 'group_title=Group Title Links, title=Title 1, price=10, downloads=unlimited,' - .' file=media/file_link.mp4,sortorder=1|group_title=Group Title, title=Title 2, price=10, downloads' - .'=unlimited, url=media/file2.mp4,sortorder=0', + . ' file=media/file_link.mp4,sortorder=1|group_title=Group Title, title=Title 2, price=10, downloads' + . '=unlimited, url=media/file2.mp4,sortorder=0', ]; $this->connectionMock->expects($this->any())->method('fetchAll')->with( $this->select @@ -843,7 +822,8 @@ public function testPrepareAttributesWithDefaultValueForSave() ] ); - $this->downloadableModelMock->prepareAttributesWithDefaultValueForSave($rowData); + $result = $this->downloadableModelMock->prepareAttributesWithDefaultValueForSave($rowData); + $this->assertNotNull($result); } /** diff --git a/app/code/Magento/Eav/Api/AttributeGroupRepositoryInterface.php b/app/code/Magento/Eav/Api/AttributeGroupRepositoryInterface.php index 80b5ba0400be3..4f10cd998a8e8 100644 --- a/app/code/Magento/Eav/Api/AttributeGroupRepositoryInterface.php +++ b/app/code/Magento/Eav/Api/AttributeGroupRepositoryInterface.php @@ -9,6 +9,7 @@ /** * Interface AttributeGroupRepositoryInterface * @api + * @since 100.0.2 */ interface AttributeGroupRepositoryInterface { diff --git a/app/code/Magento/Eav/Api/AttributeManagementInterface.php b/app/code/Magento/Eav/Api/AttributeManagementInterface.php index bf6f30ec62bdf..f63c1f74ab064 100644 --- a/app/code/Magento/Eav/Api/AttributeManagementInterface.php +++ b/app/code/Magento/Eav/Api/AttributeManagementInterface.php @@ -9,6 +9,7 @@ /** * Interface AttributeManagementInterface * @api + * @since 100.0.2 */ interface AttributeManagementInterface { diff --git a/app/code/Magento/Eav/Api/AttributeOptionManagementInterface.php b/app/code/Magento/Eav/Api/AttributeOptionManagementInterface.php index 1bc3dae64b3c9..aac6e2174b1ea 100644 --- a/app/code/Magento/Eav/Api/AttributeOptionManagementInterface.php +++ b/app/code/Magento/Eav/Api/AttributeOptionManagementInterface.php @@ -8,6 +8,7 @@ /** * Interface AttributeOptionManagementInterface * @api + * @since 100.0.2 */ interface AttributeOptionManagementInterface { diff --git a/app/code/Magento/Eav/Api/AttributeRepositoryInterface.php b/app/code/Magento/Eav/Api/AttributeRepositoryInterface.php index 77d1d22db668c..ad323cdd7bf36 100644 --- a/app/code/Magento/Eav/Api/AttributeRepositoryInterface.php +++ b/app/code/Magento/Eav/Api/AttributeRepositoryInterface.php @@ -9,6 +9,7 @@ /** * Interface AttributeRepositoryInterface * @api + * @since 100.0.2 */ interface AttributeRepositoryInterface { diff --git a/app/code/Magento/Eav/Api/AttributeSetManagementInterface.php b/app/code/Magento/Eav/Api/AttributeSetManagementInterface.php index 58be6e827b48f..f2ead9a6b43cd 100644 --- a/app/code/Magento/Eav/Api/AttributeSetManagementInterface.php +++ b/app/code/Magento/Eav/Api/AttributeSetManagementInterface.php @@ -9,6 +9,7 @@ /** * Interface AttributeSetManagementInterface * @api + * @since 100.0.2 */ interface AttributeSetManagementInterface { diff --git a/app/code/Magento/Eav/Api/AttributeSetRepositoryInterface.php b/app/code/Magento/Eav/Api/AttributeSetRepositoryInterface.php index beb1a2ad3eb68..8bd65ba85abef 100644 --- a/app/code/Magento/Eav/Api/AttributeSetRepositoryInterface.php +++ b/app/code/Magento/Eav/Api/AttributeSetRepositoryInterface.php @@ -9,6 +9,7 @@ /** * Interface AttributeSetRepositoryInterface * @api + * @since 100.0.2 */ interface AttributeSetRepositoryInterface { diff --git a/app/code/Magento/Eav/Api/Data/AttributeDefaultValueInterface.php b/app/code/Magento/Eav/Api/Data/AttributeDefaultValueInterface.php index dbd6f6d4c42a3..56ae16c53402c 100644 --- a/app/code/Magento/Eav/Api/Data/AttributeDefaultValueInterface.php +++ b/app/code/Magento/Eav/Api/Data/AttributeDefaultValueInterface.php @@ -11,6 +11,7 @@ * Allows to manage attribute default value through interface * @api * @package Magento\Eav\Api\Data + * @since 100.2.0 */ interface AttributeDefaultValueInterface { @@ -19,11 +20,13 @@ interface AttributeDefaultValueInterface /** * @param string $defaultValue * @return \Magento\Framework\Api\MetadataObjectInterface + * @since 100.2.0 */ public function setDefaultValue($defaultValue); /** * @return string + * @since 100.2.0 */ public function getDefaultValue(); } diff --git a/app/code/Magento/Eav/Api/Data/AttributeFrontendLabelInterface.php b/app/code/Magento/Eav/Api/Data/AttributeFrontendLabelInterface.php index babdf64e1f14f..3fc7e72dd3025 100644 --- a/app/code/Magento/Eav/Api/Data/AttributeFrontendLabelInterface.php +++ b/app/code/Magento/Eav/Api/Data/AttributeFrontendLabelInterface.php @@ -9,6 +9,7 @@ /** * Interface AttributeFrontendLabelInterface * @api + * @since 100.0.2 */ interface AttributeFrontendLabelInterface extends AttributeOptionLabelInterface { diff --git a/app/code/Magento/Eav/Api/Data/AttributeGroupInterface.php b/app/code/Magento/Eav/Api/Data/AttributeGroupInterface.php index 7d602c7edc310..6d64b9a941301 100644 --- a/app/code/Magento/Eav/Api/Data/AttributeGroupInterface.php +++ b/app/code/Magento/Eav/Api/Data/AttributeGroupInterface.php @@ -10,6 +10,7 @@ /** * Interface AttributeGroupInterface * @api + * @since 100.0.2 */ interface AttributeGroupInterface extends ExtensibleDataInterface { diff --git a/app/code/Magento/Eav/Api/Data/AttributeGroupSearchResultsInterface.php b/app/code/Magento/Eav/Api/Data/AttributeGroupSearchResultsInterface.php index 6e9101d39fa98..9c319490d950a 100644 --- a/app/code/Magento/Eav/Api/Data/AttributeGroupSearchResultsInterface.php +++ b/app/code/Magento/Eav/Api/Data/AttributeGroupSearchResultsInterface.php @@ -9,6 +9,7 @@ /** * Interface AttributeGroupSearchResultsInterface * @api + * @since 100.0.2 */ interface AttributeGroupSearchResultsInterface extends \Magento\Framework\Api\SearchResultsInterface { diff --git a/app/code/Magento/Eav/Api/Data/AttributeInterface.php b/app/code/Magento/Eav/Api/Data/AttributeInterface.php index 55edf8f4600a7..9664cabc79ba0 100644 --- a/app/code/Magento/Eav/Api/Data/AttributeInterface.php +++ b/app/code/Magento/Eav/Api/Data/AttributeInterface.php @@ -9,6 +9,7 @@ /** * Interface AttributeInterface * @api + * @since 100.0.2 */ interface AttributeInterface extends \Magento\Framework\Api\CustomAttributesDataInterface { diff --git a/app/code/Magento/Eav/Api/Data/AttributeOptionInterface.php b/app/code/Magento/Eav/Api/Data/AttributeOptionInterface.php index c42f04cccea9d..7b659366346d5 100644 --- a/app/code/Magento/Eav/Api/Data/AttributeOptionInterface.php +++ b/app/code/Magento/Eav/Api/Data/AttributeOptionInterface.php @@ -10,6 +10,7 @@ * Created from: * @codeCoverageIgnore * @api + * @since 100.0.2 */ interface AttributeOptionInterface { diff --git a/app/code/Magento/Eav/Api/Data/AttributeOptionLabelInterface.php b/app/code/Magento/Eav/Api/Data/AttributeOptionLabelInterface.php index b215c90e000f2..4240ed411bd14 100644 --- a/app/code/Magento/Eav/Api/Data/AttributeOptionLabelInterface.php +++ b/app/code/Magento/Eav/Api/Data/AttributeOptionLabelInterface.php @@ -9,6 +9,7 @@ /** * Interface AttributeOptionLabelInterface * @api + * @since 100.0.2 */ interface AttributeOptionLabelInterface { diff --git a/app/code/Magento/Eav/Api/Data/AttributeSearchResultsInterface.php b/app/code/Magento/Eav/Api/Data/AttributeSearchResultsInterface.php index 0724e92b1ccce..6f8fd94edb52b 100644 --- a/app/code/Magento/Eav/Api/Data/AttributeSearchResultsInterface.php +++ b/app/code/Magento/Eav/Api/Data/AttributeSearchResultsInterface.php @@ -9,6 +9,7 @@ /** * Interface AttributeSearchResultsInterface * @api + * @since 100.0.2 */ interface AttributeSearchResultsInterface extends \Magento\Framework\Api\SearchResultsInterface { diff --git a/app/code/Magento/Eav/Api/Data/AttributeSetInterface.php b/app/code/Magento/Eav/Api/Data/AttributeSetInterface.php index 6233af6b9cb89..1b4cc782919c2 100644 --- a/app/code/Magento/Eav/Api/Data/AttributeSetInterface.php +++ b/app/code/Magento/Eav/Api/Data/AttributeSetInterface.php @@ -8,6 +8,7 @@ /** * Interface AttributeSetInterface * @api + * @since 100.0.2 */ interface AttributeSetInterface extends \Magento\Framework\Api\ExtensibleDataInterface { diff --git a/app/code/Magento/Eav/Api/Data/AttributeSetSearchResultsInterface.php b/app/code/Magento/Eav/Api/Data/AttributeSetSearchResultsInterface.php index b3d5fe59e30ed..6a3d3b960e02b 100644 --- a/app/code/Magento/Eav/Api/Data/AttributeSetSearchResultsInterface.php +++ b/app/code/Magento/Eav/Api/Data/AttributeSetSearchResultsInterface.php @@ -9,6 +9,7 @@ /** * Interface AttributeSetSearchResultsInterface * @api + * @since 100.0.2 */ interface AttributeSetSearchResultsInterface extends \Magento\Framework\Api\SearchResultsInterface { diff --git a/app/code/Magento/Eav/Api/Data/AttributeValidationRuleInterface.php b/app/code/Magento/Eav/Api/Data/AttributeValidationRuleInterface.php index 4783ad5dd058d..b5858158a4034 100644 --- a/app/code/Magento/Eav/Api/Data/AttributeValidationRuleInterface.php +++ b/app/code/Magento/Eav/Api/Data/AttributeValidationRuleInterface.php @@ -9,6 +9,7 @@ /** * Interface AttributeValidationRuleInterface * @api + * @since 100.0.2 */ interface AttributeValidationRuleInterface extends \Magento\Framework\DataObject\KeyValueObjectInterface { diff --git a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/AbstractOptions.php b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/AbstractOptions.php index feb1c3accb44e..9b44b2c7395ac 100644 --- a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/AbstractOptions.php +++ b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/AbstractOptions.php @@ -9,7 +9,8 @@ * Attribute add/edit form options tab * * @api - * @deprecated + * @deprecated 100.2.0 + * @since 100.0.2 */ abstract class AbstractOptions extends \Magento\Framework\View\Element\AbstractBlock { diff --git a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/Labels.php b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/Labels.php index 47c3b0523f4db..ad4b3089d5153 100644 --- a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/Labels.php +++ b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/Labels.php @@ -10,6 +10,7 @@ * * @api * @author Magento Core Team + * @since 100.0.2 */ class Labels extends \Magento\Backend\Block\Template { diff --git a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/Options.php b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/Options.php index d0aa815f8f8cc..72f4086c1c56b 100644 --- a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/Options.php +++ b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/Options.php @@ -15,6 +15,7 @@ /** * @api + * @since 100.0.2 */ class Options extends \Magento\Backend\Block\Template { @@ -89,6 +90,7 @@ public function getStores() * Returns stores sorted by Sort Order * * @return array + * @since 100.1.0 */ public function getStoresSortedBySortOrder() { diff --git a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Grid/AbstractGrid.php b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Grid/AbstractGrid.php index af83b58ec4187..55c0583191492 100644 --- a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Grid/AbstractGrid.php +++ b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Grid/AbstractGrid.php @@ -10,7 +10,8 @@ * * @api * @SuppressWarnings(PHPMD.DepthOfInheritance) - * @deprecated + * @deprecated 100.2.0 + * @since 100.0.2 */ abstract class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended { diff --git a/app/code/Magento/Eav/Model/Attribute.php b/app/code/Magento/Eav/Model/Attribute.php index 7bf39b1753622..64504b59fe9c9 100644 --- a/app/code/Magento/Eav/Model/Attribute.php +++ b/app/code/Magento/Eav/Model/Attribute.php @@ -19,6 +19,7 @@ /** * @api + * @since 100.0.2 */ class Attribute extends \Magento\Eav\Model\Entity\Attribute { @@ -29,9 +30,8 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute //const MODULE_NAME = 'Magento_Eav'; /** - * Prefix of model events object - * - * @var string + * Name of the module + * Override it */ protected $_eventObject = 'attribute'; diff --git a/app/code/Magento/Eav/Model/Attribute/Data/AbstractData.php b/app/code/Magento/Eav/Model/Attribute/Data/AbstractData.php index d7bea31e6f701..ed052cb71e2fa 100644 --- a/app/code/Magento/Eav/Model/Attribute/Data/AbstractData.php +++ b/app/code/Magento/Eav/Model/Attribute/Data/AbstractData.php @@ -10,6 +10,7 @@ use Magento\Framework\App\RequestInterface; use Magento\Framework\Exception\LocalizedException as CoreException; +use Magento\Framework\Validator\EmailAddress; /** * EAV Attribute Abstract Data Model @@ -17,6 +18,7 @@ * @api * @author Magento Core Team * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ abstract class AbstractData { @@ -365,7 +367,7 @@ protected function _validateInputRule($value) __("'%value%' appears to be a DNS hostname but cannot extract TLD part") __("'%value%' appears to be a DNS hostname but cannot match TLD against known list") */ - $validator = new \Zend_Validate_EmailAddress(); + $validator = new EmailAddress(); $validator->setMessage( __('"%1" invalid type entered.', $label), \Zend_Validate_EmailAddress::INVALID @@ -406,10 +408,6 @@ protected function _validateInputRule($value) __("'%value%' looks like an IP address, which is not an acceptable format."), \Zend_Validate_Hostname::IP_ADDRESS_NOT_ALLOWED ); - $validator->setMessage( - __("'%value%' looks like a DNS hostname but we cannot match the TLD against known list."), - \Zend_Validate_Hostname::UNKNOWN_TLD - ); $validator->setMessage( __("'%value%' looks like a DNS hostname but contains a dash in an invalid position."), \Zend_Validate_Hostname::INVALID_DASH diff --git a/app/code/Magento/Eav/Model/Attribute/Data/File.php b/app/code/Magento/Eav/Model/Attribute/Data/File.php index 1c6a7dee956c7..0364330517b88 100644 --- a/app/code/Magento/Eav/Model/Attribute/Data/File.php +++ b/app/code/Magento/Eav/Model/Attribute/Data/File.php @@ -12,6 +12,7 @@ * EAV Entity Attribute File Data Model * * @api + * @since 100.0.2 */ class File extends \Magento\Eav\Model\Attribute\Data\AbstractData { diff --git a/app/code/Magento/Eav/Model/Attribute/GroupRepository.php b/app/code/Magento/Eav/Model/Attribute/GroupRepository.php index b6bde73c1a837..9d0fa78668382 100644 --- a/app/code/Magento/Eav/Model/Attribute/GroupRepository.php +++ b/app/code/Magento/Eav/Model/Attribute/GroupRepository.php @@ -205,7 +205,7 @@ protected function retrieveAttributeSetIdFromSearchCriteria( /** * Retrieve collection processor * - * @deprecated + * @deprecated 100.2.0 * @return CollectionProcessorInterface */ private function getCollectionProcessor() diff --git a/app/code/Magento/Eav/Model/AttributeDataFactory.php b/app/code/Magento/Eav/Model/AttributeDataFactory.php index bc027bb821410..e5844b093e347 100644 --- a/app/code/Magento/Eav/Model/AttributeDataFactory.php +++ b/app/code/Magento/Eav/Model/AttributeDataFactory.php @@ -22,11 +22,7 @@ class AttributeDataFactory // available only for multiply attributes - /** - * Array of attribute data models by input type - * - * @var array - */ + // available only for multiply attributes protected $_dataModels = []; /** diff --git a/app/code/Magento/Eav/Model/AttributeFactory.php b/app/code/Magento/Eav/Model/AttributeFactory.php index d58934e49f104..17e7c21f0ac41 100644 --- a/app/code/Magento/Eav/Model/AttributeFactory.php +++ b/app/code/Magento/Eav/Model/AttributeFactory.php @@ -10,6 +10,7 @@ * * @api * @codeCoverageIgnore + * @since 100.0.2 */ class AttributeFactory { diff --git a/app/code/Magento/Eav/Model/AttributeManagement.php b/app/code/Magento/Eav/Model/AttributeManagement.php index 0c347ef0c439e..ec283b8eac19b 100644 --- a/app/code/Magento/Eav/Model/AttributeManagement.php +++ b/app/code/Magento/Eav/Model/AttributeManagement.php @@ -22,7 +22,7 @@ class AttributeManagement implements \Magento\Eav\Api\AttributeManagementInterfa /** * @var \Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection - * @deprecated please use instead \Magento\Eav\Model\ResourceModel\Entity\Attribute\CollectionFactory + * @deprecated 100.2.0 please use instead \Magento\Eav\Model\ResourceModel\Entity\Attribute\CollectionFactory */ protected $attributeCollection; diff --git a/app/code/Magento/Eav/Model/AttributeRepository.php b/app/code/Magento/Eav/Model/AttributeRepository.php index 5003219011722..3f20558d03d78 100644 --- a/app/code/Magento/Eav/Model/AttributeRepository.php +++ b/app/code/Magento/Eav/Model/AttributeRepository.php @@ -193,7 +193,7 @@ public function deleteById($attributeId) /** * Retrieve collection processor * - * @deprecated + * @deprecated 100.2.0 * @return CollectionProcessorInterface */ private function getCollectionProcessor() diff --git a/app/code/Magento/Eav/Model/AttributeSetRepository.php b/app/code/Magento/Eav/Model/AttributeSetRepository.php index d58bf6440a60d..d0b7ed3ccaa28 100644 --- a/app/code/Magento/Eav/Model/AttributeSetRepository.php +++ b/app/code/Magento/Eav/Model/AttributeSetRepository.php @@ -120,7 +120,7 @@ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCr /** * Retrieve entity type code from search criteria * - * @deprecated + * @deprecated 100.2.0 * @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria * @return null|string */ @@ -177,7 +177,7 @@ public function deleteById($attributeSetId) /** * Retrieve collection processor * - * @deprecated + * @deprecated 100.2.0 * @return CollectionProcessorInterface */ private function getCollectionProcessor() diff --git a/app/code/Magento/Eav/Model/Config.php b/app/code/Magento/Eav/Model/Config.php index a1989fcec8c7d..cc68709cd3b03 100644 --- a/app/code/Magento/Eav/Model/Config.php +++ b/app/code/Magento/Eav/Model/Config.php @@ -13,6 +13,7 @@ /** * @api * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class Config { @@ -24,11 +25,7 @@ class Config const ATTRIBUTES_CODES_CACHE_ID = 'EAV_ENTITY_ATTRIBUTES_CODES'; /**#@-*/ - /** - * Entity types data - * - * @var array - */ + /**#@-*/ protected $_entityTypeData; /** @@ -89,7 +86,9 @@ class Config */ protected $_cache; - /** @var \Magento\Framework\App\Cache\StateInterface */ + /** + * @var \Magento\Framework\App\Cache\StateInterface + */ protected $_cacheState; /** @@ -470,11 +469,12 @@ protected function _initAttributes($entityType) /** * Get attributes by entity type * - * @deprecated + * @deprecated 100.2.0 * @see \Magento\Eav\Model\Config::getEntityAttributes * * @param string $entityType * @return AbstractAttribute[] + * @since 100.2.0 */ public function getAttributes($entityType) { @@ -539,7 +539,7 @@ private function createAttribute($model) /** * Get codes of all entity type attributes * - * @deprecated + * @deprecated 100.2.0 * @see \Magento\Eav\Model\Config::getEntityAttributes * * @param mixed $entityType @@ -560,6 +560,7 @@ public function getEntityAttributeCodes($entityType, $object = null) * * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) + * @since 100.2.0 */ public function getEntityAttributes($entityType, $object = null) { diff --git a/app/code/Magento/Eav/Model/EavCustomAttributeTypeLocator.php b/app/code/Magento/Eav/Model/EavCustomAttributeTypeLocator.php index 719208674f7ee..b20ee08a47aba 100644 --- a/app/code/Magento/Eav/Model/EavCustomAttributeTypeLocator.php +++ b/app/code/Magento/Eav/Model/EavCustomAttributeTypeLocator.php @@ -126,7 +126,7 @@ public function getAllServiceDataInterfaces() * Get complex type locator instance * * @return ComplexTypeLocator - * @deprecated + * @deprecated 100.1.0 */ private function getComplexTypeLocator() { @@ -140,7 +140,7 @@ private function getComplexTypeLocator() * Get simple type locator instance * * @return SimpleTypeLocator - * @deprecated + * @deprecated 100.1.0 */ private function getSimpleTypeLocator() { diff --git a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php index 071f5167b5870..51351490061fc 100644 --- a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php +++ b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php @@ -31,11 +31,13 @@ * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ abstract class AbstractEntity extends AbstractResource implements EntityInterface, DefaultAttributesProvider { /** * @var \Magento\Eav\Model\Entity\AttributeLoaderInterface + * @since 100.1.0 */ protected $attributeLoader; @@ -99,6 +101,7 @@ abstract class AbstractEntity extends AbstractResource implements EntityInterfac * Entity primary key for link field name * * @var string + * @since 100.1.0 */ protected $linkIdField; @@ -724,6 +727,7 @@ public function getEntityTable() * Get link id * * @return string + * @since 100.1.0 */ public function getLinkField() { @@ -763,7 +767,7 @@ public function getEntityIdField() */ public function getValueEntityIdField() { - return $this->getEntityIdField(); + return $this->getLinkField(); } /** @@ -881,28 +885,33 @@ public function checkAttributeUniqueValue(AbstractAttribute $attribute, $object) { $connection = $this->getConnection(); $select = $connection->select(); - if ($attribute->getBackend()->getType() === 'static') { + + $entityIdField = $this->getEntityIdField(); + $attributeBackend = $attribute->getBackend(); + if ($attributeBackend->getType() === 'static') { $value = $object->getData($attribute->getAttributeCode()); $bind = ['value' => trim($value)]; $select->from( $this->getEntityTable(), - $this->getEntityIdField() + $entityIdField )->where( $attribute->getAttributeCode() . ' = :value' ); } else { $value = $object->getData($attribute->getAttributeCode()); - if ($attribute->getBackend()->getType() == 'datetime') { + if ($attributeBackend->getType() == 'datetime') { $value = (new \DateTime($value))->format('Y-m-d H:i:s'); } $bind = [ 'attribute_id' => $attribute->getId(), 'value' => trim($value), ]; + + $entityIdField = $attributeBackend->getEntityIdField(); $select->from( - $attribute->getBackend()->getTable(), - $object->getResource()->getLinkField() + $attributeBackend->getTable(), + $entityIdField )->where( 'attribute_id = :attribute_id' )->where( @@ -917,9 +926,10 @@ public function checkAttributeUniqueValue(AbstractAttribute $attribute, $object) $data = $connection->fetchCol($select, $bind); - if ($object->getId()) { + $objectId = $object->getData($entityIdField); + if ($objectId) { if (isset($data[0])) { - return $data[0] == $object->getId(); + return $data[0] == $objectId; } return true; } @@ -976,9 +986,10 @@ public function load($object, $entityId, $attributes = []) /** * Loads attributes metadata. * - * @deprecated Use self::loadAttributesForObject instead + * @deprecated 100.2.0 Use self::loadAttributesForObject instead * @param array|null $attributes * @return $this + * @since 100.1.0 */ protected function loadAttributesMetadata($attributes) { @@ -1160,6 +1171,7 @@ public function save(\Magento\Framework\Model\AbstractModel $object) * * @param \Magento\Framework\Model\AbstractModel $object * @return void + * @since 100.1.0 */ protected function processSave($object) { @@ -1724,6 +1736,7 @@ public function delete($object) * @return void * @throws \Exception * @SuppressWarnings(PHPMD.UnusedLocalVariable) + * @since 100.1.0 */ protected function evaluateDelete($object, $id, $connection) { @@ -1860,7 +1873,8 @@ protected function _isAttributeValueEmpty(AbstractAttribute $attribute, $value) * * @return AttributeLoaderInterface * - * @deprecated + * @deprecated 100.1.0 + * @since 100.1.0 */ protected function getAttributeLoader() { @@ -1874,6 +1888,7 @@ protected function getAttributeLoader() * Perform actions after entity load * * @param \Magento\Framework\DataObject $object + * @since 100.1.0 */ public function afterLoad(\Magento\Framework\DataObject $object) { @@ -1884,6 +1899,7 @@ public function afterLoad(\Magento\Framework\DataObject $object) * Perform actions before entity save * * @param \Magento\Framework\DataObject $object + * @since 100.1.0 */ public function beforeSave(\Magento\Framework\DataObject $object) { @@ -1894,6 +1910,7 @@ public function beforeSave(\Magento\Framework\DataObject $object) * Perform actions after entity save * * @param \Magento\Framework\DataObject $object + * @since 100.1.0 */ public function afterSave(\Magento\Framework\DataObject $object) { @@ -1904,6 +1921,7 @@ public function afterSave(\Magento\Framework\DataObject $object) * Perform actions before entity delete * * @param \Magento\Framework\DataObject $object + * @since 100.1.0 */ public function beforeDelete(\Magento\Framework\DataObject $object) { @@ -1914,6 +1932,7 @@ public function beforeDelete(\Magento\Framework\DataObject $object) * Perform actions after entity delete * * @param \Magento\Framework\DataObject $object + * @since 100.1.0 */ public function afterDelete(\Magento\Framework\DataObject $object) { @@ -1927,6 +1946,7 @@ public function afterDelete(\Magento\Framework\DataObject $object) * @param array $attributes * @param AbstractEntity|null $object * @return void + * @since 100.2.0 */ protected function loadAttributesForObject($attributes, $object = null) { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute.php b/app/code/Magento/Eav/Model/Entity/Attribute.php index fc598b264b395..c9865098602c0 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute.php @@ -16,6 +16,7 @@ * @method \Magento\Eav\Model\Entity\Attribute setOption($value) * @method \Magento\Eav\Api\Data\AttributeExtensionInterface getExtensionAttributes() * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class Attribute extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute implements \Magento\Framework\DataObject\IdentityInterface @@ -25,6 +26,11 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute im */ const ATTRIBUTE_CODE_MAX_LENGTH = 30; + /** + * Attribute code min length. + */ + const ATTRIBUTE_CODE_MIN_LENGTH = 1; + /** * Cache tag */ @@ -304,6 +310,7 @@ public function afterSave() /** * @return $this + * @since 100.0.7 */ public function afterDelete() { @@ -475,6 +482,7 @@ public function getIdentities() /** * @inheritdoc + * @since 100.0.7 */ public function __sleep() { @@ -487,6 +495,7 @@ public function __sleep() /** * @inheritdoc + * @since 100.0.7 */ public function __wakeup() { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php b/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php index d6225cc698ddd..19877a51c4869 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php @@ -17,6 +17,7 @@ * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.TooManyFields) + * @since 100.0.2 */ abstract class AbstractAttribute extends \Magento\Framework\Model\AbstractExtensibleModel implements AttributeInterface, @@ -122,6 +123,7 @@ abstract class AbstractAttribute extends \Magento\Framework\Model\AbstractExtens * Serializer Instance. * * @var Json + * @since 100.2.0 */ protected $serializer; @@ -196,9 +198,10 @@ public function __construct( /** * Get Serializer instance. - * @deprecated + * @deprecated 100.2.0 * * @return Json + * @since 100.2.0 */ protected function getSerializer() { @@ -658,6 +661,7 @@ public function isValueEmpty($value) * * @param array|null|bool|int|float|string $value * @return bool + * @since 100.1.6 */ public function isAllowedEmptyTextValue($value) { @@ -866,7 +870,7 @@ public function _getFlatColumnsDdlDefinition() * Retrieve flat columns definition in old format (before MMDB support) * Used in database compatible mode * - * @deprecated + * @deprecated 100.2.0 * @return array * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ @@ -1322,6 +1326,7 @@ public function setExtensionAttributes(\Magento\Eav\Api\Data\AttributeExtensionI /** * @inheritdoc + * @since 100.0.7 */ public function __sleep() { @@ -1346,6 +1351,7 @@ public function __sleep() /** * @inheritdoc + * @since 100.0.7 */ public function __wakeup() { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/AttributeGroupAlreadyExistsException.php b/app/code/Magento/Eav/Model/Entity/Attribute/AttributeGroupAlreadyExistsException.php index 6aa8810583e3a..fa50aa588b4ed 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/AttributeGroupAlreadyExistsException.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/AttributeGroupAlreadyExistsException.php @@ -9,6 +9,7 @@ /** * @api + * @since 100.2.0 */ class AttributeGroupAlreadyExistsException extends AlreadyExistsException { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/AttributeInterface.php b/app/code/Magento/Eav/Model/Entity/Attribute/AttributeInterface.php index 5502c8cc89324..f6ec8024ce235 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/AttributeInterface.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/AttributeInterface.php @@ -5,6 +5,10 @@ */ namespace Magento\Eav\Model\Entity\Attribute; +/** + * Interface \Magento\Eav\Model\Entity\Attribute\AttributeInterface + * + */ interface AttributeInterface { } diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/AbstractBackend.php b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/AbstractBackend.php index 4a9fa32d06ad2..fab2ed182f30e 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/AbstractBackend.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/AbstractBackend.php @@ -12,6 +12,7 @@ * * @api * @SuppressWarnings(PHPMD.NumberOfChildren) + * @since 100.0.2 */ abstract class AbstractBackend implements \Magento\Eav\Model\Entity\Attribute\Backend\BackendInterface { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/ArrayBackend.php b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/ArrayBackend.php index 4afbf774ed311..03c91f53287eb 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/ArrayBackend.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/ArrayBackend.php @@ -9,6 +9,7 @@ * Backend model for attribute with multiple values * * @api + * @since 100.0.2 */ class ArrayBackend extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Datetime.php b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Datetime.php index 860545866e19a..786060ea7b312 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Datetime.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Datetime.php @@ -10,6 +10,7 @@ /** * @api + * @since 100.0.2 */ class Datetime extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/DefaultBackend.php b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/DefaultBackend.php index 5b2ea18aeec5c..c02773d57339b 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/DefaultBackend.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/DefaultBackend.php @@ -9,6 +9,7 @@ * Entity/Attribute/Model - attribute backend default * * @api + * @since 100.0.2 */ class DefaultBackend extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Increment.php b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Increment.php index 32153de3c12c2..0b08fa0df4153 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Increment.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Increment.php @@ -9,6 +9,7 @@ * Entity/Attribute/Model - attribute backend default * * @api + * @since 100.0.2 */ class Increment extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/JsonEncoded.php b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/JsonEncoded.php index a873462215558..f47c73f01f238 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/JsonEncoded.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/JsonEncoded.php @@ -11,6 +11,7 @@ * Backend model for attribute that stores structures in json format * * @api + * @since 100.2.0 */ class JsonEncoded extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend { @@ -34,6 +35,7 @@ public function __construct(Json $jsonSerializer) * * @param \Magento\Framework\DataObject $object * @return $this + * @since 100.2.0 */ public function beforeSave($object) { @@ -50,6 +52,7 @@ public function beforeSave($object) * * @param \Magento\Framework\DataObject $object * @return $this + * @since 100.2.0 */ public function afterLoad($object) { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Store.php b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Store.php index 2cc8157166376..391a22670b655 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Store.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Store.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Store extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Time/Created.php b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Time/Created.php index fb133524af86a..0177cdeafc289 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Time/Created.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Time/Created.php @@ -9,6 +9,7 @@ * Entity/Attribute/Model - attribute backend default * * @api + * @since 100.0.2 */ class Created extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend { @@ -20,7 +21,7 @@ class Created extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBacken /** * @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime * @codeCoverageIgnore - * @deprecated Remove unused dependency + * @deprecated 100.1.0 Remove unused dependency */ public function __construct(\Magento\Framework\Stdlib\DateTime\DateTime $dateTime) { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Time/Updated.php b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Time/Updated.php index 7191a0f87626c..212e56d2595e4 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Time/Updated.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Time/Updated.php @@ -8,6 +8,7 @@ /** * Entity/Attribute/Model - attribute backend default * @api + * @since 100.0.2 */ class Updated extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend { @@ -19,7 +20,7 @@ class Updated extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBacken /** * @param \Magento\Framework\Stdlib\DateTime $dateTime * @codeCoverageIgnore - * @deprecated Remove unused dependency + * @deprecated 100.1.0 Remove unused dependency */ public function __construct(\Magento\Framework\Stdlib\DateTime $dateTime) { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Config.php b/app/code/Magento/Eav/Model/Entity/Attribute/Config.php index c2b1e81bcb26a..8332262f0e0c5 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Config.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Config.php @@ -11,6 +11,7 @@ * Provides EAV attributes configuration * * @api + * @since 100.0.2 */ class Config extends \Magento\Framework\Config\Data { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Exception.php b/app/code/Magento/Eav/Model/Entity/Attribute/Exception.php index 559cce22bb2c7..f9c3cb08535e7 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Exception.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Exception.php @@ -9,6 +9,7 @@ * EAV entity attribute exception * * @api + * @since 100.0.2 */ class Exception extends \Magento\Framework\Exception\LocalizedException { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/AbstractFrontend.php b/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/AbstractFrontend.php index a2bb750e1716e..cdd4fce583230 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/AbstractFrontend.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/AbstractFrontend.php @@ -21,6 +21,7 @@ /** * @api + * @since 100.0.2 */ abstract class AbstractFrontend implements \Magento\Eav\Model\Entity\Attribute\Frontend\FrontendInterface { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/Datetime.php b/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/Datetime.php index 6e84ca7c07354..1e2976df4cb0e 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/Datetime.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/Datetime.php @@ -10,6 +10,7 @@ /** * @api + * @since 100.0.2 */ class Datetime extends \Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/DefaultFrontend.php b/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/DefaultFrontend.php index fe577091ca67e..9d04e8b22f489 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/DefaultFrontend.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/DefaultFrontend.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class DefaultFrontend extends \Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/FrontendInterface.php b/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/FrontendInterface.php index b46ead5be6047..d9363cf5494aa 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/FrontendInterface.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/FrontendInterface.php @@ -11,6 +11,7 @@ * Frontend is providing the user interface for the attribute * * @api + * @since 100.0.2 */ interface FrontendInterface { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Group.php b/app/code/Magento/Eav/Model/Entity/Attribute/Group.php index 004faf3ee9a6f..0b6ac2b998de7 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Group.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Group.php @@ -9,8 +9,6 @@ /** * @api - * @method \Magento\Eav\Model\ResourceModel\Entity\Attribute\Group _getResource() - * @method \Magento\Eav\Model\ResourceModel\Entity\Attribute\Group getResource() * @method int getSortOrder() * @method \Magento\Eav\Model\Entity\Attribute\Group setSortOrder(int $value) * @method int getDefaultId() @@ -19,6 +17,7 @@ * @method \Magento\Eav\Model\Entity\Attribute\Group setAttributeGroupCode(string $value) * @method string getTabGroupCode() * @method \Magento\Eav\Model\Entity\Attribute\Group setTabGroupCode(string $value) + * @since 100.0.2 */ class Group extends \Magento\Framework\Model\AbstractExtensibleModel implements \Magento\Eav\Api\Data\AttributeGroupInterface diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Option.php b/app/code/Magento/Eav/Model/Entity/Attribute/Option.php index 9346d5382fe48..a42087b99df4b 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Option.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Option.php @@ -11,13 +11,12 @@ /** * Emtity attribute option model * - * @method \Magento\Eav\Model\ResourceModel\Entity\Attribute\Option _getResource() - * @method \Magento\Eav\Model\ResourceModel\Entity\Attribute\Option getResource() * @method int getAttributeId() * @method \Magento\Eav\Model\Entity\Attribute\Option setAttributeId(int $value) * * @api * @codeCoverageIgnore + * @since 100.0.2 */ class Option extends AbstractModel implements AttributeOptionInterface { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/ScopedAttributeInterface.php b/app/code/Magento/Eav/Model/Entity/Attribute/ScopedAttributeInterface.php index 08cb128e550bf..eed4e4661f22b 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/ScopedAttributeInterface.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/ScopedAttributeInterface.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ interface ScopedAttributeInterface { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Set.php b/app/code/Magento/Eav/Model/Entity/Attribute/Set.php index 99c872c6e3730..5434f05610467 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Set.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Set.php @@ -7,7 +7,6 @@ /** * Eav attribute set model * - * @method \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set getResource() * @method int getEntityTypeId() * @method \Magento\Eav\Model\Entity\Attribute\Set setEntityTypeId(int $value) * @method string getAttributeSetName() @@ -38,11 +37,7 @@ class Set extends \Magento\Framework\Model\AbstractExtensibleModel implements const KEY_ENTITY_TYPE_ID = 'entity_type_id'; /**#@-*/ - /** - * Resource instance - * - * @var \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set - */ + /**#@-*/ protected $_resource; /** @@ -373,6 +368,7 @@ public function getDefaultGroupId($setId = null) * Get resource instance * * @return \Magento\Framework\Model\ResourceModel\Db\AbstractDb + * @deprecated 100.2.0 because resource models should be used directly */ protected function _getResource() { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Source/AbstractSource.php b/app/code/Magento/Eav/Model/Entity/Attribute/Source/AbstractSource.php index 36fa30a3a99db..0991b3f9f4b23 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Source/AbstractSource.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Source/AbstractSource.php @@ -11,6 +11,7 @@ * @api * @author Magento Core Team * @SuppressWarnings(PHPMD.NumberOfChildren) + * @since 100.0.2 */ abstract class AbstractSource implements \Magento\Eav\Model\Entity\Attribute\Source\SourceInterface, diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Source/Boolean.php b/app/code/Magento/Eav/Model/Entity/Attribute/Source/Boolean.php index a1c78c2dfc324..a9f91797cc72d 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Source/Boolean.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Source/Boolean.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ class Boolean extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Source/SourceInterface.php b/app/code/Magento/Eav/Model/Entity/Attribute/Source/SourceInterface.php index c85eaceae1d19..44b4ab55ec7da 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Source/SourceInterface.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Source/SourceInterface.php @@ -11,6 +11,7 @@ * Source is providing the selection options for user interface * * @api + * @since 100.0.2 */ interface SourceInterface { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Source/Store.php b/app/code/Magento/Eav/Model/Entity/Attribute/Source/Store.php index 876f13675e3ba..00450088e86aa 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Source/Store.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Source/Store.php @@ -9,6 +9,7 @@ * Customer store_id attribute source * * @api + * @since 100.0.2 */ class Store extends \Magento\Eav\Model\Entity\Attribute\Source\Table { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Source/Table.php b/app/code/Magento/Eav/Model/Entity/Attribute/Source/Table.php index 1e0b8557a1d07..03d64ff27e962 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Source/Table.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Source/Table.php @@ -10,6 +10,7 @@ /** * @api + * @since 100.0.2 */ class Table extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource { @@ -93,7 +94,7 @@ public function getAllOptions($withEmpty = true, $defaultValues = false) * Get StoreManager dependency * * @return StoreManagerInterface - * @deprecated + * @deprecated 100.1.6 */ private function getStoreManager() { diff --git a/app/code/Magento/Eav/Model/Entity/AttributeLoader.php b/app/code/Magento/Eav/Model/Entity/AttributeLoader.php index 65667af3daa26..a925f8e78ff33 100644 --- a/app/code/Magento/Eav/Model/Entity/AttributeLoader.php +++ b/app/code/Magento/Eav/Model/Entity/AttributeLoader.php @@ -63,6 +63,9 @@ public function loadAllAttributes(AbstractEntity $resource, DataObject $object = * Check and init default attributes */ $defaultAttributesCodes = array_diff($resource->getDefaultAttributes(), $attributeCodes); + + $resource->unsetAttributes(); + foreach ($defaultAttributesCodes as $attributeCode) { $resource->addAttribute($this->_getDefaultAttribute($resource, $attributeCode)); } diff --git a/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php b/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php index 28cdbb48d1941..bd3fd17393d7c 100644 --- a/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php +++ b/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php @@ -17,6 +17,7 @@ * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ abstract class AbstractCollection extends AbstractDb implements SourceProviderInterface { @@ -1421,6 +1422,7 @@ protected function _addAttributeJoin($attributeCode, $joinType = 'inner') * * @param \Magento\Eav\Model\Entity\AbstractEntity $entity * @return string + * @since 100.1.0 */ protected function getEntityPkName(\Magento\Eav\Model\Entity\AbstractEntity $entity) { diff --git a/app/code/Magento/Eav/Model/Entity/Collection/VersionControl/AbstractCollection.php b/app/code/Magento/Eav/Model/Entity/Collection/VersionControl/AbstractCollection.php index 176085081e5e6..e626ed35eb1e9 100644 --- a/app/code/Magento/Eav/Model/Entity/Collection/VersionControl/AbstractCollection.php +++ b/app/code/Magento/Eav/Model/Entity/Collection/VersionControl/AbstractCollection.php @@ -8,6 +8,7 @@ /** * Class Abstract Collection * @api + * @since 100.0.2 */ abstract class AbstractCollection extends \Magento\Eav\Model\Entity\Collection\AbstractCollection { diff --git a/app/code/Magento/Eav/Model/Entity/Context.php b/app/code/Magento/Eav/Model/Entity/Context.php index 40eb71f1aeebd..396eb959c2d58 100644 --- a/app/code/Magento/Eav/Model/Entity/Context.php +++ b/app/code/Magento/Eav/Model/Entity/Context.php @@ -18,6 +18,7 @@ * * @api * @codeCoverageIgnore + * @since 100.0.2 */ class Context implements \Magento\Framework\ObjectManager\ContextInterface { diff --git a/app/code/Magento/Eav/Model/Entity/EntityInterface.php b/app/code/Magento/Eav/Model/Entity/EntityInterface.php index 95192087e00b9..396763e995130 100644 --- a/app/code/Magento/Eav/Model/Entity/EntityInterface.php +++ b/app/code/Magento/Eav/Model/Entity/EntityInterface.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ interface EntityInterface { diff --git a/app/code/Magento/Eav/Model/Entity/Increment/AbstractIncrement.php b/app/code/Magento/Eav/Model/Entity/Increment/AbstractIncrement.php index 35e7bf6ea5eff..406e23921db4d 100644 --- a/app/code/Magento/Eav/Model/Entity/Increment/AbstractIncrement.php +++ b/app/code/Magento/Eav/Model/Entity/Increment/AbstractIncrement.php @@ -13,6 +13,7 @@ * - last_id * * @api + * @since 100.0.2 */ abstract class AbstractIncrement extends \Magento\Framework\DataObject implements \Magento\Eav\Model\Entity\Increment\IncrementInterface diff --git a/app/code/Magento/Eav/Model/Entity/Increment/IncrementInterface.php b/app/code/Magento/Eav/Model/Entity/Increment/IncrementInterface.php index fbf4a16f47368..72038f209aad9 100644 --- a/app/code/Magento/Eav/Model/Entity/Increment/IncrementInterface.php +++ b/app/code/Magento/Eav/Model/Entity/Increment/IncrementInterface.php @@ -7,6 +7,7 @@ /** * @api + * @since 100.0.2 */ interface IncrementInterface { diff --git a/app/code/Magento/Eav/Model/Entity/Increment/NumericValue.php b/app/code/Magento/Eav/Model/Entity/Increment/NumericValue.php index 01b605ded066d..b86b1e33c5859 100644 --- a/app/code/Magento/Eav/Model/Entity/Increment/NumericValue.php +++ b/app/code/Magento/Eav/Model/Entity/Increment/NumericValue.php @@ -15,6 +15,7 @@ * - last_id * * @api + * @since 100.0.2 */ class NumericValue extends \Magento\Eav\Model\Entity\Increment\AbstractIncrement { diff --git a/app/code/Magento/Eav/Model/Entity/Setup/Context.php b/app/code/Magento/Eav/Model/Entity/Setup/Context.php index adfb05c5cc2b3..6cbff66297675 100644 --- a/app/code/Magento/Eav/Model/Entity/Setup/Context.php +++ b/app/code/Magento/Eav/Model/Entity/Setup/Context.php @@ -18,6 +18,7 @@ * * @api * @codeCoverageIgnore + * @since 100.0.2 */ class Context extends \Magento\Framework\Module\Setup\Context { diff --git a/app/code/Magento/Eav/Model/Entity/Setup/PropertyMapperInterface.php b/app/code/Magento/Eav/Model/Entity/Setup/PropertyMapperInterface.php index f107f200d70f4..b2bb727d6bc88 100644 --- a/app/code/Magento/Eav/Model/Entity/Setup/PropertyMapperInterface.php +++ b/app/code/Magento/Eav/Model/Entity/Setup/PropertyMapperInterface.php @@ -7,6 +7,10 @@ */ namespace Magento\Eav\Model\Entity\Setup; +/** + * Interface \Magento\Eav\Model\Entity\Setup\PropertyMapperInterface + * + */ interface PropertyMapperInterface { /** diff --git a/app/code/Magento/Eav/Model/Entity/Store.php b/app/code/Magento/Eav/Model/Entity/Store.php index b2b6a3a70d659..759ad7f6103a5 100644 --- a/app/code/Magento/Eav/Model/Entity/Store.php +++ b/app/code/Magento/Eav/Model/Entity/Store.php @@ -7,8 +7,6 @@ /** * @api - * @method \Magento\Eav\Model\ResourceModel\Entity\Store _getResource() - * @method \Magento\Eav\Model\ResourceModel\Entity\Store getResource() * @method int getEntityTypeId() * @method \Magento\Eav\Model\Entity\Store setEntityTypeId(int $value) * @method int getStoreId() @@ -17,6 +15,7 @@ * @method \Magento\Eav\Model\Entity\Store setIncrementPrefix(string $value) * @method string getIncrementLastId() * @method \Magento\Eav\Model\Entity\Store setIncrementLastId(string $value) + * @since 100.0.2 */ class Store extends \Magento\Framework\Model\AbstractModel { diff --git a/app/code/Magento/Eav/Model/Entity/Type.php b/app/code/Magento/Eav/Model/Entity/Type.php index e8f2a30804efd..aa298d7d547bf 100644 --- a/app/code/Magento/Eav/Model/Entity/Type.php +++ b/app/code/Magento/Eav/Model/Entity/Type.php @@ -9,8 +9,6 @@ * Entity type model * * @api - * @method \Magento\Eav\Model\ResourceModel\Entity\Type _getResource() - * @method \Magento\Eav\Model\ResourceModel\Entity\Type getResource() * @method \Magento\Eav\Model\Entity\Type setEntityTypeCode(string $value) * @method string getEntityModel() * @method \Magento\Eav\Model\Entity\Type setEntityModel(string $value) @@ -36,6 +34,7 @@ * @method \Magento\Eav\Model\Entity\Type setEntityAttributeCollection(string $value) * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class Type extends \Magento\Framework\Model\AbstractModel { diff --git a/app/code/Magento/Eav/Model/Form.php b/app/code/Magento/Eav/Model/Form.php index 08a86f350ec5e..c8c50521f5509 100644 --- a/app/code/Magento/Eav/Model/Form.php +++ b/app/code/Magento/Eav/Model/Form.php @@ -13,6 +13,7 @@ * @api * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ abstract class Form { diff --git a/app/code/Magento/Eav/Model/Form/Element.php b/app/code/Magento/Eav/Model/Form/Element.php index 9b6c65df08b43..28b6b1433eba5 100644 --- a/app/code/Magento/Eav/Model/Form/Element.php +++ b/app/code/Magento/Eav/Model/Form/Element.php @@ -11,7 +11,6 @@ * Eav Form Element Model * * @api - * @method \Magento\Eav\Model\ResourceModel\Form\Element getResource() * @method int getTypeId() * @method \Magento\Eav\Model\Form\Element setTypeId(int $value) * @method int getFieldsetId() @@ -20,6 +19,7 @@ * @method \Magento\Eav\Model\Form\Element setAttributeId(int $value) * @method int getSortOrder() * @method \Magento\Eav\Model\Form\Element setSortOrder(int $value) + * @since 100.0.2 */ class Element extends \Magento\Framework\Model\AbstractModel { @@ -67,28 +67,6 @@ protected function _construct() $this->_init(\Magento\Eav\Model\ResourceModel\Form\Element::class); } - /** - * Retrieve resource instance wrapper - * - * @return \Magento\Eav\Model\ResourceModel\Form\Element - * @codeCoverageIgnore - */ - protected function _getResource() - { - return parent::_getResource(); - } - - /** - * Retrieve resource collection instance wrapper - * - * @return \Magento\Eav\Model\ResourceModel\Form\Element\Collection - * @codeCoverageIgnore - */ - public function getCollection() - { - return parent::getCollection(); - } - /** * Validate data before save data * diff --git a/app/code/Magento/Eav/Model/Form/Factory.php b/app/code/Magento/Eav/Model/Form/Factory.php index 7acb4a3b0859f..9223dc9e148f1 100644 --- a/app/code/Magento/Eav/Model/Form/Factory.php +++ b/app/code/Magento/Eav/Model/Form/Factory.php @@ -8,6 +8,7 @@ /** * EAV form object factory * @api + * @since 100.0.2 */ class Factory { diff --git a/app/code/Magento/Eav/Model/Form/Fieldset.php b/app/code/Magento/Eav/Model/Form/Fieldset.php index fd94996085832..a0c706c3d03a5 100644 --- a/app/code/Magento/Eav/Model/Form/Fieldset.php +++ b/app/code/Magento/Eav/Model/Form/Fieldset.php @@ -9,13 +9,13 @@ * Eav Form Fieldset Model * * @api - * @method \Magento\Eav\Model\ResourceModel\Form\Fieldset getResource() * @method int getTypeId() * @method \Magento\Eav\Model\Form\Fieldset setTypeId(int $value) * @method string getCode() * @method \Magento\Eav\Model\Form\Fieldset setCode(string $value) * @method int getSortOrder() * @method \Magento\Eav\Model\Form\Fieldset setSortOrder(int $value) + * @since 100.0.2 */ class Fieldset extends \Magento\Framework\Model\AbstractModel { @@ -63,28 +63,6 @@ protected function _construct() $this->_init(\Magento\Eav\Model\ResourceModel\Form\Fieldset::class); } - /** - * Retrieve resource instance wrapper - * - * @return \Magento\Eav\Model\ResourceModel\Form\Fieldset - * @codeCoverageIgnore - */ - protected function _getResource() - { - return parent::_getResource(); - } - - /** - * Retrieve resource collection instance wrapper - * - * @return \Magento\Eav\Model\ResourceModel\Form\Fieldset\Collection - * @codeCoverageIgnore - */ - public function getCollection() - { - return parent::getCollection(); - } - /** * Validate data before save data * diff --git a/app/code/Magento/Eav/Model/Form/Type.php b/app/code/Magento/Eav/Model/Form/Type.php index 8dbe7591d4cda..361e3faac7b32 100644 --- a/app/code/Magento/Eav/Model/Form/Type.php +++ b/app/code/Magento/Eav/Model/Form/Type.php @@ -8,7 +8,6 @@ /** * Eav Form Type Model * - * @method \Magento\Eav\Model\ResourceModel\Form\Type getResource() * @method string getCode() * @method \Magento\Eav\Model\Form\Type setCode(string $value) * @method string getLabel() @@ -76,28 +75,6 @@ protected function _construct() $this->_init(\Magento\Eav\Model\ResourceModel\Form\Type::class); } - /** - * Retrieve resource instance wrapper - * - * @return \Magento\Eav\Model\ResourceModel\Form\Type - * @codeCoverageIgnore - */ - protected function _getResource() - { - return parent::_getResource(); - } - - /** - * Retrieve resource collection instance wrapper - * - * @return \Magento\Eav\Model\ResourceModel\Form\Type\Collection - * @codeCoverageIgnore - */ - public function getCollection() - { - return parent::getCollection(); - } - /** * Retrieve assigned Eav Entity types * diff --git a/app/code/Magento/Eav/Model/ResourceModel/Attribute.php b/app/code/Magento/Eav/Model/ResourceModel/Attribute.php index ec24695a279d5..8160a9822dd08 100644 --- a/app/code/Magento/Eav/Model/ResourceModel/Attribute.php +++ b/app/code/Magento/Eav/Model/ResourceModel/Attribute.php @@ -12,6 +12,7 @@ * EAV attribute resource model (Using Forms) * * @api + * @since 100.0.2 */ abstract class Attribute extends \Magento\Eav\Model\ResourceModel\Entity\Attribute { diff --git a/app/code/Magento/Eav/Model/ResourceModel/Attribute/Collection.php b/app/code/Magento/Eav/Model/ResourceModel/Attribute/Collection.php index 88f922bcb6421..7abb54e780f5f 100644 --- a/app/code/Magento/Eav/Model/ResourceModel/Attribute/Collection.php +++ b/app/code/Magento/Eav/Model/ResourceModel/Attribute/Collection.php @@ -11,6 +11,7 @@ * EAV additional attribute resource collection (Using Forms) * * @api + * @since 100.0.2 */ abstract class Collection extends \Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection { diff --git a/app/code/Magento/Eav/Model/ResourceModel/Attribute/DefaultEntityAttributes/ProviderInterface.php b/app/code/Magento/Eav/Model/ResourceModel/Attribute/DefaultEntityAttributes/ProviderInterface.php index d5b999d69ea6c..02d94a7ce4dc0 100644 --- a/app/code/Magento/Eav/Model/ResourceModel/Attribute/DefaultEntityAttributes/ProviderInterface.php +++ b/app/code/Magento/Eav/Model/ResourceModel/Attribute/DefaultEntityAttributes/ProviderInterface.php @@ -5,6 +5,10 @@ */ namespace Magento\Eav\Model\ResourceModel\Attribute\DefaultEntityAttributes; +/** + * Interface \Magento\Eav\Model\ResourceModel\Attribute\DefaultEntityAttributes\ProviderInterface + * + */ interface ProviderInterface { /** diff --git a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute.php b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute.php index c4fcb3fea7e2e..d64d5774fef1f 100644 --- a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute.php +++ b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute.php @@ -17,6 +17,7 @@ * * @api * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class Attribute extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { @@ -214,6 +215,7 @@ protected function _afterSave(AbstractModel $object) * @param \Magento\Framework\Model\AbstractModel|\Magento\Framework\DataObject $object * @return $this * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @since 100.0.7 */ protected function _afterDelete(\Magento\Framework\Model\AbstractModel $object) { @@ -223,7 +225,7 @@ protected function _afterDelete(\Magento\Framework\Model\AbstractModel $object) /** * @return Config - * @deprecated + * @deprecated 100.0.7 */ private function getConfig() { @@ -524,6 +526,7 @@ public function getIdByCode($entityType, $code) * * @param int|string $entityAttributeId * @return array + * @since 100.1.0 */ public function getEntityAttribute($entityAttributeId) { @@ -715,6 +718,7 @@ public function getValidAttributeIds($attributeIds) * Provide variables to serialize * * @return array + * @since 100.0.7 */ public function __sleep() { @@ -727,6 +731,7 @@ public function __sleep() * Restore global dependencies * * @return void + * @since 100.0.7 */ public function __wakeup() { diff --git a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Collection.php b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Collection.php index 9b26bcfdf3eaf..872a9b79c9ba6 100644 --- a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Collection.php +++ b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Collection.php @@ -12,6 +12,7 @@ * * @api * @author Magento Core Team + * @since 100.0.2 */ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { @@ -489,6 +490,7 @@ public function getSelectCountSql() * @param string $cond * @param string $cols * @return $this + * @since 100.1.0 */ public function joinLeft($table, $cond, $cols = '*') { diff --git a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Group/Collection.php b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Group/Collection.php index 0759498617c09..8f3a2a388f462 100644 --- a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Group/Collection.php +++ b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Group/Collection.php @@ -9,6 +9,7 @@ * Eav attribute group resource collection * * @api + * @since 100.0.2 */ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { diff --git a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Set/Collection.php b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Set/Collection.php index d0ee7745124a7..635eca99a276f 100644 --- a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Set/Collection.php +++ b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Set/Collection.php @@ -10,6 +10,7 @@ * * @api * @author Magento Core Team + * @since 100.0.2 */ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { diff --git a/app/code/Magento/Eav/Model/ResourceModel/Entity/Type.php b/app/code/Magento/Eav/Model/ResourceModel/Entity/Type.php index e32a881f5059b..a66bdcb1f33d8 100644 --- a/app/code/Magento/Eav/Model/ResourceModel/Entity/Type.php +++ b/app/code/Magento/Eav/Model/ResourceModel/Entity/Type.php @@ -9,6 +9,7 @@ * EAV entity type resource model * * @api + * @since 100.0.2 */ class Type extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { diff --git a/app/code/Magento/Eav/Model/ResourceModel/Form/Attribute/Collection.php b/app/code/Magento/Eav/Model/ResourceModel/Form/Attribute/Collection.php index 562ae02923252..9438178e56085 100644 --- a/app/code/Magento/Eav/Model/ResourceModel/Form/Attribute/Collection.php +++ b/app/code/Magento/Eav/Model/ResourceModel/Form/Attribute/Collection.php @@ -10,6 +10,7 @@ * * @api * @author Magento Core Team + * @since 100.0.2 */ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { diff --git a/app/code/Magento/Eav/Model/ResourceModel/Form/Element/Collection.php b/app/code/Magento/Eav/Model/ResourceModel/Form/Element/Collection.php index 79d0a0221d555..38fb274f113a7 100644 --- a/app/code/Magento/Eav/Model/ResourceModel/Form/Element/Collection.php +++ b/app/code/Magento/Eav/Model/ResourceModel/Form/Element/Collection.php @@ -9,6 +9,7 @@ * Eav Form Element Resource Collection * * @api + * @since 100.0.2 */ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { diff --git a/app/code/Magento/Eav/Model/ResourceModel/Form/Fieldset/Collection.php b/app/code/Magento/Eav/Model/ResourceModel/Form/Fieldset/Collection.php index 07b60766166d9..a06db7ce4bf9e 100644 --- a/app/code/Magento/Eav/Model/ResourceModel/Form/Fieldset/Collection.php +++ b/app/code/Magento/Eav/Model/ResourceModel/Form/Fieldset/Collection.php @@ -17,6 +17,7 @@ * Eav Form Fieldset Resource Collection * * @api + * @since 100.0.2 */ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { diff --git a/app/code/Magento/Eav/Model/ResourceModel/Helper.php b/app/code/Magento/Eav/Model/ResourceModel/Helper.php index fc63c9082332b..65e2fb250cecd 100644 --- a/app/code/Magento/Eav/Model/ResourceModel/Helper.php +++ b/app/code/Magento/Eav/Model/ResourceModel/Helper.php @@ -9,6 +9,7 @@ * Eav Mysql resource helper model * * @api + * @since 100.0.2 */ class Helper extends \Magento\Framework\DB\Helper { diff --git a/app/code/Magento/Eav/Model/ResourceModel/ReadHandler.php b/app/code/Magento/Eav/Model/ResourceModel/ReadHandler.php index 2af37d09aad81..9febea9b7b2bf 100644 --- a/app/code/Magento/Eav/Model/ResourceModel/ReadHandler.php +++ b/app/code/Magento/Eav/Model/ResourceModel/ReadHandler.php @@ -28,7 +28,9 @@ class ReadHandler implements AttributeInterface */ private $logger; - /** @var \Magento\Eav\Model\Config */ + /** + * @var \Magento\Eav\Model\Config + */ private $config; /** diff --git a/app/code/Magento/Eav/Model/ResourceModel/UpdateHandler.php b/app/code/Magento/Eav/Model/ResourceModel/UpdateHandler.php index a6256b0a0a1a7..cc7a0c4deb14c 100644 --- a/app/code/Magento/Eav/Model/ResourceModel/UpdateHandler.php +++ b/app/code/Magento/Eav/Model/ResourceModel/UpdateHandler.php @@ -190,7 +190,7 @@ public function execute($entityType, $entityData, $arguments = []) /** * Get read handler * - * @deprecated + * @deprecated 100.1.0 * * @return ReadHandler */ diff --git a/app/code/Magento/Eav/Setup/EavSetup.php b/app/code/Magento/Eav/Setup/EavSetup.php index 0f377990583a0..13f55308e6fa6 100644 --- a/app/code/Magento/Eav/Setup/EavSetup.php +++ b/app/code/Magento/Eav/Setup/EavSetup.php @@ -17,6 +17,7 @@ * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @codeCoverageIgnore + * @since 100.0.2 */ class EavSetup { @@ -557,6 +558,7 @@ public function addAttributeGroup($entityTypeId, $setId, $name, $sortOrder = nul /** * @param string $groupName * @return string + * @since 100.1.0 */ public function convertToAttributeGroupCode($groupName) { @@ -629,6 +631,7 @@ public function getAttributeGroup($entityTypeId, $setId, $id, $field = null) * @param string $code * @param string $field * @return mixed + * @since 100.1.0 */ public function getAttributeGroupByCode($entityTypeId, $setId, $code, $field = null) { @@ -768,19 +771,24 @@ private function _getValue($array, $key, $default = null) */ private function _validateAttributeData($data) { - $attributeCodeMaxLength = \Magento\Eav\Model\Entity\Attribute::ATTRIBUTE_CODE_MAX_LENGTH; + $minLength = \Magento\Eav\Model\Entity\Attribute::ATTRIBUTE_CODE_MIN_LENGTH; + $maxLength = \Magento\Eav\Model\Entity\Attribute::ATTRIBUTE_CODE_MAX_LENGTH; + $attributeCode = isset($data['attribute_code']) ? $data['attribute_code'] : ''; - if (isset( - $data['attribute_code'] - ) && !\Zend_Validate::is( - $data['attribute_code'], + $isAllowedLength = \Zend_Validate::is( + trim($attributeCode), 'StringLength', - ['max' => $attributeCodeMaxLength] - ) - ) { - throw new LocalizedException( - __('An attribute code must not be more than %1 characters.', $attributeCodeMaxLength) + ['min' => $minLength, 'max' => $maxLength] + ); + + if (!$isAllowedLength) { + $errorMessage = __( + 'An attribute code must not be less than %1 and more than %2 characters.', + $minLength, + $maxLength ); + + throw new LocalizedException($errorMessage); } return true; diff --git a/app/code/Magento/Eav/Setup/UpgradeSchema.php b/app/code/Magento/Eav/Setup/UpgradeSchema.php index 8f82efe329f17..616514b3aa156 100644 --- a/app/code/Magento/Eav/Setup/UpgradeSchema.php +++ b/app/code/Magento/Eav/Setup/UpgradeSchema.php @@ -25,6 +25,10 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con if (version_compare($context->getVersion(), '2.1.0', '<')) { $this->addUniqueKeyToEavAttributeGroupTable($setup); } + + if (version_compare($context->getVersion(), '2.1.1', '<')) { + $this->modifyAttributeCodeColumnForNotNullable($setup); + } $setup->endSetup(); } @@ -45,4 +49,23 @@ private function addUniqueKeyToEavAttributeGroupTable(SchemaSetupInterface $setu \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE ); } + + /** + * Column attribute_code from eav_attribute should not be nullable. + * + * @param SchemaSetupInterface $setup + */ + private function modifyAttributeCodeColumnForNotNullable(SchemaSetupInterface $setup) + { + $setup->getConnection()->modifyColumn( + $setup->getTable('eav_attribute'), + 'attribute_code', + [ + 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 'length' => 255, + 'nullable' => false, + 'comment' => 'Attribute Code', + ] + ); + } } diff --git a/app/code/Magento/Eav/Test/Unit/Block/Adminhtml/Attribute/PropertyLockerTest.php b/app/code/Magento/Eav/Test/Unit/Block/Adminhtml/Attribute/PropertyLockerTest.php index aae0de909c390..3a9e0e2e05337 100644 --- a/app/code/Magento/Eav/Test/Unit/Block/Adminhtml/Attribute/PropertyLockerTest.php +++ b/app/code/Magento/Eav/Test/Unit/Block/Adminhtml/Attribute/PropertyLockerTest.php @@ -7,7 +7,7 @@ use Magento\Eav\Block\Adminhtml\Attribute\PropertyLocker; -class PropertyLockerTest extends \PHPUnit_Framework_TestCase +class PropertyLockerTest extends \PHPUnit\Framework\TestCase { /** @var PropertyLocker */ protected $object; diff --git a/app/code/Magento/Eav/Test/Unit/Helper/DataTest.php b/app/code/Magento/Eav/Test/Unit/Helper/DataTest.php index 9842c67198f18..877d6e635a57d 100644 --- a/app/code/Magento/Eav/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Eav/Test/Unit/Helper/DataTest.php @@ -8,7 +8,7 @@ use Magento\Store\Model\ScopeInterface; -class DataTest extends \PHPUnit_Framework_TestCase +class DataTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Helper\Data @@ -42,17 +42,11 @@ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->attributeConfig = $this->getMock(\Magento\Eav\Model\Entity\Attribute\Config::class, [], [], '', false); - $this->eavConfig = $this->getMock(\Magento\Eav\Model\Config::class, [], [], '', false); - $this->context = $this->getMock( - \Magento\Framework\App\Helper\Context::class, - ['getScopeConfig'], - [], - '', - false - ); + $this->attributeConfig = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Config::class); + $this->eavConfig = $this->createMock(\Magento\Eav\Model\Config::class); + $this->context = $this->createPartialMock(\Magento\Framework\App\Helper\Context::class, ['getScopeConfig']); - $this->scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $this->scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $this->context->expects($this->once())->method('getScopeConfig')->willReturn($this->scopeConfigMock); $this->helper = $objectManager->getObject( diff --git a/app/code/Magento/Eav/Test/Unit/Model/Adminhtml/Attribute/Validation/Rules/OptionsTest.php b/app/code/Magento/Eav/Test/Unit/Model/Adminhtml/Attribute/Validation/Rules/OptionsTest.php index d9ea28b360e5c..3a258a46fbee4 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Adminhtml/Attribute/Validation/Rules/OptionsTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Adminhtml/Attribute/Validation/Rules/OptionsTest.php @@ -11,7 +11,7 @@ /** * Class OptionsTest */ -class OptionsTest extends \PHPUnit_Framework_TestCase +class OptionsTest extends \PHPUnit\Framework\TestCase { /** * @var Options diff --git a/app/code/Magento/Eav/Test/Unit/Model/Adminhtml/System/Config/Source/Inputtype/ValidatorTest.php b/app/code/Magento/Eav/Test/Unit/Model/Adminhtml/System/Config/Source/Inputtype/ValidatorTest.php index bbfab4ddf5175..fa53ce81ca5f7 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Adminhtml/System/Config/Source/Inputtype/ValidatorTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Adminhtml/System/Config/Source/Inputtype/ValidatorTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Eav\Test\Unit\Model\Adminhtml\System\Config\Source\Inputtype; -class ValidatorTest extends \PHPUnit_Framework_TestCase +class ValidatorTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype\Validator @@ -20,7 +20,7 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $validatorData = ['type']; - $this->helperMock = $this->getMock(\Magento\Eav\Helper\Data::class, [], [], '', false); + $this->helperMock = $this->createMock(\Magento\Eav\Helper\Data::class); $this->helperMock->expects($this->once())->method('getInputTypesValidatorData')->willReturn($validatorData); $this->model = new \Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype\Validator($this->helperMock); } diff --git a/app/code/Magento/Eav/Test/Unit/Model/Adminhtml/System/Config/Source/InputtypeTest.php b/app/code/Magento/Eav/Test/Unit/Model/Adminhtml/System/Config/Source/InputtypeTest.php index c80657c240224..2d00e02adc55d 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Adminhtml/System/Config/Source/InputtypeTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Adminhtml/System/Config/Source/InputtypeTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Eav\Test\Unit\Model\Adminhtml\System\Config\Source; -class InputtypeTest extends \PHPUnit_Framework_TestCase +class InputtypeTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype diff --git a/app/code/Magento/Eav/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/AttributeGroupAttributeSetIdFilterTest.php b/app/code/Magento/Eav/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/AttributeGroupAttributeSetIdFilterTest.php index 4b7dc1e51fe42..5a3a1cc083d0c 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/AttributeGroupAttributeSetIdFilterTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/AttributeGroupAttributeSetIdFilterTest.php @@ -9,7 +9,7 @@ use Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\Collection; use Magento\Framework\Api\Filter; -class AttributeGroupAttributeSetIdFilterTest extends \PHPUnit_Framework_TestCase +class AttributeGroupAttributeSetIdFilterTest extends \PHPUnit\Framework\TestCase { /** * @var AttributeGroupAttributeSetIdFilter diff --git a/app/code/Magento/Eav/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/AttributeGroupCodeFilterTest.php b/app/code/Magento/Eav/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/AttributeGroupCodeFilterTest.php index 9b83a9be59348..6ac5ff3966334 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/AttributeGroupCodeFilterTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/AttributeGroupCodeFilterTest.php @@ -9,7 +9,7 @@ use Magento\Framework\Api\Filter; use Magento\Framework\Data\Collection\AbstractDb; -class AttributeGroupCodeFilterTest extends \PHPUnit_Framework_TestCase +class AttributeGroupCodeFilterTest extends \PHPUnit\Framework\TestCase { /** * @var AttributeGroupCodeFilter diff --git a/app/code/Magento/Eav/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/AttributeSetEntityTypeCodeFilterTest.php b/app/code/Magento/Eav/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/AttributeSetEntityTypeCodeFilterTest.php index 16b6dd38ca6ef..f9ac95b7c3921 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/AttributeSetEntityTypeCodeFilterTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessor/AttributeSetEntityTypeCodeFilterTest.php @@ -11,7 +11,7 @@ use Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection; use Magento\Framework\Api\Filter; -class AttributeSetEntityTypeCodeFilterTest extends \PHPUnit_Framework_TestCase +class AttributeSetEntityTypeCodeFilterTest extends \PHPUnit\Framework\TestCase { /** * @var AttributeSetEntityTypeCodeFilter diff --git a/app/code/Magento/Eav/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessorTest.php b/app/code/Magento/Eav/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessorTest.php index 4e73257efa038..5103eaed3d72f 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessorTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Api/SearchCriteria/CollectionProcessor/FilterProcessorTest.php @@ -12,7 +12,7 @@ use Magento\Framework\Api\SearchCriteriaInterface; use Magento\Framework\Data\Collection\AbstractDb; -class FilterProcessorTest extends \PHPUnit_Framework_TestCase +class FilterProcessorTest extends \PHPUnit\Framework\TestCase { /** * Return model @@ -32,8 +32,7 @@ private function getModel(array $customFilters, array $fieldMapping) public function testProcess() { /** @var CustomFilterInterface|\PHPUnit_Framework_MockObject_MockObject $customFilterMock */ - $customFilterMock = $this->getMockBuilder(CustomFilterInterface::class) - ->getMock(); + $customFilterMock = $this->createPartialMock(CustomFilterInterface::class, ['apply']); $customFilterField = 'customFilterField'; $customFilters = [$customFilterField => $customFilterMock]; @@ -151,8 +150,7 @@ public function testProcess() public function testProcessWithException() { /** @var \stdClass|\PHPUnit_Framework_MockObject_MockObject $customFilterMock */ - $customFilterMock = $this->getMockBuilder(\stdClass::class) - ->getMock(); + $customFilterMock = $this->createPartialMock(\stdClass::class, ['apply']); $customFilterField = 'customFilterField'; $customFilters = [$customFilterField => $customFilterMock]; diff --git a/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/AbstractDataTest.php b/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/AbstractDataTest.php index eddf95ebdb14c..1c29a70e2da6d 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/AbstractDataTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/AbstractDataTest.php @@ -10,7 +10,7 @@ use Magento\Eav\Model\Attribute\Data\Text; -class AbstractDataTest extends \PHPUnit_Framework_TestCase +class AbstractDataTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Model\Attribute\Data\AbstractData @@ -19,10 +19,10 @@ class AbstractDataTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $timezoneMock = $this->getMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); - $loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class, [], [], '', false); - $localeResolverMock = $this->getMock(\Magento\Framework\Locale\ResolverInterface::class); - $stringMock = $this->getMock(\Magento\Framework\Stdlib\StringUtils::class, [], [], '', false); + $timezoneMock = $this->createMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); + $loggerMock = $this->createMock(\Psr\Log\LoggerInterface::class); + $localeResolverMock = $this->createMock(\Magento\Framework\Locale\ResolverInterface::class); + $stringMock = $this->createMock(\Magento\Framework\Stdlib\StringUtils::class); /* testing abstract model through its child */ $this->model = new Text($timezoneMock, $loggerMock, $localeResolverMock, $stringMock); @@ -34,7 +34,7 @@ protected function setUp() */ public function testGetEntity() { - $entityMock = $this->getMock(\Magento\Framework\Model\AbstractModel::class, [], [], '', false); + $entityMock = $this->createMock(\Magento\Framework\Model\AbstractModel::class); $this->model->setEntity($entityMock); $this->assertEquals($entityMock, $this->model->getEntity()); } @@ -100,26 +100,14 @@ public function extractedDataDataProvider() */ public function testGetRequestValue($requestScope, $value, $params, $requestScopeOnly, $expectedResult, $filter) { - $requestMock = $this->getMock( - \Magento\Framework\App\Request\Http::class, - ['getParams', 'getParam'], - [], - '', - false - ); + $requestMock = $this->createPartialMock(\Magento\Framework\App\Request\Http::class, ['getParams', 'getParam']); $requestMock->expects($this->any())->method('getParam')->will($this->returnValueMap([ ['attributeCode', false, $value], [$requestScope, $value], ])); $requestMock->expects($this->any())->method('getParams')->will($this->returnValue($params)); - $attributeMock = $this->getMock( - \Magento\Eav\Model\Attribute::class, - ['getInputFilter', 'getAttributeCode'], - [], - '', - false - ); + $attributeMock = $this->createPartialMock(\Magento\Eav\Model\Attribute::class, ['getInputFilter', 'getAttributeCode']); $attributeMock->expects($this->any())->method('getAttributeCode')->will($this->returnValue('attributeCode')); if ($filter) { $attributeMock->expects($this->any())->method('getInputFilter')->will($this->returnValue($filter)); diff --git a/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/BooleanTest.php b/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/BooleanTest.php index 97eb9d5e9b71c..b438de306d684 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/BooleanTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/BooleanTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Eav\Test\Unit\Model\Attribute\Data; -class BooleanTest extends \PHPUnit_Framework_TestCase +class BooleanTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Model\Attribute\Data\Boolean @@ -14,9 +14,9 @@ class BooleanTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $timezoneMock = $this->getMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); - $loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class, [], [], '', false); - $localeResolverMock = $this->getMock(\Magento\Framework\Locale\ResolverInterface::class); + $timezoneMock = $this->createMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); + $loggerMock = $this->createMock(\Psr\Log\LoggerInterface::class); + $localeResolverMock = $this->createMock(\Magento\Framework\Locale\ResolverInterface::class); $this->model = new \Magento\Eav\Model\Attribute\Data\Boolean($timezoneMock, $loggerMock, $localeResolverMock); } @@ -31,10 +31,10 @@ protected function setUp() */ public function testOutputValue($format, $value, $expectedResult) { - $entityMock = $this->getMock(\Magento\Framework\Model\AbstractModel::class, [], [], '', false); + $entityMock = $this->createMock(\Magento\Framework\Model\AbstractModel::class); $entityMock->expects($this->once())->method('getData')->will($this->returnValue($value)); - $attributeMock = $this->getMock(\Magento\Eav\Model\Attribute::class, [], [], '', false); + $attributeMock = $this->createMock(\Magento\Eav\Model\Attribute::class); $this->model->setEntity($entityMock); $this->model->setAttribute($attributeMock); diff --git a/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/DateTest.php b/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/DateTest.php index 46176f16b2227..b976efe9867f9 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/DateTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/DateTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Eav\Test\Unit\Model\Attribute\Data; -class DateTest extends \PHPUnit_Framework_TestCase +class DateTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Model\Attribute\Data\Date @@ -19,9 +19,9 @@ class DateTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->timezoneMock = $this->getMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); - $loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class, [], [], '', false); - $localeResolverMock = $this->getMock(\Magento\Framework\Locale\ResolverInterface::class); + $this->timezoneMock = $this->createMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); + $loggerMock = $this->createMock(\Psr\Log\LoggerInterface::class); + $localeResolverMock = $this->createMock(\Magento\Framework\Locale\ResolverInterface::class); $this->model = new \Magento\Eav\Model\Attribute\Data\Date( $this->timezoneMock, @@ -41,16 +41,10 @@ protected function setUp() */ public function testOutputValue($format, $value, $callTimes, $expectedResult) { - $entityMock = $this->getMock(\Magento\Framework\Model\AbstractModel::class, [], [], '', false); + $entityMock = $this->createMock(\Magento\Framework\Model\AbstractModel::class); $entityMock->expects($this->once())->method('getData')->will($this->returnValue($value)); - $attributeMock = $this->getMock( - \Magento\Eav\Model\Attribute::class, - ['getInputFilter', '__wakeup'], - [], - '', - false - ); + $attributeMock = $this->createPartialMock(\Magento\Eav\Model\Attribute::class, ['getInputFilter', '__wakeup']); $attributeMock->expects($this->exactly($callTimes))->method('getInputFilter')->will($this->returnValue(false)); $this->model->setEntity($entityMock); @@ -91,10 +85,10 @@ public function outputValueDataProvider() */ public function testValidateValue($value, $rules, $originalValue, $isRequired, $expectedResult) { - $entityMock = $this->getMock(\Magento\Framework\Model\AbstractModel::class, [], [], '', false); + $entityMock = $this->createMock(\Magento\Framework\Model\AbstractModel::class); $entityMock->expects($this->any())->method('getDataUsingMethod')->will($this->returnValue($originalValue)); - $attributeMock = $this->getMock(\Magento\Eav\Model\Attribute::class, [], [], '', false); + $attributeMock = $this->createMock(\Magento\Eav\Model\Attribute::class); $attributeMock->expects($this->any())->method('getStoreLabel')->will($this->returnValue('Label')); $attributeMock->expects($this->any())->method('getIsRequired')->will($this->returnValue($isRequired)); $attributeMock->expects($this->any())->method('getValidateRules')->will($this->returnValue($rules)); @@ -164,10 +158,10 @@ public function validateValueDataProvider() */ public function testCompactValue($value, $expectedResult) { - $entityMock = $this->getMock(\Magento\Framework\Model\AbstractModel::class, [], [], '', false); + $entityMock = $this->createMock(\Magento\Framework\Model\AbstractModel::class); $entityMock->expects($this->once())->method('setDataUsingMethod')->with('attrCode', $expectedResult); - $attributeMock = $this->getMock(\Magento\Eav\Model\Attribute::class, [], [], '', false); + $attributeMock = $this->createMock(\Magento\Eav\Model\Attribute::class); $attributeMock->expects($this->any())->method('getAttributeCode')->will($this->returnValue('attrCode')); $this->model->setAttribute($attributeMock); @@ -191,7 +185,7 @@ public function compactValueDataProvider() */ public function testCompactValueWithFalseValue() { - $entityMock = $this->getMock(\Magento\Framework\Model\AbstractModel::class, [], [], '', false); + $entityMock = $this->createMock(\Magento\Framework\Model\AbstractModel::class); $entityMock->expects($this->never())->method('setDataUsingMethod'); $this->model->setEntity($entityMock); diff --git a/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/FileTest.php b/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/FileTest.php index 2fdd631f0ec0b..e75c5ef2b1ffa 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/FileTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/FileTest.php @@ -8,7 +8,7 @@ namespace Magento\Eav\Test\Unit\Model\Attribute\Data; -class FileTest extends \PHPUnit_Framework_TestCase +class FileTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Model\Attribute\Data\File @@ -27,14 +27,12 @@ class FileTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $timezoneMock = $this->getMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); - $loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class, [], [], '', false); - $localeResolverMock = $this->getMock(\Magento\Framework\Locale\ResolverInterface::class); - $this->urlEncoder = $this->getMock(\Magento\Framework\Url\EncoderInterface::class, [], [], '', false); - $this->fileValidatorMock = $this->getMock( - \Magento\MediaStorage\Model\File\Validator\NotProtectedExtension::class, ['isValid', 'getMessages'], [], '', false - ); - $filesystemMock = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); + $timezoneMock = $this->createMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); + $loggerMock = $this->createMock(\Psr\Log\LoggerInterface::class); + $localeResolverMock = $this->createMock(\Magento\Framework\Locale\ResolverInterface::class); + $this->urlEncoder = $this->createMock(\Magento\Framework\Url\EncoderInterface::class); + $this->fileValidatorMock = $this->createPartialMock(\Magento\MediaStorage\Model\File\Validator\NotProtectedExtension::class, ['isValid', 'getMessages']); + $filesystemMock = $this->createMock(\Magento\Framework\Filesystem::class); $this->model = new \Magento\Eav\Model\Attribute\Data\File( $timezoneMock, $loggerMock, $localeResolverMock, @@ -53,10 +51,10 @@ protected function setUp() */ public function testOutputValue($format, $value, $callTimes, $expectedResult) { - $entityMock = $this->getMock(\Magento\Framework\Model\AbstractModel::class, [], [], '', false); + $entityMock = $this->createMock(\Magento\Framework\Model\AbstractModel::class); $entityMock->expects($this->once())->method('getData')->will($this->returnValue($value)); - $attributeMock = $this->getMock(\Magento\Eav\Model\Attribute::class, [], [], '', false); + $attributeMock = $this->createMock(\Magento\Eav\Model\Attribute::class); $this->urlEncoder->expects($this->exactly($callTimes)) ->method('encode') ->will($this->returnValue('url_key')); @@ -110,10 +108,10 @@ public function testValidateValue( $value, $originalValue, $isRequired, $isAjaxRequest, $rules, $fileIsValid, $expectedResult ) { $this->markTestSkipped('MAGETWO-34751: Test fails after being moved. Might have hidden dependency.'); - $entityMock = $this->getMock(\Magento\Framework\Model\AbstractModel::class, [], [], '', false); + $entityMock = $this->createMock(\Magento\Framework\Model\AbstractModel::class); $entityMock->expects($this->any())->method('getData')->will($this->returnValue($originalValue)); - $attributeMock = $this->getMock(\Magento\Eav\Model\Attribute::class, [], [], '', false); + $attributeMock = $this->createMock(\Magento\Eav\Model\Attribute::class); $attributeMock->expects($this->any())->method('getStoreLabel')->will($this->returnValue('Label')); $attributeMock->expects($this->any())->method('getIsRequired')->will($this->returnValue($isRequired)); $attributeMock->expects($this->any())->method('getIsAjaxRequest')->will($this->returnValue($isAjaxRequest)); diff --git a/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/ImageTest.php b/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/ImageTest.php index 78b21b720e5eb..83b15718ed389 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/ImageTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/ImageTest.php @@ -8,7 +8,7 @@ namespace Magento\Eav\Test\Unit\Model\Attribute\Data; -class ImageTest extends \PHPUnit_Framework_TestCase +class ImageTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Model\Attribute\Data\File @@ -18,14 +18,12 @@ class ImageTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->markTestSkipped('MAGETWO-34751: Test fails after being moved. Might have hidden dependency.'); - $timezoneMock = $this->getMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); - $loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class, [], [], '', false); - $localeResolverMock = $this->getMock(\Magento\Framework\Locale\ResolverInterface::class); - $urlEncoder = $this->getMock(\Magento\Framework\Url\EncoderInterface::class, [], [], '', false); - $fileValidatorMock = $this->getMock( - \Magento\MediaStorage\Model\File\Validator\NotProtectedExtension::class, [], [], '', false - ); - $filesystemMock = $this->getMock(\Magento\Framework\Filesystem::class, [], [], '', false); + $timezoneMock = $this->createMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); + $loggerMock = $this->createMock(\Psr\Log\LoggerInterface::class); + $localeResolverMock = $this->createMock(\Magento\Framework\Locale\ResolverInterface::class); + $urlEncoder = $this->createMock(\Magento\Framework\Url\EncoderInterface::class); + $fileValidatorMock = $this->createMock(\Magento\MediaStorage\Model\File\Validator\NotProtectedExtension::class); + $filesystemMock = $this->createMock(\Magento\Framework\Filesystem::class); $this->model = new \Magento\Eav\Model\Attribute\Data\Image( $timezoneMock, $loggerMock, $localeResolverMock, $urlEncoder, $fileValidatorMock, $filesystemMock @@ -49,10 +47,10 @@ protected function setUp() public function testValidateValue( $value, $originalValue, $isRequired, $isAjaxRequest, $rules, $expectedResult ) { - $entityMock = $this->getMock(\Magento\Framework\Model\AbstractModel::class, [], [], '', false); + $entityMock = $this->createMock(\Magento\Framework\Model\AbstractModel::class); $entityMock->expects($this->any())->method('getData')->will($this->returnValue($originalValue)); - $attributeMock = $this->getMock(\Magento\Eav\Model\Attribute::class, [], [], '', false); + $attributeMock = $this->createMock(\Magento\Eav\Model\Attribute::class); $attributeMock->expects($this->any())->method('getStoreLabel')->will($this->returnValue('Label')); $attributeMock->expects($this->any())->method('getIsRequired')->will($this->returnValue($isRequired)); $attributeMock->expects($this->any())->method('getIsAjaxRequest')->will($this->returnValue($isAjaxRequest)); diff --git a/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/MultilineTest.php b/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/MultilineTest.php index b03168d5a8f21..f628d52f6647f 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/MultilineTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/MultilineTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Eav\Test\Unit\Model\Attribute\Data; -class MultilineTest extends \PHPUnit_Framework_TestCase +class MultilineTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Model\Attribute\Data\Multiline @@ -19,10 +19,10 @@ class MultilineTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $timezoneMock = $this->getMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); - $loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class, [], [], '', false); - $localeResolverMock = $this->getMock(\Magento\Framework\Locale\ResolverInterface::class); - $this->stringMock = $this->getMock(\Magento\Framework\Stdlib\StringUtils::class, [], [], '', false); + $timezoneMock = $this->createMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); + $loggerMock = $this->createMock(\Psr\Log\LoggerInterface::class); + $localeResolverMock = $this->createMock(\Magento\Framework\Locale\ResolverInterface::class); + $this->stringMock = $this->createMock(\Magento\Framework\Stdlib\StringUtils::class); $this->model = new \Magento\Eav\Model\Attribute\Data\Multiline( $timezoneMock, @@ -41,8 +41,8 @@ protected function setUp() */ public function testExtractValue($param, $expectedResult) { - $requestMock = $this->getMock(\Magento\Framework\App\RequestInterface::class); - $attributeMock = $this->getMock(\Magento\Eav\Model\Attribute::class, [], [], '', false); + $requestMock = $this->createMock(\Magento\Framework\App\RequestInterface::class); + $attributeMock = $this->createMock(\Magento\Eav\Model\Attribute::class); $requestMock->expects($this->once())->method('getParam')->will($this->returnValue($param)); $attributeMock->expects($this->once())->method('getAttributeCode')->will($this->returnValue('attributeCode')); @@ -77,10 +77,10 @@ public function extractValueDataProvider() */ public function testOutputValue($format, $expectedResult) { - $entityMock = $this->getMock(\Magento\Framework\Model\AbstractModel::class, [], [], '', false); + $entityMock = $this->createMock(\Magento\Framework\Model\AbstractModel::class); $entityMock->expects($this->once())->method('getData')->will($this->returnValue("value1\nvalue2")); - $attributeMock = $this->getMock(\Magento\Eav\Model\Attribute::class, [], [], '', false); + $attributeMock = $this->createMock(\Magento\Eav\Model\Attribute::class); $this->model->setEntity($entityMock); $this->model->setAttribute($attributeMock); @@ -124,10 +124,10 @@ public function outputValueDataProvider() */ public function testValidateValue($value, $isAttributeRequired, $rules, $expectedResult) { - $entityMock = $this->getMock(\Magento\Framework\Model\AbstractModel::class, [], [], '', false); + $entityMock = $this->createMock(\Magento\Framework\Model\AbstractModel::class); $entityMock->expects($this->any())->method('getDataUsingMethod')->will($this->returnValue("value1\nvalue2")); - $attributeMock = $this->getMock(\Magento\Eav\Model\Attribute::class, [], [], '', false); + $attributeMock = $this->createMock(\Magento\Eav\Model\Attribute::class); $attributeMock->expects($this->any())->method('getMultilineCount')->will($this->returnValue(2)); $attributeMock->expects($this->any())->method('getValidateRules')->will($this->returnValue($rules)); $attributeMock->expects($this->any())->method('getStoreLabel')->will($this->returnValue('Label')); diff --git a/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/MultiselectTest.php b/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/MultiselectTest.php index 9ba347ee9979f..642f64ab9b9f3 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/MultiselectTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/MultiselectTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Eav\Test\Unit\Model\Attribute\Data; -class MultiselectTest extends \PHPUnit_Framework_TestCase +class MultiselectTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Model\Attribute\Data\Multiselect @@ -14,9 +14,9 @@ class MultiselectTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $timezoneMock = $this->getMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); - $loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class, [], [], '', false); - $localeResolverMock = $this->getMock(\Magento\Framework\Locale\ResolverInterface::class); + $timezoneMock = $this->createMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); + $loggerMock = $this->createMock(\Psr\Log\LoggerInterface::class); + $localeResolverMock = $this->createMock(\Magento\Framework\Locale\ResolverInterface::class); $this->model = new \Magento\Eav\Model\Attribute\Data\Multiselect( $timezoneMock, @@ -34,8 +34,8 @@ protected function setUp() */ public function testExtractValue($param, $expectedResult) { - $requestMock = $this->getMock(\Magento\Framework\App\RequestInterface::class); - $attributeMock = $this->getMock(\Magento\Eav\Model\Attribute::class, [], [], '', false); + $requestMock = $this->createMock(\Magento\Framework\App\RequestInterface::class); + $attributeMock = $this->createMock(\Magento\Eav\Model\Attribute::class); $requestMock->expects($this->once())->method('getParam')->will($this->returnValue($param)); $attributeMock->expects($this->once())->method('getAttributeCode')->will($this->returnValue('attributeCode')); @@ -74,19 +74,13 @@ public function extractValueDataProvider() */ public function testOutputValue($format, $expectedResult) { - $entityMock = $this->getMock(\Magento\Framework\Model\AbstractModel::class, [], [], '', false); + $entityMock = $this->createMock(\Magento\Framework\Model\AbstractModel::class); $entityMock->expects($this->once())->method('getData')->will($this->returnValue('value1,value2,')); - $sourceMock = $this->getMock( - \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource::class, - [], - [], - '', - false - ); + $sourceMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Source\AbstractSource::class); $sourceMock->expects($this->any())->method('getOptionText')->will($this->returnArgument(0)); - $attributeMock = $this->getMock(\Magento\Eav\Model\Attribute::class, [], [], '', false); + $attributeMock = $this->createMock(\Magento\Eav\Model\Attribute::class); $attributeMock->expects($this->any())->method('getSource')->will($this->returnValue($sourceMock)); $this->model->setEntity($entityMock); diff --git a/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/SelectTest.php b/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/SelectTest.php index 7b9b6e4c49b9c..ac71c6db6e304 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/SelectTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/SelectTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Eav\Test\Unit\Model\Attribute\Data; -class SelectTest extends \PHPUnit_Framework_TestCase +class SelectTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Model\Attribute\Data\Select @@ -14,9 +14,9 @@ class SelectTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $timezoneMock = $this->getMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); - $loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class, [], [], '', false); - $localeResolverMock = $this->getMock(\Magento\Framework\Locale\ResolverInterface::class); + $timezoneMock = $this->createMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); + $loggerMock = $this->createMock(\Psr\Log\LoggerInterface::class); + $localeResolverMock = $this->createMock(\Magento\Framework\Locale\ResolverInterface::class); $this->model = new \Magento\Eav\Model\Attribute\Data\Select($timezoneMock, $loggerMock, $localeResolverMock); } @@ -31,19 +31,13 @@ protected function setUp() */ public function testOutputValue($format, $value, $expectedResult) { - $entityMock = $this->getMock(\Magento\Framework\Model\AbstractModel::class, [], [], '', false); + $entityMock = $this->createMock(\Magento\Framework\Model\AbstractModel::class); $entityMock->expects($this->once())->method('getData')->will($this->returnValue($value)); - $sourceMock = $this->getMock( - \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource::class, - [], - [], - '', - false - ); + $sourceMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Source\AbstractSource::class); $sourceMock->expects($this->any())->method('getOptionText')->will($this->returnValue(123)); - $attributeMock = $this->getMock(\Magento\Eav\Model\Attribute::class, [], [], '', false); + $attributeMock = $this->createMock(\Magento\Eav\Model\Attribute::class); $attributeMock->expects($this->any())->method('getSource')->will($this->returnValue($sourceMock)); $this->model->setEntity($entityMock); @@ -86,10 +80,10 @@ public function outputValueDataProvider() */ public function testValidateValue($value, $originalValue, $isRequired, $expectedResult) { - $entityMock = $this->getMock(\Magento\Framework\Model\AbstractModel::class, [], [], '', false); + $entityMock = $this->createMock(\Magento\Framework\Model\AbstractModel::class); $entityMock->expects($this->any())->method('getData')->will($this->returnValue($originalValue)); - $attributeMock = $this->getMock(\Magento\Eav\Model\Attribute::class, [], [], '', false); + $attributeMock = $this->createMock(\Magento\Eav\Model\Attribute::class); $attributeMock->expects($this->any())->method('getStoreLabel')->will($this->returnValue('Label')); $attributeMock->expects($this->any())->method('getIsRequired')->will($this->returnValue($isRequired)); @@ -142,10 +136,10 @@ public function validateValueDataProvider() */ public function testCompactValue() { - $entityMock = $this->getMock(\Magento\Framework\Model\AbstractModel::class, [], [], '', false); + $entityMock = $this->createMock(\Magento\Framework\Model\AbstractModel::class); $entityMock->expects($this->once())->method('setData')->with('attrCode', 'value'); - $attributeMock = $this->getMock(\Magento\Eav\Model\Attribute::class, [], [], '', false); + $attributeMock = $this->createMock(\Magento\Eav\Model\Attribute::class); $attributeMock->expects($this->any())->method('getAttributeCode')->will($this->returnValue('attrCode')); $this->model->setAttribute($attributeMock); @@ -158,7 +152,7 @@ public function testCompactValue() */ public function testCompactValueWithFalseValue() { - $entityMock = $this->getMock(\Magento\Framework\Model\AbstractModel::class, [], [], '', false); + $entityMock = $this->createMock(\Magento\Framework\Model\AbstractModel::class); $entityMock->expects($this->never())->method('setData'); $this->model->setEntity($entityMock); diff --git a/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/TextTest.php b/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/TextTest.php index 0d7d5beeeb9c5..36eac0bfab27b 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/TextTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/TextTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Eav\Test\Unit\Model\Attribute\Data; -class TextTest extends \PHPUnit_Framework_TestCase +class TextTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Model\Attribute\Data\Text @@ -14,24 +14,10 @@ class TextTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $locale = $this->getMock( - \Magento\Framework\Stdlib\DateTime\TimezoneInterface::class, - [], - [], - '', - false, - false - ); - $localeResolver = $this->getMock( - \Magento\Framework\Locale\ResolverInterface::class, - [], - [], - '', - false, - false - ); - $logger = $this->getMock(\Psr\Log\LoggerInterface::class); - $helper = $this->getMock(\Magento\Framework\Stdlib\StringUtils::class, [], [], '', false, false); + $locale = $this->createMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); + $localeResolver = $this->createMock(\Magento\Framework\Locale\ResolverInterface::class); + $logger = $this->createMock(\Psr\Log\LoggerInterface::class); + $helper = $this->createMock(\Magento\Framework\Stdlib\StringUtils::class); $attributeData = [ 'store_label' => 'Test', @@ -42,7 +28,7 @@ protected function setUp() $attributeClass = \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class; $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $eavTypeFactory = $this->getMock(\Magento\Eav\Model\Entity\TypeFactory::class, [], [], '', false, false); + $eavTypeFactory = $this->createMock(\Magento\Eav\Model\Entity\TypeFactory::class); $arguments = $objectManagerHelper->getConstructArguments( $attributeClass, ['eavTypeFactory' => $eavTypeFactory, 'data' => $attributeData] @@ -51,7 +37,10 @@ protected function setUp() /** @var $attribute \Magento\Eav\Model\Entity\Attribute\AbstractAttribute| * \PHPUnit_Framework_MockObject_MockObject */ - $attribute = $this->getMock($attributeClass, ['_init'], $arguments); + $attribute = $this->getMockBuilder($attributeClass) + ->setMethods(['_init']) + ->setConstructorArgs($arguments) + ->getMock(); $this->_model = new \Magento\Eav\Model\Attribute\Data\Text($locale, $logger, $localeResolver, $helper); $this->_model->setAttribute($attribute); } diff --git a/app/code/Magento/Eav/Test/Unit/Model/Attribute/GroupRepositoryTest.php b/app/code/Magento/Eav/Test/Unit/Model/Attribute/GroupRepositoryTest.php index 498c77d481cd7..c07122e049a74 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Attribute/GroupRepositoryTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Attribute/GroupRepositoryTest.php @@ -10,7 +10,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class GroupRepositoryTest extends \PHPUnit_Framework_TestCase +class GroupRepositoryTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Model\Attribute\GroupRepository @@ -54,34 +54,22 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->groupResourceMock = $this->getMock( + $this->groupResourceMock = $this->createPartialMock( \Magento\Eav\Model\ResourceModel\Entity\Attribute\Group::class, - ['delete', '__wakeup', 'load', 'save'], - [], - '', - false + ['delete', '__wakeup', 'load', 'save'] ); - $this->groupFactoryMock = $this->getMock( + $this->groupFactoryMock = $this->createPartialMock( \Magento\Eav\Model\Entity\Attribute\GroupFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->setRepositoryMock = $this->getMock(\Magento\Eav\Api\AttributeSetRepositoryInterface::class); - $this->searchResultsFactoryMock = $this->getMock( + $this->setRepositoryMock = $this->createMock(\Magento\Eav\Api\AttributeSetRepositoryInterface::class); + $this->searchResultsFactoryMock = $this->createPartialMock( \Magento\Eav\Api\Data\AttributeGroupSearchResultsInterfaceFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->groupListFactoryMock = $this->getMock( + $this->groupListFactoryMock = $this->createPartialMock( \Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\CollectionFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->collectionProcessor = $this->getMockBuilder(CollectionProcessorInterface::class) @@ -111,8 +99,8 @@ protected function setUp() public function testSaveIfObjectNew() { $attributeSetId = 42; - $groupMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute\Group::class, [], [], '', false); - $attributeSetMock = $this->getMock(\Magento\Eav\Api\Data\AttributeSetInterface::class); + $groupMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Group::class); + $attributeSetMock = $this->createMock(\Magento\Eav\Api\Data\AttributeSetInterface::class); $groupMock->expects($this->once())->method('getAttributeSetId')->willReturn($attributeSetId); @@ -137,9 +125,9 @@ public function testSaveIfObjectNotNew() { $attributeSetId = 42; $groupId = 20; - $groupMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute\Group::class, [], [], '', false); - $existingGroupMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute\Group::class, [], [], '', false); - $attributeSetMock = $this->getMock(\Magento\Eav\Api\Data\AttributeSetInterface::class); + $groupMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Group::class); + $existingGroupMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Group::class); + $attributeSetMock = $this->createMock(\Magento\Eav\Api\Data\AttributeSetInterface::class); $groupMock->expects($this->exactly(2))->method('getAttributeSetId')->willReturn($attributeSetId); $groupMock->expects($this->exactly(2))->method('getAttributeGroupId')->willReturn($groupId); @@ -171,13 +159,7 @@ public function testSaveIfObjectNotNew() public function testSaveThrowExceptionIfAttributeSetDoesNotExist() { $attributeSetId = -1; - $groupMock = $this->getMock( - \Magento\Eav\Model\Entity\Attribute\Group::class, - ['getAttributeSetId'], - [], - '', - false - ); + $groupMock = $this->createPartialMock(\Magento\Eav\Model\Entity\Attribute\Group::class, ['getAttributeSetId']); $groupMock->expects($this->exactly(2))->method('getAttributeSetId')->willReturn($attributeSetId); $this->setRepositoryMock->expects($this->once()) ->method('get') @@ -203,9 +185,9 @@ public function testSaveThrowExceptionIfCannotSaveGroup() { $attributeSetId = 42; $groupId = 20; - $groupMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute\Group::class, [], [], '', false); - $existingGroupMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute\Group::class, [], [], '', false); - $attributeSetMock = $this->getMock(\Magento\Eav\Api\Data\AttributeSetInterface::class); + $groupMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Group::class); + $existingGroupMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Group::class); + $attributeSetMock = $this->createMock(\Magento\Eav\Api\Data\AttributeSetInterface::class); $groupMock->expects($this->any())->method('getAttributeSetId')->willReturn($attributeSetId); $groupMock->expects($this->any())->method('getAttributeGroupId')->willReturn($groupId); $attributeSetMock->expects($this->any())->method('getAttributeSetId')->willReturn(10); @@ -234,9 +216,9 @@ public function testSaveThrowExceptionIfGroupDoesNotBelongToProvidedSet() { $attributeSetId = 42; $groupId = 20; - $groupMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute\Group::class, [], [], '', false); - $existingGroupMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute\Group::class, [], [], '', false); - $attributeSetMock = $this->getMock(\Magento\Eav\Api\Data\AttributeSetInterface::class); + $groupMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Group::class); + $existingGroupMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Group::class); + $attributeSetMock = $this->createMock(\Magento\Eav\Api\Data\AttributeSetInterface::class); $groupMock->expects($this->any())->method('getAttributeSetId')->willReturn($attributeSetId); $groupMock->expects($this->any())->method('getAttributeGroupId')->willReturn($groupId); $attributeSetMock->expects($this->any())->method('getAttributeSetId')->willReturn(10); @@ -261,9 +243,9 @@ public function testSaveThrowExceptionIfProvidedGroupDoesNotExist() { $attributeSetId = 42; $groupId = 20; - $groupMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute\Group::class, [], [], '', false); - $existingGroupMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute\Group::class, [], [], '', false); - $attributeSetMock = $this->getMock(\Magento\Eav\Api\Data\AttributeSetInterface::class); + $groupMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Group::class); + $existingGroupMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Group::class); + $attributeSetMock = $this->createMock(\Magento\Eav\Api\Data\AttributeSetInterface::class); $groupMock->expects($this->any())->method('getAttributeSetId')->willReturn($attributeSetId); $groupMock->expects($this->any())->method('getAttributeGroupId')->willReturn($groupId); $attributeSetMock->expects($this->any())->method('getAttributeSetId')->willReturn(10); @@ -318,12 +300,9 @@ public function testGetList() ->disableOriginalConstructor() ->getMock(); - $groupCollectionMock = $this->getMock( + $groupCollectionMock = $this->createPartialMock( \Magento\Eav\Model\Entity\Collection\AbstractCollection::class, - ['getItems', 'getSize'], - [], - '', - false + ['getItems', 'getSize'] ); $groupCollectionMock->expects($this->once())->method('getItems')->willReturn([$groupMock]); @@ -331,13 +310,7 @@ public function testGetList() $groupCollectionMock->expects($this->once())->method('getSize')->willReturn(1); - $searchResultsMock = $this->getMock( - \Magento\Eav\Api\Data\AttributeGroupSearchResultsInterface::class, - [], - [], - '', - false - ); + $searchResultsMock = $this->createMock(\Magento\Eav\Api\Data\AttributeGroupSearchResultsInterface::class); $searchResultsMock->expects($this->once())->method('setSearchCriteria')->with($searchCriteriaMock); $searchResultsMock->expects($this->once())->method('setItems')->with([$groupMock]); $searchResultsMock->expects($this->once())->method('setTotalCount')->with(1); @@ -362,7 +335,7 @@ public function testGetList() */ public function testGetListWithInvalidInputException() { - $searchCriteriaMock = $this->getMock(\Magento\Framework\Api\SearchCriteriaInterface::class); + $searchCriteriaMock = $this->createMock(\Magento\Framework\Api\SearchCriteriaInterface::class); $searchCriteriaMock->expects($this->once())->method('getFilterGroups')->willReturn([]); $this->model->getList($searchCriteriaMock); } @@ -379,9 +352,9 @@ public function testGetListWithInvalidInputException() public function testGetListWithNoSuchEntityException() { $attributeSetId = 'filter'; - $searchCriteriaMock = $this->getMock(\Magento\Framework\Api\SearchCriteriaInterface::class); - $filterGroupMock = $this->getMock(\Magento\Framework\Api\Search\FilterGroup::class, [], [], '', false); - $filterInterfaceMock = $this->getMock(\Magento\Framework\Api\Filter::class, [], [], '', false); + $searchCriteriaMock = $this->createMock(\Magento\Framework\Api\SearchCriteriaInterface::class); + $filterGroupMock = $this->createMock(\Magento\Framework\Api\Search\FilterGroup::class); + $filterInterfaceMock = $this->createMock(\Magento\Framework\Api\Filter::class); $searchCriteriaMock->expects($this->once())->method('getFilterGroups')->willReturn([$filterGroupMock]); @@ -406,7 +379,7 @@ public function testGetListWithNoSuchEntityException() public function testGet() { $groupId = 42; - $groupMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute\Group::class, [], [], '', false); + $groupMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Group::class); $this->groupFactoryMock->expects($this->once())->method('create')->willReturn($groupMock); $this->groupResourceMock->expects($this->once())->method('load')->with($groupMock, $groupId); $groupMock->expects($this->once())->method('getId')->willReturn($groupId); @@ -424,7 +397,7 @@ public function testGet() public function testGetThrowExceptionIfProvidedGroupDoesNotExist() { $groupId = 42; - $groupMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute\Group::class, [], [], '', false); + $groupMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Group::class); $this->groupFactoryMock->expects($this->once())->method('create')->willReturn($groupMock); $this->groupResourceMock->expects($this->once())->method('load')->with($groupMock, $groupId); $groupMock->expects($this->once())->method('getId')->willReturn(false); @@ -439,7 +412,7 @@ public function testGetThrowExceptionIfProvidedGroupDoesNotExist() */ public function testDelete() { - $groupMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute\Group::class, [], [], '', false); + $groupMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Group::class); $this->groupResourceMock->expects($this->once())->method('delete')->with($groupMock); $this->assertTrue($this->model->delete($groupMock)); } @@ -454,7 +427,7 @@ public function testDelete() */ public function testDeleteThrowExceptionIfProvidedGroupDoesNotExist() { - $groupMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute\Group::class, [], [], '', false); + $groupMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Group::class); $this->groupResourceMock->expects($this->once()) ->method('delete') ->with($groupMock) @@ -471,12 +444,12 @@ public function testDeleteThrowExceptionIfProvidedGroupDoesNotExist() public function testDeleteById() { $groupId = 42; - $groupMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute\Group::class, [], [], '', false); + $groupMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Group::class); $this->groupFactoryMock->expects($this->once())->method('create')->willReturn($groupMock); $this->groupResourceMock->expects($this->once())->method('load')->with($groupMock, $groupId); $groupMock->expects($this->once())->method('getId')->willReturn($groupId); - $groupMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute\Group::class, [], [], '', false); + $groupMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Group::class); $this->groupResourceMock->expects($this->once())->method('delete')->with($groupMock); $this->assertTrue($this->model->deleteById($groupId)); diff --git a/app/code/Magento/Eav/Test/Unit/Model/AttributeFactoryTest.php b/app/code/Magento/Eav/Test/Unit/Model/AttributeFactoryTest.php index 0748eeffacdab..572e7192d810e 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/AttributeFactoryTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/AttributeFactoryTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Eav\Test\Unit\Model; -class AttributeFactoryTest extends \PHPUnit_Framework_TestCase +class AttributeFactoryTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Model\AttributeFactory @@ -25,7 +25,7 @@ class AttributeFactoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { /** @var $objectManagerMock \Magento\Framework\ObjectManagerInterface */ - $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); + $objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); $objectManagerMock->expects( $this->any() )->method( diff --git a/app/code/Magento/Eav/Test/Unit/Model/AttributeManagementTest.php b/app/code/Magento/Eav/Test/Unit/Model/AttributeManagementTest.php index fa635bb0d1d8c..62fae4f5eb568 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/AttributeManagementTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/AttributeManagementTest.php @@ -20,7 +20,7 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @codingStandardsIgnoreFile */ -class AttributeManagementTest extends \PHPUnit_Framework_TestCase +class AttributeManagementTest extends \PHPUnit\Framework\TestCase { /** * @var AttributeManagement @@ -70,19 +70,19 @@ class AttributeManagementTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->setRepositoryMock = - $this->getMock(AttributeSetRepositoryInterface::class, [], [], '', false); + $this->createMock(AttributeSetRepositoryInterface::class); $this->attributeCollectionMock = - $this->getMock(Collection::class, [], [], '', false); + $this->createMock(Collection::class); $this->eavConfigMock = - $this->getMock(Config::class, [], [], '', false); + $this->createMock(Config::class); $this->entityTypeFactoryMock = - $this->getMock(ConfigFactory::class, ['create', '__wakeup'], [], '', false); + $this->createPartialMock(ConfigFactory::class, ['create', '__wakeup']); $this->groupRepositoryMock = - $this->getMock(AttributeGroupRepositoryInterface::class, [], [], '', false); + $this->createMock(AttributeGroupRepositoryInterface::class); $this->attributeRepositoryMock = - $this->getMock(AttributeRepositoryInterface::class, [], [], '', false); + $this->createMock(AttributeRepositoryInterface::class); $this->attributeResourceMock = - $this->getMock(Attribute::class, [], [], '', false); + $this->createMock(Attribute::class); $this->attributeCollectionFactoryMock = $this->getMockBuilder(CollectionFactory::class) ->disableOriginalConstructor() ->getMock(); @@ -132,14 +132,14 @@ public function testAssignInputException() $attributeGroupId = 3; $attributeCode = 4; $sortOrder = 5; - $attributeSetMock = $this->getMock(\Magento\Eav\Api\Data\AttributeSetInterface::class, [], [], '', false); + $attributeSetMock = $this->createMock(\Magento\Eav\Api\Data\AttributeSetInterface::class); $this->setRepositoryMock->expects($this->once()) ->method('get') ->with($attributeSetId) ->willReturn($attributeSetMock); $this->entityTypeFactoryMock->expects($this->once())->method('create')->willReturn($this->eavConfigMock); $attributeSetMock->expects($this->once())->method('getEntityTypeId')->willReturn(66); - $entityTypeMock = $this->getMock(\Magento\Eav\Model\Entity\Type::class, [], [], '', false); + $entityTypeMock = $this->createMock(\Magento\Eav\Model\Entity\Type::class); $this->eavConfigMock->expects($this->once())->method('getEntityType')->with(66)->willReturn($entityTypeMock); $entityTypeMock->expects($this->once())->method('getEntityTypeCode')->willReturn($entityTypeCode+1); @@ -158,14 +158,14 @@ public function testAssignInputExceptionGroupInSet() $attributeGroupId = 3; $attributeCode = 4; $sortOrder = 5; - $attributeSetMock = $this->getMock(\Magento\Eav\Api\Data\AttributeSetInterface::class, [], [], '', false); + $attributeSetMock = $this->createMock(\Magento\Eav\Api\Data\AttributeSetInterface::class); $this->setRepositoryMock->expects($this->once()) ->method('get') ->with($attributeSetId) ->willReturn($attributeSetMock); $this->entityTypeFactoryMock->expects($this->once())->method('create')->willReturn($this->eavConfigMock); $attributeSetMock->expects($this->once())->method('getEntityTypeId')->willReturn(66); - $entityTypeMock = $this->getMock(\Magento\Eav\Model\Entity\Type::class, [], [], '', false); + $entityTypeMock = $this->createMock(\Magento\Eav\Model\Entity\Type::class); $this->eavConfigMock->expects($this->once())->method('getEntityType')->with(66)->willReturn($entityTypeMock); $entityTypeMock->expects($this->once())->method('getEntityTypeCode')->willReturn($entityTypeCode); @@ -187,17 +187,17 @@ public function testAssign() $attributeGroupId = 3; $attributeCode = 4; $sortOrder = 5; - $attributeSetMock = $this->getMock(\Magento\Eav\Api\Data\AttributeSetInterface::class, [], [], '', false); + $attributeSetMock = $this->createMock(\Magento\Eav\Api\Data\AttributeSetInterface::class); $this->setRepositoryMock->expects($this->once()) ->method('get') ->with($attributeSetId) ->willReturn($attributeSetMock); $this->entityTypeFactoryMock->expects($this->once())->method('create')->willReturn($this->eavConfigMock); $attributeSetMock->expects($this->once())->method('getEntityTypeId')->willReturn(66); - $entityTypeMock = $this->getMock(\Magento\Eav\Model\Entity\Type::class, [], [], '', false); + $entityTypeMock = $this->createMock(\Magento\Eav\Model\Entity\Type::class); $this->eavConfigMock->expects($this->once())->method('getEntityType')->with(66)->willReturn($entityTypeMock); $entityTypeMock->expects($this->once())->method('getEntityTypeCode')->willReturn($entityTypeCode); - $attributeMock = $this->getMock(\Magento\Eav\Model\Attribute::class, [], [], '', false); + $attributeMock = $this->createMock(\Magento\Eav\Model\Attribute::class); $this->attributeRepositoryMock->expects($this->once()) ->method('get') ->with($entityTypeCode, $attributeCode) @@ -235,16 +235,16 @@ public function testUnassign() $attributeSetId = 1; $attributeCode = 'code'; - $attributeSetMock = $this->getMock(\Magento\Eav\Api\Data\AttributeSetInterface::class, [], [], '', false); + $attributeSetMock = $this->createMock(\Magento\Eav\Api\Data\AttributeSetInterface::class); $this->setRepositoryMock->expects($this->once()) ->method('get') ->with($attributeSetId) ->willReturn($attributeSetMock); $this->entityTypeFactoryMock->expects($this->once())->method('create')->willReturn($this->eavConfigMock); $attributeSetMock->expects($this->once())->method('getEntityTypeId')->willReturn(66); - $entityTypeMock = $this->getMock(\Magento\Eav\Model\Entity\Type::class, [], [], '', false); + $entityTypeMock = $this->createMock(\Magento\Eav\Model\Entity\Type::class); $this->eavConfigMock->expects($this->once())->method('getEntityType')->with(66)->willReturn($entityTypeMock); - $attributeMock = $this->getMock( + $attributeMock = $this->createPartialMock( \Magento\Eav\Model\Entity\Attribute::class, [ 'getEntityAttributeId', @@ -253,10 +253,8 @@ public function testUnassign() 'getIsUserDefined', 'deleteEntity', '__wakeup' - ], - [], - '', - false); + ] + ); $entityTypeMock->expects($this->once())->method('getEntityTypeCode')->willReturn('entity type code'); $this->attributeRepositoryMock->expects($this->once()) ->method('get') @@ -281,16 +279,16 @@ public function testUnassignInputException() $attributeSetId = 1; $attributeCode = 'code'; - $attributeSetMock = $this->getMock(\Magento\Eav\Api\Data\AttributeSetInterface::class, [], [], '', false); + $attributeSetMock = $this->createMock(\Magento\Eav\Api\Data\AttributeSetInterface::class); $this->setRepositoryMock->expects($this->once()) ->method('get') ->with($attributeSetId) ->willReturn($attributeSetMock); $this->entityTypeFactoryMock->expects($this->once())->method('create')->willReturn($this->eavConfigMock); $attributeSetMock->expects($this->once())->method('getEntityTypeId')->willReturn(66); - $entityTypeMock = $this->getMock(\Magento\Eav\Model\Entity\Type::class, [], [], '', false); + $entityTypeMock = $this->createMock(\Magento\Eav\Model\Entity\Type::class); $this->eavConfigMock->expects($this->once())->method('getEntityType')->with(66)->willReturn($entityTypeMock); - $attributeMock = $this->getMock( + $attributeMock = $this->createPartialMock( \Magento\Eav\Model\Entity\Attribute::class, [ 'getEntityAttributeId', @@ -299,10 +297,8 @@ public function testUnassignInputException() 'getIsUserDefined', 'deleteEntity', '__wakeup' - ], - [], - '', - false); + ] + ); $entityTypeMock->expects($this->once())->method('getEntityTypeCode')->willReturn('entity type code'); $this->attributeRepositoryMock->expects($this->once()) ->method('get') @@ -344,16 +340,16 @@ public function testUnassignStateException() $attributeSetId = 1; $attributeCode = 'code'; - $attributeSetMock = $this->getMock(\Magento\Eav\Api\Data\AttributeSetInterface::class, [], [], '', false); + $attributeSetMock = $this->createMock(\Magento\Eav\Api\Data\AttributeSetInterface::class); $this->setRepositoryMock->expects($this->once()) ->method('get') ->with($attributeSetId) ->willReturn($attributeSetMock); $this->entityTypeFactoryMock->expects($this->once())->method('create')->willReturn($this->eavConfigMock); $attributeSetMock->expects($this->once())->method('getEntityTypeId')->willReturn(66); - $entityTypeMock = $this->getMock(\Magento\Eav\Model\Entity\Type::class, [], [], '', false); + $entityTypeMock = $this->createMock(\Magento\Eav\Model\Entity\Type::class); $this->eavConfigMock->expects($this->once())->method('getEntityType')->with(66)->willReturn($entityTypeMock); - $attributeMock = $this->getMock( + $attributeMock = $this->createPartialMock( \Magento\Eav\Model\Entity\Attribute::class, [ 'getEntityAttributeId', @@ -362,10 +358,8 @@ public function testUnassignStateException() 'getIsUserDefined', 'deleteEntity', '__wakeup' - ], - [], - '', - false); + ] + ); $entityTypeMock->expects($this->once())->method('getEntityTypeCode')->willReturn('entity type code'); $this->attributeRepositoryMock->expects($this->once()) ->method('get') @@ -386,12 +380,9 @@ public function testGetAttributes() $entityType = 'type'; $attributeSetId = 148; - $attributeCollectionFactoryMock = $this->getMock( + $attributeCollectionFactoryMock = $this->createPartialMock( \Magento\Eav\Model\ResourceModel\Entity\Attribute\CollectionFactory::class, - ['create'], - [], - '', - false + ['create'] ); $attributeCollectionFactoryMock->expects($this->once()) ->method('create') @@ -404,12 +395,12 @@ public function testGetAttributes() $attributeCollectionFactoryMock ); - $attributeSetMock = $this->getMock(\Magento\Eav\Api\Data\AttributeSetInterface::class, [], [], '', false); + $attributeSetMock = $this->createMock(\Magento\Eav\Api\Data\AttributeSetInterface::class); $this->setRepositoryMock->expects($this->once()) ->method('get') ->with($attributeSetId) ->willReturn($attributeSetMock); - $entityTypeMock = $this->getMock(\Magento\Eav\Model\Entity\Type::class, [], [], '', false); + $entityTypeMock = $this->createMock(\Magento\Eav\Model\Entity\Type::class); $this->eavConfigMock->expects($this->once()) ->method('getEntityType') ->with($entityType) @@ -421,7 +412,7 @@ public function testGetAttributes() ->method('setAttributeSetFilter') ->with(88) ->willReturnSelf(); - $attributeMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute::class, [], [], '', false); + $attributeMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute::class); $this->attributeCollectionMock->expects($this->once())->method('load')->willReturnSelf(); $this->attributeCollectionMock->expects($this->once())->method('getItems')->willReturn([$attributeMock]); @@ -437,12 +428,12 @@ public function testGetAttributesNoSuchEntityException() $entityType = 'type'; $attributeSetId = 148; - $attributeSetMock = $this->getMock(\Magento\Eav\Api\Data\AttributeSetInterface::class, [], [], '', false); + $attributeSetMock = $this->createMock(\Magento\Eav\Api\Data\AttributeSetInterface::class); $this->setRepositoryMock->expects($this->once()) ->method('get') ->with($attributeSetId) ->willReturn($attributeSetMock); - $entityTypeMock = $this->getMock(\Magento\Eav\Model\Entity\Type::class, [], [], '', false); + $entityTypeMock = $this->createMock(\Magento\Eav\Model\Entity\Type::class); $this->eavConfigMock->expects($this->once()) ->method('getEntityType') ->with($entityType) diff --git a/app/code/Magento/Eav/Test/Unit/Model/AttributeRepositoryTest.php b/app/code/Magento/Eav/Test/Unit/Model/AttributeRepositoryTest.php index c11abfa2188f2..c225941c9eb35 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/AttributeRepositoryTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/AttributeRepositoryTest.php @@ -15,7 +15,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class AttributeRepositoryTest extends \PHPUnit_Framework_TestCase +class AttributeRepositoryTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Model\Config|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Eav/Test/Unit/Model/AttributeSetManagementTest.php b/app/code/Magento/Eav/Test/Unit/Model/AttributeSetManagementTest.php index 7a7b33bff2587..b6130ca14f1d3 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/AttributeSetManagementTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/AttributeSetManagementTest.php @@ -7,7 +7,7 @@ use Magento\Eav\Model\AttributeSetManagement; -class AttributeSetManagementTest extends \PHPUnit_Framework_TestCase +class AttributeSetManagementTest extends \PHPUnit\Framework\TestCase { /** * @var AttributeSetManagement @@ -26,8 +26,8 @@ class AttributeSetManagementTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->repositoryMock = $this->getMock(\Magento\Eav\Api\AttributeSetRepositoryInterface::class); - $this->eavConfigMock = $this->getMock(\Magento\Eav\Model\Config::class, ['getEntityType'], [], '', false); + $this->repositoryMock = $this->createMock(\Magento\Eav\Api\AttributeSetRepositoryInterface::class); + $this->eavConfigMock = $this->createPartialMock(\Magento\Eav\Model\Config::class, ['getEntityType']); $this->model = new \Magento\Eav\Model\AttributeSetManagement( $this->eavConfigMock, @@ -40,18 +40,15 @@ public function testCreate() $skeletonId = 1; $entityTypeCode = 'catalog_product'; $entityTypeId = 4; - $entityTypeMock = $this->getMock(\Magento\Eav\Model\Entity\Type::class, [], [], '', false); + $entityTypeMock = $this->createMock(\Magento\Eav\Model\Entity\Type::class); $entityTypeMock->expects($this->any())->method('getId')->will($this->returnValue($entityTypeId)); $this->eavConfigMock->expects($this->once()) ->method('getEntityType') ->with($entityTypeCode) ->will($this->returnValue($entityTypeMock)); - $attributeSetMock = $this->getMock( + $attributeSetMock = $this->createPartialMock( \Magento\Eav\Model\Entity\Attribute\Set::class, - ['validate', 'getId', 'setEntityTypeId', 'initFromSkeleton'], - [], - '', - false + ['validate', 'getId', 'setEntityTypeId', 'initFromSkeleton'] ); $attributeSetMock->expects($this->once())->method('validate'); $attributeSetMock->expects($this->once())->method('setEntityTypeId')->with($entityTypeId); @@ -71,12 +68,9 @@ public function testCreateThrowsExceptionIfGivenAttributeSetAlreadyHasId() { $skeletonId = 1; $entityTypeCode = 'catalog_product'; - $attributeSetMock = $this->getMock( + $attributeSetMock = $this->createPartialMock( \Magento\Eav\Model\Entity\Attribute\Set::class, - ['validate', 'getId', 'setEntityTypeId', 'initFromSkeleton'], - [], - '', - false + ['validate', 'getId', 'setEntityTypeId', 'initFromSkeleton'] ); $attributeSetMock->expects($this->any())->method('getId')->will($this->returnValue(1)); $this->repositoryMock->expects($this->never())->method('save')->with($attributeSetMock); @@ -92,12 +86,9 @@ public function testCreateThrowsExceptionIfGivenSkeletonIdIsInvalid() { $skeletonId = 0; $entityTypeCode = 'catalog_product'; - $attributeSetMock = $this->getMock( + $attributeSetMock = $this->createPartialMock( \Magento\Eav\Model\Entity\Attribute\Set::class, - ['validate', 'getId', 'setEntityTypeId', 'initFromSkeleton'], - [], - '', - false + ['validate', 'getId', 'setEntityTypeId', 'initFromSkeleton'] ); $this->repositoryMock->expects($this->never())->method('save')->with($attributeSetMock); $attributeSetMock->expects($this->never())->method('initFromSkeleton')->with($skeletonId); @@ -113,15 +104,12 @@ public function testCreateThrowsExceptionIfAttributeSetNotValid() $entityTypeId = 4; $skeletonId = 5; $entityTypeCode = 'catalog_product'; - $attributeSetMock = $this->getMock( + $attributeSetMock = $this->createPartialMock( \Magento\Eav\Model\Entity\Attribute\Set::class, - ['validate', 'getId', 'setEntityTypeId', 'initFromSkeleton'], - [], - '', - false + ['validate', 'getId', 'setEntityTypeId', 'initFromSkeleton'] ); - $entityTypeMock = $this->getMock(\Magento\Eav\Model\Entity\Type::class, [], [], '', false); + $entityTypeMock = $this->createMock(\Magento\Eav\Model\Entity\Type::class); $entityTypeMock->expects($this->any())->method('getId')->will($this->returnValue($entityTypeId)); $this->eavConfigMock->expects($this->once()) ->method('getEntityType') diff --git a/app/code/Magento/Eav/Test/Unit/Model/AttributeSetRepositoryTest.php b/app/code/Magento/Eav/Test/Unit/Model/AttributeSetRepositoryTest.php index 3322036fcc372..b7724c9cf349d 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/AttributeSetRepositoryTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/AttributeSetRepositoryTest.php @@ -12,7 +12,7 @@ * @SuppressWarnings(PHPMD.LongVariable) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class AttributeSetRepositoryTest extends \PHPUnit_Framework_TestCase +class AttributeSetRepositoryTest extends \PHPUnit\Framework\TestCase { /** * @var AttributeSetRepository @@ -59,41 +59,23 @@ class AttributeSetRepositoryTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->resourceMock = $this->getMock( - \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set::class, - [], - [], - '', - false - ); - $this->setFactoryMock = $this->getMock( + $this->resourceMock = $this->createMock(\Magento\Eav\Model\ResourceModel\Entity\Attribute\Set::class); + $this->setFactoryMock = $this->createPartialMock( \Magento\Eav\Model\Entity\Attribute\SetFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->collectionFactoryMock = $this->getMock( + $this->collectionFactoryMock = $this->createPartialMock( \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->eavConfigMock = $this->getMock(\Magento\Eav\Model\Config::class, ['getEntityType'], [], '', false); - $this->resultFactoryMock = $this->getMock( + $this->eavConfigMock = $this->createPartialMock(\Magento\Eav\Model\Config::class, ['getEntityType']); + $this->resultFactoryMock = $this->createPartialMock( \Magento\Eav\Api\Data\AttributeSetSearchResultsInterfaceFactory::class, - ['create'], - [], - '', - false + ['create'] ); - $this->extensionAttributesJoinProcessorMock = $this->getMock( + $this->extensionAttributesJoinProcessorMock = $this->createPartialMock( \Magento\Framework\Api\ExtensionAttribute\JoinProcessor::class, - ['process'], - [], - '', - false + ['process'] ); $this->collectionProcessor = $this->getMockBuilder(CollectionProcessorInterface::class) @@ -116,7 +98,7 @@ protected function setUp() public function testGet() { $attributeSetId = 1; - $attributeSetMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute\Set::class, [], [], '', false); + $attributeSetMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Set::class); $this->setFactoryMock->expects($this->once())->method('create')->will($this->returnValue($attributeSetMock)); $this->resourceMock->expects($this->once())->method('load')->with($attributeSetMock, $attributeSetId, null); $attributeSetMock->expects($this->any())->method('getId')->will($this->returnValue($attributeSetId)); @@ -131,7 +113,7 @@ public function testGet() public function testGetThrowsExceptionIfRequestedAttributeSetDoesNotExist() { $attributeSetId = 9999; - $attributeSetMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute\Set::class, [], [], '', false); + $attributeSetMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Set::class); $this->setFactoryMock->expects($this->once())->method('create')->will($this->returnValue($attributeSetMock)); $this->resourceMock->expects($this->once())->method('load')->with($attributeSetMock, $attributeSetId, null); $this->model->get($attributeSetId); @@ -142,7 +124,7 @@ public function testGetThrowsExceptionIfRequestedAttributeSetDoesNotExist() */ public function testSave() { - $attributeSetMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute\Set::class, [], [], '', false); + $attributeSetMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Set::class); $this->resourceMock->expects($this->once())->method('save')->with($attributeSetMock); $this->assertEquals($attributeSetMock, $this->model->save($attributeSetMock)); } @@ -154,7 +136,7 @@ public function testSave() */ public function testSaveThrowsExceptionIfGivenEntityCannotBeSaved() { - $attributeSetMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute\Set::class, [], [], '', false); + $attributeSetMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Set::class); $this->resourceMock->expects($this->once())->method('save')->with($attributeSetMock)->willThrowException( new \Exception('Some internal exception message.') ); @@ -166,7 +148,7 @@ public function testSaveThrowsExceptionIfGivenEntityCannotBeSaved() */ public function testDelete() { - $attributeSetMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute\Set::class, [], [], '', false); + $attributeSetMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Set::class); $this->resourceMock->expects($this->once())->method('delete')->with($attributeSetMock); $this->assertTrue($this->model->delete($attributeSetMock)); } @@ -178,7 +160,7 @@ public function testDelete() */ public function testDeleteThrowsExceptionIfGivenEntityCannotBeDeleted() { - $attributeSetMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute\Set::class, [], [], '', false); + $attributeSetMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Set::class); $this->resourceMock->expects($this->once())->method('delete')->with($attributeSetMock)->willThrowException( new \Magento\Framework\Exception\CouldNotDeleteException(__('Some internal exception message.')) ); @@ -192,7 +174,7 @@ public function testDeleteThrowsExceptionIfGivenEntityCannotBeDeleted() */ public function testDeleteThrowsExceptionIfGivenAttributeSetIsDefault() { - $attributeSetMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute\Set::class, [], [], '', false); + $attributeSetMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Set::class); $this->resourceMock->expects($this->once())->method('delete')->with($attributeSetMock)->willThrowException( new \Magento\Framework\Exception\StateException(__('Some internal exception message.')) ); @@ -205,7 +187,7 @@ public function testDeleteThrowsExceptionIfGivenAttributeSetIsDefault() public function testDeleteById() { $attributeSetId = 1; - $attributeSetMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute\Set::class, [], [], '', false); + $attributeSetMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Set::class); $attributeSetMock->expects($this->any())->method('getId')->will($this->returnValue($attributeSetId)); $this->setFactoryMock->expects($this->once())->method('create')->will($this->returnValue($attributeSetMock)); $this->resourceMock->expects($this->once())->method('load')->with($attributeSetMock, $attributeSetId, null); @@ -218,7 +200,7 @@ public function testDeleteById() */ public function testGetList() { - $attributeSetMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute\Set::class, [], [], '', false); + $attributeSetMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Set::class); $collectionMock = $this->getMockBuilder(\Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection::class) ->disableOriginalConstructor() @@ -237,7 +219,7 @@ public function testGetList() $this->collectionFactoryMock->expects($this->once())->method('create')->willReturn($collectionMock); - $searchCriteriaMock = $this->getMock(\Magento\Framework\Api\SearchCriteriaInterface::class); + $searchCriteriaMock = $this->createMock(\Magento\Framework\Api\SearchCriteriaInterface::class); $resultMock = $this->getMockBuilder(\Magento\Eav\Api\Data\AttributeSetSearchResultsInterface::class) ->getMockForAbstractClass(); @@ -272,7 +254,7 @@ public function testGetList() */ public function testGetListIfEntityTypeCodeIsNull() { - $attributeSetMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute\Set::class, [], [], '', false); + $attributeSetMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Set::class); $collectionMock = $this->getMockBuilder(\Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection::class) ->disableOriginalConstructor() @@ -293,7 +275,7 @@ public function testGetListIfEntityTypeCodeIsNull() ->method('create') ->willReturn($collectionMock); - $searchCriteriaMock = $this->getMock(\Magento\Framework\Api\SearchCriteriaInterface::class); + $searchCriteriaMock = $this->createMock(\Magento\Framework\Api\SearchCriteriaInterface::class); $resultMock = $this->getMockBuilder(\Magento\Eav\Api\Data\AttributeSetSearchResultsInterface::class) ->getMockForAbstractClass(); diff --git a/app/code/Magento/Eav/Test/Unit/Model/ConfigTest.php b/app/code/Magento/Eav/Test/Unit/Model/ConfigTest.php index da2b22143ad49..097643363f624 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/ConfigTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/ConfigTest.php @@ -13,7 +13,7 @@ use Magento\Framework\DataObject; use Magento\Framework\Serialize\SerializerInterface; -class ConfigTest extends \PHPUnit_Framework_TestCase +class ConfigTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Model\Config @@ -57,7 +57,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->cacheMock = $this->getMock(\Magento\Framework\App\CacheInterface::class); + $this->cacheMock = $this->createMock(\Magento\Framework\App\CacheInterface::class); $this->typeFactoryMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\TypeFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() @@ -67,15 +67,15 @@ protected function setUp() ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $this->cacheStateMock = $this->getMock(\Magento\Framework\App\Cache\StateInterface::class); + $this->cacheStateMock = $this->createMock(\Magento\Framework\App\Cache\StateInterface::class); $this->universalFactoryMock = $this->getMockBuilder(\Magento\Framework\Validator\UniversalFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $this->serializerMock = $this->getMock(SerializerInterface::class); + $this->serializerMock = $this->createMock(SerializerInterface::class); - $this->typeMock = $this->getMock(Type::class, [], [], '', false); + $this->typeMock = $this->createMock(Type::class); $this->config = new Config( $this->cacheMock, @@ -360,7 +360,7 @@ public function testGetEntityTypeCacheDoesNotExist() ->willReturn(false); $this->serializerMock->expects($this->never()) ->method('unserialize'); - $attributeCollectionMock = $this->getMock(Collection::class, [], [], '', false); + $attributeCollectionMock = $this->createMock(Collection::class); $this->collectionFactoryMock->expects($this->once()) ->method('create') ->willReturn($attributeCollectionMock); diff --git a/app/code/Magento/Eav/Test/Unit/Model/CustomAttributesMapperTest.php b/app/code/Magento/Eav/Test/Unit/Model/CustomAttributesMapperTest.php index ba980525d3dc9..d2067bccef0bb 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/CustomAttributesMapperTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/CustomAttributesMapperTest.php @@ -8,7 +8,7 @@ /** * Class CustomAttributesMapperTest */ -class CustomAttributesMapperTest extends \PHPUnit_Framework_TestCase +class CustomAttributesMapperTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager diff --git a/app/code/Magento/Eav/Test/Unit/Model/EavCustomAttributeTypeLocatorTest.php b/app/code/Magento/Eav/Test/Unit/Model/EavCustomAttributeTypeLocatorTest.php index ddd4042ed84a1..75f6b02cc4aea 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/EavCustomAttributeTypeLocatorTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/EavCustomAttributeTypeLocatorTest.php @@ -16,7 +16,7 @@ /** * Unit test class for \Magento\Eav\Model\EavCustomAttributeTypeLocator */ -class EavCustomAttributeTypeLocatorTest extends \PHPUnit_Framework_TestCase +class EavCustomAttributeTypeLocatorTest extends \PHPUnit\Framework\TestCase { /** * @var EavCustomAttributeTypeLocator @@ -30,13 +30,7 @@ class EavCustomAttributeTypeLocatorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->attributeRepository = $this->getMock( - \Magento\Eav\Model\AttributeRepository::class, - ['get'], - [], - '', - false - ); + $this->attributeRepository = $this->createPartialMock(\Magento\Eav\Model\AttributeRepository::class, ['get']); } /** @@ -105,25 +99,13 @@ public function getTypeDataProvider() $serviceInterface => [$mediaBackEndModelClass => $mediaAttributeDataInterface] ]; - $attribute = $this->getMock( - \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, - ['getBackendModel'], - [], - '', - false - ); + $attribute = $this->createPartialMock(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, ['getBackendModel']); $attribute->expects($this->any()) ->method('getBackendModel') ->willReturn($mediaBackEndModelClass); - $attributeNoBackendModel = $this->getMock( - \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, - ['getBackendModel', 'getFrontendInput'], - [], - '', - false - ); + $attributeNoBackendModel = $this->createPartialMock(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class, ['getBackendModel', 'getFrontendInput']); $attributeNoBackendModel->expects($this->any()) ->method('getBackendModel') diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/AbstractEntityTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/AbstractEntityTest.php index 266b21ce23dc4..682907e9c0a23 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/AbstractEntityTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/AbstractEntityTest.php @@ -11,7 +11,11 @@ use Magento\Framework\Model\AbstractModel; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class AbstractEntityTest extends \PHPUnit_Framework_TestCase +/** + * Class AbstractEntityTest + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class AbstractEntityTest extends \PHPUnit\Framework\TestCase { /** * Entity model to be tested @@ -25,7 +29,7 @@ class AbstractEntityTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $this->eavConfig = $this->getMock(\Magento\Eav\Model\Config::class, [], [], '', false); + $this->eavConfig = $this->createMock(\Magento\Eav\Model\Config::class); $arguments = $objectManager->getConstructArguments( AbstractEntity::class, ['eavConfig' => $this->eavConfig] @@ -50,9 +54,9 @@ protected function tearDown() */ public function testCompareAttributes($attribute1Sort, $attribute2Sort, $expected) { - $attribute1 = $this->getMock(\Magento\Eav\Model\Entity\Attribute::class, ['__wakeup'], [], '', false); + $attribute1 = $this->createPartialMock(\Magento\Eav\Model\Entity\Attribute::class, ['__wakeup']); $attribute1->setAttributeSetInfo([0 => $attribute1Sort]); - $attribute2 = $this->getMock(\Magento\Eav\Model\Entity\Attribute::class, ['__wakeup'], [], '', false); + $attribute2 = $this->createPartialMock(\Magento\Eav\Model\Entity\Attribute::class, ['__wakeup']); $attribute2->setAttributeSetInfo([0 => $attribute2Sort]); $this->assertEquals($expected, $this->_model->attributesCompare($attribute1, $attribute2)); } @@ -88,17 +92,14 @@ protected function _getAttributes() $attributes = []; $codes = ['entity_type_id', 'attribute_set_id', 'created_at', 'updated_at', 'parent_id', 'increment_id']; foreach ($codes as $code) { - $mock = $this->getMock( + $mock = $this->createPartialMock( \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class, - ['getBackend', 'getBackendTable', '__wakeup'], - [], - '', - false + ['getBackend', 'getBackendTable', '__wakeup'] ); $mock->setAttributeId($code); /** @var $backendModel \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend */ - $backendModel = $this->getMock( + $backendModel = $this->createPartialMock( \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend::class, ['getBackend', 'getBackendTable'] ); @@ -121,9 +122,7 @@ protected function _getAttributes() */ protected function _getConnectionMock() { - $connection = $this->getMock( - \Magento\Framework\DB\Adapter\Pdo\Mysql::class, - [ + $connection = $this->createPartialMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, [ 'describeTable', 'getIndexList', 'lastInsertId', @@ -132,26 +131,13 @@ protected function _getConnectionMock() 'select', 'query', 'delete' - ], - [], - '', - false - ); - $statement = $this->getMock( + ]); + $statement = $this->createPartialMock( \Zend_Db_Statement::class, - ['closeCursor', 'columnCount', 'errorCode', 'errorInfo', 'fetch', 'nextRowset', 'rowCount'], - [], - '', - false + ['closeCursor', 'columnCount', 'errorCode', 'errorInfo', 'fetch', 'nextRowset', 'rowCount'] ); - $select = $this->getMock( - \Magento\Framework\DB\Select::class, - [], - [], - '', - false - ); + $select = $this->createMock(\Magento\Framework\DB\Select::class); $select->expects($this->any()) ->method('from') ->willReturnSelf(); @@ -206,12 +192,9 @@ protected function _getConnectionMock() */ protected function _getAttributeMock($attributeCode, $attributeSetId) { - $attribute = $this->getMock( + $attribute = $this->createPartialMock( \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class, - ['getBackend', 'getBackendTable', 'isInSet', 'getApplyTo', 'getAttributeCode', '__wakeup'], - [], - '', - false + ['getBackend', 'getBackendTable', 'isInSet', 'getApplyTo', 'getAttributeCode', '__wakeup'] ); $attribute->setAttributeId($attributeCode); @@ -248,12 +231,9 @@ protected function _getAttributeMock($attributeCode, $attributeSetId) */ public function testSave($attributeCode, $attributeSetId, $productData, $productOrigData) { - $object = $this->getMock( + $object = $this->createPartialMock( \Magento\Catalog\Model\Product::class, - ['getOrigData', '__wakeup', 'beforeSave', 'afterSave', 'validateBeforeSave'], - [], - '', - false + ['getOrigData', '__wakeup', 'beforeSave', 'afterSave', 'validateBeforeSave'] ); $object->setEntityTypeId(1); foreach ($productData as $key => $value) { @@ -271,7 +251,7 @@ public function testSave($attributeCode, $attributeSetId, $productData, $product $attribute = $this->_getAttributeMock($attributeCode, $attributeSetId); /** @var $backendModel \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend */ - $backendModel = $this->getMock( + $backendModel = $this->createPartialMock( \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend::class, [ 'getBackend', @@ -302,7 +282,7 @@ public function testSave($attributeCode, $attributeSetId, $productData, $product ->disableOriginalConstructor() ->getMock(); $objectManager = new ObjectManager($this); - $this->eavConfig = $this->getMock(\Magento\Eav\Model\Config::class, [], [], '', false); + $this->eavConfig = $this->createMock(\Magento\Eav\Model\Config::class); $arguments = $objectManager->getConstructArguments( AbstractEntity::class, [ @@ -363,7 +343,7 @@ public function productAttributesDataProvider() */ public function testDuplicateExceptionProcessingOnSave() { - $connection = $this->getMock(AdapterInterface::class); + $connection = $this->createMock(AdapterInterface::class); $connection->expects($this->once())->method('rollback'); /** @var AbstractEntity|\PHPUnit_Framework_MockObject_MockObject $model */ diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/AbstractAttributeTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/AbstractAttributeTest.php index dc3a5db0ab605..5f5398c77488c 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/AbstractAttributeTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/AbstractAttributeTest.php @@ -7,7 +7,7 @@ namespace Magento\Eav\Test\Unit\Model\Entity\Attribute; -class AbstractAttributeTest extends \PHPUnit_Framework_TestCase +class AbstractAttributeTest extends \PHPUnit\Framework\TestCase { public function testGetOptionWhenOptionsAreSet() { @@ -95,13 +95,10 @@ public function testGetOptionWhenOptionsAreEmptyWithSource() public function testConvertToObjects() { - $attributeOptionMock = $this->getMock(\Magento\Eav\Api\Data\AttributeOptionInterface::class); - $dataFactoryMock = $this->getMock( + $attributeOptionMock = $this->createMock(\Magento\Eav\Api\Data\AttributeOptionInterface::class); + $dataFactoryMock = $this->createPartialMock( \Magento\Eav\Api\Data\AttributeOptionInterfaceFactory::class, - ['create'], - [], - '', - false + ['create'] ); $dataObjectHelperMock = $this->getMockBuilder(\Magento\Framework\Api\DataObjectHelper::class) ->disableOriginalConstructor() @@ -150,7 +147,7 @@ public function testGetValidationRulesWhenRuleIsSerialized() $modelClassName = \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class; $model = $this->getMockForAbstractClass($modelClassName, [], '', false); - $serializerMock = $this->getMock(\Magento\Framework\Serialize\SerializerInterface::class); + $serializerMock = $this->createMock(\Magento\Framework\Serialize\SerializerInterface::class); $reflection = new \ReflectionClass($modelClassName); $reflectionProperty = $reflection->getProperty('serializer'); diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Backend/AbstractTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Backend/AbstractTest.php index 17bfb29bcb9b2..ec539857721c2 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Backend/AbstractTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Backend/AbstractTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Eav\Test\Unit\Model\Entity\Attribute\Backend; -class AbstractTest extends \PHPUnit_Framework_TestCase +class AbstractTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend|\PHPUnit_Framework_MockObject_MockObject @@ -27,12 +27,9 @@ public function testGetAffectedFields() $valueId = 10; $attributeId = 42; - $attribute = $this->getMock( + $attribute = $this->createPartialMock( \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class, - ['getBackendTable', 'isStatic', 'getAttributeId', '__wakeup'], - [], - '', - false + ['getBackendTable', 'isStatic', 'getAttributeId', '__wakeup'] ); $attribute->expects($this->any())->method('getAttributeId')->will($this->returnValue($attributeId)); diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Backend/ArrayBackendTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Backend/ArrayBackendTest.php index 79d8cc5e727df..3c0e304dbf628 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Backend/ArrayBackendTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Backend/ArrayBackendTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Eav\Test\Unit\Model\Entity\Attribute\Backend; -class ArrayBackendTest extends \PHPUnit_Framework_TestCase +class ArrayBackendTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend @@ -19,14 +19,11 @@ class ArrayBackendTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_attribute = $this->getMock( + $this->_attribute = $this->createPartialMock( \Magento\Eav\Model\Entity\Attribute::class, - ['getAttributeCode', '__wakeup'], - [], - '', - false + ['getAttributeCode', '__wakeup'] ); - $logger = $this->getMock(\Psr\Log\LoggerInterface::class); + $logger = $this->createMock(\Psr\Log\LoggerInterface::class); $this->_model = new \Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend($logger); $this->_model->setAttribute($this->_attribute); } diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Backend/JsonEncodedTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Backend/JsonEncodedTest.php index c407ec9af73b4..96846c0d1fe56 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Backend/JsonEncodedTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Backend/JsonEncodedTest.php @@ -8,7 +8,7 @@ use Magento\Eav\Model\Entity\Attribute\Backend\JsonEncoded; -class JsonEncodedTest extends \PHPUnit_Framework_TestCase +class JsonEncodedTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Model\Entity\Attribute\Backend\JsonEncoded diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Config/ConverterTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Config/ConverterTest.php index 189796eb03d7e..334a0d3e77174 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Config/ConverterTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Config/ConverterTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Eav\Test\Unit\Model\Entity\Attribute\Config; -class ConverterTest extends \PHPUnit_Framework_TestCase +class ConverterTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Model\Entity\Attribute\Config\Converter diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Config/XsdTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Config/XsdTest.php index 36e37c8488c7e..d566ca798190a 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Config/XsdTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Config/XsdTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Eav\Test\Unit\Model\Entity\Attribute\Config; -class XsdTest extends \PHPUnit_Framework_TestCase +class XsdTest extends \PHPUnit\Framework\TestCase { /** * Path to xsd schema file diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/ConfigTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/ConfigTest.php index 29ff5d9cbb480..57ca046130624 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/ConfigTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/ConfigTest.php @@ -9,7 +9,7 @@ */ namespace Magento\Eav\Test\Unit\Model\Entity\Attribute; -class ConfigTest extends \PHPUnit_Framework_TestCase +class ConfigTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Model\Entity\Attribute\Config @@ -43,23 +43,17 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_attribute = $this->getMock(\Magento\Eav\Model\Entity\Attribute::class, [], [], '', false); - $this->_entityType = $this->getMock(\Magento\Eav\Model\Entity\Type::class, [], [], '', false); - $this->_readerMock = $this->getMock( - \Magento\Eav\Model\Entity\Attribute\Config\Reader::class, - [], - [], - '', - false - ); - $this->_cacheMock = $this->getMock(\Magento\Framework\App\Cache\Type\Config::class, [], [], '', false); + $this->_attribute = $this->createMock(\Magento\Eav\Model\Entity\Attribute::class); + $this->_entityType = $this->createMock(\Magento\Eav\Model\Entity\Type::class); + $this->_readerMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Config\Reader::class); + $this->_cacheMock = $this->createMock(\Magento\Framework\App\Cache\Type\Config::class); $this->_cacheId = 'eav_attributes'; $this->_cacheMock->expects($this->once()) ->method('load') ->with($this->_cacheId) ->willReturn(''); - $serializerMock = $this->getMock(\Magento\Framework\Serialize\SerializerInterface::class); + $serializerMock = $this->createMock(\Magento\Framework\Serialize\SerializerInterface::class); $serializerMock->method('unserialize') ->willReturn([]); diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Frontend/DatetimeTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Frontend/DatetimeTest.php index 395132926a956..66549f2e00415 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Frontend/DatetimeTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Frontend/DatetimeTest.php @@ -7,7 +7,7 @@ use Magento\Eav\Model\Entity\Attribute\Frontend\Datetime; -class DatetimeTest extends \PHPUnit_Framework_TestCase +class DatetimeTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -31,20 +31,11 @@ class DatetimeTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->booleanFactoryMock = $this->getMock( - \Magento\Eav\Model\Entity\Attribute\Source\BooleanFactory::class, - [], - [], - '', - false - ); - $this->localeDateMock = $this->getMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); - $this->attributeMock = $this->getMock( + $this->booleanFactoryMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Source\BooleanFactory::class); + $this->localeDateMock = $this->createMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class); + $this->attributeMock = $this->createPartialMock( \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class, - ['getAttributeCode', 'getFrontendLabel'], - [], - '', - false + ['getAttributeCode', 'getFrontendLabel', 'getData'] ); $this->model = new Datetime($this->booleanFactoryMock, $this->localeDateMock); diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Frontend/DefaultFrontendTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Frontend/DefaultFrontendTest.php index 7ff2dc0b9f0df..a61c9ef447458 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Frontend/DefaultFrontendTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Frontend/DefaultFrontendTest.php @@ -14,7 +14,7 @@ use Magento\Eav\Model\Entity\Attribute\AbstractAttribute; use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource; -class DefaultFrontendTest extends \PHPUnit_Framework_TestCase +class DefaultFrontendTest extends \PHPUnit\Framework\TestCase { /** * @var DefaultFrontend diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/GroupTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/GroupTest.php index bf5462901ee7a..d4c91e98d9608 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/GroupTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/GroupTest.php @@ -8,7 +8,7 @@ use Magento\Eav\Model\Entity\Attribute\Group; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class GroupTest extends \PHPUnit_Framework_TestCase +class GroupTest extends \PHPUnit\Framework\TestCase { /** * @var Group @@ -27,20 +27,14 @@ class GroupTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->resourceMock = $this->getMock( - \Magento\Eav\Model\ResourceModel\Entity\Attribute\Group::class, - [], - [], - '', - false - ); + $this->resourceMock = $this->createMock(\Magento\Eav\Model\ResourceModel\Entity\Attribute\Group::class); $translitFilter = $this->getMockBuilder(\Magento\Framework\Filter\Translit::class) ->disableOriginalConstructor() ->getMock(); $translitFilter->expects($this->atLeastOnce())->method('filter')->willReturnArgument(0); - $this->eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); - $contextMock = $this->getMock(\Magento\Framework\Model\Context::class, [], [], '', false); + $this->eventManagerMock = $this->createMock(\Magento\Framework\Event\ManagerInterface::class); + $contextMock = $this->createMock(\Magento\Framework\Model\Context::class); $contextMock->expects($this->any())->method('getEventDispatcher')->willReturn($this->eventManagerMock); $constructorArguments = [ 'resource' => $this->resourceMock, diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/OptionManagementTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/OptionManagementTest.php index c2564f9ec933e..36eb78fd435e7 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/OptionManagementTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/OptionManagementTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Eav\Test\Unit\Model\Entity\Attribute; -class OptionManagementTest extends \PHPUnit_Framework_TestCase +class OptionManagementTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Model\Entity\Attribute\OptionManagement @@ -24,15 +24,9 @@ class OptionManagementTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->attributeRepositoryMock = $this->getMock( - \Magento\Eav\Model\AttributeRepository::class, - [], - [], - '', - false - ); + $this->attributeRepositoryMock = $this->createMock(\Magento\Eav\Model\AttributeRepository::class); $this->resourceModelMock = - $this->getMock(\Magento\Eav\Model\ResourceModel\Entity\Attribute::class, [], [], '', false); + $this->createMock(\Magento\Eav\Model\ResourceModel\Entity\Attribute::class); $this->model = new \Magento\Eav\Model\Entity\Attribute\OptionManagement( $this->attributeRepositoryMock, $this->resourceModelMock @@ -61,7 +55,7 @@ public function testAdd() true, ['usesSource', 'setDefault', 'setOption'] ); - $labelMock = $this->getMock(\Magento\Eav\Api\Data\AttributeOptionLabelInterface::class); + $labelMock = $this->createMock(\Magento\Eav\Api\Data\AttributeOptionLabelInterface::class); $option = ['value' => [ 'new_option' => [ @@ -169,7 +163,7 @@ public function testAddWithCannotSaveException() true, ['usesSource', 'setDefault', 'setOption'] ); - $labelMock = $this->getMock(\Magento\Eav\Api\Data\AttributeOptionLabelInterface::class); + $labelMock = $this->createMock(\Magento\Eav\Api\Data\AttributeOptionLabelInterface::class); $option = ['value' => [ 'new_option' => [ @@ -345,7 +339,7 @@ public function testGetItems() true, ['getOptions'] ); - $optionsMock = [$this->getMock(\Magento\Eav\Api\Data\AttributeOptionInterface::class)]; + $optionsMock = [$this->createMock(\Magento\Eav\Api\Data\AttributeOptionInterface::class)]; $this->attributeRepositoryMock->expects($this->once())->method('get')->with($entityType, $attributeCode) ->willReturn($attributeMock); $attributeMock->expects($this->once())->method('getOptions')->willReturn($optionsMock); diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/SetTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/SetTest.php index 1f7e134f07a30..78465e57c6236 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/SetTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/SetTest.php @@ -9,7 +9,7 @@ */ namespace Magento\Eav\Test\Unit\Model\Entity\Attribute; -class SetTest extends \PHPUnit_Framework_TestCase +class SetTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Model\Entity\Attribute\Set @@ -18,16 +18,9 @@ class SetTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $resource = $this->getMock(\Magento\Eav\Model\ResourceModel\Entity\Attribute\Set::class, [], [], '', false); - $attrGroupFactory = $this->getMock( - \Magento\Eav\Model\Entity\Attribute\GroupFactory::class, - [], - [], - '', - false, - false - ); - $attrFactory = $this->getMock(\Magento\Eav\Model\Entity\AttributeFactory::class, [], [], '', false, false); + $resource = $this->createMock(\Magento\Eav\Model\ResourceModel\Entity\Attribute\Set::class); + $attrGroupFactory = $this->createMock(\Magento\Eav\Model\Entity\Attribute\GroupFactory::class); + $attrFactory = $this->createMock(\Magento\Eav\Model\Entity\AttributeFactory::class); $arguments = [ 'attrGroupFactory' => $attrGroupFactory, 'attributeFactory' => $attrFactory, @@ -51,7 +44,7 @@ public function testValidateWithExistingName($attributeSetName, $exceptionMessag { $this->_model->getResource()->expects($this->any())->method('validate')->will($this->returnValue(false)); - $this->setExpectedException(\Magento\Framework\Exception\LocalizedException::class, $exceptionMessage); + $this->expectException(\Magento\Framework\Exception\LocalizedException::class, $exceptionMessage); $this->_model->setAttributeSetName($attributeSetName); $this->_model->validate(); } diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Source/BooleanTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Source/BooleanTest.php index 24fc47fcec60d..bb7baa0e461ee 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Source/BooleanTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Source/BooleanTest.php @@ -11,7 +11,7 @@ use Magento\Eav\Model\Entity\AbstractEntity; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class BooleanTest extends \PHPUnit_Framework_TestCase +class BooleanTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Model\Entity\Attribute\Source\Boolean @@ -26,13 +26,7 @@ protected function setUp() public function testGetFlatColumns() { - $abstractAttributeMock = $this->getMock( - \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class, - ['getAttributeCode', '__wakeup'], - [], - '', - false - ); + $abstractAttributeMock = $this->createPartialMock(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class, ['getAttributeCode', '__wakeup']); $abstractAttributeMock->expects($this->any())->method('getAttributeCode')->will($this->returnValue('code')); @@ -75,7 +69,7 @@ public function testAddValueSortToCollection( $entity->expects($this->once())->method('getLinkField')->willReturn('entity_id'); $attributeMock->expects($this->once())->method('getEntity')->willReturn($entity); - $selectMock = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); + $selectMock = $this->createMock(\Magento\Framework\DB\Select::class); $collectionMock = $this->getCollectionMock(); $collectionMock->expects($this->any())->method('getSelect')->will($this->returnValue($selectMock)); @@ -164,11 +158,11 @@ public function addValueSortToCollectionDataProvider() protected function getCollectionMock() { $collectionMethods = ['getSelect', 'getStoreId', 'getConnection']; - $collectionMock = $this->getMock( - \Magento\Eav\Model\Entity\Collection\AbstractCollection::class, $collectionMethods, [], '', false + $collectionMock = $this->createPartialMock( + \Magento\Eav\Model\Entity\Collection\AbstractCollection::class, $collectionMethods ); - $connectionMock = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['method'], [], '', false); + $connectionMock = $this->createPartialMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['method']); $collectionMock->expects($this->any())->method('getConnection')->will($this->returnValue($connectionMock)); $collectionMock->expects($this->any())->method('getStoreId')->will($this->returnValue('12')); @@ -182,20 +176,11 @@ protected function getCollectionMock() protected function getAttributeMock() { $attributeMockMethods = ['getAttributeCode', 'getId', 'getBackend', 'isScopeGlobal', '__wakeup' , 'getEntity']; - $attributeMock = $this->getMock( + $attributeMock = $this->createPartialMock( \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class, - $attributeMockMethods, - [], - '', - false - ); - $backendMock = $this->getMock( - \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend::class, - [], - [], - '', - false + $attributeMockMethods ); + $backendMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend::class); $attributeMock->expects($this->any())->method('getAttributeCode')->will($this->returnValue('code')); $attributeMock->expects($this->any())->method('getId')->will($this->returnValue('123')); diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Source/TableTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Source/TableTest.php index 63c6fbb3c70ce..6f79e7ed06fad 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Source/TableTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Source/TableTest.php @@ -5,17 +5,17 @@ */ namespace Magento\Eav\Test\Unit\Model\Entity\Attribute\Source; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource; use Magento\Eav\Model\Entity\Attribute\AbstractAttribute; -use Magento\Store\Model\StoreManagerInterface; -use Magento\Store\Api\Data\StoreInterface; +use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource; use Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\Collection as AttributeOptionCollection; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Store\Api\Data\StoreInterface; +use Magento\Store\Model\StoreManagerInterface; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class TableTest extends \PHPUnit_Framework_TestCase +class TableTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Model\Entity\Attribute\Source\Table @@ -62,7 +62,7 @@ protected function setUp() { $objectManager = new ObjectManager($this); - $this->collectionFactory = $this->getMock( + $this->collectionFactory = $this->createPartialMock( \Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\CollectionFactory::class, [ 'create', @@ -72,10 +72,7 @@ protected function setUp() 'setStoreFilter', 'load', 'toOptionArray' - ], - [], - '', - false + ] ); $this->attributeOptionCollectionMock = $this->getMockBuilder(AttributeOptionCollection::class) @@ -83,12 +80,9 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); - $this->attrOptionFactory = $this->getMock( + $this->attrOptionFactory = $this->createPartialMock( \Magento\Eav\Model\ResourceModel\Entity\Attribute\OptionFactory::class, - ['create'], - [], - '', - false + ['create'] ); $this->sourceMock = $this->getMockBuilder(AbstractSource::class) @@ -126,13 +120,7 @@ protected function setUp() public function testGetFlatColumns() { - $abstractFrontendMock = $this->getMock( - \Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend::class, - [], - [], - '', - false - ); + $abstractFrontendMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend::class); $this->abstractAttributeMock->expects($this->any())->method('getFrontend')->willReturn(($abstractFrontendMock)); $this->abstractAttributeMock->expects($this->any())->method('getAttributeCode')->willReturn('code'); diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/AttributeLoaderTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/AttributeLoaderTest.php index 4deb3a576ecef..3cfc3dafda3f5 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/AttributeLoaderTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/AttributeLoaderTest.php @@ -8,13 +8,12 @@ use Magento\Eav\Model\Attribute; use Magento\Eav\Model\Config; use Magento\Eav\Model\Entity\AbstractEntity; -use Magento\Eav\Model\Entity\Attribute\AbstractAttribute; use Magento\Eav\Model\Entity\AttributeLoader; use Magento\Eav\Model\Entity\Type; use Magento\Framework\DataObject; use Magento\Framework\ObjectManagerInterface; -class AttributeLoaderTest extends \PHPUnit_Framework_TestCase +class AttributeLoaderTest extends \PHPUnit\Framework\TestCase { /** * @var Config|\PHPUnit_Framework_MockObject_MockObject @@ -43,10 +42,13 @@ class AttributeLoaderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->configMock = $this->getMock(Config::class, [], [], '', false); - $this->objectManagerMock = $this->getMock(ObjectManagerInterface::class); - $this->entityMock = $this->getMock(AbstractEntity::class, [], [], '', false); - $this->entityTypeMock = $this->getMock(Type::class, [], [], '', false); + $this->configMock = $this->createMock(Config::class, [], [], '', false); + $this->objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class) + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $this->entityMock = $this->createMock(AbstractEntity::class, [], [], '', false); + $this->entityTypeMock = $this->createMock(Type::class, [], [], '', false); $this->attributeLoader = new AttributeLoader( $this->configMock, $this->objectManagerMock @@ -55,44 +57,34 @@ protected function setUp() public function testLoadAllAttributes() { - $defaultAttributes = ['bar']; + $attributeCode = 'bar'; $entityTypeId = 1; $dataObject = new DataObject(); - $this->entityMock->expects($this->any()) - ->method('getEntityType') - ->willReturn($this->entityTypeMock); - - $this->entityMock->expects($this->once()) - ->method('getDefaultAttributes') - ->willReturn($defaultAttributes); - $this->entityTypeMock->expects($this->any()) - ->method('getId') - ->willReturn($entityTypeId); - $attributeMock = $this->getMock( - \Magento\Eav\Model\Attribute::class, - [ - 'setAttributeCode', - 'setBackendType', - 'setIsGlobal', - 'setEntityType', - 'setEntityTypeId' - ], - [], - '', - false - ); - $this->configMock->expects($this->once()) - ->method('getEntityAttributes') - ->willReturn(['bar' => $attributeMock]); - $this->entityMock->expects($this->once()) - ->method('addAttribute') - ->with($attributeMock); + $this->entityMock->expects($this->atLeastOnce())->method('getEntityType')->willReturn($this->entityTypeMock); + $this->entityMock->expects($this->once())->method('getDefaultAttributes')->willReturn([$attributeCode]); + $this->entityTypeMock->expects($this->atLeastOnce())->method('getId')->willReturn($entityTypeId); + $this->configMock->expects($this->once())->method('getEntityAttributes')->willReturn([]); + $this->entityMock->expects($this->once())->method('unsetAttributes')->willReturnSelf(); + $this->entityTypeMock->expects($this->once()) + ->method('getAttributeModel')->willReturn(\Magento\Eav\Model\Entity::DEFAULT_ATTRIBUTE_MODEL); + $attributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute::class) + ->setMethods(['setAttributeCode', 'setBackendType', 'setIsGlobal', 'setEntityType', 'setEntityTypeId']) + ->disableOriginalConstructor()->getMock(); + $this->objectManagerMock->expects($this->once()) + ->method('create')->with(\Magento\Eav\Model\Entity::DEFAULT_ATTRIBUTE_MODEL)->willReturn($attributeMock); + $attributeMock->expects($this->once())->method('setAttributeCode')->with($attributeCode)->willReturnSelf(); + $attributeMock->expects($this->once())->method('setBackendType') + ->with(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::TYPE_STATIC)->willReturnSelf(); + $attributeMock->expects($this->once())->method('setIsGlobal')->with(1)->willReturnSelf(); + $attributeMock->expects($this->once())->method('setEntityType')->with($this->entityTypeMock)->willReturnSelf(); + $attributeMock->expects($this->once())->method('setEntityTypeId')->with($entityTypeId)->willReturnSelf(); + $this->entityMock->expects($this->once())->method('addAttribute')->with($attributeMock)->willReturnSelf(); $this->attributeLoader->loadAllAttributes($this->entityMock, $dataObject); } public function testLoadAllAttributesAttributeCodesPresentInDefaultAttributes() { - $attributeMock = $this->getMock( + $attributeMock = $this->createPartialMock( \Magento\Eav\Model\Attribute::class, [ 'setAttributeCode', @@ -100,28 +92,19 @@ public function testLoadAllAttributesAttributeCodesPresentInDefaultAttributes() 'setIsGlobal', 'setEntityType', 'setEntityTypeId' - ], - [], - '', - false + ] ); - $attributeCodes = ['bar'=>$attributeMock]; + $attributeCodes = ['bar' => $attributeMock]; $defaultAttributes = ['bar']; $dataObject = new DataObject(); - $this->entityMock->expects($this->any()) - ->method('getEntityType') - ->willReturn($this->entityTypeMock); + $this->entityMock->expects($this->once())->method('getEntityType')->willReturn($this->entityTypeMock); $this->configMock->expects($this->once()) - ->method('getEntityAttributes') - ->willReturn($attributeCodes, $dataObject); - $this->entityMock->expects($this->once()) - ->method('getDefaultAttributes') - ->willReturn($defaultAttributes); + ->method('getEntityAttributes')->willReturn($attributeCodes); + $this->entityMock->expects($this->once())->method('getDefaultAttributes')->willReturn($defaultAttributes); + $this->entityMock->expects($this->once())->method('unsetAttributes')->willReturnSelf(); $this->entityMock->expects($this->atLeastOnce()) - ->method('addAttribute')->with($attributeMock); - - $this->objectManagerMock->expects($this->never()) - ->method('create'); + ->method('addAttribute')->with($attributeMock)->willReturnSelf(); + $this->objectManagerMock->expects($this->never())->method('create'); $this->attributeLoader->loadAllAttributes($this->entityMock, $dataObject); } } diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/AttributeTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/AttributeTest.php index 8ebd809a62c71..27957e8090d3e 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/AttributeTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/AttributeTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Eav\Test\Unit\Model\Entity; -class AttributeTest extends \PHPUnit_Framework_TestCase +class AttributeTest extends \PHPUnit\Framework\TestCase { /** * Attribute model to be tested @@ -15,7 +15,7 @@ class AttributeTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_model = $this->getMock(\Magento\Eav\Model\Entity\Attribute::class, ['__wakeup'], [], '', false); + $this->_model = $this->createPartialMock(\Magento\Eav\Model\Entity\Attribute::class, ['__wakeup']); } protected function tearDown() diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Collection/AbstractCollectionTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Collection/AbstractCollectionTest.php index a11f847a53a02..88185387ed398 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Collection/AbstractCollectionTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Collection/AbstractCollectionTest.php @@ -5,14 +5,12 @@ */ namespace Magento\Eav\Test\Unit\Model\Entity\Collection; -use Magento\Eav\Test\Unit\Model\Entity\Collection\AbstractCollectionStub; - /** * AbstractCollection test * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class AbstractCollectionTest extends \PHPUnit_Framework_TestCase +class AbstractCollectionTest extends \PHPUnit\Framework\TestCase { /** * @var AbstractCollectionStub|\PHPUnit_Framework_MockObject_MockObject @@ -71,56 +69,22 @@ class AbstractCollectionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->coreEntityFactoryMock = $this->getMock( - \Magento\Framework\Data\Collection\EntityFactory::class, - [], - [], - '', - false - ); - $this->loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); - $this->fetchStrategyMock = $this->getMock( - \Magento\Framework\Data\Collection\Db\FetchStrategyInterface::class, - [], - [], - '', - false - ); - $this->eventManagerMock = $this->getMock( - \Magento\Framework\Event\ManagerInterface::class, - [], - [], - '', - false + $this->coreEntityFactoryMock = $this->createMock(\Magento\Framework\Data\Collection\EntityFactory::class); + $this->loggerMock = $this->createMock(\Psr\Log\LoggerInterface::class); + $this->fetchStrategyMock = $this->createMock( + \Magento\Framework\Data\Collection\Db\FetchStrategyInterface::class ); - $this->configMock = $this->getMock(\Magento\Eav\Model\Config::class, [], [], '', false); - $this->coreResourceMock = $this->getMock( - \Magento\Framework\App\ResourceConnection::class, - [], - [], - '', - false - ); - $this->resourceHelperMock = $this->getMock(\Magento\Eav\Model\ResourceModel\Helper::class, [], [], '', false); - $this->validatorFactoryMock = $this->getMock( - \Magento\Framework\Validator\UniversalFactory::class, - [], - [], - '', - false - ); - $this->entityFactoryMock = $this->getMock(\Magento\Eav\Model\EntityFactory::class, [], [], '', false); + $this->eventManagerMock = $this->createMock(\Magento\Framework\Event\ManagerInterface::class); + $this->configMock = $this->createMock(\Magento\Eav\Model\Config::class); + $this->coreResourceMock = $this->createMock(\Magento\Framework\App\ResourceConnection::class); + $this->resourceHelperMock = $this->createMock(\Magento\Eav\Model\ResourceModel\Helper::class); + $this->validatorFactoryMock = $this->createMock(\Magento\Framework\Validator\UniversalFactory::class); + $this->entityFactoryMock = $this->createMock(\Magento\Eav\Model\EntityFactory::class); /** @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject */ - $connectionMock = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false); - $this->statementMock = $this->getMock( - \Magento\Framework\DB\Statement\Pdo\Mysql::class, - ['fetch'], - [], - '', - false - ); + $connectionMock = $this->createMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class); + $this->statementMock = $this->createPartialMock(\Magento\Framework\DB\Statement\Pdo\Mysql::class, ['fetch']); /** @var $selectMock \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject */ - $selectMock = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); + $selectMock = $this->createMock(\Magento\Framework\DB\Select::class); $this->coreEntityFactoryMock->expects( $this->any() )->method( @@ -138,7 +102,7 @@ protected function setUp() )->will( $this->returnValue($connectionMock) ); - $entityMock = $this->getMock(\Magento\Eav\Model\Entity\AbstractEntity::class, [], [], '', false); + $entityMock = $this->createMock(\Magento\Eav\Model\Entity\AbstractEntity::class); $entityMock->expects($this->any())->method('getConnection')->will($this->returnValue($connectionMock)); $entityMock->expects($this->any())->method('getDefaultAttributes')->will($this->returnValue([])); diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Collection/VersionControl/AbstractCollectionTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Collection/VersionControl/AbstractCollectionTest.php index 2df8893d7778c..d281b8d1095f4 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Collection/VersionControl/AbstractCollectionTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Collection/VersionControl/AbstractCollectionTest.php @@ -5,7 +5,6 @@ */ namespace Magento\Eav\Test\Unit\Model\Entity\Collection\VersionControl; -use Magento\Eav\Test\Unit\Model\Entity\Collection\VersionControl\AbstractCollectionStub; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; /** @@ -31,12 +30,9 @@ protected function setUp() $objectManager = new ObjectManager($this); - $this->entitySnapshot = $this->getMock( + $this->entitySnapshot = $this->createPartialMock( \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot::class, - ['registerSnapshot'], - [], - '', - false + ['registerSnapshot'] ); $this->subject = $objectManager->getObject( diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Increment/AlphanumTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Increment/AlphanumTest.php index 6786288e76367..16ba85f4905ea 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Increment/AlphanumTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Increment/AlphanumTest.php @@ -7,7 +7,7 @@ use Magento\Eav\Model\Entity\Increment\Alphanum; -class AlphanumTest extends \PHPUnit_Framework_TestCase +class AlphanumTest extends \PHPUnit\Framework\TestCase { /** * @var Alphanum diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Increment/NumericTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Increment/NumericTest.php index e4ca529f17635..a976fc1f3e654 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Increment/NumericTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Increment/NumericTest.php @@ -7,7 +7,7 @@ use Magento\Eav\Model\Entity\Increment\NumericValue; -class NumericTest extends \PHPUnit_Framework_TestCase +class NumericTest extends \PHPUnit\Framework\TestCase { /** * @var NumericValue diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/TypeTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/TypeTest.php index ae6d69f04f130..844379c41928d 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/TypeTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/TypeTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Eav\Test\Unit\Model\Entity; -class TypeTest extends \PHPUnit_Framework_TestCase +class TypeTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Model\Entity\Type @@ -49,36 +49,12 @@ class TypeTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->contextMock = $this->getMock(\Magento\Framework\Model\Context::class, [], [], '', false); - $this->registryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); - $this->attrFactoryMock = $this->getMock( - \Magento\Eav\Model\Entity\AttributeFactory::class, - [], - [], - '', - false - ); - $this->attrSetFactoryMock = $this->getMock( - \Magento\Eav\Model\Entity\Attribute\SetFactory::class, - [], - [], - '', - false - ); - $this->storeFactoryMock = $this->getMock( - \Magento\Eav\Model\Entity\StoreFactory::class, - ['create'], - [], - '', - false - ); - $this->universalFactoryMock = $this->getMock( - \Magento\Framework\Validator\UniversalFactory::class, - [], - [], - '', - false - ); + $this->contextMock = $this->createMock(\Magento\Framework\Model\Context::class); + $this->registryMock = $this->createMock(\Magento\Framework\Registry::class); + $this->attrFactoryMock = $this->createMock(\Magento\Eav\Model\Entity\AttributeFactory::class); + $this->attrSetFactoryMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\SetFactory::class); + $this->storeFactoryMock = $this->createPartialMock(\Magento\Eav\Model\Entity\StoreFactory::class, ['create']); + $this->universalFactoryMock = $this->createMock(\Magento\Framework\Validator\UniversalFactory::class); $this->resourceMock = $this->getMockForAbstractClass( \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, [], diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/VersionControl/AbstractEntityTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/VersionControl/AbstractEntityTest.php index f6f7a79e52a5c..b5d08e5dbe0ab 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/VersionControl/AbstractEntityTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/VersionControl/AbstractEntityTest.php @@ -26,20 +26,14 @@ class AbstractEntityTest extends \Magento\Eav\Test\Unit\Model\Entity\AbstractEnt protected function setUp() { - $this->entitySnapshot = $this->getMock( + $this->entitySnapshot = $this->createPartialMock( \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot::class, - ['isModified', 'registerSnapshot'], - [], - '', - false + ['isModified', 'registerSnapshot'] ); - $this->entityRelationComposite = $this->getMock( + $this->entityRelationComposite = $this->createPartialMock( \Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationComposite::class, - ['processRelations'], - [], - '', - false + ['processRelations'] ); parent::setUp(); @@ -56,12 +50,9 @@ protected function setUp() */ public function testSave($attributeCode, $attributeSetId, $productData, $productOrigData) { - $object = $this->getMock( + $object = $this->createPartialMock( \Magento\Catalog\Model\Product::class, - ['getOrigData', '__wakeup', 'beforeSave', 'afterSave', 'validateBeforeSave'], - [], - '', - false + ['getOrigData', '__wakeup', 'beforeSave', 'afterSave', 'validateBeforeSave'] ); $object->setEntityTypeId(1); @@ -80,7 +71,7 @@ public function testSave($attributeCode, $attributeSetId, $productData, $product $attribute = $this->_getAttributeMock($attributeCode, $attributeSetId); /** @var $backendModel \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend */ - $backendModel = $this->getMock( + $backendModel = $this->createPartialMock( \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend::class, [ 'getBackend', @@ -157,7 +148,7 @@ public function testSaveNotModified() $objectManager = new ObjectManager($this); /** @var $object \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject */ - $object = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); + $object = $this->createMock(\Magento\Catalog\Model\Product::class); $arguments = $objectManager->getConstructArguments( \Magento\Eav\Model\Entity\VersionControl\AbstractEntity::class, diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/VersionControl/MetadataTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/VersionControl/MetadataTest.php index 367b64998d7f6..20d40eb92cb4f 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/VersionControl/MetadataTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/VersionControl/MetadataTest.php @@ -10,7 +10,7 @@ /** * Test for version control metadata model. */ -class MetadataTest extends \PHPUnit_Framework_TestCase +class MetadataTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Model\Entity\VersionControl\Metadata @@ -36,12 +36,9 @@ protected function setUp() { $objectManager = new ObjectManager($this); - $this->model = $this->getMock( + $this->model = $this->createPartialMock( \Magento\Framework\Model\AbstractModel::class, - ['getResource', 'getAttributes'], - [], - '', - false + ['getResource', 'getAttributes'] ); $this->resource = $this->getMockForAbstractClass( diff --git a/app/code/Magento/Eav/Test/Unit/Model/FormTest.php b/app/code/Magento/Eav/Test/Unit/Model/FormTest.php index c597311c3c289..3b4a684c9e52a 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/FormTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/FormTest.php @@ -9,7 +9,7 @@ */ namespace Magento\Eav\Test\Unit\Model; -class FormTest extends \PHPUnit_Framework_TestCase +class FormTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Model\Form diff --git a/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Attribute/CollectionTest.php b/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Attribute/CollectionTest.php index 9e0537e6205dd..823f32f46b9a5 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Attribute/CollectionTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Attribute/CollectionTest.php @@ -12,7 +12,7 @@ * Class CollectionTest * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class CollectionTest extends \PHPUnit_Framework_TestCase +class CollectionTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Model\ResourceModel\Attribute\Collection|\PHPUnit_Framework_MockObject_MockObject @@ -76,33 +76,22 @@ class CollectionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->entityFactoryMock = $this->getMock( - \Magento\Framework\Data\Collection\EntityFactory::class, - [], - [], - '', - false - ); - $this->loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); - $this->fetchStrategyMock = $this->getMock(\Magento\Framework\Data\Collection\Db\FetchStrategyInterface::class); - $this->eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); + $this->entityFactoryMock = $this->createMock(\Magento\Framework\Data\Collection\EntityFactory::class); + $this->loggerMock = $this->createMock(\Psr\Log\LoggerInterface::class); + $this->fetchStrategyMock = $this->createMock(\Magento\Framework\Data\Collection\Db\FetchStrategyInterface::class); + $this->eventManagerMock = $this->createMock(\Magento\Framework\Event\ManagerInterface::class); - $this->eavConfigMock = $this->getMock(\Magento\Eav\Model\Config::class, [], [], '', false); - $this->entityTypeMock = $this->getMock(\Magento\Eav\Model\Entity\Type::class, ['__wakeup'], [], '', false); + $this->eavConfigMock = $this->createMock(\Magento\Eav\Model\Config::class); + $this->entityTypeMock = $this->createPartialMock(\Magento\Eav\Model\Entity\Type::class, ['__wakeup']); $this->entityTypeMock->setAdditionalAttributeTable('some_extra_table'); $this->eavConfigMock->expects($this->any()) ->method('getEntityType') ->will($this->returnValue($this->entityTypeMock)); - $this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnSelf()); - $this->connectionMock = $this->getMock( - \Magento\Framework\DB\Adapter\Pdo\Mysql::class, - ['select', 'describeTable', 'quoteIdentifier', '_connect', '_quote'], - [], - '', - false); + $this->connectionMock = $this->createPartialMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['select', 'describeTable', 'quoteIdentifier', '_connect', '_quote']); $this->selectRenderer = $this->getMockBuilder(\Magento\Framework\DB\Select\SelectRenderer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/AttributeLoaderTest.php b/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/AttributeLoaderTest.php index c564268d64d0d..8e6fa3afd15b9 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/AttributeLoaderTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/AttributeLoaderTest.php @@ -6,7 +6,7 @@ namespace Magento\Eav\Test\Unit\Model\ResourceModel; -class AttributeLoaderTest extends \PHPUnit_Framework_TestCase +class AttributeLoaderTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Api\AttributeRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject @@ -30,7 +30,7 @@ class AttributeLoaderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->attributeRepositoryMock = $this->getMock(\Magento\Eav\Api\AttributeRepositoryInterface::class); + $this->attributeRepositoryMock = $this->createMock(\Magento\Eav\Api\AttributeRepositoryInterface::class); $this->metadataPoolMock = $this->getMockBuilder(\Magento\Framework\EntityManager\MetadataPool::class) ->disableOriginalConstructor() ->getMock(); @@ -56,7 +56,7 @@ protected function setUp() */ public function testGetAttributes($entityType, $attributeSetId, $expectedCondition) { - $metadataMock = $this->getMock(\Magento\Framework\EntityManager\EntityMetadataInterface::class); + $metadataMock = $this->createMock(\Magento\Framework\EntityManager\EntityMetadataInterface::class); $metadataMock->expects($this->once()) ->method('getEavEntityType') ->willReturn($entityType); @@ -65,7 +65,7 @@ public function testGetAttributes($entityType, $attributeSetId, $expectedConditi ->with($entityType) ->willReturn($metadataMock); - $searchCriteria = $this->getMock(\Magento\Framework\Api\SearchCriteriaInterface::class); + $searchCriteria = $this->createMock(\Magento\Framework\Api\SearchCriteriaInterface::class); $this->searchCriteriaBuilderMock->expects($this->once()) ->method('addFilter') ->with( @@ -77,8 +77,8 @@ public function testGetAttributes($entityType, $attributeSetId, $expectedConditi ->method('create') ->willReturn($searchCriteria); - $attributeMock = $this->getMock(\Magento\Eav\Api\Data\AttributeInterface::class); - $searchResultMock = $this->getMock(\Magento\Eav\Api\Data\AttributeSearchResultsInterface::class); + $attributeMock = $this->createMock(\Magento\Eav\Api\Data\AttributeInterface::class); + $searchResultMock = $this->createMock(\Magento\Eav\Api\Data\AttributeSearchResultsInterface::class); $searchResultMock->expects($this->once()) ->method('getItems') ->willReturn([$attributeMock]); diff --git a/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Entity/Attribute/Option/CollectionTest.php b/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Entity/Attribute/Option/CollectionTest.php index b738edce432bf..36d2b242e9882 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Entity/Attribute/Option/CollectionTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Entity/Attribute/Option/CollectionTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Eav\Test\Unit\Model\ResourceModel\Entity\Attribute\Option; -class CollectionTest extends \PHPUnit_Framework_TestCase +class CollectionTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\Collection|\PHPUnit_Framework_MockObject_MockObject @@ -59,43 +59,15 @@ class CollectionTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->entityFactoryMock = $this->getMock( - \Magento\Framework\Data\Collection\EntityFactory::class, - [], - [], - '', - false - ); - $this->loggerMock = $this->getMock(\Psr\Log\LoggerInterface::class); - $this->fetchStrategyMock = $this->getMock( - \Magento\Framework\Data\Collection\Db\FetchStrategyInterface::class, - [], - [], - '', - false - ); - $this->eventManagerMock = $this->getMock( - \Magento\Framework\Event\ManagerInterface::class, - [], - [], - '', - false - ); - $this->coreResourceMock = $this->getMock( - \Magento\Framework\App\ResourceConnection::class, - [], - [], - '', - false - ); - $this->storeManagerMock = $this->getMock( - \Magento\Store\Model\StoreManagerInterface::class, - [], - [], - '', - false + $this->entityFactoryMock = $this->createMock(\Magento\Framework\Data\Collection\EntityFactory::class); + $this->loggerMock = $this->createMock(\Psr\Log\LoggerInterface::class); + $this->fetchStrategyMock = $this->createMock( + \Magento\Framework\Data\Collection\Db\FetchStrategyInterface::class ); - $this->connectionMock = $this->getMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, [], [], '', false); + $this->eventManagerMock = $this->createMock(\Magento\Framework\Event\ManagerInterface::class); + $this->coreResourceMock = $this->createMock(\Magento\Framework\App\ResourceConnection::class); + $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->connectionMock = $this->createMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class); $this->resourceMock = $this->getMockForAbstractClass( \Magento\Framework\Model\ResourceModel\Db\AbstractDb::class, [], @@ -105,7 +77,7 @@ protected function setUp() true, ['__wakeup', 'getConnection', 'getMainTable', 'getTable'] ); - $this->selectMock = $this->getMock(\Magento\Framework\DB\Select::class, [], [], '', false); + $this->selectMock = $this->createMock(\Magento\Framework\DB\Select::class); $this->coreResourceMock->expects($this->any())->method('getConnection')->willReturn($this->connectionMock); $this->coreResourceMock->expects($this->any())->method('getTableName')->with('eav_attribute_option_value') diff --git a/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Entity/Attribute/SetTest.php b/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Entity/Attribute/SetTest.php index 586384b052203..1c66788f8585a 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Entity/Attribute/SetTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Entity/Attribute/SetTest.php @@ -12,7 +12,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class SetTest extends \PHPUnit_Framework_TestCase +class SetTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject|Set @@ -64,17 +64,13 @@ protected function setUp() ->disableOriginalConstructor() ->setMethods(['getConnection', 'getTableName']) ->getMock(); - $this->transactionManagerMock = $this->getMock( + $this->transactionManagerMock = $this->createMock( \Magento\Framework\Model\ResourceModel\Db\TransactionManagerInterface::class ); - $this->relationProcessor = $this->getMock( - \Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor::class, - [], - [], - '', - false + $this->relationProcessor = $this->createMock( + \Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor::class ); - $contextMock = $this->getMock(\Magento\Framework\Model\ResourceModel\Db\Context::class, [], [], '', false); + $contextMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\Context::class); $contextMock->expects($this->once()) ->method('getTransactionManager') ->willReturn($this->transactionManagerMock); @@ -88,14 +84,10 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); - $this->serializerMock = $this->getMock(Json::class); + $this->serializerMock = $this->createMock(Json::class); - $attributeGroupFactoryMock = $this->getMock( - \Magento\Eav\Model\ResourceModel\Entity\Attribute\GroupFactory::class, - [], - [], - '', - false + $attributeGroupFactoryMock = $this->createMock( + \Magento\Eav\Model\ResourceModel\Entity\Attribute\GroupFactory::class ); $this->model = $objectManager->getObject( @@ -109,10 +101,8 @@ protected function setUp() $objectManager->setBackwardCompatibleProperty($this->model, 'serializer', $this->serializerMock); - $this->typeMock = $this->getMock(\Magento\Eav\Model\Entity\Type::class, [], [], '', false); - $this->objectMock = $this->getMock( - \Magento\Framework\Model\AbstractModel::class, - [ + $this->typeMock = $this->createMock(\Magento\Eav\Model\Entity\Type::class); + $this->objectMock = $this->createPartialMock(\Magento\Framework\Model\AbstractModel::class, [ 'getEntityTypeId', 'getAttributeSetId', 'beforeDelete', @@ -121,11 +111,7 @@ protected function setUp() 'afterDelete', 'afterDeleteCommit', '__wakeup' - ], - [], - '', - false - ); + ]); } /** @@ -137,12 +123,12 @@ public function testBeforeDeleteStateException() { $this->resourceMock->expects($this->any()) ->method('getConnection') - ->willReturn($this->getMock(\Magento\Framework\DB\Adapter\AdapterInterface::class)); + ->willReturn($this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class)); $this->transactionManagerMock->expects($this->once()) ->method('start') - ->with($this->getMock(\Magento\Framework\DB\Adapter\AdapterInterface::class)) - ->willReturn($this->getMock(\Magento\Framework\DB\Adapter\AdapterInterface::class)); + ->with($this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class)) + ->willReturn($this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class)); $this->objectMock->expects($this->once())->method('getEntityTypeId')->willReturn(665); $this->eavConfigMock->expects($this->once())->method('getEntityType')->with(665)->willReturn($this->typeMock); @@ -161,12 +147,12 @@ public function testBeforeDelete() { $this->resourceMock->expects($this->any()) ->method('getConnection') - ->willReturn($this->getMock(\Magento\Framework\DB\Adapter\AdapterInterface::class)); + ->willReturn($this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class)); $this->transactionManagerMock->expects($this->once()) ->method('start') - ->with($this->getMock(\Magento\Framework\DB\Adapter\AdapterInterface::class)) - ->willReturn($this->getMock(\Magento\Framework\DB\Adapter\AdapterInterface::class)); + ->with($this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class)) + ->willReturn($this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class)); $this->objectMock->expects($this->once())->method('getEntityTypeId')->willReturn(665); $this->eavConfigMock->expects($this->once())->method('getEntityType')->with(665)->willReturn($this->typeMock); diff --git a/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Entity/AttributeTest.php b/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Entity/AttributeTest.php index 09768ded496eb..9c82898dedd98 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Entity/AttributeTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Entity/AttributeTest.php @@ -13,7 +13,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class AttributeTest extends \PHPUnit_Framework_TestCase +class AttributeTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -27,14 +27,8 @@ class AttributeTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->contextMock = $this->getMock( - \Magento\Framework\Model\Context::class, - [], - [], - '', - false - ); - $eventManagerMock = $this->getMock(\Magento\Framework\Event\ManagerInterface::class); + $this->contextMock = $this->createMock(\Magento\Framework\Model\Context::class); + $eventManagerMock = $this->createMock(\Magento\Framework\Event\ManagerInterface::class); $eventManagerMock->expects($this->any())->method('dispatch'); $this->contextMock->expects($this->any())->method('getEventDispatcher')->willReturn($eventManagerMock); } @@ -60,7 +54,7 @@ public function testSaveOptionSystemAttribute() 'source_model' => \Magento\Catalog\Model\Product\Attribute\Source\Status::class, 'is_required' => 1, 'is_user_defined' => 0, - 'is_unique' => 0, + 'is_unique' => 0 ]; $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); @@ -69,9 +63,13 @@ public function testSaveOptionSystemAttribute() $arguments['data'] = $attributeData; $arguments['context'] = $this->contextMock; - $model = $this->getMock(\Magento\Framework\Model\AbstractModel::class, null, $arguments); + $model = $this->getMockBuilder(\Magento\Framework\Model\AbstractModel::class) + ->setMethods(['hasDataChanges']) + ->setConstructorArgs($arguments) + ->getMock(); $model->setDefault(['2']); $model->setOption(['delete' => [1 => '', 2 => '']]); + $model->expects($this->any())->method('hasDataChanges')->willReturn(true); $connectionMock->expects( $this->once() @@ -138,7 +136,12 @@ public function testSaveOptionNewUserDefinedAttribute() $arguments = $objectManagerHelper->getConstructArguments(\Magento\Framework\Model\AbstractModel::class); $arguments['data'] = $attributeData; $arguments['context'] = $this->contextMock; - $model = $this->getMock(\Magento\Framework\Model\AbstractModel::class, null, $arguments); + $model = $this->getMockBuilder(\Magento\Framework\Model\AbstractModel::class) + ->setMethods(['hasDataChanges']) + ->setConstructorArgs($arguments) + ->getMock(); + $model->expects($this->any())->method('hasDataChanges')->willReturn(true); + $model->setOption(['value' => ['option_1' => ['Backend Label', 'Frontend Label']]]); $connectionMock->expects( @@ -219,7 +222,11 @@ public function testSaveOptionNoValue() /** @var $model \Magento\Framework\Model\AbstractModel */ $arguments = $objectManagerHelper->getConstructArguments(\Magento\Framework\Model\AbstractModel::class); $arguments['context'] = $this->contextMock; - $model = $this->getMock(\Magento\Framework\Model\AbstractModel::class, null, $arguments); + $model = $this->getMockBuilder(\Magento\Framework\Model\AbstractModel::class) + ->setMethods(['hasDataChanges']) + ->setConstructorArgs($arguments) + ->getMock(); + $model->expects($this->any())->method('hasDataChanges')->willReturn(true); $model->setOption('not-an-array'); $connectionMock->expects($this->once())->method('insert')->with('eav_attribute'); @@ -237,9 +244,7 @@ public function testSaveOptionNoValue() */ protected function _prepareResourceModel() { - $connectionMock = $this->getMock( - \Magento\Framework\DB\Adapter\Pdo\Mysql::class, - [ + $connectionMock = $this->createPartialMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, [ '_connect', 'delete', 'describeTable', @@ -253,11 +258,7 @@ protected function _prepareResourceModel() 'rollback', 'select', 'getTransactionLevel' - ], - [], - '', - false - ); + ]); $connectionMock->expects( $this->any() )->method( @@ -281,13 +282,7 @@ protected function _prepareResourceModel() ] ) ); - $this->selectMock = $this->getMock( - \Magento\Framework\DB\Select::class, - [], - [], - '', - false - ); + $this->selectMock = $this->createMock(\Magento\Framework\DB\Select::class); $connectionMock->expects( $this->any() )->method( @@ -298,7 +293,7 @@ protected function _prepareResourceModel() $this->selectMock->expects($this->any())->method('from')->willReturnSelf(); $this->selectMock->expects($this->any())->method('where')->willReturnSelf(); - $storeManager = $this->getMock(\Magento\Store\Model\StoreManager::class, ['getStores'], [], '', false); + $storeManager = $this->createPartialMock(\Magento\Store\Model\StoreManager::class, ['getStores']); $storeManager->expects( $this->any() )->method( @@ -313,27 +308,14 @@ protected function _prepareResourceModel() ); /** @var $resource \Magento\Framework\App\ResourceConnection */ - $resource = $this->getMock( - \Magento\Framework\App\ResourceConnection::class, - [], - [], - '', - false, - false - ); + $resource = $this->createMock(\Magento\Framework\App\ResourceConnection::class); $resource->expects($this->any())->method('getTableName')->will($this->returnArgument(0)); $resource->expects($this->any())->method('getConnection')->with()->will($this->returnValue($connectionMock)); - $eavEntityType = $this->getMock(\Magento\Eav\Model\ResourceModel\Entity\Type::class, [], [], '', false, false); + $eavEntityType = $this->createMock(\Magento\Eav\Model\ResourceModel\Entity\Type::class); - $relationProcessorMock = $this->getMock( - \Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor::class, - [], - [], - '', - false - ); + $relationProcessorMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor::class); - $contextMock = $this->getMock(\Magento\Framework\Model\ResourceModel\Db\Context::class, [], [], '', false); + $contextMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\Context::class); $contextMock->expects($this->once())->method('getResources')->willReturn($resource); $contextMock->expects($this->once())->method('getObjectRelationProcessor')->willReturn($relationProcessorMock); diff --git a/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/ReadHandlerTest.php b/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/ReadHandlerTest.php index a8d65adcab55b..60c823cadfe89 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/ReadHandlerTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/ResourceModel/ReadHandlerTest.php @@ -9,7 +9,7 @@ use Magento\Framework\EntityManager\EntityMetadataInterface; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -class ReadHandlerTest extends \PHPUnit_Framework_TestCase +class ReadHandlerTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Model\Config|\PHPUnit_Framework_MockObject_MockObject diff --git a/app/code/Magento/Eav/Test/Unit/Model/Validator/Attribute/BackendTest.php b/app/code/Magento/Eav/Test/Unit/Model/Validator/Attribute/BackendTest.php index 31a227693e3a7..da8f5182addde 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Validator/Attribute/BackendTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Validator/Attribute/BackendTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Eav\Test\Unit\Model\Validator\Attribute; -class BackendTest extends \PHPUnit_Framework_TestCase +class BackendTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Eav\Model\Validator\Attribute\Backend @@ -20,7 +20,7 @@ class BackendTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->model = new \Magento\Eav\Model\Validator\Attribute\Backend(); - $this->entityMock = $this->getMock(\Magento\Framework\Model\AbstractModel::class, [], [], '', false); + $this->entityMock = $this->createMock(\Magento\Framework\Model\AbstractModel::class); } /** @@ -30,7 +30,7 @@ protected function setUp() public function testisValidIfProvidedModelIsIncorrect() { $this->model->isValid( - $this->getMock(\Magento\Framework\DataObject::class, [], [], '', false) + $this->createMock(\Magento\Framework\DataObject::class) ); } @@ -40,7 +40,7 @@ public function testisValidIfProvidedModelIsIncorrect() */ public function testisValidIfProvidedResourceModelIsIncorrect() { - $resourceMock = $this->getMock(\Magento\Framework\DataObject::class, [], [], '', false); + $resourceMock = $this->createMock(\Magento\Framework\DataObject::class); $this->entityMock->expects($this->once())->method('getResource')->willReturn($resourceMock); $this->model->isValid($this->entityMock); } @@ -48,14 +48,14 @@ public function testisValidIfProvidedResourceModelIsIncorrect() public function testisValidIfAttributeValueNotValid() { $exceptionMessage = __('The value of attribute not valid'); - $attributeMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute::class, [], [], '', false); - $resourceMock = $this->getMock(\Magento\Eav\Model\Entity\AbstractEntity::class, [], [], '', false); + $attributeMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute::class); + $resourceMock = $this->createMock(\Magento\Eav\Model\Entity\AbstractEntity::class); $this->entityMock->expects($this->once())->method('getResource')->willReturn($resourceMock); $resourceMock->expects($this->once())->method('loadAllAttributes')->with($this->entityMock)->willReturnSelf(); $resourceMock->expects($this->once())->method('getAttributesByCode')->willReturn([$attributeMock]); - $backendMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend::class); + $backendMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend::class); $attributeMock->expects($this->once())->method('getBackend')->willReturn($backendMock); $backendMock->expects($this->once()) @@ -68,14 +68,14 @@ public function testisValidIfAttributeValueNotValid() public function testisValidIfValidationResultIsFalse() { - $attributeMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute::class, [], [], '', false); - $resourceMock = $this->getMock(\Magento\Eav\Model\Entity\AbstractEntity::class, [], [], '', false); + $attributeMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute::class); + $resourceMock = $this->createMock(\Magento\Eav\Model\Entity\AbstractEntity::class); $this->entityMock->expects($this->once())->method('getResource')->willReturn($resourceMock); $resourceMock->expects($this->once())->method('loadAllAttributes')->with($this->entityMock)->willReturnSelf(); $resourceMock->expects($this->once())->method('getAttributesByCode')->willReturn([$attributeMock]); - $backendMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend::class); + $backendMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend::class); $backendMock->expects($this->once())->method('validate')->with($this->entityMock)->willReturn(false); $attributeMock->expects($this->once())->method('getBackend')->willReturn($backendMock); @@ -86,14 +86,14 @@ public function testisValidIfValidationResultIsFalse() public function testisValidIfValidationResultIsString() { - $attributeMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute::class, [], [], '', false); - $resourceMock = $this->getMock(\Magento\Eav\Model\Entity\AbstractEntity::class, [], [], '', false); + $attributeMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute::class); + $resourceMock = $this->createMock(\Magento\Eav\Model\Entity\AbstractEntity::class); $this->entityMock->expects($this->once())->method('getResource')->willReturn($resourceMock); $resourceMock->expects($this->once())->method('loadAllAttributes')->with($this->entityMock)->willReturnSelf(); $resourceMock->expects($this->once())->method('getAttributesByCode')->willReturn([$attributeMock]); - $backendMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend::class); + $backendMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend::class); $backendMock->expects($this->once())->method('validate')->with($this->entityMock)->willReturn('string'); $attributeMock->expects($this->once())->method('getBackend')->willReturn($backendMock); @@ -104,14 +104,14 @@ public function testisValidIfValidationResultIsString() public function testisValidSuccess() { - $attributeMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute::class, [], [], '', false); - $resourceMock = $this->getMock(\Magento\Eav\Model\Entity\AbstractEntity::class, [], [], '', false); + $attributeMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute::class); + $resourceMock = $this->createMock(\Magento\Eav\Model\Entity\AbstractEntity::class); $this->entityMock->expects($this->once())->method('getResource')->willReturn($resourceMock); $resourceMock->expects($this->once())->method('loadAllAttributes')->with($this->entityMock)->willReturnSelf(); $resourceMock->expects($this->once())->method('getAttributesByCode')->willReturn([$attributeMock]); - $backendMock = $this->getMock(\Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend::class); + $backendMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend::class); $backendMock->expects($this->once())->method('validate')->with($this->entityMock)->willReturn(true); $attributeMock->expects($this->once())->method('getBackend')->willReturn($backendMock); diff --git a/app/code/Magento/Eav/Test/Unit/Model/Validator/Attribute/DataTest.php b/app/code/Magento/Eav/Test/Unit/Model/Validator/Attribute/DataTest.php index 072d64e9d803c..07ce6fbfc6a4c 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Validator/Attribute/DataTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Validator/Attribute/DataTest.php @@ -9,7 +9,7 @@ */ namespace Magento\Eav\Test\Unit\Model\Validator\Attribute; -class DataTest extends \PHPUnit_Framework_TestCase +class DataTest extends \PHPUnit\Framework\TestCase { /** * Testing \Magento\Eav\Model\Validator\Attribute\Data::isValid @@ -31,14 +31,15 @@ public function testIsValid( ) { $entity = $this->_getEntityMock(); $attribute = $this->_getAttributeMock($attributeData); - $attrDataFactory = $this->getMock( - \Magento\Eav\Model\AttributeDataFactory::class, - ['create'], - [ - 'objectManager' => $this->getMock(\Magento\Framework\ObjectManagerInterface::class), - 'string' => $this->getMock(\Magento\Framework\Stdlib\StringUtils::class) - ] - ); + $attrDataFactory = $this->getMockBuilder(\Magento\Eav\Model\AttributeDataFactory::class) + ->setMethods(['create']) + ->setConstructorArgs( + [ + 'objectManager' => $this->createMock(\Magento\Framework\ObjectManagerInterface::class), + 'string' => $this->createMock(\Magento\Framework\Stdlib\StringUtils::class) + ] + ) + ->getMock(); $validator = new \Magento\Eav\Model\Validator\Attribute\Data($attrDataFactory); $validator->setAttributes([$attribute])->setData($data); @@ -167,14 +168,15 @@ public function testIsValidAttributesFromCollection() $entity->expects($this->once())->method('getResource')->will($this->returnValue($resource)); $entity->expects($this->once())->method('getEntityType')->will($this->returnValue($entityType)); $dataModel = $this->_getDataModelMock(true); - $attrDataFactory = $this->getMock( - \Magento\Eav\Model\AttributeDataFactory::class, - ['create'], - [ - 'objectManager' => $this->getMock(\Magento\Framework\ObjectManagerInterface::class), - 'string' => $this->getMock(\Magento\Framework\Stdlib\StringUtils::class) - ] - ); + $attrDataFactory = $this->getMockBuilder(\Magento\Eav\Model\AttributeDataFactory::class) + ->setMethods(['create']) + ->setConstructorArgs( + [ + 'objectManager' => $this->createMock(\Magento\Framework\ObjectManagerInterface::class), + 'string' => $this->createMock(\Magento\Framework\Stdlib\StringUtils::class) + ] + ) + ->getMock(); $attrDataFactory->expects( $this->once() )->method( @@ -216,14 +218,16 @@ public function testIsValidBlackListWhiteListChecks($callback) $data = ['attribute' => 'new_test_data', 'attribute2' => 'some data']; $entity = $this->_getEntityMock(); $dataModel = $this->_getDataModelMock(true, $data['attribute']); - $attrDataFactory = $this->getMock( - \Magento\Eav\Model\AttributeDataFactory::class, - ['create'], - [ - 'objectManager' => $this->getMock(\Magento\Framework\ObjectManagerInterface::class), - 'string' => $this->getMock(\Magento\Framework\Stdlib\StringUtils::class) - ] - ); + $attrDataFactory = $this->getMockBuilder(\Magento\Eav\Model\AttributeDataFactory::class) + ->setMethods(['create']) + ->setConstructorArgs( + [ + 'objectManager' => $this->createMock(\Magento\Framework\ObjectManagerInterface::class), + 'string' => $this->createMock(\Magento\Framework\Stdlib\StringUtils::class) + ] + ) + ->getMock(); + $attrDataFactory->expects( $this->once() )->method( @@ -258,14 +262,14 @@ public function whiteBlackListProvider() public function testSetAttributesWhiteList() { $attributes = ['attr1', 'attr2', 'attr3']; - $attrDataFactory = $this->getMock( - \Magento\Eav\Model\AttributeDataFactory::class, - [], - [ - 'objectManager' => $this->getMock(\Magento\Framework\ObjectManagerInterface::class), - 'string' => $this->getMock(\Magento\Framework\Stdlib\StringUtils::class) - ] - ); + $attrDataFactory = $this->getMockBuilder(\Magento\Eav\Model\AttributeDataFactory::class) + ->setConstructorArgs( + [ + 'objectManager' => $this->createMock(\Magento\Framework\ObjectManagerInterface::class), + 'string' => $this->createMock(\Magento\Framework\Stdlib\StringUtils::class) + ] + ) + ->getMock(); $validator = new \Magento\Eav\Model\Validator\Attribute\Data($attrDataFactory); $result = $validator->setAttributesWhiteList($attributes); $this->assertAttributeEquals($attributes, '_attributesWhiteList', $validator); @@ -275,14 +279,14 @@ public function testSetAttributesWhiteList() public function testSetAttributesBlackList() { $attributes = ['attr1', 'attr2', 'attr3']; - $attrDataFactory = $this->getMock( - \Magento\Eav\Model\AttributeDataFactory::class, - [], - [ - 'objectManager' => $this->getMock(\Magento\Framework\ObjectManagerInterface::class), - 'string' => $this->getMock(\Magento\Framework\Stdlib\StringUtils::class) - ] - ); + $attrDataFactory = $this->getMockBuilder(\Magento\Eav\Model\AttributeDataFactory::class) + ->setConstructorArgs( + [ + 'objectManager' => $this->createMock(\Magento\Framework\ObjectManagerInterface::class), + 'string' => $this->createMock(\Magento\Framework\Stdlib\StringUtils::class) + ] + ) + ->getMock(); $validator = new \Magento\Eav\Model\Validator\Attribute\Data($attrDataFactory); $result = $validator->setAttributesBlackList($attributes); $this->assertAttributeEquals($attributes, '_attributesBlackList', $validator); @@ -311,14 +315,15 @@ public function testAddErrorMessages() ); $expectedMessages = ['attribute1' => ['Error1'], 'attribute2' => ['Error2']]; $expectedDouble = ['attribute1' => ['Error1', 'Error1'], 'attribute2' => ['Error2', 'Error2']]; - $factory = $this->getMock( - \Magento\Eav\Model\AttributeDataFactory::class, - ['create'], - [ - 'objectManager' => $this->getMock(\Magento\Framework\ObjectManagerInterface::class), - 'string' => $this->getMock(\Magento\Framework\Stdlib\StringUtils::class) - ] - ); + $factory = $this->getMockBuilder(\Magento\Eav\Model\AttributeDataFactory::class) + ->setMethods(['create']) + ->setConstructorArgs( + [ + 'objectManager' => $this->createMock(\Magento\Framework\ObjectManagerInterface::class), + 'string' => $this->createMock(\Magento\Framework\Stdlib\StringUtils::class) + ] + ) + ->getMock(); $validator = new \Magento\Eav\Model\Validator\Attribute\Data($factory); $validator->setAttributes([$firstAttribute, $secondAttribute])->setData($data); diff --git a/app/code/Magento/Eav/Test/Unit/Plugin/Model/ResourceModel/Entity/AttributeTest.php b/app/code/Magento/Eav/Test/Unit/Plugin/Model/ResourceModel/Entity/AttributeTest.php index dfe71bb1c143b..0f3325a3295a6 100644 --- a/app/code/Magento/Eav/Test/Unit/Plugin/Model/ResourceModel/Entity/AttributeTest.php +++ b/app/code/Magento/Eav/Test/Unit/Plugin/Model/ResourceModel/Entity/AttributeTest.php @@ -14,7 +14,7 @@ use Magento\Eav\Model\Cache\Type; use Magento\Eav\Model\Entity\Attribute; -class AttributeTest extends \PHPUnit_Framework_TestCase +class AttributeTest extends \PHPUnit\Framework\TestCase { /** * @var CacheInterface|\PHPUnit_Framework_MockObject_MockObject @@ -44,10 +44,10 @@ class AttributeTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new ObjectManager($this); - $this->cacheMock = $this->getMock(CacheInterface::class); - $this->cacheStateMock = $this->getMock(StateInterface::class); - $this->attributeResourceMock = $this->getMock(AttributeResource::class, [], [], '', false); - $this->serializerMock = $this->getMock(SerializerInterface::class); + $this->cacheMock = $this->createMock(CacheInterface::class); + $this->cacheStateMock = $this->createMock(StateInterface::class); + $this->attributeResourceMock = $this->createMock(AttributeResource::class); + $this->serializerMock = $this->createMock(SerializerInterface::class); $this->attributeResourcePlugin = $objectManager->getObject( AttributeResourcePlugin::class, [ diff --git a/app/code/Magento/Eav/etc/module.xml b/app/code/Magento/Eav/etc/module.xml index 3169cb4e89a49..acd5807a29f90 100644 --- a/app/code/Magento/Eav/etc/module.xml +++ b/app/code/Magento/Eav/etc/module.xml @@ -6,7 +6,7 @@ */ --> - + diff --git a/app/code/Magento/Email/Block/Adminhtml/Template.php b/app/code/Magento/Email/Block/Adminhtml/Template.php index b68c7ae4e8f78..e12a5f15ad624 100644 --- a/app/code/Magento/Email/Block/Adminhtml/Template.php +++ b/app/code/Magento/Email/Block/Adminhtml/Template.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class Template extends \Magento\Backend\Block\Template implements \Magento\Backend\Block\Widget\ContainerInterface { diff --git a/app/code/Magento/Email/Block/Adminhtml/Template/Preview.php b/app/code/Magento/Email/Block/Adminhtml/Template/Preview.php index b9332e65768c0..5f22a36510c4e 100644 --- a/app/code/Magento/Email/Block/Adminhtml/Template/Preview.php +++ b/app/code/Magento/Email/Block/Adminhtml/Template/Preview.php @@ -13,6 +13,7 @@ /** * @api + * @since 100.0.2 */ class Preview extends \Magento\Backend\Block\Widget { diff --git a/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Preview.php b/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Preview.php index 3cce977fbe542..e23cd6cf17eb2 100644 --- a/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Preview.php +++ b/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Preview.php @@ -19,6 +19,7 @@ public function execute() $this->_view->loadLayout(); $this->_view->getPage()->getConfig()->getTitle()->prepend(__('Email Preview')); $this->_view->renderLayout(); + $this->getResponse()->setHeader('Content-Security-Policy', "script-src 'none'"); } catch (\Exception $e) { $this->messageManager->addError(__('An error occurred. The email template can not be opened for preview.')); $this->_redirect('adminhtml/*/'); diff --git a/app/code/Magento/Email/Model/AbstractTemplate.php b/app/code/Magento/Email/Model/AbstractTemplate.php index 6660cac4b6202..fa9d28074bf85 100644 --- a/app/code/Magento/Email/Model/AbstractTemplate.php +++ b/app/code/Magento/Email/Model/AbstractTemplate.php @@ -21,6 +21,7 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.TooManyFields) * @api + * @since 100.0.2 */ abstract class AbstractTemplate extends AbstractModel implements TemplateTypesInterface { diff --git a/app/code/Magento/Email/Model/BackendTemplate.php b/app/code/Magento/Email/Model/BackendTemplate.php index 9e6b7914ca9fe..4e6a25c54303e 100644 --- a/app/code/Magento/Email/Model/BackendTemplate.php +++ b/app/code/Magento/Email/Model/BackendTemplate.php @@ -13,6 +13,7 @@ * @api * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class BackendTemplate extends Template { diff --git a/app/code/Magento/Email/Model/Mail/TransportInterfacePlugin.php b/app/code/Magento/Email/Model/Mail/TransportInterfacePlugin.php index e1bab0bc57ece..b5c2ab67ac95e 100644 --- a/app/code/Magento/Email/Model/Mail/TransportInterfacePlugin.php +++ b/app/code/Magento/Email/Model/Mail/TransportInterfacePlugin.php @@ -10,13 +10,13 @@ use Magento\Framework\Mail\TransportInterface; use Magento\Store\Model\ScopeInterface; +/** + * Plugin over \Magento\Framework\Mail\TransportInterface + * + * It disables email sending depending on the system configuration settings + */ class TransportInterfacePlugin { - /** - * Config path to mail sending setting that shows if email communications are disabled - */ - const XML_PATH_SYSTEM_SMTP_DISABLE = 'system/smtp/disable'; - /** * @var ScopeConfigInterface */ @@ -32,7 +32,7 @@ public function __construct( } /** - * Omit email sending if disabled + * Omit email sending depending on the system configuration setting * * @param TransportInterface $subject * @param \Closure $proceed @@ -44,7 +44,7 @@ public function aroundSendMessage( TransportInterface $subject, \Closure $proceed ) { - if (!$this->scopeConfig->isSetFlag(self::XML_PATH_SYSTEM_SMTP_DISABLE, ScopeInterface::SCOPE_STORE)) { + if (!$this->scopeConfig->isSetFlag('system/smtp/disable', ScopeInterface::SCOPE_STORE)) { $proceed(); } } diff --git a/app/code/Magento/Email/Model/ResourceModel/Template.php b/app/code/Magento/Email/Model/ResourceModel/Template.php index 030705bf7b419..ef1667f0670ec 100644 --- a/app/code/Magento/Email/Model/ResourceModel/Template.php +++ b/app/code/Magento/Email/Model/ResourceModel/Template.php @@ -11,6 +11,7 @@ * Template db resource * * @api + * @since 100.0.2 */ class Template extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { diff --git a/app/code/Magento/Email/Model/ResourceModel/Template/Collection.php b/app/code/Magento/Email/Model/ResourceModel/Template/Collection.php index b13f878e2bc65..d1f752e217302 100644 --- a/app/code/Magento/Email/Model/ResourceModel/Template/Collection.php +++ b/app/code/Magento/Email/Model/ResourceModel/Template/Collection.php @@ -9,6 +9,7 @@ * Templates collection * * @api + * @since 100.0.2 */ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { diff --git a/app/code/Magento/Email/Model/Template.php b/app/code/Magento/Email/Model/Template.php index 37beca03c9de9..8724b725ae489 100644 --- a/app/code/Magento/Email/Model/Template.php +++ b/app/code/Magento/Email/Model/Template.php @@ -10,8 +10,6 @@ /** * Template model * - * @method \Magento\Email\Model\ResourceModel\Template _getResource() - * @method \Magento\Email\Model\ResourceModel\Template getResource() * @method string getTemplateCode() * @method \Magento\Email\Model\Template setTemplateCode(string $value) * @method string getTemplateText() @@ -38,20 +36,27 @@ * @api * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class Template extends AbstractTemplate implements \Magento\Framework\Mail\TemplateInterface { /** - * Configuration path for default email templates + * Configuration path to source of Return-Path and whether it should be set at all + * @deprecated + * @see \Magento\Email\Model\Transport::XML_PATH_SENDING_SET_RETURN_PATH */ const XML_PATH_SENDING_SET_RETURN_PATH = 'system/smtp/set_return_path'; + /** + * Configuration path for custom Return-Path email + * @deprecated + * @see \Magento\Email\Model\Transport::XML_PATH_SENDING_RETURN_PATH_EMAIL + */ const XML_PATH_SENDING_RETURN_PATH_EMAIL = 'system/smtp/return_path_email'; /** * Config path to mail sending setting that shows if email communications are disabled * @deprecated - * @see \Magento\Email\Model\Mail\TransportInterfacePlugin::XML_PATH_SYSTEM_SMTP_DISABLE */ const XML_PATH_SYSTEM_SMTP_DISABLE = 'system/smtp/disable'; diff --git a/app/code/Magento/Email/Model/Template/Filter.php b/app/code/Magento/Email/Model/Template/Filter.php index b3784d295cc4e..3d479d20e4f51 100644 --- a/app/code/Magento/Email/Model/Template/Filter.php +++ b/app/code/Magento/Email/Model/Template/Filter.php @@ -18,6 +18,7 @@ * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class Filter extends \Magento\Framework\Filter\Template { @@ -149,9 +150,15 @@ class Filter extends \Magento\Framework\Filter\Template /** * @var \Pelago\Emogrifier + * @deprecated */ protected $emogrifier; + /** + * @var \Magento\Framework\Css\PreProcessor\Adapter\CssInliner + */ + private $cssInliner; + /** * @var \Magento\Email\Model\Source\Variables */ @@ -182,6 +189,7 @@ class Filter extends \Magento\Framework\Filter\Template * @param \Pelago\Emogrifier $emogrifier * @param \Magento\Email\Model\Source\Variables $configVariables * @param array $variables + * @param \Magento\Framework\Css\PreProcessor\Adapter\CssInliner|null $cssInliner * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -199,7 +207,8 @@ public function __construct( \Magento\Framework\UrlInterface $urlModel, \Pelago\Emogrifier $emogrifier, \Magento\Email\Model\Source\Variables $configVariables, - $variables = [] + $variables = [], + \Magento\Framework\Css\PreProcessor\Adapter\CssInliner $cssInliner = null ) { $this->_escaper = $escaper; $this->_assetRepo = $assetRepo; @@ -213,6 +222,8 @@ public function __construct( $this->_appState = $appState; $this->urlModel = $urlModel; $this->emogrifier = $emogrifier; + $this->cssInliner = $cssInliner ?: \Magento\Framework\App\ObjectManager::getInstance() + ->get(\Magento\Framework\Css\PreProcessor\Adapter\CssInliner::class); $this->configVariables = $configVariables; parent::__construct($string, $variables); } @@ -310,7 +321,7 @@ public function setDesignParams(array $designParams) } /** - * @deprecated + * @deprecated 100.1.2 * @return Css\Processor */ private function getCssProcessor() @@ -322,7 +333,7 @@ private function getCssProcessor() } /** - * @deprecated + * @deprecated 100.1.2 * @param string $dirType * @return ReadInterface */ @@ -974,14 +985,14 @@ public function applyInlineCss($html) ); } - $emogrifier = $this->emogrifier; - $emogrifier->setHtml($html); - $emogrifier->setCss($cssToInline); + $this->cssInliner->setHtml($html); + + $this->cssInliner->setCss($cssToInline); // Don't parse inline ",rE:true,sL:"css"}},{cN:"tag",b:"|$)",e:">",k:{title:"script"},c:[b],starts:{e:"<\/script>",rE:true,sL:"javascript"}},{b:"<%",e:"%>",sL:"vbscript"},{cN:"tag",b:"",c:[{cN:"title",b:"[^ />]+"},b]}]}}(hljs);hljs.LANGUAGES.json=function(a){var e={literal:"true false null"};var d=[a.QSM,a.CNM];var c={cN:"value",e:",",eW:true,eE:true,c:d,k:e};var b={b:"{",e:"}",c:[{cN:"attribute",b:'\\s*"',e:'"\\s*:\\s*',eB:true,eE:true,c:[a.BE],i:"\\n",starts:c}],i:"\\S"};var f={b:"\\[",e:"\\]",c:[a.inherit(c,{cN:null})],i:"\\S"};d.splice(d.length,0,b,f);return{c:d,k:e,i:"\\S"}}(hljs); \ No newline at end of file diff --git a/app/code/Magento/Swagger/view/frontend/web/swagger-ui/js/lib/highlight.9.1.0.pack.js b/app/code/Magento/Swagger/view/frontend/web/swagger-ui/js/lib/highlight.9.1.0.pack.js new file mode 100644 index 0000000000000..7b00c68d36561 --- /dev/null +++ b/app/code/Magento/Swagger/view/frontend/web/swagger-ui/js/lib/highlight.9.1.0.pack.js @@ -0,0 +1 @@ +!function(e){"undefined"!=typeof exports?e(exports):(self.hljs=e({}),"function"==typeof define&&define.amd&&define("hljs",[],function(){return self.hljs}))}(function(e){function r(e){return e.replace(/&/gm,"&").replace(//gm,">")}function t(e){return e.nodeName.toLowerCase()}function n(e,r){var t=e&&e.exec(r);return t&&0==t.index}function a(e){return/^(no-?highlight|plain|text)$/i.test(e)}function c(e){var r,t,n,c=e.className+" ";if(c+=e.parentNode?e.parentNode.className:"",t=/\blang(?:uage)?-([\w-]+)\b/i.exec(c))return E(t[1])?t[1]:"no-highlight";for(c=c.split(/\s+/),r=0,n=c.length;n>r;r++)if(E(c[r])||a(c[r]))return c[r]}function i(e,r){var t,n={};for(t in e)n[t]=e[t];if(r)for(t in r)n[t]=r[t];return n}function o(e){var r=[];return function n(e,a){for(var c=e.firstChild;c;c=c.nextSibling)3==c.nodeType?a+=c.nodeValue.length:1==c.nodeType&&(r.push({event:"start",offset:a,node:c}),a=n(c,a),t(c).match(/br|hr|img|input/)||r.push({event:"stop",offset:a,node:c}));return a}(e,0),r}function s(e,n,a){function c(){return e.length&&n.length?e[0].offset!=n[0].offset?e[0].offset"}function o(e){l+=""}function s(e){("start"==e.event?i:o)(e.node)}for(var u=0,l="",f=[];e.length||n.length;){var b=c();if(l+=r(a.substr(u,b[0].offset-u)),u=b[0].offset,b==e){f.reverse().forEach(o);do s(b.splice(0,1)[0]),b=c();while(b==e&&b.length&&b[0].offset==u);f.reverse().forEach(i)}else"start"==b[0].event?f.push(b[0].node):f.pop(),s(b.splice(0,1)[0])}return l+r(a.substr(u))}function u(e){function r(e){return e&&e.source||e}function t(t,n){return new RegExp(r(t),"m"+(e.cI?"i":"")+(n?"g":""))}function n(a,c){if(!a.compiled){if(a.compiled=!0,a.k=a.k||a.bK,a.k){var o={},s=function(r,t){e.cI&&(t=t.toLowerCase()),t.split(" ").forEach(function(e){var t=e.split("|");o[t[0]]=[r,t[1]?Number(t[1]):1]})};"string"==typeof a.k?s("keyword",a.k):Object.keys(a.k).forEach(function(e){s(e,a.k[e])}),a.k=o}a.lR=t(a.l||/\b\w+\b/,!0),c&&(a.bK&&(a.b="\\b("+a.bK.split(" ").join("|")+")\\b"),a.b||(a.b=/\B|\b/),a.bR=t(a.b),a.e||a.eW||(a.e=/\B|\b/),a.e&&(a.eR=t(a.e)),a.tE=r(a.e)||"",a.eW&&c.tE&&(a.tE+=(a.e?"|":"")+c.tE)),a.i&&(a.iR=t(a.i)),void 0===a.r&&(a.r=1),a.c||(a.c=[]);var u=[];a.c.forEach(function(e){e.v?e.v.forEach(function(r){u.push(i(e,r))}):u.push("self"==e?a:e)}),a.c=u,a.c.forEach(function(e){n(e,a)}),a.starts&&n(a.starts,c);var l=a.c.map(function(e){return e.bK?"\\.?("+e.b+")\\.?":e.b}).concat([a.tE,a.i]).map(r).filter(Boolean);a.t=l.length?t(l.join("|"),!0):{exec:function(){return null}}}}n(e)}function l(e,t,a,c){function i(e,r){for(var t=0;t";return c+=e+'">',c+r+i}function p(){if(!M.k)return r(B);var e="",t=0;M.lR.lastIndex=0;for(var n=M.lR.exec(B);n;){e+=r(B.substr(t,n.index-t));var a=b(M,n);a?(L+=a[1],e+=g(a[0],r(n[0]))):e+=r(n[0]),t=M.lR.lastIndex,n=M.lR.exec(B)}return e+r(B.substr(t))}function h(){var e="string"==typeof M.sL;if(e&&!y[M.sL])return r(B);var t=e?l(M.sL,B,!0,R[M.sL]):f(B,M.sL.length?M.sL:void 0);return M.r>0&&(L+=t.r),e&&(R[M.sL]=t.top),g(t.language,t.value,!1,!0)}function d(){return void 0!==M.sL?h():p()}function m(e,t){var n=e.cN?g(e.cN,"",!0):"";e.rB?(x+=n,B=""):e.eB?(x+=r(t)+n,B=""):(x+=n,B=t),M=Object.create(e,{parent:{value:M}})}function v(e,t){if(B+=e,void 0===t)return x+=d(),0;var n=i(t,M);if(n)return x+=d(),m(n,t),n.rB?0:t.length;var a=o(M,t);if(a){var c=M;c.rE||c.eE||(B+=t),x+=d();do M.cN&&(x+=""),L+=M.r,M=M.parent;while(M!=a.parent);return c.eE&&(x+=r(t)),B="",a.starts&&m(a.starts,""),c.rE?0:t.length}if(s(t,M))throw new Error('Illegal lexeme "'+t+'" for mode "'+(M.cN||"")+'"');return B+=t,t.length||1}var N=E(e);if(!N)throw new Error('Unknown language: "'+e+'"');u(N);var C,M=c||N,R={},x="";for(C=M;C!=N;C=C.parent)C.cN&&(x=g(C.cN,"",!0)+x);var B="",L=0;try{for(var S,A,k=0;M.t.lastIndex=k,S=M.t.exec(t),S;)A=v(t.substr(k,S.index-k),S[0]),k=S.index+A;for(v(t.substr(k)),C=M;C.parent;C=C.parent)C.cN&&(x+="");return{r:L,value:x,language:e,top:M}}catch(I){if(-1!=I.message.indexOf("Illegal"))return{r:0,value:r(t)};throw I}}function f(e,t){t=t||w.languages||Object.keys(y);var n={r:0,value:r(e)},a=n;return t.forEach(function(r){if(E(r)){var t=l(r,e,!1);t.language=r,t.r>a.r&&(a=t),t.r>n.r&&(a=n,n=t)}}),a.language&&(n.second_best=a),n}function b(e){return w.tabReplace&&(e=e.replace(/^((<[^>]+>|\t)+)/gm,function(e,r){return r.replace(/\t/g,w.tabReplace)})),w.useBR&&(e=e.replace(/\n/g,"
")),e}function g(e,r,t){var n=r?C[r]:t,a=[e.trim()];return e.match(/\bhljs\b/)||a.push("hljs"),-1===e.indexOf(n)&&a.push(n),a.join(" ").trim()}function p(e){var r=c(e);if(!a(r)){var t;w.useBR?(t=document.createElementNS("http://www.w3.org/1999/xhtml","div"),t.innerHTML=e.innerHTML.replace(/\n/g,"").replace(//g,"\n")):t=e;var n=t.textContent,i=r?l(r,n,!0):f(n),u=o(t);if(u.length){var p=document.createElementNS("http://www.w3.org/1999/xhtml","div");p.innerHTML=i.value,i.value=s(u,o(p),n)}i.value=b(i.value),e.innerHTML=i.value,e.className=g(e.className,r,i.language),e.result={language:i.language,re:i.r},i.second_best&&(e.second_best={language:i.second_best.language,re:i.second_best.r})}}function h(e){w=i(w,e)}function d(){if(!d.called){d.called=!0;var e=document.querySelectorAll("pre code");Array.prototype.forEach.call(e,p)}}function m(){addEventListener("DOMContentLoaded",d,!1),addEventListener("load",d,!1)}function v(r,t){var n=y[r]=t(e);n.aliases&&n.aliases.forEach(function(e){C[e]=r})}function N(){return Object.keys(y)}function E(e){return e=(e||"").toLowerCase(),y[e]||y[C[e]]}var w={classPrefix:"hljs-",tabReplace:null,useBR:!1,languages:void 0},y={},C={};return e.highlight=l,e.highlightAuto=f,e.fixMarkup=b,e.highlightBlock=p,e.configure=h,e.initHighlighting=d,e.initHighlightingOnLoad=m,e.registerLanguage=v,e.listLanguages=N,e.getLanguage=E,e.inherit=i,e.IR="[a-zA-Z]\\w*",e.UIR="[a-zA-Z_]\\w*",e.NR="\\b\\d+(\\.\\d+)?",e.CNR="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",e.BNR="\\b(0b[01]+)",e.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",e.BE={b:"\\\\[\\s\\S]",r:0},e.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[e.BE]},e.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[e.BE]},e.PWM={b:/\b(a|an|the|are|I|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|like)\b/},e.C=function(r,t,n){var a=e.inherit({cN:"comment",b:r,e:t,c:[]},n||{});return a.c.push(e.PWM),a.c.push({cN:"doctag",b:"(?:TODO|FIXME|NOTE|BUG|XXX):",r:0}),a},e.CLCM=e.C("//","$"),e.CBCM=e.C("/\\*","\\*/"),e.HCM=e.C("#","$"),e.NM={cN:"number",b:e.NR,r:0},e.CNM={cN:"number",b:e.CNR,r:0},e.BNM={cN:"number",b:e.BNR,r:0},e.CSSNM={cN:"number",b:e.NR+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",r:0},e.RM={cN:"regexp",b:/\//,e:/\/[gimuy]*/,i:/\n/,c:[e.BE,{b:/\[/,e:/\]/,r:0,c:[e.BE]}]},e.TM={cN:"title",b:e.IR,r:0},e.UTM={cN:"title",b:e.UIR,r:0},e}),hljs.registerLanguage("json",function(e){var r={literal:"true false null"},t=[e.QSM,e.CNM],n={e:",",eW:!0,eE:!0,c:t,k:r},a={b:"{",e:"}",c:[{cN:"attr",b:'\\s*"',e:'"\\s*:\\s*',eB:!0,eE:!0,c:[e.BE],i:"\\n",starts:n}],i:"\\S"},c={b:"\\[",e:"\\]",c:[e.inherit(n)],i:"\\S"};return t.splice(t.length,0,a,c),{c:t,k:r,i:"\\S"}}),hljs.registerLanguage("xml",function(e){var r="[A-Za-z0-9\\._:-]+",t={b:/<\?(php)?(?!\w)/,e:/\?>/,sL:"php"},n={eW:!0,i:/]+/}]}]}]};return{aliases:["html","xhtml","rss","atom","xsl","plist"],cI:!0,c:[{cN:"meta",b:"",r:10,c:[{b:"\\[",e:"\\]"}]},e.C("",{r:10}),{b:"<\\!\\[CDATA\\[",e:"\\]\\]>",r:10},{cN:"tag",b:"|$)",e:">",k:{name:"style"},c:[n],starts:{e:"",rE:!0,sL:["css","xml"]}},{cN:"tag",b:"|$)",e:">",k:{name:"script"},c:[n],starts:{e:"",rE:!0,sL:["actionscript","javascript","handlebars","xml"]}},t,{cN:"meta",b:/<\?\w+/,e:/\?>/,r:10},{cN:"tag",b:"",c:[{cN:"name",b:/[^\/><\s]+/,r:0},n]}]}}),hljs.registerLanguage("javascript",function(e){return{aliases:["js"],k:{keyword:"in of if for while finally var new function do return void else break catch instanceof with throw case default try this switch continue typeof delete let yield const export super debugger as async await import from as",literal:"true false null undefined NaN Infinity",built_in:"eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError Number Math Date String RegExp Array Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require module console window document Symbol Set Map WeakSet WeakMap Proxy Reflect Promise"},c:[{cN:"meta",r:10,b:/^\s*['"]use (strict|asm)['"]/},{cN:"meta",b:/^#!/,e:/$/},e.ASM,e.QSM,{cN:"string",b:"`",e:"`",c:[e.BE,{cN:"subst",b:"\\$\\{",e:"\\}"}]},e.CLCM,e.CBCM,{cN:"number",v:[{b:"\\b(0[bB][01]+)"},{b:"\\b(0[oO][0-7]+)"},{b:e.CNR}],r:0},{b:"("+e.RSR+"|\\b(case|return|throw)\\b)\\s*",k:"return throw case",c:[e.CLCM,e.CBCM,e.RM,{b:/\s*[);\]]/,r:0,sL:"xml"}],r:0},{cN:"function",bK:"function",e:/\{/,eE:!0,c:[e.inherit(e.TM,{b:/[A-Za-z$_][0-9A-Za-z$_]*/}),{cN:"params",b:/\(/,e:/\)/,eB:!0,eE:!0,c:[e.CLCM,e.CBCM]}],i:/\[|%/},{b:/\$[(.]/},{b:"\\."+e.IR,r:0},{cN:"class",bK:"class",e:/[{;=]/,eE:!0,i:/[:"\[\]]/,c:[{bK:"extends"},e.UTM]},{bK:"constructor",e:/\{/,eE:!0}],i:/#(?!!)/}}),hljs.registerLanguage("css",function(e){var r="[a-zA-Z-][a-zA-Z0-9_-]*",t={b:/[A-Z\_\.\-]+\s*:/,rB:!0,e:";",eW:!0,c:[{cN:"attribute",b:/\S/,e:":",eE:!0,starts:{eW:!0,eE:!0,c:[{b:/[\w-]+\s*\(/,rB:!0,c:[{cN:"built_in",b:/[\w-]+/}]},e.CSSNM,e.QSM,e.ASM,e.CBCM,{cN:"number",b:"#[0-9A-Fa-f]+"},{cN:"meta",b:"!important"}]}}]};return{cI:!0,i:/[=\/|'\$]/,c:[e.CBCM,{cN:"selector-id",b:/#[A-Za-z0-9_-]+/},{cN:"selector-class",b:/\.[A-Za-z0-9_-]+/},{cN:"selector-attr",b:/\[/,e:/\]/,i:"$"},{cN:"selector-pseudo",b:/:(:)?[a-zA-Z0-9\_\-\+\(\)"'.]+/},{b:"@(font-face|page)",l:"[a-z-]+",k:"font-face page"},{b:"@",e:"[{;]",c:[{cN:"keyword",b:/\S+/},{b:/\s/,eW:!0,eE:!0,r:0,c:[e.ASM,e.QSM,e.CSSNM]}]},{cN:"selector-tag",b:r,r:0},{b:"{",e:"}",i:/\S/,c:[e.CBCM,t]}]}}); \ No newline at end of file diff --git a/app/code/Magento/Swagger/view/frontend/web/swagger-ui/js/lib/highlight.9.1.0.pack_extended.js b/app/code/Magento/Swagger/view/frontend/web/swagger-ui/js/lib/highlight.9.1.0.pack_extended.js new file mode 100644 index 0000000000000..162a224ddd604 --- /dev/null +++ b/app/code/Magento/Swagger/view/frontend/web/swagger-ui/js/lib/highlight.9.1.0.pack_extended.js @@ -0,0 +1 @@ +"use strict";!function(){var h,l;h=hljs.configure,hljs.configure=function(l){var i=l.highlightSizeThreshold;hljs.highlightSizeThreshold=i===+i?i:null,h.call(this,l)},l=hljs.highlightBlock,hljs.highlightBlock=function(h){var i=h.innerHTML,g=hljs.highlightSizeThreshold;(null==g||g>i.length)&&l.call(hljs,h)}}(); \ No newline at end of file diff --git a/app/code/Magento/Swagger/view/frontend/web/swagger-ui/js/lib/jsoneditor.min.js b/app/code/Magento/Swagger/view/frontend/web/swagger-ui/js/lib/jsoneditor.min.js new file mode 100644 index 0000000000000..21db1ab3e112a --- /dev/null +++ b/app/code/Magento/Swagger/view/frontend/web/swagger-ui/js/lib/jsoneditor.min.js @@ -0,0 +1,5 @@ +!function(){var t;!function(){var e=!1,i=/xyz/.test(function(){window.postMessage("xyz")})?/\b_super\b/:/.*/;return t=function(){},t.extend=function(t){function s(){!e&&this.init&&this.init.apply(this,arguments)}var r=this.prototype;e=!0;var n=new this;e=!1;for(var o in t)n[o]="function"==typeof t[o]&&"function"==typeof r[o]&&i.test(t[o])?function(t,e){return function(){var i=this._super;this._super=r[t];var s=e.apply(this,arguments);return this._super=i,s}}(o,t[o]):t[o];return s.prototype=n,s.prototype.constructor=s,s.extend=arguments.callee,s},t}(),function(){function t(t,e){e=e||{bubbles:!1,cancelable:!1,detail:void 0};var i=document.createEvent("CustomEvent");return i.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),i}t.prototype=window.Event.prototype,window.CustomEvent=t}(),function(){for(var t=0,e=["ms","moz","webkit","o"],i=0;i0&&t.length-1 in t){for(i=0;i=o&&!a&&(a=!0,e())})}},s.send()}}),o||e()},expandRefs:function(t){for(t=i({},t);t.$ref;){var e=t.$ref;delete t.$ref,this.refs[e]||(e=decodeURIComponent(e)),t=this.extendSchemas(t,this.refs[e])}return t},expandSchema:function(t){var e,r=this,n=i({},t);if("object"==typeof t.type&&(Array.isArray(t.type)?s(t.type,function(e,i){"object"==typeof i&&(t.type[e]=r.expandSchema(i))}):t.type=r.expandSchema(t.type)),"object"==typeof t.disallow&&(Array.isArray(t.disallow)?s(t.disallow,function(e,i){"object"==typeof i&&(t.disallow[e]=r.expandSchema(i))}):t.disallow=r.expandSchema(t.disallow)),t.anyOf&&s(t.anyOf,function(e,i){t.anyOf[e]=r.expandSchema(i)}),t.dependencies&&s(t.dependencies,function(e,i){"object"!=typeof i||Array.isArray(i)||(t.dependencies[e]=r.expandSchema(i))}),t.not&&(t.not=this.expandSchema(t.not)),t.allOf){for(e=0;e=t.maximum?d.push({path:r,property:"maximum",message:this.translate("error_maximum_excl",[t.maximum])}):!t.exclusiveMaximum&&e>t.maximum&&d.push({path:r,property:"maximum",message:this.translate("error_maximum_incl",[t.maximum])})),t.hasOwnProperty("minimum")&&(t.exclusiveMinimum&&e<=t.minimum?d.push({path:r,property:"minimum",message:this.translate("error_minimum_excl",[t.minimum])}):!t.exclusiveMinimum&&et.maxLength&&d.push({path:r,property:"maxLength",message:this.translate("error_maxLength",[t.maxLength])}),t.minLength&&(e+"").lengtht.maxItems&&d.push({path:r,property:"maxItems",message:this.translate("error_maxItems",[t.maxItems])}),t.minItems&&e.lengtht.maxProperties&&d.push({path:r,property:"maxProperties",message:this.translate("error_maxProperties",[t.maxProperties])})}if(t.minProperties){o=0;for(a in e)e.hasOwnProperty(a)&&o++;o=0){e=this.theme.getBlockLinkHolder(),i=this.theme.getBlockLink(),i.setAttribute("target","_blank");var a=document.createElement(r);a.setAttribute("controls","controls"),this.theme.createMediaLink(e,i,a),this.link_watchers.push(function(e){var s=n(e);i.setAttribute("href",s),i.textContent=t.rel||s,a.setAttribute("src",s)})}else e=this.theme.getBlockLink(),e.setAttribute("target","_blank"),e.textContent=t.rel,this.link_watchers.push(function(i){var s=n(i);e.setAttribute("href",s),e.textContent=t.rel||s});return e},refreshWatchedFieldValues:function(){if(this.watched_values){var t={},e=!1,i=this;if(this.watched){var s,r;for(var n in this.watched)this.watched.hasOwnProperty(n)&&(r=i.jsoneditor.getEditor(this.watched[n]),s=r?r.getValue():null,i.watched_values[n]!==s&&(e=!0),t[n]=s)}return t.self=this.getValue(),this.watched_values.self!==t.self&&(e=!0),this.watched_values=t,e}},getWatchedFieldValues:function(){return this.watched_values},updateHeaderText:function(){if(this.header)if(this.header.children.length){for(var t=0;t-1:!!this.jsoneditor.options.required_by_default},getDisplayText:function(t){var e=[],i={};s(t,function(t,e){e.title&&(i[e.title]=i[e.title]||0,i[e.title]++),e.description&&(i[e.description]=i[e.description]||0,i[e.description]++),e.format&&(i[e.format]=i[e.format]||0,i[e.format]++),e.type&&(i[e.type]=i[e.type]||0,i[e.type]++)}),s(t,function(t,s){var r;r="string"==typeof s?s:s.title&&i[s.title]<=1?s.title:s.format&&i[s.format]<=1?s.format:s.type&&i[s.type]<=1?s.type:s.description&&i[s.description]<=1?s.descripton:s.title?s.title:s.format?s.format:s.type?s.type:s.description?s.description:JSON.stringify(s).length<50?JSON.stringify(s):"type",e.push(r)});var r={};return s(e,function(t,s){r[s]=r[s]||0,r[s]++,i[s]>1&&(e[t]=s+" "+r[s])}),e},getOption:function(t){try{throw"getOption is deprecated"}catch(e){window.console.error(e)}return this.options[t]},showValidationErrors:function(t){}}),n.defaults.editors["null"]=n.AbstractEditor.extend({getValue:function(){return null},setValue:function(){this.onChange()},getNumColumns:function(){return 2}}),n.defaults.editors.string=n.AbstractEditor.extend({register:function(){this._super(),this.input&&this.input.setAttribute("name",this.formname)},unregister:function(){this._super(),this.input&&this.input.removeAttribute("name")},setValue:function(t,e,i){if((!this.template||i)&&(null===t||"undefined"==typeof t?t="":"object"==typeof t?t=JSON.stringify(t):"string"!=typeof t&&(t=""+t),t!==this.serialized)){var s=this.sanitize(t);if(this.input.value!==s){this.input.value=s,this.sceditor_instance?this.sceditor_instance.val(s):this.epiceditor?this.epiceditor.importFile(null,s):this.ace_editor&&this.ace_editor.setValue(s);var r=i||this.getValue()!==t;this.refreshValue(),e?this.is_dirty=!1:"change"===this.jsoneditor.options.show_errors&&(this.is_dirty=!0),this.adjust_height&&this.adjust_height(this.input),this.onChange(r)}}},getNumColumns:function(){var t,e=Math.ceil(Math.max(this.getTitle().length,this.schema.maxLength||0,this.schema.minLength||0)/5);return t="textarea"===this.input_type?6:["text","email"].indexOf(this.input_type)>=0?4:2,Math.min(12,Math.max(e,t))},build:function(){var t=this;if(this.options.compact||(this.header=this.label=this.theme.getFormInputLabel(this.getTitle(),this.isRequired())),this.schema.description&&(this.description=this.theme.getFormInputDescription(this.schema.description)),this.format=this.schema.format,!this.format&&this.schema.media&&this.schema.media.type&&(this.format=this.schema.media.type.replace(/(^(application|text)\/(x-)?(script\.)?)|(-source$)/g,"")),!this.format&&this.options.default_format&&(this.format=this.options.default_format),this.options.format&&(this.format=this.options.format),this.format)if("textarea"===this.format)this.input_type="textarea",this.input=this.theme.getTextareaInput();else if("range"===this.format){this.input_type="range";var e=this.schema.minimum||0,i=this.schema.maximum||Math.max(100,e+1),s=1;this.schema.multipleOf&&(e%this.schema.multipleOf&&(e=Math.ceil(e/this.schema.multipleOf)*this.schema.multipleOf),i%this.schema.multipleOf&&(i=Math.floor(i/this.schema.multipleOf)*this.schema.multipleOf),s=this.schema.multipleOf),this.input=this.theme.getRangeInput(e,i,s)}else["actionscript","batchfile","bbcode","c","c++","cpp","coffee","csharp","css","dart","django","ejs","erlang","golang","handlebars","haskell","haxe","html","ini","jade","java","javascript","json","less","lisp","lua","makefile","markdown","matlab","mysql","objectivec","pascal","perl","pgsql","php","python","r","ruby","sass","scala","scss","smarty","sql","stylus","svg","twig","vbscript","xml","yaml"].indexOf(this.format)>=0?(this.input_type=this.format,this.source_code=!0,this.input=this.theme.getTextareaInput()):(this.input_type=this.format,this.input=this.theme.getFormInputField(this.input_type));else this.input_type="text",this.input=this.theme.getFormInputField(this.input_type);"undefined"!=typeof this.schema.maxLength&&this.input.setAttribute("maxlength",this.schema.maxLength),"undefined"!=typeof this.schema.pattern?this.input.setAttribute("pattern",this.schema.pattern):"undefined"!=typeof this.schema.minLength&&this.input.setAttribute("pattern",".{"+this.schema.minLength+",}"),this.options.compact?this.container.className+=" compact":this.options.input_width&&(this.input.style.width=this.options.input_width),(this.schema.readOnly||this.schema.readonly||this.schema.template)&&(this.always_disabled=!0,this.input.disabled=!0),this.input.addEventListener("change",function(e){if(e.preventDefault(),e.stopPropagation(),t.schema.template)return void(this.value=t.value);var i=this.value,s=t.sanitize(i);i!==s&&(this.value=s),t.is_dirty=!0,t.refreshValue(),t.onChange(!0)}),this.options.input_height&&(this.input.style.height=this.options.input_height),this.options.expand_height&&(this.adjust_height=function(t){if(t){var e,i=t.offsetHeight;if(t.offsetHeight100);)e++,i++,t.style.height=i+"px";else{for(e=0;t.offsetHeight>=t.scrollHeight+3&&!(e>100);)e++,i--,t.style.height=i+"px";t.style.height=i+1+"px"}}},this.input.addEventListener("keyup",function(e){t.adjust_height(this)}),this.input.addEventListener("change",function(e){t.adjust_height(this)}),this.adjust_height()),this.format&&this.input.setAttribute("data-schemaformat",this.format),this.control=this.theme.getFormControl(this.label,this.input,this.description),this.container.appendChild(this.control),window.requestAnimationFrame(function(){t.input.parentNode&&t.afterInputReady(),t.adjust_height&&t.adjust_height(t.input)}),this.schema.template?(this.template=this.jsoneditor.compileTemplate(this.schema.template,this.template_engine),this.refreshValue()):this.refreshValue()},enable:function(){this.always_disabled||(this.input.disabled=!1),this._super()},disable:function(){this.input.disabled=!0,this._super()},afterInputReady:function(){var t,e=this;if(this.source_code)if(this.options.wysiwyg&&["html","bbcode"].indexOf(this.input_type)>=0&&window.jQuery&&window.jQuery.fn&&window.jQuery.fn.sceditor)t=i({},{plugins:"html"===e.input_type?"xhtml":"bbcode",emoticonsEnabled:!1,width:"100%",height:300},n.plugins.sceditor,e.options.sceditor_options||{}),window.jQuery(e.input).sceditor(t),e.sceditor_instance=window.jQuery(e.input).sceditor("instance"),e.sceditor_instance.blur(function(){var t=window.jQuery("
"+e.sceditor_instance.val()+"
");window.jQuery("#sceditor-start-marker,#sceditor-end-marker,.sceditor-nlf",t).remove(),e.input.value=t.html(),e.value=e.input.value,e.is_dirty=!0,e.onChange(!0)});else if("markdown"===this.input_type&&window.EpicEditor)this.epiceditor_container=document.createElement("div"),this.input.parentNode.insertBefore(this.epiceditor_container,this.input),this.input.style.display="none",t=i({},n.plugins.epiceditor,{container:this.epiceditor_container,clientSideStorage:!1}),this.epiceditor=new window.EpicEditor(t).load(),this.epiceditor.importFile(null,this.getValue()),this.epiceditor.on("update",function(){var t=e.epiceditor.exportFile();e.input.value=t,e.value=t,e.is_dirty=!0,e.onChange(!0)});else if(window.ace){ +var s=this.input_type;("cpp"===s||"c++"===s||"c"===s)&&(s="c_cpp"),this.ace_container=document.createElement("div"),this.ace_container.style.width="100%",this.ace_container.style.position="relative",this.ace_container.style.height="400px",this.input.parentNode.insertBefore(this.ace_container,this.input),this.input.style.display="none",this.ace_editor=window.ace.edit(this.ace_container),this.ace_editor.setValue(this.getValue()),n.plugins.ace.theme&&this.ace_editor.setTheme("ace/theme/"+n.plugins.ace.theme),s=window.ace.require("ace/mode/"+s),s&&this.ace_editor.getSession().setMode(new s.Mode),this.ace_editor.on("change",function(){var t=e.ace_editor.getValue();e.input.value=t,e.refreshValue(),e.is_dirty=!0,e.onChange(!0)})}e.theme.afterInputReady(e.input)},refreshValue:function(){this.value=this.input.value,"string"!=typeof this.value&&(this.value=""),this.serialized=this.value},destroy:function(){this.sceditor_instance?this.sceditor_instance.destroy():this.epiceditor?this.epiceditor.unload():this.ace_editor&&this.ace_editor.destroy(),this.template=null,this.input&&this.input.parentNode&&this.input.parentNode.removeChild(this.input),this.label&&this.label.parentNode&&this.label.parentNode.removeChild(this.label),this.description&&this.description.parentNode&&this.description.parentNode.removeChild(this.description),this._super()},sanitize:function(t){return t},onWatchedFieldChange:function(){var t;this.template&&(t=this.getWatchedFieldValues(),this.setValue(this.template(t),!1,!0)),this._super()},showValidationErrors:function(t){var e=this;if("always"===this.jsoneditor.options.show_errors);else if(!this.is_dirty&&this.previous_error_setting===this.jsoneditor.options.show_errors)return;this.previous_error_setting=this.jsoneditor.options.show_errors;var i=[];s(t,function(t,s){s.path===e.path&&i.push(s.message)}),i.length?this.theme.addInputError(this.input,i.join(". ")+"."):this.theme.removeInputError(this.input)}}),n.defaults.editors.number=n.defaults.editors.string.extend({sanitize:function(t){return(t+"").replace(/[^0-9\.\-eE]/g,"")},getNumColumns:function(){return 2},getValue:function(){return 1*this.value}}),n.defaults.editors.integer=n.defaults.editors.number.extend({sanitize:function(t){return t+="",t.replace(/[^0-9\-]/g,"")},getNumColumns:function(){return 2}}),n.defaults.editors.object=n.AbstractEditor.extend({getDefault:function(){return i({},this.schema["default"]||{})},getChildEditors:function(){return this.editors},register:function(){if(this._super(),this.editors)for(var t in this.editors)this.editors.hasOwnProperty(t)&&this.editors[t].register()},unregister:function(){if(this._super(),this.editors)for(var t in this.editors)this.editors.hasOwnProperty(t)&&this.editors[t].unregister()},getNumColumns:function(){return Math.max(Math.min(12,this.maxwidth),3)},enable:function(){if(this.editjson_button&&(this.editjson_button.disabled=!1),this.addproperty_button&&(this.addproperty_button.disabled=!1),this._super(),this.editors)for(var t in this.editors)this.editors.hasOwnProperty(t)&&this.editors[t].enable()},disable:function(){if(this.editjson_button&&(this.editjson_button.disabled=!0),this.addproperty_button&&(this.addproperty_button.disabled=!0),this.hideEditJSON(),this._super(),this.editors)for(var t in this.editors)this.editors.hasOwnProperty(t)&&this.editors[t].disable()},layoutEditors:function(){var t,e,i=this;if(this.row_container){this.property_order=Object.keys(this.editors),this.property_order=this.property_order.sort(function(t,e){var s=i.editors[t].schema.propertyOrder,r=i.editors[e].schema.propertyOrder;return"number"!=typeof s&&(s=1e3),"number"!=typeof r&&(r=1e3),s-r});var r;if("grid"===this.format){var n=[];for(s(this.property_order,function(t,e){var s=i.editors[e];if(!s.property_removed){for(var r=!1,o=s.options.hidden?0:s.options.grid_columns||s.getNumColumns(),a=s.options.hidden?0:s.container.offsetHeight,h=0;ha)&&(r=h);r===!1&&(n.push({width:0,minh:999999,maxh:0,editors:[]}),r=n.length-1),n[r].editors.push({key:e,width:o,height:a}),n[r].width+=o,n[r].minh=Math.min(n[r].minh,a),n[r].maxh=Math.max(n[r].maxh,a)}}),t=0;tn[t].editors[o].width&&(o=e),n[t].editors[e].width*=12/n[t].width,n[t].editors[e].width=Math.floor(n[t].editors[e].width),a+=n[t].editors[e].width;12>a&&(n[t].editors[o].width+=12-a),n[t].width=12}if(this.layout===JSON.stringify(n))return!1;for(this.layout=JSON.stringify(n),r=document.createElement("div"),t=0;t=this.schema.maxProperties),this.addproperty_checkboxes&&(this.addproperty_list.innerHTML=""),this.addproperty_checkboxes={};for(t in this.cached_editors)this.cached_editors.hasOwnProperty(t)&&(this.addPropertyCheckbox(t),this.isRequired(this.cached_editors[t])&&t in this.editors&&(this.addproperty_checkboxes[t].disabled=!0),"undefined"!=typeof this.schema.minProperties&&s<=this.schema.minProperties?(this.addproperty_checkboxes[t].disabled=this.addproperty_checkboxes[t].checked,this.addproperty_checkboxes[t].checked||(r=!0)):t in this.editors?(r=!0,i=!0):e||this.schema.properties.hasOwnProperty(t)?(this.addproperty_checkboxes[t].disabled=!1,r=!0):this.addproperty_checkboxes[t].disabled=!0);this.canHaveAdditionalProperties()&&(r=!0);for(t in this.schema.properties)this.schema.properties.hasOwnProperty(t)&&(this.cached_editors[t]||(r=!0,this.addPropertyCheckbox(t)));r?this.canHaveAdditionalProperties()?e?this.addproperty_add.disabled=!1:this.addproperty_add.disabled=!0:(this.addproperty_add.style.display="none",this.addproperty_input.style.display="none"):(this.hideAddProperty(),this.addproperty_controls.style.display="none")},isRequired:function(t){return"boolean"==typeof t.schema.required?t.schema.required:Array.isArray(this.schema.required)?this.schema.required.indexOf(t.key)>-1:!!this.jsoneditor.options.required_by_default},setValue:function(t,e){var i=this;t=t||{},("object"!=typeof t||Array.isArray(t))&&(t={}),s(this.cached_editors,function(s,r){"undefined"!=typeof t[s]?(i.addObjectProperty(s),r.setValue(t[s],e)):e||i.isRequired(r)?r.setValue(r.getDefault(),e):i.removeObjectProperty(s)}),s(t,function(t,s){i.cached_editors[t]||(i.addObjectProperty(t),i.editors[t]&&i.editors[t].setValue(s,e))}),this.refreshValue(),this.layoutEditors(),this.onChange()},showValidationErrors:function(t){var e=this,i=[],r=[];s(t,function(t,s){s.path===e.path?i.push(s):r.push(s)}),this.error_holder&&(i.length?(this.error_holder.innerHTML="",this.error_holder.style.display="",s(i,function(t,i){e.error_holder.appendChild(e.theme.getErrorMessage(i.message))})):this.error_holder.style.display="none"),this.options.table_row&&(i.length?this.theme.addTableRowError(this.container):this.theme.removeTableRowError(this.container)),s(this.editors,function(t,e){e.showValidationErrors(r)})}}),n.defaults.editors.array=n.AbstractEditor.extend({getDefault:function(){return this.schema["default"]||[]},register:function(){if(this._super(),this.rows)for(var t=0;t=this.schema.items.length?this.schema.additionalItems===!0?{}:this.schema.additionalItems?i({},this.schema.additionalItems):void 0:i({},this.schema.items[t]):this.schema.items?i({},this.schema.items):{}},getItemInfo:function(t){var e=this.getItemSchema(t);this.item_info=this.item_info||{};var i=JSON.stringify(e);return"undefined"!=typeof this.item_info[i]?this.item_info[i]:(e=this.jsoneditor.expandRefs(e),this.item_info[i]={title:e.title||"item","default":e["default"],width:12,child_editors:e.properties||e.items},this.item_info[i])},getElementEditor:function(t){var e=this.getItemInfo(t),i=this.getItemSchema(t);i=this.jsoneditor.expandRefs(i),i.title=e.title+" "+(t+1);var s,r=this.jsoneditor.getEditorClass(i);s=this.tabs_holder?this.theme.getTabContent():e.child_editors?this.theme.getChildEditorHolder():this.theme.getIndentedPanel(),this.row_holder.appendChild(s);var n=this.jsoneditor.createEditor(r,{jsoneditor:this.jsoneditor,schema:i,container:s,path:this.path+"."+t,parent:this,required:!0});return n.preBuild(),n.build(),n.postBuild(),n.title_controls||(n.array_controls=this.theme.getButtonHolder(),s.appendChild(n.array_controls)),n},destroy:function(){this.empty(!0),this.title&&this.title.parentNode&&this.title.parentNode.removeChild(this.title),this.description&&this.description.parentNode&&this.description.parentNode.removeChild(this.description),this.row_holder&&this.row_holder.parentNode&&this.row_holder.parentNode.removeChild(this.row_holder),this.controls&&this.controls.parentNode&&this.controls.parentNode.removeChild(this.controls),this.panel&&this.panel.parentNode&&this.panel.parentNode.removeChild(this.panel),this.rows=this.row_cache=this.title=this.description=this.row_holder=this.panel=this.controls=null,this._super()},empty:function(t){if(this.rows){var e=this;s(this.rows,function(i,s){t&&(s.tab&&s.tab.parentNode&&s.tab.parentNode.removeChild(s.tab),e.destroyRow(s,!0),e.row_cache[i]=null),e.rows[i]=null}),e.rows=[],t&&(e.row_cache=[])}},destroyRow:function(t,e){var i=t.container;e?(t.destroy(),i.parentNode&&i.parentNode.removeChild(i),t.tab&&t.tab.parentNode&&t.tab.parentNode.removeChild(t.tab)):(t.tab&&(t.tab.style.display="none"),i.style.display="none",t.unregister())},getMax:function(){return Array.isArray(this.schema.items)&&this.schema.additionalItems===!1?Math.min(this.schema.items.length,this.schema.maxItems||1/0):this.schema.maxItems||1/0},refreshTabs:function(t){var e=this;s(this.rows,function(i,s){s.tab&&(t?s.tab_text.textContent=s.getHeaderText():s.tab===e.active_tab?(e.theme.markTabActive(s.tab),s.container.style.display=""):(e.theme.markTabInactive(s.tab),s.container.style.display="none"))})},setValue:function(t,e){t=t||[],Array.isArray(t)||(t=[t]);var i=JSON.stringify(t);if(i!==this.serialized){if(this.schema.minItems)for(;t.lengththis.getMax()&&(t=t.slice(0,this.getMax()));var r=this;s(t,function(t,i){r.rows[t]?r.rows[t].setValue(i,e):r.row_cache[t]?(r.rows[t]=r.row_cache[t],r.rows[t].setValue(i,e),r.rows[t].container.style.display="",r.rows[t].tab&&(r.rows[t].tab.style.display=""),r.rows[t].register()):r.addRow(i,e)});for(var n=t.length;n=this.rows.length;s(this.rows,function(t,i){i.movedown_button&&(t===e.rows.length-1?i.movedown_button.style.display="none":i.movedown_button.style.display=""),i.delete_button&&(r?i.delete_button.style.display="none":i.delete_button.style.display=""),e.value[t]=i.getValue()});var n=!1;this.value.length?1===this.value.length?(this.remove_all_rows_button.style.display="none",r||this.hide_delete_buttons?this.delete_last_row_button.style.display="none":(this.delete_last_row_button.style.display="",n=!0)):r||this.hide_delete_buttons?(this.delete_last_row_button.style.display="none",this.remove_all_rows_button.style.display="none"):(this.delete_last_row_button.style.display="",this.remove_all_rows_button.style.display="",n=!0):(this.delete_last_row_button.style.display="none",this.remove_all_rows_button.style.display="none"),this.getMax()&&this.getMax()<=this.rows.length||this.hide_add_button?this.add_row_button.style.display="none":(this.add_row_button.style.display="",n=!0),!this.collapsed&&n?this.controls.style.display="inline-block":this.controls.style.display="none"}},addRow:function(t,e){var i=this,r=this.rows.length;i.rows[r]=this.getElementEditor(r),i.row_cache[r]=i.rows[r],i.tabs_holder&&(i.rows[r].tab_text=document.createElement("span"),i.rows[r].tab_text.textContent=i.rows[r].getHeaderText(),i.rows[r].tab=i.theme.getTab(i.rows[r].tab_text),i.rows[r].tab.addEventListener("click",function(t){i.active_tab=i.rows[r].tab,i.refreshTabs(),t.preventDefault(),t.stopPropagation()}),i.theme.addTab(i.tabs_holder,i.rows[r].tab));var n=i.rows[r].title_controls||i.rows[r].array_controls;i.hide_delete_buttons||(i.rows[r].delete_button=this.getButton(i.getItemTitle(),"delete","Delete "+i.getItemTitle()),i.rows[r].delete_button.className+=" delete",i.rows[r].delete_button.setAttribute("data-i",r),i.rows[r].delete_button.addEventListener("click",function(t){t.preventDefault(),t.stopPropagation();var e=1*this.getAttribute("data-i"),r=i.getValue(),n=[],o=null;s(r,function(t,s){return t===e?void(i.rows[t].tab===i.active_tab&&(i.rows[t+1]?o=i.rows[t].tab:t&&(o=i.rows[t-1].tab))):void n.push(s)}),i.setValue(n),o&&(i.active_tab=o,i.refreshTabs()),i.onChange(!0)}),n&&n.appendChild(i.rows[r].delete_button)),r&&!i.hide_move_buttons&&(i.rows[r].moveup_button=this.getButton("","moveup","Move up"),i.rows[r].moveup_button.className+=" moveup",i.rows[r].moveup_button.setAttribute("data-i",r),i.rows[r].moveup_button.addEventListener("click",function(t){t.preventDefault(),t.stopPropagation();var e=1*this.getAttribute("data-i");if(!(0>=e)){var s=i.getValue(),r=s[e-1];s[e-1]=s[e],s[e]=r,i.setValue(s),i.active_tab=i.rows[e-1].tab,i.refreshTabs(),i.onChange(!0)}}),n&&n.appendChild(i.rows[r].moveup_button)),i.hide_move_buttons||(i.rows[r].movedown_button=this.getButton("","movedown","Move down"),i.rows[r].movedown_button.className+=" movedown",i.rows[r].movedown_button.setAttribute("data-i",r),i.rows[r].movedown_button.addEventListener("click",function(t){t.preventDefault(),t.stopPropagation();var e=1*this.getAttribute("data-i"),s=i.getValue();if(!(e>=s.length-1)){var r=s[e+1];s[e+1]=s[e],s[e]=r,i.setValue(s),i.active_tab=i.rows[e+1].tab,i.refreshTabs(),i.onChange(!0)}}),n&&n.appendChild(i.rows[r].movedown_button)),t&&i.rows[r].setValue(t,e),i.refreshTabs()},addControls:function(){var t=this;this.collapsed=!1,this.toggle_button=this.getButton("","collapse","Collapse"),this.title_controls.appendChild(this.toggle_button);var e=t.row_holder.style.display,i=t.controls.style.display;this.toggle_button.addEventListener("click",function(s){s.preventDefault(),s.stopPropagation(),t.collapsed?(t.collapsed=!1,t.panel&&(t.panel.style.display=""),t.row_holder.style.display=e,t.tabs_holder&&(t.tabs_holder.style.display=""),t.controls.style.display=i,t.setButtonText(this,"","collapse","Collapse")):(t.collapsed=!0,t.row_holder.style.display="none",t.tabs_holder&&(t.tabs_holder.style.display="none"),t.controls.style.display="none",t.panel&&(t.panel.style.display="none"),t.setButtonText(this,"","expand","Expand"))}),this.options.collapsed&&r(this.toggle_button,"click"),this.schema.options&&"undefined"!=typeof this.schema.options.disable_collapse?this.schema.options.disable_collapse&&(this.toggle_button.style.display="none"):this.jsoneditor.options.disable_collapse&&(this.toggle_button.style.display="none"),this.add_row_button=this.getButton(this.getItemTitle(),"add","Add "+this.getItemTitle()),this.add_row_button.addEventListener("click",function(e){e.preventDefault(),e.stopPropagation();var i=t.rows.length;t.row_cache[i]?(t.rows[i]=t.row_cache[i],t.rows[i].setValue(t.rows[i].getDefault()),t.rows[i].container.style.display="",t.rows[i].tab&&(t.rows[i].tab.style.display=""),t.rows[i].register()):t.addRow(),t.active_tab=t.rows[i].tab,t.refreshTabs(),t.refreshValue(),t.onChange(!0)}),t.controls.appendChild(this.add_row_button),this.delete_last_row_button=this.getButton("Last "+this.getItemTitle(),"delete","Delete Last "+this.getItemTitle()), +this.delete_last_row_button.addEventListener("click",function(e){e.preventDefault(),e.stopPropagation();var i=t.getValue(),s=null;t.rows.length>1&&t.rows[t.rows.length-1].tab===t.active_tab&&(s=t.rows[t.rows.length-2].tab),i.pop(),t.setValue(i),s&&(t.active_tab=s,t.refreshTabs()),t.onChange(!0)}),t.controls.appendChild(this.delete_last_row_button),this.remove_all_rows_button=this.getButton("All","delete","Delete All"),this.remove_all_rows_button.addEventListener("click",function(e){e.preventDefault(),e.stopPropagation(),t.setValue([]),t.onChange(!0)}),t.controls.appendChild(this.remove_all_rows_button),t.tabs&&(this.add_row_button.style.width="100%",this.add_row_button.style.textAlign="left",this.add_row_button.style.marginBottom="3px",this.delete_last_row_button.style.width="100%",this.delete_last_row_button.style.textAlign="left",this.delete_last_row_button.style.marginBottom="3px",this.remove_all_rows_button.style.width="100%",this.remove_all_rows_button.style.textAlign="left",this.remove_all_rows_button.style.marginBottom="3px")},showValidationErrors:function(t){var e=this,i=[],r=[];s(t,function(t,s){s.path===e.path?i.push(s):r.push(s)}),this.error_holder&&(i.length?(this.error_holder.innerHTML="",this.error_holder.style.display="",s(i,function(t,i){e.error_holder.appendChild(e.theme.getErrorMessage(i.message))})):this.error_holder.style.display="none"),s(this.rows,function(t,e){e.showValidationErrors(r)})}}),n.defaults.editors.table=n.defaults.editors.array.extend({register:function(){if(this._super(),this.rows)for(var t=0;tthis.schema.maxItems&&(t=t.slice(0,this.schema.maxItems));var i=JSON.stringify(t);if(i!==this.serialized){var r=!1,n=this;s(t,function(t,e){n.rows[t]?n.rows[t].setValue(e):(n.addRow(e),r=!0)});for(var o=t.length;o=this.rows.length,i=!1;s(this.rows,function(s,r){r.movedown_button&&(s===t.rows.length-1?r.movedown_button.style.display="none":(i=!0,r.movedown_button.style.display="")),r.delete_button&&(e?r.delete_button.style.display="none":(i=!0,r.delete_button.style.display="")),r.moveup_button&&(i=!0)}),s(this.rows,function(t,e){i?e.controls_cell.style.display="":e.controls_cell.style.display="none"}),i?this.controls_header_cell.style.display="":this.controls_header_cell.style.display="none";var r=!1;this.value.length?1===this.value.length||this.hide_delete_buttons?(this.table.style.display="",this.remove_all_rows_button.style.display="none",e||this.hide_delete_buttons?this.delete_last_row_button.style.display="none":(this.delete_last_row_button.style.display="",r=!0)):(this.table.style.display="",e||this.hide_delete_buttons?(this.delete_last_row_button.style.display="none",this.remove_all_rows_button.style.display="none"):(this.delete_last_row_button.style.display="",this.remove_all_rows_button.style.display="",r=!0)):(this.delete_last_row_button.style.display="none",this.remove_all_rows_button.style.display="none",this.table.style.display="none"),this.schema.maxItems&&this.schema.maxItems<=this.rows.length||this.hide_add_button?this.add_row_button.style.display="none":(this.add_row_button.style.display="",r=!0),r?this.controls.style.display="":this.controls.style.display="none"},refreshValue:function(){var t=this;this.value=[],s(this.rows,function(e,i){t.value[e]=i.getValue()}),this.serialized=JSON.stringify(this.value)},addRow:function(t){var e=this,i=this.rows.length;e.rows[i]=this.getElementEditor(i);var r=e.rows[i].table_controls;this.hide_delete_buttons||(e.rows[i].delete_button=this.getButton("","delete","Delete"),e.rows[i].delete_button.className+=" delete",e.rows[i].delete_button.setAttribute("data-i",i),e.rows[i].delete_button.addEventListener("click",function(t){t.preventDefault(),t.stopPropagation();var i=1*this.getAttribute("data-i"),r=e.getValue(),n=[];s(r,function(t,e){t!==i&&n.push(e)}),e.setValue(n),e.onChange(!0)}),r.appendChild(e.rows[i].delete_button)),i&&!this.hide_move_buttons&&(e.rows[i].moveup_button=this.getButton("","moveup","Move up"),e.rows[i].moveup_button.className+=" moveup",e.rows[i].moveup_button.setAttribute("data-i",i),e.rows[i].moveup_button.addEventListener("click",function(t){t.preventDefault(),t.stopPropagation();var i=1*this.getAttribute("data-i");if(!(0>=i)){var s=e.getValue(),r=s[i-1];s[i-1]=s[i],s[i]=r,e.setValue(s),e.onChange(!0)}}),r.appendChild(e.rows[i].moveup_button)),this.hide_move_buttons||(e.rows[i].movedown_button=this.getButton("","movedown","Move down"),e.rows[i].movedown_button.className+=" movedown",e.rows[i].movedown_button.setAttribute("data-i",i),e.rows[i].movedown_button.addEventListener("click",function(t){t.preventDefault(),t.stopPropagation();var i=1*this.getAttribute("data-i"),s=e.getValue();if(!(i>=s.length-1)){var r=s[i+1];s[i+1]=s[i],s[i]=r,e.setValue(s),e.onChange(!0)}}),r.appendChild(e.rows[i].movedown_button)),t&&e.rows[i].setValue(t)},addControls:function(){var t=this;this.collapsed=!1,this.toggle_button=this.getButton("","collapse","Collapse"),this.title_controls&&(this.title_controls.appendChild(this.toggle_button),this.toggle_button.addEventListener("click",function(e){e.preventDefault(),e.stopPropagation(),t.collapsed?(t.collapsed=!1,t.panel.style.display="",t.setButtonText(this,"","collapse","Collapse")):(t.collapsed=!0,t.panel.style.display="none",t.setButtonText(this,"","expand","Expand"))}),this.options.collapsed&&r(this.toggle_button,"click"),this.schema.options&&"undefined"!=typeof this.schema.options.disable_collapse?this.schema.options.disable_collapse&&(this.toggle_button.style.display="none"):this.jsoneditor.options.disable_collapse&&(this.toggle_button.style.display="none")),this.add_row_button=this.getButton(this.getItemTitle(),"add","Add "+this.getItemTitle()),this.add_row_button.addEventListener("click",function(e){e.preventDefault(),e.stopPropagation(),t.addRow(),t.refreshValue(),t.refreshRowButtons(),t.onChange(!0)}),t.controls.appendChild(this.add_row_button),this.delete_last_row_button=this.getButton("Last "+this.getItemTitle(),"delete","Delete Last "+this.getItemTitle()),this.delete_last_row_button.addEventListener("click",function(e){e.preventDefault(),e.stopPropagation();var i=t.getValue();i.pop(),t.setValue(i),t.onChange(!0)}),t.controls.appendChild(this.delete_last_row_button),this.remove_all_rows_button=this.getButton("All","delete","Delete All"),this.remove_all_rows_button.addEventListener("click",function(e){e.preventDefault(),e.stopPropagation(),t.setValue([]),t.onChange(!0)}),t.controls.appendChild(this.remove_all_rows_button)}}),n.defaults.editors.multiple=n.AbstractEditor.extend({register:function(){if(this.editors){for(var t=0;tnull";if("object"==typeof t){var i="";return s(t,function(s,r){var n=e.getHTML(r);Array.isArray(t)||(n="
"+s+": "+n+"
"),i+="
  • "+n+"
  • "}),i=Array.isArray(t)?"
      "+i+"
    ":"
      "+i+"
    "}return"boolean"==typeof t?t?"true":"false":"string"==typeof t?t.replace(/&/g,"&").replace(//g,">"):t},setValue:function(t){this.value!==t&&(this.value=t,this.refreshValue(),this.onChange())},destroy:function(){this.display_area&&this.display_area.parentNode&&this.display_area.parentNode.removeChild(this.display_area),this.title&&this.title.parentNode&&this.title.parentNode.removeChild(this.title),this.switcher&&this.switcher.parentNode&&this.switcher.parentNode.removeChild(this.switcher),this._super()}}),n.defaults.editors.select=n.AbstractEditor.extend({setValue:function(t,e){t=this.typecast(t||"");var i=t;this.enum_values.indexOf(i)<0&&(i=this.enum_values[0]),this.value!==i&&(this.input.value=this.enum_options[this.enum_values.indexOf(i)],this.select2&&this.select2.select2("val",this.input.value),this.value=i,this.onChange())},register:function(){this._super(),this.input&&this.input.setAttribute("name",this.formname)},unregister:function(){this._super(),this.input&&this.input.removeAttribute("name")},getNumColumns:function(){if(!this.enum_options)return 3;for(var t=this.getTitle().length,e=0;e2||this.enum_options.length&&this.enumSource)){var t=i({},n.plugins.select2);this.schema.options&&this.schema.options.select2_options&&(t=i(t,this.schema.options.select2_options)),this.select2=window.jQuery(this.input).select2(t);var e=this;this.select2.on("select2-blur",function(){e.input.value=e.select2.select2("val"),e.onInputChange()})}else this.select2=null},postBuild:function(){this._super(),this.theme.afterInputReady(this.input),this.setupSelect2()},onWatchedFieldChange:function(){var t,e;if(this.enumSource){t=this.getWatchedFieldValues();for(var i=[],s=[],r=0;rType: "+t+", Size: "+Math.floor((this.value.length-this.value.split(",")[0].length-1)/1.33333)+" bytes","image"===t.substr(0,5)){this.preview.innerHTML+="
    ";var e=document.createElement("img");e.style.maxWidth="100%",e.style.maxHeight="100px",e.src=this.value,this.preview.appendChild(e)}}else this.preview.innerHTML="Invalid data URI"}},enable:function(){this.uploader&&(this.uploader.disabled=!1),this._super()},disable:function(){this.uploader&&(this.uploader.disabled=!0),this._super()},setValue:function(t){this.value!==t&&(this.value=t,this.input.value=this.value,this.refreshPreview(),this.onChange())},destroy:function(){this.preview&&this.preview.parentNode&&this.preview.parentNode.removeChild(this.preview),this.title&&this.title.parentNode&&this.title.parentNode.removeChild(this.title),this.input&&this.input.parentNode&&this.input.parentNode.removeChild(this.input),this.uploader&&this.uploader.parentNode&&this.uploader.parentNode.removeChild(this.uploader),this._super()}}),n.defaults.editors.upload=n.AbstractEditor.extend({getNumColumns:function(){return 4},build:function(){var t=this;if(this.title=this.header=this.label=this.theme.getFormInputLabel(this.getTitle(),this.isRequired()),this.input=this.theme.getFormInputField("hidden"),this.container.appendChild(this.input),!this.schema.readOnly&&!this.schema.readonly){if(!this.jsoneditor.options.upload)throw"Upload handler required for upload editor";this.uploader=this.theme.getFormInputField("file"),this.uploader.addEventListener("change",function(e){if(e.preventDefault(),e.stopPropagation(),this.files&&this.files.length){var i=new FileReader;i.onload=function(e){t.preview_value=e.target.result,t.refreshPreview(),t.onChange(!0),i=null},i.readAsDataURL(this.files[0])}})}var e=this.schema.description;e||(e=""),this.preview=this.theme.getFormInputDescription(e),this.container.appendChild(this.preview),this.control=this.theme.getFormControl(this.label,this.uploader||this.input,this.preview),this.container.appendChild(this.control)},refreshPreview:function(){if(this.last_preview!==this.preview_value&&(this.last_preview=this.preview_value,this.preview.innerHTML="",this.preview_value)){var t=this,e=this.preview_value.match(/^data:([^;,]+)[;,]/);e&&(e=e[1]),e||(e="unknown");var i=this.uploader.files[0];if(this.preview.innerHTML="Type: "+e+", Size: "+i.size+" bytes","image"===e.substr(0,5)){this.preview.innerHTML+="
    ";var s=document.createElement("img");s.style.maxWidth="100%",s.style.maxHeight="100px",s.src=this.preview_value, +this.preview.appendChild(s)}this.preview.innerHTML+="
    ";var r=this.getButton("Upload","upload","Upload");this.preview.appendChild(r),r.addEventListener("click",function(e){e.preventDefault(),r.setAttribute("disabled","disabled"),t.theme.removeInputError(t.uploader),t.theme.getProgressBar&&(t.progressBar=t.theme.getProgressBar(),t.preview.appendChild(t.progressBar)),t.jsoneditor.options.upload(t.path,i,{success:function(e){t.setValue(e),t.parent?t.parent.onChildEditorChange(t):t.jsoneditor.onChange(),t.progressBar&&t.preview.removeChild(t.progressBar),r.removeAttribute("disabled")},failure:function(e){t.theme.addInputError(t.uploader,e),t.progressBar&&t.preview.removeChild(t.progressBar),r.removeAttribute("disabled")},updateProgress:function(e){t.progressBar&&(e?t.theme.updateProgressBar(t.progressBar,e):t.theme.updateProgressBarUnknown(t.progressBar))}})})}},enable:function(){this.uploader&&(this.uploader.disabled=!1),this._super()},disable:function(){this.uploader&&(this.uploader.disabled=!0),this._super()},setValue:function(t){this.value!==t&&(this.value=t,this.input.value=this.value,this.onChange())},destroy:function(){this.preview&&this.preview.parentNode&&this.preview.parentNode.removeChild(this.preview),this.title&&this.title.parentNode&&this.title.parentNode.removeChild(this.title),this.input&&this.input.parentNode&&this.input.parentNode.removeChild(this.input),this.uploader&&this.uploader.parentNode&&this.uploader.parentNode.removeChild(this.uploader),this._super()}}),n.defaults.editors.checkbox=n.AbstractEditor.extend({setValue:function(t,e){this.value=!!t,this.input.checked=this.value,this.onChange()},register:function(){this._super(),this.input&&this.input.setAttribute("name",this.formname)},unregister:function(){this._super(),this.input&&this.input.removeAttribute("name")},getNumColumns:function(){return Math.min(12,Math.max(this.getTitle().length/7,2))},build:function(){var t=this;this.options.compact||(this.label=this.header=this.theme.getCheckboxLabel(this.getTitle())),this.schema.description&&(this.description=this.theme.getFormInputDescription(this.schema.description)),this.options.compact&&(this.container.className+=" compact"),this.input=this.theme.getCheckbox(),this.control=this.theme.getFormControl(this.label,this.input,this.description),(this.schema.readOnly||this.schema.readonly)&&(this.always_disabled=!0,this.input.disabled=!0),this.input.addEventListener("change",function(e){e.preventDefault(),e.stopPropagation(),t.value=this.checked,t.onChange(!0)}),this.container.appendChild(this.control)},enable:function(){this.always_disabled||(this.input.disabled=!1),this._super()},disable:function(){this.input.disabled=!0,this._super()},destroy:function(){this.label&&this.label.parentNode&&this.label.parentNode.removeChild(this.label),this.description&&this.description.parentNode&&this.description.parentNode.removeChild(this.description),this.input&&this.input.parentNode&&this.input.parentNode.removeChild(this.input),this._super()}});var o=function(){var t=document.documentElement;return t.matches?"matches":t.webkitMatchesSelector?"webkitMatchesSelector":t.mozMatchesSelector?"mozMatchesSelector":t.msMatchesSelector?"msMatchesSelector":t.oMatchesSelector?"oMatchesSelector":void 0}();n.AbstractTheme=t.extend({getContainer:function(){return document.createElement("div")},getFloatRightLinkHolder:function(){var t=document.createElement("div");return t.style=t.style||{},t.style.cssFloat="right",t.style.marginLeft="10px",t},getModal:function(){var t=document.createElement("div");return t.style.backgroundColor="white",t.style.border="1px solid black",t.style.boxShadow="3px 3px black",t.style.position="absolute",t.style.zIndex="10",t.style.display="none",t},getGridContainer:function(){var t=document.createElement("div");return t},getGridRow:function(){var t=document.createElement("div");return t.className="row",t},getGridColumn:function(){var t=document.createElement("div");return t},setGridColumnSize:function(t,e){},getLink:function(t){var e=document.createElement("a");return e.setAttribute("href","#"),e.appendChild(document.createTextNode(t)),e},disableHeader:function(t){t.style.color="#ccc"},disableLabel:function(t){t.style.color="#ccc"},enableHeader:function(t){t.style.color=""},enableLabel:function(t){t.style.color=""},getFormInputLabel:function(t){var e=document.createElement("label");return e.appendChild(document.createTextNode(t)),e},getCheckboxLabel:function(t){var e=this.getFormInputLabel(t);return e.style.fontWeight="normal",e},getHeader:function(t,e){var i=document.createElement("h3");return"string"==typeof t?i.textContent=t:i.appendChild(t),e&&(i.className+=" required"),i},getCheckbox:function(){var t=this.getFormInputField("checkbox");return t.style.display="inline-block",t.style.width="auto",t},getMultiCheckboxHolder:function(t,e,i){var s=document.createElement("div");e&&(e.style.display="block",s.appendChild(e));for(var r in t)t.hasOwnProperty(r)&&(t[r].style.display="inline-block",t[r].style.marginRight="20px",s.appendChild(t[r]));return i&&s.appendChild(i),s},getSelectInput:function(t){var e=document.createElement("select");return t&&this.setSelectOptions(e,t),e},getSwitcher:function(t){var e=this.getSelectInput(t);return e.style.backgroundColor="transparent",e.style.display="inline-block",e.style.fontStyle="italic",e.style.fontWeight="normal",e.style.height="auto",e.style.marginBottom=0,e.style.marginLeft="5px",e.style.padding="0 0 0 3px",e.style.width="auto",e},getSwitcherOptions:function(t){return t.getElementsByTagName("option")},setSwitcherOptions:function(t,e,i){this.setSelectOptions(t,e,i)},setSelectOptions:function(t,e,i){i=i||[],t.innerHTML="";for(var s=0;s'),t.errmsg=t.parentNode.getElementsByClassName("error")[0]),t.errmsg.textContent=e)},removeInputError:function(t){t.errmsg&&(t.group.className=t.group.className.replace(/ error/g,""),t.errmsg.style.display="none")},getProgressBar:function(){var t=document.createElement("div");t.className="progress";var e=document.createElement("span");return e.className="meter",e.style.width="0%",t.appendChild(e),t},updateProgressBar:function(t,e){t&&(t.firstChild.style.width=e+"%")},updateProgressBarUnknown:function(t){t&&(t.firstChild.style.width="100%")}}),n.defaults.themes.foundation3=n.defaults.themes.foundation.extend({getHeaderButtonHolder:function(){var t=this._super();return t.style.fontSize=".6em",t},getFormInputLabel:function(t,e){var i=this._super(t);return i.style.fontWeight="bold",e&&(i.className+=" required"),i},getTabHolder:function(){var t=document.createElement("div");return t.className="row",t.innerHTML="
    ",t},setGridColumnSize:function(t,e){var i=["zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve"];t.className="columns "+i[e]},getTab:function(t){var e=document.createElement("dd"),i=document.createElement("a");return i.setAttribute("href","#"),i.appendChild(t),e.appendChild(i),e},getTabContentHolder:function(t){return t.children[1]},getTabContent:function(){var t=document.createElement("div");return t.className="content active",t.style.paddingLeft="5px",t},markTabActive:function(t){t.className+=" active"},markTabInactive:function(t){t.className=t.className.replace(/\s*active/g,"")},addTab:function(t,e){t.children[0].appendChild(e)}}),n.defaults.themes.foundation4=n.defaults.themes.foundation.extend({getHeaderButtonHolder:function(){var t=this._super();return t.style.fontSize=".6em",t},setGridColumnSize:function(t,e){t.className="columns large-"+e},getFormInputDescription:function(t){var e=this._super(t);return e.style.fontSize=".8rem",e},getFormInputLabel:function(t,e){var i=this._super(t);return i.style.fontWeight="bold",e&&(i.className+=" required"),i}}),n.defaults.themes.foundation5=n.defaults.themes.foundation.extend({getFormInputDescription:function(t){var e=this._super(t);return e.style.fontSize=".8rem",e},setGridColumnSize:function(t,e){t.className="columns medium-"+e},getButton:function(t,e,i){var s=this._super(t,e,i);return s.className=s.className.replace(/\s*small/g,"")+" tiny",s},getTabHolder:function(){var t=document.createElement("div");return t.innerHTML="
    ",t},getTab:function(t){var e=document.createElement("dd"),i=document.createElement("a");return i.setAttribute("href","#"),i.appendChild(t),e.appendChild(i),e},getTabContentHolder:function(t){return t.children[1]},getTabContent:function(){var t=document.createElement("div");return t.className="content active",t.style.paddingLeft="5px",t},markTabActive:function(t){t.className+=" active"},markTabInactive:function(t){t.className=t.className.replace(/\s*active/g,"")},addTab:function(t,e){t.children[0].appendChild(e)}}),n.defaults.themes.html=n.AbstractTheme.extend({getFormInputLabel:function(t,e){var i=this._super(t);return i.style.display="block",i.style.marginBottom="3px",i.style.fontWeight="bold",e&&(i.className+=" required"),i},getFormInputDescription:function(t){var e=this._super(t);return e.style.fontSize=".8em",e.style.margin=0,e.style.display="inline-block",e.style.fontStyle="italic",e},getIndentedPanel:function(){var t=this._super();return t.style.border="1px solid #ddd",t.style.padding="5px",t.style.margin="5px",t.style.borderRadius="3px",t},getChildEditorHolder:function(){var t=this._super();return t.style.marginBottom="8px",t},getHeaderButtonHolder:function(){var t=this.getButtonHolder();return t.style.display="inline-block",t.style.marginLeft="10px",t.style.fontSize=".8em",t.style.verticalAlign="middle",t},getTable:function(){var t=this._super();return t.style.borderBottom="1px solid #ccc",t.style.marginBottom="5px",t},addInputError:function(t,e){if(t.style.borderColor="red",t.errmsg)t.errmsg.style.display="block";else{var i=this.closest(t,".form-control");t.errmsg=document.createElement("div"),t.errmsg.setAttribute("class","errmsg"),t.errmsg.style=t.errmsg.style||{},t.errmsg.style.color="red",i.appendChild(t.errmsg)}t.errmsg.innerHTML="",t.errmsg.appendChild(document.createTextNode(e))},removeInputError:function(t){t.style.borderColor="",t.errmsg&&(t.errmsg.style.display="none")},getProgressBar:function(){var t=100,e=0,i=document.createElement("progress");return i.setAttribute("max",t),i.setAttribute("value",e),i},updateProgressBar:function(t,e){t&&t.setAttribute("value",e)},updateProgressBarUnknown:function(t){t&&t.removeAttribute("value")}}),n.defaults.themes.jqueryui=n.AbstractTheme.extend({getTable:function(){var t=this._super();return t.setAttribute("cellpadding",5),t.setAttribute("cellspacing",0),t},getTableHeaderCell:function(t){var e=this._super(t);return e.className="ui-state-active",e.style.fontWeight="bold",e},getTableCell:function(){var t=this._super();return t.className="ui-widget-content",t},getHeaderButtonHolder:function(){var t=this.getButtonHolder();return t.style.marginLeft="10px",t.style.fontSize=".6em",t.style.display="inline-block",t},getFormInputDescription:function(t){var e=this.getDescription(t);return e.style.marginLeft="10px",e.style.display="inline-block",e},getFormControl:function(t,e,i){var s=this._super(t,e,i);return"checkbox"===e.type?(s.style.lineHeight="25px",s.style.padding="3px 0"):s.style.padding="4px 0 8px 0",s},getDescription:function(t){var e=document.createElement("span");return e.style.fontSize=".8em",e.style.fontStyle="italic",e.textContent=t,e},getButtonHolder:function(){var t=document.createElement("div");return t.className="ui-buttonset",t.style.fontSize=".7em",t},getFormInputLabel:function(t,e){var i=document.createElement("label");return i.style.fontWeight="bold",i.style.display="block",e&&(i.className+=" required"),i.textContent=t,i},getButton:function(t,e,i){var s=document.createElement("button");s.className="ui-button ui-widget ui-state-default ui-corner-all",e&&!t?(s.className+=" ui-button-icon-only",e.className+=" ui-button-icon-primary ui-icon-primary",s.appendChild(e)):e?(s.className+=" ui-button-text-icon-primary",e.className+=" ui-button-icon-primary ui-icon-primary",s.appendChild(e)):s.className+=" ui-button-text-only";var r=document.createElement("span");return r.className="ui-button-text",r.textContent=t||i||".",s.appendChild(r),s.setAttribute("title",i),s},setButtonText:function(t,e,i,s){t.innerHTML="",t.className="ui-button ui-widget ui-state-default ui-corner-all",i&&!e?(t.className+=" ui-button-icon-only",i.className+=" ui-button-icon-primary ui-icon-primary",t.appendChild(i)):i?(t.className+=" ui-button-text-icon-primary",i.className+=" ui-button-icon-primary ui-icon-primary",t.appendChild(i)):t.className+=" ui-button-text-only";var r=document.createElement("span");r.className="ui-button-text",r.textContent=e||s||".",t.appendChild(r),t.setAttribute("title",s)},getIndentedPanel:function(){var t=document.createElement("div");return t.className="ui-widget-content ui-corner-all",t.style.padding="1em 1.4em",t.style.marginBottom="20px",t},afterInputReady:function(t){t.controls||(t.controls=this.closest(t,".form-control"))},addInputError:function(t,e){t.controls&&(t.errmsg?t.errmsg.style.display="":(t.errmsg=document.createElement("div"),t.errmsg.className="ui-state-error",t.controls.appendChild(t.errmsg)),t.errmsg.textContent=e)},removeInputError:function(t){t.errmsg&&(t.errmsg.style.display="none")},markTabActive:function(t){t.className=t.className.replace(/\s*ui-widget-header/g,"")+" ui-state-active"},markTabInactive:function(t){t.className=t.className.replace(/\s*ui-state-active/g,"")+" ui-widget-header"}}),n.AbstractIconLib=t.extend({mapping:{collapse:"",expand:"","delete":"",edit:"",add:"",cancel:"",save:"",moveup:"",movedown:""},icon_prefix:"",getIconClass:function(t){return this.mapping[t]?this.icon_prefix+this.mapping[t]:null},getIcon:function(t){var e=this.getIconClass(t);if(!e)return null;var i=document.createElement("i");return i.className=e,i}}),n.defaults.iconlibs.bootstrap2=n.AbstractIconLib.extend({mapping:{collapse:"chevron-down",expand:"chevron-up","delete":"trash",edit:"pencil",add:"plus",cancel:"ban-circle",save:"ok",moveup:"arrow-up",movedown:"arrow-down"},icon_prefix:"icon-"}),n.defaults.iconlibs.bootstrap3=n.AbstractIconLib.extend({mapping:{collapse:"chevron-down",expand:"chevron-right","delete":"remove",edit:"pencil",add:"plus",cancel:"floppy-remove",save:"floppy-saved",moveup:"arrow-up",movedown:"arrow-down"},icon_prefix:"glyphicon glyphicon-"}),n.defaults.iconlibs.fontawesome3=n.AbstractIconLib.extend({mapping:{collapse:"chevron-down",expand:"chevron-right","delete":"remove",edit:"pencil",add:"plus",cancel:"ban-circle",save:"save",moveup:"arrow-up",movedown:"arrow-down"},icon_prefix:"icon-"}),n.defaults.iconlibs.fontawesome4=n.AbstractIconLib.extend({mapping:{collapse:"caret-square-o-down",expand:"caret-square-o-right","delete":"times",edit:"pencil",add:"plus",cancel:"ban",save:"save",moveup:"arrow-up",movedown:"arrow-down"},icon_prefix:"fa fa-"}),n.defaults.iconlibs.foundation2=n.AbstractIconLib.extend({mapping:{collapse:"minus",expand:"plus","delete":"remove",edit:"edit",add:"add-doc",cancel:"error",save:"checkmark",moveup:"up-arrow",movedown:"down-arrow"},icon_prefix:"foundicon-"}),n.defaults.iconlibs.foundation3=n.AbstractIconLib.extend({mapping:{collapse:"minus",expand:"plus","delete":"x",edit:"pencil",add:"page-add",cancel:"x-circle",save:"save",moveup:"arrow-up",movedown:"arrow-down"},icon_prefix:"fi-"}),n.defaults.iconlibs.jqueryui=n.AbstractIconLib.extend({mapping:{collapse:"triangle-1-s",expand:"triangle-1-e","delete":"trash",edit:"pencil",add:"plusthick",cancel:"closethick",save:"disk",moveup:"arrowthick-1-n",movedown:"arrowthick-1-s"},icon_prefix:"ui-icon ui-icon-"}),n.defaults.templates["default"]=function(){return{compile:function(t){var e=t.match(/{{\s*([a-zA-Z0-9\-_ \.]+)\s*}}/g),i=e&&e.length;if(!i)return function(){return t};for(var s=[],r=function(t){var i,r=e[t].replace(/[{}]+/g,"").trim().split("."),n=r.length;if(n>1){var o;i=function(e){for(o=e,t=0;n>t&&(o=o[r[t]]);t++);return o}}else r=r[0],i=function(t){return t[r]};s.push({s:e[t],r:i})},n=0;i>n;n++)r(n);return function(e){var r,o=t+"";for(n=0;i>n;n++)r=s[n],o=o.replace(r.s,r.r(e));return o}}}},n.defaults.templates.ejs=function(){return!!window.EJS&&{compile:function(t){var e=new window.EJS({text:t});return function(t){return e.render(t)}}}},n.defaults.templates.handlebars=function(){return window.Handlebars},n.defaults.templates.hogan=function(){return!!window.Hogan&&{compile:function(t){var e=window.Hogan.compile(t);return function(t){return e.render(t)}}}},n.defaults.templates.markup=function(){return!(!window.Mark||!window.Mark.up)&&{compile:function(t){return function(e){return window.Mark.up(t,e)}}}},n.defaults.templates.mustache=function(){return!!window.Mustache&&{compile:function(t){return function(e){return window.Mustache.render(t,e)}}}},n.defaults.templates.swig=function(){return window.swig},n.defaults.templates.underscore=function(){return!!window._&&{compile:function(t){return function(e){return window._.template(t,e)}}}},n.defaults.theme="html",n.defaults.template="default",n.defaults.options={},n.defaults.translate=function(t,e){var i=n.defaults.languages[n.defaults.language];if(!i)throw"Unknown language "+n.defaults.language;var s=i[t]||n.defaults.languages[n.defaults.default_language][t];if("undefined"==typeof s)throw"Unknown translate string "+t;if(e)for(var r=0;r=0?"multiselect":void 0}),n.defaults.resolvers.unshift(function(t){return t.oneOf?"multiple":void 0}),function(){if(window.jQuery||window.Zepto){var t=window.jQuery||window.Zepto;t.jsoneditor=n.defaults,t.fn.jsoneditor=function(t){var e=this,i=this.data("jsoneditor");if("value"===t){if(!i)throw"Must initialize jsoneditor before getting/setting the value";if(!(arguments.length>1))return i.getValue();i.setValue(arguments[1])}else{if("validate"===t){if(!i)throw"Must initialize jsoneditor before validating";return arguments.length>1?i.validate(arguments[1]):i.validate()}"destroy"===t?i&&(i.destroy(),this.data("jsoneditor",null)):(i&&i.destroy(),i=new n(this.get(0),t),this.data("jsoneditor",i),i.on("change",function(){e.trigger("change")}),i.on("ready",function(){e.trigger("ready")}))}return this}}}(),window.JSONEditor=n}(); \ No newline at end of file diff --git a/app/code/Magento/Swagger/view/frontend/web/swagger-ui/js/lib/lodash.min.js b/app/code/Magento/Swagger/view/frontend/web/swagger-ui/js/lib/lodash.min.js new file mode 100644 index 0000000000000..3625da8d55264 --- /dev/null +++ b/app/code/Magento/Swagger/view/frontend/web/swagger-ui/js/lib/lodash.min.js @@ -0,0 +1,2 @@ +(function(){function n(n,t){if(n!==t){var r=null===n,e=n===x,u=n===n,o=null===t,i=t===x,f=t===t;if(n>t&&!o||!u||r&&!i&&f||e&&f)return 1;if(n=n&&9<=n&&13>=n||32==n||160==n||5760==n||6158==n||8192<=n&&(8202>=n||8232==n||8233==n||8239==n||8287==n||12288==n||65279==n)}function v(n,t){for(var r=-1,e=n.length,u=-1,o=[];++r=F&&wu&&hu?new Dn(t):null,a=t.length;c&&(i=Mn,f=!1,t=c);n:for(;++oi(t,c,0)&&u.push(c);return u}function lt(n,t){var r=!0;return zu(n,function(n,e,u){return r=!!t(n,e,u)}),r}function st(n,t,r,e){var u=e,o=u;return zu(n,function(n,i,f){i=+t(n,i,f),(r(i,u)||i===e&&i===o)&&(u=i,o=n)}),o}function pt(n,t){var r=[];return zu(n,function(n,e,u){t(n,e,u)&&r.push(n)}),r}function ht(n,t,r,e){var u;return r(n,function(n,r,o){return t(n,r,o)?(u=e?r:n,!1):void 0}),u}function _t(n,t,r,e){e||(e=[]);for(var u=-1,o=n.length;++ut&&(t=-t>u?0:u+t),r=r===x||r>u?u:+r||0,0>r&&(r+=u),u=t>r?0:r-t>>>0,t>>>=0,r=De(u);++e=a)break n;o=e[o],u*="asc"===o||!0===o?1:-1;break n}u=t.b-r.b}return u})}function Ft(n,t){var r=0;return zu(n,function(n,e,u){r+=+t(n,e,u)||0}),r}function Lt(n,t){var e=-1,u=jr(),o=n.length,i=u===r,f=i&&o>=F,c=f&&wu&&hu?new Dn((void 0)):null,a=[];c?(u=Mn,i=!1):(f=!1,c=t?[]:a);n:for(;++eu(c,s,0)&&((t||f)&&c.push(s),a.push(l))}return a}function Nt(n,t){for(var r=-1,e=t.length,u=De(e);++r>>1,i=n[o];(r?i<=t:iu?x:o,u=1);++e=F)return t.plant(e).value();for(var u=0,n=r?o[u].apply(this,n):e;++uarguments.length;return"function"==typeof e&&o===x&&Wo(r)?n(r,e,u,i):Ct(r,mr(e,o,4),u,i,t)}}function hr(n,t,r,e,u,o,i,f,c,a){function l(){for(var w=arguments.length,b=w,j=De(w);b--;)j[b]=arguments[b];if(e&&(j=qt(j,e,u)),o&&(j=Kt(j,o,i)),_||y){var b=l.placeholder,k=v(j,b),w=w-k.length;if(wt?0:t)):[]}function Vr(n,t,r){var e=n?n.length:0;return e?((r?$r(n,t,r):null==t)&&(t=1),t=e-(+t||0),St(n,0,0>t?0:t)):[]}function Zr(n){return n?n[0]:x}function Yr(n,t,e){var u=n?n.length:0;if(!u)return-1;if("number"==typeof e)e=0>e?ju(u+e,0):e;else if(e)return e=zt(n,t),er?ju(u+r,0):r||0,"string"==typeof n||!Wo(n)&&Ae(n)?r<=u&&-1t?0:+t||0,e);++r=n&&(t=x),r}}function le(n,t,r){function e(t,r){r&&au(r),c=p=h=x,t&&(_=xo(),a=n.apply(s,f),p||c||(f=s=x))}function u(){var n=t-(xo()-l);0>=n||n>t?e(h,c):p=_u(u,n)}function o(){e(g,p)}function i(){if(f=arguments,l=xo(),s=this,h=g&&(p||!y),!1===v)var r=y&&!p;else{c||y||(_=l);var e=v-(l-_),i=0>=e||e>v;i?(c&&(c=au(c)),_=l,a=n.apply(s,f)):c||(c=_u(o,e))}return i&&p?p=au(p):p||t===v||(p=_u(u,t)),r&&(i=!0,a=n.apply(s,f)),!i||p||c||(f=s=x),a}var f,c,a,l,s,p,h,_=0,v=!1,g=!0;if("function"!=typeof n)throw new Xe(T);if(t=0>t?0:+t||0,!0===r)var y=!0,g=!1;else de(r)&&(y=!!r.leading,v="maxWait"in r&&ju(+r.maxWait||0,t),g="trailing"in r?!!r.trailing:g);return i.cancel=function(){p&&au(p),c&&au(c),_=0,c=p=h=x},i}function se(n,t){if("function"!=typeof n||t&&"function"!=typeof t)throw new Xe(T);var r=function(){var e=arguments,u=t?t.apply(this,e):e[0],o=r.cache;return o.has(u)?o.get(u):(e=n.apply(this,e),r.cache=o.set(u,e),e)};return r.cache=new se.Cache,r}function pe(n,t){if("function"!=typeof n)throw new Xe(T);return t=ju(t===x?n.length-1:+t||0,0),function(){for(var r=arguments,e=-1,u=ju(r.length-t,0),o=De(u);++et}function _e(n){return h(n)&&Sr(n)&&eu.call(n,"callee")&&!pu.call(n,"callee")}function ve(n,t,r,e){return e=(r="function"==typeof r?Dt(r,e,3):x)?r(n,t):x,e===x?xt(n,t,r):!!e}function ge(n){return h(n)&&"string"==typeof n.message&&ou.call(n)==q}function ye(n){return de(n)&&ou.call(n)==K}function de(n){var t=typeof n;return!!n&&("object"==t||"function"==t)}function we(n){return null!=n&&(ye(n)?fu.test(ru.call(n)):h(n)&&(Gn(n)?fu:In).test(n))}function xe(n){return"number"==typeof n||h(n)&&ou.call(n)==V}function be(n){var t;if(!h(n)||ou.call(n)!=Z||Gn(n)||_e(n)||!(eu.call(n,"constructor")||(t=n.constructor,"function"!=typeof t||t instanceof t)))return!1;var r;return Nn.support.ownLast?(vt(n,function(n,t,e){return r=eu.call(e,t),!1}),!1!==r):(vt(n,function(n,t){r=t}),r===x||eu.call(n,r))}function me(n){return de(n)&&ou.call(n)==Y}function Ae(n){return"string"==typeof n||h(n)&&ou.call(n)==G}function je(n){return h(n)&&Lr(n.length)&&!!Fn[ou.call(n)]}function ke(n,t){return nt||!n||!mu(t))return r;do t%2&&(r+=n),t=xu(t/2),n+=n;while(t);return r}function We(n,t,r){var e=n;return(n=u(n))?(r?$r(e,t,r):null==t)?n.slice(g(n),y(n)+1):(t+="",n.slice(o(n,t),i(n,t)+1)):n}function Fe(n,t,r){return r&&$r(n,t,r)&&(t=x),n=u(n),n.match(t||Un)||[]}function Le(n,t,r){return r&&$r(n,t,r)&&(t=x),h(n)?Te(n):it(n,t)}function Ne(n){return n}function Te(n){return At(ft(n,!0))}function Pe(n,t,r){if(null==r){var e=de(t),u=e?Ko(t):x;((u=u&&u.length?dt(t,u):x)?u.length:e)||(u=!1,r=t,t=n,n=this)}u||(u=dt(t,Ko(t)));var o=!0,e=-1,i=ye(n),f=u.length;!1===r?o=!1:de(r)&&"chain"in r&&(o=r.chain);for(;++e=$)return r}else n=0;return qu(r,e)}}(),Yu=pe(function(n,t){return h(n)&&Sr(n)?at(n,_t(t,!1,!0)):[]}),Gu=er(),Ju=er(!0),Xu=pe(function(n){for(var t=n.length,e=t,u=De(l),o=jr(),i=o===r,f=[];e--;){var c=n[e]=Sr(c=n[e])?c:[];u[e]=i&&120<=c.length&&wu&&hu?new Dn(e&&c):null}var i=n[0],a=-1,l=i?i.length:0,s=u[0];n:for(;++a(s?Mn(s,c):o(f,c,0))){for(e=t;--e;){var p=u[e];if(0>(p?Mn(p,c):o(n[e],c,0)))continue n}s&&s.push(c),f.push(c)}return f}),Hu=pe(function(t,r){r=_t(r);var e=ut(t,r);return Rt(t,r.sort(n)),e}),Qu=yr(),no=yr(!0),to=pe(function(n){return Lt(_t(n,!1,!0))}),ro=pe(function(n,t){return Sr(n)?at(n,t):[]}),eo=pe(Hr),uo=pe(function(n){var t=n.length,r=2--n?t.apply(this,arguments):void 0}},Nn.ary=function(n,t,r){return r&&$r(n,t,r)&&(t=x),t=n&&null==t?n.length:ju(+t||0,0),dr(n,E,x,x,x,x,t)},Nn.assign=Lo,Nn.at=io,Nn.before=ae,Nn.bind=bo,Nn.bindAll=mo, +Nn.bindKey=Ao,Nn.callback=Le,Nn.chain=te,Nn.chunk=function(n,t,r){t=(r?$r(n,t,r):null==t)?1:ju(xu(t)||1,1),r=0;for(var e=n?n.length:0,u=-1,o=De(du(e/t));rr&&(r=-r>u?0:u+r),e=e===x||e>u?u:+e||0,0>e&&(e+=u),u=r>e?0:e>>>0,r>>>=0;rt?0:t)):[]},Nn.takeRight=function(n,t,r){var e=n?n.length:0;return e?((r?$r(n,t,r):null==t)&&(t=1),t=e-(+t||0),St(n,0>t?0:t)):[]},Nn.takeRightWhile=function(n,t,r){return n&&n.length?Tt(n,mr(t,r,3),!1,!0):[]},Nn.takeWhile=function(n,t,r){return n&&n.length?Tt(n,mr(t,r,3)):[]},Nn.tap=function(n,t,r){return t.call(r,n),n},Nn.throttle=function(n,t,r){var e=!0,u=!0;if("function"!=typeof n)throw new Xe(T);return!1===r?e=!1:de(r)&&(e="leading"in r?!!r.leading:e,u="trailing"in r?!!r.trailing:u),le(n,t,{leading:e,maxWait:+t,trailing:u})},Nn.thru=re,Nn.times=function(n,t,r){if(n=xu(n),1>n||!mu(n))return[];var e=-1,u=De(ku(n,4294967295));for(t=Dt(t,r,1);++ee?u[e]=t(e):t(e);return u},Nn.toArray=Oe,Nn.toPlainObject=Ie,Nn.transform=function(n,t,r,e){var u=Wo(n)||je(n);return t=mr(t,e,4),null==r&&(u||de(n)?(e=n.constructor,r=u?Wo(n)?new e:[]:Pu(ye(e)?e.prototype:x)):r={}),(u?Kn:gt)(n,function(n,e,u){return t(r,n,e,u)}),r},Nn.union=to,Nn.uniq=Xr,Nn.unzip=Hr,Nn.unzipWith=Qr,Nn.values=Se,Nn.valuesIn=function(n){return Nt(n,Ee(n))},Nn.where=function(n,t){return ue(n,At(t))},Nn.without=ro,Nn.wrap=function(n,t){return t=null==t?Ne:t,dr(t,I,x,[n],[])},Nn.xor=function(){for(var n=-1,t=arguments.length;++nr?0:+r||0,e),r-=t.length,0<=r&&n.indexOf(t,r)==r},Nn.escape=function(n){return(n=u(n))&&hn.test(n)?n.replace(sn,a):n},Nn.escapeRegExp=function(n){return(n=u(n))&&bn.test(n)?n.replace(xn,l):n||"(?:)"},Nn.every=ee,Nn.find=co,Nn.findIndex=Gu,Nn.findKey=Po,Nn.findLast=ao,Nn.findLastIndex=Ju,Nn.findLastKey=zo,Nn.findWhere=function(n,t){return co(n,At(t))},Nn.first=Zr,Nn.floor=ii,Nn.get=function(n,t,r){return n=null==n?x:wt(n,Mr(t),t+""),n===x?r:n},Nn.gt=he,Nn.gte=function(n,t){return n>=t},Nn.has=function(n,t){if(null==n)return!1;var r=eu.call(n,t);if(!r&&!Wr(t)){if(t=Mr(t),n=1==t.length?n:wt(n,St(t,0,-1)),null==n)return!1;t=Gr(t),r=eu.call(n,t)}return r||Lr(n.length)&&Ur(t,n.length)&&(Wo(n)||_e(n)||Ae(n))},Nn.identity=Ne,Nn.includes=oe,Nn.indexOf=Yr,Nn.inRange=function(n,t,r){return t=+t||0,r===x?(r=t,t=0):r=+r||0,n>=ku(t,r)&&nr?ju(e+r,0):ku(r||0,e-1))+1;else if(r)return u=zt(n,t,!0)-1,n=n[u],(t===t?t===n:n!==n)?u:-1;if(t!==t)return p(n,u,!0);for(;u--;)if(n[u]===t)return u;return-1},Nn.lt=ke,Nn.lte=function(n,t){return n<=t},Nn.max=fi,Nn.min=ci,Nn.noConflict=function(){return Yn._=iu,this},Nn.noop=ze,Nn.now=xo,Nn.pad=function(n,t,r){n=u(n),t=+t;var e=n.length;return er?0:+r||0,n.length),n.lastIndexOf(t,r)==r},Nn.sum=function(n,t,r){if(r&&$r(n,t,r)&&(t=x),t=mr(t,r,3),1==t.length){n=Wo(n)?n:Br(n),r=n.length;for(var e=0;r--;)e+=+t(n[r])||0;n=e}else n=Ft(n,t);return n},Nn.template=function(n,t,r){var e=Nn.templateSettings;r&&$r(n,t,r)&&(t=r=x),n=u(n),t=rt(et({},r||t),e,tt),r=rt(et({},t.imports),e.imports,tt);var o,i,f=Ko(r),c=Nt(r,f),a=0;r=t.interpolate||Cn;var l="__p+='";r=Ge((t.escape||Cn).source+"|"+r.source+"|"+(r===gn?jn:Cn).source+"|"+(t.evaluate||Cn).source+"|$","g");var p="sourceURL"in t?"//# sourceURL="+t.sourceURL+"\n":"";if(n.replace(r,function(t,r,e,u,f,c){return e||(e=u),l+=n.slice(a,c).replace(Sn,s),r&&(o=!0,l+="'+__e("+r+")+'"),f&&(i=!0,l+="';"+f+";\n__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),a=c+t.length,t}),l+="';",(t=t.variable)||(l="with(obj){"+l+"}"),l=(i?l.replace(fn,""):l).replace(cn,"$1").replace(an,"$1;"),l="function("+(t||"obj")+"){"+(t?"":"obj||(obj={});")+"var __t,__p=''"+(o?",__e=_.escape":"")+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}",t=ri(function(){return Ke(f,p+"return "+l).apply(x,c)}),t.source=l,ge(t))throw t;return t},Nn.trim=We,Nn.trimLeft=function(n,t,r){var e=n;return(n=u(n))?n.slice((r?$r(e,t,r):null==t)?g(n):o(n,t+"")):n},Nn.trimRight=function(n,t,r){var e=n;return(n=u(n))?(r?$r(e,t,r):null==t)?n.slice(0,y(n)+1):n.slice(0,i(n,t+"")+1):n},Nn.trunc=function(n,t,r){r&&$r(n,t,r)&&(t=x);var e=S;if(r=U,null!=t)if(de(t)){var o="separator"in t?t.separator:o,e="length"in t?+t.length||0:e;r="omission"in t?u(t.omission):r}else e=+t||0;if(n=u(n),e>=n.length)return n;if(e-=r.length,1>e)return r;if(t=n.slice(0,e),null==o)return t+r;if(me(o)){if(n.slice(e).search(o)){var i,f=n.slice(0,e);for(o.global||(o=Ge(o.source,(kn.exec(o)||"")+"g")),o.lastIndex=0;n=o.exec(f);)i=n.index;t=t.slice(0,null==i?e:i)}}else n.indexOf(o,e)!=e&&(o=t.lastIndexOf(o),-1u.__dir__?"Right":"")}),u},zn.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse()}}),Kn(["filter","map","takeWhile"],function(n,t){var r=t+1,e=r!=N;zn.prototype[n]=function(n,t){var u=this.clone();return u.__iteratees__.push({iteratee:mr(n,t,1),type:r}),u.__filtered__=u.__filtered__||e,u}}),Kn(["first","last"],function(n,t){var r="take"+(t?"Right":"");zn.prototype[n]=function(){return this[r](1).value()[0]}}),Kn(["initial","rest"],function(n,t){var r="drop"+(t?"":"Right");zn.prototype[n]=function(){return this.__filtered__?new zn(this):this[r](1)}}),Kn(["pluck","where"],function(n,t){var r=t?"filter":"map",e=t?At:Be;zn.prototype[n]=function(n){return this[r](e(n))}}),zn.prototype.compact=function(){return this.filter(Ne)},zn.prototype.reject=function(n,t){return n=mr(n,t,1),this.filter(function(t){return!n(t)})},zn.prototype.slice=function(n,t){n=null==n?0:+n||0;var r=this;return r.__filtered__&&(0t)?new zn(r):(0>n?r=r.takeRight(-n):n&&(r=r.drop(n)),t!==x&&(t=+t||0,r=0>t?r.dropRight(-t):r.take(t-n)),r)},zn.prototype.takeRightWhile=function(n,t){return this.reverse().takeWhile(n,t).reverse()},zn.prototype.toArray=function(){return this.take(Cu)},gt(zn.prototype,function(n,t){var r=/^(?:filter|map|reject)|While$/.test(t),e=/^(?:first|last)$/.test(t),u=Nn[e?"take"+("last"==t?"Right":""):t];u&&(Nn.prototype[t]=function(){var t=e?[1]:arguments,o=this.__chain__,i=this.__wrapped__,f=!!this.__actions__.length,c=i instanceof zn,a=t[0],l=c||Wo(i);l&&r&&"function"==typeof a&&1!=a.length&&(c=l=!1);var s=function(n){return e&&o?u(n,1)[0]:u.apply(x,Hn([n],t))},a={func:re,args:[s],thisArg:x},f=c&&!f;return e&&!o?f?(i=i.clone(),i.__actions__.push(a),n.call(i)):u.call(x,this.value())[0]:!e&&l?(i=f?i:new zn(this),i=n.apply(i,t),i.__actions__.push(a),new Pn(i,o)):this.thru(s)})}),Kn("join pop push replace shift sort splice split unshift".split(" "),function(n){var t=(/^(?:replace|split)$/.test(n)?tu:He)[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=!Tu.spliceObjects&&/^(?:pop|shift|splice)$/.test(n),u=/^(?:join|pop|replace|shift)$/.test(n),o=e?function(){var n=t.apply(this,arguments);return 0===this.length&&delete this[0],n}:t;Nn.prototype[n]=function(){var n=arguments;return u&&!this.__chain__?o.apply(this.value(),n):this[r](function(t){return o.apply(t,n)})}}),gt(zn.prototype,function(n,t){var r=Nn[t];if(r){var e=r.name+"";(Fu[e]||(Fu[e]=[])).push({name:t,func:r})}}),Fu[hr(x,A).name]=[{name:"wrapper",func:x}],zn.prototype.clone=function(){var n=new zn(this.__wrapped__);return n.__actions__=qn(this.__actions__),n.__dir__=this.__dir__,n.__filtered__=this.__filtered__,n.__iteratees__=qn(this.__iteratees__),n.__takeCount__=this.__takeCount__,n.__views__=qn(this.__views__),n},zn.prototype.reverse=function(){if(this.__filtered__){var n=new zn(this);n.__dir__=-1,n.__filtered__=!0}else n=this.clone(),n.__dir__*=-1;return n},zn.prototype.value=function(){var n,t=this.__wrapped__.value(),r=this.__dir__,e=Wo(t),u=0>r,o=e?t.length:0;n=0;for(var i=o,f=this.__views__,c=-1,a=f.length;++c"'`]/g,pn=RegExp(ln.source),hn=RegExp(sn.source),_n=/<%-([\s\S]+?)%>/g,vn=/<%([\s\S]+?)%>/g,gn=/<%=([\s\S]+?)%>/g,yn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,dn=/^\w*$/,wn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g,xn=/^[:!,]|[\\^$.*+?()[\]{}|\/]|(^[0-9a-fA-Fnrtuvx])|([\n\r\u2028\u2029])/g,bn=RegExp(xn.source),mn=/[\u0300-\u036f\ufe20-\ufe23]/g,An=/\\(\\)?/g,jn=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,kn=/\w*$/,On=/^0[xX]/,In=/^\[object .+?Constructor\]$/,Rn=/^\d+$/,En=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,Cn=/($^)/,Sn=/['\n\r\u2028\u2029\\]/g,Un=RegExp("[A-Z\\xc0-\\xd6\\xd8-\\xde]+(?=[A-Z\\xc0-\\xd6\\xd8-\\xde][a-z\\xdf-\\xf6\\xf8-\\xff]+)|[A-Z\\xc0-\\xd6\\xd8-\\xde]?[a-z\\xdf-\\xf6\\xf8-\\xff]+|[A-Z\\xc0-\\xd6\\xd8-\\xde]+|[0-9]+","g"),$n="Array ArrayBuffer Date Error Float32Array Float64Array Function Int8Array Int16Array Int32Array Math Number Object RegExp Set String _ clearTimeout isFinite parseFloat parseInt setTimeout TypeError Uint8Array Uint8ClampedArray Uint16Array Uint32Array WeakMap".split(" "),Wn="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),Fn={};Fn[X]=Fn[H]=Fn[Q]=Fn[nn]=Fn[tn]=Fn[rn]=Fn[en]=Fn[un]=Fn[on]=!0,Fn[z]=Fn[B]=Fn[J]=Fn[D]=Fn[M]=Fn[q]=Fn[K]=Fn["[object Map]"]=Fn[V]=Fn[Z]=Fn[Y]=Fn["[object Set]"]=Fn[G]=Fn["[object WeakMap]"]=!1;var Ln={};Ln[z]=Ln[B]=Ln[J]=Ln[D]=Ln[M]=Ln[X]=Ln[H]=Ln[Q]=Ln[nn]=Ln[tn]=Ln[V]=Ln[Z]=Ln[Y]=Ln[G]=Ln[rn]=Ln[en]=Ln[un]=Ln[on]=!0,Ln[q]=Ln[K]=Ln["[object Map]"]=Ln["[object Set]"]=Ln["[object WeakMap]"]=!1;var Nn={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss"},Tn={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Pn={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},zn={"function":!0,object:!0},Bn={0:"x30",1:"x31",2:"x32",3:"x33",4:"x34",5:"x35",6:"x36",7:"x37",8:"x38",9:"x39",A:"x41",B:"x42",C:"x43",D:"x44",E:"x45",F:"x46",a:"x61",b:"x62",c:"x63",d:"x64",e:"x65",f:"x66",n:"x6e",r:"x72",t:"x74",u:"x75",v:"x76",x:"x78"},Dn={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Mn=zn[typeof exports]&&exports&&!exports.nodeType&&exports,qn=zn[typeof module]&&module&&!module.nodeType&&module,Kn=zn[typeof self]&&self&&self.Object&&self,Vn=zn[typeof window]&&window&&window.Object&&window,Zn=qn&&qn.exports===Mn&&Mn,Yn=Mn&&qn&&"object"==typeof global&&global&&global.Object&&global||Vn!==(this&&this.window)&&Vn||Kn||this,Gn=function(){try{Object({toString:0}+"")}catch(n){return function(){return!1}}return function(n){return"function"!=typeof n.toString&&"string"==typeof(n+"")}}(),Jn=w();"function"==typeof define&&"object"==typeof define.amd&&define.amd?(Yn._=Jn,define(function(){return Jn})):Mn&&qn?Zn?(qn.exports=Jn)._=Jn:Mn._=Jn:Yn._=Jn}).call(this); \ No newline at end of file diff --git a/app/code/Magento/Swagger/view/frontend/web/swagger-ui/js/lib/object-assign-pollyfill.js b/app/code/Magento/Swagger/view/frontend/web/swagger-ui/js/lib/object-assign-pollyfill.js new file mode 100644 index 0000000000000..b34d63c859d99 --- /dev/null +++ b/app/code/Magento/Swagger/view/frontend/web/swagger-ui/js/lib/object-assign-pollyfill.js @@ -0,0 +1 @@ +"function"!=typeof Object.assign&&!function(){Object.assign=function(n){"use strict";if(void 0===n||null===n)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(n),o=1;o= 2.0.0-beta.1'],'main': function (depth0, helpers, partials, data) { - var helper, functionType = 'function', - helperMissing = helpers.helperMissing, - escapeExpression = this.escapeExpression; - - return '\n
    \n
    \n
    \n \n \n
    \n
    \n'; - },'useData': true - }); - this['Handlebars']['templates']['basic_auth_button_view'] = Handlebars.template({ - 'compiler': [6,'>= 2.0.0-beta.1'],'main': function (depth0, helpers, partials, data) { - return '
    \n
    \n
    \n
    \n \n
    \n \n \n
    \n
    \n\n'; - },'useData': true - }); - this['Handlebars']['templates']['content_type'] = Handlebars.template({ - '1': function (depth0, helpers, partials, data) { - var stack1, buffer = ''; - - stack1 = helpers.each.call(depth0, depth0 != null ? depth0.produces : depth0, { - 'name': 'each','hash': {},'fn': this.program(2, data),'inverse': this.noop,'data': data - }); - - if (stack1 != null) { - buffer += stack1; - } - - return buffer; - },'2': function (depth0, helpers, partials, data) { - var stack1, lambda = this.lambda, - buffer = ' \n"; +},"4":function(container,depth0,helpers,partials,data) { + return " \n"; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing; + + return "\n\n"; +},"useData":true}); +templates['main'] = template({"1":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing; + + return "
    " + + ((stack1 = (helpers.sanitize || (depth0 && depth0.sanitize) || alias2).call(alias1,((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.title : stack1),{"name":"sanitize","hash":{},"data":data})) != null ? stack1 : "") + + "
    \n
    " + + ((stack1 = (helpers.sanitize || (depth0 && depth0.sanitize) || alias2).call(alias1,((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.description : stack1),{"name":"sanitize","hash":{},"data":data})) != null ? stack1 : "") + + "
    \n" + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.externalDocs : depth0),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + " " + + ((stack1 = helpers["if"].call(alias1,((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.termsOfServiceUrl : stack1),{"name":"if","hash":{},"fn":container.program(4, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "\n " + + ((stack1 = helpers["if"].call(alias1,((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.contact : stack1)) != null ? stack1.name : stack1),{"name":"if","hash":{},"fn":container.program(6, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "\n " + + ((stack1 = helpers["if"].call(alias1,((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.contact : stack1)) != null ? stack1.url : stack1),{"name":"if","hash":{},"fn":container.program(8, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "\n " + + ((stack1 = helpers["if"].call(alias1,((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.contact : stack1)) != null ? stack1.email : stack1),{"name":"if","hash":{},"fn":container.program(10, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "\n " + + ((stack1 = helpers["if"].call(alias1,((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.license : stack1),{"name":"if","hash":{},"fn":container.program(12, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "\n"; +},"2":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing; + + return "

    " + + ((stack1 = (helpers.sanitize || (depth0 && depth0.sanitize) || alias2).call(alias1,((stack1 = (depth0 != null ? depth0.externalDocs : depth0)) != null ? stack1.description : stack1),{"name":"sanitize","hash":{},"data":data})) != null ? stack1 : "") + + "

    \n " + + ((stack1 = (helpers.escape || (depth0 && depth0.escape) || alias2).call(alias1,((stack1 = (depth0 != null ? depth0.externalDocs : depth0)) != null ? stack1.url : stack1),{"name":"escape","hash":{},"data":data})) != null ? stack1 : "") + + "\n"; +},"4":function(container,depth0,helpers,partials,data) { + var stack1; + + return ""; +},"6":function(container,depth0,helpers,partials,data) { + var stack1; + + return "
    Created by
    " + + ((stack1 = (helpers.escape || (depth0 && depth0.escape) || helpers.helperMissing).call(depth0 != null ? depth0 : {},((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.contact : stack1)) != null ? stack1.name : stack1),{"name":"escape","hash":{},"data":data})) != null ? stack1 : "") + + "
    "; +},"8":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing; + + return ""; +},"10":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing; + + return ""; +},"12":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing; + + return ""; +},"14":function(container,depth0,helpers,partials,data) { + var stack1; + + return " , api version: " + + ((stack1 = (helpers.escape || (depth0 && depth0.escape) || helpers.helperMissing).call(depth0 != null ? depth0 : {},((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.version : stack1),{"name":"escape","hash":{},"data":data})) != null ? stack1 : "") + + "\n "; +},"16":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing; + + return " \n \n"; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : {}; + + return "
    \n" + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.info : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "
    \n
    \n
    \n\n
      \n\n
      \n

      [ base url: " + + ((stack1 = (helpers.escape || (depth0 && depth0.escape) || helpers.helperMissing).call(alias1,(depth0 != null ? depth0.basePath : depth0),{"name":"escape","hash":{},"data":data})) != null ? stack1 : "") + + "\n" + + ((stack1 = helpers["if"].call(alias1,((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.version : stack1),{"name":"if","hash":{},"fn":container.program(14, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "]\n" + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.validatorUrl : depth0),{"name":"if","hash":{},"fn":container.program(16, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "

      \n
      \n
      \n"; +},"useData":true}); +templates['oauth2'] = template({"1":function(container,depth0,helpers,partials,data) { + var stack1; + + return "

      Authorization URL: " + + ((stack1 = (helpers.sanitize || (depth0 && depth0.sanitize) || helpers.helperMissing).call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.authorizationUrl : depth0),{"name":"sanitize","hash":{},"data":data})) != null ? stack1 : "") + + "

      "; +},"3":function(container,depth0,helpers,partials,data) { + var stack1; + + return "

      Token URL: " + + ((stack1 = (helpers.sanitize || (depth0 && depth0.sanitize) || helpers.helperMissing).call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.tokenUrl : depth0),{"name":"sanitize","hash":{},"data":data})) != null ? stack1 : "") + + "

      "; +},"5":function(container,depth0,helpers,partials,data) { + return "

      Please input username and password for password flow authorization

      \n
      \n
      \n
      \n
      \n"; +},"7":function(container,depth0,helpers,partials,data) { + var stack1; + + return "

      Setup client authentication." + + ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.requireClientAuthenticaiton : depth0),{"name":"if","hash":{},"fn":container.program(8, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "

      \n
      \n
      \n \n
      \n"; +},"8":function(container,depth0,helpers,partials,data) { + return "(Required)"; +},"10":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing; + + return "
    • \n \n
      \n " + + ((stack1 = (helpers.escape || (depth0 && depth0.escape) || alias2).call(alias1,(depth0 != null ? depth0.description : depth0),{"name":"escape","hash":{},"data":data})) != null ? stack1 : "") + + "\n" + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.OAuthSchemeKey : depth0),{"name":"if","hash":{},"fn":container.program(11, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + " \n
    • \n"; +},"11":function(container,depth0,helpers,partials,data) { + var stack1; + + return " (" + + ((stack1 = (helpers.escape || (depth0 && depth0.escape) || helpers.helperMissing).call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.OAuthSchemeKey : depth0),{"name":"escape","hash":{},"data":data})) != null ? stack1 : "") + + ")\n"; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing; + + return "
      \n

      OAuth2.0

      \n

      " + + ((stack1 = (helpers.sanitize || (depth0 && depth0.sanitize) || alias2).call(alias1,(depth0 != null ? depth0.description : depth0),{"name":"sanitize","hash":{},"data":data})) != null ? stack1 : "") + + "

      \n " + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.authorizationUrl : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "\n " + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.tokenUrl : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "\n

      flow: " + + ((stack1 = (helpers.escape || (depth0 && depth0.escape) || alias2).call(alias1,(depth0 != null ? depth0.flow : depth0),{"name":"escape","hash":{},"data":data})) != null ? stack1 : "") + + "

      \n" + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.isPasswordFlow : depth0),{"name":"if","hash":{},"fn":container.program(5, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.clientAuthentication : depth0),{"name":"if","hash":{},"fn":container.program(7, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "

      " + + ((stack1 = (helpers.escape || (depth0 && depth0.escape) || alias2).call(alias1,(depth0 != null ? depth0.appName : depth0),{"name":"escape","hash":{},"data":data})) != null ? stack1 : "") + + " API requires the following scopes. Select which ones you want to grant to Swagger UI.

      \n

      Scopes are used to grant an application different levels of access to data on behalf of the end user. Each API may declare one or more scopes.\n Learn how to use\n

      \n
        \n" + + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.scopes : depth0),{"name":"each","hash":{},"fn":container.program(10, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "
      \n
      "; +},"useData":true}); +templates['operation'] = template({"1":function(container,depth0,helpers,partials,data) { + return "deprecated"; +},"3":function(container,depth0,helpers,partials,data) { + return "

      Warning: Deprecated

      \n"; +},"5":function(container,depth0,helpers,partials,data) { + var stack1; + + return "

      Implementation Notes

      \n
      " + + ((stack1 = (helpers.sanitize || (depth0 && depth0.sanitize) || helpers.helperMissing).call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.description : depth0),{"name":"sanitize","hash":{},"data":data})) != null ? stack1 : "") + + "
      \n"; +},"7":function(container,depth0,helpers,partials,data) { + return "
      \n"; +},"9":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : {}; + + return "
      \n

      Response Class (Status " + + ((stack1 = (helpers.escape || (depth0 && depth0.escape) || helpers.helperMissing).call(alias1,(depth0 != null ? depth0.successCode : depth0),{"name":"escape","hash":{},"data":data})) != null ? stack1 : "") + + ")

      \n " + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.successDescription : depth0),{"name":"if","hash":{},"fn":container.program(10, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "\n

      \n
      \n
      \n
      \n"; +},"10":function(container,depth0,helpers,partials,data) { + var stack1; + + return "
      " + + ((stack1 = (helpers.sanitize || (depth0 && depth0.sanitize) || helpers.helperMissing).call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.successDescription : depth0),{"name":"sanitize","hash":{},"data":data})) != null ? stack1 : "") + + "
      "; +},"12":function(container,depth0,helpers,partials,data) { + var stack1; + + return "

      Headers

      \n \n \n \n \n \n \n \n \n \n \n" + + ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.headers : depth0),{"name":"each","hash":{},"fn":container.program(13, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + " \n
      HeaderDescriptionTypeOther
      \n"; +},"13":function(container,depth0,helpers,partials,data) { + var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing; + + return " \n " + + container.escapeExpression(((helper = (helper = helpers.key || (data && data.key)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"key","hash":{},"data":data}) : helper))) + + "\n " + + ((stack1 = (helpers.sanitize || (depth0 && depth0.sanitize) || alias2).call(alias1,(depth0 != null ? depth0.description : depth0),{"name":"sanitize","hash":{},"data":data})) != null ? stack1 : "") + + "\n " + + ((stack1 = (helpers.escape || (depth0 && depth0.escape) || alias2).call(alias1,(depth0 != null ? depth0.type : depth0),{"name":"escape","hash":{},"data":data})) != null ? stack1 : "") + + "\n " + + ((stack1 = (helpers.escape || (depth0 && depth0.escape) || alias2).call(alias1,(depth0 != null ? depth0.other : depth0),{"name":"escape","hash":{},"data":data})) != null ? stack1 : "") + + "\n \n"; +},"15":function(container,depth0,helpers,partials,data) { + return "

      Parameters

      \n \n \n \n \n \n \n \n \n \n \n \n\n \n
      ParameterValueDescriptionParameter TypeData Type
      \n"; +},"17":function(container,depth0,helpers,partials,data) { + return "
      \n

      Response Messages

      \n \n \n \n \n \n \n \n \n \n \n \n
      HTTP Status CodeReasonResponse ModelHeaders
      \n"; +},"19":function(container,depth0,helpers,partials,data) { + return ""; +},"21":function(container,depth0,helpers,partials,data) { + return "
      \n \n \n \n
      \n"; +},"23":function(container,depth0,helpers,partials,data) { + return "

      Request Headers

      \n
      \n"; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3=container.escapeExpression; + + return " \n"; +},"useData":true}); +templates['param'] = template({"1":function(container,depth0,helpers,partials,data) { + var stack1; + + return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.isFile : depth0),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.program(4, data, 0),"data":data})) != null ? stack1 : ""); +},"2":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing; + + return " \n
      \n"; +},"4":function(container,depth0,helpers,partials,data) { + var stack1; + + return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0["default"] : depth0),{"name":"if","hash":{},"fn":container.program(5, data, 0),"inverse":container.program(7, data, 0),"data":data})) != null ? stack1 : ""); +},"5":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing; + + return "
      \n \n
      \n
      \n"; +},"7":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing; + + return " \n
      \n
      \n
      \n"; +},"9":function(container,depth0,helpers,partials,data) { + var stack1; + + return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.isFile : depth0),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.program(10, data, 0),"data":data})) != null ? stack1 : ""); +},"10":function(container,depth0,helpers,partials,data) { + var stack1; + + return ((stack1 = (helpers.renderTextParam || (depth0 && depth0.renderTextParam) || helpers.helperMissing).call(depth0 != null ? depth0 : {},depth0,{"name":"renderTextParam","hash":{},"fn":container.program(11, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : ""); +},"11":function(container,depth0,helpers,partials,data) { + return ""; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing; + + return "\n\n\n" + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.isBody : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.program(9, data, 0),"data":data})) != null ? stack1 : "") + + "\n\n" + + ((stack1 = (helpers.sanitize || (depth0 && depth0.sanitize) || alias2).call(alias1,(depth0 != null ? depth0.description : depth0),{"name":"sanitize","hash":{},"data":data})) != null ? stack1 : "") + + "\n" + + ((stack1 = (helpers.escape || (depth0 && depth0.escape) || alias2).call(alias1,(depth0 != null ? depth0.paramType : depth0),{"name":"escape","hash":{},"data":data})) != null ? stack1 : "") + + "\n\n \n\n"; +},"useData":true}); +templates['param_list'] = template({"1":function(container,depth0,helpers,partials,data) { + return " required"; +},"3":function(container,depth0,helpers,partials,data) { + return " multiple=\"multiple\""; +},"5":function(container,depth0,helpers,partials,data) { + return " required "; +},"7":function(container,depth0,helpers,partials,data) { + var stack1; + + return " \n"; +},"8":function(container,depth0,helpers,partials,data) { + return " selected=\"\" "; +},"10":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing; + + return "\n \n\n"; +},"11":function(container,depth0,helpers,partials,data) { + return " selected=\"\" "; +},"13":function(container,depth0,helpers,partials,data) { + return " (default) "; +},"15":function(container,depth0,helpers,partials,data) { + return ""; +},"17":function(container,depth0,helpers,partials,data) { + return ""; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing; + + return "\n\n \n\n" + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.required : depth0),{"name":"if","hash":{},"fn":container.program(15, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = ((helper = (helper = helpers.description || (depth0 != null ? depth0.description : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"description","hash":{},"data":data}) : helper))) != null ? stack1 : "") + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.required : depth0),{"name":"if","hash":{},"fn":container.program(17, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "\n" + + ((stack1 = (helpers.escape || (depth0 && depth0.escape) || alias2).call(alias1,(depth0 != null ? depth0.paramType : depth0),{"name":"escape","hash":{},"data":data})) != null ? stack1 : "") + + "\n\n"; +},"useData":true}); +templates['param_readonly'] = template({"1":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing; + + return " \n
      \n"; +},"3":function(container,depth0,helpers,partials,data) { + var stack1; + + return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0["default"] : depth0),{"name":"if","hash":{},"fn":container.program(4, data, 0),"inverse":container.program(6, data, 0),"data":data})) != null ? stack1 : ""); +},"4":function(container,depth0,helpers,partials,data) { + var stack1; + + return " " + + ((stack1 = (helpers.sanitize || (depth0 && depth0.sanitize) || helpers.helperMissing).call(depth0 != null ? depth0 : {},(depth0 != null ? depth0["default"] : depth0),{"name":"sanitize","hash":{},"data":data})) != null ? stack1 : "") + + "\n"; +},"6":function(container,depth0,helpers,partials,data) { + return " (empty)\n"; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing; + + return "\n\n" + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.isBody : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.program(3, data, 0),"data":data})) != null ? stack1 : "") + + "\n" + + ((stack1 = (helpers.sanitize || (depth0 && depth0.sanitize) || alias2).call(alias1,(depth0 != null ? depth0.description : depth0),{"name":"sanitize","hash":{},"data":data})) != null ? stack1 : "") + + "\n" + + ((stack1 = (helpers.escape || (depth0 && depth0.escape) || alias2).call(alias1,(depth0 != null ? depth0.paramType : depth0),{"name":"escape","hash":{},"data":data})) != null ? stack1 : "") + + "\n\n"; +},"useData":true}); +templates['param_readonly_required'] = template({"1":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing; + + return " \n"; +},"3":function(container,depth0,helpers,partials,data) { + var stack1; + + return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0["default"] : depth0),{"name":"if","hash":{},"fn":container.program(4, data, 0),"inverse":container.program(6, data, 0),"data":data})) != null ? stack1 : ""); +},"4":function(container,depth0,helpers,partials,data) { + var stack1; + + return " " + + ((stack1 = (helpers.sanitize || (depth0 && depth0.sanitize) || helpers.helperMissing).call(depth0 != null ? depth0 : {},(depth0 != null ? depth0["default"] : depth0),{"name":"sanitize","hash":{},"data":data})) != null ? stack1 : "") + + "\n"; +},"6":function(container,depth0,helpers,partials,data) { + return " (empty)\n"; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing; + + return "\n\n" + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.isBody : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.program(3, data, 0),"data":data})) != null ? stack1 : "") + + "\n" + + ((stack1 = (helpers.sanitize || (depth0 && depth0.sanitize) || alias2).call(alias1,(depth0 != null ? depth0.description : depth0),{"name":"sanitize","hash":{},"data":data})) != null ? stack1 : "") + + "\n" + + ((stack1 = (helpers.escape || (depth0 && depth0.escape) || alias2).call(alias1,(depth0 != null ? depth0.paramType : depth0),{"name":"escape","hash":{},"data":data})) != null ? stack1 : "") + + "\n\n"; +},"useData":true}); +templates['param_required'] = template({"1":function(container,depth0,helpers,partials,data) { + var stack1; + + return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.isFile : depth0),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.program(4, data, 0),"data":data})) != null ? stack1 : ""); +},"2":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing; + + return " \n"; +},"4":function(container,depth0,helpers,partials,data) { + var stack1; + + return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0["default"] : depth0),{"name":"if","hash":{},"fn":container.program(5, data, 0),"inverse":container.program(7, data, 0),"data":data})) != null ? stack1 : ""); +},"5":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing; + + return "
      \n \n
      \n
      \n"; +},"7":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing; + + return " \n
      \n
      \n
      \n"; +},"9":function(container,depth0,helpers,partials,data) { + var stack1; + + return ((stack1 = helpers["if"].call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.isFile : depth0),{"name":"if","hash":{},"fn":container.program(10, data, 0),"inverse":container.program(12, data, 0),"data":data})) != null ? stack1 : ""); +},"10":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing; + + return " \n"; +},"12":function(container,depth0,helpers,partials,data) { + var stack1; + + return ((stack1 = (helpers.renderTextParam || (depth0 && depth0.renderTextParam) || helpers.helperMissing).call(depth0 != null ? depth0 : {},depth0,{"name":"renderTextParam","hash":{},"fn":container.program(13, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : ""); +},"13":function(container,depth0,helpers,partials,data) { + return ""; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing; + + return "\n\n" + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.isBody : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.program(9, data, 0),"data":data})) != null ? stack1 : "") + + "\n\n " + + ((stack1 = (helpers.sanitize || (depth0 && depth0.sanitize) || alias2).call(alias1,(depth0 != null ? depth0.description : depth0),{"name":"sanitize","hash":{},"data":data})) != null ? stack1 : "") + + "\n\n" + + ((stack1 = (helpers.escape || (depth0 && depth0.escape) || alias2).call(alias1,(depth0 != null ? depth0.paramType : depth0),{"name":"escape","hash":{},"data":data})) != null ? stack1 : "") + + "\n\n"; +},"useData":true}); +templates['parameter_content_type'] = template({"1":function(container,depth0,helpers,partials,data) { + var stack1; + + return ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.consumes : depth0),{"name":"each","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : ""); +},"2":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing; + + return " \n"; +},"4":function(container,depth0,helpers,partials,data) { + return " \n"; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing; + + return "\n\n"; +},"useData":true}); +templates['popup'] = template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var helper; + + return "
      \n
      " + + container.escapeExpression(((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"title","hash":{},"data":data}) : helper))) + + "
      \n
      \n

      \n
      \n \n
      \n
      \n
      "; +},"useData":true}); +templates['resource'] = template({"1":function(container,depth0,helpers,partials,data) { + return " : "; +},"3":function(container,depth0,helpers,partials,data) { + var stack1; + + return "
    • \n Raw\n
    • \n"; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1, helper, options, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, buffer = + "
      \n

      \n " + + ((stack1 = (helpers.sanitize || (depth0 && depth0.sanitize) || alias2).call(alias1,(depth0 != null ? depth0.name : depth0),{"name":"sanitize","hash":{},"data":data})) != null ? stack1 : "") + + " "; + stack1 = ((helper = (helper = helpers.summary || (depth0 != null ? depth0.summary : depth0)) != null ? helper : alias2),(options={"name":"summary","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data}),(typeof helper === "function" ? helper.call(alias1,options) : helper)); + if (!helpers.summary) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)} + if (stack1 != null) { buffer += stack1; } + return buffer + ((stack1 = (helpers.sanitize || (depth0 && depth0.sanitize) || alias2).call(alias1,(depth0 != null ? depth0.summary : depth0),{"name":"sanitize","hash":{},"data":data})) != null ? stack1 : "") + + "\n

      \n
        \n
      • \n Show/Hide\n
      • \n
      • \n \n List Operations\n \n
      • \n
      • \n \n Expand Operations\n \n
      • \n" + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.url : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "
      \n
      \n\n"; +},"useData":true}); +templates['response_content_type'] = template({"1":function(container,depth0,helpers,partials,data) { + var stack1; + + return ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.produces : depth0),{"name":"each","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : ""); +},"2":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing; + + return " \n"; +},"4":function(container,depth0,helpers,partials,data) { + return " \n"; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression; + + return "\n\n"; +},"useData":true}); +templates['signature'] = template({"1":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : {}; + + return "\n
      \n\n
      \n\n
      \n
      \n " + + container.escapeExpression((helpers.sanitize || (depth0 && depth0.sanitize) || helpers.helperMissing).call(alias1,(depth0 != null ? depth0.signature : depth0),{"name":"sanitize","hash":{},"data":data})) + + "\n
      \n\n
      \n" + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.sampleJSON : depth0),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.sampleXML : depth0),{"name":"if","hash":{},"fn":container.program(5, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "
      \n
      \n"; +},"2":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : {}; + + return "
      \n
      "
      +    + ((stack1 = (helpers.escape || (depth0 && depth0.escape) || helpers.helperMissing).call(alias1,(depth0 != null ? depth0.sampleJSON : depth0),{"name":"escape","hash":{},"data":data})) != null ? stack1 : "")
      +    + "
      \n " + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.isParam : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "\n
      \n"; +},"3":function(container,depth0,helpers,partials,data) { + return ""; +},"5":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : {}; + + return "
      \n
      "
      +    + ((stack1 = (helpers.escape || (depth0 && depth0.escape) || helpers.helperMissing).call(alias1,(depth0 != null ? depth0.sampleXML : depth0),{"name":"escape","hash":{},"data":data})) != null ? stack1 : "")
      +    + "
      \n " + + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.isParam : depth0),{"name":"if","hash":{},"fn":container.program(3, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + "\n
      \n"; +},"7":function(container,depth0,helpers,partials,data) { + var stack1; + + return " " + + ((stack1 = (helpers.escape || (depth0 && depth0.escape) || helpers.helperMissing).call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.signature : depth0),{"name":"escape","hash":{},"data":data})) != null ? stack1 : "") + + "\n"; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1; + + return ((stack1 = (helpers.ifCond || (depth0 && depth0.ifCond) || helpers.helperMissing).call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.sampleJSON : depth0),"||",(depth0 != null ? depth0.sampleXML : depth0),{"name":"ifCond","hash":{},"fn":container.program(1, data, 0),"inverse":container.program(7, data, 0),"data":data})) != null ? stack1 : ""); +},"useData":true}); +templates['status_code'] = template({"1":function(container,depth0,helpers,partials,data) { + var stack1, helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing; + + return " \n " + + container.escapeExpression(((helper = (helper = helpers.key || (data && data.key)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"key","hash":{},"data":data}) : helper))) + + "\n " + + ((stack1 = (helpers.sanitize || (depth0 && depth0.sanitize) || alias2).call(alias1,(depth0 != null ? depth0.description : depth0),{"name":"sanitize","hash":{},"data":data})) != null ? stack1 : "") + + "\n " + + ((stack1 = (helpers.escape || (depth0 && depth0.escape) || alias2).call(alias1,(depth0 != null ? depth0.type : depth0),{"name":"escape","hash":{},"data":data})) != null ? stack1 : "") + + "\n \n"; +},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) { + var stack1, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing; + + return "" + + ((stack1 = (helpers.escape || (depth0 && depth0.escape) || alias2).call(alias1,(depth0 != null ? depth0.code : depth0),{"name":"escape","hash":{},"data":data})) != null ? stack1 : "") + + "\n" + + ((stack1 = (helpers.escape || (depth0 && depth0.escape) || alias2).call(alias1,(depth0 != null ? depth0.message : depth0),{"name":"escape","hash":{},"data":data})) != null ? stack1 : "") + + "\n\n\n \n \n" + + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.headers : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "") + + " \n
      \n"; +},"useData":true}); +})();} + /* jshint ignore:end */ +'use strict'; + + +$(function() { + + // Helper function for vertically aligning DOM elements + // http://www.seodenver.com/simple-vertical-align-plugin-for-jquery/ + $.fn.vAlign = function() { + return this.each(function(){ + var ah = $(this).height(); + var ph = $(this).parent().height(); + var mh = (ph - ah) / 2; + $(this).css('margin-top', mh); + }); + }; + + $.fn.stretchFormtasticInputWidthToParent = function() { + return this.each(function(){ + var p_width = $(this).closest("form").innerWidth(); + var p_padding = parseInt($(this).closest("form").css('padding-left') ,10) + parseInt($(this).closest('form').css('padding-right'), 10); + var this_padding = parseInt($(this).css('padding-left'), 10) + parseInt($(this).css('padding-right'), 10); + $(this).css('width', p_width - p_padding - this_padding); + }); + }; + + $('form.formtastic li.string input, form.formtastic textarea').stretchFormtasticInputWidthToParent(); + + // Vertically center these paragraphs + // Parent may need a min-height for this to work.. + $('ul.downplayed li div.content p').vAlign(); + + // When a sandbox form is submitted.. + $("form.sandbox").submit(function(){ + + var error_free = true; + + // Cycle through the forms required inputs + $(this).find("input.required").each(function() { + + // Remove any existing error styles from the input + $(this).removeClass('error'); + + // Tack the error style on if the input is empty.. + if ($(this).val() === '') { + $(this).addClass('error'); + $(this).wiggle(); + error_free = false; + } + + }); + + return error_free; + }); + +}); + +function clippyCopiedCallback() { + $('#api_key_copied').fadeIn().delay(1000).fadeOut(); + + // var b = $("#clippy_tooltip_" + a); + // b.length != 0 && (b.attr("title", "copied!").trigger("tipsy.reload"), setTimeout(function() { + // b.attr("title", "copy to clipboard") + // }, + // 500)) +} + +// Logging function that accounts for browsers that don't have window.console +function log(){ + log.history = log.history || []; + log.history.push(arguments); + if(this.console){ + console.log( Array.prototype.slice.call(arguments)[0] ); + } +} + +// Handle browsers that do console incorrectly (IE9 and below, see http://stackoverflow.com/a/5539378/7913) +if (Function.prototype.bind && console && typeof console.log === "object") { + [ + "log","info","warn","error","assert","dir","clear","profile","profileEnd" + ].forEach(function (method) { + console[method] = this.bind(console[method], console); + }, Function.prototype.call); +} + +window.Docs = { + + shebang: function() { + + // If shebang has an operation nickname in it.. + // e.g. /docs/#!/words/get_search + var fragments = $.param.fragment().split('/'); + fragments.shift(); // get rid of the bang + + switch (fragments.length) { + case 1: + if (fragments[0].length > 0) { // prevent matching "#/" + // Expand all operations for the resource and scroll to it + var dom_id = 'resource_' + fragments[0]; + + Docs.expandEndpointListForResource(fragments[0]); + $("#"+dom_id).slideto({highlight: false}); + } + break; + case 2: + // Refer to the endpoint DOM element, e.g. #words_get_search + + // Expand Resource + Docs.expandEndpointListForResource(fragments[0]); + $("#"+dom_id).slideto({highlight: false}); + + // Expand operation + var li_dom_id = fragments.join('_'); + var li_content_dom_id = li_dom_id + "_content"; + + + Docs.expandOperation($('#'+li_content_dom_id)); + $('#'+li_dom_id).slideto({highlight: false}); + break; + } + }, + + toggleEndpointListForResource: function(resource) { + var elem = $('li#resource_' + Docs.escapeResourceName(resource) + ' ul.endpoints'); + if (elem.is(':visible')) { + $.bbq.pushState('#/', 2); + Docs.collapseEndpointListForResource(resource); + } else { + $.bbq.pushState('#/' + resource, 2); + Docs.expandEndpointListForResource(resource); + } + }, + + // Expand resource + expandEndpointListForResource: function(resource) { + var resource = Docs.escapeResourceName(resource); + if (resource == '') { + $('.resource ul.endpoints').slideDown(); + return; + } + + $('li#resource_' + resource).addClass('active'); + + var elem = $('li#resource_' + resource + ' ul.endpoints'); + elem.slideDown(); + }, + + // Collapse resource and mark as explicitly closed + collapseEndpointListForResource: function(resource) { + var resource = Docs.escapeResourceName(resource); + if (resource == '') { + $('.resource ul.endpoints').slideUp(); + return; + } + + $('li#resource_' + resource).removeClass('active'); + + var elem = $('li#resource_' + resource + ' ul.endpoints'); + elem.slideUp(); + }, + + expandOperationsForResource: function(resource) { + // Make sure the resource container is open.. + Docs.expandEndpointListForResource(resource); + + if (resource == '') { + $('.resource ul.endpoints li.operation div.content').slideDown(); + return; + } + + $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() { + Docs.expandOperation($(this)); + }); + }, + + collapseOperationsForResource: function(resource) { + // Make sure the resource container is open.. + Docs.expandEndpointListForResource(resource); + + if (resource == '') { + $('.resource ul.endpoints li.operation div.content').slideUp(); + return; + } + + $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() { + Docs.collapseOperation($(this)); + }); + }, + + escapeResourceName: function(resource) { + return resource.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g, "\\$&"); + }, + + expandOperation: function(elem) { + elem.slideDown(); + }, + + collapseOperation: function(elem) { + elem.slideUp(); + } +}; + +/*! + * https://github.com/es-shims/es5-shim + * @license es5-shim Copyright 2009-2015 by contributors, MIT License + * see https://github.com/es-shims/es5-shim/blob/master/LICENSE + */ - return buffer + '\n'; - },'4': function (depth0, helpers, partials, data) { - return ' \n'; - },'compiler': [6,'>= 2.0.0-beta.1'],'main': function (depth0, helpers, partials, data) { - var stack1, helper, functionType = 'function', - helperMissing = helpers.helperMissing, - escapeExpression = this.escapeExpression, - buffer = '\n\n'; - },'useData': true - }); +// UMD (Universal Module Definition) +// see https://github.com/umdjs/umd/blob/master/templates/returnExports.js +(function (root, factory) { 'use strict'; - $(function () { - - // Helper function for vertically aligning DOM elements - // http://www.seodenver.com/simple-vertical-align-plugin-for-jquery/ - $.fn.vAlign = function () { - return this.each(function () { - var ah = $(this).height(); - var ph = $(this).parent().height(); - var mh = (ph - ah) / 2; - - $(this).css('margin-top', mh); - }); - }; - - $.fn.stretchFormtasticInputWidthToParent = function () { - return this.each(function () { - var p_width = $(this).closest('form').innerWidth(); - var p_padding = parseInt($(this).closest('form').css('padding-left'), 10) + parseInt($(this).closest('form').css('padding-right'), 10); - var this_padding = parseInt($(this).css('padding-left'), 10) + parseInt($(this).css('padding-right'), 10); - - $(this).css('width', p_width - p_padding - this_padding); - }); - }; - - $('form.formtastic li.string input, form.formtastic textarea').stretchFormtasticInputWidthToParent(); - - // Vertically center these paragraphs - // Parent may need a min-height for this to work.. - $('ul.downplayed li div.content p').vAlign(); - - // When a sandbox form is submitted.. - $('form.sandbox').submit(function () { - - var error_free = true; - - // Cycle through the forms required inputs - $(this).find('input.required').each(function () { - - // Remove any existing error styles from the input - $(this).removeClass('error'); - - // Tack the error style on if the input is empty.. - if ($(this).val() === '') { - $(this).addClass('error'); - $(this).wiggle(); - error_free = false; - } - - }); - - return error_free; - }); - - }); - - function clippyCopiedCallback() { - $('#api_key_copied').fadeIn().delay(1000).fadeOut(); - - // var b = $("#clippy_tooltip_" + a); - // b.length != 0 && (b.attr("title", "copied!").trigger("tipsy.reload"), setTimeout(function() { - // b.attr("title", "copy to clipboard") - // }, - // 500)) + /* global define, exports, module */ + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(factory); + } else if (typeof exports === 'object') { + // Node. Does not work with strict CommonJS, but + // only CommonJS-like enviroments that support module.exports, + // like Node. + module.exports = factory(); + } else { + // Browser globals (root is window) + root.returnExports = factory(); } +}(this, function () { + /** + * Brings an environment as close to ECMAScript 5 compliance + * as is possible with the facilities of erstwhile engines. + * + * Annotated ES5: http://es5.github.com/ (specific links below) + * ES5 Spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf + * Required reading: http://javascriptweblog.wordpress.com/2011/12/05/extending-javascript-natives/ + */ - // Logging function that accounts for browsers that don't have window.console - function log() { - log.history = log.history || []; - log.history.push(arguments); - - if (this.console) { - console.log(Array.prototype.slice.call(arguments)[0]); + // Shortcut to an often accessed properties, in order to avoid multiple + // dereference that costs universally. This also holds a reference to known-good + // functions. + var $Array = Array; + var ArrayPrototype = $Array.prototype; + var $Object = Object; + var ObjectPrototype = $Object.prototype; + var $Function = Function; + var FunctionPrototype = $Function.prototype; + var $String = String; + var StringPrototype = $String.prototype; + var $Number = Number; + var NumberPrototype = $Number.prototype; + var array_slice = ArrayPrototype.slice; + var array_splice = ArrayPrototype.splice; + var array_push = ArrayPrototype.push; + var array_unshift = ArrayPrototype.unshift; + var array_concat = ArrayPrototype.concat; + var array_join = ArrayPrototype.join; + var call = FunctionPrototype.call; + var apply = FunctionPrototype.apply; + var max = Math.max; + var min = Math.min; + + // Having a toString local variable name breaks in Opera so use to_string. + var to_string = ObjectPrototype.toString; + + /* global Symbol */ + /* eslint-disable one-var-declaration-per-line, no-redeclare, max-statements-per-line */ + var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol'; + var isCallable; /* inlined from https://npmjs.com/is-callable */ var fnToStr = Function.prototype.toString, constructorRegex = /^\s*class /, isES6ClassFn = function isES6ClassFn(value) { try { var fnStr = fnToStr.call(value); var singleStripped = fnStr.replace(/\/\/.*\n/g, ''); var multiStripped = singleStripped.replace(/\/\*[.\s\S]*\*\//g, ''); var spaceStripped = multiStripped.replace(/\n/mg, ' ').replace(/ {2}/g, ' '); return constructorRegex.test(spaceStripped); } catch (e) { return false; /* not a function */ } }, tryFunctionObject = function tryFunctionObject(value) { try { if (isES6ClassFn(value)) { return false; } fnToStr.call(value); return true; } catch (e) { return false; } }, fnClass = '[object Function]', genClass = '[object GeneratorFunction]', isCallable = function isCallable(value) { if (!value) { return false; } if (typeof value !== 'function' && typeof value !== 'object') { return false; } if (hasToStringTag) { return tryFunctionObject(value); } if (isES6ClassFn(value)) { return false; } var strClass = to_string.call(value); return strClass === fnClass || strClass === genClass; }; + + var isRegex; /* inlined from https://npmjs.com/is-regex */ var regexExec = RegExp.prototype.exec, tryRegexExec = function tryRegexExec(value) { try { regexExec.call(value); return true; } catch (e) { return false; } }, regexClass = '[object RegExp]'; isRegex = function isRegex(value) { if (typeof value !== 'object') { return false; } return hasToStringTag ? tryRegexExec(value) : to_string.call(value) === regexClass; }; + var isString; /* inlined from https://npmjs.com/is-string */ var strValue = String.prototype.valueOf, tryStringObject = function tryStringObject(value) { try { strValue.call(value); return true; } catch (e) { return false; } }, stringClass = '[object String]'; isString = function isString(value) { if (typeof value === 'string') { return true; } if (typeof value !== 'object') { return false; } return hasToStringTag ? tryStringObject(value) : to_string.call(value) === stringClass; }; + /* eslint-enable one-var-declaration-per-line, no-redeclare, max-statements-per-line */ + + /* inlined from http://npmjs.com/define-properties */ + var supportsDescriptors = $Object.defineProperty && (function () { + try { + var obj = {}; + $Object.defineProperty(obj, 'x', { enumerable: false, value: obj }); + for (var _ in obj) { // jscs:ignore disallowUnusedVariables + return false; + } + return obj.x === obj; + } catch (e) { /* this is ES3 */ + return false; } - } - - // Handle browsers that do console incorrectly (IE9 and below, see http://stackoverflow.com/a/5539378/7913) - if (Function.prototype.bind && console && typeof console.log === 'object') { - [ - 'log','info','warn','error','assert','dir','clear','profile','profileEnd' - ].forEach(function (method) { - console[method] = this.bind(console[method], console); - }, Function.prototype.call); - } - - window.Docs = { - - shebang: function () { - - // If shebang has an operation nickname in it.. - // e.g. /docs/#!/words/get_search - var fragments = $.param.fragment().split('/'); - - fragments.shift(); // get rid of the bang - - switch (fragments.length) { - case 1: - if (fragments[0].length > 0) { // prevent matching "#/" - // Expand all operations for the resource and scroll to it - var dom_id = 'resource_' + fragments[0]; - - Docs.expandEndpointListForResource(fragments[0]); - $('#' + dom_id).slideto({ - highlight: false - }); - } - break; - - case 2: - // Refer to the endpoint DOM element, e.g. #words_get_search - - // Expand Resource - Docs.expandEndpointListForResource(fragments[0]); - $('#' + dom_id).slideto({ - highlight: false - }); - - // Expand operation - var li_dom_id = fragments.join('_'); - var li_content_dom_id = li_dom_id + '_content'; - - Docs.expandOperation($('#' + li_content_dom_id)); - $('#' + li_dom_id).slideto({ - highlight: false - }); - break; + }()); + var defineProperties = (function (has) { + // Define configurable, writable, and non-enumerable props + // if they don't exist. + var defineProperty; + if (supportsDescriptors) { + defineProperty = function (object, name, method, forceAssign) { + if (!forceAssign && (name in object)) { + return; + } + $Object.defineProperty(object, name, { + configurable: true, + enumerable: false, + writable: true, + value: method + }); + }; + } else { + defineProperty = function (object, name, method, forceAssign) { + if (!forceAssign && (name in object)) { + return; + } + object[name] = method; + }; + } + return function defineProperties(object, map, forceAssign) { + for (var name in map) { + if (has.call(map, name)) { + defineProperty(object, name, map[name], forceAssign); + } } + }; + }(ObjectPrototype.hasOwnProperty)); - }, - - toggleEndpointListForResource: function (resource) { - var elem = $('li#resource_' + Docs.escapeResourceName(resource) + ' ul.endpoints'); - - if (elem.is(':visible')) { - Docs.collapseEndpointListForResource(resource); - } else { - Docs.expandEndpointListForResource(resource); - } - }, + // + // Util + // ====== + // - // Expand resource - expandEndpointListForResource: function (resource) { - var resource = Docs.escapeResourceName(resource); + /* replaceable with https://npmjs.com/package/es-abstract /helpers/isPrimitive */ + var isPrimitive = function isPrimitive(input) { + var type = typeof input; + return input === null || (type !== 'object' && type !== 'function'); + }; - if (resource == '') { - $('.resource ul.endpoints').slideDown(); + var isActualNaN = $Number.isNaN || function isActualNaN(x) { + return x !== x; + }; - return; + var ES = { + // ES5 9.4 + // http://es5.github.com/#x9.4 + // http://jsperf.com/to-integer + /* replaceable with https://npmjs.com/package/es-abstract ES5.ToInteger */ + ToInteger: function ToInteger(num) { + var n = +num; + if (isActualNaN(n)) { + n = 0; + } else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) { + n = (n > 0 || -1) * Math.floor(Math.abs(n)); } - - $('li#resource_' + resource).addClass('active'); - - var elem = $('li#resource_' + resource + ' ul.endpoints'); - - elem.slideDown(); + return n; }, - // Collapse resource and mark as explicitly closed - collapseEndpointListForResource: function (resource) { - var resource = Docs.escapeResourceName(resource); - - if (resource == '') { - $('.resource ul.endpoints').slideUp(); - - return; + /* replaceable with https://npmjs.com/package/es-abstract ES5.ToPrimitive */ + ToPrimitive: function ToPrimitive(input) { + var val, valueOf, toStr; + if (isPrimitive(input)) { + return input; } - - $('li#resource_' + resource).removeClass('active'); - - var elem = $('li#resource_' + resource + ' ul.endpoints'); - - elem.slideUp(); - }, - - expandOperationsForResource: function (resource) { - // Make sure the resource container is open.. - Docs.expandEndpointListForResource(resource); - - if (resource == '') { - $('.resource ul.endpoints li.operation div.content').slideDown(); - - return; + valueOf = input.valueOf; + if (isCallable(valueOf)) { + val = valueOf.call(input); + if (isPrimitive(val)) { + return val; + } } - - $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function () { - Docs.expandOperation($(this)); - }); - }, - - collapseOperationsForResource: function (resource) { - // Make sure the resource container is open.. - Docs.expandEndpointListForResource(resource); - - if (resource == '') { - $('.resource ul.endpoints li.operation div.content').slideUp(); - - return; + toStr = input.toString; + if (isCallable(toStr)) { + val = toStr.call(input); + if (isPrimitive(val)) { + return val; + } } - - $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function () { - Docs.collapseOperation($(this)); - }); - }, - - escapeResourceName: function (resource) { - return resource.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g, '\\$&'); + throw new TypeError(); }, - expandOperation: function (elem) { - elem.slideDown(); + // ES5 9.9 + // http://es5.github.com/#x9.9 + /* replaceable with https://npmjs.com/package/es-abstract ES5.ToObject */ + ToObject: function (o) { + if (o == null) { // this matches both null and undefined + throw new TypeError("can't convert " + o + ' to object'); + } + return $Object(o); }, - collapseOperation: function (elem) { - elem.slideUp(); + /* replaceable with https://npmjs.com/package/es-abstract ES5.ToUint32 */ + ToUint32: function ToUint32(x) { + return x >>> 0; } }; - 'use strict'; - - Handlebars.registerHelper('sanitize', function (html) { - // Strip the script tags from the html, and return it as a Handlebars.SafeString - html = html.replace(/)<[^<]*)*<\/script>/gi, ''); - - return new Handlebars.SafeString(html); - }); - - Handlebars.registerHelper('renderTextParam', function (param) { - var result, type = 'text', - idAtt = ''; - var isArray = param.type.toLowerCase() === 'array' || param.allowMultiple; - var defaultValue = isArray && Array.isArray(param.default) ? param.default.join('\n') : param.default; - - var dataVendorExtensions = Object.keys(param).filter(function (property) { - // filter X-data- properties - return property.match(/^X-data-/i) !== null; - }).reduce(function (result, property) { - // remove X- from property name, so it results in html attributes like data-foo='bar' - return result += ' ' + property.substring(2, property.length) + '=\'' + param[property] + '\''; - }, ''); + // + // Function + // ======== + // - if (typeof defaultValue === 'undefined') { - defaultValue = ''; - } - - if (param.format && param.format === 'password') { - type = 'password'; - } - - if (param.valueId) { - idAtt = ' id=\'' + param.valueId + '\''; - } + // ES-5 15.3.4.5 + // http://es5.github.com/#x15.3.4.5 - if (isArray) { - result = ''; - } else { - var parameterClass = 'parameter'; + var Empty = function Empty() {}; - if (param.required) { - parameterClass += ' required'; + defineProperties(FunctionPrototype, { + bind: function bind(that) { // .length is 1 + // 1. Let Target be the this value. + var target = this; + // 2. If IsCallable(Target) is false, throw a TypeError exception. + if (!isCallable(target)) { + throw new TypeError('Function.prototype.bind called on incompatible ' + target); } - result = ''; - } + // 3. Let A be a new (possibly empty) internal list of all of the + // argument values provided after thisArg (arg1, arg2 etc), in order. + // XXX slicedArgs will stand in for "A" if used + var args = array_slice.call(arguments, 1); // for normal call + // 4. Let F be a new native ECMAScript object. + // 11. Set the [[Prototype]] internal property of F to the standard + // built-in Function prototype object as specified in 15.3.3.1. + // 12. Set the [[Call]] internal property of F as described in + // 15.3.4.5.1. + // 13. Set the [[Construct]] internal property of F as described in + // 15.3.4.5.2. + // 14. Set the [[HasInstance]] internal property of F as described in + // 15.3.4.5.3. + var bound; + var binder = function () { + + if (this instanceof bound) { + // 15.3.4.5.2 [[Construct]] + // When the [[Construct]] internal method of a function object, + // F that was created using the bind function is called with a + // list of arguments ExtraArgs, the following steps are taken: + // 1. Let target be the value of F's [[TargetFunction]] + // internal property. + // 2. If target has no [[Construct]] internal method, a + // TypeError exception is thrown. + // 3. Let boundArgs be the value of F's [[BoundArgs]] internal + // property. + // 4. Let args be a new list containing the same values as the + // list boundArgs in the same order followed by the same + // values as the list ExtraArgs in the same order. + // 5. Return the result of calling the [[Construct]] internal + // method of target providing args as the arguments. + + var result = apply.call( + target, + this, + array_concat.call(args, array_slice.call(arguments)) + ); + if ($Object(result) === result) { + return result; + } + return this; - return new Handlebars.SafeString(result); - }); + } else { + // 15.3.4.5.1 [[Call]] + // When the [[Call]] internal method of a function object, F, + // which was created using the bind function is called with a + // this value and a list of arguments ExtraArgs, the following + // steps are taken: + // 1. Let boundArgs be the value of F's [[BoundArgs]] internal + // property. + // 2. Let boundThis be the value of F's [[BoundThis]] internal + // property. + // 3. Let target be the value of F's [[TargetFunction]] internal + // property. + // 4. Let args be a new list containing the same values as the + // list boundArgs in the same order followed by the same + // values as the list ExtraArgs in the same order. + // 5. Return the result of calling the [[Call]] internal method + // of target providing boundThis as the this value and + // providing args as the arguments. + + // equiv: target.call(this, ...boundArgs, ...args) + return apply.call( + target, + that, + array_concat.call(args, array_slice.call(arguments)) + ); - this['Handlebars']['templates']['main'] = Handlebars.template({ - '1': function (depth0, helpers, partials, data) { - var stack1, lambda = this.lambda, - escapeExpression = this.escapeExpression, - buffer = '
      ' + - escapeExpression(lambda((stack1 = depth0 != null ? depth0.info : depth0) != null ? stack1.title : stack1, depth0)) + - '
      \n
      '; + } - stack1 = lambda((stack1 = depth0 != null ? depth0.info : depth0) != null ? stack1.description : stack1, depth0); + }; - if (stack1 != null) { - buffer += stack1; - } - buffer += '
      \n'; - stack1 = helpers['if'].call(depth0, depth0 != null ? depth0.externalDocs : depth0, { - 'name': 'if','hash': {},'fn': this.program(2, data),'inverse': this.noop,'data': data - }); + // 15. If the [[Class]] internal property of Target is "Function", then + // a. Let L be the length property of Target minus the length of A. + // b. Set the length own property of F to either 0 or L, whichever is + // larger. + // 16. Else set the length own property of F to 0. - if (stack1 != null) { - buffer += stack1; - } - buffer += ' '; - stack1 = helpers['if'].call(depth0, (stack1 = depth0 != null ? depth0.info : depth0) != null ? stack1.termsOfServiceUrl : stack1, { - 'name': 'if','hash': {},'fn': this.program(4, data),'inverse': this.noop,'data': data - }); + var boundLength = max(0, target.length - args.length); - if (stack1 != null) { - buffer += stack1; - } - buffer += '\n '; - stack1 = helpers['if'].call(depth0, (stack1 = (stack1 = depth0 != null ? depth0.info : depth0) != null ? stack1.contact : stack1) != null ? stack1.name : stack1, { - 'name': 'if','hash': {},'fn': this.program(6, data),'inverse': this.noop,'data': data - }); + // 17. Set the attributes of the length own property of F to the values + // specified in 15.3.5.1. + var boundArgs = []; + for (var i = 0; i < boundLength; i++) { + array_push.call(boundArgs, '$' + i); + } - if (stack1 != null) { - buffer += stack1; - } - buffer += '\n '; - stack1 = helpers['if'].call(depth0, (stack1 = (stack1 = depth0 != null ? depth0.info : depth0) != null ? stack1.contact : stack1) != null ? stack1.url : stack1, { - 'name': 'if','hash': {},'fn': this.program(8, data),'inverse': this.noop,'data': data - }); + // XXX Build a dynamic function with desired amount of arguments is the only + // way to set the length property of a function. + // In environments where Content Security Policies enabled (Chrome extensions, + // for ex.) all use of eval or Function costructor throws an exception. + // However in all of these environments Function.prototype.bind exists + // and so this code will never be executed. + bound = $Function('binder', 'return function (' + array_join.call(boundArgs, ',') + '){ return binder.apply(this, arguments); }')(binder); + + if (target.prototype) { + Empty.prototype = target.prototype; + bound.prototype = new Empty(); + // Clean up dangling references. + Empty.prototype = null; + } - if (stack1 != null) { - buffer += stack1; - } - buffer += '\n '; - stack1 = helpers['if'].call(depth0, (stack1 = (stack1 = depth0 != null ? depth0.info : depth0) != null ? stack1.contact : stack1) != null ? stack1.email : stack1, { - 'name': 'if','hash': {},'fn': this.program(10, data),'inverse': this.noop,'data': data - }); + // TODO + // 18. Set the [[Extensible]] internal property of F to true. + + // TODO + // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3). + // 20. Call the [[DefineOwnProperty]] internal method of F with + // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]: + // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and + // false. + // 21. Call the [[DefineOwnProperty]] internal method of F with + // arguments "arguments", PropertyDescriptor {[[Get]]: thrower, + // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false}, + // and false. + + // TODO + // NOTE Function objects created using Function.prototype.bind do not + // have a prototype property or the [[Code]], [[FormalParameters]], and + // [[Scope]] internal properties. + // XXX can't delete prototype in pure-js. + + // 22. Return F. + return bound; + } + }); - if (stack1 != null) { - buffer += stack1; - } - buffer += '\n '; - stack1 = helpers['if'].call(depth0, (stack1 = depth0 != null ? depth0.info : depth0) != null ? stack1.license : stack1, { - 'name': 'if','hash': {},'fn': this.program(12, data),'inverse': this.noop,'data': data - }); + // _Please note: Shortcuts are defined after `Function.prototype.bind` as we + // use it in defining shortcuts. + var owns = call.bind(ObjectPrototype.hasOwnProperty); + var toStr = call.bind(ObjectPrototype.toString); + var arraySlice = call.bind(array_slice); + var arraySliceApply = apply.bind(array_slice); + var strSlice = call.bind(StringPrototype.slice); + var strSplit = call.bind(StringPrototype.split); + var strIndexOf = call.bind(StringPrototype.indexOf); + var pushCall = call.bind(array_push); + var isEnum = call.bind(ObjectPrototype.propertyIsEnumerable); + var arraySort = call.bind(ArrayPrototype.sort); + + // + // Array + // ===== + // + + var isArray = $Array.isArray || function isArray(obj) { + return toStr(obj) === '[object Array]'; + }; - if (stack1 != null) { - buffer += stack1; + // ES5 15.4.4.12 + // http://es5.github.com/#x15.4.4.13 + // Return len+argCount. + // [bugfix, ielt8] + // IE < 8 bug: [].unshift(0) === undefined but should be "1" + var hasUnshiftReturnValueBug = [].unshift(0) !== 1; + defineProperties(ArrayPrototype, { + unshift: function () { + array_unshift.apply(this, arguments); + return this.length; + } + }, hasUnshiftReturnValueBug); + + // ES5 15.4.3.2 + // http://es5.github.com/#x15.4.3.2 + // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray + defineProperties($Array, { isArray: isArray }); + + // The IsCallable() check in the Array functions + // has been replaced with a strict check on the + // internal class of the object to trap cases where + // the provided function was actually a regular + // expression literal, which in V8 and + // JavaScriptCore is a typeof "function". Only in + // V8 are regular expression literals permitted as + // reduce parameters, so it is desirable in the + // general case for the shim to match the more + // strict and common behavior of rejecting regular + // expressions. + + // ES5 15.4.4.18 + // http://es5.github.com/#x15.4.4.18 + // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/forEach + + // Check failure of by-index access of string characters (IE < 9) + // and failure of `0 in boxedString` (Rhino) + var boxedString = $Object('a'); + var splitString = boxedString[0] !== 'a' || !(0 in boxedString); + + var properlyBoxesContext = function properlyBoxed(method) { + // Check node 0.6.21 bug where third parameter is not boxed + var properlyBoxesNonStrict = true; + var properlyBoxesStrict = true; + var threwException = false; + if (method) { + try { + method.call('foo', function (_, __, context) { + if (typeof context !== 'object') { + properlyBoxesNonStrict = false; } + }); - return buffer + '\n'; - },'2': function (depth0, helpers, partials, data) { - var stack1, lambda = this.lambda, - escapeExpression = this.escapeExpression; - - return '

      ' + - escapeExpression(lambda((stack1 = depth0 != null ? depth0.externalDocs : depth0) != null ? stack1.description : stack1, depth0)) + - '

      \n ' + - escapeExpression(lambda((stack1 = depth0 != null ? depth0.externalDocs : depth0) != null ? stack1.url : stack1, depth0)) + - '\n'; - },'4': function (depth0, helpers, partials, data) { - var stack1, lambda = this.lambda, - escapeExpression = this.escapeExpression; - - return ''; - },'6': function (depth0, helpers, partials, data) { - var stack1, lambda = this.lambda, - escapeExpression = this.escapeExpression; - - return '
      Created by ' + - escapeExpression(lambda((stack1 = (stack1 = depth0 != null ? depth0.info : depth0) != null ? stack1.contact : stack1) != null ? stack1.name : stack1, depth0)) + - '
      '; - },'8': function (depth0, helpers, partials, data) { - var stack1, lambda = this.lambda, - escapeExpression = this.escapeExpression; - - return ''; - },'10': function (depth0, helpers, partials, data) { - var stack1, lambda = this.lambda, - escapeExpression = this.escapeExpression; - - return ''; - },'12': function (depth0, helpers, partials, data) { - var stack1, lambda = this.lambda, - escapeExpression = this.escapeExpression; - - return ''; - },'14': function (depth0, helpers, partials, data) { - var stack1, lambda = this.lambda, - escapeExpression = this.escapeExpression; - - return ' , api version: ' + - escapeExpression(lambda((stack1 = depth0 != null ? depth0.info : depth0) != null ? stack1.version : stack1, depth0)) + - '\n '; - },'16': function (depth0, helpers, partials, data) { - var helper, functionType = 'function', - helperMissing = helpers.helperMissing, - escapeExpression = this.escapeExpression; - - return ' \n \n'; - },'compiler': [6,'>= 2.0.0-beta.1'],'main': function (depth0, helpers, partials, data) { - var stack1, helper, functionType = 'function', - helperMissing = helpers.helperMissing, - escapeExpression = this.escapeExpression, - buffer = '
      \n'; - - stack1 = helpers['if'].call(depth0, depth0 != null ? depth0.info : depth0, { - 'name': 'if','hash': {},'fn': this.program(1, data),'inverse': this.noop,'data': data - }); + method.call([1], function () { + 'use strict'; - if (stack1 != null) { - buffer += stack1; + properlyBoxesStrict = typeof this === 'string'; + }, 'x'); + } catch (e) { + threwException = true; } - buffer += '
      \n
      \n
        \n\n \n
        \n'; - },'useData': true - }); - this['Handlebars']['templates']['operation'] = Handlebars.template({ - '1': function (depth0, helpers, partials, data) { - return 'deprecated'; - },'3': function (depth0, helpers, partials, data) { - return '

        Warning: Deprecated

        \n'; - },'5': function (depth0, helpers, partials, data) { - var stack1, helper, functionType = 'function', - helperMissing = helpers.helperMissing, - buffer = '

        Implementation Notes

        \n
        '; - - stack1 = (helper = (helper = helpers.description || (depth0 != null ? depth0.description : depth0)) != null ? helper : helperMissing,typeof helper === functionType ? helper.call(depth0, { - 'name': 'description','hash': {},'data': data - }) : helper); - - if (stack1 != null) { - buffer += stack1; + while (++i < length) { + if (i in self) { + // Invoke the callback function with call, passing arguments: + // context, property value, property key, thisArg object + if (typeof T === 'undefined') { + callbackfn(self[i], i, object); + } else { + callbackfn.call(T, self[i], i, object); + } + } } - - return buffer + '
        \n'; - },'7': function (depth0, helpers, partials, data) { - return '
        \n '; - },'9': function (depth0, helpers, partials, data) { - var stack1, buffer = '
        \n'; - - stack1 = helpers.each.call(depth0, depth0, { - 'name': 'each','hash': {},'fn': this.program(10, data),'inverse': this.noop,'data': data - }); - - if (stack1 != null) { - buffer += stack1; + } + }, !properlyBoxesContext(ArrayPrototype.forEach)); + + // ES5 15.4.4.19 + // http://es5.github.com/#x15.4.4.19 + // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map + defineProperties(ArrayPrototype, { + map: function map(callbackfn/*, thisArg*/) { + var object = ES.ToObject(this); + var self = splitString && isString(this) ? strSplit(this, '') : object; + var length = ES.ToUint32(self.length); + var result = $Array(length); + var T; + if (arguments.length > 1) { + T = arguments[1]; } - return buffer + '
        \n'; - },'10': function (depth0, helpers, partials, data) { - var stack1, lambda = this.lambda, - escapeExpression = this.escapeExpression, - buffer = '
        ' + - escapeExpression(lambda(depth0 != null ? depth0.scope : depth0, depth0)) + - '
        \n'; - },'12': function (depth0, helpers, partials, data) { - return '
        '; - },'14': function (depth0, helpers, partials, data) { - return '
        \n \n
        \n'; - },'16': function (depth0, helpers, partials, data) { - var helper, functionType = 'function', - helperMissing = helpers.helperMissing, - escapeExpression = this.escapeExpression; - - return '

        Response Class (Status ' + - escapeExpression((helper = (helper = helpers.successCode || (depth0 != null ? depth0.successCode : depth0)) != null ? helper : helperMissing,typeof helper === functionType ? helper.call(depth0, { - 'name': 'successCode','hash': {},'data': data - }) : helper)) + - ')

        \n

        \n
        \n
        \n'; - },'18': function (depth0, helpers, partials, data) { - return '

        Parameters

        \n \n \n \n \n \n \n \n \n \n \n \n\n \n
        ParameterValueDescriptionParameter TypeData Type
        \n'; - },'20': function (depth0, helpers, partials, data) { - return '
        \n

        Response Messages

        \n \n \n \n \n \n \n \n \n \n \n\n \n
        HTTP Status CodeReasonResponse ModelHeaders
        \n'; - },'22': function (depth0, helpers, partials, data) { - return ''; - },'24': function (depth0, helpers, partials, data) { - return '
        \n \n Hide Response\n \n
        \n'; - },'26': function (depth0, helpers, partials, data) { - return '

        Request Headers

        \n
        \n'; - },'compiler': [6,'>= 2.0.0-beta.1'],'main': function (depth0, helpers, partials, data) { - var stack1, helper, options, functionType = 'function', - helperMissing = helpers.helperMissing, - escapeExpression = this.escapeExpression, - blockHelperMissing = helpers.blockHelperMissing, - buffer = '\n
          \n
        • \n \n
          \n'; - stack1 = helpers['if'].call(depth0, depth0 != null ? depth0.deprecated : depth0, { - 'name': 'if','hash': {},'fn': this.program(3, data),'inverse': this.noop,'data': data - }); - if (stack1 != null) { - buffer += stack1; + // If no callback function or if callback is not a callable function + if (!isCallable(callbackfn)) { + throw new TypeError('Array.prototype.filter callback must be a function'); } - stack1 = helpers['if'].call(depth0, depth0 != null ? depth0.description : depth0, { - 'name': 'if','hash': {},'fn': this.program(5, data),'inverse': this.noop,'data': data - }); - if (stack1 != null) { - buffer += stack1; + for (var i = 0; i < length; i++) { + if (i in self) { + value = self[i]; + if (typeof T === 'undefined' ? callbackfn(value, i, object) : callbackfn.call(T, value, i, object)) { + pushCall(result, value); + } + } } - stack1 = (helper = (helper = helpers.oauth || (depth0 != null ? depth0.oauth : depth0)) != null ? helper : helperMissing,options = { - 'name': 'oauth','hash': {},'fn': this.program(7, data),'inverse': this.noop,'data': data - },typeof helper === functionType ? helper.call(depth0, options) : helper); - - if (!helpers.oauth) { - stack1 = blockHelperMissing.call(depth0, stack1, options); + return result; + } + }, !properlyBoxesContext(ArrayPrototype.filter)); + + // ES5 15.4.4.16 + // http://es5.github.com/#x15.4.4.16 + // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every + defineProperties(ArrayPrototype, { + every: function every(callbackfn/*, thisArg*/) { + var object = ES.ToObject(this); + var self = splitString && isString(this) ? strSplit(this, '') : object; + var length = ES.ToUint32(self.length); + var T; + if (arguments.length > 1) { + T = arguments[1]; } - if (stack1 != null) { - buffer += stack1; + // If no callback function or if callback is not a callable function + if (!isCallable(callbackfn)) { + throw new TypeError('Array.prototype.every callback must be a function'); } - buffer += '\n'; - stack1 = helpers.each.call(depth0, depth0 != null ? depth0.oauth : depth0, { - 'name': 'each','hash': {},'fn': this.program(9, data),'inverse': this.noop,'data': data - }); - if (stack1 != null) { - buffer += stack1; + for (var i = 0; i < length; i++) { + if (i in self && !(typeof T === 'undefined' ? callbackfn(self[i], i, object) : callbackfn.call(T, self[i], i, object))) { + return false; + } } - buffer += ' '; - stack1 = (helper = (helper = helpers.oauth || (depth0 != null ? depth0.oauth : depth0)) != null ? helper : helperMissing,options = { - 'name': 'oauth','hash': {},'fn': this.program(12, data),'inverse': this.noop,'data': data - },typeof helper === functionType ? helper.call(depth0, options) : helper); - - if (!helpers.oauth) { - stack1 = blockHelperMissing.call(depth0, stack1, options); + return true; + } + }, !properlyBoxesContext(ArrayPrototype.every)); + + // ES5 15.4.4.17 + // http://es5.github.com/#x15.4.4.17 + // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some + defineProperties(ArrayPrototype, { + some: function some(callbackfn/*, thisArg */) { + var object = ES.ToObject(this); + var self = splitString && isString(this) ? strSplit(this, '') : object; + var length = ES.ToUint32(self.length); + var T; + if (arguments.length > 1) { + T = arguments[1]; } - if (stack1 != null) { - buffer += stack1; + // If no callback function or if callback is not a callable function + if (!isCallable(callbackfn)) { + throw new TypeError('Array.prototype.some callback must be a function'); } - buffer += '\n'; - stack1 = (helper = (helper = helpers.oauth || (depth0 != null ? depth0.oauth : depth0)) != null ? helper : helperMissing,options = { - 'name': 'oauth','hash': {},'fn': this.program(14, data),'inverse': this.noop,'data': data - },typeof helper === functionType ? helper.call(depth0, options) : helper); - if (!helpers.oauth) { - stack1 = blockHelperMissing.call(depth0, stack1, options); + for (var i = 0; i < length; i++) { + if (i in self && (typeof T === 'undefined' ? callbackfn(self[i], i, object) : callbackfn.call(T, self[i], i, object))) { + return true; + } } - - if (stack1 != null) { - buffer += stack1; + return false; + } + }, !properlyBoxesContext(ArrayPrototype.some)); + + // ES5 15.4.4.21 + // http://es5.github.com/#x15.4.4.21 + // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce + var reduceCoercesToObject = false; + if (ArrayPrototype.reduce) { + reduceCoercesToObject = typeof ArrayPrototype.reduce.call('es5', function (_, __, ___, list) { + return list; + }) === 'object'; + } + defineProperties(ArrayPrototype, { + reduce: function reduce(callbackfn/*, initialValue*/) { + var object = ES.ToObject(this); + var self = splitString && isString(this) ? strSplit(this, '') : object; + var length = ES.ToUint32(self.length); + + // If no callback function or if callback is not a callable function + if (!isCallable(callbackfn)) { + throw new TypeError('Array.prototype.reduce callback must be a function'); } - stack1 = helpers['if'].call(depth0, depth0 != null ? depth0.type : depth0, { - 'name': 'if','hash': {},'fn': this.program(16, data),'inverse': this.noop,'data': data - }); - if (stack1 != null) { - buffer += stack1; + // no value to return if no initial value and an empty array + if (length === 0 && arguments.length === 1) { + throw new TypeError('reduce of empty array with no initial value'); } - buffer += '
          \n
          \n'; - stack1 = helpers['if'].call(depth0, depth0 != null ? depth0.parameters : depth0, { - 'name': 'if','hash': {},'fn': this.program(18, data),'inverse': this.noop,'data': data - }); - if (stack1 != null) { - buffer += stack1; - } - stack1 = helpers['if'].call(depth0, depth0 != null ? depth0.responseMessages : depth0, { - 'name': 'if','hash': {},'fn': this.program(20, data),'inverse': this.noop,'data': data - }); + var i = 0; + var result; + if (arguments.length >= 2) { + result = arguments[1]; + } else { + do { + if (i in self) { + result = self[i++]; + break; + } - if (stack1 != null) { - buffer += stack1; + // if array contains no values, no initial value to return + if (++i >= length) { + throw new TypeError('reduce of empty array with no initial value'); + } + } while (true); } - stack1 = helpers['if'].call(depth0, depth0 != null ? depth0.isReadOnly : depth0, { - 'name': 'if','hash': {},'fn': this.program(22, data),'inverse': this.program(24, data),'data': data - }); - if (stack1 != null) { - buffer += stack1; + for (; i < length; i++) { + if (i in self) { + result = callbackfn(result, self[i], i, object); + } } - buffer += '
          \n
          \n

          Curl

          \n
          \n

          Request URL

          \n
          \n'; - stack1 = helpers['if'].call(depth0, depth0 != null ? depth0.showRequestHeaders : depth0, { - 'name': 'if','hash': {},'fn': this.program(26, data),'inverse': this.noop,'data': data - }); - if (stack1 != null) { - buffer += stack1; + return result; + } + }, !reduceCoercesToObject); + + // ES5 15.4.4.22 + // http://es5.github.com/#x15.4.4.22 + // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight + var reduceRightCoercesToObject = false; + if (ArrayPrototype.reduceRight) { + reduceRightCoercesToObject = typeof ArrayPrototype.reduceRight.call('es5', function (_, __, ___, list) { + return list; + }) === 'object'; + } + defineProperties(ArrayPrototype, { + reduceRight: function reduceRight(callbackfn/*, initial*/) { + var object = ES.ToObject(this); + var self = splitString && isString(this) ? strSplit(this, '') : object; + var length = ES.ToUint32(self.length); + + // If no callback function or if callback is not a callable function + if (!isCallable(callbackfn)) { + throw new TypeError('Array.prototype.reduceRight callback must be a function'); } - return buffer + '

          Response Body

          \n
          \n

          Response Code

          \n
          \n

          Response Headers

          \n
          \n
          \n
          \n
        • \n
        \n'; - },'useData': true - }); - this['Handlebars']['templates']['param_list'] = Handlebars.template({ - '1': function (depth0, helpers, partials, data) { - return ' required'; - },'3': function (depth0, helpers, partials, data) { - return ' multiple="multiple"'; - },'5': function (depth0, helpers, partials, data) { - return ' required '; - },'7': function (depth0, helpers, partials, data) { - var stack1, buffer = ' \n'; - },'8': function (depth0, helpers, partials, data) { - return ' selected="\" '; - },'10': function (depth0, helpers, partials, data) { - var stack1, helper, functionType = 'function', - helperMissing = helpers.helperMissing, - escapeExpression = this.escapeExpression, - buffer = '\n \n\n'; - },'11': function (depth0, helpers, partials, data) { - return ' selected="\" '; - },'13': function (depth0, helpers, partials, data) { - return ' (default) '; - },'15': function (depth0, helpers, partials, data) { - return ''; - },'17': function (depth0, helpers, partials, data) { - return ''; - },'compiler': [6,'>= 2.0.0-beta.1'],'main': function (depth0, helpers, partials, data) { - var stack1, helper, functionType = 'function', - helperMissing = helpers.helperMissing, - escapeExpression = this.escapeExpression, - buffer = '\n\n \n\n'; - stack1 = helpers['if'].call(depth0, depth0 != null ? depth0.required : depth0, { - 'name': 'if','hash': {},'fn': this.program(15, data),'inverse': this.noop,'data': data - }); - - if (stack1 != null) { - buffer += stack1; + // handle negative indices + i = i >= 0 ? i : length - Math.abs(i); + for (; i >= 0; i--) { + if (i in self && searchElement === self[i]) { + return i; + } } - stack1 = (helper = (helper = helpers.description || (depth0 != null ? depth0.description : depth0)) != null ? helper : helperMissing,typeof helper === functionType ? helper.call(depth0, { - 'name': 'description','hash': {},'data': data - }) : helper); - - if (stack1 != null) { - buffer += stack1; + return -1; + } + }, hasFirefox2LastIndexOfBug); + + // ES5 15.4.4.12 + // http://es5.github.com/#x15.4.4.12 + var spliceNoopReturnsEmptyArray = (function () { + var a = [1, 2]; + var result = a.splice(); + return a.length === 2 && isArray(result) && result.length === 0; + }()); + defineProperties(ArrayPrototype, { + // Safari 5.0 bug where .splice() returns undefined + splice: function splice(start, deleteCount) { + if (arguments.length === 0) { + return []; + } else { + return array_splice.apply(this, arguments); } - stack1 = helpers['if'].call(depth0, depth0 != null ? depth0.required : depth0, { - 'name': 'if','hash': {},'fn': this.program(17, data),'inverse': this.noop,'data': data - }); - - if (stack1 != null) { - buffer += stack1; + } + }, !spliceNoopReturnsEmptyArray); + + var spliceWorksWithEmptyObject = (function () { + var obj = {}; + ArrayPrototype.splice.call(obj, 0, 0, 1); + return obj.length === 1; + }()); + defineProperties(ArrayPrototype, { + splice: function splice(start, deleteCount) { + if (arguments.length === 0) { + return []; } - buffer += '\n'; - stack1 = (helper = (helper = helpers.paramType || (depth0 != null ? depth0.paramType : depth0)) != null ? helper : helperMissing,typeof helper === functionType ? helper.call(depth0, { - 'name': 'paramType','hash': {},'data': data - }) : helper); - - if (stack1 != null) { - buffer += stack1; + var args = arguments; + this.length = max(ES.ToInteger(this.length), 0); + if (arguments.length > 0 && typeof deleteCount !== 'number') { + args = arraySlice(arguments); + if (args.length < 2) { + pushCall(args, this.length - start); + } else { + args[1] = ES.ToInteger(deleteCount); + } } - - return buffer + '\n\n'; - },'useData': true - }); - this['Handlebars']['templates']['param_readonly_required'] = Handlebars.template({ - '1': function (depth0, helpers, partials, data) { - var helper, functionType = 'function', - helperMissing = helpers.helperMissing, - escapeExpression = this.escapeExpression; - - return ' \n'; - },'3': function (depth0, helpers, partials, data) { - var stack1, buffer = ''; - - stack1 = helpers['if'].call(depth0, depth0 != null ? depth0['default'] : depth0, { - 'name': 'if','hash': {},'fn': this.program(4, data),'inverse': this.program(6, data),'data': data - }); - - if (stack1 != null) { - buffer += stack1; + return array_splice.apply(this, args); + } + }, !spliceWorksWithEmptyObject); + var spliceWorksWithLargeSparseArrays = (function () { + // Per https://github.com/es-shims/es5-shim/issues/295 + // Safari 7/8 breaks with sparse arrays of size 1e5 or greater + var arr = new $Array(1e5); + // note: the index MUST be 8 or larger or the test will false pass + arr[8] = 'x'; + arr.splice(1, 1); + // note: this test must be defined *after* the indexOf shim + // per https://github.com/es-shims/es5-shim/issues/313 + return arr.indexOf('x') === 7; + }()); + var spliceWorksWithSmallSparseArrays = (function () { + // Per https://github.com/es-shims/es5-shim/issues/295 + // Opera 12.15 breaks on this, no idea why. + var n = 256; + var arr = []; + arr[n] = 'a'; + arr.splice(n + 1, 0, 'b'); + return arr[n] === 'a'; + }()); + defineProperties(ArrayPrototype, { + splice: function splice(start, deleteCount) { + var O = ES.ToObject(this); + var A = []; + var len = ES.ToUint32(O.length); + var relativeStart = ES.ToInteger(start); + var actualStart = relativeStart < 0 ? max((len + relativeStart), 0) : min(relativeStart, len); + var actualDeleteCount = min(max(ES.ToInteger(deleteCount), 0), len - actualStart); + + var k = 0; + var from; + while (k < actualDeleteCount) { + from = $String(actualStart + k); + if (owns(O, from)) { + A[k] = O[from]; + } + k += 1; } - return buffer; - },'4': function (depth0, helpers, partials, data) { - var helper, functionType = 'function', - helperMissing = helpers.helperMissing, - escapeExpression = this.escapeExpression; - - return ' ' + - escapeExpression((helper = (helper = helpers['default'] || (depth0 != null ? depth0['default'] : depth0)) != null ? helper : helperMissing,typeof helper === functionType ? helper.call(depth0, { - 'name': 'default','hash': {},'data': data - }) : helper)) + - '\n'; - },'6': function (depth0, helpers, partials, data) { - return ' (empty)\n'; - },'compiler': [6,'>= 2.0.0-beta.1'],'main': function (depth0, helpers, partials, data) { - var stack1, helper, functionType = 'function', - helperMissing = helpers.helperMissing, - escapeExpression = this.escapeExpression, - buffer = '\n\n'; - - stack1 = helpers['if'].call(depth0, depth0 != null ? depth0.isBody : depth0, { - 'name': 'if','hash': {},'fn': this.program(1, data),'inverse': this.program(3, data),'data': data - }); - - if (stack1 != null) { - buffer += stack1; + var items = arraySlice(arguments, 2); + var itemCount = items.length; + var to; + if (itemCount < actualDeleteCount) { + k = actualStart; + var maxK = len - actualDeleteCount; + while (k < maxK) { + from = $String(k + actualDeleteCount); + to = $String(k + itemCount); + if (owns(O, from)) { + O[to] = O[from]; + } else { + delete O[to]; + } + k += 1; + } + k = len; + var minK = len - actualDeleteCount + itemCount; + while (k > minK) { + delete O[k - 1]; + k -= 1; + } + } else if (itemCount > actualDeleteCount) { + k = len - actualDeleteCount; + while (k > actualStart) { + from = $String(k + actualDeleteCount - 1); + to = $String(k + itemCount - 1); + if (owns(O, from)) { + O[to] = O[from]; + } else { + delete O[to]; + } + k -= 1; + } } - buffer += '\n'; - stack1 = (helper = (helper = helpers.description || (depth0 != null ? depth0.description : depth0)) != null ? helper : helperMissing,typeof helper === functionType ? helper.call(depth0, { - 'name': 'description','hash': {},'data': data - }) : helper); - - if (stack1 != null) { - buffer += stack1; + k = actualStart; + for (var i = 0; i < items.length; ++i) { + O[k] = items[i]; + k += 1; } - buffer += '\n'; - stack1 = (helper = (helper = helpers.paramType || (depth0 != null ? depth0.paramType : depth0)) != null ? helper : helperMissing,typeof helper === functionType ? helper.call(depth0, { - 'name': 'paramType','hash': {},'data': data - }) : helper); + O.length = len - actualDeleteCount + itemCount; - if (stack1 != null) { - buffer += stack1; + return A; + } + }, !spliceWorksWithLargeSparseArrays || !spliceWorksWithSmallSparseArrays); + + var originalJoin = ArrayPrototype.join; + var hasStringJoinBug; + try { + hasStringJoinBug = Array.prototype.join.call('123', ',') !== '1,2,3'; + } catch (e) { + hasStringJoinBug = true; + } + if (hasStringJoinBug) { + defineProperties(ArrayPrototype, { + join: function join(separator) { + var sep = typeof separator === 'undefined' ? ',' : separator; + return originalJoin.call(isString(this) ? strSplit(this, '') : this, sep); } + }, hasStringJoinBug); + } - return buffer + '\n\n'; - },'useData': true - }); - this['Handlebars']['templates']['param_readonly'] = Handlebars.template({ - '1': function (depth0, helpers, partials, data) { - var helper, functionType = 'function', - helperMissing = helpers.helperMissing, - escapeExpression = this.escapeExpression; - - return ' \n'; - },'3': function (depth0, helpers, partials, data) { - var stack1, buffer = ''; - - stack1 = helpers['if'].call(depth0, depth0 != null ? depth0['default'] : depth0, { - 'name': 'if','hash': {},'fn': this.program(4, data),'inverse': this.program(6, data),'data': data - }); - - if (stack1 != null) { - buffer += stack1; + var hasJoinUndefinedBug = [1, 2].join(undefined) !== '1,2'; + if (hasJoinUndefinedBug) { + defineProperties(ArrayPrototype, { + join: function join(separator) { + var sep = typeof separator === 'undefined' ? ',' : separator; + return originalJoin.call(this, sep); } + }, hasJoinUndefinedBug); + } - return buffer; - },'4': function (depth0, helpers, partials, data) { - var helper, functionType = 'function', - helperMissing = helpers.helperMissing, - escapeExpression = this.escapeExpression; - - return ' ' + - escapeExpression((helper = (helper = helpers['default'] || (depth0 != null ? depth0['default'] : depth0)) != null ? helper : helperMissing,typeof helper === functionType ? helper.call(depth0, { - 'name': 'default','hash': {},'data': data - }) : helper)) + - '\n'; - },'6': function (depth0, helpers, partials, data) { - return ' (empty)\n'; - },'compiler': [6,'>= 2.0.0-beta.1'],'main': function (depth0, helpers, partials, data) { - var stack1, helper, functionType = 'function', - helperMissing = helpers.helperMissing, - escapeExpression = this.escapeExpression, - buffer = '\n\n'; - - stack1 = helpers['if'].call(depth0, depth0 != null ? depth0.isBody : depth0, { - 'name': 'if','hash': {},'fn': this.program(1, data),'inverse': this.program(3, data),'data': data - }); + var pushShim = function push(item) { + var O = ES.ToObject(this); + var n = ES.ToUint32(O.length); + var i = 0; + while (i < arguments.length) { + O[n + i] = arguments[i]; + i += 1; + } + O.length = n + i; + return n + i; + }; - if (stack1 != null) { - buffer += stack1; + var pushIsNotGeneric = (function () { + var obj = {}; + var result = Array.prototype.push.call(obj, undefined); + return result !== 1 || obj.length !== 1 || typeof obj[0] !== 'undefined' || !owns(obj, 0); + }()); + defineProperties(ArrayPrototype, { + push: function push(item) { + if (isArray(this)) { + return array_push.apply(this, arguments); } - buffer += '\n'; - stack1 = (helper = (helper = helpers.description || (depth0 != null ? depth0.description : depth0)) != null ? helper : helperMissing,typeof helper === functionType ? helper.call(depth0, { - 'name': 'description','hash': {},'data': data - }) : helper); - - if (stack1 != null) { - buffer += stack1; + return pushShim.apply(this, arguments); + } + }, pushIsNotGeneric); + + // This fixes a very weird bug in Opera 10.6 when pushing `undefined + var pushUndefinedIsWeird = (function () { + var arr = []; + var result = arr.push(undefined); + return result !== 1 || arr.length !== 1 || typeof arr[0] !== 'undefined' || !owns(arr, 0); + }()); + defineProperties(ArrayPrototype, { push: pushShim }, pushUndefinedIsWeird); + + // ES5 15.2.3.14 + // http://es5.github.io/#x15.4.4.10 + // Fix boxed string bug + defineProperties(ArrayPrototype, { + slice: function (start, end) { + var arr = isString(this) ? strSplit(this, '') : this; + return arraySliceApply(arr, arguments); + } + }, splitString); + + var sortIgnoresNonFunctions = (function () { + try { + [1, 2].sort(null); + [1, 2].sort({}); + return true; + } catch (e) {} + return false; + }()); + var sortThrowsOnRegex = (function () { + // this is a problem in Firefox 4, in which `typeof /a/ === 'function'` + try { + [1, 2].sort(/a/); + return false; + } catch (e) {} + return true; + }()); + var sortIgnoresUndefined = (function () { + // applies in IE 8, for one. + try { + [1, 2].sort(undefined); + return true; + } catch (e) {} + return false; + }()); + defineProperties(ArrayPrototype, { + sort: function sort(compareFn) { + if (typeof compareFn === 'undefined') { + return arraySort(this); } - buffer += '\n'; - stack1 = (helper = (helper = helpers.paramType || (depth0 != null ? depth0.paramType : depth0)) != null ? helper : helperMissing,typeof helper === functionType ? helper.call(depth0, { - 'name': 'paramType','hash': {},'data': data - }) : helper); - - if (stack1 != null) { - buffer += stack1; + if (!isCallable(compareFn)) { + throw new TypeError('Array.prototype.sort callback must be a function'); + } + return arraySort(this, compareFn); + } + }, sortIgnoresNonFunctions || !sortIgnoresUndefined || !sortThrowsOnRegex); + + // + // Object + // ====== + // + + // ES5 15.2.3.14 + // http://es5.github.com/#x15.2.3.14 + + // http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation + var hasDontEnumBug = !isEnum({ 'toString': null }, 'toString'); + var hasProtoEnumBug = isEnum(function () {}, 'prototype'); + var hasStringEnumBug = !owns('x', '0'); + var equalsConstructorPrototype = function (o) { + var ctor = o.constructor; + return ctor && ctor.prototype === o; + }; + var blacklistedKeys = { + $window: true, + $console: true, + $parent: true, + $self: true, + $frame: true, + $frames: true, + $frameElement: true, + $webkitIndexedDB: true, + $webkitStorageInfo: true, + $external: true + }; + var hasAutomationEqualityBug = (function () { + /* globals window */ + if (typeof window === 'undefined') { + return false; + } + for (var k in window) { + try { + if (!blacklistedKeys['$' + k] && owns(window, k) && window[k] !== null && typeof window[k] === 'object') { + equalsConstructorPrototype(window[k]); + } + } catch (e) { + return true; } + } + return false; + }()); + var equalsConstructorPrototypeIfNotBuggy = function (object) { + if (typeof window === 'undefined' || !hasAutomationEqualityBug) { + return equalsConstructorPrototype(object); + } + try { + return equalsConstructorPrototype(object); + } catch (e) { + return false; + } + }; + var dontEnums = [ + 'toString', + 'toLocaleString', + 'valueOf', + 'hasOwnProperty', + 'isPrototypeOf', + 'propertyIsEnumerable', + 'constructor' + ]; + var dontEnumsLength = dontEnums.length; + + // taken directly from https://github.com/ljharb/is-arguments/blob/master/index.js + // can be replaced with require('is-arguments') if we ever use a build process instead + var isStandardArguments = function isArguments(value) { + return toStr(value) === '[object Arguments]'; + }; + var isLegacyArguments = function isArguments(value) { + return value !== null && + typeof value === 'object' && + typeof value.length === 'number' && + value.length >= 0 && + !isArray(value) && + isCallable(value.callee); + }; + var isArguments = isStandardArguments(arguments) ? isStandardArguments : isLegacyArguments; - return buffer + '\n\n'; - },'useData': true - }); - this['Handlebars']['templates']['param_required'] = Handlebars.template({ - '1': function (depth0, helpers, partials, data) { - var stack1, buffer = ''; + defineProperties($Object, { + keys: function keys(object) { + var isFn = isCallable(object); + var isArgs = isArguments(object); + var isObject = object !== null && typeof object === 'object'; + var isStr = isObject && isString(object); - stack1 = helpers['if'].call(depth0, depth0 != null ? depth0.isFile : depth0, { - 'name': 'if','hash': {},'fn': this.program(2, data),'inverse': this.program(4, data),'data': data - }); + if (!isObject && !isFn && !isArgs) { + throw new TypeError('Object.keys called on a non-object'); + } + + var theKeys = []; + var skipProto = hasProtoEnumBug && isFn; + if ((isStr && hasStringEnumBug) || isArgs) { + for (var i = 0; i < object.length; ++i) { + pushCall(theKeys, $String(i)); + } + } - if (stack1 != null) { - buffer += stack1; + if (!isArgs) { + for (var name in object) { + if (!(skipProto && name === 'prototype') && owns(object, name)) { + pushCall(theKeys, $String(name)); } + } + } - return buffer; - },'2': function (depth0, helpers, partials, data) { - var helper, functionType = 'function', - helperMissing = helpers.helperMissing, - escapeExpression = this.escapeExpression; - - return ' \n'; - },'4': function (depth0, helpers, partials, data) { - var stack1, buffer = ''; - - stack1 = helpers['if'].call(depth0, depth0 != null ? depth0['default'] : depth0, { - 'name': 'if','hash': {},'fn': this.program(5, data),'inverse': this.program(7, data),'data': data - }); + if (hasDontEnumBug) { + var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object); + for (var j = 0; j < dontEnumsLength; j++) { + var dontEnum = dontEnums[j]; + if (!(skipConstructor && dontEnum === 'constructor') && owns(object, dontEnum)) { + pushCall(theKeys, dontEnum); + } + } + } + return theKeys; + } + }); - if (stack1 != null) { - buffer += stack1; + var keysWorksWithArguments = $Object.keys && (function () { + // Safari 5.0 bug + return $Object.keys(arguments).length === 2; + }(1, 2)); + var keysHasArgumentsLengthBug = $Object.keys && (function () { + var argKeys = $Object.keys(arguments); + return arguments.length !== 1 || argKeys.length !== 1 || argKeys[0] !== 1; + }(1)); + var originalKeys = $Object.keys; + defineProperties($Object, { + keys: function keys(object) { + if (isArguments(object)) { + return originalKeys(arraySlice(object)); + } else { + return originalKeys(object); } + } + }, !keysWorksWithArguments || keysHasArgumentsLengthBug); + + // + // Date + // ==== + // + + var hasNegativeMonthYearBug = new Date(-3509827329600292).getUTCMonth() !== 0; + var aNegativeTestDate = new Date(-1509842289600292); + var aPositiveTestDate = new Date(1449662400000); + var hasToUTCStringFormatBug = aNegativeTestDate.toUTCString() !== 'Mon, 01 Jan -45875 11:59:59 GMT'; + var hasToDateStringFormatBug; + var hasToStringFormatBug; + var timeZoneOffset = aNegativeTestDate.getTimezoneOffset(); + if (timeZoneOffset < -720) { + hasToDateStringFormatBug = aNegativeTestDate.toDateString() !== 'Tue Jan 02 -45875'; + hasToStringFormatBug = !(/^Thu Dec 10 2015 \d\d:\d\d:\d\d GMT[-\+]\d\d\d\d(?: |$)/).test(aPositiveTestDate.toString()); + } else { + hasToDateStringFormatBug = aNegativeTestDate.toDateString() !== 'Mon Jan 01 -45875'; + hasToStringFormatBug = !(/^Wed Dec 09 2015 \d\d:\d\d:\d\d GMT[-\+]\d\d\d\d(?: |$)/).test(aPositiveTestDate.toString()); + } - return buffer; - },'5': function (depth0, helpers, partials, data) { - var helper, functionType = 'function', - helperMissing = helpers.helperMissing, - escapeExpression = this.escapeExpression; - - return ' \n
        \n
        \n'; - },'7': function (depth0, helpers, partials, data) { - var helper, functionType = 'function', - helperMissing = helpers.helperMissing, - escapeExpression = this.escapeExpression; - - return ' \n
        \n
        \n'; - },'9': function (depth0, helpers, partials, data) { - var stack1, buffer = ''; - - stack1 = helpers['if'].call(depth0, depth0 != null ? depth0.isFile : depth0, { - 'name': 'if','hash': {},'fn': this.program(10, data),'inverse': this.program(12, data),'data': data - }); + var originalGetFullYear = call.bind(Date.prototype.getFullYear); + var originalGetMonth = call.bind(Date.prototype.getMonth); + var originalGetDate = call.bind(Date.prototype.getDate); + var originalGetUTCFullYear = call.bind(Date.prototype.getUTCFullYear); + var originalGetUTCMonth = call.bind(Date.prototype.getUTCMonth); + var originalGetUTCDate = call.bind(Date.prototype.getUTCDate); + var originalGetUTCDay = call.bind(Date.prototype.getUTCDay); + var originalGetUTCHours = call.bind(Date.prototype.getUTCHours); + var originalGetUTCMinutes = call.bind(Date.prototype.getUTCMinutes); + var originalGetUTCSeconds = call.bind(Date.prototype.getUTCSeconds); + var originalGetUTCMilliseconds = call.bind(Date.prototype.getUTCMilliseconds); + var dayName = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; + var monthName = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; + var daysInMonth = function daysInMonth(month, year) { + return originalGetDate(new Date(year, month, 0)); + }; - if (stack1 != null) { - buffer += stack1; + defineProperties(Date.prototype, { + getFullYear: function getFullYear() { + if (!this || !(this instanceof Date)) { + throw new TypeError('this is not a Date object.'); + } + var year = originalGetFullYear(this); + if (year < 0 && originalGetMonth(this) > 11) { + return year + 1; + } + return year; + }, + getMonth: function getMonth() { + if (!this || !(this instanceof Date)) { + throw new TypeError('this is not a Date object.'); + } + var year = originalGetFullYear(this); + var month = originalGetMonth(this); + if (year < 0 && month > 11) { + return 0; + } + return month; + }, + getDate: function getDate() { + if (!this || !(this instanceof Date)) { + throw new TypeError('this is not a Date object.'); + } + var year = originalGetFullYear(this); + var month = originalGetMonth(this); + var date = originalGetDate(this); + if (year < 0 && month > 11) { + if (month === 12) { + return date; + } + var days = daysInMonth(0, year + 1); + return (days - date) + 1; + } + return date; + }, + getUTCFullYear: function getUTCFullYear() { + if (!this || !(this instanceof Date)) { + throw new TypeError('this is not a Date object.'); + } + var year = originalGetUTCFullYear(this); + if (year < 0 && originalGetUTCMonth(this) > 11) { + return year + 1; + } + return year; + }, + getUTCMonth: function getUTCMonth() { + if (!this || !(this instanceof Date)) { + throw new TypeError('this is not a Date object.'); + } + var year = originalGetUTCFullYear(this); + var month = originalGetUTCMonth(this); + if (year < 0 && month > 11) { + return 0; } + return month; + }, + getUTCDate: function getUTCDate() { + if (!this || !(this instanceof Date)) { + throw new TypeError('this is not a Date object.'); + } + var year = originalGetUTCFullYear(this); + var month = originalGetUTCMonth(this); + var date = originalGetUTCDate(this); + if (year < 0 && month > 11) { + if (month === 12) { + return date; + } + var days = daysInMonth(0, year + 1); + return (days - date) + 1; + } + return date; + } + }, hasNegativeMonthYearBug); - return buffer; - },'10': function (depth0, helpers, partials, data) { - var helper, functionType = 'function', - helperMissing = helpers.helperMissing, - escapeExpression = this.escapeExpression; - - return ' \n'; - },'12': function (depth0, helpers, partials, data) { - var stack1, helperMissing = helpers.helperMissing, - buffer = ''; - - stack1 = (helpers.renderTextParam || depth0 && depth0.renderTextParam || helperMissing).call(depth0, depth0, { - 'name': 'renderTextParam','hash': {},'fn': this.program(13, data),'inverse': this.noop,'data': data - }); + defineProperties(Date.prototype, { + toUTCString: function toUTCString() { + if (!this || !(this instanceof Date)) { + throw new TypeError('this is not a Date object.'); + } + var day = originalGetUTCDay(this); + var date = originalGetUTCDate(this); + var month = originalGetUTCMonth(this); + var year = originalGetUTCFullYear(this); + var hour = originalGetUTCHours(this); + var minute = originalGetUTCMinutes(this); + var second = originalGetUTCSeconds(this); + return dayName[day] + ', ' + + (date < 10 ? '0' + date : date) + ' ' + + monthName[month] + ' ' + + year + ' ' + + (hour < 10 ? '0' + hour : hour) + ':' + + (minute < 10 ? '0' + minute : minute) + ':' + + (second < 10 ? '0' + second : second) + ' GMT'; + } + }, hasNegativeMonthYearBug || hasToUTCStringFormatBug); - if (stack1 != null) { - buffer += stack1; + // Opera 12 has `,` + defineProperties(Date.prototype, { + toDateString: function toDateString() { + if (!this || !(this instanceof Date)) { + throw new TypeError('this is not a Date object.'); } + var day = this.getDay(); + var date = this.getDate(); + var month = this.getMonth(); + var year = this.getFullYear(); + return dayName[day] + ' ' + + monthName[month] + ' ' + + (date < 10 ? '0' + date : date) + ' ' + + year; + } + }, hasNegativeMonthYearBug || hasToDateStringFormatBug); - return buffer; - },'13': function (depth0, helpers, partials, data) { - return ''; - },'compiler': [6,'>= 2.0.0-beta.1'],'main': function (depth0, helpers, partials, data) { - var stack1, helper, functionType = 'function', - helperMissing = helpers.helperMissing, - escapeExpression = this.escapeExpression, - buffer = '\n\n'; - - stack1 = helpers['if'].call(depth0, depth0 != null ? depth0.isBody : depth0, { - 'name': 'if','hash': {},'fn': this.program(1, data),'inverse': this.program(9, data),'data': data + // can't use defineProperties here because of toString enumeration issue in IE <= 8 + if (hasNegativeMonthYearBug || hasToStringFormatBug) { + Date.prototype.toString = function toString() { + if (!this || !(this instanceof Date)) { + throw new TypeError('this is not a Date object.'); + } + var day = this.getDay(); + var date = this.getDate(); + var month = this.getMonth(); + var year = this.getFullYear(); + var hour = this.getHours(); + var minute = this.getMinutes(); + var second = this.getSeconds(); + var timezoneOffset = this.getTimezoneOffset(); + var hoursOffset = Math.floor(Math.abs(timezoneOffset) / 60); + var minutesOffset = Math.floor(Math.abs(timezoneOffset) % 60); + return dayName[day] + ' ' + + monthName[month] + ' ' + + (date < 10 ? '0' + date : date) + ' ' + + year + ' ' + + (hour < 10 ? '0' + hour : hour) + ':' + + (minute < 10 ? '0' + minute : minute) + ':' + + (second < 10 ? '0' + second : second) + ' GMT' + + (timezoneOffset > 0 ? '-' : '+') + + (hoursOffset < 10 ? '0' + hoursOffset : hoursOffset) + + (minutesOffset < 10 ? '0' + minutesOffset : minutesOffset); + }; + if (supportsDescriptors) { + $Object.defineProperty(Date.prototype, 'toString', { + configurable: true, + enumerable: false, + writable: true }); + } + } - if (stack1 != null) { - buffer += stack1; + // ES5 15.9.5.43 + // http://es5.github.com/#x15.9.5.43 + // This function returns a String value represent the instance in time + // represented by this Date object. The format of the String is the Date Time + // string format defined in 15.9.1.15. All fields are present in the String. + // The time zone is always UTC, denoted by the suffix Z. If the time value of + // this object is not a finite Number a RangeError exception is thrown. + var negativeDate = -62198755200000; + var negativeYearString = '-000001'; + var hasNegativeDateBug = Date.prototype.toISOString && new Date(negativeDate).toISOString().indexOf(negativeYearString) === -1; + var hasSafari51DateBug = Date.prototype.toISOString && new Date(-1).toISOString() !== '1969-12-31T23:59:59.999Z'; + + var getTime = call.bind(Date.prototype.getTime); + + defineProperties(Date.prototype, { + toISOString: function toISOString() { + if (!isFinite(this) || !isFinite(getTime(this))) { + // Adope Photoshop requires the second check. + throw new RangeError('Date.prototype.toISOString called on non-finite value.'); } - buffer += '\n\n '; - stack1 = (helper = (helper = helpers.description || (depth0 != null ? depth0.description : depth0)) != null ? helper : helperMissing,typeof helper === functionType ? helper.call(depth0, { - 'name': 'description','hash': {},'data': data - }) : helper); - if (stack1 != null) { - buffer += stack1; - } - buffer += '\n\n'; - stack1 = (helper = (helper = helpers.paramType || (depth0 != null ? depth0.paramType : depth0)) != null ? helper : helperMissing,typeof helper === functionType ? helper.call(depth0, { - 'name': 'paramType','hash': {},'data': data - }) : helper); + var year = originalGetUTCFullYear(this); - if (stack1 != null) { - buffer += stack1; - } + var month = originalGetUTCMonth(this); + // see https://github.com/es-shims/es5-shim/issues/111 + year += Math.floor(month / 12); + month = (month % 12 + 12) % 12; - return buffer + '\n\n'; - },'useData': true - }); - this['Handlebars']['templates']['param'] = Handlebars.template({ - '1': function (depth0, helpers, partials, data) { - var stack1, buffer = ''; + // the date time string format is specified in 15.9.1.15. + var result = [month + 1, originalGetUTCDate(this), originalGetUTCHours(this), originalGetUTCMinutes(this), originalGetUTCSeconds(this)]; + year = ( + (year < 0 ? '-' : (year > 9999 ? '+' : '')) + + strSlice('00000' + Math.abs(year), (0 <= year && year <= 9999) ? -4 : -6) + ); - stack1 = helpers['if'].call(depth0, depth0 != null ? depth0.isFile : depth0, { - 'name': 'if','hash': {},'fn': this.program(2, data),'inverse': this.program(4, data),'data': data - }); + for (var i = 0; i < result.length; ++i) { + // pad months, days, hours, minutes, and seconds to have two digits. + result[i] = strSlice('00' + result[i], -2); + } + // pad milliseconds to have three digits. + return ( + year + '-' + arraySlice(result, 0, 2).join('-') + + 'T' + arraySlice(result, 2).join(':') + '.' + + strSlice('000' + originalGetUTCMilliseconds(this), -3) + 'Z' + ); + } + }, hasNegativeDateBug || hasSafari51DateBug); + + // ES5 15.9.5.44 + // http://es5.github.com/#x15.9.5.44 + // This function provides a String representation of a Date object for use by + // JSON.stringify (15.12.3). + var dateToJSONIsSupported = (function () { + try { + return Date.prototype.toJSON && + new Date(NaN).toJSON() === null && + new Date(negativeDate).toJSON().indexOf(negativeYearString) !== -1 && + Date.prototype.toJSON.call({ // generic + toISOString: function () { return true; } + }); + } catch (e) { + return false; + } + }()); + if (!dateToJSONIsSupported) { + Date.prototype.toJSON = function toJSON(key) { + // When the toJSON method is called with argument key, the following + // steps are taken: + + // 1. Let O be the result of calling ToObject, giving it the this + // value as its argument. + // 2. Let tv be ES.ToPrimitive(O, hint Number). + var O = $Object(this); + var tv = ES.ToPrimitive(O); + // 3. If tv is a Number and is not finite, return null. + if (typeof tv === 'number' && !isFinite(tv)) { + return null; + } + // 4. Let toISO be the result of calling the [[Get]] internal method of + // O with argument "toISOString". + var toISO = O.toISOString; + // 5. If IsCallable(toISO) is false, throw a TypeError exception. + if (!isCallable(toISO)) { + throw new TypeError('toISOString property is not callable'); + } + // 6. Return the result of calling the [[Call]] internal method of + // toISO with O as the this value and an empty argument list. + return toISO.call(O); + + // NOTE 1 The argument is ignored. + + // NOTE 2 The toJSON function is intentionally generic; it does not + // require that its this value be a Date object. Therefore, it can be + // transferred to other kinds of objects for use as a method. However, + // it does require that any such object have a toISOString method. An + // object is free to use the argument key to filter its + // stringification. + }; + } - if (stack1 != null) { - buffer += stack1; - } + // ES5 15.9.4.2 + // http://es5.github.com/#x15.9.4.2 + // based on work shared by Daniel Friesen (dantman) + // http://gist.github.com/303249 + var supportsExtendedYears = Date.parse('+033658-09-27T01:46:40.000Z') === 1e15; + var acceptsInvalidDates = !isNaN(Date.parse('2012-04-04T24:00:00.500Z')) || !isNaN(Date.parse('2012-11-31T23:59:59.000Z')) || !isNaN(Date.parse('2012-12-31T23:59:60.000Z')); + var doesNotParseY2KNewYear = isNaN(Date.parse('2000-01-01T00:00:00.000Z')); + if (doesNotParseY2KNewYear || acceptsInvalidDates || !supportsExtendedYears) { + // XXX global assignment won't work in embeddings that use + // an alternate object for the context. + /* global Date: true */ + /* eslint-disable no-undef */ + var maxSafeUnsigned32Bit = Math.pow(2, 31) - 1; + var hasSafariSignedIntBug = isActualNaN(new Date(1970, 0, 1, 0, 0, 0, maxSafeUnsigned32Bit + 1).getTime()); + /* eslint-disable no-implicit-globals */ + Date = (function (NativeDate) { + /* eslint-enable no-implicit-globals */ + /* eslint-enable no-undef */ + // Date.length === 7 + var DateShim = function Date(Y, M, D, h, m, s, ms) { + var length = arguments.length; + var date; + if (this instanceof NativeDate) { + var seconds = s; + var millis = ms; + if (hasSafariSignedIntBug && length >= 7 && ms > maxSafeUnsigned32Bit) { + // work around a Safari 8/9 bug where it treats the seconds as signed + var msToShift = Math.floor(ms / maxSafeUnsigned32Bit) * maxSafeUnsigned32Bit; + var sToShift = Math.floor(msToShift / 1e3); + seconds += sToShift; + millis -= sToShift * 1e3; + } + date = length === 1 && $String(Y) === Y ? // isString(Y) + // We explicitly pass it through parse: + new NativeDate(DateShim.parse(Y)) : + // We have to manually make calls depending on argument + // length here + length >= 7 ? new NativeDate(Y, M, D, h, m, seconds, millis) : + length >= 6 ? new NativeDate(Y, M, D, h, m, seconds) : + length >= 5 ? new NativeDate(Y, M, D, h, m) : + length >= 4 ? new NativeDate(Y, M, D, h) : + length >= 3 ? new NativeDate(Y, M, D) : + length >= 2 ? new NativeDate(Y, M) : + length >= 1 ? new NativeDate(Y instanceof NativeDate ? +Y : Y) : + new NativeDate(); + } else { + date = NativeDate.apply(this, arguments); + } + if (!isPrimitive(date)) { + // Prevent mixups with unfixed Date object + defineProperties(date, { constructor: DateShim }, true); + } + return date; + }; - return buffer; - },'2': function (depth0, helpers, partials, data) { - var helper, functionType = 'function', - helperMissing = helpers.helperMissing, - escapeExpression = this.escapeExpression; - - return ' \n
        \n'; - },'4': function (depth0, helpers, partials, data) { - var stack1, buffer = ''; - - stack1 = helpers['if'].call(depth0, depth0 != null ? depth0['default'] : depth0, { - 'name': 'if','hash': {},'fn': this.program(5, data),'inverse': this.program(7, data),'data': data - }); + // 15.9.1.15 Date Time String Format. + var isoDateExpression = new RegExp('^' + + '(\\d{4}|[+-]\\d{6})' + // four-digit year capture or sign + + // 6-digit extended year + '(?:-(\\d{2})' + // optional month capture + '(?:-(\\d{2})' + // optional day capture + '(?:' + // capture hours:minutes:seconds.milliseconds + 'T(\\d{2})' + // hours capture + ':(\\d{2})' + // minutes capture + '(?:' + // optional :seconds.milliseconds + ':(\\d{2})' + // seconds capture + '(?:(\\.\\d{1,}))?' + // milliseconds capture + ')?' + + '(' + // capture UTC offset component + 'Z|' + // UTC capture + '(?:' + // offset specifier +/-hours:minutes + '([-+])' + // sign capture + '(\\d{2})' + // hours offset capture + ':(\\d{2})' + // minutes offset capture + ')' + + ')?)?)?)?' + + '$'); + + var months = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365]; + + var dayFromMonth = function dayFromMonth(year, month) { + var t = month > 1 ? 1 : 0; + return ( + months[month] + + Math.floor((year - 1969 + t) / 4) - + Math.floor((year - 1901 + t) / 100) + + Math.floor((year - 1601 + t) / 400) + + 365 * (year - 1970) + ); + }; - if (stack1 != null) { - buffer += stack1; + var toUTC = function toUTC(t) { + var s = 0; + var ms = t; + if (hasSafariSignedIntBug && ms > maxSafeUnsigned32Bit) { + // work around a Safari 8/9 bug where it treats the seconds as signed + var msToShift = Math.floor(ms / maxSafeUnsigned32Bit) * maxSafeUnsigned32Bit; + var sToShift = Math.floor(msToShift / 1e3); + s += sToShift; + ms -= sToShift * 1e3; + } + return $Number(new NativeDate(1970, 0, 1, 0, 0, s, ms)); + }; + + // Copy any custom methods a 3rd party library may have added + for (var key in NativeDate) { + if (owns(NativeDate, key)) { + DateShim[key] = NativeDate[key]; + } } - return buffer; - },'5': function (depth0, helpers, partials, data) { - var helper, functionType = 'function', - helperMissing = helpers.helperMissing, - escapeExpression = this.escapeExpression; - - return ' \n
        \n
        \n'; - },'7': function (depth0, helpers, partials, data) { - var helper, functionType = 'function', - helperMissing = helpers.helperMissing, - escapeExpression = this.escapeExpression; - - return ' \n
        \n
        \n'; - },'9': function (depth0, helpers, partials, data) { - var stack1, buffer = ''; - - stack1 = helpers['if'].call(depth0, depth0 != null ? depth0.isFile : depth0, { - 'name': 'if','hash': {},'fn': this.program(2, data),'inverse': this.program(10, data),'data': data - }); + // Copy "native" methods explicitly; they may be non-enumerable + defineProperties(DateShim, { + now: NativeDate.now, + UTC: NativeDate.UTC + }, true); + DateShim.prototype = NativeDate.prototype; + defineProperties(DateShim.prototype, { + constructor: DateShim + }, true); + + // Upgrade Date.parse to handle simplified ISO 8601 strings + var parseShim = function parse(string) { + var match = isoDateExpression.exec(string); + if (match) { + // parse months, days, hours, minutes, seconds, and milliseconds + // provide default values if necessary + // parse the UTC offset component + var year = $Number(match[1]), + month = $Number(match[2] || 1) - 1, + day = $Number(match[3] || 1) - 1, + hour = $Number(match[4] || 0), + minute = $Number(match[5] || 0), + second = $Number(match[6] || 0), + millisecond = Math.floor($Number(match[7] || 0) * 1000), + // When time zone is missed, local offset should be used + // (ES 5.1 bug) + // see https://bugs.ecmascript.org/show_bug.cgi?id=112 + isLocalTime = Boolean(match[4] && !match[8]), + signOffset = match[9] === '-' ? 1 : -1, + hourOffset = $Number(match[10] || 0), + minuteOffset = $Number(match[11] || 0), + result; + var hasMinutesOrSecondsOrMilliseconds = minute > 0 || second > 0 || millisecond > 0; + if ( + hour < (hasMinutesOrSecondsOrMilliseconds ? 24 : 25) && + minute < 60 && second < 60 && millisecond < 1000 && + month > -1 && month < 12 && hourOffset < 24 && + minuteOffset < 60 && // detect invalid offsets + day > -1 && + day < (dayFromMonth(year, month + 1) - dayFromMonth(year, month)) + ) { + result = ( + (dayFromMonth(year, month) + day) * 24 + + hour + + hourOffset * signOffset + ) * 60; + result = ( + (result + minute + minuteOffset * signOffset) * 60 + + second + ) * 1000 + millisecond; + if (isLocalTime) { + result = toUTC(result); + } + if (-8.64e15 <= result && result <= 8.64e15) { + return result; + } + } + return NaN; + } + return NativeDate.parse.apply(this, arguments); + }; + defineProperties(DateShim, { parse: parseShim }); + + return DateShim; + }(Date)); + /* global Date: false */ + } + + // ES5 15.9.4.4 + // http://es5.github.com/#x15.9.4.4 + if (!Date.now) { + Date.now = function now() { + return new Date().getTime(); + }; + } - if (stack1 != null) { - buffer += stack1; + // + // Number + // ====== + // + + // ES5.1 15.7.4.5 + // http://es5.github.com/#x15.7.4.5 + var hasToFixedBugs = NumberPrototype.toFixed && ( + (0.00008).toFixed(3) !== '0.000' || + (0.9).toFixed(0) !== '1' || + (1.255).toFixed(2) !== '1.25' || + (1000000000000000128).toFixed(0) !== '1000000000000000128' + ); + + var toFixedHelpers = { + base: 1e7, + size: 6, + data: [0, 0, 0, 0, 0, 0], + multiply: function multiply(n, c) { + var i = -1; + var c2 = c; + while (++i < toFixedHelpers.size) { + c2 += n * toFixedHelpers.data[i]; + toFixedHelpers.data[i] = c2 % toFixedHelpers.base; + c2 = Math.floor(c2 / toFixedHelpers.base); + } + }, + divide: function divide(n) { + var i = toFixedHelpers.size; + var c = 0; + while (--i >= 0) { + c += toFixedHelpers.data[i]; + toFixedHelpers.data[i] = Math.floor(c / n); + c = (c % n) * toFixedHelpers.base; } + }, + numToString: function numToString() { + var i = toFixedHelpers.size; + var s = ''; + while (--i >= 0) { + if (s !== '' || i === 0 || toFixedHelpers.data[i] !== 0) { + var t = $String(toFixedHelpers.data[i]); + if (s === '') { + s = t; + } else { + s += strSlice('0000000', 0, 7 - t.length) + t; + } + } + } + return s; + }, + pow: function pow(x, n, acc) { + return (n === 0 ? acc : (n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc))); + }, + log: function log(x) { + var n = 0; + var x2 = x; + while (x2 >= 4096) { + n += 12; + x2 /= 4096; + } + while (x2 >= 2) { + n += 1; + x2 /= 2; + } + return n; + } + }; - return buffer; - },'10': function (depth0, helpers, partials, data) { - var stack1, helperMissing = helpers.helperMissing, - buffer = ''; + var toFixedShim = function toFixed(fractionDigits) { + var f, x, s, m, e, z, j, k; - stack1 = (helpers.renderTextParam || depth0 && depth0.renderTextParam || helperMissing).call(depth0, depth0, { - 'name': 'renderTextParam','hash': {},'fn': this.program(11, data),'inverse': this.noop,'data': data - }); + // Test for NaN and round fractionDigits down + f = $Number(fractionDigits); + f = isActualNaN(f) ? 0 : Math.floor(f); - if (stack1 != null) { - buffer += stack1; - } + if (f < 0 || f > 20) { + throw new RangeError('Number.toFixed called with invalid number of decimals'); + } - return buffer; - },'11': function (depth0, helpers, partials, data) { - return ''; - },'compiler': [6,'>= 2.0.0-beta.1'],'main': function (depth0, helpers, partials, data) { - var stack1, helper, functionType = 'function', - helperMissing = helpers.helperMissing, - escapeExpression = this.escapeExpression, - buffer = '\n\n\n'; - - stack1 = helpers['if'].call(depth0, depth0 != null ? depth0.isBody : depth0, { - 'name': 'if','hash': {},'fn': this.program(1, data),'inverse': this.program(9, data),'data': data - }); + x = $Number(this); - if (stack1 != null) { - buffer += stack1; - } - buffer += '\n\n'; - stack1 = (helper = (helper = helpers.description || (depth0 != null ? depth0.description : depth0)) != null ? helper : helperMissing,typeof helper === functionType ? helper.call(depth0, { - 'name': 'description','hash': {},'data': data - }) : helper); + if (isActualNaN(x)) { + return 'NaN'; + } - if (stack1 != null) { - buffer += stack1; - } - buffer += '\n'; - stack1 = (helper = (helper = helpers.paramType || (depth0 != null ? depth0.paramType : depth0)) != null ? helper : helperMissing,typeof helper === functionType ? helper.call(depth0, { - 'name': 'paramType','hash': {},'data': data - }) : helper); + // If it is too big or small, return the string value of the number + if (x <= -1e21 || x >= 1e21) { + return $String(x); + } - if (stack1 != null) { - buffer += stack1; - } + s = ''; - return buffer + '\n\n \n\n'; - },'useData': true - }); - this['Handlebars']['templates']['parameter_content_type'] = Handlebars.template({ - '1': function (depth0, helpers, partials, data) { - var stack1, buffer = ''; + if (x < 0) { + s = '-'; + x = -x; + } - stack1 = helpers.each.call(depth0, depth0 != null ? depth0.consumes : depth0, { - 'name': 'each','hash': {},'fn': this.program(2, data),'inverse': this.noop,'data': data - }); + m = '0'; - if (stack1 != null) { - buffer += stack1; - } + if (x > 1e-21) { + // 1e-21 < x < 1e21 + // -70 < log2(x) < 70 + e = toFixedHelpers.log(x * toFixedHelpers.pow(2, 69, 1)) - 69; + z = (e < 0 ? x * toFixedHelpers.pow(2, -e, 1) : x / toFixedHelpers.pow(2, e, 1)); + z *= 0x10000000000000; // Math.pow(2, 52); + e = 52 - e; - return buffer; - },'2': function (depth0, helpers, partials, data) { - var stack1, lambda = this.lambda, - buffer = ' \n'; - },'4': function (depth0, helpers, partials, data) { - return ' \n'; - },'compiler': [6,'>= 2.0.0-beta.1'],'main': function (depth0, helpers, partials, data) { - var stack1, helper, functionType = 'function', - helperMissing = helpers.helperMissing, - escapeExpression = this.escapeExpression, - buffer = '\n\n'; - },'useData': true - }); - this['Handlebars']['templates']['resource'] = Handlebars.template({ - '1': function (depth0, helpers, partials, data) { - return ' : '; - },'3': function (depth0, helpers, partials, data) { - var helper, functionType = 'function', - helperMissing = helpers.helperMissing, - escapeExpression = this.escapeExpression; - - return '
      • \n Raw\n
      • \n'; - },'compiler': [6,'>= 2.0.0-beta.1'],'main': function (depth0, helpers, partials, data) { - var stack1, helper, options, functionType = 'function', - helperMissing = helpers.helperMissing, - escapeExpression = this.escapeExpression, - blockHelperMissing = helpers.blockHelperMissing, - buffer = '
        \n

        \n ' + - escapeExpression((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : helperMissing,typeof helper === functionType ? helper.call(depth0, { - 'name': 'name','hash': {},'data': data - }) : helper)) + - ' '; - - stack1 = (helper = (helper = helpers.summary || (depth0 != null ? depth0.summary : depth0)) != null ? helper : helperMissing,options = { - 'name': 'summary','hash': {},'fn': this.program(1, data),'inverse': this.noop,'data': data - },typeof helper === functionType ? helper.call(depth0, options) : helper); - - if (!helpers.summary) { - stack1 = blockHelperMissing.call(depth0, stack1, options); - } + return m; + }; + defineProperties(NumberPrototype, { toFixed: toFixedShim }, hasToFixedBugs); - if (stack1 != null) { - buffer += stack1; + var hasToPrecisionUndefinedBug = (function () { + try { + return 1.0.toPrecision(undefined) === '1'; + } catch (e) { + return true; + } + }()); + var originalToPrecision = NumberPrototype.toPrecision; + defineProperties(NumberPrototype, { + toPrecision: function toPrecision(precision) { + return typeof precision === 'undefined' ? originalToPrecision.call(this) : originalToPrecision.call(this, precision); + } + }, hasToPrecisionUndefinedBug); + + // + // String + // ====== + // + + // ES5 15.5.4.14 + // http://es5.github.com/#x15.5.4.14 + + // [bugfix, IE lt 9, firefox 4, Konqueror, Opera, obscure browsers] + // Many browsers do not split properly with regular expressions or they + // do not perform the split correctly under obscure conditions. + // See http://blog.stevenlevithan.com/archives/cross-browser-split + // I've tested in many browsers and this seems to cover the deviant ones: + // 'ab'.split(/(?:ab)*/) should be ["", ""], not [""] + // '.'.split(/(.?)(.?)/) should be ["", ".", "", ""], not ["", ""] + // 'tesst'.split(/(s)*/) should be ["t", undefined, "e", "s", "t"], not + // [undefined, "t", undefined, "e", ...] + // ''.split(/.?/) should be [], not [""] + // '.'.split(/()()/) should be ["."], not ["", "", "."] + + if ( + 'ab'.split(/(?:ab)*/).length !== 2 || + '.'.split(/(.?)(.?)/).length !== 4 || + 'tesst'.split(/(s)*/)[1] === 't' || + 'test'.split(/(?:)/, -1).length !== 4 || + ''.split(/.?/).length || + '.'.split(/()()/).length > 1 + ) { + (function () { + var compliantExecNpcg = typeof (/()??/).exec('')[1] === 'undefined'; // NPCG: nonparticipating capturing group + var maxSafe32BitInt = Math.pow(2, 32) - 1; + + StringPrototype.split = function (separator, limit) { + var string = String(this); + if (typeof separator === 'undefined' && limit === 0) { + return []; + } + + // If `separator` is not a regex, use native split + if (!isRegex(separator)) { + return strSplit(this, separator, limit); + } + + var output = []; + var flags = (separator.ignoreCase ? 'i' : '') + + (separator.multiline ? 'm' : '') + + (separator.unicode ? 'u' : '') + // in ES6 + (separator.sticky ? 'y' : ''), // Firefox 3+ and ES6 + lastLastIndex = 0, + // Make `global` and avoid `lastIndex` issues by working with a copy + separator2, match, lastIndex, lastLength; + var separatorCopy = new RegExp(separator.source, flags + 'g'); + if (!compliantExecNpcg) { + // Doesn't need flags gy, but they don't hurt + separator2 = new RegExp('^' + separatorCopy.source + '$(?!\\s)', flags); + } + /* Values for `limit`, per the spec: + * If undefined: 4294967295 // maxSafe32BitInt + * If 0, Infinity, or NaN: 0 + * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296; + * If negative number: 4294967296 - Math.floor(Math.abs(limit)) + * If other: Type-convert, then use the above rules + */ + var splitLimit = typeof limit === 'undefined' ? maxSafe32BitInt : ES.ToUint32(limit); + match = separatorCopy.exec(string); + while (match) { + // `separatorCopy.lastIndex` is not reliable cross-browser + lastIndex = match.index + match[0].length; + if (lastIndex > lastLastIndex) { + pushCall(output, strSlice(string, lastLastIndex, match.index)); + // Fix browsers whose `exec` methods don't consistently return `undefined` for + // nonparticipating capturing groups + if (!compliantExecNpcg && match.length > 1) { + /* eslint-disable no-loop-func */ + match[0].replace(separator2, function () { + for (var i = 1; i < arguments.length - 2; i++) { + if (typeof arguments[i] === 'undefined') { + match[i] = void 0; + } + } + }); + /* eslint-enable no-loop-func */ + } + if (match.length > 1 && match.index < string.length) { + array_push.apply(output, arraySlice(match, 1)); + } + lastLength = match[0].length; + lastLastIndex = lastIndex; + if (output.length >= splitLimit) { + break; + } + } + if (separatorCopy.lastIndex === match.index) { + separatorCopy.lastIndex++; // Avoid an infinite loop + } + match = separatorCopy.exec(string); + } + if (lastLastIndex === string.length) { + if (lastLength || !separatorCopy.test('')) { + pushCall(output, ''); + } + } else { + pushCall(output, strSlice(string, lastLastIndex)); + } + return output.length > splitLimit ? arraySlice(output, 0, splitLimit) : output; + }; + }()); + + // [bugfix, chrome] + // If separator is undefined, then the result array contains just one String, + // which is the this value (converted to a String). If limit is not undefined, + // then the output array is truncated so that it contains no more than limit + // elements. + // "0".split(undefined, 0) -> [] + } else if ('0'.split(void 0, 0).length) { + StringPrototype.split = function split(separator, limit) { + if (typeof separator === 'undefined' && limit === 0) { + return []; } - stack1 = (helper = (helper = helpers.summary || (depth0 != null ? depth0.summary : depth0)) != null ? helper : helperMissing,typeof helper === functionType ? helper.call(depth0, { - 'name': 'summary','hash': {},'data': data - }) : helper); + return strSplit(this, separator, limit); + }; + } - if (stack1 != null) { - buffer += stack1; + var str_replace = StringPrototype.replace; + var replaceReportsGroupsCorrectly = (function () { + var groups = []; + 'x'.replace(/x(.)?/g, function (match, group) { + pushCall(groups, group); + }); + return groups.length === 1 && typeof groups[0] === 'undefined'; + }()); + + if (!replaceReportsGroupsCorrectly) { + StringPrototype.replace = function replace(searchValue, replaceValue) { + var isFn = isCallable(replaceValue); + var hasCapturingGroups = isRegex(searchValue) && (/\)[*?]/).test(searchValue.source); + if (!isFn || !hasCapturingGroups) { + return str_replace.call(this, searchValue, replaceValue); + } else { + var wrappedReplaceValue = function (match) { + var length = arguments.length; + var originalLastIndex = searchValue.lastIndex; + searchValue.lastIndex = 0; + var args = searchValue.exec(match) || []; + searchValue.lastIndex = originalLastIndex; + pushCall(args, arguments[length - 2], arguments[length - 1]); + return replaceValue.apply(this, args); + }; + return str_replace.call(this, searchValue, wrappedReplaceValue); } - buffer += '\n

        \n
          \n
        • \n Show/Hide\n
        • \n
        • \n \n List Operations\n \n
        • \n
        • \n \n Expand Operations\n \n
        • \n'; - stack1 = helpers['if'].call(depth0, depth0 != null ? depth0.url : depth0, { - 'name': 'if','hash': {},'fn': this.program(3, data),'inverse': this.noop,'data': data - }); + }; + } - if (stack1 != null) { - buffer += stack1; + // ECMA-262, 3rd B.2.3 + // Not an ECMAScript standard, although ECMAScript 3rd Edition has a + // non-normative section suggesting uniform semantics and it should be + // normalized across all browsers + // [bugfix, IE lt 9] IE < 9 substr() with negative value not working in IE + var string_substr = StringPrototype.substr; + var hasNegativeSubstrBug = ''.substr && '0b'.substr(-1) !== 'b'; + defineProperties(StringPrototype, { + substr: function substr(start, length) { + var normalizedStart = start; + if (start < 0) { + normalizedStart = max(this.length + start, 0); } + return string_substr.call(this, normalizedStart, length); + } + }, hasNegativeSubstrBug); + + // ES5 15.5.4.20 + // whitespace from: http://es5.github.io/#x15.5.4.20 + var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' + + '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028' + + '\u2029\uFEFF'; + var zeroWidth = '\u200b'; + var wsRegexChars = '[' + ws + ']'; + var trimBeginRegexp = new RegExp('^' + wsRegexChars + wsRegexChars + '*'); + var trimEndRegexp = new RegExp(wsRegexChars + wsRegexChars + '*$'); + var hasTrimWhitespaceBug = StringPrototype.trim && (ws.trim() || !zeroWidth.trim()); + defineProperties(StringPrototype, { + // http://blog.stevenlevithan.com/archives/faster-trim-javascript + // http://perfectionkills.com/whitespace-deviations/ + trim: function trim() { + if (typeof this === 'undefined' || this === null) { + throw new TypeError("can't convert " + this + ' to object'); + } + return $String(this).replace(trimBeginRegexp, '').replace(trimEndRegexp, ''); + } + }, hasTrimWhitespaceBug); + var trim = call.bind(String.prototype.trim); + + var hasLastIndexBug = StringPrototype.lastIndexOf && 'abcあい'.lastIndexOf('あい', 2) !== -1; + defineProperties(StringPrototype, { + lastIndexOf: function lastIndexOf(searchString) { + if (typeof this === 'undefined' || this === null) { + throw new TypeError("can't convert " + this + ' to object'); + } + var S = $String(this); + var searchStr = $String(searchString); + var numPos = arguments.length > 1 ? $Number(arguments[1]) : NaN; + var pos = isActualNaN(numPos) ? Infinity : ES.ToInteger(numPos); + var start = min(max(pos, 0), S.length); + var searchLen = searchStr.length; + var k = start + searchLen; + while (k > 0) { + k = max(0, k - searchLen); + var index = strIndexOf(strSlice(S, k, start + searchLen), searchStr); + if (index !== -1) { + return k + index; + } + } + return -1; + } + }, hasLastIndexBug); - return buffer + '
        \n
        \n
          \n\n
        \n'; - },'useData': true - }); - this['Handlebars']['templates']['response_content_type'] = Handlebars.template({ - '1': function (depth0, helpers, partials, data) { - var stack1, buffer = ''; - - stack1 = helpers.each.call(depth0, depth0 != null ? depth0.produces : depth0, { - 'name': 'each','hash': {},'fn': this.program(2, data),'inverse': this.noop,'data': data - }); - - if (stack1 != null) { - buffer += stack1; - } + var originalLastIndexOf = StringPrototype.lastIndexOf; + defineProperties(StringPrototype, { + lastIndexOf: function lastIndexOf(searchString) { + return originalLastIndexOf.apply(this, arguments); + } + }, StringPrototype.lastIndexOf.length !== 1); + + // ES-5 15.1.2.2 + /* eslint-disable radix */ + if (parseInt(ws + '08') !== 8 || parseInt(ws + '0x16') !== 22) { + /* eslint-enable radix */ + /* global parseInt: true */ + parseInt = (function (origParseInt) { + var hexRegex = /^[\-+]?0[xX]/; + return function parseInt(str, radix) { + var string = trim(String(str)); + var defaultedRadix = $Number(radix) || (hexRegex.test(string) ? 16 : 10); + return origParseInt(string, defaultedRadix); + }; + }(parseInt)); + } - return buffer; - },'2': function (depth0, helpers, partials, data) { - var stack1, lambda = this.lambda, - buffer = ' \n'; - },'compiler': [6,'>= 2.0.0-beta.1'],'main': function (depth0, helpers, partials, data) { - var stack1, helper, functionType = 'function', - helperMissing = helpers.helperMissing, - escapeExpression = this.escapeExpression, - buffer = '\n\n'; - },'useData': true - }); - this['Handlebars']['templates']['signature'] = Handlebars.template({ - 'compiler': [6,'>= 2.0.0-beta.1'],'main': function (depth0, helpers, partials, data) { - var stack1, helper, functionType = 'function', - helperMissing = helpers.helperMissing, - escapeExpression = this.escapeExpression, - buffer = '
        \n\n
        \n\n
        \n
        \n '; - - stack1 = (helper = (helper = helpers.signature || (depth0 != null ? depth0.signature : depth0)) != null ? helper : helperMissing,typeof helper === functionType ? helper.call(depth0, { - 'name': 'signature','hash': {},'data': data - }) : helper); - - if (stack1 != null) { - buffer += stack1; - } + if (text === undefined) { return ''; } - return buffer + '\n
        \n\n
        \n
        ' +
        -                escapeExpression((helper = (helper = helpers.sampleJSON || (depth0 != null ? depth0.sampleJSON : depth0)) != null ? helper : helperMissing,typeof helper === functionType ? helper.call(depth0, {
        -                'name': 'sampleJSON','hash': {},'data': data
        -            }) : helper)) +
        -                '
        \n \n
        \n
        \n\n'; - },'useData': true + result = sanitizeHtml(text, { + allowedTags: [ 'div', 'span', 'b', 'i', 'em', 'strong', 'a', 'br', 'table', 'tbody', 'tr', 'th', 'td' ], + allowedAttributes: { + 'div': [ 'class' ], + 'span': [ 'class' ], + 'table': [ 'class' ], + 'td': [ 'class' ], + 'th': [ 'colspan' ], + 'a': [ 'href' ] + } }); - this['Handlebars']['templates']['status_code'] = Handlebars.template({ - '1': function (depth0, helpers, partials, data) { - var lambda = this.lambda, - escapeExpression = this.escapeExpression; - - return ' \n ' + - escapeExpression(lambda(data && data.key, depth0)) + - '\n ' + - escapeExpression(lambda(depth0 != null ? depth0.description : depth0, depth0)) + - '\n ' + - escapeExpression(lambda(depth0 != null ? depth0.type : depth0, depth0)) + - '\n \n'; - },'compiler': [6,'>= 2.0.0-beta.1'],'main': function (depth0, helpers, partials, data) { - var stack1, helper, functionType = 'function', - helperMissing = helpers.helperMissing, - escapeExpression = this.escapeExpression, - buffer = '' + - escapeExpression((helper = (helper = helpers.code || (depth0 != null ? depth0.code : depth0)) != null ? helper : helperMissing,typeof helper === functionType ? helper.call(depth0, { - 'name': 'code','hash': {},'data': data - }) : helper)) + - '\n'; - - stack1 = (helper = (helper = helpers.message || (depth0 != null ? depth0.message : depth0)) != null ? helper : helperMissing,typeof helper === functionType ? helper.call(depth0, { - 'name': 'message','hash': {},'data': data - }) : helper); - - if (stack1 != null) { - buffer += stack1; - } - buffer += '\n\n\n \n \n'; - stack1 = helpers.each.call(depth0, depth0 != null ? depth0.headers : depth0, { - 'name': 'each','hash': {},'fn': this.program(1, data),'inverse': this.noop,'data': data - }); - if (stack1 != null) { - buffer += stack1; - } + return new Handlebars.SafeString(result); +}); + +Handlebars.registerHelper('renderTextParam', function(param) { + var result, type = 'text', idAtt = ''; + var paramType = param.type || param.schema && param.schema.type || ''; + var isArray = paramType.toLowerCase() === 'array' || param.allowMultiple; + var defaultValue = isArray && Array.isArray(param.default) ? param.default.join('\n') : param.default; + var name = Handlebars.Utils.escapeExpression(param.name); + var valueId = Handlebars.Utils.escapeExpression(param.valueId); + paramType = Handlebars.Utils.escapeExpression(paramType); + + var dataVendorExtensions = Object.keys(param).filter(function(property) { + // filter X-data- properties + return property.match(/^X-data-/i) !== null; + }).reduce(function(result, property) { + // remove X- from property name, so it results in html attributes like data-foo='bar' + return result += ' ' + property.substring(2, property.length) + '=\'' + param[property] + '\''; + }, ''); + + if(param.format && param.format === 'password') { + type = 'password'; + } - return buffer + ' \n
        \n'; - },'useData': true - }); + if(valueId) { + idAtt = ' id=\'' + valueId + '\''; + } - /** - * swagger-client - swagger-client is a javascript client for use with swaggering APIs. - * @version v2.1.2 - * @link http://swagger.io - * @license Apache-2.0 - */ - (function (f) { - if (typeof exports === 'object' && typeof module !== 'undefined') { - module.exports = f(); - } else if (typeof define === 'function' && define.amd) { - define([], f); - } else { - var g; - - if (typeof window !== 'undefined') { - g = window; - } else if (typeof global !== 'undefined') { - g = global; - } else if (typeof self !== 'undefined') { - g = self; - } else { - g = this; - }g.SwaggerClient = f(); + if (defaultValue) { + defaultValue = sanitizeHtml(defaultValue); + } else { + defaultValue = ''; + } + + if(isArray) { + result = ''; + } else { + var parameterClass = 'parameter'; + if(param.required) { + parameterClass += ' required'; } - })(function () { - var define,module,exports; + result = ''; + } + return new Handlebars.SafeString(result); +}); + +Handlebars.registerHelper('ifCond', function (v1, operator, v2, options) { + + switch (operator) { + case '==': + return (v1 == v2) ? options.fn(this) : options.inverse(this); + case '===': + return (v1 === v2) ? options.fn(this) : options.inverse(this); + case '<': + return (v1 < v2) ? options.fn(this) : options.inverse(this); + case '<=': + return (v1 <= v2) ? options.fn(this) : options.inverse(this); + case '>': + return (v1 > v2) ? options.fn(this) : options.inverse(this); + case '>=': + return (v1 >= v2) ? options.fn(this) : options.inverse(this); + case '&&': + return (v1 && v2) ? options.fn(this) : options.inverse(this); + case '||': + return (v1 || v2) ? options.fn(this) : options.inverse(this); + default: + return options.inverse(this); + } +}); - return (function e(t, n, r) { - function s(o, u) { - if (!n[o]) { - if (!t[o]) { - var a = typeof require == 'function' && require; +Handlebars.registerHelper('escape', function (value) { + var text = Handlebars.Utils.escapeExpression(value); - if (!u && a)return a(o, !0); + return new Handlebars.SafeString(text); +}); - if (i)return i(o, !0); var f = new Error('Cannot find module \'' + o + '\''); +(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.sanitizeHtml=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o=0){globRegex.push(quoteRegexp(name).replace(/\\\*/g,".*"))}else{allowedAttributesMap[tag].push(name)}});allowedAttributesGlobMap[tag]=new RegExp("^("+globRegex.join("|")+")$")})}var allowedClassesMap={};each(options.allowedClasses,function(classes,tag){if(allowedAttributesMap){if(!has(allowedAttributesMap,tag)){allowedAttributesMap[tag]=[]}allowedAttributesMap[tag].push("class")}allowedClassesMap[tag]=classes});var transformTagsMap={};var transformTagsAll;each(options.transformTags,function(transform,tag){var transFun;if(typeof transform==="function"){transFun=transform}else if(typeof transform==="string"){transFun=sanitizeHtml.simpleTransform(transform)}if(tag==="*"){transformTagsAll=transFun}else{transformTagsMap[tag]=transFun}});var depth=0;var stack=[];var skipMap={};var transformMap={};var skipText=false;var skipTextDepth=0;var parser=new htmlparser.Parser({onopentag:function(name,attribs){if(skipText){skipTextDepth++;return}var frame=new Frame(name,attribs);stack.push(frame);var skip=false;var hasText=frame.text?true:false;var transformedTag;if(has(transformTagsMap,name)){transformedTag=transformTagsMap[name](name,attribs);frame.attribs=attribs=transformedTag.attribs;if(transformedTag.text!==undefined){frame.innerText=transformedTag.text}if(name!==transformedTag.tagName){frame.name=name=transformedTag.tagName;transformMap[depth]=transformedTag.tagName}}if(transformTagsAll){transformedTag=transformTagsAll(name,attribs);frame.attribs=attribs=transformedTag.attribs;if(name!==transformedTag.tagName){frame.name=name=transformedTag.tagName;transformMap[depth]=transformedTag.tagName}}if(options.allowedTags&&options.allowedTags.indexOf(name)===-1){skip=true;if(nonTextTagsArray.indexOf(name)!==-1){skipText=true;skipTextDepth=1}skipMap[depth]=true}depth++;if(skip){return}result+="<"+name;if(!allowedAttributesMap||has(allowedAttributesMap,name)||allowedAttributesMap["*"]){each(attribs,function(value,a){if(!allowedAttributesMap||has(allowedAttributesMap,name)&&allowedAttributesMap[name].indexOf(a)!==-1||allowedAttributesMap["*"]&&allowedAttributesMap["*"].indexOf(a)!==-1||has(allowedAttributesGlobMap,name)&&allowedAttributesGlobMap[name].test(a)||allowedAttributesGlobMap["*"]&&allowedAttributesGlobMap["*"].test(a)){if(a==="href"||a==="src"){if(naughtyHref(name,value)){delete frame.attribs[a];return}}if(a==="class"){value=filterClasses(value,allowedClassesMap[name]);if(!value.length){delete frame.attribs[a];return}}result+=" "+a;if(value.length){result+='="'+escapeHtml(value)+'"'}}else{delete frame.attribs[a]}})}if(options.selfClosing.indexOf(name)!==-1){result+=" />"}else{result+=">";if(frame.innerText&&!hasText&&!options.textFilter){result+=frame.innerText}}},ontext:function(text){if(skipText){return}var lastFrame=stack[stack.length-1];var tag;if(lastFrame){tag=lastFrame.tag;text=lastFrame.innerText!==undefined?lastFrame.innerText:text}if(tag==="script"||tag==="style"){result+=text}else{var escaped=escapeHtml(text);if(options.textFilter){result+=options.textFilter(escaped)}else{result+=escaped}}if(stack.length){var frame=stack[stack.length-1];frame.text+=text}},onclosetag:function(name){if(skipText){skipTextDepth--;if(!skipTextDepth){skipText=false}else{return}}var frame=stack.pop();if(!frame){return}skipText=false;depth--;if(skipMap[depth]){delete skipMap[depth];frame.updateParentNodeText();return}if(transformMap[depth]){name=transformMap[depth];delete transformMap[depth]}if(options.exclusiveFilter&&options.exclusiveFilter(frame)){result=result.substr(0,frame.tagPosition);return}frame.updateParentNodeText();if(options.selfClosing.indexOf(name)!==-1){return}result+=""}},options.parser);parser.write(html);parser.end();return result;function escapeHtml(s){if(typeof s!=="string"){s=s+""}return s.replace(/\&/g,"&").replace(//g,">").replace(/\"/g,""")}function naughtyHref(name,href){href=href.replace(/[\x00-\x20]+/g,"");href=href.replace(/<\!\-\-.*?\-\-\>/g,"");var matches=href.match(/^([a-zA-Z]+)\:/);if(!matches){return false}var scheme=matches[1].toLowerCase();if(has(options.allowedSchemesByTag,name)){return options.allowedSchemesByTag[name].indexOf(scheme)===-1}return!options.allowedSchemes||options.allowedSchemes.indexOf(scheme)===-1}function filterClasses(classes,allowed){if(!allowed){return classes}classes=classes.split(/\s+/);return classes.filter(function(clss){return allowed.indexOf(clss)!==-1}).join(" ")}}var htmlParserDefaults={decodeEntities:true};sanitizeHtml.defaults={allowedTags:["h3","h4","h5","h6","blockquote","p","a","ul","ol","nl","li","b","i","strong","em","strike","code","hr","br","div","table","thead","caption","tbody","tr","th","td","pre"],allowedAttributes:{a:["href","name","target"],img:["src"]},selfClosing:["img","br","hr","area","base","basefont","input","link","meta"],allowedSchemes:["http","https","ftp","mailto"],allowedSchemesByTag:{}};sanitizeHtml.simpleTransform=function(newTagName,newAttribs,merge){merge=merge===undefined?true:merge;newAttribs=newAttribs||{};return function(tagName,attribs){var attrib;if(merge){for(attrib in newAttribs){attribs[attrib]=newAttribs[attrib]}}else{attribs=newAttribs}return{tagName:newTagName,attribs:attribs}}}},{htmlparser2:36,"regexp-quote":54,xtend:58}],2:[function(require,module,exports){"use strict";exports.toByteArray=toByteArray;exports.fromByteArray=fromByteArray;var lookup=[];var revLookup=[];var Arr=typeof Uint8Array!=="undefined"?Uint8Array:Array;function init(){var code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var i=0,len=code.length;i0){throw new Error("Invalid string. Length must be a multiple of 4")}placeHolders=b64[len-2]==="="?2:b64[len-1]==="="?1:0;arr=new Arr(len*3/4-placeHolders);l=placeHolders>0?len-4:len;var L=0;for(i=0,j=0;i>16&255;arr[L++]=tmp>>8&255;arr[L++]=tmp&255}if(placeHolders===2){tmp=revLookup[b64.charCodeAt(i)]<<2|revLookup[b64.charCodeAt(i+1)]>>4;arr[L++]=tmp&255}else if(placeHolders===1){tmp=revLookup[b64.charCodeAt(i)]<<10|revLookup[b64.charCodeAt(i+1)]<<4|revLookup[b64.charCodeAt(i+2)]>>2;arr[L++]=tmp>>8&255;arr[L++]=tmp&255}return arr}function tripletToBase64(num){return lookup[num>>18&63]+lookup[num>>12&63]+lookup[num>>6&63]+lookup[num&63]}function encodeChunk(uint8,start,end){var tmp;var output=[];for(var i=start;ilen2?len2:i+maxChunkLength))}if(extraBytes===1){tmp=uint8[len-1];output+=lookup[tmp>>2];output+=lookup[tmp<<4&63];output+="=="}else if(extraBytes===2){tmp=(uint8[len-2]<<8)+uint8[len-1];output+=lookup[tmp>>10];output+=lookup[tmp>>4&63];output+=lookup[tmp<<2&63];output+="="}parts.push(output);return parts.join("")}},{}],3:[function(require,module,exports){},{}],4:[function(require,module,exports){(function(global){"use strict";var buffer=require("buffer");var Buffer=buffer.Buffer;var SlowBuffer=buffer.SlowBuffer;var MAX_LEN=buffer.kMaxLength||2147483647;exports.alloc=function alloc(size,fill,encoding){if(typeof Buffer.alloc==="function"){return Buffer.alloc(size,fill,encoding)}if(typeof encoding==="number"){throw new TypeError("encoding must not be number")}if(typeof size!=="number"){throw new TypeError("size must be a number")}if(size>MAX_LEN){throw new RangeError("size is too large")}var enc=encoding;var _fill=fill;if(_fill===undefined){enc=undefined;_fill=0}var buf=new Buffer(size);if(typeof _fill==="string"){var fillBuf=new Buffer(_fill,enc);var flen=fillBuf.length;var i=-1;while(++iMAX_LEN){throw new RangeError("size is too large")}return new Buffer(size)};exports.from=function from(value,encodingOrOffset,length){if(typeof Buffer.from==="function"&&(!global.Uint8Array||Uint8Array.from!==Buffer.from)){return Buffer.from(value,encodingOrOffset,length)}if(typeof value==="number"){throw new TypeError('"value" argument must not be a number')}if(typeof value==="string"){return new Buffer(value,encodingOrOffset)}if(typeof ArrayBuffer!=="undefined"&&value instanceof ArrayBuffer){var offset=encodingOrOffset;if(arguments.length===1){return new Buffer(value)}if(typeof offset==="undefined"){offset=0}var len=length;if(typeof len==="undefined"){len=value.byteLength-offset}if(offset>=value.byteLength){throw new RangeError("'offset' is out of bounds")}if(len>value.byteLength-offset){throw new RangeError("'length' is out of bounds")}return new Buffer(value.slice(offset,offset+len))}if(Buffer.isBuffer(value)){var out=new Buffer(value.length);value.copy(out,0,0,value.length);return out}if(value){if(Array.isArray(value)||typeof ArrayBuffer!=="undefined"&&value.buffer instanceof ArrayBuffer||"length"in value){return new Buffer(value)}if(value.type==="Buffer"&&Array.isArray(value.data)){return new Buffer(value.data)}}throw new TypeError("First argument must be a string, Buffer, "+"ArrayBuffer, Array, or array-like object.")};exports.allocUnsafeSlow=function allocUnsafeSlow(size){if(typeof Buffer.allocUnsafeSlow==="function"){return Buffer.allocUnsafeSlow(size)}if(typeof size!=="number"){throw new TypeError("size must be a number")}if(size>=MAX_LEN){throw new RangeError("size is too large")}return new SlowBuffer(size)}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{buffer:5}],5:[function(require,module,exports){(function(global){"use strict";var base64=require("base64-js");var ieee754=require("ieee754");var isArray=require("isarray");exports.Buffer=Buffer;exports.SlowBuffer=SlowBuffer;exports.INSPECT_MAX_BYTES=50;Buffer.TYPED_ARRAY_SUPPORT=global.TYPED_ARRAY_SUPPORT!==undefined?global.TYPED_ARRAY_SUPPORT:typedArraySupport();exports.kMaxLength=kMaxLength();function typedArraySupport(){try{var arr=new Uint8Array(1);arr.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}};return arr.foo()===42&&typeof arr.subarray==="function"&&arr.subarray(1,1).byteLength===0}catch(e){return false}}function kMaxLength(){return Buffer.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function createBuffer(that,length){if(kMaxLength()=kMaxLength()){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+kMaxLength().toString(16)+" bytes")}return length|0}function SlowBuffer(length){if(+length!=length){length=0}return Buffer.alloc(+length)}Buffer.isBuffer=function isBuffer(b){return!!(b!=null&&b._isBuffer)};Buffer.compare=function compare(a,b){if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b)){throw new TypeError("Arguments must be Buffers")}if(a===b)return 0;var x=a.length;var y=b.length;for(var i=0,len=Math.min(x,y);i>>1;case"base64":return base64ToBytes(string).length;default:if(loweredCase)return utf8ToBytes(string).length;encoding=(""+encoding).toLowerCase();loweredCase=true}}}Buffer.byteLength=byteLength;function slowToString(encoding,start,end){var loweredCase=false;if(start===undefined||start<0){start=0}if(start>this.length){return""}if(end===undefined||end>this.length){end=this.length}if(end<=0){return""}end>>>=0;start>>>=0;if(end<=start){return""}if(!encoding)encoding="utf8";while(true){switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"latin1":case"binary":return latin1Slice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase();loweredCase=true}}}Buffer.prototype._isBuffer=true;function swap(b,n,m){var i=b[n];b[n]=b[m];b[m]=i}Buffer.prototype.swap16=function swap16(){var len=this.length;if(len%2!==0){throw new RangeError("Buffer size must be a multiple of 16-bits")}for(var i=0;i0){str=this.toString("hex",0,max).match(/.{2}/g).join(" ");if(this.length>max)str+=" ... "}return""};Buffer.prototype.compare=function compare(target,start,end,thisStart,thisEnd){if(!Buffer.isBuffer(target)){throw new TypeError("Argument must be a Buffer")}if(start===undefined){start=0}if(end===undefined){end=target?target.length:0}if(thisStart===undefined){thisStart=0}if(thisEnd===undefined){thisEnd=this.length}if(start<0||end>target.length||thisStart<0||thisEnd>this.length){throw new RangeError("out of range index")}if(thisStart>=thisEnd&&start>=end){return 0}if(thisStart>=thisEnd){return-1}if(start>=end){return 1}start>>>=0;end>>>=0;thisStart>>>=0;thisEnd>>>=0;if(this===target)return 0;var x=thisEnd-thisStart;var y=end-start;var len=Math.min(x,y);var thisCopy=this.slice(thisStart,thisEnd);var targetCopy=target.slice(start,end);for(var i=0;i2147483647){byteOffset=2147483647}else if(byteOffset<-2147483648){byteOffset=-2147483648}byteOffset=+byteOffset;if(isNaN(byteOffset)){byteOffset=dir?0:buffer.length-1}if(byteOffset<0)byteOffset=buffer.length+byteOffset;if(byteOffset>=buffer.length){if(dir)return-1;else byteOffset=buffer.length-1}else if(byteOffset<0){if(dir)byteOffset=0;else return-1}if(typeof val==="string"){val=Buffer.from(val,encoding)}if(Buffer.isBuffer(val)){if(val.length===0){return-1}return arrayIndexOf(buffer,val,byteOffset,encoding,dir)}else if(typeof val==="number"){val=val&255;if(Buffer.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf==="function"){if(dir){return Uint8Array.prototype.indexOf.call(buffer,val,byteOffset)}else{return Uint8Array.prototype.lastIndexOf.call(buffer,val,byteOffset)}}return arrayIndexOf(buffer,[val],byteOffset,encoding,dir)}throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(arr,val,byteOffset,encoding,dir){var indexSize=1;var arrLength=arr.length;var valLength=val.length;if(encoding!==undefined){encoding=String(encoding).toLowerCase();if(encoding==="ucs2"||encoding==="ucs-2"||encoding==="utf16le"||encoding==="utf-16le"){if(arr.length<2||val.length<2){return-1}indexSize=2;arrLength/=2;valLength/=2;byteOffset/=2}}function read(buf,i){if(indexSize===1){return buf[i]}else{return buf.readUInt16BE(i*indexSize)}}var i;if(dir){var foundIndex=-1;for(i=byteOffset;iarrLength)byteOffset=arrLength-valLength;for(i=byteOffset;i>=0;i--){var found=true;for(var j=0;jremaining){length=remaining}}var strLen=string.length;if(strLen%2!==0)throw new TypeError("Invalid hex string");if(length>strLen/2){length=strLen/2}for(var i=0;iremaining)length=remaining;if(string.length>0&&(length<0||offset<0)||offset>this.length){throw new RangeError("Attempt to write outside buffer bounds")}if(!encoding)encoding="utf8";var loweredCase=false;for(;;){switch(encoding){case"hex":return hexWrite(this,string,offset,length);case"utf8":case"utf-8":return utf8Write(this,string,offset,length);case"ascii":return asciiWrite(this,string,offset,length);case"latin1":case"binary":return latin1Write(this,string,offset,length);case"base64":return base64Write(this,string,offset,length);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,string,offset,length);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(""+encoding).toLowerCase();loweredCase=true}}};Buffer.prototype.toJSON=function toJSON(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(buf,start,end){if(start===0&&end===buf.length){return base64.fromByteArray(buf)}else{return base64.fromByteArray(buf.slice(start,end))}}function utf8Slice(buf,start,end){end=Math.min(buf.length,end);var res=[];var i=start;while(i239?4:firstByte>223?3:firstByte>191?2:1;if(i+bytesPerSequence<=end){var secondByte,thirdByte,fourthByte,tempCodePoint;switch(bytesPerSequence){case 1:if(firstByte<128){codePoint=firstByte}break;case 2:secondByte=buf[i+1];if((secondByte&192)===128){tempCodePoint=(firstByte&31)<<6|secondByte&63;if(tempCodePoint>127){codePoint=tempCodePoint}}break;case 3:secondByte=buf[i+1];thirdByte=buf[i+2];if((secondByte&192)===128&&(thirdByte&192)===128){tempCodePoint=(firstByte&15)<<12|(secondByte&63)<<6|thirdByte&63;if(tempCodePoint>2047&&(tempCodePoint<55296||tempCodePoint>57343)){codePoint=tempCodePoint}}break;case 4:secondByte=buf[i+1];thirdByte=buf[i+2];fourthByte=buf[i+3];if((secondByte&192)===128&&(thirdByte&192)===128&&(fourthByte&192)===128){tempCodePoint=(firstByte&15)<<18|(secondByte&63)<<12|(thirdByte&63)<<6|fourthByte&63;if(tempCodePoint>65535&&tempCodePoint<1114112){codePoint=tempCodePoint}}}}if(codePoint===null){codePoint=65533;bytesPerSequence=1}else if(codePoint>65535){codePoint-=65536;res.push(codePoint>>>10&1023|55296);codePoint=56320|codePoint&1023}res.push(codePoint);i+=bytesPerSequence}return decodeCodePointsArray(res)}var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(codePoints){var len=codePoints.length;if(len<=MAX_ARGUMENTS_LENGTH){return String.fromCharCode.apply(String,codePoints)}var res="";var i=0;while(ilen)end=len;var out="";for(var i=start;ilen){start=len}if(end<0){end+=len;if(end<0)end=0}else if(end>len){end=len}if(endlength)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function readUIntLE(offset,byteLength,noAssert){offset=offset|0;byteLength=byteLength|0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i0&&(mul*=256)){val+=this[offset+--byteLength]*mul}return val};Buffer.prototype.readUInt8=function readUInt8(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);return this[offset]};Buffer.prototype.readUInt16LE=function readUInt16LE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]|this[offset+1]<<8};Buffer.prototype.readUInt16BE=function readUInt16BE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]<<8|this[offset+1]};Buffer.prototype.readUInt32LE=function readUInt32LE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+this[offset+3]*16777216};Buffer.prototype.readUInt32BE=function readUInt32BE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]*16777216+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])};Buffer.prototype.readIntLE=function readIntLE(offset,byteLength,noAssert){offset=offset|0;byteLength=byteLength|0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readIntBE=function readIntBE(offset,byteLength,noAssert){offset=offset|0;byteLength=byteLength|0;if(!noAssert)checkOffset(offset,byteLength,this.length); +var i=byteLength;var mul=1;var val=this[offset+--i];while(i>0&&(mul*=256)){val+=this[offset+--i]*mul}mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readInt8=function readInt8(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);if(!(this[offset]&128))return this[offset];return(255-this[offset]+1)*-1};Buffer.prototype.readInt16LE=function readInt16LE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt16BE=function readInt16BE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt32LE=function readInt32LE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24};Buffer.prototype.readInt32BE=function readInt32BE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]};Buffer.prototype.readFloatLE=function readFloatLE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,true,23,4)};Buffer.prototype.readFloatBE=function readFloatBE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,false,23,4)};Buffer.prototype.readDoubleLE=function readDoubleLE(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,true,52,8)};Buffer.prototype.readDoubleBE=function readDoubleBE(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,false,52,8)};function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError('"buffer" argument must be a Buffer instance');if(value>max||valuebuf.length)throw new RangeError("Index out of range")}Buffer.prototype.writeUIntLE=function writeUIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset|0;byteLength=byteLength|0;if(!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var mul=1;var i=0;this[offset]=value&255;while(++i=0&&(mul*=256)){this[offset+i]=value/mul&255}return offset+byteLength};Buffer.prototype.writeUInt8=function writeUInt8(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,1,255,0);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);this[offset]=value&255;return offset+1};function objectWriteUInt16(buf,value,offset,littleEndian){if(value<0)value=65535+value+1;for(var i=0,j=Math.min(buf.length-offset,2);i>>(littleEndian?i:1-i)*8}}Buffer.prototype.writeUInt16LE=function writeUInt16LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value&255;this[offset+1]=value>>>8}else{objectWriteUInt16(this,value,offset,true)}return offset+2};Buffer.prototype.writeUInt16BE=function writeUInt16BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value&255}else{objectWriteUInt16(this,value,offset,false)}return offset+2};function objectWriteUInt32(buf,value,offset,littleEndian){if(value<0)value=4294967295+value+1;for(var i=0,j=Math.min(buf.length-offset,4);i>>(littleEndian?i:3-i)*8&255}}Buffer.prototype.writeUInt32LE=function writeUInt32LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset+3]=value>>>24;this[offset+2]=value>>>16;this[offset+1]=value>>>8;this[offset]=value&255}else{objectWriteUInt32(this,value,offset,true)}return offset+4};Buffer.prototype.writeUInt32BE=function writeUInt32BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255}else{objectWriteUInt32(this,value,offset,false)}return offset+4};Buffer.prototype.writeIntLE=function writeIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset|0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=0;var mul=1;var sub=0;this[offset]=value&255;while(++i>0)-sub&255}return offset+byteLength};Buffer.prototype.writeIntBE=function writeIntBE(value,offset,byteLength,noAssert){value=+value;offset=offset|0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=byteLength-1;var mul=1;var sub=0;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){if(value<0&&sub===0&&this[offset+i+1]!==0){sub=1}this[offset+i]=(value/mul>>0)-sub&255}return offset+byteLength};Buffer.prototype.writeInt8=function writeInt8(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,1,127,-128);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);if(value<0)value=255+value+1;this[offset]=value&255;return offset+1};Buffer.prototype.writeInt16LE=function writeInt16LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value&255;this[offset+1]=value>>>8}else{objectWriteUInt16(this,value,offset,true)}return offset+2};Buffer.prototype.writeInt16BE=function writeInt16BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value&255}else{objectWriteUInt16(this,value,offset,false)}return offset+2};Buffer.prototype.writeInt32LE=function writeInt32LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value&255;this[offset+1]=value>>>8;this[offset+2]=value>>>16;this[offset+3]=value>>>24}else{objectWriteUInt32(this,value,offset,true)}return offset+4};Buffer.prototype.writeInt32BE=function writeInt32BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(value<0)value=4294967295+value+1;if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255}else{objectWriteUInt32(this,value,offset,false)}return offset+4};function checkIEEE754(buf,value,offset,ext,max,min){if(offset+ext>buf.length)throw new RangeError("Index out of range");if(offset<0)throw new RangeError("Index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){if(!noAssert){checkIEEE754(buf,value,offset,4,3.4028234663852886e38,-3.4028234663852886e38)}ieee754.write(buf,value,offset,littleEndian,23,4);return offset+4}Buffer.prototype.writeFloatLE=function writeFloatLE(value,offset,noAssert){return writeFloat(this,value,offset,true,noAssert)};Buffer.prototype.writeFloatBE=function writeFloatBE(value,offset,noAssert){return writeFloat(this,value,offset,false,noAssert)};function writeDouble(buf,value,offset,littleEndian,noAssert){if(!noAssert){checkIEEE754(buf,value,offset,8,1.7976931348623157e308,-1.7976931348623157e308)}ieee754.write(buf,value,offset,littleEndian,52,8);return offset+8}Buffer.prototype.writeDoubleLE=function writeDoubleLE(value,offset,noAssert){return writeDouble(this,value,offset,true,noAssert)};Buffer.prototype.writeDoubleBE=function writeDoubleBE(value,offset,noAssert){return writeDouble(this,value,offset,false,noAssert)};Buffer.prototype.copy=function copy(target,targetStart,start,end){if(!start)start=0;if(!end&&end!==0)end=this.length;if(targetStart>=target.length)targetStart=target.length;if(!targetStart)targetStart=0;if(end>0&&end=this.length)throw new RangeError("sourceStart out of bounds");if(end<0)throw new RangeError("sourceEnd out of bounds");if(end>this.length)end=this.length;if(target.length-targetStart=0;--i){target[i+targetStart]=this[i+start]}}else if(len<1e3||!Buffer.TYPED_ARRAY_SUPPORT){for(i=0;i>>0;end=end===undefined?this.length:end>>>0;if(!val)val=0;var i;if(typeof val==="number"){for(i=start;i55295&&codePoint<57344){if(!leadSurrogate){if(codePoint>56319){if((units-=3)>-1)bytes.push(239,191,189);continue}else if(i+1===length){if((units-=3)>-1)bytes.push(239,191,189);continue}leadSurrogate=codePoint;continue}if(codePoint<56320){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=codePoint;continue}codePoint=(leadSurrogate-55296<<10|codePoint-56320)+65536}else if(leadSurrogate){if((units-=3)>-1)bytes.push(239,191,189)}leadSurrogate=null;if(codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}else if(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,codePoint&63|128)}else if(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,codePoint&63|128)}else if(codePoint<1114112){if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,codePoint&63|128)}else{throw new Error("Invalid code point")}}return bytes}function asciiToBytes(str){var byteArray=[];for(var i=0;i>8;lo=c%256;byteArray.push(lo);byteArray.push(hi)}return byteArray}function base64ToBytes(str){return base64.toByteArray(base64clean(str))}function blitBuffer(src,dst,offset,length){for(var i=0;i=dst.length||i>=src.length)break;dst[i+offset]=src[i]}return i}function isnan(val){return val!==val}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"base64-js":2,ieee754:37,isarray:40}],6:[function(require,module,exports){(function(Buffer){function isArray(arg){if(Array.isArray){return Array.isArray(arg)}return objectToString(arg)==="[object Array]"}exports.isArray=isArray;function isBoolean(arg){return typeof arg==="boolean"}exports.isBoolean=isBoolean;function isNull(arg){return arg===null}exports.isNull=isNull;function isNullOrUndefined(arg){return arg==null}exports.isNullOrUndefined=isNullOrUndefined;function isNumber(arg){return typeof arg==="number"}exports.isNumber=isNumber;function isString(arg){return typeof arg==="string"}exports.isString=isString;function isSymbol(arg){return typeof arg==="symbol"}exports.isSymbol=isSymbol;function isUndefined(arg){return arg===void 0}exports.isUndefined=isUndefined;function isRegExp(re){return objectToString(re)==="[object RegExp]"}exports.isRegExp=isRegExp;function isObject(arg){return typeof arg==="object"&&arg!==null}exports.isObject=isObject;function isDate(d){return objectToString(d)==="[object Date]"}exports.isDate=isDate;function isError(e){return objectToString(e)==="[object Error]"||e instanceof Error}exports.isError=isError;function isFunction(arg){return typeof arg==="function"}exports.isFunction=isFunction;function isPrimitive(arg){return arg===null||typeof arg==="boolean"||typeof arg==="number"||typeof arg==="string"||typeof arg==="symbol"||typeof arg==="undefined"}exports.isPrimitive=isPrimitive;exports.isBuffer=Buffer.isBuffer;function objectToString(o){return Object.prototype.toString.call(o)}}).call(this,{isBuffer:require("../../is-buffer/index.js")})},{"../../is-buffer/index.js":39}],7:[function(require,module,exports){var ElementType=require("domelementtype");var entities=require("entities");var booleanAttributes={__proto__:null,allowfullscreen:true,async:true,autofocus:true,autoplay:true,checked:true,controls:true,default:true,defer:true,disabled:true,hidden:true,ismap:true,loop:true,multiple:true,muted:true,open:true,readonly:true,required:true,reversed:true,scoped:true,seamless:true,selected:true,typemustmatch:true};var unencodedElements={__proto__:null,style:true,script:true,xmp:true,iframe:true,noembed:true,noframes:true,plaintext:true,noscript:true};function formatAttrs(attributes,opts){if(!attributes)return;var output="",value;for(var key in attributes){value=attributes[key];if(output){output+=" "}if(!value&&booleanAttributes[key]){output+=key}else{output+=key+'="'+(opts.decodeEntities?entities.encodeXML(value):value)+'"'}}return output}var singleTag={__proto__:null,area:true,base:true,basefont:true,br:true,col:true,command:true,embed:true,frame:true,hr:true,img:true,input:true,isindex:true,keygen:true,link:true,meta:true,param:true,source:true,track:true,wbr:true};var render=module.exports=function(dom,opts){if(!Array.isArray(dom)&&!dom.cheerio)dom=[dom];opts=opts||{};var output="";for(var i=0;i"}else{tag+=">";if(elem.children){tag+=render(elem.children,opts)}if(!singleTag[elem.name]||opts.xmlMode){tag+=""}}return tag}function renderDirective(elem){return"<"+elem.data+">"}function renderText(elem,opts){var data=elem.data||"";if(opts.decodeEntities&&!(elem.parent&&elem.parent.name in unencodedElements)){data=entities.encodeXML(data)}return data}function renderCdata(elem){return""}function renderComment(elem){return""}},{domelementtype:8,entities:20}],8:[function(require,module,exports){module.exports={Text:"text",Directive:"directive",Comment:"comment",Script:"script",Style:"style",Tag:"tag",CDATA:"cdata",isTag:function(elem){return elem.type==="tag"||elem.type==="script"||elem.type==="style"}}},{}],9:[function(require,module,exports){module.exports={Text:"text",Directive:"directive",Comment:"comment",Script:"script",Style:"style",Tag:"tag",CDATA:"cdata",Doctype:"doctype",isTag:function(elem){return elem.type==="tag"||elem.type==="script"||elem.type==="style"}}},{}],10:[function(require,module,exports){var ElementType=require("domelementtype");var re_whitespace=/\s+/g;var NodePrototype=require("./lib/node");var ElementPrototype=require("./lib/element");function DomHandler(callback,options,elementCB){if(typeof callback==="object"){elementCB=options;options=callback;callback=null}else if(typeof options==="function"){elementCB=options;options=defaultOpts}this._callback=callback;this._options=options||defaultOpts;this._elementCB=elementCB;this.dom=[];this._done=false;this._tagStack=[];this._parser=this._parser||null}var defaultOpts={normalizeWhitespace:false,withStartIndices:false};DomHandler.prototype.onparserinit=function(parser){this._parser=parser};DomHandler.prototype.onreset=function(){DomHandler.call(this,this._callback,this._options,this._elementCB)};DomHandler.prototype.onend=function(){if(this._done)return;this._done=true;this._parser=null;this._handleCallback(null)};DomHandler.prototype._handleCallback=DomHandler.prototype.onerror=function(error){if(typeof this._callback==="function"){this._callback(error,this.dom)}else{if(error)throw error}};DomHandler.prototype.onclosetag=function(){var elem=this._tagStack.pop();if(this._elementCB)this._elementCB(elem)};DomHandler.prototype._addDomElement=function(element){var parent=this._tagStack[this._tagStack.length-1];var siblings=parent?parent.children:this.dom;var previousSibling=siblings[siblings.length-1];element.next=null;if(this._options.withStartIndices){element.startIndex=this._parser.startIndex}if(this._options.withDomLvl1){element.__proto__=element.type==="tag"?ElementPrototype:NodePrototype}if(previousSibling){element.prev=previousSibling;previousSibling.next=element}else{element.prev=null}siblings.push(element);element.parent=parent||null};DomHandler.prototype.onopentag=function(name,attribs){var element={type:name==="script"?ElementType.Script:name==="style"?ElementType.Style:ElementType.Tag,name:name,attribs:attribs,children:[]};this._addDomElement(element);this._tagStack.push(element)};DomHandler.prototype.ontext=function(data){var normalize=this._options.normalizeWhitespace||this._options.ignoreWhitespace;var lastTag;if(!this._tagStack.length&&this.dom.length&&(lastTag=this.dom[this.dom.length-1]).type===ElementType.Text){if(normalize){lastTag.data=(lastTag.data+data).replace(re_whitespace," ")}else{lastTag.data+=data}}else{if(this._tagStack.length&&(lastTag=this._tagStack[this._tagStack.length-1])&&(lastTag=lastTag.children[lastTag.children.length-1])&&lastTag.type===ElementType.Text){if(normalize){lastTag.data=(lastTag.data+data).replace(re_whitespace," ")}else{lastTag.data+=data}}else{if(normalize){data=data.replace(re_whitespace," ")}this._addDomElement({data:data,type:ElementType.Text})}}};DomHandler.prototype.oncomment=function(data){var lastTag=this._tagStack[this._tagStack.length-1];if(lastTag&&lastTag.type===ElementType.Comment){lastTag.data+=data;return}var element={data:data,type:ElementType.Comment};this._addDomElement(element);this._tagStack.push(element)};DomHandler.prototype.oncdatastart=function(){var element={children:[{data:"",type:ElementType.Text}],type:ElementType.CDATA};this._addDomElement(element);this._tagStack.push(element)};DomHandler.prototype.oncommentend=DomHandler.prototype.oncdataend=function(){this._tagStack.pop()};DomHandler.prototype.onprocessinginstruction=function(name,data){this._addDomElement({name:name,data:data,type:ElementType.Directive})};module.exports=DomHandler},{"./lib/element":11,"./lib/node":12,domelementtype:9}],11:[function(require,module,exports){var NodePrototype=require("./node");var ElementPrototype=module.exports=Object.create(NodePrototype);var domLvl1={tagName:"name"};Object.keys(domLvl1).forEach(function(key){var shorthand=domLvl1[key];Object.defineProperty(ElementPrototype,key,{get:function(){return this[shorthand]||null},set:function(val){this[shorthand]=val;return val}})})},{"./node":12}],12:[function(require,module,exports){var NodePrototype=module.exports={get firstChild(){var children=this.children;return children&&children[0]||null},get lastChild(){var children=this.children;return children&&children[children.length-1]||null},get nodeType(){return nodeTypes[this.type]||nodeTypes.element}};var domLvl1={tagName:"name",childNodes:"children",parentNode:"parent",previousSibling:"prev",nextSibling:"next",nodeValue:"data"};var nodeTypes={element:1,text:3,cdata:4,comment:8};Object.keys(domLvl1).forEach(function(key){var shorthand=domLvl1[key];Object.defineProperty(NodePrototype,key,{get:function(){return this[shorthand]||null},set:function(val){this[shorthand]=val;return val}})})},{}],13:[function(require,module,exports){var DomUtils=module.exports;[require("./lib/stringify"),require("./lib/traversal"),require("./lib/manipulation"),require("./lib/querying"),require("./lib/legacy"),require("./lib/helpers")].forEach(function(ext){Object.keys(ext).forEach(function(key){DomUtils[key]=ext[key].bind(DomUtils)})})},{"./lib/helpers":14,"./lib/legacy":15,"./lib/manipulation":16,"./lib/querying":17,"./lib/stringify":18,"./lib/traversal":19}],14:[function(require,module,exports){exports.removeSubsets=function(nodes){var idx=nodes.length,node,ancestor,replace;while(--idx>-1){node=ancestor=nodes[idx];nodes[idx]=null;replace=true;while(ancestor){if(nodes.indexOf(ancestor)>-1){replace=false;nodes.splice(idx,1);break}ancestor=ancestor.parent}if(replace){nodes[idx]=node}}return nodes};var POSITION={DISCONNECTED:1,PRECEDING:2,FOLLOWING:4,CONTAINS:8,CONTAINED_BY:16};var comparePos=exports.compareDocumentPosition=function(nodeA,nodeB){var aParents=[];var bParents=[];var current,sharedParent,siblings,aSibling,bSibling,idx;if(nodeA===nodeB){return 0}current=nodeA;while(current){aParents.unshift(current);current=current.parent}current=nodeB;while(current){bParents.unshift(current);current=current.parent}idx=0;while(aParents[idx]===bParents[idx]){idx++}if(idx===0){return POSITION.DISCONNECTED}sharedParent=aParents[idx-1];siblings=sharedParent.children;aSibling=aParents[idx];bSibling=bParents[idx];if(siblings.indexOf(aSibling)>siblings.indexOf(bSibling)){if(sharedParent===nodeB){return POSITION.FOLLOWING|POSITION.CONTAINED_BY}return POSITION.FOLLOWING}else{if(sharedParent===nodeA){return POSITION.PRECEDING|POSITION.CONTAINS}return POSITION.PRECEDING}};exports.uniqueSort=function(nodes){var idx=nodes.length,node,position;nodes=nodes.slice();while(--idx>-1){node=nodes[idx];position=nodes.indexOf(node);if(position>-1&&position0){childs=find(test,childs,recurse,limit);result=result.concat(childs);limit-=childs.length;if(limit<=0)break}}return result}function findOneChild(test,elems){for(var i=0,l=elems.length;i0){elem=findOne(test,elems[i].children)}}return elem}function existsOne(test,elems){for(var i=0,l=elems.length;i0&&existsOne(test,elems[i].children))){return true}}return false}function findAll(test,elems){var result=[];for(var i=0,j=elems.length;i0){result=result.concat(findAll(test,elems[i].children))}}return result}},{domelementtype:9}],18:[function(require,module,exports){var ElementType=require("domelementtype"),getOuterHTML=require("dom-serializer"),isTag=ElementType.isTag;module.exports={getInnerHTML:getInnerHTML,getOuterHTML:getOuterHTML,getText:getText};function getInnerHTML(elem,opts){return elem.children?elem.children.map(function(elem){return getOuterHTML(elem,opts)}).join(""):""}function getText(elem){if(Array.isArray(elem))return elem.map(getText).join("");if(isTag(elem)||elem.type===ElementType.CDATA)return getText(elem.children);if(elem.type===ElementType.Text)return elem.data;return""}},{"dom-serializer":7,domelementtype:9}],19:[function(require,module,exports){var getChildren=exports.getChildren=function(elem){return elem.children};var getParent=exports.getParent=function(elem){return elem.parent};exports.getSiblings=function(elem){var parent=getParent(elem);return parent?getChildren(parent):[elem]};exports.getAttributeValue=function(elem,name){return elem.attribs&&elem.attribs[name]};exports.hasAttrib=function(elem,name){return!!elem.attribs&&hasOwnProperty.call(elem.attribs,name)};exports.getName=function(elem){return elem.name}},{}],20:[function(require,module,exports){var encode=require("./lib/encode.js"),decode=require("./lib/decode.js");exports.decode=function(data,level){return(!level||level<=0?decode.XML:decode.HTML)(data)};exports.decodeStrict=function(data,level){return(!level||level<=0?decode.XML:decode.HTMLStrict)(data)};exports.encode=function(data,level){return(!level||level<=0?encode.XML:encode.HTML)(data)};exports.encodeXML=encode.XML;exports.encodeHTML4=exports.encodeHTML5=exports.encodeHTML=encode.HTML;exports.decodeXML=exports.decodeXMLStrict=decode.XML;exports.decodeHTML4=exports.decodeHTML5=exports.decodeHTML=decode.HTML;exports.decodeHTML4Strict=exports.decodeHTML5Strict=exports.decodeHTMLStrict=decode.HTMLStrict;exports.escape=encode.escape},{"./lib/decode.js":21,"./lib/encode.js":23}],21:[function(require,module,exports){var entityMap=require("../maps/entities.json"),legacyMap=require("../maps/legacy.json"),xmlMap=require("../maps/xml.json"),decodeCodePoint=require("./decode_codepoint.js");var decodeXMLStrict=getStrictDecoder(xmlMap),decodeHTMLStrict=getStrictDecoder(entityMap);function getStrictDecoder(map){var keys=Object.keys(map).join("|"),replace=getReplacer(map);keys+="|#[xX][\\da-fA-F]+|#\\d+";var re=new RegExp("&(?:"+keys+");","g");return function(str){return String(str).replace(re,replace)}}var decodeHTML=function(){var legacy=Object.keys(legacyMap).sort(sorter);var keys=Object.keys(entityMap).sort(sorter);for(var i=0,j=0;i=55296&&codePoint<=57343||codePoint>1114111){return"�"}if(codePoint in decodeMap){codePoint=decodeMap[codePoint]}var output="";if(codePoint>65535){codePoint-=65536;output+=String.fromCharCode(codePoint>>>10&1023|55296);codePoint=56320|codePoint&1023}output+=String.fromCharCode(codePoint);return output}},{"../maps/decode.json":24}],23:[function(require,module,exports){var inverseXML=getInverseObj(require("../maps/xml.json")),xmlReplacer=getInverseReplacer(inverseXML);exports.XML=getInverse(inverseXML,xmlReplacer);var inverseHTML=getInverseObj(require("../maps/entities.json")),htmlReplacer=getInverseReplacer(inverseHTML);exports.HTML=getInverse(inverseHTML,htmlReplacer);function getInverseObj(obj){return Object.keys(obj).sort().reduce(function(inverse,name){inverse[obj[name]]="&"+name+";";return inverse},{})}function getInverseReplacer(inverse){var single=[],multiple=[];Object.keys(inverse).forEach(function(k){if(k.length===1){single.push("\\"+k)}else{multiple.push(k)}});multiple.unshift("["+single.join("")+"]");return new RegExp(multiple.join("|"),"g")}var re_nonASCII=/[^\0-\x7F]/g,re_astralSymbols=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;function singleCharReplacer(c){return"&#x"+c.charCodeAt(0).toString(16).toUpperCase()+";"}function astralReplacer(c){var high=c.charCodeAt(0);var low=c.charCodeAt(1);var codePoint=(high-55296)*1024+low-56320+65536;return"&#x"+codePoint.toString(16).toUpperCase()+";"}function getInverse(inverse,re){function func(name){return inverse[name]}return function(data){return data.replace(re,func).replace(re_astralSymbols,astralReplacer).replace(re_nonASCII,singleCharReplacer)}}var re_xmlChars=getInverseReplacer(inverseXML);function escapeXML(data){return data.replace(re_xmlChars,singleCharReplacer).replace(re_astralSymbols,astralReplacer).replace(re_nonASCII,singleCharReplacer)}exports.escape=escapeXML},{"../maps/entities.json":25,"../maps/xml.json":27}],24:[function(require,module,exports){module.exports={0:65533,128:8364,130:8218,131:402,132:8222,133:8230,134:8224,135:8225,136:710,137:8240,138:352,139:8249,140:338,142:381,145:8216,146:8217,147:8220,148:8221,149:8226,150:8211,151:8212,152:732,153:8482,154:353,155:8250,156:339,158:382,159:376}},{}],25:[function(require,module,exports){module.exports={Aacute:"Á",aacute:"á",Abreve:"Ă",abreve:"ă",ac:"∾",acd:"∿",acE:"∾̳",Acirc:"Â",acirc:"â",acute:"´",Acy:"А",acy:"а",AElig:"Æ",aelig:"æ",af:"⁡",Afr:"𝔄",afr:"𝔞",Agrave:"À",agrave:"à",alefsym:"ℵ",aleph:"ℵ",Alpha:"Α",alpha:"α",Amacr:"Ā",amacr:"ā",amalg:"⨿",amp:"&",AMP:"&",andand:"⩕",And:"⩓",and:"∧",andd:"⩜",andslope:"⩘",andv:"⩚",ang:"∠",ange:"⦤",angle:"∠",angmsdaa:"⦨",angmsdab:"⦩",angmsdac:"⦪",angmsdad:"⦫",angmsdae:"⦬",angmsdaf:"⦭",angmsdag:"⦮",angmsdah:"⦯",angmsd:"∡",angrt:"∟",angrtvb:"⊾",angrtvbd:"⦝",angsph:"∢",angst:"Å",angzarr:"⍼",Aogon:"Ą",aogon:"ą",Aopf:"𝔸",aopf:"𝕒",apacir:"⩯",ap:"≈",apE:"⩰",ape:"≊",apid:"≋",apos:"'",ApplyFunction:"⁡",approx:"≈",approxeq:"≊",Aring:"Å",aring:"å",Ascr:"𝒜",ascr:"𝒶",Assign:"≔",ast:"*",asymp:"≈",asympeq:"≍",Atilde:"Ã",atilde:"ã",Auml:"Ä",auml:"ä",awconint:"∳",awint:"⨑",backcong:"≌",backepsilon:"϶",backprime:"‵",backsim:"∽",backsimeq:"⋍",Backslash:"∖",Barv:"⫧",barvee:"⊽",barwed:"⌅",Barwed:"⌆",barwedge:"⌅",bbrk:"⎵",bbrktbrk:"⎶",bcong:"≌",Bcy:"Б",bcy:"б",bdquo:"„",becaus:"∵",because:"∵",Because:"∵",bemptyv:"⦰",bepsi:"϶",bernou:"ℬ",Bernoullis:"ℬ",Beta:"Β",beta:"β",beth:"ℶ",between:"≬",Bfr:"𝔅",bfr:"𝔟",bigcap:"⋂",bigcirc:"◯",bigcup:"⋃",bigodot:"⨀",bigoplus:"⨁",bigotimes:"⨂",bigsqcup:"⨆",bigstar:"★",bigtriangledown:"▽",bigtriangleup:"△",biguplus:"⨄",bigvee:"⋁",bigwedge:"⋀",bkarow:"⤍",blacklozenge:"⧫",blacksquare:"▪",blacktriangle:"▴",blacktriangledown:"▾",blacktriangleleft:"◂",blacktriangleright:"▸",blank:"␣",blk12:"▒",blk14:"░",blk34:"▓",block:"█",bne:"=⃥",bnequiv:"≡⃥",bNot:"⫭",bnot:"⌐",Bopf:"𝔹",bopf:"𝕓",bot:"⊥",bottom:"⊥",bowtie:"⋈",boxbox:"⧉",boxdl:"┐",boxdL:"╕",boxDl:"╖",boxDL:"╗",boxdr:"┌",boxdR:"╒",boxDr:"╓",boxDR:"╔",boxh:"─",boxH:"═",boxhd:"┬",boxHd:"╤",boxhD:"╥",boxHD:"╦",boxhu:"┴",boxHu:"╧",boxhU:"╨",boxHU:"╩",boxminus:"⊟",boxplus:"⊞",boxtimes:"⊠",boxul:"┘",boxuL:"╛",boxUl:"╜",boxUL:"╝",boxur:"└",boxuR:"╘",boxUr:"╙",boxUR:"╚",boxv:"│",boxV:"║",boxvh:"┼",boxvH:"╪",boxVh:"╫",boxVH:"╬",boxvl:"┤",boxvL:"╡",boxVl:"╢",boxVL:"╣",boxvr:"├",boxvR:"╞",boxVr:"╟",boxVR:"╠",bprime:"‵",breve:"˘",Breve:"˘",brvbar:"¦",bscr:"𝒷",Bscr:"ℬ",bsemi:"⁏",bsim:"∽",bsime:"⋍",bsolb:"⧅",bsol:"\\",bsolhsub:"⟈",bull:"•",bullet:"•",bump:"≎",bumpE:"⪮",bumpe:"≏",Bumpeq:"≎",bumpeq:"≏",Cacute:"Ć",cacute:"ć",capand:"⩄",capbrcup:"⩉",capcap:"⩋",cap:"∩",Cap:"⋒",capcup:"⩇",capdot:"⩀",CapitalDifferentialD:"ⅅ",caps:"∩︀",caret:"⁁",caron:"ˇ",Cayleys:"ℭ",ccaps:"⩍",Ccaron:"Č",ccaron:"č",Ccedil:"Ç",ccedil:"ç",Ccirc:"Ĉ",ccirc:"ĉ",Cconint:"∰",ccups:"⩌",ccupssm:"⩐",Cdot:"Ċ",cdot:"ċ",cedil:"¸",Cedilla:"¸",cemptyv:"⦲",cent:"¢",centerdot:"·",CenterDot:"·",cfr:"𝔠",Cfr:"ℭ",CHcy:"Ч",chcy:"ч",check:"✓",checkmark:"✓",Chi:"Χ",chi:"χ",circ:"ˆ",circeq:"≗",circlearrowleft:"↺",circlearrowright:"↻",circledast:"⊛",circledcirc:"⊚",circleddash:"⊝",CircleDot:"⊙",circledR:"®",circledS:"Ⓢ",CircleMinus:"⊖",CirclePlus:"⊕",CircleTimes:"⊗",cir:"○",cirE:"⧃",cire:"≗",cirfnint:"⨐",cirmid:"⫯",cirscir:"⧂",ClockwiseContourIntegral:"∲",CloseCurlyDoubleQuote:"”",CloseCurlyQuote:"’",clubs:"♣",clubsuit:"♣",colon:":",Colon:"∷",Colone:"⩴",colone:"≔",coloneq:"≔",comma:",",commat:"@",comp:"∁",compfn:"∘",complement:"∁",complexes:"ℂ",cong:"≅",congdot:"⩭",Congruent:"≡",conint:"∮",Conint:"∯",ContourIntegral:"∮",copf:"𝕔",Copf:"ℂ",coprod:"∐",Coproduct:"∐",copy:"©",COPY:"©",copysr:"℗",CounterClockwiseContourIntegral:"∳",crarr:"↵",cross:"✗",Cross:"⨯",Cscr:"𝒞",cscr:"𝒸",csub:"⫏",csube:"⫑",csup:"⫐",csupe:"⫒",ctdot:"⋯",cudarrl:"⤸",cudarrr:"⤵",cuepr:"⋞",cuesc:"⋟",cularr:"↶",cularrp:"⤽",cupbrcap:"⩈",cupcap:"⩆",CupCap:"≍",cup:"∪",Cup:"⋓",cupcup:"⩊",cupdot:"⊍",cupor:"⩅",cups:"∪︀",curarr:"↷",curarrm:"⤼",curlyeqprec:"⋞",curlyeqsucc:"⋟",curlyvee:"⋎",curlywedge:"⋏",curren:"¤",curvearrowleft:"↶",curvearrowright:"↷",cuvee:"⋎",cuwed:"⋏",cwconint:"∲",cwint:"∱",cylcty:"⌭",dagger:"†",Dagger:"‡",daleth:"ℸ",darr:"↓",Darr:"↡",dArr:"⇓",dash:"‐",Dashv:"⫤",dashv:"⊣",dbkarow:"⤏",dblac:"˝",Dcaron:"Ď",dcaron:"ď",Dcy:"Д",dcy:"д",ddagger:"‡",ddarr:"⇊",DD:"ⅅ",dd:"ⅆ",DDotrahd:"⤑",ddotseq:"⩷",deg:"°",Del:"∇",Delta:"Δ",delta:"δ",demptyv:"⦱",dfisht:"⥿",Dfr:"𝔇",dfr:"𝔡",dHar:"⥥",dharl:"⇃",dharr:"⇂",DiacriticalAcute:"´",DiacriticalDot:"˙",DiacriticalDoubleAcute:"˝",DiacriticalGrave:"`",DiacriticalTilde:"˜",diam:"⋄",diamond:"⋄",Diamond:"⋄",diamondsuit:"♦",diams:"♦",die:"¨",DifferentialD:"ⅆ",digamma:"ϝ",disin:"⋲",div:"÷",divide:"÷",divideontimes:"⋇",divonx:"⋇",DJcy:"Ђ",djcy:"ђ",dlcorn:"⌞",dlcrop:"⌍",dollar:"$",Dopf:"𝔻",dopf:"𝕕",Dot:"¨",dot:"˙",DotDot:"⃜",doteq:"≐",doteqdot:"≑",DotEqual:"≐",dotminus:"∸",dotplus:"∔",dotsquare:"⊡",doublebarwedge:"⌆",DoubleContourIntegral:"∯",DoubleDot:"¨",DoubleDownArrow:"⇓",DoubleLeftArrow:"⇐",DoubleLeftRightArrow:"⇔",DoubleLeftTee:"⫤",DoubleLongLeftArrow:"⟸",DoubleLongLeftRightArrow:"⟺",DoubleLongRightArrow:"⟹",DoubleRightArrow:"⇒",DoubleRightTee:"⊨",DoubleUpArrow:"⇑",DoubleUpDownArrow:"⇕",DoubleVerticalBar:"∥",DownArrowBar:"⤓",downarrow:"↓",DownArrow:"↓",Downarrow:"⇓",DownArrowUpArrow:"⇵",DownBreve:"̑",downdownarrows:"⇊",downharpoonleft:"⇃",downharpoonright:"⇂",DownLeftRightVector:"⥐",DownLeftTeeVector:"⥞",DownLeftVectorBar:"⥖",DownLeftVector:"↽",DownRightTeeVector:"⥟",DownRightVectorBar:"⥗",DownRightVector:"⇁",DownTeeArrow:"↧",DownTee:"⊤",drbkarow:"⤐",drcorn:"⌟",drcrop:"⌌",Dscr:"𝒟",dscr:"𝒹",DScy:"Ѕ",dscy:"ѕ",dsol:"⧶",Dstrok:"Đ",dstrok:"đ",dtdot:"⋱",dtri:"▿",dtrif:"▾",duarr:"⇵",duhar:"⥯",dwangle:"⦦",DZcy:"Џ",dzcy:"џ",dzigrarr:"⟿",Eacute:"É",eacute:"é",easter:"⩮",Ecaron:"Ě",ecaron:"ě",Ecirc:"Ê",ecirc:"ê",ecir:"≖",ecolon:"≕",Ecy:"Э",ecy:"э",eDDot:"⩷",Edot:"Ė",edot:"ė",eDot:"≑",ee:"ⅇ",efDot:"≒",Efr:"𝔈",efr:"𝔢",eg:"⪚",Egrave:"È",egrave:"è",egs:"⪖",egsdot:"⪘",el:"⪙",Element:"∈",elinters:"⏧",ell:"ℓ",els:"⪕",elsdot:"⪗",Emacr:"Ē",emacr:"ē",empty:"∅",emptyset:"∅",EmptySmallSquare:"◻",emptyv:"∅",EmptyVerySmallSquare:"▫",emsp13:" ",emsp14:" ",emsp:" ",ENG:"Ŋ",eng:"ŋ",ensp:" ",Eogon:"Ę",eogon:"ę",Eopf:"𝔼",eopf:"𝕖",epar:"⋕",eparsl:"⧣",eplus:"⩱",epsi:"ε",Epsilon:"Ε",epsilon:"ε",epsiv:"ϵ",eqcirc:"≖",eqcolon:"≕",eqsim:"≂",eqslantgtr:"⪖",eqslantless:"⪕",Equal:"⩵",equals:"=",EqualTilde:"≂",equest:"≟",Equilibrium:"⇌",equiv:"≡",equivDD:"⩸",eqvparsl:"⧥",erarr:"⥱",erDot:"≓",escr:"ℯ",Escr:"ℰ",esdot:"≐",Esim:"⩳",esim:"≂",Eta:"Η",eta:"η",ETH:"Ð",eth:"ð",Euml:"Ë",euml:"ë",euro:"€",excl:"!",exist:"∃",Exists:"∃",expectation:"ℰ",exponentiale:"ⅇ",ExponentialE:"ⅇ",fallingdotseq:"≒",Fcy:"Ф",fcy:"ф",female:"♀",ffilig:"ffi",fflig:"ff",ffllig:"ffl",Ffr:"𝔉",ffr:"𝔣",filig:"fi",FilledSmallSquare:"◼",FilledVerySmallSquare:"▪",fjlig:"fj",flat:"♭",fllig:"fl",fltns:"▱",fnof:"ƒ",Fopf:"𝔽",fopf:"𝕗",forall:"∀",ForAll:"∀",fork:"⋔",forkv:"⫙",Fouriertrf:"ℱ",fpartint:"⨍",frac12:"½",frac13:"⅓",frac14:"¼",frac15:"⅕",frac16:"⅙",frac18:"⅛",frac23:"⅔",frac25:"⅖",frac34:"¾",frac35:"⅗",frac38:"⅜",frac45:"⅘",frac56:"⅚",frac58:"⅝",frac78:"⅞",frasl:"⁄",frown:"⌢",fscr:"𝒻",Fscr:"ℱ",gacute:"ǵ",Gamma:"Γ",gamma:"γ",Gammad:"Ϝ",gammad:"ϝ",gap:"⪆",Gbreve:"Ğ",gbreve:"ğ",Gcedil:"Ģ",Gcirc:"Ĝ",gcirc:"ĝ",Gcy:"Г",gcy:"г",Gdot:"Ġ",gdot:"ġ",ge:"≥",gE:"≧",gEl:"⪌",gel:"⋛",geq:"≥",geqq:"≧",geqslant:"⩾",gescc:"⪩",ges:"⩾",gesdot:"⪀",gesdoto:"⪂",gesdotol:"⪄",gesl:"⋛︀",gesles:"⪔",Gfr:"𝔊",gfr:"𝔤",gg:"≫",Gg:"⋙",ggg:"⋙",gimel:"ℷ",GJcy:"Ѓ",gjcy:"ѓ",gla:"⪥",gl:"≷",glE:"⪒",glj:"⪤",gnap:"⪊",gnapprox:"⪊",gne:"⪈",gnE:"≩",gneq:"⪈",gneqq:"≩",gnsim:"⋧",Gopf:"𝔾",gopf:"𝕘",grave:"`",GreaterEqual:"≥",GreaterEqualLess:"⋛",GreaterFullEqual:"≧",GreaterGreater:"⪢",GreaterLess:"≷",GreaterSlantEqual:"⩾",GreaterTilde:"≳",Gscr:"𝒢",gscr:"ℊ",gsim:"≳",gsime:"⪎",gsiml:"⪐",gtcc:"⪧",gtcir:"⩺",gt:">",GT:">",Gt:"≫",gtdot:"⋗",gtlPar:"⦕",gtquest:"⩼",gtrapprox:"⪆",gtrarr:"⥸",gtrdot:"⋗",gtreqless:"⋛",gtreqqless:"⪌",gtrless:"≷",gtrsim:"≳",gvertneqq:"≩︀",gvnE:"≩︀",Hacek:"ˇ",hairsp:" ",half:"½",hamilt:"ℋ",HARDcy:"Ъ",hardcy:"ъ",harrcir:"⥈",harr:"↔",hArr:"⇔",harrw:"↭",Hat:"^",hbar:"ℏ",Hcirc:"Ĥ",hcirc:"ĥ",hearts:"♥",heartsuit:"♥",hellip:"…",hercon:"⊹",hfr:"𝔥",Hfr:"ℌ",HilbertSpace:"ℋ",hksearow:"⤥",hkswarow:"⤦",hoarr:"⇿",homtht:"∻",hookleftarrow:"↩",hookrightarrow:"↪",hopf:"𝕙",Hopf:"ℍ",horbar:"―",HorizontalLine:"─",hscr:"𝒽",Hscr:"ℋ",hslash:"ℏ",Hstrok:"Ħ",hstrok:"ħ",HumpDownHump:"≎",HumpEqual:"≏",hybull:"⁃",hyphen:"‐",Iacute:"Í",iacute:"í",ic:"⁣",Icirc:"Î",icirc:"î",Icy:"И",icy:"и",Idot:"İ",IEcy:"Е",iecy:"е",iexcl:"¡",iff:"⇔",ifr:"𝔦",Ifr:"ℑ",Igrave:"Ì",igrave:"ì",ii:"ⅈ",iiiint:"⨌",iiint:"∭",iinfin:"⧜",iiota:"℩",IJlig:"IJ",ijlig:"ij",Imacr:"Ī",imacr:"ī",image:"ℑ",ImaginaryI:"ⅈ",imagline:"ℐ",imagpart:"ℑ",imath:"ı",Im:"ℑ",imof:"⊷",imped:"Ƶ",Implies:"⇒",incare:"℅",in:"∈",infin:"∞",infintie:"⧝",inodot:"ı",intcal:"⊺",int:"∫",Int:"∬",integers:"ℤ",Integral:"∫",intercal:"⊺",Intersection:"⋂",intlarhk:"⨗",intprod:"⨼",InvisibleComma:"⁣",InvisibleTimes:"⁢",IOcy:"Ё",iocy:"ё",Iogon:"Į",iogon:"į",Iopf:"𝕀",iopf:"𝕚",Iota:"Ι",iota:"ι",iprod:"⨼",iquest:"¿",iscr:"𝒾",Iscr:"ℐ",isin:"∈",isindot:"⋵",isinE:"⋹",isins:"⋴",isinsv:"⋳",isinv:"∈",it:"⁢",Itilde:"Ĩ",itilde:"ĩ",Iukcy:"І",iukcy:"і",Iuml:"Ï",iuml:"ï",Jcirc:"Ĵ",jcirc:"ĵ",Jcy:"Й",jcy:"й",Jfr:"𝔍",jfr:"𝔧",jmath:"ȷ",Jopf:"𝕁",jopf:"𝕛",Jscr:"𝒥",jscr:"𝒿",Jsercy:"Ј",jsercy:"ј",Jukcy:"Є",jukcy:"є",Kappa:"Κ",kappa:"κ",kappav:"ϰ",Kcedil:"Ķ",kcedil:"ķ",Kcy:"К",kcy:"к",Kfr:"𝔎",kfr:"𝔨",kgreen:"ĸ",KHcy:"Х",khcy:"х",KJcy:"Ќ",kjcy:"ќ",Kopf:"𝕂",kopf:"𝕜",Kscr:"𝒦",kscr:"𝓀",lAarr:"⇚",Lacute:"Ĺ",lacute:"ĺ",laemptyv:"⦴",lagran:"ℒ",Lambda:"Λ",lambda:"λ",lang:"⟨",Lang:"⟪",langd:"⦑",langle:"⟨",lap:"⪅",Laplacetrf:"ℒ",laquo:"«",larrb:"⇤",larrbfs:"⤟",larr:"←",Larr:"↞",lArr:"⇐",larrfs:"⤝",larrhk:"↩",larrlp:"↫",larrpl:"⤹",larrsim:"⥳",larrtl:"↢",latail:"⤙",lAtail:"⤛",lat:"⪫",late:"⪭",lates:"⪭︀",lbarr:"⤌",lBarr:"⤎",lbbrk:"❲",lbrace:"{",lbrack:"[",lbrke:"⦋",lbrksld:"⦏",lbrkslu:"⦍",Lcaron:"Ľ",lcaron:"ľ",Lcedil:"Ļ",lcedil:"ļ",lceil:"⌈",lcub:"{",Lcy:"Л",lcy:"л",ldca:"⤶",ldquo:"“",ldquor:"„",ldrdhar:"⥧",ldrushar:"⥋",ldsh:"↲",le:"≤",lE:"≦",LeftAngleBracket:"⟨",LeftArrowBar:"⇤",leftarrow:"←",LeftArrow:"←",Leftarrow:"⇐",LeftArrowRightArrow:"⇆",leftarrowtail:"↢",LeftCeiling:"⌈",LeftDoubleBracket:"⟦",LeftDownTeeVector:"⥡",LeftDownVectorBar:"⥙",LeftDownVector:"⇃",LeftFloor:"⌊",leftharpoondown:"↽",leftharpoonup:"↼",leftleftarrows:"⇇",leftrightarrow:"↔",LeftRightArrow:"↔",Leftrightarrow:"⇔",leftrightarrows:"⇆",leftrightharpoons:"⇋",leftrightsquigarrow:"↭",LeftRightVector:"⥎",LeftTeeArrow:"↤",LeftTee:"⊣",LeftTeeVector:"⥚",leftthreetimes:"⋋",LeftTriangleBar:"⧏",LeftTriangle:"⊲",LeftTriangleEqual:"⊴",LeftUpDownVector:"⥑",LeftUpTeeVector:"⥠",LeftUpVectorBar:"⥘",LeftUpVector:"↿",LeftVectorBar:"⥒",LeftVector:"↼",lEg:"⪋",leg:"⋚",leq:"≤",leqq:"≦",leqslant:"⩽",lescc:"⪨",les:"⩽",lesdot:"⩿",lesdoto:"⪁",lesdotor:"⪃",lesg:"⋚︀",lesges:"⪓",lessapprox:"⪅",lessdot:"⋖",lesseqgtr:"⋚",lesseqqgtr:"⪋",LessEqualGreater:"⋚",LessFullEqual:"≦",LessGreater:"≶",lessgtr:"≶",LessLess:"⪡",lesssim:"≲",LessSlantEqual:"⩽",LessTilde:"≲",lfisht:"⥼",lfloor:"⌊",Lfr:"𝔏",lfr:"𝔩",lg:"≶",lgE:"⪑",lHar:"⥢",lhard:"↽",lharu:"↼",lharul:"⥪",lhblk:"▄",LJcy:"Љ",ljcy:"љ",llarr:"⇇",ll:"≪",Ll:"⋘",llcorner:"⌞",Lleftarrow:"⇚",llhard:"⥫",lltri:"◺",Lmidot:"Ŀ",lmidot:"ŀ",lmoustache:"⎰",lmoust:"⎰",lnap:"⪉",lnapprox:"⪉",lne:"⪇",lnE:"≨",lneq:"⪇",lneqq:"≨",lnsim:"⋦",loang:"⟬",loarr:"⇽",lobrk:"⟦",longleftarrow:"⟵",LongLeftArrow:"⟵",Longleftarrow:"⟸",longleftrightarrow:"⟷",LongLeftRightArrow:"⟷",Longleftrightarrow:"⟺",longmapsto:"⟼",longrightarrow:"⟶",LongRightArrow:"⟶",Longrightarrow:"⟹",looparrowleft:"↫",looparrowright:"↬",lopar:"⦅",Lopf:"𝕃",lopf:"𝕝",loplus:"⨭",lotimes:"⨴",lowast:"∗",lowbar:"_",LowerLeftArrow:"↙",LowerRightArrow:"↘",loz:"◊",lozenge:"◊",lozf:"⧫",lpar:"(",lparlt:"⦓",lrarr:"⇆",lrcorner:"⌟",lrhar:"⇋",lrhard:"⥭",lrm:"‎",lrtri:"⊿",lsaquo:"‹",lscr:"𝓁",Lscr:"ℒ",lsh:"↰",Lsh:"↰",lsim:"≲",lsime:"⪍",lsimg:"⪏",lsqb:"[",lsquo:"‘",lsquor:"‚",Lstrok:"Ł",lstrok:"ł",ltcc:"⪦",ltcir:"⩹",lt:"<",LT:"<",Lt:"≪",ltdot:"⋖",lthree:"⋋",ltimes:"⋉",ltlarr:"⥶",ltquest:"⩻",ltri:"◃",ltrie:"⊴",ltrif:"◂",ltrPar:"⦖",lurdshar:"⥊",luruhar:"⥦",lvertneqq:"≨︀",lvnE:"≨︀",macr:"¯",male:"♂",malt:"✠",maltese:"✠",Map:"⤅",map:"↦",mapsto:"↦",mapstodown:"↧",mapstoleft:"↤",mapstoup:"↥",marker:"▮",mcomma:"⨩",Mcy:"М",mcy:"м",mdash:"—",mDDot:"∺",measuredangle:"∡",MediumSpace:" ",Mellintrf:"ℳ",Mfr:"𝔐",mfr:"𝔪",mho:"℧",micro:"µ",midast:"*",midcir:"⫰",mid:"∣",middot:"·",minusb:"⊟",minus:"−",minusd:"∸",minusdu:"⨪",MinusPlus:"∓",mlcp:"⫛",mldr:"…",mnplus:"∓",models:"⊧",Mopf:"𝕄",mopf:"𝕞",mp:"∓",mscr:"𝓂",Mscr:"ℳ",mstpos:"∾",Mu:"Μ",mu:"μ",multimap:"⊸",mumap:"⊸",nabla:"∇",Nacute:"Ń",nacute:"ń",nang:"∠⃒",nap:"≉",napE:"⩰̸",napid:"≋̸",napos:"ʼn",napprox:"≉",natural:"♮",naturals:"ℕ",natur:"♮",nbsp:" ",nbump:"≎̸",nbumpe:"≏̸",ncap:"⩃",Ncaron:"Ň",ncaron:"ň",Ncedil:"Ņ",ncedil:"ņ",ncong:"≇",ncongdot:"⩭̸",ncup:"⩂",Ncy:"Н",ncy:"н",ndash:"–",nearhk:"⤤",nearr:"↗",neArr:"⇗",nearrow:"↗",ne:"≠",nedot:"≐̸",NegativeMediumSpace:"​",NegativeThickSpace:"​",NegativeThinSpace:"​",NegativeVeryThinSpace:"​",nequiv:"≢",nesear:"⤨",nesim:"≂̸",NestedGreaterGreater:"≫",NestedLessLess:"≪",NewLine:"\n",nexist:"∄",nexists:"∄",Nfr:"𝔑",nfr:"𝔫",ngE:"≧̸",nge:"≱",ngeq:"≱",ngeqq:"≧̸",ngeqslant:"⩾̸",nges:"⩾̸",nGg:"⋙̸",ngsim:"≵",nGt:"≫⃒",ngt:"≯",ngtr:"≯",nGtv:"≫̸",nharr:"↮",nhArr:"⇎",nhpar:"⫲",ni:"∋",nis:"⋼",nisd:"⋺",niv:"∋",NJcy:"Њ",njcy:"њ",nlarr:"↚",nlArr:"⇍",nldr:"‥",nlE:"≦̸",nle:"≰",nleftarrow:"↚",nLeftarrow:"⇍",nleftrightarrow:"↮",nLeftrightarrow:"⇎",nleq:"≰",nleqq:"≦̸",nleqslant:"⩽̸",nles:"⩽̸",nless:"≮",nLl:"⋘̸",nlsim:"≴",nLt:"≪⃒",nlt:"≮",nltri:"⋪",nltrie:"⋬",nLtv:"≪̸",nmid:"∤",NoBreak:"⁠",NonBreakingSpace:" ",nopf:"𝕟",Nopf:"ℕ",Not:"⫬",not:"¬",NotCongruent:"≢",NotCupCap:"≭",NotDoubleVerticalBar:"∦",NotElement:"∉",NotEqual:"≠",NotEqualTilde:"≂̸",NotExists:"∄",NotGreater:"≯",NotGreaterEqual:"≱",NotGreaterFullEqual:"≧̸",NotGreaterGreater:"≫̸",NotGreaterLess:"≹",NotGreaterSlantEqual:"⩾̸",NotGreaterTilde:"≵",NotHumpDownHump:"≎̸",NotHumpEqual:"≏̸",notin:"∉",notindot:"⋵̸",notinE:"⋹̸",notinva:"∉",notinvb:"⋷",notinvc:"⋶",NotLeftTriangleBar:"⧏̸",NotLeftTriangle:"⋪",NotLeftTriangleEqual:"⋬",NotLess:"≮",NotLessEqual:"≰",NotLessGreater:"≸",NotLessLess:"≪̸",NotLessSlantEqual:"⩽̸",NotLessTilde:"≴",NotNestedGreaterGreater:"⪢̸",NotNestedLessLess:"⪡̸",notni:"∌",notniva:"∌",notnivb:"⋾",notnivc:"⋽",NotPrecedes:"⊀",NotPrecedesEqual:"⪯̸",NotPrecedesSlantEqual:"⋠",NotReverseElement:"∌",NotRightTriangleBar:"⧐̸",NotRightTriangle:"⋫",NotRightTriangleEqual:"⋭",NotSquareSubset:"⊏̸",NotSquareSubsetEqual:"⋢",NotSquareSuperset:"⊐̸",NotSquareSupersetEqual:"⋣",NotSubset:"⊂⃒",NotSubsetEqual:"⊈",NotSucceeds:"⊁",NotSucceedsEqual:"⪰̸",NotSucceedsSlantEqual:"⋡",NotSucceedsTilde:"≿̸",NotSuperset:"⊃⃒",NotSupersetEqual:"⊉",NotTilde:"≁",NotTildeEqual:"≄",NotTildeFullEqual:"≇",NotTildeTilde:"≉",NotVerticalBar:"∤",nparallel:"∦",npar:"∦",nparsl:"⫽⃥",npart:"∂̸",npolint:"⨔",npr:"⊀",nprcue:"⋠",nprec:"⊀",npreceq:"⪯̸",npre:"⪯̸",nrarrc:"⤳̸",nrarr:"↛",nrArr:"⇏",nrarrw:"↝̸",nrightarrow:"↛",nRightarrow:"⇏",nrtri:"⋫",nrtrie:"⋭",nsc:"⊁",nsccue:"⋡",nsce:"⪰̸",Nscr:"𝒩",nscr:"𝓃",nshortmid:"∤",nshortparallel:"∦",nsim:"≁",nsime:"≄",nsimeq:"≄",nsmid:"∤",nspar:"∦",nsqsube:"⋢",nsqsupe:"⋣",nsub:"⊄",nsubE:"⫅̸",nsube:"⊈",nsubset:"⊂⃒",nsubseteq:"⊈",nsubseteqq:"⫅̸",nsucc:"⊁",nsucceq:"⪰̸",nsup:"⊅",nsupE:"⫆̸",nsupe:"⊉",nsupset:"⊃⃒",nsupseteq:"⊉",nsupseteqq:"⫆̸",ntgl:"≹",Ntilde:"Ñ",ntilde:"ñ",ntlg:"≸",ntriangleleft:"⋪",ntrianglelefteq:"⋬",ntriangleright:"⋫",ntrianglerighteq:"⋭",Nu:"Ν",nu:"ν",num:"#",numero:"№",numsp:" ",nvap:"≍⃒",nvdash:"⊬",nvDash:"⊭",nVdash:"⊮",nVDash:"⊯",nvge:"≥⃒",nvgt:">⃒",nvHarr:"⤄",nvinfin:"⧞",nvlArr:"⤂",nvle:"≤⃒",nvlt:"<⃒",nvltrie:"⊴⃒",nvrArr:"⤃",nvrtrie:"⊵⃒",nvsim:"∼⃒",nwarhk:"⤣",nwarr:"↖",nwArr:"⇖",nwarrow:"↖",nwnear:"⤧",Oacute:"Ó",oacute:"ó",oast:"⊛",Ocirc:"Ô",ocirc:"ô",ocir:"⊚",Ocy:"О",ocy:"о",odash:"⊝",Odblac:"Ő",odblac:"ő",odiv:"⨸",odot:"⊙",odsold:"⦼",OElig:"Œ",oelig:"œ",ofcir:"⦿",Ofr:"𝔒",ofr:"𝔬",ogon:"˛",Ograve:"Ò",ograve:"ò",ogt:"⧁",ohbar:"⦵",ohm:"Ω",oint:"∮",olarr:"↺",olcir:"⦾",olcross:"⦻",oline:"‾",olt:"⧀",Omacr:"Ō",omacr:"ō",Omega:"Ω",omega:"ω",Omicron:"Ο",omicron:"ο",omid:"⦶",ominus:"⊖",Oopf:"𝕆",oopf:"𝕠",opar:"⦷",OpenCurlyDoubleQuote:"“",OpenCurlyQuote:"‘",operp:"⦹",oplus:"⊕",orarr:"↻",Or:"⩔",or:"∨",ord:"⩝",order:"ℴ",orderof:"ℴ",ordf:"ª",ordm:"º",origof:"⊶",oror:"⩖",orslope:"⩗",orv:"⩛",oS:"Ⓢ",Oscr:"𝒪",oscr:"ℴ",Oslash:"Ø",oslash:"ø",osol:"⊘",Otilde:"Õ",otilde:"õ",otimesas:"⨶",Otimes:"⨷",otimes:"⊗",Ouml:"Ö",ouml:"ö",ovbar:"⌽",OverBar:"‾",OverBrace:"⏞",OverBracket:"⎴",OverParenthesis:"⏜",para:"¶",parallel:"∥",par:"∥",parsim:"⫳",parsl:"⫽",part:"∂",PartialD:"∂",Pcy:"П",pcy:"п",percnt:"%",period:".",permil:"‰",perp:"⊥",pertenk:"‱",Pfr:"𝔓",pfr:"𝔭",Phi:"Φ",phi:"φ",phiv:"ϕ",phmmat:"ℳ",phone:"☎",Pi:"Π",pi:"π",pitchfork:"⋔",piv:"ϖ",planck:"ℏ",planckh:"ℎ",plankv:"ℏ",plusacir:"⨣",plusb:"⊞",pluscir:"⨢",plus:"+",plusdo:"∔",plusdu:"⨥",pluse:"⩲",PlusMinus:"±",plusmn:"±",plussim:"⨦",plustwo:"⨧",pm:"±",Poincareplane:"ℌ",pointint:"⨕",popf:"𝕡",Popf:"ℙ",pound:"£",prap:"⪷",Pr:"⪻",pr:"≺",prcue:"≼",precapprox:"⪷",prec:"≺",preccurlyeq:"≼",Precedes:"≺",PrecedesEqual:"⪯",PrecedesSlantEqual:"≼",PrecedesTilde:"≾",preceq:"⪯",precnapprox:"⪹",precneqq:"⪵",precnsim:"⋨",pre:"⪯",prE:"⪳",precsim:"≾",prime:"′",Prime:"″",primes:"ℙ",prnap:"⪹",prnE:"⪵",prnsim:"⋨",prod:"∏",Product:"∏",profalar:"⌮",profline:"⌒",profsurf:"⌓",prop:"∝",Proportional:"∝",Proportion:"∷",propto:"∝",prsim:"≾",prurel:"⊰",Pscr:"𝒫",pscr:"𝓅",Psi:"Ψ",psi:"ψ",puncsp:" ",Qfr:"𝔔",qfr:"𝔮",qint:"⨌",qopf:"𝕢",Qopf:"ℚ",qprime:"⁗",Qscr:"𝒬",qscr:"𝓆",quaternions:"ℍ",quatint:"⨖",quest:"?",questeq:"≟",quot:'"',QUOT:'"',rAarr:"⇛",race:"∽̱",Racute:"Ŕ",racute:"ŕ",radic:"√",raemptyv:"⦳",rang:"⟩",Rang:"⟫",rangd:"⦒",range:"⦥",rangle:"⟩",raquo:"»",rarrap:"⥵",rarrb:"⇥",rarrbfs:"⤠",rarrc:"⤳",rarr:"→",Rarr:"↠",rArr:"⇒",rarrfs:"⤞",rarrhk:"↪",rarrlp:"↬",rarrpl:"⥅",rarrsim:"⥴",Rarrtl:"⤖",rarrtl:"↣",rarrw:"↝",ratail:"⤚",rAtail:"⤜",ratio:"∶",rationals:"ℚ",rbarr:"⤍",rBarr:"⤏",RBarr:"⤐",rbbrk:"❳",rbrace:"}",rbrack:"]",rbrke:"⦌",rbrksld:"⦎",rbrkslu:"⦐",Rcaron:"Ř",rcaron:"ř",Rcedil:"Ŗ",rcedil:"ŗ",rceil:"⌉",rcub:"}",Rcy:"Р",rcy:"р",rdca:"⤷",rdldhar:"⥩",rdquo:"”",rdquor:"”",rdsh:"↳",real:"ℜ",realine:"ℛ",realpart:"ℜ",reals:"ℝ",Re:"ℜ",rect:"▭",reg:"®",REG:"®",ReverseElement:"∋",ReverseEquilibrium:"⇋",ReverseUpEquilibrium:"⥯",rfisht:"⥽",rfloor:"⌋",rfr:"𝔯",Rfr:"ℜ",rHar:"⥤",rhard:"⇁",rharu:"⇀",rharul:"⥬",Rho:"Ρ",rho:"ρ",rhov:"ϱ",RightAngleBracket:"⟩",RightArrowBar:"⇥",rightarrow:"→",RightArrow:"→",Rightarrow:"⇒",RightArrowLeftArrow:"⇄",rightarrowtail:"↣",RightCeiling:"⌉",RightDoubleBracket:"⟧",RightDownTeeVector:"⥝",RightDownVectorBar:"⥕",RightDownVector:"⇂",RightFloor:"⌋",rightharpoondown:"⇁",rightharpoonup:"⇀",rightleftarrows:"⇄",rightleftharpoons:"⇌",rightrightarrows:"⇉",rightsquigarrow:"↝",RightTeeArrow:"↦",RightTee:"⊢",RightTeeVector:"⥛",rightthreetimes:"⋌",RightTriangleBar:"⧐",RightTriangle:"⊳",RightTriangleEqual:"⊵",RightUpDownVector:"⥏",RightUpTeeVector:"⥜",RightUpVectorBar:"⥔",RightUpVector:"↾",RightVectorBar:"⥓",RightVector:"⇀",ring:"˚",risingdotseq:"≓",rlarr:"⇄",rlhar:"⇌",rlm:"‏",rmoustache:"⎱",rmoust:"⎱",rnmid:"⫮",roang:"⟭",roarr:"⇾",robrk:"⟧",ropar:"⦆",ropf:"𝕣",Ropf:"ℝ",roplus:"⨮",rotimes:"⨵",RoundImplies:"⥰",rpar:")",rpargt:"⦔",rppolint:"⨒",rrarr:"⇉",Rrightarrow:"⇛",rsaquo:"›",rscr:"𝓇",Rscr:"ℛ",rsh:"↱",Rsh:"↱",rsqb:"]",rsquo:"’",rsquor:"’",rthree:"⋌",rtimes:"⋊",rtri:"▹",rtrie:"⊵",rtrif:"▸",rtriltri:"⧎",RuleDelayed:"⧴",ruluhar:"⥨",rx:"℞",Sacute:"Ś",sacute:"ś",sbquo:"‚",scap:"⪸",Scaron:"Š",scaron:"š",Sc:"⪼",sc:"≻",sccue:"≽",sce:"⪰",scE:"⪴",Scedil:"Ş",scedil:"ş",Scirc:"Ŝ",scirc:"ŝ",scnap:"⪺",scnE:"⪶",scnsim:"⋩",scpolint:"⨓",scsim:"≿",Scy:"С",scy:"с",sdotb:"⊡",sdot:"⋅",sdote:"⩦",searhk:"⤥",searr:"↘",seArr:"⇘",searrow:"↘",sect:"§",semi:";",seswar:"⤩",setminus:"∖",setmn:"∖",sext:"✶",Sfr:"𝔖",sfr:"𝔰",sfrown:"⌢",sharp:"♯",SHCHcy:"Щ",shchcy:"щ",SHcy:"Ш",shcy:"ш",ShortDownArrow:"↓",ShortLeftArrow:"←",shortmid:"∣",shortparallel:"∥",ShortRightArrow:"→",ShortUpArrow:"↑",shy:"­",Sigma:"Σ",sigma:"σ",sigmaf:"ς",sigmav:"ς",sim:"∼",simdot:"⩪",sime:"≃",simeq:"≃",simg:"⪞",simgE:"⪠",siml:"⪝",simlE:"⪟",simne:"≆",simplus:"⨤",simrarr:"⥲",slarr:"←",SmallCircle:"∘",smallsetminus:"∖",smashp:"⨳",smeparsl:"⧤",smid:"∣",smile:"⌣",smt:"⪪",smte:"⪬",smtes:"⪬︀",SOFTcy:"Ь",softcy:"ь",solbar:"⌿",solb:"⧄",sol:"/",Sopf:"𝕊",sopf:"𝕤",spades:"♠",spadesuit:"♠",spar:"∥",sqcap:"⊓",sqcaps:"⊓︀",sqcup:"⊔",sqcups:"⊔︀",Sqrt:"√",sqsub:"⊏",sqsube:"⊑",sqsubset:"⊏",sqsubseteq:"⊑",sqsup:"⊐",sqsupe:"⊒",sqsupset:"⊐",sqsupseteq:"⊒",square:"□",Square:"□",SquareIntersection:"⊓",SquareSubset:"⊏",SquareSubsetEqual:"⊑",SquareSuperset:"⊐",SquareSupersetEqual:"⊒",SquareUnion:"⊔",squarf:"▪",squ:"□",squf:"▪",srarr:"→",Sscr:"𝒮",sscr:"𝓈",ssetmn:"∖",ssmile:"⌣",sstarf:"⋆",Star:"⋆",star:"☆",starf:"★",straightepsilon:"ϵ",straightphi:"ϕ",strns:"¯",sub:"⊂",Sub:"⋐",subdot:"⪽",subE:"⫅",sube:"⊆",subedot:"⫃",submult:"⫁",subnE:"⫋",subne:"⊊",subplus:"⪿",subrarr:"⥹",subset:"⊂",Subset:"⋐",subseteq:"⊆",subseteqq:"⫅",SubsetEqual:"⊆",subsetneq:"⊊",subsetneqq:"⫋",subsim:"⫇",subsub:"⫕",subsup:"⫓",succapprox:"⪸",succ:"≻",succcurlyeq:"≽",Succeeds:"≻",SucceedsEqual:"⪰",SucceedsSlantEqual:"≽",SucceedsTilde:"≿",succeq:"⪰",succnapprox:"⪺",succneqq:"⪶",succnsim:"⋩",succsim:"≿",SuchThat:"∋",sum:"∑",Sum:"∑",sung:"♪",sup1:"¹",sup2:"²",sup3:"³",sup:"⊃",Sup:"⋑",supdot:"⪾",supdsub:"⫘",supE:"⫆",supe:"⊇",supedot:"⫄",Superset:"⊃",SupersetEqual:"⊇",suphsol:"⟉",suphsub:"⫗",suplarr:"⥻",supmult:"⫂",supnE:"⫌",supne:"⊋",supplus:"⫀",supset:"⊃",Supset:"⋑",supseteq:"⊇",supseteqq:"⫆",supsetneq:"⊋",supsetneqq:"⫌",supsim:"⫈",supsub:"⫔",supsup:"⫖",swarhk:"⤦",swarr:"↙",swArr:"⇙",swarrow:"↙",swnwar:"⤪",szlig:"ß",Tab:"\t",target:"⌖",Tau:"Τ",tau:"τ",tbrk:"⎴",Tcaron:"Ť",tcaron:"ť",Tcedil:"Ţ",tcedil:"ţ",Tcy:"Т",tcy:"т",tdot:"⃛",telrec:"⌕",Tfr:"𝔗",tfr:"𝔱",there4:"∴",therefore:"∴",Therefore:"∴",Theta:"Θ",theta:"θ",thetasym:"ϑ",thetav:"ϑ",thickapprox:"≈",thicksim:"∼",ThickSpace:"  ",ThinSpace:" ",thinsp:" ",thkap:"≈",thksim:"∼",THORN:"Þ",thorn:"þ",tilde:"˜",Tilde:"∼",TildeEqual:"≃",TildeFullEqual:"≅",TildeTilde:"≈",timesbar:"⨱",timesb:"⊠",times:"×",timesd:"⨰",tint:"∭",toea:"⤨",topbot:"⌶",topcir:"⫱",top:"⊤",Topf:"𝕋",topf:"𝕥",topfork:"⫚",tosa:"⤩",tprime:"‴",trade:"™",TRADE:"™",triangle:"▵",triangledown:"▿",triangleleft:"◃",trianglelefteq:"⊴",triangleq:"≜",triangleright:"▹",trianglerighteq:"⊵",tridot:"◬",trie:"≜",triminus:"⨺",TripleDot:"⃛",triplus:"⨹",trisb:"⧍",tritime:"⨻",trpezium:"⏢",Tscr:"𝒯",tscr:"𝓉",TScy:"Ц",tscy:"ц",TSHcy:"Ћ",tshcy:"ћ",Tstrok:"Ŧ",tstrok:"ŧ",twixt:"≬",twoheadleftarrow:"↞",twoheadrightarrow:"↠",Uacute:"Ú",uacute:"ú",uarr:"↑",Uarr:"↟",uArr:"⇑",Uarrocir:"⥉",Ubrcy:"Ў",ubrcy:"ў",Ubreve:"Ŭ",ubreve:"ŭ",Ucirc:"Û",ucirc:"û",Ucy:"У",ucy:"у",udarr:"⇅",Udblac:"Ű",udblac:"ű",udhar:"⥮",ufisht:"⥾",Ufr:"𝔘",ufr:"𝔲",Ugrave:"Ù",ugrave:"ù",uHar:"⥣",uharl:"↿",uharr:"↾",uhblk:"▀",ulcorn:"⌜",ulcorner:"⌜",ulcrop:"⌏",ultri:"◸",Umacr:"Ū",umacr:"ū",uml:"¨",UnderBar:"_",UnderBrace:"⏟",UnderBracket:"⎵",UnderParenthesis:"⏝",Union:"⋃",UnionPlus:"⊎",Uogon:"Ų",uogon:"ų",Uopf:"𝕌",uopf:"𝕦",UpArrowBar:"⤒",uparrow:"↑",UpArrow:"↑",Uparrow:"⇑",UpArrowDownArrow:"⇅",updownarrow:"↕",UpDownArrow:"↕",Updownarrow:"⇕",UpEquilibrium:"⥮",upharpoonleft:"↿",upharpoonright:"↾",uplus:"⊎",UpperLeftArrow:"↖",UpperRightArrow:"↗",upsi:"υ",Upsi:"ϒ",upsih:"ϒ",Upsilon:"Υ",upsilon:"υ",UpTeeArrow:"↥",UpTee:"⊥",upuparrows:"⇈",urcorn:"⌝",urcorner:"⌝",urcrop:"⌎",Uring:"Ů",uring:"ů",urtri:"◹",Uscr:"𝒰",uscr:"𝓊",utdot:"⋰",Utilde:"Ũ",utilde:"ũ",utri:"▵",utrif:"▴",uuarr:"⇈",Uuml:"Ü",uuml:"ü",uwangle:"⦧",vangrt:"⦜",varepsilon:"ϵ",varkappa:"ϰ",varnothing:"∅",varphi:"ϕ",varpi:"ϖ",varpropto:"∝",varr:"↕",vArr:"⇕",varrho:"ϱ",varsigma:"ς",varsubsetneq:"⊊︀",varsubsetneqq:"⫋︀",varsupsetneq:"⊋︀",varsupsetneqq:"⫌︀",vartheta:"ϑ",vartriangleleft:"⊲",vartriangleright:"⊳",vBar:"⫨",Vbar:"⫫",vBarv:"⫩",Vcy:"В",vcy:"в",vdash:"⊢",vDash:"⊨",Vdash:"⊩",VDash:"⊫",Vdashl:"⫦",veebar:"⊻",vee:"∨",Vee:"⋁",veeeq:"≚",vellip:"⋮",verbar:"|",Verbar:"‖",vert:"|",Vert:"‖",VerticalBar:"∣",VerticalLine:"|",VerticalSeparator:"❘",VerticalTilde:"≀",VeryThinSpace:" ",Vfr:"𝔙",vfr:"𝔳",vltri:"⊲",vnsub:"⊂⃒",vnsup:"⊃⃒",Vopf:"𝕍",vopf:"𝕧",vprop:"∝",vrtri:"⊳",Vscr:"𝒱",vscr:"𝓋",vsubnE:"⫋︀",vsubne:"⊊︀",vsupnE:"⫌︀",vsupne:"⊋︀",Vvdash:"⊪",vzigzag:"⦚",Wcirc:"Ŵ",wcirc:"ŵ",wedbar:"⩟",wedge:"∧",Wedge:"⋀",wedgeq:"≙",weierp:"℘",Wfr:"𝔚",wfr:"𝔴",Wopf:"𝕎",wopf:"𝕨",wp:"℘",wr:"≀",wreath:"≀",Wscr:"𝒲",wscr:"𝓌",xcap:"⋂",xcirc:"◯",xcup:"⋃",xdtri:"▽",Xfr:"𝔛",xfr:"𝔵",xharr:"⟷",xhArr:"⟺",Xi:"Ξ",xi:"ξ",xlarr:"⟵",xlArr:"⟸",xmap:"⟼",xnis:"⋻",xodot:"⨀",Xopf:"𝕏",xopf:"𝕩",xoplus:"⨁",xotime:"⨂",xrarr:"⟶",xrArr:"⟹",Xscr:"𝒳",xscr:"𝓍",xsqcup:"⨆",xuplus:"⨄",xutri:"△",xvee:"⋁",xwedge:"⋀",Yacute:"Ý",yacute:"ý",YAcy:"Я",yacy:"я",Ycirc:"Ŷ",ycirc:"ŷ",Ycy:"Ы",ycy:"ы",yen:"¥",Yfr:"𝔜",yfr:"𝔶",YIcy:"Ї",yicy:"ї",Yopf:"𝕐",yopf:"𝕪",Yscr:"𝒴",yscr:"𝓎",YUcy:"Ю",yucy:"ю",yuml:"ÿ",Yuml:"Ÿ",Zacute:"Ź",zacute:"ź",Zcaron:"Ž",zcaron:"ž",Zcy:"З",zcy:"з",Zdot:"Ż",zdot:"ż",zeetrf:"ℨ",ZeroWidthSpace:"​",Zeta:"Ζ",zeta:"ζ",zfr:"𝔷",Zfr:"ℨ",ZHcy:"Ж",zhcy:"ж",zigrarr:"⇝",zopf:"𝕫",Zopf:"ℤ",Zscr:"𝒵",zscr:"𝓏",zwj:"‍",zwnj:"‌"}},{}],26:[function(require,module,exports){module.exports={Aacute:"Á",aacute:"á",Acirc:"Â",acirc:"â",acute:"´",AElig:"Æ",aelig:"æ",Agrave:"À",agrave:"à",amp:"&",AMP:"&",Aring:"Å",aring:"å",Atilde:"Ã",atilde:"ã",Auml:"Ä",auml:"ä",brvbar:"¦",Ccedil:"Ç",ccedil:"ç",cedil:"¸",cent:"¢",copy:"©",COPY:"©",curren:"¤",deg:"°",divide:"÷",Eacute:"É",eacute:"é",Ecirc:"Ê",ecirc:"ê",Egrave:"È",egrave:"è",ETH:"Ð",eth:"ð",Euml:"Ë",euml:"ë",frac12:"½",frac14:"¼",frac34:"¾",gt:">",GT:">",Iacute:"Í",iacute:"í",Icirc:"Î",icirc:"î",iexcl:"¡",Igrave:"Ì",igrave:"ì",iquest:"¿",Iuml:"Ï",iuml:"ï",laquo:"«",lt:"<",LT:"<",macr:"¯",micro:"µ",middot:"·",nbsp:" ",not:"¬",Ntilde:"Ñ",ntilde:"ñ",Oacute:"Ó",oacute:"ó",Ocirc:"Ô",ocirc:"ô",Ograve:"Ò",ograve:"ò",ordf:"ª",ordm:"º",Oslash:"Ø",oslash:"ø",Otilde:"Õ",otilde:"õ",Ouml:"Ö",ouml:"ö",para:"¶",plusmn:"±",pound:"£",quot:'"',QUOT:'"',raquo:"»",reg:"®",REG:"®",sect:"§",shy:"­",sup1:"¹",sup2:"²",sup3:"³",szlig:"ß",THORN:"Þ",thorn:"þ",times:"×",Uacute:"Ú",uacute:"ú",Ucirc:"Û",ucirc:"û",Ugrave:"Ù",ugrave:"ù",uml:"¨",Uuml:"Ü",uuml:"ü",Yacute:"Ý",yacute:"ý",yen:"¥",yuml:"ÿ"}},{}],27:[function(require,module,exports){module.exports={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'}},{}],28:[function(require,module,exports){function EventEmitter(){this._events=this._events||{};this._maxListeners=this._maxListeners||undefined}module.exports=EventEmitter;EventEmitter.EventEmitter=EventEmitter;EventEmitter.prototype._events=undefined;EventEmitter.prototype._maxListeners=undefined;EventEmitter.defaultMaxListeners=10;EventEmitter.prototype.setMaxListeners=function(n){if(!isNumber(n)||n<0||isNaN(n))throw TypeError("n must be a positive number");this._maxListeners=n;return this};EventEmitter.prototype.emit=function(type){var er,handler,len,args,i,listeners;if(!this._events)this._events={};if(type==="error"){if(!this._events.error||isObject(this._events.error)&&!this._events.error.length){er=arguments[1];if(er instanceof Error){throw er}else{var err=new Error('Uncaught, unspecified "error" event. ('+er+")");err.context=er;throw err}}}handler=this._events[type];if(isUndefined(handler))return false;if(isFunction(handler)){switch(arguments.length){case 1:handler.call(this);break;case 2:handler.call(this,arguments[1]);break;case 3:handler.call(this,arguments[1],arguments[2]);break;default:args=Array.prototype.slice.call(arguments,1);handler.apply(this,args)}}else if(isObject(handler)){args=Array.prototype.slice.call(arguments,1);listeners=handler.slice();len=listeners.length;for(i=0;i0&&this._events[type].length>m){this._events[type].warned=true;console.error("(node) warning: possible EventEmitter memory "+"leak detected. %d listeners added. "+"Use emitter.setMaxListeners() to increase limit.",this._events[type].length);if(typeof console.trace==="function"){console.trace()}}}return this};EventEmitter.prototype.on=EventEmitter.prototype.addListener;EventEmitter.prototype.once=function(type,listener){if(!isFunction(listener))throw TypeError("listener must be a function");var fired=false;function g(){this.removeListener(type,g);if(!fired){fired=true;listener.apply(this,arguments)}}g.listener=listener;this.on(type,g);return this};EventEmitter.prototype.removeListener=function(type,listener){var list,position,length,i;if(!isFunction(listener))throw TypeError("listener must be a function");if(!this._events||!this._events[type])return this;list=this._events[type];length=list.length;position=-1;if(list===listener||isFunction(list.listener)&&list.listener===listener){delete this._events[type];if(this._events.removeListener)this.emit("removeListener",type,listener)}else if(isObject(list)){for(i=length;i-- >0;){if(list[i]===listener||list[i].listener&&list[i].listener===listener){position=i;break}}if(position<0)return this;if(list.length===1){list.length=0;delete this._events[type]}else{list.splice(position,1); +}if(this._events.removeListener)this.emit("removeListener",type,listener)}return this};EventEmitter.prototype.removeAllListeners=function(type){var key,listeners;if(!this._events)return this;if(!this._events.removeListener){if(arguments.length===0)this._events={};else if(this._events[type])delete this._events[type];return this}if(arguments.length===0){for(key in this._events){if(key==="removeListener")continue;this.removeAllListeners(key)}this.removeAllListeners("removeListener");this._events={};return this}listeners=this._events[type];if(isFunction(listeners)){this.removeListener(type,listeners)}else if(listeners){while(listeners.length)this.removeListener(type,listeners[listeners.length-1])}delete this._events[type];return this};EventEmitter.prototype.listeners=function(type){var ret;if(!this._events||!this._events[type])ret=[];else if(isFunction(this._events[type]))ret=[this._events[type]];else ret=this._events[type].slice();return ret};EventEmitter.prototype.listenerCount=function(type){if(this._events){var evlistener=this._events[type];if(isFunction(evlistener))return 1;else if(evlistener)return evlistener.length}return 0};EventEmitter.listenerCount=function(emitter,type){return emitter.listenerCount(type)};function isFunction(arg){return typeof arg==="function"}function isNumber(arg){return typeof arg==="number"}function isObject(arg){return typeof arg==="object"&&arg!==null}function isUndefined(arg){return arg===void 0}},{}],29:[function(require,module,exports){module.exports=CollectingHandler;function CollectingHandler(cbs){this._cbs=cbs||{};this.events=[]}var EVENTS=require("./").EVENTS;Object.keys(EVENTS).forEach(function(name){if(EVENTS[name]===0){name="on"+name;CollectingHandler.prototype[name]=function(){this.events.push([name]);if(this._cbs[name])this._cbs[name]()}}else if(EVENTS[name]===1){name="on"+name;CollectingHandler.prototype[name]=function(a){this.events.push([name,a]);if(this._cbs[name])this._cbs[name](a)}}else if(EVENTS[name]===2){name="on"+name;CollectingHandler.prototype[name]=function(a,b){this.events.push([name,a,b]);if(this._cbs[name])this._cbs[name](a,b)}}else{throw Error("wrong number of arguments")}});CollectingHandler.prototype.onreset=function(){this.events=[];if(this._cbs.onreset)this._cbs.onreset()};CollectingHandler.prototype.restart=function(){if(this._cbs.onreset)this._cbs.onreset();for(var i=0,len=this.events.length;i0;this._cbs.onclosetag(this._stack[--i]));}if(this._cbs.onend)this._cbs.onend()};Parser.prototype.reset=function(){if(this._cbs.onreset)this._cbs.onreset();this._tokenizer.reset();this._tagname="";this._attribname="";this._attribs=null;this._stack=[];if(this._cbs.onparserinit)this._cbs.onparserinit(this)};Parser.prototype.parseComplete=function(data){this.reset();this.end(data)};Parser.prototype.write=function(chunk){this._tokenizer.write(chunk)};Parser.prototype.end=function(chunk){this._tokenizer.end(chunk)};Parser.prototype.pause=function(){this._tokenizer.pause()};Parser.prototype.resume=function(){this._tokenizer.resume()};Parser.prototype.parseChunk=Parser.prototype.write;Parser.prototype.done=Parser.prototype.end;module.exports=Parser},{"./Tokenizer.js":34,events:28,inherits:38}],32:[function(require,module,exports){module.exports=ProxyHandler;function ProxyHandler(cbs){this._cbs=cbs||{}}var EVENTS=require("./").EVENTS;Object.keys(EVENTS).forEach(function(name){if(EVENTS[name]===0){name="on"+name;ProxyHandler.prototype[name]=function(){if(this._cbs[name])this._cbs[name]()}}else if(EVENTS[name]===1){name="on"+name;ProxyHandler.prototype[name]=function(a){if(this._cbs[name])this._cbs[name](a)}}else if(EVENTS[name]===2){name="on"+name;ProxyHandler.prototype[name]=function(a,b){if(this._cbs[name])this._cbs[name](a,b)}}else{throw Error("wrong number of arguments")}})},{"./":36}],33:[function(require,module,exports){module.exports=Stream;var Parser=require("./WritableStream.js");function Stream(options){Parser.call(this,new Cbs(this),options)}require("inherits")(Stream,Parser);Stream.prototype.readable=true;function Cbs(scope){this.scope=scope}var EVENTS=require("../").EVENTS;Object.keys(EVENTS).forEach(function(name){if(EVENTS[name]===0){Cbs.prototype["on"+name]=function(){this.scope.emit(name)}}else if(EVENTS[name]===1){Cbs.prototype["on"+name]=function(a){this.scope.emit(name,a)}}else if(EVENTS[name]===2){Cbs.prototype["on"+name]=function(a,b){this.scope.emit(name,a,b)}}else{throw Error("wrong number of arguments!")}})},{"../":36,"./WritableStream.js":35,inherits:38}],34:[function(require,module,exports){module.exports=Tokenizer;var decodeCodePoint=require("entities/lib/decode_codepoint.js"),entityMap=require("entities/maps/entities.json"),legacyMap=require("entities/maps/legacy.json"),xmlMap=require("entities/maps/xml.json"),i=0,TEXT=i++,BEFORE_TAG_NAME=i++,IN_TAG_NAME=i++,IN_SELF_CLOSING_TAG=i++,BEFORE_CLOSING_TAG_NAME=i++,IN_CLOSING_TAG_NAME=i++,AFTER_CLOSING_TAG_NAME=i++,BEFORE_ATTRIBUTE_NAME=i++,IN_ATTRIBUTE_NAME=i++,AFTER_ATTRIBUTE_NAME=i++,BEFORE_ATTRIBUTE_VALUE=i++,IN_ATTRIBUTE_VALUE_DQ=i++,IN_ATTRIBUTE_VALUE_SQ=i++,IN_ATTRIBUTE_VALUE_NQ=i++,BEFORE_DECLARATION=i++,IN_DECLARATION=i++,IN_PROCESSING_INSTRUCTION=i++,BEFORE_COMMENT=i++,IN_COMMENT=i++,AFTER_COMMENT_1=i++,AFTER_COMMENT_2=i++,BEFORE_CDATA_1=i++,BEFORE_CDATA_2=i++,BEFORE_CDATA_3=i++,BEFORE_CDATA_4=i++,BEFORE_CDATA_5=i++,BEFORE_CDATA_6=i++,IN_CDATA=i++,AFTER_CDATA_1=i++,AFTER_CDATA_2=i++,BEFORE_SPECIAL=i++,BEFORE_SPECIAL_END=i++,BEFORE_SCRIPT_1=i++,BEFORE_SCRIPT_2=i++,BEFORE_SCRIPT_3=i++,BEFORE_SCRIPT_4=i++,BEFORE_SCRIPT_5=i++,AFTER_SCRIPT_1=i++,AFTER_SCRIPT_2=i++,AFTER_SCRIPT_3=i++,AFTER_SCRIPT_4=i++,AFTER_SCRIPT_5=i++,BEFORE_STYLE_1=i++,BEFORE_STYLE_2=i++,BEFORE_STYLE_3=i++,BEFORE_STYLE_4=i++,AFTER_STYLE_1=i++,AFTER_STYLE_2=i++,AFTER_STYLE_3=i++,AFTER_STYLE_4=i++,BEFORE_ENTITY=i++,BEFORE_NUMERIC_ENTITY=i++,IN_NAMED_ENTITY=i++,IN_NUMERIC_ENTITY=i++,IN_HEX_ENTITY=i++,j=0,SPECIAL_NONE=j++,SPECIAL_SCRIPT=j++,SPECIAL_STYLE=j++;function whitespace(c){return c===" "||c==="\n"||c==="\t"||c==="\f"||c==="\r"}function characterState(char,SUCCESS){return function(c){if(c===char)this._state=SUCCESS}}function ifElseState(upper,SUCCESS,FAILURE){var lower=upper.toLowerCase();if(upper===lower){return function(c){if(c===lower){this._state=SUCCESS}else{this._state=FAILURE;this._index--}}}else{return function(c){if(c===lower||c===upper){this._state=SUCCESS}else{this._state=FAILURE;this._index--}}}}function consumeSpecialNameChar(upper,NEXT_STATE){var lower=upper.toLowerCase();return function(c){if(c===lower||c===upper){this._state=NEXT_STATE}else{this._state=IN_TAG_NAME;this._index--}}}function Tokenizer(options,cbs){this._state=TEXT;this._buffer="";this._sectionStart=0;this._index=0;this._bufferOffset=0;this._baseState=TEXT;this._special=SPECIAL_NONE;this._cbs=cbs;this._running=true;this._ended=false;this._xmlMode=!!(options&&options.xmlMode);this._decodeEntities=!!(options&&options.decodeEntities)}Tokenizer.prototype._stateText=function(c){if(c==="<"){if(this._index>this._sectionStart){this._cbs.ontext(this._getSection())}this._state=BEFORE_TAG_NAME;this._sectionStart=this._index}else if(this._decodeEntities&&this._special===SPECIAL_NONE&&c==="&"){if(this._index>this._sectionStart){this._cbs.ontext(this._getSection())}this._baseState=TEXT;this._state=BEFORE_ENTITY;this._sectionStart=this._index}};Tokenizer.prototype._stateBeforeTagName=function(c){if(c==="/"){this._state=BEFORE_CLOSING_TAG_NAME}else if(c==="<"){this._cbs.ontext(this._getSection());this._sectionStart=this._index}else if(c===">"||this._special!==SPECIAL_NONE||whitespace(c)){this._state=TEXT}else if(c==="!"){this._state=BEFORE_DECLARATION;this._sectionStart=this._index+1}else if(c==="?"){this._state=IN_PROCESSING_INSTRUCTION;this._sectionStart=this._index+1}else{this._state=!this._xmlMode&&(c==="s"||c==="S")?BEFORE_SPECIAL:IN_TAG_NAME;this._sectionStart=this._index}};Tokenizer.prototype._stateInTagName=function(c){if(c==="/"||c===">"||whitespace(c)){this._emitToken("onopentagname");this._state=BEFORE_ATTRIBUTE_NAME;this._index--}};Tokenizer.prototype._stateBeforeCloseingTagName=function(c){if(whitespace(c));else if(c===">"){this._state=TEXT}else if(this._special!==SPECIAL_NONE){if(c==="s"||c==="S"){this._state=BEFORE_SPECIAL_END}else{this._state=TEXT;this._index--}}else{this._state=IN_CLOSING_TAG_NAME;this._sectionStart=this._index}};Tokenizer.prototype._stateInCloseingTagName=function(c){if(c===">"||whitespace(c)){this._emitToken("onclosetag");this._state=AFTER_CLOSING_TAG_NAME;this._index--}};Tokenizer.prototype._stateAfterCloseingTagName=function(c){if(c===">"){this._state=TEXT;this._sectionStart=this._index+1}};Tokenizer.prototype._stateBeforeAttributeName=function(c){if(c===">"){this._cbs.onopentagend();this._state=TEXT;this._sectionStart=this._index+1}else if(c==="/"){this._state=IN_SELF_CLOSING_TAG}else if(!whitespace(c)){this._state=IN_ATTRIBUTE_NAME;this._sectionStart=this._index}};Tokenizer.prototype._stateInSelfClosingTag=function(c){if(c===">"){this._cbs.onselfclosingtag();this._state=TEXT;this._sectionStart=this._index+1}else if(!whitespace(c)){this._state=BEFORE_ATTRIBUTE_NAME;this._index--}};Tokenizer.prototype._stateInAttributeName=function(c){if(c==="="||c==="/"||c===">"||whitespace(c)){this._cbs.onattribname(this._getSection());this._sectionStart=-1;this._state=AFTER_ATTRIBUTE_NAME;this._index--}};Tokenizer.prototype._stateAfterAttributeName=function(c){if(c==="="){this._state=BEFORE_ATTRIBUTE_VALUE}else if(c==="/"||c===">"){this._cbs.onattribend();this._state=BEFORE_ATTRIBUTE_NAME;this._index--}else if(!whitespace(c)){this._cbs.onattribend();this._state=IN_ATTRIBUTE_NAME;this._sectionStart=this._index}};Tokenizer.prototype._stateBeforeAttributeValue=function(c){if(c==='"'){this._state=IN_ATTRIBUTE_VALUE_DQ;this._sectionStart=this._index+1}else if(c==="'"){this._state=IN_ATTRIBUTE_VALUE_SQ;this._sectionStart=this._index+1}else if(!whitespace(c)){this._state=IN_ATTRIBUTE_VALUE_NQ;this._sectionStart=this._index;this._index--}};Tokenizer.prototype._stateInAttributeValueDoubleQuotes=function(c){if(c==='"'){this._emitToken("onattribdata");this._cbs.onattribend();this._state=BEFORE_ATTRIBUTE_NAME}else if(this._decodeEntities&&c==="&"){this._emitToken("onattribdata");this._baseState=this._state;this._state=BEFORE_ENTITY;this._sectionStart=this._index}};Tokenizer.prototype._stateInAttributeValueSingleQuotes=function(c){if(c==="'"){this._emitToken("onattribdata");this._cbs.onattribend();this._state=BEFORE_ATTRIBUTE_NAME}else if(this._decodeEntities&&c==="&"){this._emitToken("onattribdata");this._baseState=this._state;this._state=BEFORE_ENTITY;this._sectionStart=this._index}};Tokenizer.prototype._stateInAttributeValueNoQuotes=function(c){if(whitespace(c)||c===">"){this._emitToken("onattribdata");this._cbs.onattribend();this._state=BEFORE_ATTRIBUTE_NAME;this._index--}else if(this._decodeEntities&&c==="&"){this._emitToken("onattribdata");this._baseState=this._state;this._state=BEFORE_ENTITY;this._sectionStart=this._index}};Tokenizer.prototype._stateBeforeDeclaration=function(c){this._state=c==="["?BEFORE_CDATA_1:c==="-"?BEFORE_COMMENT:IN_DECLARATION};Tokenizer.prototype._stateInDeclaration=function(c){if(c===">"){this._cbs.ondeclaration(this._getSection());this._state=TEXT;this._sectionStart=this._index+1}};Tokenizer.prototype._stateInProcessingInstruction=function(c){if(c===">"){this._cbs.onprocessinginstruction(this._getSection());this._state=TEXT;this._sectionStart=this._index+1}};Tokenizer.prototype._stateBeforeComment=function(c){if(c==="-"){this._state=IN_COMMENT;this._sectionStart=this._index+1}else{this._state=IN_DECLARATION}};Tokenizer.prototype._stateInComment=function(c){if(c==="-")this._state=AFTER_COMMENT_1};Tokenizer.prototype._stateAfterComment1=function(c){if(c==="-"){this._state=AFTER_COMMENT_2}else{this._state=IN_COMMENT}};Tokenizer.prototype._stateAfterComment2=function(c){if(c===">"){this._cbs.oncomment(this._buffer.substring(this._sectionStart,this._index-2));this._state=TEXT;this._sectionStart=this._index+1}else if(c!=="-"){this._state=IN_COMMENT}};Tokenizer.prototype._stateBeforeCdata1=ifElseState("C",BEFORE_CDATA_2,IN_DECLARATION);Tokenizer.prototype._stateBeforeCdata2=ifElseState("D",BEFORE_CDATA_3,IN_DECLARATION);Tokenizer.prototype._stateBeforeCdata3=ifElseState("A",BEFORE_CDATA_4,IN_DECLARATION);Tokenizer.prototype._stateBeforeCdata4=ifElseState("T",BEFORE_CDATA_5,IN_DECLARATION);Tokenizer.prototype._stateBeforeCdata5=ifElseState("A",BEFORE_CDATA_6,IN_DECLARATION);Tokenizer.prototype._stateBeforeCdata6=function(c){if(c==="["){this._state=IN_CDATA;this._sectionStart=this._index+1}else{this._state=IN_DECLARATION;this._index--}};Tokenizer.prototype._stateInCdata=function(c){if(c==="]")this._state=AFTER_CDATA_1};Tokenizer.prototype._stateAfterCdata1=characterState("]",AFTER_CDATA_2);Tokenizer.prototype._stateAfterCdata2=function(c){if(c===">"){this._cbs.oncdata(this._buffer.substring(this._sectionStart,this._index-2));this._state=TEXT;this._sectionStart=this._index+1}else if(c!=="]"){this._state=IN_CDATA}};Tokenizer.prototype._stateBeforeSpecial=function(c){if(c==="c"||c==="C"){this._state=BEFORE_SCRIPT_1}else if(c==="t"||c==="T"){this._state=BEFORE_STYLE_1}else{this._state=IN_TAG_NAME;this._index--}};Tokenizer.prototype._stateBeforeSpecialEnd=function(c){if(this._special===SPECIAL_SCRIPT&&(c==="c"||c==="C")){this._state=AFTER_SCRIPT_1}else if(this._special===SPECIAL_STYLE&&(c==="t"||c==="T")){this._state=AFTER_STYLE_1}else this._state=TEXT};Tokenizer.prototype._stateBeforeScript1=consumeSpecialNameChar("R",BEFORE_SCRIPT_2);Tokenizer.prototype._stateBeforeScript2=consumeSpecialNameChar("I",BEFORE_SCRIPT_3);Tokenizer.prototype._stateBeforeScript3=consumeSpecialNameChar("P",BEFORE_SCRIPT_4);Tokenizer.prototype._stateBeforeScript4=consumeSpecialNameChar("T",BEFORE_SCRIPT_5);Tokenizer.prototype._stateBeforeScript5=function(c){if(c==="/"||c===">"||whitespace(c)){this._special=SPECIAL_SCRIPT}this._state=IN_TAG_NAME;this._index--};Tokenizer.prototype._stateAfterScript1=ifElseState("R",AFTER_SCRIPT_2,TEXT);Tokenizer.prototype._stateAfterScript2=ifElseState("I",AFTER_SCRIPT_3,TEXT);Tokenizer.prototype._stateAfterScript3=ifElseState("P",AFTER_SCRIPT_4,TEXT);Tokenizer.prototype._stateAfterScript4=ifElseState("T",AFTER_SCRIPT_5,TEXT);Tokenizer.prototype._stateAfterScript5=function(c){if(c===">"||whitespace(c)){this._special=SPECIAL_NONE;this._state=IN_CLOSING_TAG_NAME;this._sectionStart=this._index-6;this._index--}else this._state=TEXT};Tokenizer.prototype._stateBeforeStyle1=consumeSpecialNameChar("Y",BEFORE_STYLE_2);Tokenizer.prototype._stateBeforeStyle2=consumeSpecialNameChar("L",BEFORE_STYLE_3);Tokenizer.prototype._stateBeforeStyle3=consumeSpecialNameChar("E",BEFORE_STYLE_4);Tokenizer.prototype._stateBeforeStyle4=function(c){if(c==="/"||c===">"||whitespace(c)){this._special=SPECIAL_STYLE}this._state=IN_TAG_NAME;this._index--};Tokenizer.prototype._stateAfterStyle1=ifElseState("Y",AFTER_STYLE_2,TEXT);Tokenizer.prototype._stateAfterStyle2=ifElseState("L",AFTER_STYLE_3,TEXT);Tokenizer.prototype._stateAfterStyle3=ifElseState("E",AFTER_STYLE_4,TEXT);Tokenizer.prototype._stateAfterStyle4=function(c){if(c===">"||whitespace(c)){this._special=SPECIAL_NONE;this._state=IN_CLOSING_TAG_NAME;this._sectionStart=this._index-5;this._index--}else this._state=TEXT};Tokenizer.prototype._stateBeforeEntity=ifElseState("#",BEFORE_NUMERIC_ENTITY,IN_NAMED_ENTITY);Tokenizer.prototype._stateBeforeNumericEntity=ifElseState("X",IN_HEX_ENTITY,IN_NUMERIC_ENTITY);Tokenizer.prototype._parseNamedEntityStrict=function(){if(this._sectionStart+16)limit=6;while(limit>=2){var entity=this._buffer.substr(start,limit);if(legacyMap.hasOwnProperty(entity)){this._emitPartial(legacyMap[entity]);this._sectionStart+=limit+1;return}else{limit--}}};Tokenizer.prototype._stateInNamedEntity=function(c){if(c===";"){this._parseNamedEntityStrict();if(this._sectionStart+1"z")&&(c<"A"||c>"Z")&&(c<"0"||c>"9")){if(this._xmlMode);else if(this._sectionStart+1===this._index);else if(this._baseState!==TEXT){if(c!=="="){this._parseNamedEntityStrict()}}else{this._parseLegacyEntity()}this._state=this._baseState;this._index--}};Tokenizer.prototype._decodeNumericEntity=function(offset,base){var sectionStart=this._sectionStart+offset;if(sectionStart!==this._index){var entity=this._buffer.substring(sectionStart,this._index);var parsed=parseInt(entity,base);this._emitPartial(decodeCodePoint(parsed));this._sectionStart=this._index}else{this._sectionStart--}this._state=this._baseState};Tokenizer.prototype._stateInNumericEntity=function(c){if(c===";"){this._decodeNumericEntity(2,10);this._sectionStart++}else if(c<"0"||c>"9"){if(!this._xmlMode){this._decodeNumericEntity(2,10)}else{this._state=this._baseState}this._index--}};Tokenizer.prototype._stateInHexEntity=function(c){if(c===";"){this._decodeNumericEntity(3,16);this._sectionStart++}else if((c<"a"||c>"f")&&(c<"A"||c>"F")&&(c<"0"||c>"9")){if(!this._xmlMode){this._decodeNumericEntity(3,16)}else{this._state=this._baseState}this._index--}};Tokenizer.prototype._cleanup=function(){if(this._sectionStart<0){this._buffer="";this._index=0;this._bufferOffset+=this._index}else if(this._running){if(this._state===TEXT){if(this._sectionStart!==this._index){this._cbs.ontext(this._buffer.substr(this._sectionStart))}this._buffer="";this._bufferOffset+=this._index;this._index=0}else if(this._sectionStart===this._index){this._buffer="";this._bufferOffset+=this._index;this._index=0}else{this._buffer=this._buffer.substr(this._sectionStart);this._index-=this._sectionStart;this._bufferOffset+=this._sectionStart}this._sectionStart=0}};Tokenizer.prototype.write=function(chunk){if(this._ended)this._cbs.onerror(Error(".write() after done!"));this._buffer+=chunk;this._parse()};Tokenizer.prototype._parse=function(){while(this._index>1;var nBits=-7;var i=isLE?nBytes-1:0;var d=isLE?-1:1;var s=buffer[offset+i];i+=d;e=s&(1<<-nBits)-1;s>>=-nBits;nBits+=eLen;for(;nBits>0;e=e*256+buffer[offset+i],i+=d,nBits-=8){}m=e&(1<<-nBits)-1;e>>=-nBits;nBits+=mLen;for(;nBits>0;m=m*256+buffer[offset+i],i+=d,nBits-=8){}if(e===0){e=1-eBias}else if(e===eMax){return m?NaN:(s?-1:1)*Infinity}else{m=m+Math.pow(2,mLen);e=e-eBias}return(s?-1:1)*m*Math.pow(2,e-mLen)};exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c;var eLen=nBytes*8-mLen-1;var eMax=(1<>1;var rt=mLen===23?Math.pow(2,-24)-Math.pow(2,-77):0;var i=isLE?0:nBytes-1;var d=isLE?1:-1;var s=value<0||value===0&&1/value<0?1:0;value=Math.abs(value);if(isNaN(value)||value===Infinity){m=isNaN(value)?1:0;e=eMax}else{e=Math.floor(Math.log(value)/Math.LN2);if(value*(c=Math.pow(2,-e))<1){e--;c*=2}if(e+eBias>=1){value+=rt/c}else{value+=rt*Math.pow(2,1-eBias)}if(value*c>=2){e++;c/=2}if(e+eBias>=eMax){m=0;e=eMax}else if(e+eBias>=1){m=(value*c-1)*Math.pow(2,mLen);e=e+eBias}else{m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen);e=0}}for(;mLen>=8;buffer[offset+i]=m&255,i+=d,m/=256,mLen-=8){}e=e<0;buffer[offset+i]=e&255,i+=d,e/=256,eLen-=8){}buffer[offset+i-d]|=s*128}},{}],38:[function(require,module,exports){if(typeof Object.create==="function"){module.exports=function inherits(ctor,superCtor){ctor.super_=superCtor;ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:false,writable:true,configurable:true}})}}else{module.exports=function inherits(ctor,superCtor){ctor.super_=superCtor;var TempCtor=function(){};TempCtor.prototype=superCtor.prototype;ctor.prototype=new TempCtor;ctor.prototype.constructor=ctor}}},{}],39:[function(require,module,exports){module.exports=function(obj){return obj!=null&&(isBuffer(obj)||isSlowBuffer(obj)||!!obj._isBuffer)};function isBuffer(obj){return!!obj.constructor&&typeof obj.constructor.isBuffer==="function"&&obj.constructor.isBuffer(obj)}function isSlowBuffer(obj){return typeof obj.readFloatLE==="function"&&typeof obj.slice==="function"&&isBuffer(obj.slice(0,0))}},{}],40:[function(require,module,exports){var toString={}.toString;module.exports=Array.isArray||function(arr){return toString.call(arr)=="[object Array]"}},{}],41:[function(require,module,exports){(function(process){"use strict";if(!process.version||process.version.indexOf("v0.")===0||process.version.indexOf("v1.")===0&&process.version.indexOf("v1.8.")!==0){module.exports=nextTick}else{module.exports=process.nextTick}function nextTick(fn,arg1,arg2,arg3){if(typeof fn!=="function"){throw new TypeError('"callback" argument must be a function')}var len=arguments.length;var args,i;switch(len){case 0:case 1:return process.nextTick(fn);case 2:return process.nextTick(function afterTickOne(){fn.call(null,arg1)});case 3:return process.nextTick(function afterTickTwo(){fn.call(null,arg1,arg2)});case 4:return process.nextTick(function afterTickThree(){fn.call(null,arg1,arg2,arg3)});default:args=new Array(len-1);i=0;while(i1){for(var i=1;i0){if(state.ended&&!addToFront){var e=new Error("stream.push() after EOF");stream.emit("error",e)}else if(state.endEmitted&&addToFront){var _e=new Error("stream.unshift() after end event");stream.emit("error",_e)}else{var skipAdd;if(state.decoder&&!addToFront&&!encoding){chunk=state.decoder.write(chunk);skipAdd=!state.objectMode&&chunk.length===0}if(!addToFront)state.reading=false;if(!skipAdd){if(state.flowing&&state.length===0&&!state.sync){stream.emit("data",chunk);stream.read(0)}else{state.length+=state.objectMode?1:chunk.length;if(addToFront)state.buffer.unshift(chunk);else state.buffer.push(chunk);if(state.needReadable)emitReadable(stream)}}maybeReadMore(stream,state)}}else if(!addToFront){state.reading=false}return needMoreData(state)}function needMoreData(state){return!state.ended&&(state.needReadable||state.length=MAX_HWM){n=MAX_HWM}else{n--;n|=n>>>1;n|=n>>>2;n|=n>>>4;n|=n>>>8;n|=n>>>16;n++}return n}function howMuchToRead(n,state){if(n<=0||state.length===0&&state.ended)return 0;if(state.objectMode)return 1;if(n!==n){if(state.flowing&&state.length)return state.buffer.head.data.length;else return state.length}if(n>state.highWaterMark)state.highWaterMark=computeNewHighWaterMark(n);if(n<=state.length)return n;if(!state.ended){state.needReadable=true;return 0}return state.length}Readable.prototype.read=function(n){debug("read",n);n=parseInt(n,10);var state=this._readableState;var nOrig=n;if(n!==0)state.emittedReadable=false;if(n===0&&state.needReadable&&(state.length>=state.highWaterMark||state.ended)){debug("read: emitReadable",state.length,state.ended);if(state.length===0&&state.ended)endReadable(this);else emitReadable(this);return null}n=howMuchToRead(n,state);if(n===0&&state.ended){if(state.length===0)endReadable(this);return null}var doRead=state.needReadable;debug("need readable",doRead);if(state.length===0||state.length-n0)ret=fromList(n,state);else ret=null;if(ret===null){state.needReadable=true;n=0}else{state.length-=n}if(state.length===0){if(!state.ended)state.needReadable=true;if(nOrig!==n&&state.ended)endReadable(this)}if(ret!==null)this.emit("data",ret);return ret};function chunkInvalid(state,chunk){var er=null;if(!Buffer.isBuffer(chunk)&&typeof chunk!=="string"&&chunk!==null&&chunk!==undefined&&!state.objectMode){er=new TypeError("Invalid non-string/buffer chunk")}return er}function onEofChunk(stream,state){if(state.ended)return;if(state.decoder){var chunk=state.decoder.end();if(chunk&&chunk.length){state.buffer.push(chunk);state.length+=state.objectMode?1:chunk.length}}state.ended=true;emitReadable(stream)}function emitReadable(stream){var state=stream._readableState;state.needReadable=false;if(!state.emittedReadable){debug("emitReadable",state.flowing);state.emittedReadable=true;if(state.sync)processNextTick(emitReadable_,stream);else emitReadable_(stream)}}function emitReadable_(stream){debug("emit readable");stream.emit("readable");flow(stream)}function maybeReadMore(stream,state){if(!state.readingMore){state.readingMore=true;processNextTick(maybeReadMore_,stream,state)}}function maybeReadMore_(stream,state){var len=state.length;while(!state.reading&&!state.flowing&&!state.ended&&state.length1&&indexOf(state.pipes,dest)!==-1)&&!cleanedUp){debug("false write response, pause",src._readableState.awaitDrain);src._readableState.awaitDrain++;increasedAwaitDrain=true}src.pause()}}function onerror(er){debug("onerror",er);unpipe();dest.removeListener("error",onerror);if(EElistenerCount(dest,"error")===0)dest.emit("error",er)}prependListener(dest,"error",onerror);function onclose(){dest.removeListener("finish",onfinish);unpipe()}dest.once("close",onclose);function onfinish(){debug("onfinish");dest.removeListener("close",onclose);unpipe()}dest.once("finish",onfinish);function unpipe(){debug("unpipe");src.unpipe(dest)}dest.emit("pipe",src);if(!state.flowing){debug("pipe resume");src.resume()}return dest};function pipeOnDrain(src){return function(){var state=src._readableState;debug("pipeOnDrain",state.awaitDrain);if(state.awaitDrain)state.awaitDrain--;if(state.awaitDrain===0&&EElistenerCount(src,"data")){state.flowing=true;flow(src)}}}Readable.prototype.unpipe=function(dest){var state=this._readableState;if(state.pipesCount===0)return this;if(state.pipesCount===1){if(dest&&dest!==state.pipes)return this;if(!dest)dest=state.pipes;state.pipes=null;state.pipesCount=0;state.flowing=false;if(dest)dest.emit("unpipe",this);return this}if(!dest){var dests=state.pipes;var len=state.pipesCount;state.pipes=null;state.pipesCount=0;state.flowing=false;for(var _i=0;_i=state.length){if(state.decoder)ret=state.buffer.join("");else if(state.buffer.length===1)ret=state.buffer.head.data;else ret=state.buffer.concat(state.length);state.buffer.clear()}else{ret=fromListPartial(n,state.buffer,state.decoder)}return ret}function fromListPartial(n,list,hasStrings){var ret;if(nstr.length?str.length:n;if(nb===str.length)ret+=str;else ret+=str.slice(0,n);n-=nb;if(n===0){if(nb===str.length){++c;if(p.next)list.head=p.next;else list.head=list.tail=null}else{list.head=p;p.data=str.slice(nb)}break}++c}list.length-=c;return ret}function copyFromBuffer(n,list){var ret=bufferShim.allocUnsafe(n);var p=list.head;var c=1;p.data.copy(ret);n-=p.data.length;while(p=p.next){var buf=p.data;var nb=n>buf.length?buf.length:n;buf.copy(ret,ret.length-n,0,nb);n-=nb;if(n===0){if(nb===buf.length){++c;if(p.next)list.head=p.next;else list.head=list.tail=null}else{list.head=p;p.data=buf.slice(nb)}break}++c}list.length-=c;return ret}function endReadable(stream){var state=stream._readableState;if(state.length>0)throw new Error('"endReadable()" called on non-empty stream');if(!state.endEmitted){state.ended=true;processNextTick(endReadableNT,state,stream)}}function endReadableNT(state,stream){if(!state.endEmitted&&state.length===0){state.endEmitted=true;stream.readable=false;stream.emit("end")}}function forEach(xs,f){for(var i=0,l=xs.length;i-1?setImmediate:processNextTick;Writable.WritableState=WritableState;var util=require("core-util-is");util.inherits=require("inherits");var internalUtil={deprecate:require("util-deprecate")};var Stream;(function(){try{Stream=require("st"+"ream")}catch(_){}finally{if(!Stream)Stream=require("events").EventEmitter}})();var Buffer=require("buffer").Buffer;var bufferShim=require("buffer-shims");util.inherits(Writable,Stream);function nop(){}function WriteReq(chunk,encoding,cb){this.chunk=chunk;this.encoding=encoding;this.callback=cb;this.next=null}var Duplex;function WritableState(options,stream){Duplex=Duplex||require("./_stream_duplex");options=options||{};this.objectMode=!!options.objectMode;if(stream instanceof Duplex)this.objectMode=this.objectMode||!!options.writableObjectMode;var hwm=options.highWaterMark;var defaultHwm=this.objectMode?16:16*1024;this.highWaterMark=hwm||hwm===0?hwm:defaultHwm;this.highWaterMark=~~this.highWaterMark;this.needDrain=false;this.ending=false;this.ended=false;this.finished=false;var noDecode=options.decodeStrings===false;this.decodeStrings=!noDecode;this.defaultEncoding=options.defaultEncoding||"utf8";this.length=0;this.writing=false;this.corked=0;this.sync=true;this.bufferProcessing=false;this.onwrite=function(er){onwrite(stream,er)};this.writecb=null;this.writelen=0;this.bufferedRequest=null;this.lastBufferedRequest=null;this.pendingcb=0;this.prefinished=false;this.errorEmitted=false;this.bufferedRequestCount=0;this.corkedRequestsFree=new CorkedRequest(this)}WritableState.prototype.getBuffer=function writableStateGetBuffer(){var current=this.bufferedRequest;var out=[];while(current){out.push(current);current=current.next}return out};(function(){try{Object.defineProperty(WritableState.prototype,"buffer",{get:internalUtil.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer "+"instead.")})}catch(_){}})();var Duplex;function Writable(options){Duplex=Duplex||require("./_stream_duplex");if(!(this instanceof Writable)&&!(this instanceof Duplex))return new Writable(options);this._writableState=new WritableState(options,this);this.writable=true;if(options){if(typeof options.write==="function")this._write=options.write;if(typeof options.writev==="function")this._writev=options.writev}Stream.call(this)}Writable.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function writeAfterEnd(stream,cb){var er=new Error("write after end");stream.emit("error",er);processNextTick(cb,er)}function validChunk(stream,state,chunk,cb){var valid=true;var er=false;if(chunk===null){er=new TypeError("May not write null values to stream")}else if(!Buffer.isBuffer(chunk)&&typeof chunk!=="string"&&chunk!==undefined&&!state.objectMode){er=new TypeError("Invalid non-string/buffer chunk")}if(er){stream.emit("error",er);processNextTick(cb,er);valid=false}return valid}Writable.prototype.write=function(chunk,encoding,cb){var state=this._writableState;var ret=false;if(typeof encoding==="function"){cb=encoding;encoding=null}if(Buffer.isBuffer(chunk))encoding="buffer";else if(!encoding)encoding=state.defaultEncoding;if(typeof cb!=="function")cb=nop;if(state.ended)writeAfterEnd(this,cb);else if(validChunk(this,state,chunk,cb)){ +state.pendingcb++;ret=writeOrBuffer(this,state,chunk,encoding,cb)}return ret};Writable.prototype.cork=function(){var state=this._writableState;state.corked++};Writable.prototype.uncork=function(){var state=this._writableState;if(state.corked){state.corked--;if(!state.writing&&!state.corked&&!state.finished&&!state.bufferProcessing&&state.bufferedRequest)clearBuffer(this,state)}};Writable.prototype.setDefaultEncoding=function setDefaultEncoding(encoding){if(typeof encoding==="string")encoding=encoding.toLowerCase();if(!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((encoding+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+encoding);this._writableState.defaultEncoding=encoding;return this};function decodeChunk(state,chunk,encoding){if(!state.objectMode&&state.decodeStrings!==false&&typeof chunk==="string"){chunk=bufferShim.from(chunk,encoding)}return chunk}function writeOrBuffer(stream,state,chunk,encoding,cb){chunk=decodeChunk(state,chunk,encoding);if(Buffer.isBuffer(chunk))encoding="buffer";var len=state.objectMode?1:chunk.length;state.length+=len;var ret=state.length0)this.tail.next=entry;else this.head=entry;this.tail=entry;++this.length};BufferList.prototype.unshift=function(v){var entry={data:v,next:this.head};if(this.length===0)this.tail=entry;this.head=entry;++this.length};BufferList.prototype.shift=function(){if(this.length===0)return;var ret=this.head.data;if(this.length===1)this.head=this.tail=null;else this.head=this.head.next;--this.length;return ret};BufferList.prototype.clear=function(){this.head=this.tail=null;this.length=0};BufferList.prototype.join=function(s){if(this.length===0)return"";var p=this.head;var ret=""+p.data;while(p=p.next){ret+=s+p.data}return ret};BufferList.prototype.concat=function(n){if(this.length===0)return bufferShim.alloc(0);if(this.length===1)return this.head.data;var ret=bufferShim.allocUnsafe(n>>>0);var p=this.head;var i=0;while(p){p.data.copy(ret,i);i+=p.data.length;p=p.next}return ret}},{buffer:5,"buffer-shims":4}],50:[function(require,module,exports){module.exports=require("./lib/_stream_passthrough.js")},{"./lib/_stream_passthrough.js":45}],51:[function(require,module,exports){(function(process){var Stream=function(){try{return require("st"+"ream")}catch(_){}}();exports=module.exports=require("./lib/_stream_readable.js");exports.Stream=Stream||exports;exports.Readable=exports;exports.Writable=require("./lib/_stream_writable.js");exports.Duplex=require("./lib/_stream_duplex.js");exports.Transform=require("./lib/_stream_transform.js");exports.PassThrough=require("./lib/_stream_passthrough.js");if(!process.browser&&process.env.READABLE_STREAM==="disable"&&Stream){module.exports=Stream}}).call(this,require("_process"))},{"./lib/_stream_duplex.js":44,"./lib/_stream_passthrough.js":45,"./lib/_stream_readable.js":46,"./lib/_stream_transform.js":47,"./lib/_stream_writable.js":48,_process:42}],52:[function(require,module,exports){module.exports=require("./lib/_stream_transform.js")},{"./lib/_stream_transform.js":47}],53:[function(require,module,exports){module.exports=require("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":48}],54:[function(require,module,exports){module.exports=function(string){return string.replace(/[-\\^$*+?.()|[\]{}]/g,"\\$&")}},{}],55:[function(require,module,exports){module.exports=Stream;var EE=require("events").EventEmitter;var inherits=require("inherits");inherits(Stream,EE);Stream.Readable=require("readable-stream/readable.js");Stream.Writable=require("readable-stream/writable.js");Stream.Duplex=require("readable-stream/duplex.js");Stream.Transform=require("readable-stream/transform.js");Stream.PassThrough=require("readable-stream/passthrough.js");Stream.Stream=Stream;function Stream(){EE.call(this)}Stream.prototype.pipe=function(dest,options){var source=this;function ondata(chunk){if(dest.writable){if(false===dest.write(chunk)&&source.pause){source.pause()}}}source.on("data",ondata);function ondrain(){if(source.readable&&source.resume){source.resume()}}dest.on("drain",ondrain);if(!dest._isStdio&&(!options||options.end!==false)){source.on("end",onend);source.on("close",onclose)}var didOnEnd=false;function onend(){if(didOnEnd)return;didOnEnd=true;dest.end()}function onclose(){if(didOnEnd)return;didOnEnd=true;if(typeof dest.destroy==="function")dest.destroy()}function onerror(er){cleanup();if(EE.listenerCount(this,"error")===0){throw er}}source.on("error",onerror);dest.on("error",onerror);function cleanup(){source.removeListener("data",ondata);dest.removeListener("drain",ondrain);source.removeListener("end",onend);source.removeListener("close",onclose);source.removeListener("error",onerror);dest.removeListener("error",onerror);source.removeListener("end",cleanup);source.removeListener("close",cleanup);dest.removeListener("close",cleanup)}source.on("end",cleanup);source.on("close",cleanup);dest.on("close",cleanup);dest.emit("pipe",source);return dest}},{events:28,inherits:38,"readable-stream/duplex.js":43,"readable-stream/passthrough.js":50,"readable-stream/readable.js":51,"readable-stream/transform.js":52,"readable-stream/writable.js":53}],56:[function(require,module,exports){var Buffer=require("buffer").Buffer;var isBufferEncoding=Buffer.isEncoding||function(encoding){switch(encoding&&encoding.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return true;default:return false}};function assertEncoding(encoding){if(encoding&&!isBufferEncoding(encoding)){throw new Error("Unknown encoding: "+encoding)}}var StringDecoder=exports.StringDecoder=function(encoding){this.encoding=(encoding||"utf8").toLowerCase().replace(/[-_]/,"");assertEncoding(encoding);switch(this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2;this.detectIncompleteChar=utf16DetectIncompleteChar;break;case"base64":this.surrogateSize=3;this.detectIncompleteChar=base64DetectIncompleteChar;break;default:this.write=passThroughWrite;return}this.charBuffer=new Buffer(6);this.charReceived=0;this.charLength=0};StringDecoder.prototype.write=function(buffer){var charStr="";while(this.charLength){var available=buffer.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:buffer.length;buffer.copy(this.charBuffer,this.charReceived,0,available);this.charReceived+=available;if(this.charReceived=55296&&charCode<=56319){this.charLength+=this.surrogateSize;charStr="";continue}this.charReceived=this.charLength=0;if(buffer.length===0){return charStr}break}this.detectIncompleteChar(buffer);var end=buffer.length;if(this.charLength){buffer.copy(this.charBuffer,0,buffer.length-this.charReceived,end);end-=this.charReceived}charStr+=buffer.toString(this.encoding,0,end);var end=charStr.length-1;var charCode=charStr.charCodeAt(end);if(charCode>=55296&&charCode<=56319){var size=this.surrogateSize;this.charLength+=size;this.charReceived+=size;this.charBuffer.copy(this.charBuffer,size,0,size);buffer.copy(this.charBuffer,0,0,size);return charStr.substring(0,end)}return charStr};StringDecoder.prototype.detectIncompleteChar=function(buffer){var i=buffer.length>=3?3:buffer.length;for(;i>0;i--){var c=buffer[buffer.length-i];if(i==1&&c>>5==6){this.charLength=2;break}if(i<=2&&c>>4==14){this.charLength=3;break}if(i<=3&&c>>3==30){this.charLength=4;break}}this.charReceived=i};StringDecoder.prototype.end=function(buffer){var res="";if(buffer&&buffer.length)res=this.write(buffer);if(this.charReceived){var cr=this.charReceived;var buf=this.charBuffer;var enc=this.encoding;res+=buf.slice(0,cr).toString(enc)}return res};function passThroughWrite(buffer){return buffer.toString(this.encoding)}function utf16DetectIncompleteChar(buffer){this.charReceived=buffer.length%2;this.charLength=this.charReceived?2:0}function base64DetectIncompleteChar(buffer){this.charReceived=buffer.length%3;this.charLength=this.charReceived?3:0}},{buffer:5}],57:[function(require,module,exports){(function(global){module.exports=deprecate;function deprecate(fn,msg){if(config("noDeprecation")){return fn}var warned=false;function deprecated(){if(!warned){if(config("throwDeprecation")){throw new Error(msg)}else if(config("traceDeprecation")){console.trace(msg)}else{console.warn(msg)}warned=true}return fn.apply(this,arguments)}return deprecated}function config(name){try{if(!global.localStorage)return false}catch(_){return false}var val=global.localStorage[name];if(null==val)return false;return String(val).toLowerCase()==="true"}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],58:[function(require,module,exports){module.exports=extend;var hasOwnProperty=Object.prototype.hasOwnProperty;function extend(){var target={};for(var i=0;i 0) { + qp = obj.url.substring(obj.url.indexOf('?') + 1); + var parts = qp.split('&'); + if(parts && parts.length > 0) { + for(var i = 0; i < parts.length; i++) { + var kv = parts[i].split('='); + if(kv && kv.length > 0) { + if (kv[0] === this.name) { + // skip it + return false; + } + } + } + } + } - SwaggerAuthorizations.prototype.remove = function (name) { - return delete this.authz[name]; - }; + if (obj.url.indexOf('?') > 0) { + obj.url = obj.url + '&' + this.name + '=' + this.value; + } else { + obj.url = obj.url + '?' + this.name + '=' + this.value; + } - SwaggerAuthorizations.prototype.apply = function (obj, securities) { - var status = true; - var applyAll = !securities; - var flattenedSecurities = []; + return true; + } else if (this.type === 'header') { + if(typeof obj.headers[this.name] === 'undefined') { + obj.headers[this.name] = this.value; + } - // Securities could be [ {} ] - _.each(securities, function (obj, key) { + return true; + } +}; - // Make sure we account for securities being [ str ] - if (typeof key === 'string') { - flattenedSecurities.push(key); - } +var CookieAuthorization = module.exports.CookieAuthorization = function (cookie) { + this.cookie = cookie; +}; - // Flatten keys in to our array - _.each(obj, function (val, key) { - flattenedSecurities.push(key); - }); - }); +CookieAuthorization.prototype.apply = function (obj) { + obj.cookieJar = obj.cookieJar || new CookieJar(); + obj.cookieJar.setCookie(this.cookie); - _.each(this.authz, function (auth, authName) { - if (applyAll || _.includes(flattenedSecurities, authName)) { - var newStatus = auth.apply(obj); + return true; +}; - status = status && !!newStatus; // logical ORs regarding status - } - }); +/** + * Password Authorization is a basic auth implementation + */ +var PasswordAuthorization = module.exports.PasswordAuthorization = function (username, password) { + if (arguments.length === 3) { + helpers.log('PasswordAuthorization: the \'name\' argument has been removed, pass only username and password'); + username = arguments[1]; + password = arguments[2]; + } + this.username = username; + this.password = password; +}; + +PasswordAuthorization.prototype.apply = function (obj) { + if(typeof obj.headers.Authorization === 'undefined') { + obj.headers.Authorization = 'Basic ' + btoa(this.username + ':' + this.password); + } + + return true; +}; + +},{"./helpers":4,"btoa":13,"cookiejar":18,"lodash-compat/collection/each":52,"lodash-compat/collection/includes":55,"lodash-compat/lang/isArray":140,"lodash-compat/lang/isObject":144}],3:[function(require,module,exports){ +'use strict'; + +var _ = { + bind: require('lodash-compat/function/bind'), + cloneDeep: require('lodash-compat/lang/cloneDeep'), + find: require('lodash-compat/collection/find'), + forEach: require('lodash-compat/collection/forEach'), + indexOf: require('lodash-compat/array/indexOf'), + isArray: require('lodash-compat/lang/isArray'), + isObject: require('lodash-compat/lang/isObject'), + isFunction: require('lodash-compat/lang/isFunction'), + isPlainObject: require('lodash-compat/lang/isPlainObject'), + isUndefined: require('lodash-compat/lang/isUndefined') +}; +var auth = require('./auth'); +var helpers = require('./helpers'); +var Model = require('./types/model'); +var Operation = require('./types/operation'); +var OperationGroup = require('./types/operationGroup'); +var Resolver = require('./resolver'); +var SwaggerHttp = require('./http'); +var SwaggerSpecConverter = require('./spec-converter'); +var Q = require('q'); + +// We have to keep track of the function/property names to avoid collisions for tag names which are used to allow the +// following usage: 'client.{tagName}' +var reservedClientTags = [ + 'apis', + 'authorizationScheme', + 'authorizations', + 'basePath', + 'build', + 'buildFrom1_1Spec', + 'buildFrom1_2Spec', + 'buildFromSpec', + 'clientAuthorizations', + 'convertInfo', + 'debug', + 'defaultErrorCallback', + 'defaultSuccessCallback', + 'enableCookies', + 'fail', + 'failure', + 'finish', + 'help', + 'host', + 'idFromOp', + 'info', + 'initialize', + 'isBuilt', + 'isValid', + 'modelPropertyMacro', + 'models', + 'modelsArray', + 'options', + 'parameterMacro', + 'parseUri', + 'progress', + 'resourceCount', + 'sampleModels', + 'selfReflect', + 'setConsolidatedModels', + 'spec', + 'supportedSubmitMethods', + 'swaggerRequestHeaders', + 'tagFromLabel', + 'title', + 'url', + 'useJQuery', + 'jqueryAjaxCache' +]; +// We have to keep track of the function/property names to avoid collisions for tag names which are used to allow the +// following usage: 'client.apis.{tagName}' +var reservedApiTags = [ + 'apis', + 'asCurl', + 'description', + 'externalDocs', + 'help', + 'label', + 'name', + 'operation', + 'operations', + 'operationsArray', + 'path', + 'tag' +]; +var supportedOperationMethods = ['delete', 'get', 'head', 'options', 'patch', 'post', 'put']; +var SwaggerClient = module.exports = function (url, options) { + this.authorizations = null; + this.authorizationScheme = null; + this.basePath = null; + this.debug = false; + this.enableCookies = false; + this.info = null; + this.isBuilt = false; + this.isValid = false; + this.modelsArray = []; + this.resourceCount = 0; + this.url = null; + this.useJQuery = false; + this.jqueryAjaxCache = false; + this.swaggerObject = {}; + this.deferredClient = undefined; + + this.clientAuthorizations = new auth.SwaggerAuthorizations(); + + if (typeof url !== 'undefined') { + return this.initialize(url, options); + } else { + return this; + } +}; + +SwaggerClient.prototype.initialize = function (url, options) { + this.models = {}; + this.sampleModels = {}; + + if (typeof url === 'string') { + this.url = url; + } else if (_.isObject(url)) { + options = url; + this.url = options.url; + } + + if(this.url && this.url.indexOf('http:') === -1 && this.url.indexOf('https:') === -1) { + // no protocol, so we can only use window if it exists + if(typeof(window) !== 'undefined' && window && window.location) { + this.url = window.location.origin + this.url; + } + } + + options = options || {}; + this.clientAuthorizations.add(options.authorizations); + this.swaggerRequestHeaders = options.swaggerRequestHeaders || 'application/json;charset=utf-8,*/*'; + this.defaultSuccessCallback = options.defaultSuccessCallback || null; + this.defaultErrorCallback = options.defaultErrorCallback || null; + this.modelPropertyMacro = options.modelPropertyMacro || null; + this.connectionAgent = options.connectionAgent || null; + this.parameterMacro = options.parameterMacro || null; + this.usePromise = options.usePromise || null; + + // operation request timeout default + this.timeout = options.timeout || null; + // default to request timeout when not specified + this.fetchSpecTimeout = typeof options.fetchSpecTimeout !== 'undefined' ? + options.fetchSpecTimeout : options.timeout || null; + + if(this.usePromise) { + this.deferredClient = Q.defer(); + } + + if (typeof options.success === 'function') { + this.success = options.success; + } + if (options.useJQuery) { + this.useJQuery = options.useJQuery; + } + + if (options.jqueryAjaxCache) { + this.jqueryAjaxCache = options.jqueryAjaxCache; + } + + if (options.enableCookies) { + this.enableCookies = options.enableCookies; + } + + this.options = options || {}; + + // maybe don't need this? + this.options.timeout = this.timeout; + this.options.fetchSpecTimeout = this.fetchSpecTimeout; + + this.supportedSubmitMethods = options.supportedSubmitMethods || []; + this.failure = options.failure || function (err) { throw err; }; + this.progress = options.progress || function () {}; + this.spec = _.cloneDeep(options.spec); // Clone so we do not alter the provided document + + if (options.scheme) { + this.scheme = options.scheme; + } + + if (this.usePromise || typeof options.success === 'function') { + this.ready = true; + return this.build(); + } +}; + +SwaggerClient.prototype.build = function (mock) { + if (this.isBuilt) { + return this; + } + + var self = this; + + if (this.spec) { + this.progress('fetching resource list; Please wait.'); + } else { + this.progress('fetching resource list: ' + this.url + '; Please wait.'); + } + + var obj = { + useJQuery: this.useJQuery, + jqueryAjaxCache: this.jqueryAjaxCache, + connectionAgent: this.connectionAgent, + enableCookies: this.enableCookies, + url: this.url, + method: 'get', + headers: { + accept: this.swaggerRequestHeaders + }, + on: { + error: function (response) { + if (self.url.substring(0, 4) !== 'http') { + return self.fail('Please specify the protocol for ' + self.url); + } else if (response.errObj && (response.errObj.code === 'ECONNABORTED' || response.errObj.message.indexOf('timeout') !== -1)) { + return self.fail('Request timed out after ' + self.fetchSpecTimeout + 'ms'); + } else if (response.status === 0) { + return self.fail('Can\'t read from server. It may not have the appropriate access-control-origin settings.'); + } else if (response.status === 404) { + return self.fail('Can\'t read swagger JSON from ' + self.url); + } else { + return self.fail(response.status + ' : ' + response.statusText + ' ' + self.url); + } + }, + response: function (resp) { - return status; - }; + var responseObj = resp.obj; + if(!responseObj) { + return self.fail('failed to parse JSON/YAML response'); + } - /** - * ApiKeyAuthorization allows a query param or header to be injected - */ - var ApiKeyAuthorization = module.exports.ApiKeyAuthorization = function (name, value, type) { - this.name = name; - this.value = value; - this.type = type; - }; + self.swaggerVersion = responseObj.swaggerVersion; + self.swaggerObject = responseObj; - ApiKeyAuthorization.prototype.apply = function (obj) { - if (this.type === 'query') { - if (obj.url.indexOf('?') > 0) { - obj.url = obj.url + '&' + this.name + '=' + this.value; - } else { - obj.url = obj.url + '?' + this.name + '=' + this.value; - } + if (responseObj.swagger && parseInt(responseObj.swagger) === 2) { + self.swaggerVersion = responseObj.swagger; - return true; - } else if (this.type === 'header') { - if (typeof obj.headers[this.name] === 'undefined') { - obj.headers[this.name] = this.value; - } + new Resolver().resolve(responseObj, self.url, self.buildFromSpec, self); - return true; - } - }; - - var CookieAuthorization = module.exports.CookieAuthorization = function (cookie) { - this.cookie = cookie; - }; + self.isValid = true; + } else { + var converter = new SwaggerSpecConverter(); + self.oldSwaggerObject = self.swaggerObject; + + converter.setDocumentationLocation(self.url); + converter.convert(responseObj, self.clientAuthorizations, self.options, function(spec) { + self.swaggerObject = spec; + new Resolver().resolve(spec, self.url, self.buildFromSpec, self); + self.isValid = true; + }); + } + } + } + }; + + // only set timeout when specified + if (this.fetchSpecTimeout) { + obj.timeout = this.fetchSpecTimeout; + } + + if (this.spec) { + self.swaggerObject = this.spec; + setTimeout(function () { + new Resolver().resolve(self.spec, self.url, self.buildFromSpec, self); + }, 10); + } else { + this.clientAuthorizations.apply(obj); + + if (mock) { + return obj; + } - CookieAuthorization.prototype.apply = function (obj) { - obj.cookieJar = obj.cookieJar || new CookieJar(); - obj.cookieJar.setCookie(this.cookie); + new SwaggerHttp().execute(obj, this.options); + } + + return (this.usePromise) ? this.deferredClient.promise : this; +}; + +SwaggerClient.prototype.buildFromSpec = function (response) { + if (this.isBuilt) { + return this; + } + + this.apis = {}; + this.apisArray = []; + this.basePath = response.basePath || ''; + this.consumes = response.consumes; + this.host = response.host || ''; + this.info = response.info || {}; + this.produces = response.produces; + this.schemes = response.schemes || []; + this.securityDefinitions = _.cloneDeep(response.securityDefinitions); + this.security = response.security; + this.title = response.title || ''; + + var key, definedTags = {}, k, location, self = this, i; + + if (response.externalDocs) { + this.externalDocs = response.externalDocs; + } + + // legacy support + this.authSchemes = this.securityDefinitions; + + if(this.securityDefinitions) { + for(key in this.securityDefinitions) { + var securityDefinition = this.securityDefinitions[key]; + securityDefinition.vendorExtensions = {}; + for(var ext in securityDefinition) { + helpers.extractExtensions(ext, securityDefinition); + if (ext === 'scopes') { + var scopes = securityDefinition[ext]; + if(typeof scopes === 'object') { + scopes.vendorExtensions = {}; + for (var s in scopes) { + helpers.extractExtensions(s, scopes); + if(s.indexOf('x-') === 0) { + delete scopes[s]; + } + } + } + } + } + } + } + + if (Array.isArray(response.tags)) { + definedTags = {}; + + for (k = 0; k < response.tags.length; k++) { + var t = _.cloneDeep(response.tags[k]); + definedTags[t.name] = t; + for(i in t) { + if(i === 'externalDocs' && typeof t[i] === 'object') { + for(var j in t[i]) { + helpers.extractExtensions(j, t[i]); + } + } + helpers.extractExtensions(i, t); + } + } + } + + + if (typeof this.url === 'string') { + location = this.parseUri(this.url); + if (typeof this.scheme === 'undefined' && typeof this.schemes === 'undefined' || this.schemes.length === 0) { + if(typeof window !== 'undefined') { + // use the window scheme + this.scheme = window.location.protocol.replace(':',''); + } + else { + this.scheme = location.scheme || 'http'; + } + } else if (typeof window !== 'undefined' && window.location.protocol.indexOf('chrome-extension') === 0) { + // if it is chrome swagger ui extension scheme then let swagger doc url scheme decide the protocol + this.scheme = location.scheme; + } else if (typeof this.scheme === 'undefined') { + if(typeof window !== 'undefined') { + var scheme = window.location.protocol.replace(':',''); + if(scheme === 'https' && this.schemes.indexOf(scheme) === -1) { + // can't call http from https served page in a browser! + helpers.log('Cannot call a http server from https inside a browser!'); + this.scheme = 'http'; + } + else if(this.schemes.indexOf(scheme) !== -1) { + this.scheme = scheme; + } + else { + if(this.schemes.indexOf('https') !== -1) { + this.scheme = 'https'; + } + else { + this.scheme = 'http'; + } + } + } + else { + this.scheme = this.schemes[0] || location.scheme; + } + } - return true; - }; + if (typeof this.host === 'undefined' || this.host === '') { + this.host = location.host; - /** - * Password Authorization is a basic auth implementation - */ - var PasswordAuthorization = module.exports.PasswordAuthorization = function (username, password) { - if (arguments.length === 3) { - helpers.log('PasswordAuthorization: the \'name\' argument has been removed, pass only username and password'); - username = arguments[1]; - password = arguments[2]; - } - this.username = username; - this.password = password; - }; + if (location.port) { + this.host = this.host + ':' + location.port; + } + } + } + else { + if (typeof this.schemes === 'undefined' || this.schemes.length === 0) { + this.scheme = 'http'; + } + else if (typeof this.scheme === 'undefined') { + this.scheme = this.schemes[0]; + } + } - PasswordAuthorization.prototype.apply = function (obj) { - if (typeof obj.headers.Authorization === 'undefined') { - obj.headers.Authorization = 'Basic ' + btoa(this.username + ':' + this.password); - } + this.definitions = response.definitions; - return true; - }; + for (key in this.definitions) { + var model = new Model(key, this.definitions[key], this.models, this.modelPropertyMacro); - },{ - './helpers': 4,'btoa': 18,'cookiejar': 19,'lodash-compat/collection/each': 55,'lodash-compat/collection/includes': 58,'lodash-compat/lang/isArray': 143,'lodash-compat/lang/isObject': 147 - }],3: [function (require, module, exports) { - 'use strict'; - - var _ = { - bind: require('lodash-compat/function/bind'), - cloneDeep: require('lodash-compat/lang/cloneDeep'), - find: require('lodash-compat/collection/find'), - forEach: require('lodash-compat/collection/forEach'), - indexOf: require('lodash-compat/array/indexOf'), - isArray: require('lodash-compat/lang/isArray'), - isObject: require('lodash-compat/lang/isObject'), - isFunction: require('lodash-compat/lang/isFunction'), - isPlainObject: require('lodash-compat/lang/isPlainObject'), - isUndefined: require('lodash-compat/lang/isUndefined') - }; - var auth = require('./auth'); - var helpers = require('./helpers'); - var Model = require('./types/model'); - var Operation = require('./types/operation'); - var OperationGroup = require('./types/operationGroup'); - var Resolver = require('./resolver'); - var SwaggerHttp = require('./http'); - var SwaggerSpecConverter = require('./spec-converter'); - - // We have to keep track of the function/property names to avoid collisions for tag names which are used to allow the - // following usage: 'client.{tagName}' - var reservedClientTags = [ - 'apis', - 'authorizationScheme', - 'authorizations', - 'basePath', - 'build', - 'buildFrom1_1Spec', - 'buildFrom1_2Spec', - 'buildFromSpec', - 'clientAuthorizations', - 'convertInfo', - 'debug', - 'defaultErrorCallback', - 'defaultSuccessCallback', - 'fail', - 'failure', - 'finish', - 'help', - 'idFromOp', - 'info', - 'initialize', - 'isBuilt', - 'isValid', - 'modelPropertyMacro', - 'models', - 'modelsArray', - 'options', - 'parameterMacro', - 'parseUri', - 'progress', - 'resourceCount', - 'sampleModels', - 'selfReflect', - 'setConsolidatedModels', - 'spec', - 'supportedSubmitMethods', - 'swaggerRequestHeaders', - 'tagFromLabel', - 'url', - 'useJQuery' - ]; - // We have to keep track of the function/property names to avoid collisions for tag names which are used to allow the - // following usage: 'client.apis.{tagName}' - var reservedApiTags = [ - 'apis', - 'asCurl', - 'description', - 'externalDocs', - 'help', - 'label', - 'name', - 'operation', - 'operations', - 'operationsArray', - 'path', - 'tag' - ]; - var supportedOperationMethods = ['delete', 'get', 'head', 'options', 'patch', 'post', 'put']; - var SwaggerClient = module.exports = function (url, options) { - this.authorizations = null; - this.authorizationScheme = null; - this.basePath = null; - this.debug = false; - this.info = null; - this.isBuilt = false; - this.isValid = false; - this.modelsArray = []; - this.resourceCount = 0; - this.url = null; - this.useJQuery = false; - this.swaggerObject = {}; - - this.clientAuthorizations = new auth.SwaggerAuthorizations(); - - if (typeof url !== 'undefined') { - return this.initialize(url, options); - } + if (model) { + this.models[key] = model; + } + } - return this; + // get paths, create functions for each operationId - }; + // Bind help to 'client.apis' + self.apis.help = _.bind(self.help, self); - SwaggerClient.prototype.initialize = function (url, options) { - this.models = {}; - this.sampleModels = {}; + _.forEach(response.paths, function (pathObj, path) { + // Only process a path if it's an object + if (!_.isPlainObject(pathObj)) { + return; + } - if (typeof url === 'string') { - this.url = url; - } else if (_.isObject(url)) { - options = url; - this.url = options.url; - } + _.forEach(supportedOperationMethods, function (method) { + var operation = pathObj[method]; + + if (_.isUndefined(operation)) { + // Operation does not exist + return; + } else if (!_.isPlainObject(operation)) { + // Operation exists but it is not an Operation Object. Since this is invalid, log it. + helpers.log('The \'' + method + '\' operation for \'' + path + '\' path is not an Operation Object'); + + return; + } + + var tags = operation.tags; + + if (_.isUndefined(tags) || !_.isArray(tags) || tags.length === 0) { + tags = operation.tags = [ 'default' ]; + } + + var operationId = self.idFromOp(path, method, operation); + + var operationObject = new Operation(self, + operation.scheme, + operationId, + method, + path, + operation, + self.definitions, + self.models, + self.clientAuthorizations); + + operationObject.connectionAgent = self.connectionAgent; + operationObject.vendorExtensions = {}; + for(i in operation) { + helpers.extractExtensions(i, operationObject, operation[i]); + } + operationObject.externalDocs = operation.externalDocs; + if(operationObject.externalDocs) { + operationObject.externalDocs = _.cloneDeep(operationObject.externalDocs); + operationObject.externalDocs.vendorExtensions = {}; + for(i in operationObject.externalDocs) { + helpers.extractExtensions(i, operationObject.externalDocs); + } + } - options = options || {}; - this.clientAuthorizations.add(options.authorizations); - this.swaggerRequestHeaders = options.swaggerRequestHeaders || 'application/json;charset=utf-8,*/*'; - this.defaultSuccessCallback = options.defaultSuccessCallback || null; - this.defaultErrorCallback = options.defaultErrorCallback || null; - this.modelPropertyMacro = options.modelPropertyMacro || null; - this.parameterMacro = options.modelPropertyMacro || null; + // bind self operation's execute command to the api + _.forEach(tags, function (tag) { + var clientProperty = _.indexOf(reservedClientTags, tag) > -1 ? '_' + tag : tag; + var apiProperty = _.indexOf(reservedApiTags, tag) > -1 ? '_' + tag : tag; + var operationGroup = self[clientProperty]; - if (typeof options.success === 'function') { - this.success = options.success; - } + if (clientProperty !== tag) { + helpers.log('The \'' + tag + '\' tag conflicts with a SwaggerClient function/property name. Use \'client.' + + clientProperty + '\' or \'client.apis.' + tag + '\' instead of \'client.' + tag + '\'.'); + } - if (options.useJQuery) { - this.useJQuery = options.useJQuery; - } + if (apiProperty !== tag) { + helpers.log('The \'' + tag + '\' tag conflicts with a SwaggerClient operation function/property name. Use ' + + '\'client.apis.' + apiProperty + '\' instead of \'client.apis.' + tag + '\'.'); + } - this.options = options || {}; + if (_.indexOf(reservedApiTags, operationId) > -1) { + helpers.log('The \'' + operationId + '\' operationId conflicts with a SwaggerClient operation ' + + 'function/property name. Use \'client.apis.' + apiProperty + '._' + operationId + + '\' instead of \'client.apis.' + apiProperty + '.' + operationId + '\'.'); - this.supportedSubmitMethods = options.supportedSubmitMethods || []; - this.failure = options.failure || function () {}; - this.progress = options.progress || function () {}; - this.spec = _.cloneDeep(options.spec); // Clone so we do not alter the provided document + operationId = '_' + operationId; + operationObject.nickname = operationId; // So 'client.apis.[tag].operationId.help() works properly + } - if (typeof options.success === 'function') { - this.ready = true; - this.build(); - } - }; + if (_.isUndefined(operationGroup)) { + operationGroup = self[clientProperty] = self.apis[apiProperty] = {}; - SwaggerClient.prototype.build = function (mock) { - if (this.isBuilt) { - return this; - } + operationGroup.operations = {}; + operationGroup.label = apiProperty; + operationGroup.apis = {}; - var self = this; - - this.progress('fetching resource list: ' + this.url); - - var obj = { - useJQuery: this.useJQuery, - url: this.url, - method: 'get', - headers: { - accept: this.swaggerRequestHeaders - }, - on: { - error: function (response) { - if (self.url.substring(0, 4) !== 'http') { - return self.fail('Please specify the protocol for ' + self.url); - } else if (response.status === 0) { - return self.fail('Can\'t read from server. It may not have the appropriate access-control-origin settings.'); - } else if (response.status === 404) { - return self.fail('Can\'t read swagger JSON from ' + self.url); - } + var tagDef = definedTags[tag]; - return self.fail(response.status + ' : ' + response.statusText + ' ' + self.url); + if (!_.isUndefined(tagDef)) { + operationGroup.description = tagDef.description; + operationGroup.externalDocs = tagDef.externalDocs; + operationGroup.vendorExtensions = tagDef.vendorExtensions; + } - }, - response: function (resp) { + self[clientProperty].help = _.bind(self.help, operationGroup); + self.apisArray.push(new OperationGroup(tag, operationGroup.description, operationGroup.externalDocs, operationObject)); + } - var responseObj = resp.obj; + operationId = self.makeUniqueOperationId(operationId, self.apis[apiProperty]); - if (!responseObj) { - return self.fail('failed to parse JSON/YAML response'); - } + // Bind tag help + if (!_.isFunction(operationGroup.help)) { + operationGroup.help = _.bind(self.help, operationGroup); + } - self.swaggerVersion = responseObj.swaggerVersion; - self.swaggerObject = responseObj; + // bind to the apis object + self.apis[apiProperty][operationId] = operationGroup[operationId] = _.bind(operationObject.execute, + operationObject); + self.apis[apiProperty][operationId].help = operationGroup[operationId].help = _.bind(operationObject.help, + operationObject); + self.apis[apiProperty][operationId].asCurl = operationGroup[operationId].asCurl = _.bind(operationObject.asCurl, + operationObject); - if (responseObj.swagger && parseInt(responseObj.swagger) === 2) { - self.swaggerVersion = responseObj.swagger; + operationGroup.apis[operationId] = operationGroup.operations[operationId] = operationObject; - new Resolver().resolve(responseObj, self.url, self.buildFromSpec, self); + // legacy UI feature + var api = _.find(self.apisArray, function (api) { + return api.tag === tag; + }); - self.isValid = true; - } else { - var converter = new SwaggerSpecConverter(); + if (api) { + api.operationsArray.push(operationObject); + } + }); + }); + }); + + // sort the apisArray according to the tags + var sortedApis = []; + _.forEach(Object.keys(definedTags), function (tag) { + var pos; + for(pos in self.apisArray) { + var _api = self.apisArray[pos]; + if(_api && tag === _api.name) { + sortedApis.push(_api); + self.apisArray[pos] = null; + } + } + }); + // add anything left + _.forEach(self.apisArray, function (api) { + if(api) { + sortedApis.push(api); + } + }); + self.apisArray = sortedApis; + + _.forEach(response.definitions, function (definitionObj, definition) { + definitionObj.id = definition.toLowerCase(); + definitionObj.name = definition; + self.modelsArray.push(definitionObj); + }); + + this.isBuilt = true; + + if (this.usePromise) { + this.isValid = true; + this.isBuilt = true; + this.deferredClient.resolve(this); + + return this.deferredClient.promise; + } + + if (this.success) { + this.success(); + } + + return this; +}; + +SwaggerClient.prototype.makeUniqueOperationId = function(operationId, api) { + var count = 0; + var name = operationId; + + // make unique across this operation group + while(true) { + var matched = false; + _.forEach(api.operations, function (operation) { + if(operation.nickname === name) { + matched = true; + } + }); + if(!matched) { + return name; + } + name = operationId + '_' + count; + count ++; + } + + return operationId; +}; + +SwaggerClient.prototype.parseUri = function (uri) { + var urlParseRE = /^(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?:\:([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/; + var parts = urlParseRE.exec(uri); + + return { + scheme: parts[4] ? parts[4].replace(':','') : undefined, + host: parts[11], + port: parts[12], + path: parts[15] + }; +}; + +SwaggerClient.prototype.help = function (dontPrint) { + var output = ''; + + if (this instanceof SwaggerClient) { + _.forEach(this.apis, function (api, name) { + if (_.isPlainObject(api)) { + output += 'operations for the \'' + name + '\' tag\n'; + + _.forEach(api.operations, function (operation, name) { + output += ' * ' + name + ': ' + operation.summary + '\n'; + }); + } + }); + } else if (this instanceof OperationGroup || _.isPlainObject(this)) { + output += 'operations for the \'' + this.label + '\' tag\n'; - self.oldSwaggerObject = self.swaggerObject; + _.forEach(this.apis, function (operation, name) { + output += ' * ' + name + ': ' + operation.summary + '\n'; + }); + } + + if (dontPrint) { + return output; + } else { + helpers.log(output); + + return output; + } +}; + +SwaggerClient.prototype.tagFromLabel = function (label) { + return label; +}; + +SwaggerClient.prototype.idFromOp = function (path, httpMethod, op) { + if(!op || !op.operationId) { + op = op || {}; + op.operationId = httpMethod + '_' + path; + } + var opId = op.operationId.replace(/[\s!@#$%^&*()_+=\[{\]};:<>|.\/?,\\'""-]/g, '_') || (path.substring(1) + '_' + httpMethod); + + opId = opId.replace(/((_){2,})/g, '_'); + opId = opId.replace(/^(_)*/g, ''); + opId = opId.replace(/([_])*$/g, ''); + + return opId; +}; + +SwaggerClient.prototype.setHost = function (host) { + this.host = host; + + if(this.apis) { + _.forEach(this.apis, function(api) { + if(api.operations) { + _.forEach(api.operations, function(operation) { + operation.host = host; + }); + } + }); + } +}; - converter.setDocumentationLocation(self.url); - converter.convert(responseObj, self.clientAuthorizations, function (spec) { - self.swaggerObject = spec; - new Resolver().resolve(spec, self.url, self.buildFromSpec, self); - self.isValid = true; - }); - } - } - } - }; +SwaggerClient.prototype.setBasePath = function (basePath) { + this.basePath = basePath; - if (this.spec) { - self.swaggerObject = this.spec; - setTimeout(function () { - new Resolver().resolve(self.spec, self.buildFromSpec, self); - }, 10); - } else { - this.clientAuthorizations.apply(obj); + if(this.apis) { + _.forEach(this.apis, function(api) { + if(api.operations) { + _.forEach(api.operations, function(operation) { + operation.basePath = basePath; + }); + } + }); + } +}; + +SwaggerClient.prototype.setSchemes = function (schemes) { + this.schemes = schemes; + + if(schemes && schemes.length > 0) { + if(this.apis) { + _.forEach(this.apis, function (api) { + if (api.operations) { + _.forEach(api.operations, function (operation) { + operation.scheme = schemes[0]; + }); + } + }); + } + } +}; + +SwaggerClient.prototype.fail = function (message) { + if (this.usePromise) { + this.deferredClient.reject(message); + return this.deferredClient.promise; + } else { + if (this.failure) { + this.failure(message); + } + else { + this.failure(message); + } + } +}; + +},{"./auth":2,"./helpers":4,"./http":5,"./resolver":6,"./spec-converter":8,"./types/model":9,"./types/operation":10,"./types/operationGroup":11,"lodash-compat/array/indexOf":49,"lodash-compat/collection/find":53,"lodash-compat/collection/forEach":54,"lodash-compat/function/bind":58,"lodash-compat/lang/cloneDeep":138,"lodash-compat/lang/isArray":140,"lodash-compat/lang/isFunction":142,"lodash-compat/lang/isObject":144,"lodash-compat/lang/isPlainObject":145,"lodash-compat/lang/isUndefined":148,"q":157}],4:[function(require,module,exports){ +(function (process){ +'use strict'; + +var _ = { + isPlainObject: require('lodash-compat/lang/isPlainObject'), + indexOf: require('lodash-compat/array/indexOf') +}; + +module.exports.__bind = function (fn, me) { + return function(){ + return fn.apply(me, arguments); + }; +}; + +var log = module.exports.log = function() { + // Only log if available and we're not testing + if (console && process.env.NODE_ENV !== 'test') { + console.log(Array.prototype.slice.call(arguments)[0]); + } +}; + +module.exports.fail = function (message) { + log(message); +}; + +module.exports.optionHtml = function (label, value) { + return '' + label + ':' + value + ''; +}; + +var resolveSchema = module.exports.resolveSchema = function (schema) { + if (_.isPlainObject(schema.schema)) { + schema = resolveSchema(schema.schema); + } + + return schema; +}; + +module.exports.simpleRef = function (name) { + if (typeof name === 'undefined') { + return null; + } + + if (name.indexOf('#/definitions/') === 0) { + return name.substring('#/definitions/'.length); + } else { + return name; + } +}; - if (mock) { - return obj; - } +/** + * helper to remove extensions and add them to an object + * + * @param keyname + * @param obj + */ +module.exports.extractExtensions = function (keyname, obj, value) { + if(!keyname || !obj) { + return; + } + + if (typeof keyname === 'string' && keyname.indexOf('x-') === 0) { + obj.vendorExtensions = obj.vendorExtensions || {}; + if(value) { + obj.vendorExtensions[keyname] = value; + } + else { + obj.vendorExtensions[keyname] = obj[keyname]; + } + } +}; +}).call(this,require('_process')) + +},{"_process":12,"lodash-compat/array/indexOf":49,"lodash-compat/lang/isPlainObject":145}],5:[function(require,module,exports){ +(function (Buffer){ +'use strict'; + +var helpers = require('./helpers'); +var request = require('superagent'); +var jsyaml = require('js-yaml'); +var _ = { + isObject: require('lodash-compat/lang/isObject'), + keys: require('lodash-compat/object/keys') +}; + +/* + * JQueryHttpClient is a light-weight, node or browser HTTP client + */ +var JQueryHttpClient = function () { + this.type = 'JQueryHttpClient'; +}; - new SwaggerHttp().execute(obj, this.options); - } +/* + * SuperagentHttpClient is a light-weight, node or browser HTTP client + */ +var SuperagentHttpClient = function () { + this.type = 'SuperagentHttpClient'; +}; - return this; - }; +/** + * SwaggerHttp is a wrapper for executing requests + */ +var SwaggerHttp = module.exports = function () {}; + +SwaggerHttp.prototype.execute = function (obj, opts) { + var client; + + if(opts && opts.client) { + client = opts.client; + } + else { + client = new SuperagentHttpClient(opts); + } + client.opts = opts || {}; + + if (opts && opts.requestAgent) { + request = opts.requestAgent; + } + + // legacy support + var hasJQuery = false; + if(typeof window !== 'undefined') { + if(typeof window.jQuery !== 'undefined') { + hasJQuery = true; + } + } + // OPTIONS support + if(obj.method.toLowerCase() === 'options' && client.type === 'SuperagentHttpClient') { + log('forcing jQuery as OPTIONS are not supported by SuperAgent'); + obj.useJQuery = true; + } + if(this.isInternetExplorer() && (obj.useJQuery === false || !hasJQuery )) { + throw new Error('Unsupported configuration! JQuery is required but not available'); + } + if ((obj && obj.useJQuery === true) || this.isInternetExplorer() && hasJQuery) { + client = new JQueryHttpClient(opts); + } + + var success = obj.on.response; + var error = obj.on.error; + + var requestInterceptor = function(data) { + if(opts && opts.requestInterceptor) { + data = opts.requestInterceptor.apply(data); + } + return data; + }; - SwaggerClient.prototype.buildFromSpec = function (response) { - if (this.isBuilt) { - return this; - } + var responseInterceptor = function(data) { + if(opts && opts.responseInterceptor) { + data = opts.responseInterceptor.apply(data, [obj]); + } + return success(data); + }; - this.apis = {}; - this.apisArray = []; - this.basePath = response.basePath || ''; - this.consumes = response.consumes; - this.host = response.host || ''; - this.info = response.info || {}; - this.produces = response.produces; - this.schemes = response.schemes || []; - this.securityDefinitions = response.securityDefinitions; - this.title = response.title || ''; - - if (response.externalDocs) { - this.externalDocs = response.externalDocs; - } + var errorInterceptor = function(data) { + if(opts && opts.responseInterceptor) { + data = opts.responseInterceptor.apply(data, [obj]); + } + error(data); + }; - // legacy support - this.authSchemes = response.securityDefinitions; + obj.on.error = function(data) { + errorInterceptor(data); + }; - var definedTags = {}; - var k; + obj.on.response = function(data) { + if(data && data.status >= 400) { + errorInterceptor(data); + } + else { + responseInterceptor(data); + } + }; + + if (_.isObject(obj) && _.isObject(obj.body)) { + // special processing for file uploads via jquery + if (obj.body.type && obj.body.type === 'formData'){ + if(opts.useJQuery) { + obj.contentType = false; + obj.processData = false; + delete obj.headers['Content-Type']; + } + } + } - if (Array.isArray(response.tags)) { - definedTags = {}; + obj = requestInterceptor(obj) || obj; + if (obj.beforeSend) { + obj.beforeSend(function(_obj) { + client.execute(_obj || obj); + }); + } else { + client.execute(obj); + } - for (k = 0; k < response.tags.length; k++) { - var t = response.tags[k]; + return (obj.deferred) ? obj.deferred.promise : obj; +}; - definedTags[t.name] = t; - } - } +SwaggerHttp.prototype.isInternetExplorer = function () { + var detectedIE = false; - var location; + if (typeof navigator !== 'undefined' && navigator.userAgent) { + var nav = navigator.userAgent.toLowerCase(); - if (typeof this.url === 'string') { - location = this.parseUri(this.url); + if (nav.indexOf('msie') !== -1) { + var version = parseInt(nav.split('msie')[1]); - if (typeof this.schemes === 'undefined' || this.schemes.length === 0) { - this.scheme = location.scheme || 'http'; - } else { - this.scheme = this.schemes[0]; - } + if (version <= 8) { + detectedIE = true; + } + } + } - if (typeof this.host === 'undefined' || this.host === '') { - this.host = location.host; + return detectedIE; +}; - if (location.port) { - this.host = this.host + ':' + location.port; - } - } - } else if (typeof this.schemes === 'undefined' || this.schemes.length === 0) { - this.scheme = 'http'; - } else { - this.scheme = this.schemes[0]; - } +JQueryHttpClient.prototype.execute = function (obj) { + var jq = this.jQuery || (typeof window !== 'undefined' && window.jQuery); + var cb = obj.on; + var request = obj; - this.definitions = response.definitions; + if(typeof jq === 'undefined' || jq === false) { + throw new Error('Unsupported configuration! JQuery is required but not available'); + } - var key; + obj.type = obj.method; + obj.cache = obj.jqueryAjaxCache; + obj.data = obj.body; + delete obj.jqueryAjaxCache; + delete obj.useJQuery; + delete obj.body; - for (key in this.definitions) { - var model = new Model(key, this.definitions[key], this.models, this.modelPropertyMacro); + obj.complete = function (response) { + var headers = {}; + var headerArray = response.getAllResponseHeaders().split('\n'); - if (model) { - this.models[key] = model; - } - } + for (var i = 0; i < headerArray.length; i++) { + var toSplit = headerArray[i].trim(); - // get paths, create functions for each operationId - var self = this; + if (toSplit.length === 0) { + continue; + } - // Bind help to 'client.apis' - self.apis.help = _.bind(self.help, self); + var separator = toSplit.indexOf(':'); - _.forEach(response.paths, function (pathObj, path) { - // Only process a path if it's an object - if (!_.isPlainObject(pathObj)) { - return; - } + if (separator === -1) { + // Name but no value in the header + headers[toSplit] = null; - _.forEach(supportedOperationMethods, function (method) { - var operation = pathObj[method]; + continue; + } - if (_.isUndefined(operation)) { - // Operation does not exist - return; - } else if (!_.isPlainObject(operation)) { - // Operation exists but it is not an Operation Object. Since this is invalid, log it. - helpers.log('The \'' + method + '\' operation for \'' + path + '\' path is not an Operation Object'); + var name = toSplit.substring(0, separator).trim(); + var value = toSplit.substring(separator + 1).trim(); - return; - } + headers[name] = value; + } - var tags = operation.tags; + var out = { + url: request.url, + method: request.method, + status: response.status, + statusText: response.statusText, + data: response.responseText, + headers: headers + }; - if (_.isUndefined(tags) || !_.isArray(tags) || tags.length === 0) { - tags = operation.tags = ['default']; - } + try { + var possibleObj = response.responseJSON || jsyaml.safeLoad(response.responseText); + out.obj = (typeof possibleObj === 'string') ? {} : possibleObj; + } catch (ex) { + // do not set out.obj + helpers.log('unable to parse JSON/YAML content'); + } - var operationId = self.idFromOp(path, method, operation); - var operationObject = new Operation(self, - operation.scheme, - operationId, - method, - path, - operation, - self.definitions, - self.models, - self.clientAuthorizations); - - // bind self operation's execute command to the api - _.forEach(tags, function (tag) { - var clientProperty = _.indexOf(reservedClientTags, tag) > -1 ? '_' + tag : tag; - var apiProperty = _.indexOf(reservedApiTags, tag) > -1 ? '_' + tag : tag; - var operationGroup = self[clientProperty]; - - if (clientProperty !== tag) { - helpers.log('The \'' + tag + '\' tag conflicts with a SwaggerClient function/property name. Use \'client.' + - clientProperty + '\' or \'client.apis.' + tag + '\' instead of \'client.' + tag + '\'.'); - } + // I can throw, or parse null? + out.obj = out.obj || null; - if (apiProperty !== tag) { - helpers.log('The \'' + tag + '\' tag conflicts with a SwaggerClient operation function/property name. Use ' + - '\'client.apis.' + apiProperty + '\' instead of \'client.apis.' + tag + '\'.'); - } + if (response.status >= 200 && response.status < 300) { + cb.response(out); + } else if (response.status === 0 || (response.status >= 400 && response.status < 599)) { + cb.error(out); + } else { + return cb.response(out); + } + }; - if (_.indexOf(reservedApiTags, operationId) > -1) { - helpers.log('The \'' + operationId + '\' operationId conflicts with a SwaggerClient operation ' + - 'function/property name. Use \'client.apis.' + apiProperty + '._' + operationId + - '\' instead of \'client.apis.' + apiProperty + '.' + operationId + '\'.'); + jq.support.cors = true; - operationId = '_' + operationId; - operationObject.nickname = operationId; // So 'client.apis.[tag].operationId.help() works properly - } + return jq.ajax(obj); +}; - if (_.isUndefined(operationGroup)) { - operationGroup = self[clientProperty] = self.apis[apiProperty] = {}; +SuperagentHttpClient.prototype.execute = function (obj) { + var method = obj.method.toLowerCase(); + var timeout = obj.timeout; - operationGroup.operations = {}; - operationGroup.label = apiProperty; - operationGroup.apis = {}; + if (method === 'delete') { + method = 'del'; + } + var headers = obj.headers || {}; - var tagDef = definedTags[tag]; + var r = request[method](obj.url); - if (!_.isUndefined(tagDef)) { - operationGroup.description = tagDef.description; - operationGroup.externalDocs = tagDef.externalDocs; - } + if (obj.connectionAgent) { + r.agent(obj.connectionAgent); + } - self[clientProperty].help = _.bind(self.help, operationGroup); - self.apisArray.push(new OperationGroup(tag, operationGroup.description, operationGroup.externalDocs, operationObject)); - } + if (timeout) { + r.timeout(timeout); + } - // Bind tag help - if (!_.isFunction(operationGroup.help)) { - operationGroup.help = _.bind(self.help, operationGroup); - } + if (obj.enableCookies) { + r.withCredentials(); + } - // bind to the apis object - self.apis[apiProperty][operationId] = operationGroup[operationId] = _.bind(operationObject.execute, - operationObject); - self.apis[apiProperty][operationId].help = operationGroup[operationId].help = _.bind(operationObject.help, - operationObject); - self.apis[apiProperty][operationId].asCurl = operationGroup[operationId].asCurl = _.bind(operationObject.asCurl, - operationObject); + var accept = obj.headers.Accept; - operationGroup.apis[operationId] = operationGroup.operations[operationId] = operationObject; + if(this.binaryRequest(accept)) { + r.on('request', function () { + if(this.xhr) { + this.xhr.responseType = 'blob'; + } + }); + } + + if(obj.body) { + if(_.isObject(obj.body)) { + var contentType = obj.headers['Content-Type'] || ''; + if (contentType.indexOf('multipart/form-data') === 0) { + delete headers['Content-Type']; + if({}.toString.apply(obj.body) === '[object FormData]') { + r.send(obj.body); + } + else { + var keyname, value, v; + for (keyname in obj.body) { + value = obj.body[keyname]; + if(Array.isArray(value)) { + for(v in value) { + r.field(keyname, v); + } + } + else { + r.field(keyname, value); + } + } + } + } + else if (_.isObject(obj.body)) { + // non multipart/form-data + obj.body = JSON.stringify(obj.body); + r.send(obj.body); + } + } + else { + r.send(obj.body); + } + } - // legacy UI feature - var api = _.find(self.apisArray, function (api) { - return api.tag === tag; - }); + var name; + for (name in headers) { + r.set(name, headers[name]); + } - if (api) { - api.operationsArray.push(operationObject); - } - }); - }); - }); + if(typeof r.buffer === 'function') { + r.buffer(); // force superagent to populate res.text with the raw response data + } - this.isBuilt = true; + r.end(function (err, res) { + res = res || { + status: 0, + headers: {error: 'no response from server'} + }; + var response = { + url: obj.url, + method: obj.method, + headers: res.headers + }; + var cb; - if (this.success) { - this.isValid = true; - this.isBuilt = true; - this.success(); - } + if (!err && res.error) { + err = res.error; + } - return this; - }; + if (err && obj.on && obj.on.error) { + response.errObj = err; + response.status = res ? res.status : 500; + response.statusText = res ? res.text : err.message; + if (res.headers && res.headers['content-type']) { + if (res.headers['content-type'].indexOf('application/json') >= 0) { + try { + response.obj = JSON.parse(response.statusText); + } + catch (e) { + response.obj = null; + } + } + } + cb = obj.on.error; + } else if (res && obj.on && obj.on.response) { + var possibleObj; + + // Already parsed by by superagent? + if (res.body && _.keys(res.body).length > 0) { + possibleObj = res.body; + } else { + try { + possibleObj = jsyaml.safeLoad(res.text); + // can parse into a string... which we don't need running around in the system + possibleObj = (typeof possibleObj === 'string') ? null : possibleObj; + } catch (e) { + helpers.log('cannot parse JSON/YAML content'); + } + } + + // null means we can't parse into object + if(typeof Buffer === 'function' && Buffer.isBuffer(possibleObj)) { + response.data = possibleObj; + } + else { + response.obj = (typeof possibleObj === 'object') ? possibleObj : null; + } + + response.status = res.status; + response.statusText = res.text; + cb = obj.on.response; + } + if (res.xhr && res.xhr.response) { + response.data = res.xhr.response; + } + else if(!response.data) { + response.data = response.statusText; + } - SwaggerClient.prototype.parseUri = function (uri) { - var urlParseRE = /^(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?:\:([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/; - var parts = urlParseRE.exec(uri); + if (cb) { + cb(response); + } + }); +}; - return { - scheme: parts[4].replace(':', ''), - host: parts[11], - port: parts[12], - path: parts[15] - }; - }; +SuperagentHttpClient.prototype. binaryRequest = function (accept) { + if(!accept) { + return false; + } + return (/^image/i).test(accept) + || (/^application\/pdf/).test(accept) + || (/^application\/octet-stream/).test(accept); +}; - SwaggerClient.prototype.help = function (dontPrint) { - var output = ''; +}).call(this,require("buffer").Buffer) - if (this instanceof SwaggerClient) { - _.forEach(this.apis, function (api, name) { - if (_.isPlainObject(api)) { - output += 'operations for the \'' + name + '\' tag\n'; +},{"./helpers":4,"buffer":14,"js-yaml":19,"lodash-compat/lang/isObject":144,"lodash-compat/object/keys":149,"superagent":158}],6:[function(require,module,exports){ +'use strict'; - _.forEach(api.operations, function (operation, name) { - output += ' * ' + name + ': ' + operation.summary + '\n'; - }); - } - }); - } else if (this instanceof OperationGroup || _.isPlainObject(this)) { - output += 'operations for the \'' + this.label + '\' tag\n'; +var SwaggerHttp = require('./http'); +var _ = { + isObject: require('lodash-compat/lang/isObject'), + cloneDeep: require('lodash-compat/lang/cloneDeep'), + isArray: require('lodash-compat/lang/isArray'), + isString: require('lodash-compat/lang/isString') +}; - _.forEach(this.apis, function (operation, name) { - output += ' * ' + name + ': ' + operation.summary + '\n'; - }); - } - if (dontPrint) { - return output; - } - helpers.log(output); +/** + * Resolves a spec's remote references + */ +var Resolver = module.exports = function () { + this.failedUrls = []; + this.resolverCache = {}; + this.pendingUrls = {}; +}; + +Resolver.prototype.processAllOf = function(root, name, definition, resolutionTable, unresolvedRefs, spec) { + var i, location, property; + + definition['x-resolved-from'] = [ '#/definitions/' + name ]; + var allOf = definition.allOf; + // the refs go first + allOf.sort(function(a, b) { + if(a.$ref && b.$ref) { return 0; } + else if(a.$ref) { return -1; } + else { return 1; } + }); + for (i = 0; i < allOf.length; i++) { + property = allOf[i]; + location = '/definitions/' + name + '/allOf'; + this.resolveInline(root, spec, property, resolutionTable, unresolvedRefs, location); + } +}; + +Resolver.prototype.resolve = function (spec, arg1, arg2, arg3) { + this.spec = spec; + var root = arg1, callback = arg2, scope = arg3, opts = {}, location, i; + if(typeof arg1 === 'function') { + root = null; + callback = arg1; + scope = arg2; + } + var _root = root, modelName; + this.scope = (scope || this); + this.iteration = this.iteration || 0; + + if(this.scope.options && this.scope.options.requestInterceptor){ + opts.requestInterceptor = this.scope.options.requestInterceptor; + } + + if(this.scope.options && this.scope.options.responseInterceptor){ + opts.responseInterceptor = this.scope.options.responseInterceptor; + } + + var name, path, property, propertyName, parameter, done, counter; + var processedCalls = 0, resolvedRefs = {}, unresolvedRefs = {}; + var resolutionTable = []; // store objects for dereferencing + + spec.definitions = spec.definitions || {}; + // definitions + for (name in spec.definitions) { + var definition = spec.definitions[name]; + if(definition.$ref) { + this.resolveInline(root, spec, definition, resolutionTable, unresolvedRefs, definition); + } + else { + for (propertyName in definition.properties) { + property = definition.properties[propertyName]; + if (_.isArray(property.allOf)) { + this.processAllOf(root, name, property, resolutionTable, unresolvedRefs, spec); + } + else { + this.resolveTo(root, property, resolutionTable, '/definitions'); + } + } - return output; + if (definition.allOf) { + this.processAllOf(root, name, definition, resolutionTable, unresolvedRefs, spec); + } + } + } + + // shared parameters + spec.parameters = spec.parameters || {}; + for(name in spec.parameters) { + parameter = spec.parameters[name]; + if (parameter.in === 'body' && parameter.schema) { + if(_.isArray(parameter.schema.allOf)) { + // move to a definition + modelName = 'inline_model'; + var _name = modelName; + done = false; counter = 0; + while(!done) { + if(typeof spec.definitions[_name] === 'undefined') { + done = true; + break; + } + _name = modelName + '_' + counter; + counter ++; + } + spec.definitions[_name] = { allOf: parameter.schema.allOf }; + delete parameter.schema.allOf; + parameter.schema.$ref = '#/definitions/' + _name; + this.processAllOf(root, _name, spec.definitions[_name], resolutionTable, unresolvedRefs, spec); + } + else { + this.resolveTo(root, parameter.schema, resolutionTable, location); + } + } - }; + if (parameter.$ref) { + // parameter reference + this.resolveInline(root, spec, parameter, resolutionTable, unresolvedRefs, parameter.$ref); + } + } + + // operations + for (name in spec.paths) { + var method, operation, responseCode; + path = spec.paths[name]; + + if(typeof path === 'object') { + for (method in path) { + // operation reference + if (method === '$ref') { + // location = path[method]; + location = '/paths' + name; + this.resolveInline(root, spec, path, resolutionTable, unresolvedRefs, location); + } + else { + operation = path[method]; + var sharedParameters = path.parameters || []; + var parameters = operation.parameters || []; + + sharedParameters.forEach(function(parameter) { + parameters.unshift(parameter); + }); + + if (method !== 'parameters' && _.isObject(operation)) { + operation.parameters = operation.parameters || parameters; + } + + for (i in parameters) { + parameter = parameters[i]; + location = '/paths' + name + '/' + method + '/parameters'; + + if (parameter.in === 'body' && parameter.schema) { + if (_.isArray(parameter.schema.allOf)) { + // move to a definition + modelName = 'inline_model'; + name = modelName; + done = false; + counter = 0; + while (!done) { + if (typeof spec.definitions[name] === 'undefined') { + done = true; + break; + } + name = modelName + '_' + counter; + counter++; + } + spec.definitions[name] = {allOf: parameter.schema.allOf}; + delete parameter.schema.allOf; + parameter.schema.$ref = '#/definitions/' + name; + this.processAllOf(root, name, spec.definitions[name], resolutionTable, unresolvedRefs, spec); + } + else { + this.resolveTo(root, parameter.schema, resolutionTable, location); + } + } - SwaggerClient.prototype.tagFromLabel = function (label) { - return label; - }; + if (parameter.$ref) { + // parameter reference + this.resolveInline(root, spec, parameter, resolutionTable, unresolvedRefs, parameter.$ref); + } + } + + for (responseCode in operation.responses) { + var response = operation.responses[responseCode]; + location = '/paths' + name + '/' + method + '/responses/' + responseCode; + + if (_.isObject(response)) { + if (response.$ref) { + // response reference + this.resolveInline(root, spec, response, resolutionTable, unresolvedRefs, location); + } + if (response.schema) { + var responseObj = response; + if (_.isArray(responseObj.schema.allOf)) { + // move to a definition + modelName = 'inline_model'; + name = modelName; + done = false; + counter = 0; + while (!done) { + if (typeof spec.definitions[name] === 'undefined') { + done = true; + break; + } + name = modelName + '_' + counter; + counter++; + } + spec.definitions[name] = {allOf: responseObj.schema.allOf}; + delete responseObj.schema.allOf; + delete responseObj.schema.type; + responseObj.schema.$ref = '#/definitions/' + name; + this.processAllOf(root, name, spec.definitions[name], resolutionTable, unresolvedRefs, spec); + } + else if ('array' === responseObj.schema.type) { + if (responseObj.schema.items && responseObj.schema.items.$ref) { + // response reference + this.resolveInline(root, spec, responseObj.schema.items, resolutionTable, unresolvedRefs, location); + } + } + else { + this.resolveTo(root, response.schema, resolutionTable, location); + } + } + } + } + } + } + // clear them out to avoid multiple resolutions + path.parameters = []; + } + } + + var expectedCalls = 0, toResolve = []; + // if the root is same as obj[i].root we can resolve locally + var all = resolutionTable; + + var parts; + for(i = 0; i < all.length; i++) { + var a = all[i]; + if(root === a.root) { + if(a.resolveAs === 'ref') { + // resolve any path walking + var joined = ((a.root || '') + '/' + a.key).split('/'); + var normalized = []; + var url = ''; + var k; + + if(a.key.indexOf('../') >= 0) { + for(var j = 0; j < joined.length; j++) { + if(joined[j] === '..') { + normalized = normalized.slice(0, normalized.length-1); + } + else { + normalized.push(joined[j]); + } + } + for(k = 0; k < normalized.length; k ++) { + if(k > 0) { + url += '/'; + } + url += normalized[k]; + } + // we now have to remote resolve this because the path has changed + a.root = url; + toResolve.push(a); + } + else { + parts = a.key.split('#'); + if(parts.length === 2) { + if(parts[0].indexOf('http:') === 0 || parts[0].indexOf('https:') === 0) { + a.root = parts[0]; + } + location = parts[1].split('/'); + var r; + var s = spec; + for(k = 0; k < location.length; k++) { + var part = location[k]; + if(part !== '') { + s = s[part]; + if(typeof s !== 'undefined') { + r = s; + } + else { + r = null; + break; + } + } + } + if(r === null) { + // must resolve this too + toResolve.push(a); + } + } + } + } + else { + if (a.resolveAs === 'inline') { + if(a.key && a.key.indexOf('#') === -1 && a.key.charAt(0) !== '/') { + // handle relative schema + parts = a.root.split('/'); + location = ''; + for(i = 0; i < parts.length - 1; i++) { + location += parts[i] + '/'; + } + location += a.key; + a.root = location; + a.location = ''; + } + toResolve.push(a); + } + } + } + else { + toResolve.push(a); + } + } + expectedCalls = toResolve.length; - SwaggerClient.prototype.idFromOp = function (path, httpMethod, op) { - if (!op || !op.operationId) { - op = op || {}; - op.operationId = httpMethod + '_' + path; - } - var opId = op.operationId.replace(/[\s!@#$%^&*()_+=\[{\]};:<>|.\/?,\\'""-]/g, '_') || path.substring(1) + '_' + httpMethod; + // resolve anything that is local - opId = opId.replace(/((_){2,})/g, '_'); - opId = opId.replace(/^(_)*/g, ''); - opId = opId.replace(/([_])*$/g, ''); + var lock = {}; + for(var ii = 0; ii < toResolve.length; ii++) { + (function(item, spec, self, lock, ii) { + if(!item.root || item.root === root) { + // local resolve + self.resolveItem(spec, _root, resolutionTable, resolvedRefs, unresolvedRefs, item); + processedCalls += 1; - return opId; - }; + if(processedCalls === expectedCalls) { + self.finish(spec, root, resolutionTable, resolvedRefs, unresolvedRefs, callback, true); + } + } + else if(self.failedUrls.indexOf(item.root) === -1) { + var obj = { + useJQuery: false, // TODO + url: item.root, + method: 'get', + headers: { + accept: self.scope.swaggerRequestHeaders || 'application/json' + }, + on: { + error: function (error) { + processedCalls += 1; + console.log('failed url: ' + obj.url); + self.failedUrls.push(obj.url); + if (lock) { + delete lock[item.root]; + } + unresolvedRefs[item.key] = { + root: item.root, + location: item.location + }; + + if (processedCalls === expectedCalls) { + self.finish(spec, _root, resolutionTable, resolvedRefs, unresolvedRefs, callback); + } + }, // jshint ignore:line + response: function (response) { + var swagger = response.obj; + if (lock) { + delete lock[item.root]; + } + if (self.resolverCache) { + self.resolverCache[item.root] = swagger; + } + self.resolveItem(swagger, item.root, resolutionTable, resolvedRefs, unresolvedRefs, item); + processedCalls += 1; + + if (processedCalls === expectedCalls) { + self.finish(spec, _root, resolutionTable, resolvedRefs, unresolvedRefs, callback); + } + } + } // jshint ignore:line + }; - SwaggerClient.prototype.setHost = function (host) { - this.host = host; + // apply timeout only when specified + if (scope && scope.fetchSpecTimeout) { + obj.timeout = scope.fetchSpecTimeout; + } - if (this.apis) { - _.forEach(this.apis, function (api) { - if (api.operations) { - _.forEach(api.operations, function (operation) { - operation.host = host; - }); - } - }); - } - }; + if (scope && scope.clientAuthorizations) { + scope.clientAuthorizations.apply(obj); + } - SwaggerClient.prototype.setBasePath = function (basePath) { - this.basePath = basePath; + (function waitForUnlock() { + setTimeout(function() { + if (lock[obj.url]) { + waitForUnlock(); + } + else { + var cached = self.resolverCache[obj.url]; + if (_.isObject(cached)) { + obj.on.response({obj: cached}); + } + else { + lock[obj.url] = true; + new SwaggerHttp().execute(obj, opts); + } + } + }, 0); + })(); + } + + else { + processedCalls += 1; + unresolvedRefs[item.key] = { + root: item.root, + location: item.location + }; + if (processedCalls === expectedCalls) { + self.finish(spec, _root, resolutionTable, resolvedRefs, unresolvedRefs, callback); + } + } + }(toResolve[ii], spec, this, lock, ii)); + } + + if (Object.keys(toResolve).length === 0) { + this.finish(spec, _root, resolutionTable, resolvedRefs, unresolvedRefs, callback); + } +}; + +Resolver.prototype.resolveItem = function(spec, root, resolutionTable, resolvedRefs, unresolvedRefs, item) { + var path = item.location; + var location = spec, parts = path.split('/'); + if(path !== '') { + for (var j = 0; j < parts.length; j++) { + var segment = parts[j]; + if (segment.indexOf('~1') !== -1) { + segment = parts[j].replace(/~0/g, '~').replace(/~1/g, '/'); + if (segment.charAt(0) !== '/') { + segment = '/' + segment; + } + } + if (typeof location === 'undefined' || location === null) { + break; + } + if (segment === '' && j === (parts.length - 1) && parts.length > 1) { + location = null; + break; + } + if (segment.length > 0) { + location = location[segment]; + } + } + } + var resolved = item.key; + parts = item.key.split('/'); + var resolvedName = parts[parts.length-1]; + + if(resolvedName.indexOf('#') >= 0) { + resolvedName = resolvedName.split('#')[1]; + } + + if (location !== null && typeof location !== 'undefined') { + resolvedRefs[resolved] = { + name: resolvedName, + obj: location, + key: item.key, + root: item.root + }; + } else { + unresolvedRefs[resolved] = { + root: item.root, + location: item.location + }; + } +}; + +Resolver.prototype.finish = function (spec, root, resolutionTable, resolvedRefs, unresolvedRefs, callback, localResolve) { + // walk resolution table and replace with resolved refs + var ref, abs; + for (ref in resolutionTable) { + var item = resolutionTable[ref]; + + var key = item.key; + var resolvedTo = resolvedRefs[key]; + if (resolvedTo) { + spec.definitions = spec.definitions || {}; + if (item.resolveAs === 'ref') { + if (localResolve !== true) { + // don't retain root for local definitions + for (key in resolvedTo.obj) { + abs = this.retainRoot(key, resolvedTo.obj[key], item.root); + resolvedTo.obj[key] = abs; + } + } + spec.definitions[resolvedTo.name] = resolvedTo.obj; + item.obj.$ref = '#/definitions/' + resolvedTo.name; + } else if (item.resolveAs === 'inline') { + var targetObj = item.obj; + targetObj['x-resolved-from'] = [ item.key ]; + delete targetObj.$ref; + + for (key in resolvedTo.obj) { + abs = resolvedTo.obj[key]; + + if (localResolve !== true) { + // don't retain root for local definitions + abs = this.retainRoot(key, resolvedTo.obj[key], item.root); + } + targetObj[key] = abs; + } + } + } + } + var existingUnresolved = this.countUnresolvedRefs(spec); + + if(existingUnresolved === 0 || this.iteration > 5) { + this.resolveAllOf(spec.definitions); + this.resolverCache = null; + callback.call(this.scope, spec, unresolvedRefs); + } + else { + this.iteration += 1; + this.resolve(spec, root, callback, this.scope); + } +}; + +Resolver.prototype.countUnresolvedRefs = function(spec) { + var i; + var refs = this.getRefs(spec); + var keys = []; + var unresolvedKeys = []; + for(i in refs) { + if(i.indexOf('#') === 0) { + keys.push(i.substring(1)); + } + else { + unresolvedKeys.push(i); + } + } + + // verify possible keys + for (i = 0; i < keys.length; i++) { + var part = keys[i]; + var parts = part.split('/'); + var obj = spec; + + for (var k = 0; k < parts.length; k++) { + var key = parts[k]; + if(key !== '') { + obj = obj[key]; + if(typeof obj === 'undefined') { + unresolvedKeys.push(part); + break; + } + } + } + } + return unresolvedKeys.length; +}; + +Resolver.prototype.getRefs = function(spec, obj) { + obj = obj || spec; + var output = {}; + for(var key in obj) { + if (!obj.hasOwnProperty(key)) { + continue; + } + var item = obj[key]; + if(key === '$ref' && typeof item === 'string') { + output[item] = null; + } + else if(_.isObject(item)) { + var o = this.getRefs(item); + for(var k in o) { + output[k] = null; + } + } + } + return output; +}; + +function splitUrl(url) { + var result = {}; + var proto = /[a-z]+:\/\//i.exec(url); + if (proto) { + result.proto = proto[0].slice(0, -3); + url = url.slice(result.proto.length + 1); + } + if (url.slice(0, 2) === '//') { + result.domain = url.slice(2).split('/')[0]; + url = url.slice(2 + result.domain.length); + } + var p = url.split('#'); + if (p[0].length) { + result.path = p[0]; + } + if (p.length > 1) { + result.fragment = p.slice(1).join('#'); + } + return result; +} + +function unsplitUrl(url) { + var result = url.path; + if (result === undefined) { + result = ''; + } + if (url.fragment !== undefined) { + result += '#' + url.fragment; + } + if (url.domain !== undefined) { + if (result.slice(0, 1) === '/') { + result = result.slice(1); + } + result = '//' + url.domain + '/' + result; + if (url.proto !== undefined) { + result = url.proto + ':' + result; + } + } + return result; +} + +function joinUrl(base, rel) { + var relsp = splitUrl(rel); + if (relsp.domain !== undefined) { + return rel; + } + var result = splitUrl(base); + if (relsp.path === undefined) { + // change only fragment part + result.fragment = relsp.fragment; + } else if (relsp.path.slice(0, 1) === '/') { + // relative to domain + result.path = relsp.path; + result.fragment = relsp.fragment; + } else { + // relative to path + var path = result.path === undefined ? [] : result.path.split('/'); + var relpath = relsp.path.split('/'); + if (path.length) { + path.pop(); + } + while (relpath[0] === '..' || relpath[0] === '.') { + if (relpath[0] === '..') { + path.pop(); + } + relpath.shift(); + } + result.path = path.concat(relpath).join('/'); + result.fragment = relsp.fragment; + } + return unsplitUrl(result); +} + +Resolver.prototype.retainRoot = function(origKey, obj, root) { + // walk object and look for relative $refs + if(_.isObject(obj)) { + for(var key in obj) { + var item = obj[key]; + if (key === '$ref' && typeof item === 'string') { + obj[key] = joinUrl(root, item); + } + else if (_.isObject(item)) { + this.retainRoot(key, item, root); + } + } + } + else if(_.isString(obj) && origKey === '$ref') { + obj = joinUrl(root, obj); + } + return obj; +}; - if (this.apis) { - _.forEach(this.apis, function (api) { - if (api.operations) { - _.forEach(api.operations, function (operation) { - operation.basePath = basePath; - }); - } - }); - } - }; +/** + * immediately in-lines local refs, queues remote refs + * for inline resolution + */ +Resolver.prototype.resolveInline = function (root, spec, property, resolutionTable, unresolvedRefs, location) { + var key = property.$ref, ref = property.$ref, i, p, p2, rs; + var rootTrimmed = false; + + root = root || ''; // Guard against .split. @fehguy, you'll need to check if this logic fits + // More imporantly is how do we gracefully handle relative urls, when provided just a 'spec', not a 'url' ? + + if (ref) { + if(ref.indexOf('../') === 0) { + // reset root + p = ref.split('../'); + p2 = root.split('/'); + ref = ''; + for(i = 0; i < p.length; i++) { + if(p[i] === '') { + p2 = p2.slice(0, p2.length-1); + } + else { + ref += p[i]; + } + } + root = ''; + for(i = 0; i < p2.length - 1; i++) { + if(i > 0) { root += '/'; } + root += p2[i]; + } + rootTrimmed = true; + } + if(ref.indexOf('#') >= 0) { + if(ref.indexOf('/') === 0) { + rs = ref.split('#'); + p = root.split('//'); + p2 = p[1].split('/'); + root = p[0] + '//' + p2[0] + rs[0]; + location = rs[1]; + } + else { + rs = ref.split('#'); + if(rs[0] !== '') { + p2 = root.split('/'); + p2 = p2.slice(0, p2.length - 1); + if(!rootTrimmed) { + root = ''; + for (var k = 0; k < p2.length; k++) { + if(k > 0) { root += '/'; } + root += p2[k]; + } + } + root += '/' + ref.split('#')[0]; + } + location = rs[1]; + } + } + if (ref.indexOf('http:') === 0 || ref.indexOf('https:') === 0) { + if(ref.indexOf('#') >= 0) { + root = ref.split('#')[0]; + location = ref.split('#')[1]; + } + else { + root = ref; + location = ''; + } + resolutionTable.push({obj: property, resolveAs: 'inline', root: root, key: key, location: location}); + } else if (ref.indexOf('#') === 0) { + location = ref.split('#')[1]; + resolutionTable.push({obj: property, resolveAs: 'inline', root: root, key: key, location: location}); + } else if (ref.indexOf('/') === 0 && ref.indexOf('#') === -1) { + location = ref; + var matches = root.match(/^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i); + if(matches) { + root = matches[0] + ref.substring(1); + location = ''; + } + resolutionTable.push({obj: property, resolveAs: 'inline', root: root, key: key, location: location}); + } + else { + resolutionTable.push({obj: property, resolveAs: 'inline', root: root, key: key, location: location}); + } + } + else if (property.type === 'array') { + this.resolveTo(root, property.items, resolutionTable, location); + } +}; + +Resolver.prototype.resolveTo = function (root, property, resolutionTable, location) { + var sp, i; + var ref = property.$ref; + var lroot = root; + if ((typeof ref !== 'undefined') && (ref !== null)) { + if(ref.indexOf('#') >= 0) { + var parts = ref.split('#'); + + // #/definitions/foo + // foo.json#/bar + if(parts[0] && ref.indexOf('/') === 0) { + + } + else if(parts[0] && (parts[0].indexOf('http:') === 0 || parts[0].indexOf('https:') === 0)) { + lroot = parts[0]; + ref = parts[1]; + } + else if(parts[0] && parts[0].length > 0) { + // relative file + sp = root.split('/'); + lroot = ''; + for(i = 0; i < sp.length - 1; i++) { + lroot += sp[i] + '/'; + } + lroot += parts[0]; + } + else { - SwaggerClient.prototype.fail = function (message) { - this.failure(message); + } - throw message; - }; - },{ - './auth': 2,'./helpers': 4,'./http': 5,'./resolver': 6,'./spec-converter': 8,'./types/model': 9,'./types/operation': 10,'./types/operationGroup': 11,'lodash-compat/array/indexOf': 52,'lodash-compat/collection/find': 56,'lodash-compat/collection/forEach': 57,'lodash-compat/function/bind': 61,'lodash-compat/lang/cloneDeep': 141,'lodash-compat/lang/isArray': 143,'lodash-compat/lang/isFunction': 145,'lodash-compat/lang/isObject': 147,'lodash-compat/lang/isPlainObject': 148,'lodash-compat/lang/isUndefined': 151 - }],4: [function (require, module, exports) { - (function (process) { - 'use strict'; + location = parts[1]; + } + else if (ref.indexOf('http:') === 0 || ref.indexOf('https:') === 0) { + lroot = ref; + location = ''; + } + else { + // relative file + sp = root.split('/'); + lroot = ''; + for(i = 0; i < sp.length - 1; i++) { + lroot += sp[i] + '/'; + } + lroot += ref; + location = ''; + } + resolutionTable.push({ + obj: property, resolveAs: 'ref', root: lroot, key: ref, location: location + }); + } else if (property.type === 'array') { + var items = property.items; + this.resolveTo(root, items, resolutionTable, location); + } else { + if(property && (property.properties || property.additionalProperties)) { + var name = this.uniqueName('inline_model'); + if (property.title) { + name = this.uniqueName(property.title); + } + delete property.title; + this.spec.definitions[name] = _.cloneDeep(property); + property.$ref = '#/definitions/' + name; + delete property.type; + delete property.properties; + } + } +}; + +Resolver.prototype.uniqueName = function(base) { + var name = base; + var count = 0; + while(true) { + if(!_.isObject(this.spec.definitions[name])) { + return name; + } + name = base + '_' + count; + count++; + } +}; + +Resolver.prototype.resolveAllOf = function(spec, obj, depth) { + depth = depth || 0; + obj = obj || spec; + var name; + for(var key in obj) { + if (!obj.hasOwnProperty(key)) { + continue; + } + var item = obj[key]; + if(item === null) { + throw new TypeError('Swagger 2.0 does not support null types (' + obj + '). See https://github.com/swagger-api/swagger-spec/issues/229.'); + } + if(typeof item === 'object') { + this.resolveAllOf(spec, item, depth + 1); + } + if(item && typeof item.allOf !== 'undefined') { + var allOf = item.allOf; + if(_.isArray(allOf)) { + var output = _.cloneDeep(item); + delete output.allOf; + + output['x-composed'] = true; + if (typeof item['x-resolved-from'] !== 'undefined') { + output['x-resolved-from'] = item['x-resolved-from']; + } - var _ = { - isPlainObject: require('lodash-compat/lang/isPlainObject'), - indexOf: require('lodash-compat/array/indexOf') - }; - - module.exports.__bind = function (fn, me) { - return function () { - return fn.apply(me, arguments); - }; - }; - - var log = module.exports.log = function () { - // Only log if available and we're not testing - if (console && process.env.NODE_ENV !== 'test') { - console.log(Array.prototype.slice.call(arguments)[0]); - } - }; + for(var i = 0; i < allOf.length; i++) { + var component = allOf[i]; + var source = 'self'; + if(typeof component['x-resolved-from'] !== 'undefined') { + source = component['x-resolved-from'][0]; + } + + for(var part in component) { + if(!output.hasOwnProperty(part)) { + output[part] = _.cloneDeep(component[part]); + if(part === 'properties') { + for(name in output[part]) { + output[part][name]['x-resolved-from'] = source; + } + } + } + else { + if(part === 'properties') { + var properties = component[part]; + for(name in properties) { + output.properties[name] = _.cloneDeep(properties[name]); + var resolvedFrom = properties[name]['x-resolved-from']; + if (typeof resolvedFrom === 'undefined' || resolvedFrom === 'self') { + resolvedFrom = source; + } + output.properties[name]['x-resolved-from'] = resolvedFrom; + } + } + else if(part === 'required') { + // merge & dedup the required array + var a = output.required.concat(component[part]); + for(var k = 0; k < a.length; ++k) { + for(var j = k + 1; j < a.length; ++j) { + if(a[k] === a[j]) { a.splice(j--, 1); } + } + } + output.required = a; + } + else if(part === 'x-resolved-from') { + output['x-resolved-from'].push(source); + } + else { + // TODO: need to merge this property + // console.log('what to do with ' + part) + } + } + } + } + obj[key] = output; + } + } + } +}; + +},{"./http":5,"lodash-compat/lang/cloneDeep":138,"lodash-compat/lang/isArray":140,"lodash-compat/lang/isObject":144,"lodash-compat/lang/isString":146}],7:[function(require,module,exports){ +'use strict'; + +var Helpers = require('./helpers'); + +var _ = { + isPlainObject: require('lodash-compat/lang/isPlainObject'), + isUndefined: require('lodash-compat/lang/isUndefined'), + isArray: require('lodash-compat/lang/isArray'), + isObject: require('lodash-compat/lang/isObject'), + isEmpty: require('lodash-compat/lang/isEmpty'), + map: require('lodash-compat/collection/map'), + indexOf: require('lodash-compat/array/indexOf'), + cloneDeep: require('lodash-compat/lang/cloneDeep'), + keys: require('lodash-compat/object/keys'), + forEach: require('lodash-compat/collection/forEach') +}; + +var optionHtml = module.exports.optionHtml = function (label, value) { + return '' + label + ':' + value + ''; +}; + +module.exports.typeFromJsonSchema = function (type, format) { + var str; + + if (type === 'integer' && format === 'int32') { + str = 'integer'; + } else if (type === 'integer' && format === 'int64') { + str = 'long'; + } else if (type === 'integer' && typeof format === 'undefined') { + str = 'long'; + } else if (type === 'string' && format === 'date-time') { + str = 'date-time'; + } else if (type === 'string' && format === 'date') { + str = 'date'; + } else if (type === 'number' && format === 'float') { + str = 'float'; + } else if (type === 'number' && format === 'double') { + str = 'double'; + } else if (type === 'number' && typeof format === 'undefined') { + str = 'double'; + } else if (type === 'boolean') { + str = 'boolean'; + } else if (type === 'string') { + str = 'string'; + } + + return str; +}; + +var getStringSignature = module.exports.getStringSignature = function (obj, baseComponent) { + var str = ''; + + if (typeof obj.$ref !== 'undefined') { + str += Helpers.simpleRef(obj.$ref); + } else if (typeof obj.type === 'undefined') { + str += 'object'; + } else if (obj.type === 'array') { + if (baseComponent) { + str += getStringSignature((obj.items || obj.$ref || {})); + } else { + str += 'Array['; + str += getStringSignature((obj.items || obj.$ref || {})); + str += ']'; + } + } else if (obj.type === 'integer' && obj.format === 'int32') { + str += 'integer'; + } else if (obj.type === 'integer' && obj.format === 'int64') { + str += 'long'; + } else if (obj.type === 'integer' && typeof obj.format === 'undefined') { + str += 'long'; + } else if (obj.type === 'string' && obj.format === 'date-time') { + str += 'date-time'; + } else if (obj.type === 'string' && obj.format === 'date') { + str += 'date'; + } else if (obj.type === 'string' && typeof obj.format === 'undefined') { + str += 'string'; + } else if (obj.type === 'number' && obj.format === 'float') { + str += 'float'; + } else if (obj.type === 'number' && obj.format === 'double') { + str += 'double'; + } else if (obj.type === 'number' && typeof obj.format === 'undefined') { + str += 'double'; + } else if (obj.type === 'boolean') { + str += 'boolean'; + } else if (obj.$ref) { + str += Helpers.simpleRef(obj.$ref); + } else { + str += obj.type; + } + + return str; +}; + +var schemaToJSON = module.exports.schemaToJSON = function (schema, models, modelsToIgnore, modelPropertyMacro) { + // Resolve the schema (Handle nested schemas) + schema = Helpers.resolveSchema(schema); + + if(typeof modelPropertyMacro !== 'function') { + modelPropertyMacro = function(prop){ + return (prop || {}).default; + }; + } + + modelsToIgnore= modelsToIgnore || {}; + + var type = schema.type || 'object'; + var format = schema.format; + var model; + var output; + + if (!_.isUndefined(schema.example)) { + output = schema.example; + } else if (_.isUndefined(schema.items) && _.isArray(schema.enum)) { + output = schema.enum[0]; + } + + if (_.isUndefined(output)) { + if (schema.$ref) { + model = models[Helpers.simpleRef(schema.$ref)]; + + if (!_.isUndefined(model)) { + if (_.isUndefined(modelsToIgnore[model.name])) { + modelsToIgnore[model.name] = model; + output = schemaToJSON(model.definition, models, modelsToIgnore, modelPropertyMacro); + delete modelsToIgnore[model.name]; + } else { + if (model.type === 'array') { + output = []; + } else { + output = {}; + } + } + } + } else if (!_.isUndefined(schema.default)) { + output = schema.default; + } else if (type === 'string') { + if (format === 'date-time') { + output = new Date().toISOString(); + } else if (format === 'date') { + output = new Date().toISOString().split('T')[0]; + } else { + output = 'string'; + } + } else if (type === 'integer') { + output = 0; + } else if (type === 'number') { + output = 0.0; + } else if (type === 'boolean') { + output = true; + } else if (type === 'object') { + output = {}; + + _.forEach(schema.properties, function (property, name) { + var cProperty = _.cloneDeep(property); + + // Allow macro to set the default value + cProperty.default = modelPropertyMacro(property); + + output[name] = schemaToJSON(cProperty, models, modelsToIgnore, modelPropertyMacro); + }); + } else if (type === 'array') { + output = []; + + if (_.isArray(schema.items)) { + _.forEach(schema.items, function (item) { + output.push(schemaToJSON(item, models, modelsToIgnore, modelPropertyMacro)); + }); + } else if (_.isPlainObject(schema.items)) { + output.push(schemaToJSON(schema.items, models, modelsToIgnore, modelPropertyMacro)); + } else if (_.isUndefined(schema.items)) { + output.push({}); + } else { + Helpers.log('Array type\'s \'items\' property is not an array or an object, cannot process'); + } + } + } + + return output; +}; + +module.exports.schemaToHTML =function (name, schema, models, modelPropertyMacro) { + var strongOpen = ''; + var strongClose = ''; + + // Allow for ignoring the 'name' argument.... shifting the rest + if(_.isObject(arguments[0])) { + name = void 0; + schema = arguments[0]; + models = arguments[1]; + modelPropertyMacro = arguments[2]; + } + + models = models || {}; + + // Resolve the schema (Handle nested schemas) + schema = Helpers.resolveSchema(schema); + + // Return for empty object + if(_.isEmpty(schema)) { + return strongOpen + 'Empty' + strongClose; + } + + // Dereference $ref from 'models' + if(typeof schema.$ref === 'string') { + name = Helpers.simpleRef(schema.$ref); + schema = models[name]; + if(typeof schema === 'undefined') + { + return strongOpen + name + ' is not defined!' + strongClose; + } + } - module.exports.fail = function (message) { - log(message); - }; + if(typeof name !== 'string') { + name = schema.title || 'Inline Model'; + } - var optionHtml = module.exports.optionHtml = function (label, value) { - return '' + label + ':' + value + ''; - }; + // If we are a Model object... adjust accordingly + if(schema.definition) { + schema = schema.definition; + } - var resolveSchema = module.exports.resolveSchema = function (schema) { - if (_.isPlainObject(schema.schema)) { - schema = resolveSchema(schema.schema); - } + if(typeof modelPropertyMacro !== 'function') { + modelPropertyMacro = function(prop){ + return (prop || {}).default; + }; + } - return schema; - }; + var references = {}; + var seenModels = []; + var inlineModels = 0; - var simpleRef = module.exports.simpleRef = function (name) { - if (typeof name === 'undefined') { - return null; - } - if (name.indexOf('#/definitions/') === 0) { - return name.substring('#/definitions/'.length); - } - return name; + // Generate current HTML + var html = processModel(schema, name); - }; + // Generate references HTML + while (_.keys(references).length > 0) { + /* jshint ignore:start */ + _.forEach(references, function (schema, name) { + var seenModel = _.indexOf(seenModels, name) > -1; - }).call(this, require('_process')); - //# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImxpYi9oZWxwZXJzLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsImZpbGUiOiJnZW5lcmF0ZWQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlc0NvbnRlbnQiOlsiJ3VzZSBzdHJpY3QnO1xuXG52YXIgXyA9IHtcbiAgaXNQbGFpbk9iamVjdDogcmVxdWlyZSgnbG9kYXNoLWNvbXBhdC9sYW5nL2lzUGxhaW5PYmplY3QnKSxcbiAgaW5kZXhPZjogcmVxdWlyZSgnbG9kYXNoLWNvbXBhdC9hcnJheS9pbmRleE9mJylcbn07XG5cbm1vZHVsZS5leHBvcnRzLl9fYmluZCA9IGZ1bmN0aW9uIChmbiwgbWUpIHtcbiAgcmV0dXJuIGZ1bmN0aW9uKCl7XG4gICAgcmV0dXJuIGZuLmFwcGx5KG1lLCBhcmd1bWVudHMpO1xuICB9O1xufTtcblxudmFyIGxvZyA9IG1vZHVsZS5leHBvcnRzLmxvZyA9IGZ1bmN0aW9uKCkge1xuICAvLyBPbmx5IGxvZyBpZiBhdmFpbGFibGUgYW5kIHdlJ3JlIG5vdCB0ZXN0aW5nXG4gIGlmIChjb25zb2xlICYmIHByb2Nlc3MuZW52Lk5PREVfRU5WICE9PSAndGVzdCcpIHtcbiAgICBjb25zb2xlLmxvZyhBcnJheS5wcm90b3R5cGUuc2xpY2UuY2FsbChhcmd1bWVudHMpWzBdKTtcbiAgfVxufTtcblxubW9kdWxlLmV4cG9ydHMuZmFpbCA9IGZ1bmN0aW9uIChtZXNzYWdlKSB7XG4gIGxvZyhtZXNzYWdlKTtcbn07XG5cbnZhciBvcHRpb25IdG1sID0gbW9kdWxlLmV4cG9ydHMub3B0aW9uSHRtbCA9IGZ1bmN0aW9uIChsYWJlbCwgdmFsdWUpIHtcbiAgcmV0dXJuICc8dHI+PHRkIGNsYXNzPVwib3B0aW9uTmFtZVwiPicgKyBsYWJlbCArICc6PC90ZD48dGQ+JyArIHZhbHVlICsgJzwvdGQ+PC90cj4nO1xufTtcblxudmFyIHJlc29sdmVTY2hlbWEgPSBtb2R1bGUuZXhwb3J0cy5yZXNvbHZlU2NoZW1hID0gZnVuY3Rpb24gKHNjaGVtYSkge1xuICBpZiAoXy5pc1BsYWluT2JqZWN0KHNjaGVtYS5zY2hlbWEpKSB7XG4gICAgc2NoZW1hID0gcmVzb2x2ZVNjaGVtYShzY2hlbWEuc2NoZW1hKTtcbiAgfVxuXG4gIHJldHVybiBzY2hlbWE7XG59O1xuXG52YXIgc2ltcGxlUmVmID0gbW9kdWxlLmV4cG9ydHMuc2ltcGxlUmVmID0gZnVuY3Rpb24gKG5hbWUpIHtcbiAgaWYgKHR5cGVvZiBuYW1lID09PSAndW5kZWZpbmVkJykge1xuICAgIHJldHVybiBudWxsO1xuICB9XG5cbiAgaWYgKG5hbWUuaW5kZXhPZignIy9kZWZpbml0aW9ucy8nKSA9PT0gMCkge1xuICAgIHJldHVybiBuYW1lLnN1YnN0cmluZygnIy9kZWZpbml0aW9ucy8nLmxlbmd0aCk7XG4gIH0gZWxzZSB7XG4gICAgcmV0dXJuIG5hbWU7XG4gIH1cbn07XG5cbiJdfQ== - },{ - '_process': 17,'lodash-compat/array/indexOf': 52,'lodash-compat/lang/isPlainObject': 148 - }],5: [function (require, module, exports) { - 'use strict'; + delete references[name]; - var helpers = require('./helpers'); - var jQuery = require('jquery'); - var request = require('superagent'); - var jsyaml = require('js-yaml'); - var _ = { - isObject: require('lodash-compat/lang/isObject') - }; + if (!seenModel) { + seenModels.push(name); - /* - * JQueryHttpClient is a light-weight, node or browser HTTP client - */ - var JQueryHttpClient = function () {}; + html += '
        ' + processModel(schema, name); + } + }); + /* jshint ignore:end */ + } - /* - * SuperagentHttpClient is a light-weight, node or browser HTTP client - */ - var SuperagentHttpClient = function () {}; + return html; - /** - * SwaggerHttp is a wrapper for executing requests - */ - var SwaggerHttp = module.exports = function () {}; + ///////////////////////////////// - SwaggerHttp.prototype.execute = function (obj, opts) { - var client; + function addReference(schema, name, skipRef) { + var modelName = name; + var model; - if (opts && opts.client) { - client = opts.client; - } else { - client = new SuperagentHttpClient(opts); - } + if (schema.$ref) { + modelName = schema.title || Helpers.simpleRef(schema.$ref); + model = models[modelName]; + } else if (_.isUndefined(name)) { + modelName = schema.title || 'Inline Model ' + (++inlineModels); + model = {definition: schema}; + } - // legacy support - if (obj && obj.useJQuery === true || this.isInternetExplorer()) { - client = new JQueryHttpClient(opts); - } + if (skipRef !== true) { + references[modelName] = _.isUndefined(model) ? {} : model.definition; + } - var success = obj.on.response; + return modelName; + } + + function primitiveToHTML(schema) { + var html = ''; + var type = schema.type || 'object'; + + if (schema.$ref) { + html += addReference(schema, Helpers.simpleRef(schema.$ref)); + } else if (type === 'object') { + if (!_.isUndefined(schema.properties)) { + html += addReference(schema); + } else { + html += 'object'; + } + } else if (type === 'array') { + html += 'Array['; + + if (_.isArray(schema.items)) { + html += _.map(schema.items, addReference).join(','); + } else if (_.isPlainObject(schema.items)) { + if (_.isUndefined(schema.items.$ref)) { + if (!_.isUndefined(schema.items.type) && _.indexOf(['array', 'object'], schema.items.type) === -1) { + html += schema.items.type; + } else { + html += addReference(schema.items); + } + } else { + html += addReference(schema.items, Helpers.simpleRef(schema.items.$ref)); + } + } else { + Helpers.log('Array type\'s \'items\' schema is not an array or an object, cannot process'); + html += 'object'; + } + + html += ']'; + } else { + html += schema.type; + } - var responseInterceptor = function (data) { - if (opts && opts.responseInterceptor) { - data = opts.responseInterceptor.apply(data); - } - success(data); - }; - - obj.on.response = function (data) { - responseInterceptor(data); - }; - - if (_.isObject(obj) && _.isObject(obj.body)) { - // special processing for file uploads via jquery - if (obj.body.type && obj.body.type === 'formData') { - obj.contentType = false; - obj.processData = false; - - delete obj.headers['Content-Type']; - } else { - obj.body = JSON.stringify(obj.body); - } - } - client.execute(obj); - }; + html += ''; - SwaggerHttp.prototype.isInternetExplorer = function () { - var detectedIE = false; + return html; + } - if (typeof navigator !== 'undefined' && navigator.userAgent) { - var nav = navigator.userAgent.toLowerCase(); + function primitiveToOptionsHTML(schema, html) { + var options = ''; + var type = schema.type || 'object'; + var isArray = type === 'array'; - if (nav.indexOf('msie') !== -1) { - var version = parseInt(nav.split('msie')[1]); + if (isArray) { + if (_.isPlainObject(schema.items) && !_.isUndefined(schema.items.type)) { + type = schema.items.type; + } else { + type = 'object'; + } + } - if (version <= 8) { - detectedIE = true; - } - } - } + if (!_.isUndefined(schema.default)) { + options += optionHtml('Default', schema.default); + } - return detectedIE; - }; + switch (type) { + case 'string': + if (schema.minLength) { + options += optionHtml('Min. Length', schema.minLength); + } + + if (schema.maxLength) { + options += optionHtml('Max. Length', schema.maxLength); + } + + if (schema.pattern) { + options += optionHtml('Reg. Exp.', schema.pattern); + } + break; + case 'integer': + case 'number': + if (schema.minimum) { + options += optionHtml('Min. Value', schema.minimum); + } + + if (schema.exclusiveMinimum) { + options += optionHtml('Exclusive Min.', 'true'); + } + + if (schema.maximum) { + options += optionHtml('Max. Value', schema.maximum); + } + + if (schema.exclusiveMaximum) { + options += optionHtml('Exclusive Max.', 'true'); + } + + if (schema.multipleOf) { + options += optionHtml('Multiple Of', schema.multipleOf); + } + + break; + } - JQueryHttpClient.prototype.execute = function (obj) { - var cb = obj.on; - var request = obj; - - obj.type = obj.method; - obj.cache = false; - delete obj.useJQuery; - - /* - obj.beforeSend = function (xhr) { - var key, results; - if (obj.headers) { - results = []; - for (key in obj.headers) { - if (key.toLowerCase() === 'content-type') { - results.push(obj.contentType = obj.headers[key]); - } else if (key.toLowerCase() === 'accept') { - results.push(obj.accepts = obj.headers[key]); - } else { - results.push(xhr.setRequestHeader(key, obj.headers[key])); - } - } - return results; - } - };*/ - - obj.data = obj.body; - - delete obj.body; - - obj.complete = function (response) { - var headers = {}; - var headerArray = response.getAllResponseHeaders().split('\n'); - - for (var i = 0; i < headerArray.length; i++) { - var toSplit = headerArray[i].trim(); - - if (toSplit.length === 0) { - continue; - } + if (isArray) { + if (schema.minItems) { + options += optionHtml('Min. Items', schema.minItems); + } - var separator = toSplit.indexOf(':'); + if (schema.maxItems) { + options += optionHtml('Max. Items', schema.maxItems); + } - if (separator === -1) { - // Name but no value in the header - headers[toSplit] = null; + if (schema.uniqueItems) { + options += optionHtml('Unique Items', 'true'); + } - continue; - } + if (schema.collectionFormat) { + options += optionHtml('Coll. Format', schema.collectionFormat); + } + } - var name = toSplit.substring(0, separator).trim(); - var value = toSplit.substring(separator + 1).trim(); + if (_.isUndefined(schema.items)) { + if (_.isArray(schema.enum)) { + var enumString; - headers[name] = value; - } + if (type === 'number' || type === 'integer') { + enumString = schema.enum.join(', '); + } else { + enumString = '"' + schema.enum.join('", "') + '"'; + } - var out = { - url: request.url, - method: request.method, - status: response.status, - statusText: response.statusText, - data: response.responseText, - headers: headers - }; - - try { - var possibleObj = response.responseJSON || jsyaml.safeLoad(response.responseText); - - out.obj = typeof possibleObj === 'string' ? {} : possibleObj; - } catch (ex) { - // do not set out.obj - helpers.log('unable to parse JSON/YAML content'); - } + options += optionHtml('Enum', enumString); + } + } - // I can throw, or parse null? - out.obj = out.obj || null; + if (options.length > 0) { + html = '' + html + '' + options + '
        ' + type + '
        '; + } - if (response.status >= 200 && response.status < 300) { - cb.response(out); - } else if (response.status === 0 || response.status >= 400 && response.status < 599) { - cb.error(out); - } else { - return cb.response(out); - } - }; + return html; + } - jQuery.support.cors = true; + function processModel(schema, name) { + var type = schema.type || 'object'; + var isArray = schema.type === 'array'; + var html = strongOpen + name + ' ' + (isArray ? '[' : '{') + strongClose; - return jQuery.ajax(obj); - }; + if (name) { + seenModels.push(name); + } - SuperagentHttpClient.prototype.execute = function (obj) { - var method = obj.method.toLowerCase(); + if (isArray) { + if (_.isArray(schema.items)) { + html += '
        ' + _.map(schema.items, function (item) { + var type = item.type || 'object'; + + if (_.isUndefined(item.$ref)) { + if (_.indexOf(['array', 'object'], type) > -1) { + if (type === 'object' && _.isUndefined(item.properties)) { + return 'object'; + } else { + return addReference(item); + } + } else { + return primitiveToOptionsHTML(item, type); + } + } else { + return addReference(item, Helpers.simpleRef(item.$ref)); + } + }).join(',
        '); + } else if (_.isPlainObject(schema.items)) { + if (_.isUndefined(schema.items.$ref)) { + if (_.indexOf(['array', 'object'], schema.items.type || 'object') > -1) { + if ((_.isUndefined(schema.items.type) || schema.items.type === 'object') && _.isUndefined(schema.items.properties)) { + html += '
        object
        '; + } else { + html += '
        ' + addReference(schema.items) + '
        '; + } + } else { + html += '
        ' + primitiveToOptionsHTML(schema.items, schema.items.type) + '
        '; + } + } else { + html += '
        ' + addReference(schema.items, Helpers.simpleRef(schema.items.$ref)) + '
        '; + } + } else { + Helpers.log('Array type\'s \'items\' property is not an array or an object, cannot process'); + html += '
        object
        '; + } + } else { + if (schema.$ref) { + html += '
        ' + addReference(schema, name) + '
        '; + } else if (type === 'object') { + if (_.isPlainObject(schema.properties)) { + var contents = _.map(schema.properties, function (property, name) { + var propertyIsRequired = (_.indexOf(schema.required, name) >= 0); + var cProperty = _.cloneDeep(property); + + var requiredClass = propertyIsRequired ? 'required' : ''; + var html = '' + name + ' ('; + var model; + var propDescription; + + // Allow macro to set the default value + cProperty.default = modelPropertyMacro(cProperty); + + // Resolve the schema (Handle nested schemas) + cProperty = Helpers.resolveSchema(cProperty); + + propDescription = property.description || cProperty.description; + + // We need to handle property references to primitives (Issue 339) + if (!_.isUndefined(cProperty.$ref)) { + model = models[Helpers.simpleRef(cProperty.$ref)]; + + if (!_.isUndefined(model) && _.indexOf([undefined, 'array', 'object'], model.definition.type) === -1) { + // Use referenced schema + cProperty = Helpers.resolveSchema(model.definition); + } + } - if (method === 'delete') { - method = 'del'; - } - var headers = obj.headers || {}; - var r = request[method](obj.url); - var name; + html += primitiveToHTML(cProperty); - for (name in headers) { - r.set(name, headers[name]); - } + if(!propertyIsRequired) { + html += ', optional'; + } - if (obj.body) { - r.send(obj.body); - } + if(property.readOnly) { + html += ', read only'; + } - if (typeof r.buffer === 'function') { - r.buffer(); // force superagent to populate res.text with the raw response data - } + html += ')'; - r.end(function (err, res) { - res = res || { - status: 0, - headers: { - error: 'no response from server' - } - }; - var response = { - url: obj.url, - method: obj.method, - headers: res.headers - }; - var cb; - - if (!err && res.error) { - err = res.error; - } + if (!_.isUndefined(propDescription)) { + html += ': ' + '' + propDescription + ''; + } - if (err && obj.on && obj.on.error) { - response.obj = err; - response.status = res ? res.status : 500; - response.statusText = res ? res.text : err.message; - cb = obj.on.error; - } else if (res && obj.on && obj.on.response) { - var possibleObj; - - // Already parsed by by superagent? - if (res.body && Object.keys(res.body).length > 0) { - possibleObj = res.body; - } else { - try { - possibleObj = jsyaml.safeLoad(res.text); - // can parse into a string... which we don't need running around in the system - possibleObj = typeof possibleObj === 'string' ? null : possibleObj; - } catch (e) { - helpers.log('cannot parse JSON/YAML content'); - } - } + if (cProperty.enum) { + html += ' = [\'' + cProperty.enum.join('\', \'') + '\']'; + } - // null means we can't parse into object - response.obj = possibleObj || null; + return '' + primitiveToOptionsHTML(cProperty, html); + }).join(',
        '); - response.status = res.status; - response.statusText = res.text; - cb = obj.on.response; - } - response.data = response.statusText; + if (contents) { + html += contents + '
        '; + } + } + } else { + html += '
        ' + primitiveToOptionsHTML(schema, type) + '
        '; + } + } - if (cb) { - cb(response); - } - }); - }; + return html + strongOpen + (isArray ? ']' : '}') + strongClose; + } +}; +},{"./helpers":4,"lodash-compat/array/indexOf":49,"lodash-compat/collection/forEach":54,"lodash-compat/collection/map":56,"lodash-compat/lang/cloneDeep":138,"lodash-compat/lang/isArray":140,"lodash-compat/lang/isEmpty":141,"lodash-compat/lang/isObject":144,"lodash-compat/lang/isPlainObject":145,"lodash-compat/lang/isUndefined":148,"lodash-compat/object/keys":149}],8:[function(require,module,exports){ +'use strict'; - },{ - './helpers': 4,'jquery': 20,'js-yaml': 21,'lodash-compat/lang/isObject': 147,'superagent': 160 - }],6: [function (require, module, exports) { - 'use strict'; +var SwaggerHttp = require('./http'); +var _ = { + isObject: require('lodash-compat/lang/isObject') +}; - var SwaggerHttp = require('./http'); - var _ = { - isObject: require('lodash-compat/lang/isObject'), - isArray: require('lodash-compat/lang/isArray') - }; +var SwaggerSpecConverter = module.exports = function () { + this.errors = []; + this.warnings = []; + this.modelMap = {}; +}; +SwaggerSpecConverter.prototype.setDocumentationLocation = function (location) { + this.docLocation = location; +}; - /** - * Resolves a spec's remote references - */ - var Resolver = module.exports = function () {}; - - Resolver.prototype.resolve = function (spec, arg1, arg2, arg3) { - var root = arg1, - callback = arg2, - scope = arg3, - location, i; - - if (typeof arg1 === 'function') { - root = null; - callback = arg1; - scope = arg2; - } - var _root = root; +/** + * converts a resource listing OR api declaration + **/ +SwaggerSpecConverter.prototype.convert = function (obj, clientAuthorizations, opts, callback) { + // not a valid spec + if(!obj || !Array.isArray(obj.apis)) { + return this.finish(callback, null); + } + this.clientAuthorizations = clientAuthorizations; + + // create a new swagger object to return + var swagger = { swagger: '2.0' }; + + swagger.originalVersion = obj.swaggerVersion; + + // add the info + this.apiInfo(obj, swagger); + + // add security definitions + this.securityDefinitions(obj, swagger); + + // take basePath into account + if (obj.basePath) { + this.setDocumentationLocation(obj.basePath); + } + + // see if this is a single-file swagger definition + var isSingleFileSwagger = false; + var i; + for(i = 0; i < obj.apis.length; i++) { + var api = obj.apis[i]; + if(Array.isArray(api.operations)) { + isSingleFileSwagger = true; + } + } + if(isSingleFileSwagger) { + this.declaration(obj, swagger); + this.finish(callback, swagger); + } + else { + this.resourceListing(obj, swagger, opts, callback); + } +}; + +SwaggerSpecConverter.prototype.declaration = function(obj, swagger) { + var name, i, p, pos; + if(!obj.apis) { + return; + } + + if (obj.basePath.indexOf('http://') === 0) { + p = obj.basePath.substring('http://'.length); + pos = p.indexOf('/'); + if (pos > 0) { + swagger.host = p.substring(0, pos); + swagger.basePath = p.substring(pos); + } + else { + swagger.host = p; + swagger.basePath = '/'; + } + } else if (obj.basePath.indexOf('https://') === 0) { + p = obj.basePath.substring('https://'.length); + pos = p.indexOf('/'); + if (pos > 0) { + swagger.host = p.substring(0, pos); + swagger.basePath = p.substring(pos); + } + else { + swagger.host = p; + swagger.basePath = '/'; + } + } else { + swagger.basePath = obj.basePath; + } + + var resourceLevelAuth; + if(obj.authorizations) { + resourceLevelAuth = obj.authorizations; + } + if(obj.consumes) { + swagger.consumes = obj.consumes; + } + if(obj.produces) { + swagger.produces = obj.produces; + } + + // build a mapping of id to name for 1.0 model resolutions + if(_.isObject(obj)) { + for(name in obj.models) { + var existingModel = obj.models[name]; + var key = (existingModel.id || name); + this.modelMap[key] = name; + } + } + + for(i = 0; i < obj.apis.length; i++) { + var api = obj.apis[i]; + var path = api.path; + var operations = api.operations; + this.operations(path, obj.resourcePath, operations, resourceLevelAuth, swagger); + } + + var models = obj.models || {}; + this.models(models, swagger); +}; + +SwaggerSpecConverter.prototype.models = function(obj, swagger) { + if(!_.isObject(obj)) { + return; + } + var name; + + swagger.definitions = swagger.definitions || {}; + for(name in obj) { + var existingModel = obj[name]; + var _required = []; + var schema = { properties: {}}; + var propertyName; + for(propertyName in existingModel.properties) { + var existingProperty = existingModel.properties[propertyName]; + var property = {}; + this.dataType(existingProperty, property); + if(existingProperty.description) { + property.description = existingProperty.description; + } + if(existingProperty['enum']) { + property['enum'] = existingProperty['enum']; + } + if(typeof existingProperty.required === 'boolean' && existingProperty.required === true) { + _required.push(propertyName); + } + if(typeof existingProperty.required === 'string' && existingProperty.required === 'true') { + _required.push(propertyName); + } + schema.properties[propertyName] = property; + } + if(_required.length > 0) { + schema.required = _required; + } else { + schema.required = existingModel.required; + } + swagger.definitions[name] = schema; + } +}; + +SwaggerSpecConverter.prototype.extractTag = function(resourcePath) { + var pathString = resourcePath || 'default'; + if(pathString.indexOf('http:') === 0 || pathString.indexOf('https:') === 0) { + pathString = pathString.split(['/']); + pathString = pathString[pathString.length -1].substring(); + } + if(pathString.endsWith('.json')) { + pathString = pathString.substring(0, pathString.length - '.json'.length); + } + return pathString.replace('/',''); +}; + +SwaggerSpecConverter.prototype.operations = function(path, resourcePath, obj, resourceLevelAuth, swagger) { + if(!Array.isArray(obj)) { + return; + } + var i; + + if(!swagger.paths) { + swagger.paths = {}; + } + + var pathObj = swagger.paths[path] || {}; + var tag = this.extractTag(resourcePath); + swagger.tags = swagger.tags || []; + var matched = false; + for(i = 0; i < swagger.tags.length; i++) { + var tagObject = swagger.tags[i]; + if(tagObject.name === tag) { + matched = true; + } + } + if(!matched) { + swagger.tags.push({name: tag}); + } + + for(i = 0; i < obj.length; i++) { + var existingOperation = obj[i]; + var method = (existingOperation.method || existingOperation.httpMethod).toLowerCase(); + var operation = {tags: [tag]}; + var existingAuthorizations = existingOperation.authorizations; + + if(existingAuthorizations && Object.keys(existingAuthorizations).length === 0) { + existingAuthorizations = resourceLevelAuth; + } - this.scope = scope || this; - this.iteration = this.iteration || 0; + if(typeof existingAuthorizations !== 'undefined') { + var scopesObject; + for(var key in existingAuthorizations) { + operation.security = operation.security || []; + var scopes = existingAuthorizations[key]; + if(scopes) { + var securityScopes = []; + for(var j in scopes) { + securityScopes.push(scopes[j].scope); + } + scopesObject = {}; + scopesObject[key] = securityScopes; + operation.security.push(scopesObject); + } + else { + scopesObject = {}; + scopesObject[key] = []; + operation.security.push(scopesObject); + } + } + } - var name, path, property, propertyName; - var processedCalls = 0, - resolvedRefs = {}, - unresolvedRefs = {}; - var resolutionTable = []; // store objects for dereferencing + if(existingOperation.consumes) { + operation.consumes = existingOperation.consumes; + } + else if(swagger.consumes) { + operation.consumes = swagger.consumes; + } + if(existingOperation.produces) { + operation.produces = existingOperation.produces; + } + else if(swagger.produces) { + operation.produces = swagger.produces; + } + if(existingOperation.summary) { + operation.summary = existingOperation.summary; + } + if(existingOperation.notes) { + operation.description = existingOperation.notes; + } + if(existingOperation.nickname) { + operation.operationId = existingOperation.nickname; + } + if(existingOperation.deprecated) { + operation.deprecated = existingOperation.deprecated; + } - // definitions - for (name in spec.definitions) { - var definition = spec.definitions[name]; + this.authorizations(existingAuthorizations, swagger); + this.parameters(operation, existingOperation.parameters, swagger); + this.responseMessages(operation, existingOperation, swagger); + + pathObj[method] = operation; + } + + swagger.paths[path] = pathObj; +}; + +SwaggerSpecConverter.prototype.responseMessages = function(operation, existingOperation) { + if(!_.isObject(existingOperation)) { + return; + } + // build default response from the operation (1.x) + var defaultResponse = {}; + this.dataType(existingOperation, defaultResponse); + // TODO: look into the real problem of rendering responses in swagger-ui + // ....should reponseType have an implicit schema? + if(!defaultResponse.schema && defaultResponse.type) { + defaultResponse = {schema: defaultResponse}; + } + + operation.responses = operation.responses || {}; + + // grab from responseMessages (1.2) + var has200 = false; + if(Array.isArray(existingOperation.responseMessages)) { + var i; + var existingResponses = existingOperation.responseMessages; + for(i = 0; i < existingResponses.length; i++) { + var existingResponse = existingResponses[i]; + var response = { description: existingResponse.message }; + if(existingResponse.code === 200) { + has200 = true; + } + // Convert responseModel -> schema{$ref: responseModel} + if(existingResponse.responseModel) { + response.schema = {'$ref': '#/definitions/' + existingResponse.responseModel}; + } + operation.responses['' + existingResponse.code] = response; + } + } + + if(has200) { + operation.responses['default'] = defaultResponse; + } + else { + operation.responses['200'] = defaultResponse; + } +}; + +SwaggerSpecConverter.prototype.authorizations = function(obj) { + // TODO + if(!_.isObject(obj)) { + return; + } +}; + +SwaggerSpecConverter.prototype.parameters = function(operation, obj) { + if(!Array.isArray(obj)) { + return; + } + var i; + for(i = 0; i < obj.length; i++) { + var existingParameter = obj[i]; + var parameter = {}; + parameter.name = existingParameter.name; + parameter.description = existingParameter.description; + parameter.required = existingParameter.required; + parameter.in = existingParameter.paramType; + + // per #168 + if(parameter.in === 'body') { + parameter.name = 'body'; + } + if(parameter.in === 'form') { + parameter.in = 'formData'; + } - for (propertyName in definition.properties) { - property = definition.properties[propertyName]; - this.resolveTo(root, property, resolutionTable, '/definitions'); - } + if(existingParameter.enum) { + parameter.enum = existingParameter.enum; + } - if (definition.allOf) { - definition['x-resolved-from'] = ['#/definitions/' + name]; - var allOf = definition.allOf; - // the refs go first + if(existingParameter.allowMultiple === true || existingParameter.allowMultiple === 'true') { + var innerType = {}; + this.dataType(existingParameter, innerType); + parameter.type = 'array'; + parameter.items = innerType; - allOf.sort(function (a, b) { - if (a.$ref && b.$ref) { - return 0; - } else if (a.$ref) { - return -1; - } + if(existingParameter.allowableValues) { + var av = existingParameter.allowableValues; + if(av.valueType === 'LIST') { + parameter['enum'] = av.values; + } + } + } + else { + this.dataType(existingParameter, parameter); + } + if(typeof existingParameter.defaultValue !== 'undefined') { + parameter.default = existingParameter.defaultValue; + } - return 1; - }); + operation.parameters = operation.parameters || []; + operation.parameters.push(parameter); + } +}; + +SwaggerSpecConverter.prototype.dataType = function(source, target) { + if(!_.isObject(source)) { + return; + } + + if(source.minimum) { + target.minimum = source.minimum; + } + if(source.maximum) { + target.maximum = source.maximum; + } + if (source.format) { + target.format = source.format; + } + + // default can be 'false' + if(typeof source.defaultValue !== 'undefined') { + target.default = source.defaultValue; + } + + var jsonSchemaType = this.toJsonSchema(source); + if(jsonSchemaType) { + target = target || {}; + if(jsonSchemaType.type) { + target.type = jsonSchemaType.type; + } + if(jsonSchemaType.format) { + target.format = jsonSchemaType.format; + } + if(jsonSchemaType.$ref) { + target.schema = {$ref: jsonSchemaType.$ref}; + } + if(jsonSchemaType.items) { + target.items = jsonSchemaType.items; + } + } +}; + +SwaggerSpecConverter.prototype.toJsonSchema = function(source) { + if(!source) { + return 'object'; + } + var detectedType = (source.type || source.dataType || source.responseClass || ''); + var lcType = detectedType.toLowerCase(); + var format = (source.format || '').toLowerCase(); + + if(lcType.indexOf('list[') === 0) { + var innerType = detectedType.substring(5, detectedType.length - 1); + var jsonType = this.toJsonSchema({type: innerType}); + return {type: 'array', items: jsonType}; + } else if(lcType === 'int' || (lcType === 'integer' && format === 'int32')) { + {return {type: 'integer', format: 'int32'};} + } else if(lcType === 'long' || (lcType === 'integer' && format === 'int64')) { + {return {type: 'integer', format: 'int64'};} + } else if(lcType === 'integer') { + {return {type: 'integer', format: 'int64'};} + } else if(lcType === 'float' || (lcType === 'number' && format === 'float')) { + {return {type: 'number', format: 'float'};} + } else if(lcType === 'double' || (lcType === 'number' && format === 'double')) { + {return {type: 'number', format: 'double'};} + } else if((lcType === 'string' && format === 'date-time') || (lcType === 'date')) { + {return {type: 'string', format: 'date-time'};} + } else if(lcType === 'string') { + {return {type: 'string'};} + } else if(lcType === 'file') { + {return {type: 'file'};} + } else if(lcType === 'boolean') { + {return {type: 'boolean'};} + } else if(lcType === 'boolean') { + {return {type: 'boolean'};} + } else if(lcType === 'array' || lcType === 'list') { + if(source.items) { + var it = this.toJsonSchema(source.items); + return {type: 'array', items: it}; + } + else { + return {type: 'array', items: {type: 'object'}}; + } + } else if(source.$ref) { + return {$ref: this.modelMap[source.$ref] ? '#/definitions/' + this.modelMap[source.$ref] : source.$ref}; + } else if(lcType === 'void' || lcType === '') { + {return {};} + } else if (this.modelMap[source.type]) { + // If this a model using `type` instead of `$ref`, that's fine. + return {$ref: '#/definitions/' + this.modelMap[source.type]}; + } else { + // Unknown model type or 'object', pass it along. + return {type: source.type}; + } +}; + +SwaggerSpecConverter.prototype.resourceListing = function(obj, swagger, opts, callback) { + var i; + var processedCount = 0; // jshint ignore:line + var self = this; // jshint ignore:line + var expectedCount = obj.apis.length; + var _swagger = swagger; // jshint ignore:line + var _opts = {}; + + if(opts && opts.requestInterceptor){ + _opts.requestInterceptor = opts.requestInterceptor; + } + + if(opts && opts.responseInterceptor){ + _opts.responseInterceptor = opts.responseInterceptor; + } + + var swaggerRequestHeaders = 'application/json'; + + if(opts && opts.swaggerRequestHeaders) { + swaggerRequestHeaders = opts.swaggerRequestHeaders; + } + + if(expectedCount === 0) { + this.finish(callback, swagger); + } + + for(i = 0; i < expectedCount; i++) { + var api = obj.apis[i]; + var path = api.path; + var absolutePath = this.getAbsolutePath(obj.swaggerVersion, this.docLocation, path); + + if(api.description) { + swagger.tags = swagger.tags || []; + swagger.tags.push({ + name : this.extractTag(api.path), + description : api.description || '' + }); + } + var http = { + url: absolutePath, + headers: { accept: swaggerRequestHeaders }, + on: {}, + method: 'get', + timeout: opts.timeout + }; + /* jshint ignore:start */ + http.on.response = function(data) { + processedCount += 1; + var obj = data.obj; + if(obj) { + self.declaration(obj, _swagger); + } + if(processedCount === expectedCount) { + self.finish(callback, _swagger); + } + }; + http.on.error = function(data) { + console.error(data); + processedCount += 1; + if(processedCount === expectedCount) { + self.finish(callback, _swagger); + } + }; + /* jshint ignore:end */ - for (i = 0; i < allOf.length; i++) { - property = allOf[i]; - location = '/definitions/' + name + '/allOf'; - this.resolveInline(null, spec, property, resolutionTable, unresolvedRefs, location); - } - } - } + if(this.clientAuthorizations && typeof this.clientAuthorizations.apply === 'function') { + this.clientAuthorizations.apply(http); + } - // operations - for (name in spec.paths) { - var method, operation, responseCode; + new SwaggerHttp().execute(http, _opts); + } +}; + +SwaggerSpecConverter.prototype.getAbsolutePath = function(version, docLocation, path) { + if(version === '1.0') { + if(docLocation.endsWith('.json')) { + // get root path + var pos = docLocation.lastIndexOf('/'); + if(pos > 0) { + docLocation = docLocation.substring(0, pos); + } + } + } + + var location = docLocation; + if(path.indexOf('http:') === 0 || path.indexOf('https:') === 0) { + location = path; + } + else { + if(docLocation.endsWith('/')) { + location = docLocation.substring(0, docLocation.length - 1); + } + location += path; + } + location = location.replace('{format}', 'json'); + return location; +}; + +SwaggerSpecConverter.prototype.securityDefinitions = function(obj, swagger) { + if(obj.authorizations) { + var name; + for(name in obj.authorizations) { + var isValid = false; + var securityDefinition = { + vendorExtensions: {} + }; + var definition = obj.authorizations[name]; + if(definition.type === 'apiKey') { + securityDefinition.type = 'apiKey'; + securityDefinition.in = definition.passAs; + securityDefinition.name = definition.keyname || name; + isValid = true; + } + else if(definition.type === 'basicAuth') { + securityDefinition.type = 'basicAuth'; + isValid = true; + } + else if(definition.type === 'oauth2') { + var existingScopes = definition.scopes || []; + var scopes = {}; + var i; + for(i in existingScopes) { + var scope = existingScopes[i]; + scopes[scope.scope] = scope.description; + } + securityDefinition.type = 'oauth2'; + if(i > 0) { + securityDefinition.scopes = scopes; + } + if(definition.grantTypes) { + if(definition.grantTypes.implicit) { + var implicit = definition.grantTypes.implicit; + securityDefinition.flow = 'implicit'; + securityDefinition.authorizationUrl = implicit.loginEndpoint; + isValid = true; + } + /* jshint ignore:start */ + if(definition.grantTypes['authorization_code']) { + if(!securityDefinition.flow) { + // cannot set if flow is already defined + var authCode = definition.grantTypes['authorization_code']; + securityDefinition.flow = 'accessCode'; + securityDefinition.authorizationUrl = authCode.tokenRequestEndpoint.url; + securityDefinition.tokenUrl = authCode.tokenEndpoint.url; + isValid = true; + } + } + /* jshint ignore:end */ + } + } + if(isValid) { + swagger.securityDefinitions = swagger.securityDefinitions || {}; + swagger.securityDefinitions[name] = securityDefinition; + } + } + } +}; + +SwaggerSpecConverter.prototype.apiInfo = function(obj, swagger) { + // info section + if(obj.info) { + var info = obj.info; + swagger.info = {}; + + if(info.contact) { + swagger.info.contact = {}; + swagger.info.contact.email = info.contact; + } + if(info.description) { + swagger.info.description = info.description; + } + if(info.title) { + swagger.info.title = info.title; + } + if(info.termsOfServiceUrl) { + swagger.info.termsOfService = info.termsOfServiceUrl; + } + if(info.license || info.licenseUrl) { + swagger.license = {}; + if(info.license) { + swagger.license.name = info.license; + } + if(info.licenseUrl) { + swagger.license.url = info.licenseUrl; + } + } + } + else { + this.warnings.push('missing info section'); + } +}; + +SwaggerSpecConverter.prototype.finish = function (callback, obj) { + callback(obj); +}; + +},{"./http":5,"lodash-compat/lang/isObject":144}],9:[function(require,module,exports){ +'use strict'; + +var log = require('../helpers').log; +var _ = { + isPlainObject: require('lodash-compat/lang/isPlainObject'), + isString: require('lodash-compat/lang/isString'), +}; + +var SchemaMarkup = require('../schema-markup.js'); +var jsyaml = require('js-yaml'); + +var Model = module.exports = function (name, definition, models, modelPropertyMacro) { + this.definition = definition || {}; + this.isArray = definition.type === 'array'; + this.models = models || {}; + this.name = name || definition.title || 'Inline Model'; + this.modelPropertyMacro = modelPropertyMacro || function (property) { + return property.default; + }; + + return this; +}; + +// Note! This function will be removed in 2.2.x! +Model.prototype.createJSONSample = Model.prototype.getSampleValue = function (modelsToIgnore) { + modelsToIgnore = modelsToIgnore || {}; + + modelsToIgnore[this.name] = this; + + // Response support + if (this.examples && _.isPlainObject(this.examples) && this.examples['application/json']) { + this.definition.example = this.examples['application/json']; + + if (_.isString(this.definition.example)) { + this.definition.example = jsyaml.safeLoad(this.definition.example); + } + } else if (!this.definition.example) { + this.definition.example = this.examples; + } + + return SchemaMarkup.schemaToJSON(this.definition, this.models, modelsToIgnore, this.modelPropertyMacro); +}; + +Model.prototype.getMockSignature = function () { + return SchemaMarkup.schemaToHTML(this.name, this.definition, this.models, this.modelPropertyMacro); +}; + +},{"../helpers":4,"../schema-markup.js":7,"js-yaml":19,"lodash-compat/lang/isPlainObject":145,"lodash-compat/lang/isString":146}],10:[function(require,module,exports){ +'use strict'; + +var _ = { + cloneDeep: require('lodash-compat/lang/cloneDeep'), + isUndefined: require('lodash-compat/lang/isUndefined'), + isEmpty: require('lodash-compat/lang/isEmpty'), + isObject: require('lodash-compat/lang/isObject') +}; +var helpers = require('../helpers'); +var Model = require('./model'); +var SwaggerHttp = require('../http'); +var Q = require('q'); + +var Operation = module.exports = function (parent, scheme, operationId, httpMethod, path, args, definitions, models, clientAuthorizations) { + var errors = []; + + parent = parent || {}; + args = args || {}; + + if(parent && parent.options) { + this.client = parent.options.client || null; + this.requestInterceptor = parent.options.requestInterceptor || null; + this.responseInterceptor = parent.options.responseInterceptor || null; + this.requestAgent = parent.options.requestAgent; + } + this.authorizations = args.security; + this.basePath = parent.basePath || '/'; + this.clientAuthorizations = clientAuthorizations; + this.consumes = args.consumes || parent.consumes || ['application/json']; + this.produces = args.produces || parent.produces || ['application/json']; + this.deprecated = args.deprecated; + this.description = args.description; + this.host = parent.host; + this.method = (httpMethod || errors.push('Operation ' + operationId + ' is missing method.')); + this.models = models || {}; + this.nickname = (operationId || errors.push('Operations must have a nickname.')); + this.operation = args; + this.operations = {}; + this.parameters = args !== null ? (args.parameters || []) : {}; + this.parent = parent; + this.path = (path || errors.push('Operation ' + this.nickname + ' is missing path.')); + this.responses = (args.responses || {}); + this.scheme = scheme || parent.scheme || 'http'; + this.schemes = args.schemes || parent.schemes; + this.security = args.security || parent.security; + this.summary = args.summary || ''; + this.timeout = parent.timeout; + this.type = null; + this.useJQuery = parent.useJQuery; + this.jqueryAjaxCache = parent.jqueryAjaxCache; + this.enableCookies = parent.enableCookies; + + var key; + + if(!this.host) { + if(typeof window !== 'undefined') { + this.host = window.location.host; + } + else { + this.host = 'localhost'; + } + } + this.parameterMacro = parent.parameterMacro || function (operation, parameter) { + return parameter.default; + }; + + this.inlineModels = []; + + if(this.basePath !== '/' && this.basePath.slice(-1) === '/') { + this.basePath = this.basePath.slice(0, -1); + } + + if (typeof this.deprecated === 'string') { + switch(this.deprecated.toLowerCase()) { + case 'true': case 'yes': case '1': { + this.deprecated = true; + break; + } + + case 'false': case 'no': case '0': case null: { + this.deprecated = false; + break; + } + + default: this.deprecated = Boolean(this.deprecated); + } + } - path = spec.paths[name]; + var i, model; - for (method in path) { - // operation reference - if (method === '$ref') { - // location = path[method]; - location = '/paths' + name; - this.resolveInline(root, spec, path, resolutionTable, unresolvedRefs, location); - } else { - operation = path[method]; + if (definitions) { + // add to global models + for (key in definitions) { + model = new Model(key, definitions[key], this.models, parent.modelPropertyMacro); - var parameters = operation.parameters; + if (model) { + this.models[key] = model; + } + } + } + else { + definitions = {}; + } - for (i in parameters) { - var parameter = parameters[i]; + for (i = 0; i < this.parameters.length; i++) { + var d, param = this.parameters[i]; - location = '/paths' + name + '/' + method + '/parameters'; + // Allow macro to set the default value + param.default = this.parameterMacro(this, param); - if (parameter.in === 'body' && parameter.schema) { - this.resolveTo(root, parameter.schema, resolutionTable, location); - } + if (param.type === 'array') { + param.isList = true; + param.allowMultiple = true; + } - if (parameter.$ref) { - // parameter reference - this.resolveInline(root, spec, parameter, resolutionTable, unresolvedRefs, parameter.$ref); - } - } + var innerType = this.getType(param); - for (responseCode in operation.responses) { - var response = operation.responses[responseCode]; + if (innerType && innerType.toString().toLowerCase() === 'boolean') { + param.allowableValues = {}; + param.isList = true; + param['enum'] = [true, false]; // use actual primitives + } - location = '/paths' + name + '/' + method + '/responses/' + responseCode; + for(key in param) { + helpers.extractExtensions(key, param); + } + if(typeof param['x-example'] !== 'undefined') { + d = param['x-example']; + param.default = d; + } + if(param['x-examples']) { + d = param['x-examples'].default; + if(typeof d !== 'undefined') { + param.default = d; + } + } - if (_.isObject(response)) { - if (response.$ref) { - // response reference - this.resolveInline(root, spec, response, resolutionTable, unresolvedRefs, location); - } + var enumValues = param['enum'] || (param.items && param.items['enum']); - if (response.schema) { - this.resolveTo(root, response.schema, resolutionTable, location); - } - } - } - } - } - } + if (typeof enumValues !== 'undefined') { + var id; - var expectedCalls = 0, - toResolve = []; - // if the root is same as obj[i].root we can resolve locally - var all = resolutionTable; - - for (i = 0; i < all.length; i++) { - var a = all[i]; - - if (root === a.root) { - if (a.resolveAs === 'ref') { - // resolve any path walking - var joined = ((a.root || '') + '/' + a.key).split('/'); - var normalized = []; - var url = ''; - var k; - - if (a.key.indexOf('../') >= 0) { - for (var j = 0; j < joined.length; j++) { - if (joined[j] === '..') { - normalized = normalized.slice(0, normalized.length - 1); - } else { - normalized.push(joined[j]); - } - } + param.allowableValues = {}; + param.allowableValues.values = []; + param.allowableValues.descriptiveValues = []; - for (k = 0; k < normalized.length; k++) { - if (k > 0) { - url += '/'; - } - url += normalized[k]; - } - // we now have to remote resolve this because the path has changed - a.root = url; - toResolve.push(a); - } else { - var parts = a.key.split('#'); - - if (parts.length === 2) { - if (parts[0].indexOf('http://') === 0 || parts[0].indexOf('https://') === 0) { - a.root = parts[0]; - } - location = parts[1].split('/'); - var r; - var s = spec; - - for (k = 0; k < location.length; k++) { - var part = location[k]; - - if (part !== '') { - s = s[part]; - - if (typeof s !== 'undefined') { - r = s; - } else { - r = null; - break; - } - } - } - - if (r === null) { - // must resolve this too - toResolve.push(a); - } - } - } - } else if (a.resolveAs === 'inline') { - toResolve.push(a); - } - } else { - toResolve.push(a); - } - } - expectedCalls = toResolve.length; - - // resolve anything that is local - for (var ii = 0; ii < toResolve.length; ii++) { - (function (item, self) { - if (item.root === null) { - // local resolve - self.resolveItem(spec, _root, resolutionTable, resolvedRefs, unresolvedRefs, item); - processedCalls += 1; - - if (processedCalls === expectedCalls) { - self.finish(spec, root, resolutionTable, resolvedRefs, unresolvedRefs, callback); - } - } else { - var obj = { - useJQuery: false, // TODO - url: item.root, - method: 'get', - headers: { - accept: self.scope.swaggerRequestHeaders || 'application/json' - }, - on: { - error: function () { - processedCalls += 1; - unresolvedRefs[item.key] = null; - - if (processedCalls === expectedCalls) { - self.finish(spec, _root, resolutionTable, resolvedRefs, unresolvedRefs, callback); - } - }, // jshint ignore:line - response: function (response) { - var swagger = response.obj; - - self.resolveItem(swagger, _root, resolutionTable, resolvedRefs, unresolvedRefs, item); - processedCalls += 1; - - if (processedCalls === expectedCalls) { - self.finish(spec, _root, resolutionTable, resolvedRefs, unresolvedRefs, callback); - } - } - } // jshint ignore:line - }; - - if (scope && scope.clientAuthorizations) { - scope.clientAuthorizations.apply(obj); - } - new SwaggerHttp().execute(obj); - } - }(toResolve[ii], this)); - } + for (id = 0; id < enumValues.length; id++) { + var value = enumValues[id]; + var isDefault = (value === param.default || value+'' === param.default); - if (Object.keys(toResolve).length === 0) { - this.finish(spec, _root, resolutionTable, resolvedRefs, unresolvedRefs, callback); - } - }; + param.allowableValues.values.push(value); + // Always have string for descriptive values.... + param.allowableValues.descriptiveValues.push({value : value+'', isDefault: isDefault}); + } + } - Resolver.prototype.resolveItem = function (spec, root, resolutionTable, resolvedRefs, unresolvedRefs, item) { - var path = item.location; - var location = spec, - parts = path.split('/'); + if (param.type === 'array') { + innerType = [innerType]; - for (var j = 0; j < parts.length; j++) { - var segment = parts[j]; + if (typeof param.allowableValues === 'undefined') { + // can't show as a list if no values to select from + delete param.isList; + delete param.allowMultiple; + } + } - if (segment.indexOf('~1') !== -1) { - segment = parts[j].replace(/~0/g, '~').replace(/~1/g, '/'); + param.modelSignature = {type: innerType, definitions: this.models}; + param.signature = this.getModelSignature(innerType, this.models).toString(); + param.sampleJSON = this.getModelSampleJSON(innerType, this.models); + param.responseClassSignature = param.signature; + } + + var keyname, defaultResponseCode, response, responses = this.responses; + + if (responses['200']) { + response = responses['200']; + defaultResponseCode = '200'; + } else if (responses['201']) { + response = responses['201']; + defaultResponseCode = '201'; + } else if (responses['202']) { + response = responses['202']; + defaultResponseCode = '202'; + } else if (responses['203']) { + response = responses['203']; + defaultResponseCode = '203'; + } else if (responses['204']) { + response = responses['204']; + defaultResponseCode = '204'; + } else if (responses['205']) { + response = responses['205']; + defaultResponseCode = '205'; + } else if (responses['206']) { + response = responses['206']; + defaultResponseCode = '206'; + } else if (responses['default']) { + response = responses['default']; + defaultResponseCode = 'default'; + } + + for(keyname in responses) { + helpers.extractExtensions(keyname, responses); + if(typeof keyname === 'string' && keyname.indexOf('x-') === -1) { + var responseObject = responses[keyname]; + if(typeof responseObject === 'object' && typeof responseObject.headers === 'object') { + var headers = responseObject.headers; + for(var headerName in headers) { + var header = headers[headerName]; + if(typeof header === 'object') { + for(var headerKey in header) { + helpers.extractExtensions(headerKey, header); + } + } + } + } + } + } - if (segment.charAt(0) !== '/') { - segment = '/' + segment; - } - } + if (response) { + for(keyname in response) { + helpers.extractExtensions(keyname, response); + } + } + + if (response && response.schema) { + var resolvedModel = this.resolveModel(response.schema, definitions); + var successResponse; + + delete responses[defaultResponseCode]; + + if (resolvedModel) { + this.successResponse = {}; + successResponse = this.successResponse[defaultResponseCode] = resolvedModel; + } else if (!response.schema.type || response.schema.type === 'object' || response.schema.type === 'array') { + // Inline model + this.successResponse = {}; + successResponse = this.successResponse[defaultResponseCode] = new Model(undefined, response.schema || {}, this.models, parent.modelPropertyMacro); + } else { + // Primitive + this.successResponse = {}; + successResponse = this.successResponse[defaultResponseCode] = response.schema; + } - if (typeof location === 'undefined' || location === null) { - break; - } + if (successResponse) { + successResponse.vendorExtensions = response.vendorExtensions; + // Attach response properties + if (response.description) { + successResponse.description = response.description; + } - if (segment === '' && j === parts.length - 1 && parts.length > 1) { - location = null; - break; - } + if (response.examples) { + successResponse.examples = response.examples; + } - if (segment.length > 0) { - location = location[segment]; - } - } - var resolved = item.key; + if (response.headers) { + successResponse.headers = response.headers; + } + } - parts = item.key.split('/'); - var resolvedName = parts[parts.length - 1]; + this.type = response; + } - if (resolvedName.indexOf('#') >= 0) { - resolvedName = resolvedName.split('#')[1]; - } + if (errors.length > 0) { + if (this.resource && this.resource.api && this.resource.api.fail) { + this.resource.api.fail(errors); + } + } + + return this; +}; + +Operation.prototype.isDefaultArrayItemValue = function(value, param) { + if (param.default && Array.isArray(param.default)) { + return param.default.indexOf(value) !== -1; + } + return value === param.default; +}; + +Operation.prototype.getType = function (param) { + var type = param.type; + var format = param.format; + var isArray = false; + var str; + + if (type === 'integer' && format === 'int32') { + str = 'integer'; + } else if (type === 'integer' && format === 'int64') { + str = 'long'; + } else if (type === 'integer') { + str = 'integer'; + } else if (type === 'string') { + if (format === 'date-time') { + str = 'date-time'; + } else if (format === 'date') { + str = 'date'; + } else { + str = 'string'; + } + } else if (type === 'number' && format === 'float') { + str = 'float'; + } else if (type === 'number' && format === 'double') { + str = 'double'; + } else if (type === 'number') { + str = 'double'; + } else if (type === 'boolean') { + str = 'boolean'; + } else if (type === 'array') { + isArray = true; + + if (param.items) { + str = this.getType(param.items); + } + } else if (type === 'file') { + str = 'file'; + } + + if (param.$ref) { + str = helpers.simpleRef(param.$ref); + } + + var schema = param.schema; + + if (schema) { + var ref = schema.$ref; + + if (ref) { + ref = helpers.simpleRef(ref); + + if (isArray) { + return [ ref ]; + } else { + return ref; + } + } else { + // If inline schema, we add it our interal hash -> which gives us it's ID (int) + if(schema.type === 'object') { + return this.addInlineModel(schema); + } + return this.getType(schema); + } + } + if (isArray) { + return [ str ]; + } else { + return str; + } +}; - if (location !== null && typeof location !== 'undefined') { - resolvedRefs[resolved] = { - name: resolvedName, - obj: location, - key: item.key, - root: item.root - }; - } else { - unresolvedRefs[resolved] = { - root: item.root, - location: item.location - }; - } - }; +/** + * adds an inline schema (model) to a hash, where we can ref it later + * @param {object} schema a schema + * @return {number} the ID of the schema being added, or null + **/ +Operation.prototype.addInlineModel = function (schema) { + var len = this.inlineModels.length; + var model = this.resolveModel(schema, {}); + if(model) { + this.inlineModels.push(model); + return 'Inline Model '+len; // return string ref of the inline model (used with #getInlineModel) + } + return null; // report errors? +}; - Resolver.prototype.finish = function (spec, root, resolutionTable, resolvedRefs, unresolvedRefs, callback) { - // walk resolution table and replace with resolved refs - var ref; +/** + * gets the internal ref to an inline model + * @param {string} inline_str a string reference to an inline model + * @return {Model} the model being referenced. Or null + **/ +Operation.prototype.getInlineModel = function(inlineStr) { + if(/^Inline Model \d+$/.test(inlineStr)) { + var id = parseInt(inlineStr.substr('Inline Model'.length).trim(),10); // + var model = this.inlineModels[id]; + return model; + } + // I'm returning null here, should I rather throw an error? + return null; +}; + +Operation.prototype.resolveModel = function (schema, definitions) { + if (typeof schema.$ref !== 'undefined') { + var ref = schema.$ref; + + if (ref.indexOf('#/definitions/') === 0) { + ref = ref.substring('#/definitions/'.length); + } - for (ref in resolutionTable) { - var item = resolutionTable[ref]; + if (definitions[ref]) { + return new Model(ref, definitions[ref], this.models, this.parent.modelPropertyMacro); + } + // schema must at least be an object to get resolved to an inline Model + } else if (schema && typeof schema === 'object' && + (schema.type === 'object' || _.isUndefined(schema.type))) { + return new Model(undefined, schema, this.models, this.parent.modelPropertyMacro); + } + + return null; +}; + +Operation.prototype.help = function (dontPrint) { + var out = this.nickname + ': ' + this.summary + '\n'; + + for (var i = 0; i < this.parameters.length; i++) { + var param = this.parameters[i]; + var typeInfo = param.signature; + + out += '\n * ' + param.name + ' (' + typeInfo + '): ' + param.description; + } + + if (typeof dontPrint === 'undefined') { + helpers.log(out); + } + + return out; +}; + +Operation.prototype.getModelSignature = function (type, definitions) { + var isPrimitive, listType; + + if (type instanceof Array) { + listType = true; + type = type[0]; + } + + // Convert undefined to string of 'undefined' + if (typeof type === 'undefined') { + type = 'undefined'; + isPrimitive = true; + + } else if (definitions[type]){ + // a model def exists? + type = definitions[type]; /* Model */ + isPrimitive = false; + + } else if (this.getInlineModel(type)) { + type = this.getInlineModel(type); /* Model */ + isPrimitive = false; + + } else { + // We default to primitive + isPrimitive = true; + } + + if (isPrimitive) { + if (listType) { + return 'Array[' + type + ']'; + } else { + return type.toString(); + } + } else { + if (listType) { + return 'Array[' + type.getMockSignature() + ']'; + } else { + return type.getMockSignature(); + } + } +}; - var key = item.key; - var resolvedTo = resolvedRefs[key]; +Operation.prototype.supportHeaderParams = function () { + return true; +}; - if (resolvedTo) { - spec.definitions = spec.definitions || {}; +Operation.prototype.supportedSubmitMethods = function () { + return this.parent.supportedSubmitMethods; +}; - if (item.resolveAs === 'ref') { - spec.definitions[resolvedTo.name] = resolvedTo.obj; - item.obj.$ref = '#/definitions/' + resolvedTo.name; - } else if (item.resolveAs === 'inline') { - var targetObj = item.obj; +Operation.prototype.getHeaderParams = function (args) { + var headers = this.setContentTypes(args, {}); + var headerParamsByLowerCase = {}; - targetObj['x-resolved-from'] = [item.key]; - delete targetObj.$ref; + for (var i = 0; i < this.parameters.length; i++) { + var param = this.parameters[i]; - for (key in resolvedTo.obj) { - var abs = this.retainRoot(resolvedTo.obj[key], item.root); + if (param.in === 'header') { + headerParamsByLowerCase[param.name.toLowerCase()] = param; + } + } - targetObj[key] = abs; - } - } - } - } - var existingUnresolved = this.countUnresolvedRefs(spec); + for (var arg in args) { + var headerParam = headerParamsByLowerCase[arg.toLowerCase()]; + if (typeof headerParam !== 'undefined') { + var value = args[arg]; - if (existingUnresolved.length === 0 || this.iteration > 5) { - this.resolveAllOf(spec.definitions); - callback.call(this.scope, spec, unresolvedRefs); - } else { - this.iteration += 1; - this.resolve(spec, root, callback, this.scope); - } - }; + if (Array.isArray(value)) { + value = value.toString(); + } - Resolver.prototype.countUnresolvedRefs = function (spec) { - var i; - var refs = this.getRefs(spec); - var keys = []; - var unresolvedKeys = []; - - for (i in refs) { - if (i.indexOf('#') === 0) { - keys.push(i.substring(1)); - } else { - unresolvedKeys.push(i); - } - } + headers[headerParam.name] = value; + } + } - // verify possible keys - for (i = 0; i < keys.length; i++) { - var part = keys[i]; - var parts = part.split('/'); - var obj = spec; + return headers; +}; - for (var k = 0; k < parts.length; k++) { - var key = parts[k]; +Operation.prototype.urlify = function (args, maskPasswords) { + var formParams = {}; + var requestUrl = this.path.replace(/#.*/, ''); // remove URL fragment + var querystring = ''; // grab params from the args, build the querystring along the way - if (key !== '') { - obj = obj[key]; + for (var i = 0; i < this.parameters.length; i++) { + var param = this.parameters[i]; - if (typeof obj === 'undefined') { - unresolvedKeys.push(part); - break; - } - } - } - } + if (typeof args[param.name] !== 'undefined') { + var isPassword; + if(param.type === 'string' && param.format === 'password' && maskPasswords) { + isPassword = true; + } - return unresolvedKeys.length; - }; + if (param.in === 'path') { + var reg = new RegExp('\{' + param.name + '\}', 'gi'); + var value = args[param.name]; - Resolver.prototype.getRefs = function (spec, obj) { - obj = obj || spec; - var output = {}; + if (Array.isArray(value)) { + value = this.encodePathCollection(param.collectionFormat, param.name, value, isPassword); + } else { + value = this.encodePathParam(value, isPassword); + } - for (var key in obj) { - var item = obj[key]; + requestUrl = requestUrl.replace(reg, value); + } else if (param.in === 'query' && typeof args[param.name] !== 'undefined') { + if (querystring === '' && requestUrl.indexOf('?') < 0) { + querystring += '?'; + } else { + querystring += '&'; + } - if (key === '$ref' && typeof item === 'string') { - output[item] = null; - } else if (_.isObject(item)) { - var o = this.getRefs(item); + if (typeof param.collectionFormat !== 'undefined') { + var qp = args[param.name]; - for (var k in o) { - output[k] = null; - } - } - } + if (Array.isArray(qp)) { + querystring += this.encodeQueryCollection(param.collectionFormat, param.name, qp, isPassword); + } else { + querystring += this.encodeQueryKey(param.name) + '=' + this.encodeQueryParam(args[param.name], isPassword); + } + } else { + querystring += this.encodeQueryKey(param.name) + '=' + this.encodeQueryParam(args[param.name], isPassword); + } + } else if (param.in === 'formData') { + formParams[param.name] = args[param.name]; + } + } + } + var url = this.scheme + '://' + this.host; + + if (this.basePath !== '/') { + url += this.basePath; + } + return url + requestUrl + querystring; +}; + +Operation.prototype.getMissingParams = function (args) { + var missingParams = []; // check required params, track the ones that are missing + var i; + + for (i = 0; i < this.parameters.length; i++) { + var param = this.parameters[i]; + + if (param.required === true) { + if (typeof args[param.name] === 'undefined') { + missingParams = param.name; + } + } + } + + return missingParams; +}; + +Operation.prototype.getBody = function (headers, args, opts) { + var formParams = {}, hasFormParams, param, body, key, value, hasBody = false; + + // look at each param and put form params in an object + for (var i = 0; i < this.parameters.length; i++) { + param = this.parameters[i]; + if (typeof args[param.name] !== 'undefined') { + var isPassword; + if(param.type === 'string' && param.format === 'password') { + isPassword = 'password'; + } + if (param.in === 'body') { + body = args[param.name]; + } else if (param.in === 'formData') { + formParams[param.name] = { + param: param, + value: args[param.name], + password: isPassword + }; + hasFormParams = true; + } + } + else { + if(param.in === 'body') { + hasBody = true; + } + } + } - return output; - }; + // if body is null and hasBody is true, AND a JSON body is requested, send empty {} + if(hasBody && typeof body === 'undefined') { + var contentType = headers['Content-Type']; + if(contentType && contentType.indexOf('application/json') === 0) { + body = '{}'; + } + } + + var isMultiPart = false; + if(headers['Content-Type'] && headers['Content-Type'].indexOf('multipart/form-data') >= 0) { + isMultiPart = true; + } + + // handle form params + if (hasFormParams && !isMultiPart) { + var encoded = ''; + + for (key in formParams) { + param = formParams[key].param; + value = formParams[key].value; + var password; + + if(opts && opts.maskPasswords) { + password = formParams[key].password; + } + + if (typeof value !== 'undefined') { + if (Array.isArray(value)) { + if (encoded !== '') { + encoded += '&'; + } + encoded += this.encodeQueryCollection(param.collectionFormat, key, value, password); + } + else { + if (encoded !== '') { + encoded += '&'; + } - Resolver.prototype.retainRoot = function (obj, root) { - // walk object and look for relative $refs - for (var key in obj) { - var item = obj[key]; + encoded += encodeURIComponent(key) + '=' + mask(encodeURIComponent(value), password); + } + } + } - if (key === '$ref' && typeof item === 'string') { - // stop and inspect - if (item.indexOf('http://') !== 0 && item.indexOf('https://') !== 0) { - if (item.indexOf('#') !== 0) { - item = '#' + item; - } - item = (root || '') + item; - obj[key] = item; - } - } else if (_.isObject(item)) { - this.retainRoot(item, root); - } - } + body = encoded; + } else if (isMultiPart) { + var bodyParam; + if (typeof FormData === 'function') { + bodyParam = new FormData(); + + bodyParam.type = 'formData'; + + for (key in formParams) { + param = formParams[key].param; + value = args[key]; + + if (typeof value !== 'undefined') { + if({}.toString.apply(value) === '[object File]') { + bodyParam.append(key, value); + } + else if (value.type === 'file' && value.value) { + bodyParam.append(key, value.value); + } else { + if (Array.isArray(value)) { + if(param.collectionFormat === 'multi') { + bodyParam.delete(key); + for(var v in value) { + bodyParam.append(key, value[v]); + } + } + else { + bodyParam.append(key, this.encodeQueryCollection(param.collectionFormat, key, value).split('=').slice(1).join('=')); + } + } + else { + bodyParam.append(key, value); + } + } + } + } + body = bodyParam; + } + else { + bodyParam = {}; + for (key in formParams) { + value = args[key]; + if (Array.isArray(value)) { + var delimeter; + var format = param.collectionFormat || 'multi'; + if(format === 'ssv') { + delimeter = ' '; + } + else if(format === 'pipes') { + delimeter = '|'; + } + else if(format === 'tsv') { + delimeter = '\t'; + } + else if(format === 'multi') { + bodyParam[key] = value; + break; + } + else { + delimeter = ','; + } + var data; + value.forEach(function(v) { + if(data) { + data += delimeter; + } + else { + data = ''; + } + data += v; + }); + bodyParam[key] = data; + } + else { + bodyParam[key] = value; + } + } + body = bodyParam; + } + headers['Content-Type'] = 'multipart/form-data'; + } - return obj; - }; + return body; +}; - /** - * immediately in-lines local refs, queues remote refs - * for inline resolution - */ - Resolver.prototype.resolveInline = function (root, spec, property, resolutionTable, unresolvedRefs, location) { - var key = property.$ref, - ref = property.$ref, - i, p, p2, rs; - var rootTrimmed = false; - - if (ref) { - if (ref.indexOf('../') === 0) { - // reset root - p = ref.split('../'); - p2 = root.split('/'); - ref = ''; - - for (i = 0; i < p.length; i++) { - if (p[i] === '') { - p2 = p2.slice(0, p2.length - 1); - } else { - ref += p[i]; - } - } - root = ''; +/** + * gets sample response for a single operation + **/ +Operation.prototype.getModelSampleJSON = function (type, models) { + var listType, sampleJson, innerType; + models = models || {}; + + listType = (type instanceof Array); + innerType = listType ? type[0] : type; + + if(models[innerType]) { + sampleJson = models[innerType].createJSONSample(); + } else if (this.getInlineModel(innerType)){ + sampleJson = this.getInlineModel(innerType).createJSONSample(); // may return null, if type isn't correct + } + + + if (sampleJson) { + sampleJson = listType ? [sampleJson] : sampleJson; + + if (typeof sampleJson === 'string') { + return sampleJson; + } else if (_.isObject(sampleJson)) { + var t = sampleJson; + + if (sampleJson instanceof Array && sampleJson.length > 0) { + t = sampleJson[0]; + } + + if (t.nodeName && typeof t === 'Node') { + var xmlString = new XMLSerializer().serializeToString(t); + + return this.formatXml(xmlString); + } else { + return JSON.stringify(sampleJson, null, 2); + } + } else { + return sampleJson; + } + } +}; - for (i = 0; i < p2.length - 1; i++) { - if (i > 0) { - root += '/'; - } - root += p2[i]; - } - rootTrimmed = true; - } +/** + * legacy binding + **/ +Operation.prototype.do = function (args, opts, callback, error, parent) { + return this.execute(args, opts, callback, error, parent); +}; - if (ref.indexOf('#') >= 0) { - if (ref.indexOf('/') === 0) { - rs = ref.split('#'); - p = root.split('//'); - p2 = p[1].split('/'); - root = p[0] + '//' + p2[0] + rs[0]; - location = rs[1]; - } else { - rs = ref.split('#'); - - if (rs[0] !== '') { - p2 = root.split('/'); - p2 = p2.slice(0, p2.length - 1); - - if (!rootTrimmed) { - root = ''; - - for (var k = 0; k < p2.length; k++) { - if (k > 0) { - root += '/'; - } - root += p2[k]; - } - } - root += '/' + ref.split('#')[0]; - } - location = rs[1]; - } - } +/** + * executes an operation + **/ +Operation.prototype.execute = function (arg1, arg2, arg3, arg4, parent) { + var args = arg1 || {}; + var opts = {}, success, error, deferred, timeout; + + if (_.isObject(arg2)) { + opts = arg2; + success = arg3; + error = arg4; + } + + timeout = typeof opts.timeout !== 'undefined' ? opts.timeout : this.timeout; + + if(this.client) { + opts.client = this.client; + } + + if(this.requestAgent) { + opts.requestAgent = this.requestAgent; + } + + // add the request interceptor from parent, if none sent from client + if(!opts.requestInterceptor && this.requestInterceptor ) { + opts.requestInterceptor = this.requestInterceptor ; + } + + if(!opts.responseInterceptor && this.responseInterceptor) { + opts.responseInterceptor = this.responseInterceptor; + } + + if (typeof arg2 === 'function') { + success = arg2; + error = arg3; + } + + if (this.parent.usePromise) { + deferred = Q.defer(); + } else { + success = (success || this.parent.defaultSuccessCallback || helpers.log); + error = (error || this.parent.defaultErrorCallback || helpers.log); + } + + if (typeof opts.useJQuery === 'undefined') { + opts.useJQuery = this.useJQuery; + } + + if (typeof opts.jqueryAjaxCache === 'undefined') { + opts.jqueryAjaxCache = this.jqueryAjaxCache; + } + + if (typeof opts.enableCookies === 'undefined') { + opts.enableCookies = this.enableCookies; + } + + var missingParams = this.getMissingParams(args); + + if (missingParams.length > 0) { + var message = 'missing required params: ' + missingParams; + + helpers.fail(message); + + if (this.parent.usePromise) { + deferred.reject(message); + return deferred.promise; + } else { + error(message, parent); + return {}; + } + } + + var allHeaders = this.getHeaderParams(args); + var contentTypeHeaders = this.setContentTypes(args, opts); + var headers = {}, attrname; + + for (attrname in allHeaders) { headers[attrname] = allHeaders[attrname]; } + for (attrname in contentTypeHeaders) { headers[attrname] = contentTypeHeaders[attrname]; } + + var body = this.getBody(contentTypeHeaders, args, opts); + var url = this.urlify(args, opts.maskPasswords); + + if(url.indexOf('.{format}') > 0) { + if(headers) { + var format = headers.Accept || headers.accept; + if(format && format.indexOf('json') > 0) { + url = url.replace('.{format}', '.json'); + } + else if(format && format.indexOf('xml') > 0) { + url = url.replace('.{format}', '.xml'); + } + } + } + + var obj = { + url: url, + method: this.method.toUpperCase(), + body: body, + enableCookies: opts.enableCookies, + useJQuery: opts.useJQuery, + jqueryAjaxCache: opts.jqueryAjaxCache, + deferred: deferred, + headers: headers, + clientAuthorizations: opts.clientAuthorizations, + operation: this, + connectionAgent: this.connectionAgent, + on: { + response: function (response) { + if (deferred) { + deferred.resolve(response); + return deferred.promise; + } else { + return success(response, parent); + } + }, + error: function (response) { + if (deferred) { + deferred.reject(response); + return deferred.promise; + } else { + return error(response, parent); + } + } + } + }; + + if (timeout) { + obj.timeout = timeout; + } + + this.clientAuthorizations.apply(obj, this.operation.security); + if (opts.mock === true) { + return obj; + } else { + return new SwaggerHttp().execute(obj, opts); + } +}; + +function itemByPriority(col, itemPriority) { + + // No priorities? return first... + if(_.isEmpty(itemPriority)) { + return col[0]; + } + + for (var i = 0, len = itemPriority.length; i < len; i++) { + if(col.indexOf(itemPriority[i]) > -1) { + return itemPriority[i]; + } + } + + // Otherwise return first + return col[0]; +} + +Operation.prototype.setContentTypes = function (args, opts) { + // default type + var allDefinedParams = this.parameters; + var body; + var consumes = args.parameterContentType || itemByPriority(this.consumes, ['application/json', 'application/yaml']); + var accepts = opts.responseContentType || itemByPriority(this.produces, ['application/json', 'application/yaml']); + var definedFileParams = []; + var definedFormParams = []; + var headers = {}; + var i; + + // get params from the operation and set them in definedFileParams, definedFormParams, headers + for (i = 0; i < allDefinedParams.length; i++) { + var param = allDefinedParams[i]; + + if (param.in === 'formData') { + if (param.type === 'file') { + definedFileParams.push(param); + } else { + definedFormParams.push(param); + } + } else if (param.in === 'header' && opts) { + var key = param.name; + var headerValue = opts[param.name]; + + if (typeof opts[param.name] !== 'undefined') { + headers[key] = headerValue; + } + } else if (param.in === 'body' && typeof args[param.name] !== 'undefined') { + body = args[param.name]; + } + } + + // if there's a body, need to set the consumes header via requestContentType + var hasBody = body || definedFileParams.length || definedFormParams.length; + if (this.method === 'post' || this.method === 'put' || this.method === 'patch' || + ((this.method === 'delete' || this.method === 'get') && hasBody)) { + if (opts.requestContentType) { + consumes = opts.requestContentType; + } + // if any form params, content type must be set + if (definedFormParams.length > 0) { + consumes = undefined; + if (opts.requestContentType) { // override if set + consumes = opts.requestContentType; + } else if (definedFileParams.length > 0) { // if a file, must be multipart/form-data + consumes = 'multipart/form-data'; + } else { + if (this.consumes && this.consumes.length > 0) { + // use the consumes setting + for(var c in this.consumes) { + var chk = this.consumes[c]; + if(chk.indexOf('application/x-www-form-urlencoded') === 0 || chk.indexOf('multipart/form-data') === 0) { + consumes = chk; + } + } + } + } + if(typeof consumes === 'undefined') { + // default to x-www-from-urlencoded + consumes = 'application/x-www-form-urlencoded'; + } + } + } + else { + consumes = null; + } + + if (consumes && this.consumes) { + if (this.consumes.indexOf(consumes) === -1) { + helpers.log('server doesn\'t consume ' + consumes + ', try ' + JSON.stringify(this.consumes)); + } + } - if (ref.indexOf('http') === 0) { - if (ref.indexOf('#') >= 0) { - root = ref.split('#')[0]; - location = ref.split('#')[1]; - } else { - root = ref; - location = ''; - } - resolutionTable.push({ - obj: property, resolveAs: 'inline', root: root, key: key, location: location - }); - } else if (ref.indexOf('#') === 0) { - location = ref.split('#')[1]; - resolutionTable.push({ - obj: property, resolveAs: 'inline', root: root, key: key, location: location - }); - } else { - resolutionTable.push({ - obj: property, resolveAs: 'inline', root: root, key: key, location: location - }); - } - } else if (property.type === 'array') { - this.resolveTo(root, property.items, resolutionTable, location); - } - }; + if (!this.matchesAccept(accepts)) { + helpers.log('server can\'t produce ' + accepts); + } - Resolver.prototype.resolveTo = function (root, property, resolutionTable, location) { - var ref = property.$ref; + if ((consumes && body !== '') || (consumes === 'application/x-www-form-urlencoded')) { + headers['Content-Type'] = consumes; + } + else if(this.consumes && this.consumes.length > 0 && this.consumes[0] === 'application/x-www-form-urlencoded') { + headers['Content-Type'] = this.consumes[0]; + } - if (ref) { - if (ref.indexOf('#') >= 0) { - location = ref.split('#')[1]; - } - resolutionTable.push({ - obj: property, resolveAs: 'ref', root: root, key: ref, location: location - }); - } else if (property.type === 'array') { - var items = property.items; + if (accepts) { + headers.Accept = accepts; + } - this.resolveTo(root, items, resolutionTable, location); - } - }; + return headers; +}; - Resolver.prototype.resolveAllOf = function (spec, obj, depth) { - depth = depth || 0; - obj = obj || spec; - var name; +/** + * Returns true if the request accepts header matches anything in this.produces. + * If this.produces contains * / *, ignore the accept header. + * @param {string=} accepts The client request accept header. + * @return {boolean} + */ +Operation.prototype.matchesAccept = function(accepts) { + // no accepts or produces, no problem! + if (!accepts || !this.produces) { + return true; + } + return this.produces.indexOf(accepts) !== -1 || this.produces.indexOf('*/*') !== -1; +}; + +Operation.prototype.asCurl = function (args1, args2) { + var opts = {mock: true, maskPasswords: true}; + if (typeof args2 === 'object') { + for (var argKey in args2) { + opts[argKey] = args2[argKey]; + } + } + var obj = this.execute(args1, opts); - for (var key in obj) { - var item = obj[key]; + this.clientAuthorizations.apply(obj, this.operation.security); - if (item === null) { - throw new TypeError('Swagger 2.0 does not support null types (' + obj + '). See https://github.com/swagger-api/swagger-spec/issues/229.'); - } + var results = []; - if (typeof item === 'object') { - this.resolveAllOf(spec, item, depth + 1); - } + results.push('-X ' + this.method.toUpperCase()); - if (item && typeof item.allOf !== 'undefined') { - var allOf = item.allOf; + if (typeof obj.headers !== 'undefined') { + var key; - if (_.isArray(allOf)) { - var output = {}; + for (key in obj.headers) { + var value = obj.headers[key]; + if(typeof value === 'string'){ + value = value.replace(/\'/g, '\\u0027'); + } + results.push('--header \'' + key + ': ' + value + '\''); + } + } + var isFormData = false; + var isMultipart = false; + + var type = obj.headers['Content-Type']; + if(type && type.indexOf('application/x-www-form-urlencoded') === 0) { + isFormData = true; + } + else if (type && type.indexOf('multipart/form-data') === 0) { + isFormData = true; + isMultipart = true; + } + + if (obj.body) { + var body; + if (_.isObject(obj.body)) { + if(isMultipart) { + isMultipart = true; + // add the form data + for(var i = 0; i < this.parameters.length; i++) { + var parameter = this.parameters[i]; + if(parameter.in === 'formData') { + if (!body) { + body = ''; + } - output['x-composed'] = true; + var paramValue; + if(typeof FormData === 'function' && obj.body instanceof FormData) { + paramValue = obj.body.getAll(parameter.name); + } + else { + paramValue = obj.body[parameter.name]; + } + if (paramValue) { + if (parameter.type === 'file') { + if(paramValue.name) { + body += '-F ' + parameter.name + '=@"' + paramValue.name + '" '; + } + } + else { + if (Array.isArray(paramValue)) { + if(parameter.collectionFormat === 'multi') { + for(var v in paramValue) { + body += '-F ' + this.encodeQueryKey(parameter.name) + '=' + mask(paramValue[v], parameter.format) + ' '; + } + } + else { + body += '-F ' + this.encodeQueryCollection(parameter.collectionFormat, parameter.name, mask(paramValue, parameter.format)) + ' '; + } + } else { + body += '-F ' + this.encodeQueryKey(parameter.name) + '=' + mask(paramValue, parameter.format) + ' '; + } + } + } + } + } + } + if(!body) { + body = JSON.stringify(obj.body); + } + } else { + body = obj.body; + } + // escape @ => %40, ' => %27 + body = body.replace(/\'/g, '%27').replace(/\n/g, ' \\ \n '); - if (typeof item['x-resolved-from'] !== 'undefined') { - output['x-resolved-from'] = item['x-resolved-from']; - } - output.properties = {}; + if(!isFormData) { + // escape & => %26 + body = body.replace(/&/g, '%26'); + } + if(isMultipart) { + results.push(body); + } + else { + results.push('-d \'' + body.replace(/@/g, '%40') + '\''); + } + } + + return 'curl ' + (results.join(' ')) + ' \'' + obj.url + '\''; +}; + +Operation.prototype.encodePathCollection = function (type, name, value, maskPasswords) { + var encoded = ''; + var i; + var separator = ''; + + if (type === 'ssv') { + separator = '%20'; + } else if (type === 'tsv') { + separator = '%09'; + } else if (type === 'pipes') { + separator = '|'; + } else { + separator = ','; + } + + for (i = 0; i < value.length; i++) { + if (i === 0) { + encoded = this.encodeQueryParam(value[i], maskPasswords); + } else { + encoded += separator + this.encodeQueryParam(value[i], maskPasswords); + } + } - for (var i = 0; i < allOf.length; i++) { - var component = allOf[i]; - var source = 'self'; + return encoded; +}; - if (typeof component['x-resolved-from'] !== 'undefined') { - source = component['x-resolved-from'][0]; - } +Operation.prototype.encodeQueryCollection = function (type, name, value, maskPasswords) { + var encoded = ''; + var i; - for (var part in component) { - if (!output.hasOwnProperty(part)) { - output[part] = JSON.parse(JSON.stringify(component[part])); - - if (part === 'properties') { - for (name in output[part]) { - output[part][name]['x-resolved-from'] = source; - } - } - } else if (part === 'properties') { - var properties = component[part]; - - for (name in properties) { - output.properties[name] = JSON.parse(JSON.stringify(properties[name])); - var resolvedFrom = properties[name]['x-resolved-from']; - - if (typeof resolvedFrom === 'undefined' || resolvedFrom === 'self') { - resolvedFrom = source; - } - output.properties[name]['x-resolved-from'] = resolvedFrom; - } - } else if (part === 'required') { - // merge & dedup the required array - var a = output.required.concat(component[part]); - - for (var k = 0; k < a.length; ++k) { - for (var j = k + 1; j < a.length; ++j) { - if (a[k] === a[j]) { - a.splice(j--, 1); - } - } - } - output.required = a; - } else if (part === 'x-resolved-from') { - output['x-resolved-from'].push(source); - } else { - // TODO: need to merge this property - // console.log('what to do with ' + part) - } - } - } - obj[key] = output; - } - } + type = type || 'default'; + if (type === 'default' || type === 'multi') { + for (i = 0; i < value.length; i++) { + if (i > 0) {encoded += '&';} - if (_.isObject(item)) { - this.resolveAllOf(spec, item, depth + 1); - } - } - }; + encoded += this.encodeQueryKey(name) + '=' + mask(this.encodeQueryParam(value[i]), maskPasswords); + } + } else { + var separator = ''; + + if (type === 'csv') { + separator = ','; + } else if (type === 'ssv') { + separator = '%20'; + } else if (type === 'tsv') { + separator = '%09'; + } else if (type === 'pipes') { + separator = '|'; + } else if (type === 'brackets') { + for (i = 0; i < value.length; i++) { + if (i !== 0) { + encoded += '&'; + } + encoded += this.encodeQueryKey(name) + '[]=' + mask(this.encodeQueryParam(value[i]), maskPasswords); + } + } - },{ - './http': 5,'lodash-compat/lang/isArray': 143,'lodash-compat/lang/isObject': 147 - }],7: [function (require, module, exports) { - 'use strict'; - - var Helpers = require('./helpers'); - - var _ = { - isPlainObject: require('lodash-compat/lang/isPlainObject'), - isUndefined: require('lodash-compat/lang/isUndefined'), - isArray: require('lodash-compat/lang/isArray'), - isObject: require('lodash-compat/lang/isObject'), - isEmpty: require('lodash-compat/lang/isEmpty'), - map: require('lodash-compat/collection/map'), - indexOf: require('lodash-compat/array/indexOf'), - cloneDeep: require('lodash-compat/lang/cloneDeep'), - keys: require('lodash-compat/object/keys'), - forEach: require('lodash-compat/collection/forEach') - }; + if (separator !== '') { + for (i = 0; i < value.length; i++) { + if (i === 0) { + encoded = this.encodeQueryKey(name) + '=' + this.encodeQueryParam(value[i]); + } else { + encoded += separator + this.encodeQueryParam(value[i]); + } + } + } + } - module.exports.optionHtml = optionHtml; - module.exports.typeFromJsonSchema = typeFromJsonSchema; - module.exports.getStringSignature = getStringSignature; - module.exports.schemaToHTML = schemaToHTML; - module.exports.schemaToJSON = schemaToJSON; + return encoded; +}; - function optionHtml(label, value) { - return '' + label + ':' + value + ''; - } +Operation.prototype.encodeQueryKey = function (arg) { + return encodeURIComponent(arg) + .replace('%5B','[').replace('%5D', ']').replace('%24', '$'); +}; - function typeFromJsonSchema(type, format) { - var str; - - if (type === 'integer' && format === 'int32') { - str = 'integer'; - } else if (type === 'integer' && format === 'int64') { - str = 'long'; - } else if (type === 'integer' && typeof format === 'undefined') { - str = 'long'; - } else if (type === 'string' && format === 'date-time') { - str = 'date-time'; - } else if (type === 'string' && format === 'date') { - str = 'date'; - } else if (type === 'number' && format === 'float') { - str = 'float'; - } else if (type === 'number' && format === 'double') { - str = 'double'; - } else if (type === 'number' && typeof format === 'undefined') { - str = 'double'; - } else if (type === 'boolean') { - str = 'boolean'; - } else if (type === 'string') { - str = 'string'; - } +Operation.prototype.encodeQueryParam = function (arg, maskPasswords) { + if(maskPasswords) { + return "******"; + } + return encodeURIComponent(arg); +}; - return str; - } +/** + * TODO revisit, might not want to leave '/' + **/ +Operation.prototype.encodePathParam = function (pathParam, maskPasswords) { + return encodeURIComponent(pathParam, maskPasswords); +}; + +var mask = function(value, format) { + if(typeof format === 'string' && format === 'password') { + return '******'; + } + return value; +} +},{"../helpers":4,"../http":5,"./model":9,"lodash-compat/lang/cloneDeep":138,"lodash-compat/lang/isEmpty":141,"lodash-compat/lang/isObject":144,"lodash-compat/lang/isUndefined":148,"q":157}],11:[function(require,module,exports){ +'use strict'; + +var OperationGroup = module.exports = function (tag, description, externalDocs, operation) { + this.description = description; + this.externalDocs = externalDocs; + this.name = tag; + this.operation = operation; + this.operationsArray = []; + this.path = tag; + this.tag = tag; +}; + +OperationGroup.prototype.sort = function () { + +}; + + +},{}],12:[function(require,module,exports){ +// shim for using process in browser + +var process = module.exports = {}; +var queue = []; +var draining = false; + +function drainQueue() { + if (draining) { + return; + } + draining = true; + var currentQueue; + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + var i = -1; + while (++i < len) { + currentQueue[i](); + } + len = queue.length; + } + draining = false; +} +process.nextTick = function (fun) { + queue.push(fun); + if (!draining) { + setTimeout(drainQueue, 0); + } +}; + +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; + +function noop() {} + +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +// TODO(shtylman) +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; + +},{}],13:[function(require,module,exports){ +(function (Buffer){ +(function () { + "use strict"; - function getStringSignature(obj, baseComponent) { - var str = ''; - - if (typeof obj.$ref !== 'undefined') { - str += Helpers.simpleRef(obj.$ref); - } else if (typeof obj.type === 'undefined') { - str += 'object'; - } else if (obj.type === 'array') { - if (baseComponent) { - str += getStringSignature(obj.items || obj.$ref || {}); - } else { - str += 'Array['; - str += getStringSignature(obj.items || obj.$ref || {}); - str += ']'; - } - } else if (obj.type === 'integer' && obj.format === 'int32') { - str += 'integer'; - } else if (obj.type === 'integer' && obj.format === 'int64') { - str += 'long'; - } else if (obj.type === 'integer' && typeof obj.format === 'undefined') { - str += 'long'; - } else if (obj.type === 'string' && obj.format === 'date-time') { - str += 'date-time'; - } else if (obj.type === 'string' && obj.format === 'date') { - str += 'date'; - } else if (obj.type === 'string' && typeof obj.format === 'undefined') { - str += 'string'; - } else if (obj.type === 'number' && obj.format === 'float') { - str += 'float'; - } else if (obj.type === 'number' && obj.format === 'double') { - str += 'double'; - } else if (obj.type === 'number' && typeof obj.format === 'undefined') { - str += 'double'; - } else if (obj.type === 'boolean') { - str += 'boolean'; - } else if (obj.$ref) { - str += Helpers.simpleRef(obj.$ref); - } else { - str += obj.type; - } + function btoa(str) { + var buffer + ; - return str; - } + if (str instanceof Buffer) { + buffer = str; + } else { + buffer = new Buffer(str.toString(), 'binary'); + } - function schemaToJSON(schema, models, modelsToIgnore, modelPropertyMacro) { - // Resolve the schema (Handle nested schemas) - schema = Helpers.resolveSchema(schema); + return buffer.toString('base64'); + } - if (typeof modelPropertyMacro !== 'function') { - modelPropertyMacro = function (prop) { - return (prop || {}).default; - }; - } + module.exports = btoa; +}()); - modelsToIgnore = modelsToIgnore || {}; +}).call(this,require("buffer").Buffer) - var type = schema.type || 'object'; - var format = schema.format; - var model; - var output; +},{"buffer":14}],14:[function(require,module,exports){ +/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ - if (schema.example) { - output = schema.example; - } else if (_.isUndefined(schema.items) && _.isArray(schema.enum)) { - output = schema.enum[0]; - } +var base64 = require('base64-js') +var ieee754 = require('ieee754') +var isArray = require('is-array') - if (_.isUndefined(output)) { - if (schema.$ref) { - model = models[Helpers.simpleRef(schema.$ref)]; - - if (!_.isUndefined(model)) { - if (_.isUndefined(modelsToIgnore[model.name])) { - modelsToIgnore[model.name] = model; - output = schemaToJSON(model.definition, models, modelsToIgnore, modelPropertyMacro); - delete modelsToIgnore[model.name]; - } else if (model.type === 'array') { - output = []; - } else { - output = {}; - } - } - } else if (!_.isUndefined(schema.default)) { - output = schema.default; - } else if (type === 'string') { - if (format === 'date-time') { - output = new Date().toISOString(); - } else if (format === 'date') { - output = new Date().toISOString().split('T')[0]; - } else { - output = 'string'; - } - } else if (type === 'integer') { - output = 0; - } else if (type === 'number') { - output = 0.0; - } else if (type === 'boolean') { - output = true; - } else if (type === 'object') { - output = {}; - - _.forEach(schema.properties, function (property, name) { - var cProperty = _.cloneDeep(property); - - // Allow macro to set the default value - cProperty.default = modelPropertyMacro(property); - - output[name] = schemaToJSON(cProperty, models, modelsToIgnore, modelPropertyMacro); - }); - } else if (type === 'array') { - output = []; - - if (_.isArray(schema.items)) { - _.forEach(schema.items, function (item) { - output.push(schemaToJSON(item, models, modelsToIgnore, modelPropertyMacro)); - }); - } else if (_.isPlainObject(schema.items)) { - output.push(schemaToJSON(schema.items, models, modelsToIgnore, modelPropertyMacro)); - } else if (_.isUndefined(schema.items)) { - output.push({}); - } else { - Helpers.log('Array type\'s \'items\' property is not an array or an object, cannot process'); - } - } - } +exports.Buffer = Buffer +exports.SlowBuffer = SlowBuffer +exports.INSPECT_MAX_BYTES = 50 +Buffer.poolSize = 8192 // not used by this implementation - return output; - } +var rootParent = {} - function schemaToHTML(name, schema, models, modelPropertyMacro) { +/** + * If `Buffer.TYPED_ARRAY_SUPPORT`: + * === true Use Uint8Array implementation (fastest) + * === false Use Object implementation (most compatible, even IE6) + * + * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, + * Opera 11.6+, iOS 4.2+. + * + * Due to various browser bugs, sometimes the Object implementation will be used even + * when the browser supports typed arrays. + * + * Note: + * + * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances, + * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. + * + * - Safari 5-7 lacks support for changing the `Object.prototype.constructor` property + * on objects. + * + * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. + * + * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of + * incorrect length in some situations. - var strongOpen = ''; - var strongClose = ''; + * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they + * get the Object implementation, which is slower but behaves correctly. + */ +Buffer.TYPED_ARRAY_SUPPORT = (function () { + function Bar () {} + try { + var arr = new Uint8Array(1) + arr.foo = function () { return 42 } + arr.constructor = Bar + return arr.foo() === 42 && // typed array instances can be augmented + arr.constructor === Bar && // constructor can be set + typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` + arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` + } catch (e) { + return false + } +})() + +function kMaxLength () { + return Buffer.TYPED_ARRAY_SUPPORT + ? 0x7fffffff + : 0x3fffffff +} - // Allow for ignoring the 'name' argument.... shifting the rest - if (_.isObject(arguments[0])) { - name = void 0; - schema = arguments[0]; - models = arguments[1]; - modelPropertyMacro = arguments[2]; - } +/** + * Class: Buffer + * ============= + * + * The Buffer constructor returns instances of `Uint8Array` that are augmented + * with function properties for all the node `Buffer` API functions. We use + * `Uint8Array` so that square bracket notation works as expected -- it returns + * a single octet. + * + * By augmenting the instances, we can avoid modifying the `Uint8Array` + * prototype. + */ +function Buffer (arg) { + if (!(this instanceof Buffer)) { + // Avoid going through an ArgumentsAdaptorTrampoline in the common case. + if (arguments.length > 1) return new Buffer(arg, arguments[1]) + return new Buffer(arg) + } + + this.length = 0 + this.parent = undefined + + // Common case. + if (typeof arg === 'number') { + return fromNumber(this, arg) + } + + // Slightly less common case. + if (typeof arg === 'string') { + return fromString(this, arg, arguments.length > 1 ? arguments[1] : 'utf8') + } + + // Unusual. + return fromObject(this, arg) +} + +function fromNumber (that, length) { + that = allocate(that, length < 0 ? 0 : checked(length) | 0) + if (!Buffer.TYPED_ARRAY_SUPPORT) { + for (var i = 0; i < length; i++) { + that[i] = 0 + } + } + return that +} - models = models || {}; +function fromString (that, string, encoding) { + if (typeof encoding !== 'string' || encoding === '') encoding = 'utf8' - // Resolve the schema (Handle nested schemas) - schema = Helpers.resolveSchema(schema); + // Assumption: byteLength() return value is always < kMaxLength. + var length = byteLength(string, encoding) | 0 + that = allocate(that, length) - // Return for empty object - if (_.isEmpty(schema)) { - return strongOpen + 'Empty' + strongClose; - } + that.write(string, encoding) + return that +} - // Dereference $ref from 'models' - if (typeof schema.$ref === 'string') { - name = Helpers.simpleRef(schema.$ref); - schema = models[name]; - } +function fromObject (that, object) { + if (Buffer.isBuffer(object)) return fromBuffer(that, object) - if (typeof name !== 'string') { - name = schema.title || 'Inline Model'; - } + if (isArray(object)) return fromArray(that, object) - // If we are a Model object... adjust accordingly - if (schema.definition) { - schema = schema.definition; - } + if (object == null) { + throw new TypeError('must start with number, buffer, array or string') + } - if (typeof modelPropertyMacro !== 'function') { - modelPropertyMacro = function (prop) { - return (prop || {}).default; - }; - } + if (typeof ArrayBuffer !== 'undefined') { + if (object.buffer instanceof ArrayBuffer) { + return fromTypedArray(that, object) + } + if (object instanceof ArrayBuffer) { + return fromArrayBuffer(that, object) + } + } + + if (object.length) return fromArrayLike(that, object) + + return fromJsonObject(that, object) +} + +function fromBuffer (that, buffer) { + var length = checked(buffer.length) | 0 + that = allocate(that, length) + buffer.copy(that, 0, 0, length) + return that +} + +function fromArray (that, array) { + var length = checked(array.length) | 0 + that = allocate(that, length) + for (var i = 0; i < length; i += 1) { + that[i] = array[i] & 255 + } + return that +} + +// Duplicate of fromArray() to keep fromArray() monomorphic. +function fromTypedArray (that, array) { + var length = checked(array.length) | 0 + that = allocate(that, length) + // Truncating the elements is probably not what people expect from typed + // arrays with BYTES_PER_ELEMENT > 1 but it's compatible with the behavior + // of the old Buffer constructor. + for (var i = 0; i < length; i += 1) { + that[i] = array[i] & 255 + } + return that +} + +function fromArrayBuffer (that, array) { + if (Buffer.TYPED_ARRAY_SUPPORT) { + // Return an augmented `Uint8Array` instance, for best performance + array.byteLength + that = Buffer._augment(new Uint8Array(array)) + } else { + // Fallback: Return an object instance of the Buffer class + that = fromTypedArray(that, new Uint8Array(array)) + } + return that +} + +function fromArrayLike (that, array) { + var length = checked(array.length) | 0 + that = allocate(that, length) + for (var i = 0; i < length; i += 1) { + that[i] = array[i] & 255 + } + return that +} + +// Deserialize { type: 'Buffer', data: [1,2,3,...] } into a Buffer object. +// Returns a zero-length buffer for inputs that don't conform to the spec. +function fromJsonObject (that, object) { + var array + var length = 0 + + if (object.type === 'Buffer' && isArray(object.data)) { + array = object.data + length = checked(array.length) | 0 + } + that = allocate(that, length) + + for (var i = 0; i < length; i += 1) { + that[i] = array[i] & 255 + } + return that +} + +function allocate (that, length) { + if (Buffer.TYPED_ARRAY_SUPPORT) { + // Return an augmented `Uint8Array` instance, for best performance + that = Buffer._augment(new Uint8Array(length)) + } else { + // Fallback: Return an object instance of the Buffer class + that.length = length + that._isBuffer = true + } + + var fromPool = length !== 0 && length <= Buffer.poolSize >>> 1 + if (fromPool) that.parent = rootParent + + return that +} + +function checked (length) { + // Note: cannot use `length < kMaxLength` here because that fails when + // length is NaN (which is otherwise coerced to zero.) + if (length >= kMaxLength()) { + throw new RangeError('Attempt to allocate Buffer larger than maximum ' + + 'size: 0x' + kMaxLength().toString(16) + ' bytes') + } + return length | 0 +} + +function SlowBuffer (subject, encoding) { + if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding) + + var buf = new Buffer(subject, encoding) + delete buf.parent + return buf +} + +Buffer.isBuffer = function isBuffer (b) { + return !!(b != null && b._isBuffer) +} + +Buffer.compare = function compare (a, b) { + if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { + throw new TypeError('Arguments must be Buffers') + } + + if (a === b) return 0 + + var x = a.length + var y = b.length + + var i = 0 + var len = Math.min(x, y) + while (i < len) { + if (a[i] !== b[i]) break + + ++i + } + + if (i !== len) { + x = a[i] + y = b[i] + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +} + +Buffer.isEncoding = function isEncoding (encoding) { + switch (String(encoding).toLowerCase()) { + case 'hex': + case 'utf8': + case 'utf-8': + case 'ascii': + case 'binary': + case 'base64': + case 'raw': + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return true + default: + return false + } +} + +Buffer.concat = function concat (list, length) { + if (!isArray(list)) throw new TypeError('list argument must be an Array of Buffers.') + + if (list.length === 0) { + return new Buffer(0) + } + + var i + if (length === undefined) { + length = 0 + for (i = 0; i < list.length; i++) { + length += list[i].length + } + } + + var buf = new Buffer(length) + var pos = 0 + for (i = 0; i < list.length; i++) { + var item = list[i] + item.copy(buf, pos) + pos += item.length + } + return buf +} + +function byteLength (string, encoding) { + if (typeof string !== 'string') string = '' + string + + var len = string.length + if (len === 0) return 0 + + // Use a for loop to avoid recursion + var loweredCase = false + for (;;) { + switch (encoding) { + case 'ascii': + case 'binary': + // Deprecated + case 'raw': + case 'raws': + return len + case 'utf8': + case 'utf-8': + return utf8ToBytes(string).length + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return len * 2 + case 'hex': + return len >>> 1 + case 'base64': + return base64ToBytes(string).length + default: + if (loweredCase) return utf8ToBytes(string).length // assume utf8 + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} +Buffer.byteLength = byteLength - var references = {}; - var seenModels = []; - var inlineModels = 0; +// pre-set for values that may exist in the future +Buffer.prototype.length = undefined +Buffer.prototype.parent = undefined +function slowToString (encoding, start, end) { + var loweredCase = false + start = start | 0 + end = end === undefined || end === Infinity ? this.length : end | 0 - // Generate current HTML - var html = processModel(schema, name); + if (!encoding) encoding = 'utf8' + if (start < 0) start = 0 + if (end > this.length) end = this.length + if (end <= start) return '' - // Generate references HTML - while (_.keys(references).length > 0) { - /* jshint ignore:start */ - _.forEach(references, function (schema, name) { - var seenModel = _.indexOf(seenModels, name) > -1; + while (true) { + switch (encoding) { + case 'hex': + return hexSlice(this, start, end) - delete references[name]; + case 'utf8': + case 'utf-8': + return utf8Slice(this, start, end) - if (!seenModel) { - seenModels.push(name); + case 'ascii': + return asciiSlice(this, start, end) - html += '
        ' + processModel(schema, name); - } - }); - /* jshint ignore:end */ - } + case 'binary': + return binarySlice(this, start, end) - return html; + case 'base64': + return base64Slice(this, start, end) - ///////////////////////////////// + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return utf16leSlice(this, start, end) - function addReference(schema, name, skipRef) { - var modelName = name; - var model; + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = (encoding + '').toLowerCase() + loweredCase = true + } + } +} + +Buffer.prototype.toString = function toString () { + var length = this.length | 0 + if (length === 0) return '' + if (arguments.length === 0) return utf8Slice(this, 0, length) + return slowToString.apply(this, arguments) +} + +Buffer.prototype.equals = function equals (b) { + if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return true + return Buffer.compare(this, b) === 0 +} + +Buffer.prototype.inspect = function inspect () { + var str = '' + var max = exports.INSPECT_MAX_BYTES + if (this.length > 0) { + str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') + if (this.length > max) str += ' ... ' + } + return '' +} + +Buffer.prototype.compare = function compare (b) { + if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return 0 + return Buffer.compare(this, b) +} + +Buffer.prototype.indexOf = function indexOf (val, byteOffset) { + if (byteOffset > 0x7fffffff) byteOffset = 0x7fffffff + else if (byteOffset < -0x80000000) byteOffset = -0x80000000 + byteOffset >>= 0 + + if (this.length === 0) return -1 + if (byteOffset >= this.length) return -1 + + // Negative offsets start from the end of the buffer + if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0) + + if (typeof val === 'string') { + if (val.length === 0) return -1 // special case: looking for empty string always fails + return String.prototype.indexOf.call(this, val, byteOffset) + } + if (Buffer.isBuffer(val)) { + return arrayIndexOf(this, val, byteOffset) + } + if (typeof val === 'number') { + if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') { + return Uint8Array.prototype.indexOf.call(this, val, byteOffset) + } + return arrayIndexOf(this, [ val ], byteOffset) + } + + function arrayIndexOf (arr, val, byteOffset) { + var foundIndex = -1 + for (var i = 0; byteOffset + i < arr.length; i++) { + if (arr[byteOffset + i] === val[foundIndex === -1 ? 0 : i - foundIndex]) { + if (foundIndex === -1) foundIndex = i + if (i - foundIndex + 1 === val.length) return byteOffset + foundIndex + } else { + foundIndex = -1 + } + } + return -1 + } + + throw new TypeError('val must be string, number or Buffer') +} + +// `get` is deprecated +Buffer.prototype.get = function get (offset) { + console.log('.get() is deprecated. Access using array indexes instead.') + return this.readUInt8(offset) +} + +// `set` is deprecated +Buffer.prototype.set = function set (v, offset) { + console.log('.set() is deprecated. Access using array indexes instead.') + return this.writeUInt8(v, offset) +} + +function hexWrite (buf, string, offset, length) { + offset = Number(offset) || 0 + var remaining = buf.length - offset + if (!length) { + length = remaining + } else { + length = Number(length) + if (length > remaining) { + length = remaining + } + } + + // must be an even number of digits + var strLen = string.length + if (strLen % 2 !== 0) throw new Error('Invalid hex string') + + if (length > strLen / 2) { + length = strLen / 2 + } + for (var i = 0; i < length; i++) { + var parsed = parseInt(string.substr(i * 2, 2), 16) + if (isNaN(parsed)) throw new Error('Invalid hex string') + buf[offset + i] = parsed + } + return i +} + +function utf8Write (buf, string, offset, length) { + return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) +} + +function asciiWrite (buf, string, offset, length) { + return blitBuffer(asciiToBytes(string), buf, offset, length) +} + +function binaryWrite (buf, string, offset, length) { + return asciiWrite(buf, string, offset, length) +} + +function base64Write (buf, string, offset, length) { + return blitBuffer(base64ToBytes(string), buf, offset, length) +} + +function ucs2Write (buf, string, offset, length) { + return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) +} + +Buffer.prototype.write = function write (string, offset, length, encoding) { + // Buffer#write(string) + if (offset === undefined) { + encoding = 'utf8' + length = this.length + offset = 0 + // Buffer#write(string, encoding) + } else if (length === undefined && typeof offset === 'string') { + encoding = offset + length = this.length + offset = 0 + // Buffer#write(string, offset[, length][, encoding]) + } else if (isFinite(offset)) { + offset = offset | 0 + if (isFinite(length)) { + length = length | 0 + if (encoding === undefined) encoding = 'utf8' + } else { + encoding = length + length = undefined + } + // legacy write(string, encoding, offset, length) - remove in v0.13 + } else { + var swap = encoding + encoding = offset + offset = length | 0 + length = swap + } + + var remaining = this.length - offset + if (length === undefined || length > remaining) length = remaining + + if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { + throw new RangeError('attempt to write outside buffer bounds') + } + + if (!encoding) encoding = 'utf8' + + var loweredCase = false + for (;;) { + switch (encoding) { + case 'hex': + return hexWrite(this, string, offset, length) + + case 'utf8': + case 'utf-8': + return utf8Write(this, string, offset, length) + + case 'ascii': + return asciiWrite(this, string, offset, length) + + case 'binary': + return binaryWrite(this, string, offset, length) + + case 'base64': + // Warning: maxLength not taken into account in base64Write + return base64Write(this, string, offset, length) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return ucs2Write(this, string, offset, length) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} + +Buffer.prototype.toJSON = function toJSON () { + return { + type: 'Buffer', + data: Array.prototype.slice.call(this._arr || this, 0) + } +} + +function base64Slice (buf, start, end) { + if (start === 0 && end === buf.length) { + return base64.fromByteArray(buf) + } else { + return base64.fromByteArray(buf.slice(start, end)) + } +} + +function utf8Slice (buf, start, end) { + end = Math.min(buf.length, end) + var res = [] + + var i = start + while (i < end) { + var firstByte = buf[i] + var codePoint = null + var bytesPerSequence = (firstByte > 0xEF) ? 4 + : (firstByte > 0xDF) ? 3 + : (firstByte > 0xBF) ? 2 + : 1 + + if (i + bytesPerSequence <= end) { + var secondByte, thirdByte, fourthByte, tempCodePoint + + switch (bytesPerSequence) { + case 1: + if (firstByte < 0x80) { + codePoint = firstByte + } + break + case 2: + secondByte = buf[i + 1] + if ((secondByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) + if (tempCodePoint > 0x7F) { + codePoint = tempCodePoint + } + } + break + case 3: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) + if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { + codePoint = tempCodePoint + } + } + break + case 4: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + fourthByte = buf[i + 3] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) + if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { + codePoint = tempCodePoint + } + } + } + } - if (schema.$ref) { - modelName = schema.title || Helpers.simpleRef(schema.$ref); - model = models[modelName]; - } else if (_.isUndefined(name)) { - modelName = schema.title || 'Inline Model ' + ++inlineModels; - model = { - definition: schema - }; - } + if (codePoint === null) { + // we did not generate a valid codePoint so insert a + // replacement char (U+FFFD) and advance only 1 byte + codePoint = 0xFFFD + bytesPerSequence = 1 + } else if (codePoint > 0xFFFF) { + // encode to utf16 (surrogate pair dance) + codePoint -= 0x10000 + res.push(codePoint >>> 10 & 0x3FF | 0xD800) + codePoint = 0xDC00 | codePoint & 0x3FF + } - if (skipRef !== true) { - references[modelName] = _.isUndefined(model) ? {} : model.definition; - } + res.push(codePoint) + i += bytesPerSequence + } + + return decodeCodePointsArray(res) +} + +// Based on http://stackoverflow.com/a/22747272/680742, the browser with +// the lowest limit is Chrome, with 0x10000 args. +// We go 1 magnitude less, for safety +var MAX_ARGUMENTS_LENGTH = 0x1000 + +function decodeCodePointsArray (codePoints) { + var len = codePoints.length + if (len <= MAX_ARGUMENTS_LENGTH) { + return String.fromCharCode.apply(String, codePoints) // avoid extra slice() + } + + // Decode in chunks to avoid "call stack size exceeded". + var res = '' + var i = 0 + while (i < len) { + res += String.fromCharCode.apply( + String, + codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) + ) + } + return res +} + +function asciiSlice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; i++) { + ret += String.fromCharCode(buf[i] & 0x7F) + } + return ret +} + +function binarySlice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; i++) { + ret += String.fromCharCode(buf[i]) + } + return ret +} + +function hexSlice (buf, start, end) { + var len = buf.length + + if (!start || start < 0) start = 0 + if (!end || end < 0 || end > len) end = len + + var out = '' + for (var i = start; i < end; i++) { + out += toHex(buf[i]) + } + return out +} + +function utf16leSlice (buf, start, end) { + var bytes = buf.slice(start, end) + var res = '' + for (var i = 0; i < bytes.length; i += 2) { + res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256) + } + return res +} + +Buffer.prototype.slice = function slice (start, end) { + var len = this.length + start = ~~start + end = end === undefined ? len : ~~end + + if (start < 0) { + start += len + if (start < 0) start = 0 + } else if (start > len) { + start = len + } + + if (end < 0) { + end += len + if (end < 0) end = 0 + } else if (end > len) { + end = len + } + + if (end < start) end = start + + var newBuf + if (Buffer.TYPED_ARRAY_SUPPORT) { + newBuf = Buffer._augment(this.subarray(start, end)) + } else { + var sliceLen = end - start + newBuf = new Buffer(sliceLen, undefined) + for (var i = 0; i < sliceLen; i++) { + newBuf[i] = this[i + start] + } + } - return modelName; - } + if (newBuf.length) newBuf.parent = this.parent || this - function primitiveToHTML(schema) { - var html = ''; - var type = schema.type || 'object'; - - if (schema.$ref) { - html += addReference(schema, Helpers.simpleRef(schema.$ref)); - } else if (type === 'object') { - if (!_.isUndefined(schema.properties)) { - html += addReference(schema); - } else { - html += 'object'; - } - } else if (type === 'array') { - html += 'Array['; - - if (_.isArray(schema.items)) { - html += _.map(schema.items, addReference).join(','); - } else if (_.isPlainObject(schema.items)) { - if (_.isUndefined(schema.items.$ref)) { - if (!_.isUndefined(schema.items.type) && _.indexOf(['array', 'object'], schema.items.type) === -1) { - html += schema.items.type; - } else { - html += addReference(schema.items); - } - } else { - html += addReference(schema.items, Helpers.simpleRef(schema.items.$ref)); - } - } else { - Helpers.log('Array type\'s \'items\' schema is not an array or an object, cannot process'); - html += 'object'; - } + return newBuf +} - html += ']'; - } else { - html += schema.type; - } +/* + * Need to make sure that buffer isn't trying to write out of bounds. + */ +function checkOffset (offset, ext, length) { + if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') + if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') +} + +Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + + return val +} + +Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) { + checkOffset(offset, byteLength, this.length) + } + + var val = this[offset + --byteLength] + var mul = 1 + while (byteLength > 0 && (mul *= 0x100)) { + val += this[offset + --byteLength] * mul + } + + return val +} + +Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { + if (!noAssert) checkOffset(offset, 1, this.length) + return this[offset] +} + +Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + return this[offset] | (this[offset + 1] << 8) +} + +Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + return (this[offset] << 8) | this[offset + 1] +} + +Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return ((this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16)) + + (this[offset + 3] * 0x1000000) +} + +Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] * 0x1000000) + + ((this[offset + 1] << 16) | + (this[offset + 2] << 8) | + this[offset + 3]) +} + +Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var i = byteLength + var mul = 1 + var val = this[offset + --i] + while (i > 0 && (mul *= 0x100)) { + val += this[offset + --i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { + if (!noAssert) checkOffset(offset, 1, this.length) + if (!(this[offset] & 0x80)) return (this[offset]) + return ((0xff - this[offset] + 1) * -1) +} + +Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset] | (this[offset + 1] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset + 1] | (this[offset] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16) | + (this[offset + 3] << 24) +} + +Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] << 24) | + (this[offset + 1] << 16) | + (this[offset + 2] << 8) | + (this[offset + 3]) +} + +Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, true, 23, 4) +} + +Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, false, 23, 4) +} + +Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, true, 52, 8) +} + +Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, false, 52, 8) +} + +function checkInt (buf, value, offset, ext, max, min) { + if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance') + if (value > max || value < min) throw new RangeError('value is out of bounds') + if (offset + ext > buf.length) throw new RangeError('index out of range') +} + +Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0) + + var mul = 1 + var i = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0) + + var i = byteLength - 1 + var mul = 1 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) + if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) + this[offset] = value + return offset + 1 +} + +function objectWriteUInt16 (buf, value, offset, littleEndian) { + if (value < 0) value = 0xffff + value + 1 + for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) { + buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> + (littleEndian ? i : 1 - i) * 8 + } +} + +Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = value + this[offset + 1] = (value >>> 8) + } else { + objectWriteUInt16(this, value, offset, true) + } + return offset + 2 +} + +Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 8) + this[offset + 1] = value + } else { + objectWriteUInt16(this, value, offset, false) + } + return offset + 2 +} + +function objectWriteUInt32 (buf, value, offset, littleEndian) { + if (value < 0) value = 0xffffffff + value + 1 + for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) { + buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff + } +} + +Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset + 3] = (value >>> 24) + this[offset + 2] = (value >>> 16) + this[offset + 1] = (value >>> 8) + this[offset] = value + } else { + objectWriteUInt32(this, value, offset, true) + } + return offset + 4 +} + +Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = value + } else { + objectWriteUInt32(this, value, offset, false) + } + return offset + 4 +} + +Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) { + var limit = Math.pow(2, 8 * byteLength - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = 0 + var mul = 1 + var sub = value < 0 ? 1 : 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) { + var limit = Math.pow(2, 8 * byteLength - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = byteLength - 1 + var mul = 1 + var sub = value < 0 ? 1 : 0 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) + if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) + if (value < 0) value = 0xff + value + 1 + this[offset] = value + return offset + 1 +} + +Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = value + this[offset + 1] = (value >>> 8) + } else { + objectWriteUInt16(this, value, offset, true) + } + return offset + 2 +} + +Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 8) + this[offset + 1] = value + } else { + objectWriteUInt16(this, value, offset, false) + } + return offset + 2 +} + +Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = value + this[offset + 1] = (value >>> 8) + this[offset + 2] = (value >>> 16) + this[offset + 3] = (value >>> 24) + } else { + objectWriteUInt32(this, value, offset, true) + } + return offset + 4 +} + +Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (value < 0) value = 0xffffffff + value + 1 + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = value + } else { + objectWriteUInt32(this, value, offset, false) + } + return offset + 4 +} + +function checkIEEE754 (buf, value, offset, ext, max, min) { + if (value > max || value < min) throw new RangeError('value is out of bounds') + if (offset + ext > buf.length) throw new RangeError('index out of range') + if (offset < 0) throw new RangeError('index out of range') +} + +function writeFloat (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) + } + ieee754.write(buf, value, offset, littleEndian, 23, 4) + return offset + 4 +} + +Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { + return writeFloat(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { + return writeFloat(this, value, offset, false, noAssert) +} + +function writeDouble (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) + } + ieee754.write(buf, value, offset, littleEndian, 52, 8) + return offset + 8 +} + +Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { + return writeDouble(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { + return writeDouble(this, value, offset, false, noAssert) +} + +// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) +Buffer.prototype.copy = function copy (target, targetStart, start, end) { + if (!start) start = 0 + if (!end && end !== 0) end = this.length + if (targetStart >= target.length) targetStart = target.length + if (!targetStart) targetStart = 0 + if (end > 0 && end < start) end = start + + // Copy 0 bytes; we're done + if (end === start) return 0 + if (target.length === 0 || this.length === 0) return 0 + + // Fatal error conditions + if (targetStart < 0) { + throw new RangeError('targetStart out of bounds') + } + if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds') + if (end < 0) throw new RangeError('sourceEnd out of bounds') + + // Are we oob? + if (end > this.length) end = this.length + if (target.length - targetStart < end - start) { + end = target.length - targetStart + start + } + + var len = end - start + var i + + if (this === target && start < targetStart && targetStart < end) { + // descending copy from end + for (i = len - 1; i >= 0; i--) { + target[i + targetStart] = this[i + start] + } + } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { + // ascending copy from start + for (i = 0; i < len; i++) { + target[i + targetStart] = this[i + start] + } + } else { + target._set(this.subarray(start, start + len), targetStart) + } - html += ''; + return len +} - return html; - } - function primitiveToOptionsHTML(schema, html) { - var options = ''; - var type = schema.type || 'object'; - var isArray = type === 'array'; - - if (isArray) { - if (_.isPlainObject(schema.items) && !_.isUndefined(schema.items.type)) { - type = schema.items.type; - } else { - type = 'object'; - } - } +// fill(value, start=0, end=buffer.length) +Buffer.prototype.fill = function fill (value, start, end) { + if (!value) value = 0 + if (!start) start = 0 + if (!end) end = this.length - if (!_.isUndefined(schema.default)) { - options += optionHtml('Default', schema.default); - } + if (end < start) throw new RangeError('end < start') - switch (type) { - case 'string': - if (schema.minLength) { - options += optionHtml('Min. Length', schema.minLength); - } + // Fill 0 bytes; we're done + if (end === start) return + if (this.length === 0) return - if (schema.maxLength) { - options += optionHtml('Max. Length', schema.maxLength); - } + if (start < 0 || start >= this.length) throw new RangeError('start out of bounds') + if (end < 0 || end > this.length) throw new RangeError('end out of bounds') - if (schema.pattern) { - options += optionHtml('Reg. Exp.', schema.pattern); - } - break; + var i + if (typeof value === 'number') { + for (i = start; i < end; i++) { + this[i] = value + } + } else { + var bytes = utf8ToBytes(value.toString()) + var len = bytes.length + for (i = start; i < end; i++) { + this[i] = bytes[i % len] + } + } - case 'integer': - case 'number': - if (schema.minimum) { - options += optionHtml('Min. Value', schema.minimum); - } + return this +} - if (schema.exclusiveMinimum) { - options += optionHtml('Exclusive Min.', 'true'); - } +/** + * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance. + * Added in Node 0.12. Only available in browsers that support ArrayBuffer. + */ +Buffer.prototype.toArrayBuffer = function toArrayBuffer () { + if (typeof Uint8Array !== 'undefined') { + if (Buffer.TYPED_ARRAY_SUPPORT) { + return (new Buffer(this)).buffer + } else { + var buf = new Uint8Array(this.length) + for (var i = 0, len = buf.length; i < len; i += 1) { + buf[i] = this[i] + } + return buf.buffer + } + } else { + throw new TypeError('Buffer.toArrayBuffer not supported in this browser') + } +} - if (schema.maximum) { - options += optionHtml('Max. Value', schema.maximum); - } +// HELPER FUNCTIONS +// ================ - if (schema.exclusiveMaximum) { - options += optionHtml('Exclusive Max.', 'true'); - } +var BP = Buffer.prototype - if (schema.multipleOf) { - options += optionHtml('Multiple Of', schema.multipleOf); - } +/** + * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods + */ +Buffer._augment = function _augment (arr) { + arr.constructor = Buffer + arr._isBuffer = true + + // save reference to original Uint8Array set method before overwriting + arr._set = arr.set + + // deprecated + arr.get = BP.get + arr.set = BP.set + + arr.write = BP.write + arr.toString = BP.toString + arr.toLocaleString = BP.toString + arr.toJSON = BP.toJSON + arr.equals = BP.equals + arr.compare = BP.compare + arr.indexOf = BP.indexOf + arr.copy = BP.copy + arr.slice = BP.slice + arr.readUIntLE = BP.readUIntLE + arr.readUIntBE = BP.readUIntBE + arr.readUInt8 = BP.readUInt8 + arr.readUInt16LE = BP.readUInt16LE + arr.readUInt16BE = BP.readUInt16BE + arr.readUInt32LE = BP.readUInt32LE + arr.readUInt32BE = BP.readUInt32BE + arr.readIntLE = BP.readIntLE + arr.readIntBE = BP.readIntBE + arr.readInt8 = BP.readInt8 + arr.readInt16LE = BP.readInt16LE + arr.readInt16BE = BP.readInt16BE + arr.readInt32LE = BP.readInt32LE + arr.readInt32BE = BP.readInt32BE + arr.readFloatLE = BP.readFloatLE + arr.readFloatBE = BP.readFloatBE + arr.readDoubleLE = BP.readDoubleLE + arr.readDoubleBE = BP.readDoubleBE + arr.writeUInt8 = BP.writeUInt8 + arr.writeUIntLE = BP.writeUIntLE + arr.writeUIntBE = BP.writeUIntBE + arr.writeUInt16LE = BP.writeUInt16LE + arr.writeUInt16BE = BP.writeUInt16BE + arr.writeUInt32LE = BP.writeUInt32LE + arr.writeUInt32BE = BP.writeUInt32BE + arr.writeIntLE = BP.writeIntLE + arr.writeIntBE = BP.writeIntBE + arr.writeInt8 = BP.writeInt8 + arr.writeInt16LE = BP.writeInt16LE + arr.writeInt16BE = BP.writeInt16BE + arr.writeInt32LE = BP.writeInt32LE + arr.writeInt32BE = BP.writeInt32BE + arr.writeFloatLE = BP.writeFloatLE + arr.writeFloatBE = BP.writeFloatBE + arr.writeDoubleLE = BP.writeDoubleLE + arr.writeDoubleBE = BP.writeDoubleBE + arr.fill = BP.fill + arr.inspect = BP.inspect + arr.toArrayBuffer = BP.toArrayBuffer + + return arr +} + +var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g + +function base64clean (str) { + // Node strips out invalid characters like \n and \t from the string, base64-js does not + str = stringtrim(str).replace(INVALID_BASE64_RE, '') + // Node converts strings with length < 2 to '' + if (str.length < 2) return '' + // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not + while (str.length % 4 !== 0) { + str = str + '=' + } + return str +} + +function stringtrim (str) { + if (str.trim) return str.trim() + return str.replace(/^\s+|\s+$/g, '') +} + +function toHex (n) { + if (n < 16) return '0' + n.toString(16) + return n.toString(16) +} + +function utf8ToBytes (string, units) { + units = units || Infinity + var codePoint + var length = string.length + var leadSurrogate = null + var bytes = [] + + for (var i = 0; i < length; i++) { + codePoint = string.charCodeAt(i) + + // is surrogate component + if (codePoint > 0xD7FF && codePoint < 0xE000) { + // last char was a lead + if (!leadSurrogate) { + // no lead yet + if (codePoint > 0xDBFF) { + // unexpected trail + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } else if (i + 1 === length) { + // unpaired lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } - break; - } + // valid lead + leadSurrogate = codePoint - if (isArray) { - if (schema.minItems) { - options += optionHtml('Min. Items', schema.minItems); - } + continue + } - if (schema.maxItems) { - options += optionHtml('Max. Items', schema.maxItems); - } + // 2 leads in a row + if (codePoint < 0xDC00) { + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + leadSurrogate = codePoint + continue + } - if (schema.uniqueItems) { - options += optionHtml('Unique Items', 'true'); - } + // valid surrogate pair + codePoint = leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00 | 0x10000 + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + } - if (schema.collectionFormat) { - options += optionHtml('Coll. Format', schema.collectionFormat); - } - } + leadSurrogate = null + + // encode utf8 + if (codePoint < 0x80) { + if ((units -= 1) < 0) break + bytes.push(codePoint) + } else if (codePoint < 0x800) { + if ((units -= 2) < 0) break + bytes.push( + codePoint >> 0x6 | 0xC0, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x10000) { + if ((units -= 3) < 0) break + bytes.push( + codePoint >> 0xC | 0xE0, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x110000) { + if ((units -= 4) < 0) break + bytes.push( + codePoint >> 0x12 | 0xF0, + codePoint >> 0xC & 0x3F | 0x80, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else { + throw new Error('Invalid code point') + } + } + + return bytes +} + +function asciiToBytes (str) { + var byteArray = [] + for (var i = 0; i < str.length; i++) { + // Node's code seems to be doing this and not & 0x7F.. + byteArray.push(str.charCodeAt(i) & 0xFF) + } + return byteArray +} + +function utf16leToBytes (str, units) { + var c, hi, lo + var byteArray = [] + for (var i = 0; i < str.length; i++) { + if ((units -= 2) < 0) break + + c = str.charCodeAt(i) + hi = c >> 8 + lo = c % 256 + byteArray.push(lo) + byteArray.push(hi) + } + + return byteArray +} + +function base64ToBytes (str) { + return base64.toByteArray(base64clean(str)) +} + +function blitBuffer (src, dst, offset, length) { + for (var i = 0; i < length; i++) { + if ((i + offset >= dst.length) || (i >= src.length)) break + dst[i + offset] = src[i] + } + return i +} + +},{"base64-js":15,"ieee754":16,"is-array":17}],15:[function(require,module,exports){ +var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; + +;(function (exports) { + 'use strict'; + + var Arr = (typeof Uint8Array !== 'undefined') + ? Uint8Array + : Array + + var PLUS = '+'.charCodeAt(0) + var SLASH = '/'.charCodeAt(0) + var NUMBER = '0'.charCodeAt(0) + var LOWER = 'a'.charCodeAt(0) + var UPPER = 'A'.charCodeAt(0) + var PLUS_URL_SAFE = '-'.charCodeAt(0) + var SLASH_URL_SAFE = '_'.charCodeAt(0) + + function decode (elt) { + var code = elt.charCodeAt(0) + if (code === PLUS || + code === PLUS_URL_SAFE) + return 62 // '+' + if (code === SLASH || + code === SLASH_URL_SAFE) + return 63 // '/' + if (code < NUMBER) + return -1 //no match + if (code < NUMBER + 10) + return code - NUMBER + 26 + 26 + if (code < UPPER + 26) + return code - UPPER + if (code < LOWER + 26) + return code - LOWER + 26 + } + + function b64ToByteArray (b64) { + var i, j, l, tmp, placeHolders, arr + + if (b64.length % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4') + } + + // the number of equal signs (place holders) + // if there are two placeholders, than the two characters before it + // represent one byte + // if there is only one, then the three characters before it represent 2 bytes + // this is just a cheap hack to not do indexOf twice + var len = b64.length + placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0 + + // base64 is 4/3 + up to two characters of the original data + arr = new Arr(b64.length * 3 / 4 - placeHolders) + + // if there are placeholders, only get up to the last complete 4 chars + l = placeHolders > 0 ? b64.length - 4 : b64.length + + var L = 0 + + function push (v) { + arr[L++] = v + } + + for (i = 0, j = 0; i < l; i += 4, j += 3) { + tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3)) + push((tmp & 0xFF0000) >> 16) + push((tmp & 0xFF00) >> 8) + push(tmp & 0xFF) + } + + if (placeHolders === 2) { + tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4) + push(tmp & 0xFF) + } else if (placeHolders === 1) { + tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2) + push((tmp >> 8) & 0xFF) + push(tmp & 0xFF) + } + + return arr + } + + function uint8ToBase64 (uint8) { + var i, + extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes + output = "", + temp, length + + function encode (num) { + return lookup.charAt(num) + } + + function tripletToBase64 (num) { + return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F) + } + + // go through the array every three bytes, we'll deal with trailing stuff later + for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) { + temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) + output += tripletToBase64(temp) + } + + // pad the end with zeros, but make sure to not forget the extra bytes + switch (extraBytes) { + case 1: + temp = uint8[uint8.length - 1] + output += encode(temp >> 2) + output += encode((temp << 4) & 0x3F) + output += '==' + break + case 2: + temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1]) + output += encode(temp >> 10) + output += encode((temp >> 4) & 0x3F) + output += encode((temp << 2) & 0x3F) + output += '=' + break + } + + return output + } + + exports.toByteArray = b64ToByteArray + exports.fromByteArray = uint8ToBase64 +}(typeof exports === 'undefined' ? (this.base64js = {}) : exports)) + +},{}],16:[function(require,module,exports){ +exports.read = function (buffer, offset, isLE, mLen, nBytes) { + var e, m + var eLen = nBytes * 8 - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var nBits = -7 + var i = isLE ? (nBytes - 1) : 0 + var d = isLE ? -1 : 1 + var s = buffer[offset + i] + + i += d + + e = s & ((1 << (-nBits)) - 1) + s >>= (-nBits) + nBits += eLen + for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} + + m = e & ((1 << (-nBits)) - 1) + e >>= (-nBits) + nBits += mLen + for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} + + if (e === 0) { + e = 1 - eBias + } else if (e === eMax) { + return m ? NaN : ((s ? -1 : 1) * Infinity) + } else { + m = m + Math.pow(2, mLen) + e = e - eBias + } + return (s ? -1 : 1) * m * Math.pow(2, e - mLen) +} + +exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c + var eLen = nBytes * 8 - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) + var i = isLE ? 0 : (nBytes - 1) + var d = isLE ? 1 : -1 + var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 + + value = Math.abs(value) + + if (isNaN(value) || value === Infinity) { + m = isNaN(value) ? 1 : 0 + e = eMax + } else { + e = Math.floor(Math.log(value) / Math.LN2) + if (value * (c = Math.pow(2, -e)) < 1) { + e-- + c *= 2 + } + if (e + eBias >= 1) { + value += rt / c + } else { + value += rt * Math.pow(2, 1 - eBias) + } + if (value * c >= 2) { + e++ + c /= 2 + } - if (_.isUndefined(schema.items)) { - if (_.isArray(schema.enum)) { - var enumString; + if (e + eBias >= eMax) { + m = 0 + e = eMax + } else if (e + eBias >= 1) { + m = (value * c - 1) * Math.pow(2, mLen) + e = e + eBias + } else { + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) + e = 0 + } + } - if (type === 'number' || type === 'integer') { - enumString = schema.enum.join(', '); - } else { - enumString = '"' + schema.enum.join('", "') + '"'; - } + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} - options += optionHtml('Enum', enumString); - } - } + e = (e << mLen) | m + eLen += mLen + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} - if (options.length > 0) { - html = '' + html + '' + options + '
        ' + type + '
        '; - } + buffer[offset + i - d] |= s * 128 +} - return html; - } - function processModel(schema, name) { - var type = schema.type || 'object'; - var isArray = schema.type === 'array'; - var html = strongOpen + name + ' ' + (isArray ? '[' : '{') + strongClose; +},{}],17:[function(require,module,exports){ - if (name) { - seenModels.push(name); - } +/** + * isArray + */ - if (isArray) { - if (_.isArray(schema.items)) { - html += '
        ' + _.map(schema.items, function (item) { - var type = item.type || 'object'; +var isArray = Array.isArray; - if (_.isUndefined(item.$ref)) { - if (_.indexOf(['array', 'object'], type) > -1) { - if (type === 'object' && _.isUndefined(item.properties)) { - return 'object'; - } +/** + * toString + */ - return addReference(item); +var str = Object.prototype.toString; - } +/** + * Whether or not the given `val` + * is an array. + * + * example: + * + * isArray([]); + * // > true + * isArray(arguments); + * // > false + * isArray(''); + * // > false + * + * @param {mixed} val + * @return {bool} + */ - return primitiveToOptionsHTML(item, type); +module.exports = isArray || function (val) { + return !! val && '[object Array]' == str.call(val); +}; - } +},{}],18:[function(require,module,exports){ +/* jshint node: true */ +(function () { + "use strict"; + + function CookieAccessInfo(domain, path, secure, script) { + if (this instanceof CookieAccessInfo) { + this.domain = domain || undefined; + this.path = path || "/"; + this.secure = !!secure; + this.script = !!script; + return this; + } + return new CookieAccessInfo(domain, path, secure, script); + } + exports.CookieAccessInfo = CookieAccessInfo; - return addReference(item, Helpers.simpleRef(item.$ref)); - - }).join(',
        '); - } else if (_.isPlainObject(schema.items)) { - if (_.isUndefined(schema.items.$ref)) { - if (_.indexOf(['array', 'object'], schema.items.type || 'object') > -1) { - if ((_.isUndefined(schema.items.type) || schema.items.type === 'object') && _.isUndefined(schema.items.properties)) { - html += '
        object
        '; - } else { - html += '
        ' + addReference(schema.items) + '
        '; - } - } else { - html += '
        ' + primitiveToOptionsHTML(schema.items, schema.items.type) + '
        '; - } - } else { - html += '
        ' + addReference(schema.items, Helpers.simpleRef(schema.items.$ref)) + '
        '; - } - } else { - Helpers.log('Array type\'s \'items\' property is not an array or an object, cannot process'); - html += '
        object
        '; - } - } else if (schema.$ref) { - html += '
        ' + addReference(schema, name) + '
        '; - } else if (type === 'object') { - html += '
        '; - - if (_.isPlainObject(schema.properties)) { - html += _.map(schema.properties, function (property, name) { - var propertyIsRequired = _.indexOf(schema.required, name) >= 0; - var cProperty = _.cloneDeep(property); - - var requiredClass = propertyIsRequired ? 'required' : ''; - var html = '' + name + ' ('; - var model; - - // Allow macro to set the default value - cProperty.default = modelPropertyMacro(cProperty); - - // Resolve the schema (Handle nested schemas) - cProperty = Helpers.resolveSchema(cProperty); - - // We need to handle property references to primitives (Issue 339) - if (!_.isUndefined(cProperty.$ref)) { - model = models[Helpers.simpleRef(cProperty.$ref)]; - - if (!_.isUndefined(model) && _.indexOf([undefined, 'array', 'object'], model.definition.type) === -1) { - // Use referenced schema - cProperty = Helpers.resolveSchema(model.definition); - } - } + function Cookie(cookiestr, request_domain, request_path) { + if (cookiestr instanceof Cookie) { + return cookiestr; + } + if (this instanceof Cookie) { + this.name = null; + this.value = null; + this.expiration_date = Infinity; + this.path = String(request_path || "/"); + this.explicit_path = false; + this.domain = request_domain || null; + this.explicit_domain = false; + this.secure = false; //how to define default? + this.noscript = false; //httponly + if (cookiestr) { + this.parse(cookiestr, request_domain, request_path); + } + return this; + } + return new Cookie(cookiestr, request_domain, request_path); + } + exports.Cookie = Cookie; - html += primitiveToHTML(cProperty); + Cookie.prototype.toString = function toString() { + var str = [this.name + "=" + this.value]; + if (this.expiration_date !== Infinity) { + str.push("expires=" + (new Date(this.expiration_date)).toGMTString()); + } + if (this.domain) { + str.push("domain=" + this.domain); + } + if (this.path) { + str.push("path=" + this.path); + } + if (this.secure) { + str.push("secure"); + } + if (this.noscript) { + str.push("httponly"); + } + return str.join("; "); + }; - if (!propertyIsRequired) { - html += ', optional'; - } + Cookie.prototype.toValueString = function toValueString() { + return this.name + "=" + this.value; + }; - html += ')'; + var cookie_str_splitter = /[:](?=\s*[a-zA-Z0-9_\-]+\s*[=])/g; + Cookie.prototype.parse = function parse(str, request_domain, request_path) { + if (this instanceof Cookie) { + var parts = str.split(";").filter(function (value) { + return !!value; + }), + pair = parts[0].match(/([^=]+)=([\s\S]*)/), + key = pair[1], + value = pair[2], + i; + this.name = key; + this.value = value; + + for (i = 1; i < parts.length; i += 1) { + pair = parts[i].match(/([^=]+)(?:=([\s\S]*))?/); + key = pair[1].trim().toLowerCase(); + value = pair[2]; + switch (key) { + case "httponly": + this.noscript = true; + break; + case "expires": + this.expiration_date = value ? + Number(Date.parse(value)) : + Infinity; + break; + case "path": + this.path = value ? + value.trim() : + ""; + this.explicit_path = true; + break; + case "domain": + this.domain = value ? + value.trim() : + ""; + this.explicit_domain = !!this.domain; + break; + case "secure": + this.secure = true; + break; + } + } - if (!_.isUndefined(cProperty.description)) { - html += ': ' + '' + cProperty.description + ''; - } + if (!this.explicit_path) { + this.path = request_path || "/"; + } + if (!this.explicit_domain) { + this.domain = request_domain; + } - if (cProperty.enum) { - html += ' = [\'' + cProperty.enum.join('\', \'') + '\']'; - } + return this; + } + return new Cookie().parse(str, request_domain, request_path); + }; - return primitiveToOptionsHTML(cProperty, html); - }).join(',
        '); - } + Cookie.prototype.matches = function matches(access_info) { + if (this.noscript && access_info.script || + this.secure && !access_info.secure || + !this.collidesWith(access_info)) { + return false; + } + return true; + }; - html += '
        '; - } else { - html += '
        ' + primitiveToOptionsHTML(schema, type) + '
        '; - } + Cookie.prototype.collidesWith = function collidesWith(access_info) { + if ((this.path && !access_info.path) || (this.domain && !access_info.domain)) { + return false; + } + if (this.path && access_info.path.indexOf(this.path) !== 0) { + return false; + } + if (this.explicit_path && access_info.path.indexOf( this.path ) !== 0) { + return false; + } + var access_domain = access_info.domain && access_info.domain.replace(/^[\.]/,''); + var cookie_domain = this.domain && this.domain.replace(/^[\.]/,''); + if (cookie_domain === access_domain) { + return true; + } + if (cookie_domain) { + if (!this.explicit_domain) { + return false; // we already checked if the domains were exactly the same + } + var wildcard = access_domain.indexOf(cookie_domain); + if (wildcard === -1 || wildcard !== access_domain.length - cookie_domain.length) { + return false; + } + return true; + } + return true; + }; - return html + strongOpen + (isArray ? ']' : '}') + strongClose; + function CookieJar() { + var cookies, cookies_list, collidable_cookie; + if (this instanceof CookieJar) { + cookies = Object.create(null); //name: [Cookie] + + this.setCookie = function setCookie(cookie, request_domain, request_path) { + var remove, i; + cookie = new Cookie(cookie, request_domain, request_path); + //Delete the cookie if the set is past the current time + remove = cookie.expiration_date <= Date.now(); + if (cookies[cookie.name] !== undefined) { + cookies_list = cookies[cookie.name]; + for (i = 0; i < cookies_list.length; i += 1) { + collidable_cookie = cookies_list[i]; + if (collidable_cookie.collidesWith(cookie)) { + if (remove) { + cookies_list.splice(i, 1); + if (cookies_list.length === 0) { + delete cookies[cookie.name]; + } + return false; + } + cookies_list[i] = cookie; + return cookie; + } } - + if (remove) { + return false; + } + cookies_list.push(cookie); + return cookie; } + if (remove) { + return false; + } + cookies[cookie.name] = [cookie]; + return cookies[cookie.name]; + }; + //returns a cookie + this.getCookie = function getCookie(cookie_name, access_info) { + var cookie, i; + cookies_list = cookies[cookie_name]; + if (!cookies_list) { + return; + } + for (i = 0; i < cookies_list.length; i += 1) { + cookie = cookies_list[i]; + if (cookie.expiration_date <= Date.now()) { + if (cookies_list.length === 0) { + delete cookies[cookie.name]; + } + continue; + } - },{ - './helpers': 4,'lodash-compat/array/indexOf': 52,'lodash-compat/collection/forEach': 57,'lodash-compat/collection/map': 59,'lodash-compat/lang/cloneDeep': 141,'lodash-compat/lang/isArray': 143,'lodash-compat/lang/isEmpty': 144,'lodash-compat/lang/isObject': 147,'lodash-compat/lang/isPlainObject': 148,'lodash-compat/lang/isUndefined': 151,'lodash-compat/object/keys': 152 - }],8: [function (require, module, exports) { - 'use strict'; - - var SwaggerHttp = require('./http'); - var _ = { - isObject: require('lodash-compat/lang/isObject') + if (cookie.matches(access_info)) { + return cookie; + } + } + }; + //returns a list of cookies + this.getCookies = function getCookies(access_info) { + var matches = [], cookie_name, cookie; + for (cookie_name in cookies) { + cookie = this.getCookie(cookie_name, access_info); + if (cookie) { + matches.push(cookie); + } + } + matches.toString = function toString() { + return matches.join(":"); }; - - var SwaggerSpecConverter = module.exports = function () { - this.errors = []; - this.warnings = []; - this.modelMap = {}; + matches.toValueString = function toValueString() { + return matches.map(function (c) { + return c.toValueString(); + }).join(';'); }; + return matches; + }; - SwaggerSpecConverter.prototype.setDocumentationLocation = function (location) { - this.docLocation = location; - }; + return this; + } + return new CookieJar(); + } + exports.CookieJar = CookieJar; + + //returns list of cookies that were set correctly. Cookies that are expired and removed are not returned. + CookieJar.prototype.setCookies = function setCookies(cookies, request_domain, request_path) { + cookies = Array.isArray(cookies) ? + cookies : + cookies.split(cookie_str_splitter); + var successful = [], + i, + cookie; + cookies = cookies.map(function(item){ + return new Cookie(item, request_domain, request_path); + }); + for (i = 0; i < cookies.length; i += 1) { + cookie = cookies[i]; + if (this.setCookie(cookie, request_domain, request_path)) { + successful.push(cookie); + } + } + return successful; + }; +}()); - /** - * converts a resource listing OR api declaration - **/ - SwaggerSpecConverter.prototype.convert = function (obj, clientAuthorizations, callback) { - // not a valid spec - if (!obj || !Array.isArray(obj.apis)) { - return this.finish(callback, null); - } - this.clientAuthorizations = clientAuthorizations; +},{}],19:[function(require,module,exports){ +'use strict'; - // create a new swagger object to return - var swagger = { - swagger: '2.0' - }; - swagger.originalVersion = obj.swaggerVersion; +var yaml = require('./lib/js-yaml.js'); - // add the info - this.apiInfo(obj, swagger); - // add security definitions - this.securityDefinitions(obj, swagger); +module.exports = yaml; - // take basePath into account - if (obj.basePath) { - this.setDocumentationLocation(obj.basePath); - } +},{"./lib/js-yaml.js":20}],20:[function(require,module,exports){ +'use strict'; - // see if this is a single-file swagger definition - var isSingleFileSwagger = false; - var i; - for (i = 0; i < obj.apis.length; i++) { - var api = obj.apis[i]; +var loader = require('./js-yaml/loader'); +var dumper = require('./js-yaml/dumper'); - if (Array.isArray(api.operations)) { - isSingleFileSwagger = true; - } - } - if (isSingleFileSwagger) { - this.declaration(obj, swagger); - this.finish(callback, swagger); - } else { - this.resourceListing(obj, swagger, callback); - } - }; +function deprecated(name) { + return function () { + throw new Error('Function ' + name + ' is deprecated and cannot be used.'); + }; +} - SwaggerSpecConverter.prototype.declaration = function (obj, swagger) { - var name, i, p, pos; - if (!obj.apis) { - return; - } +module.exports.Type = require('./js-yaml/type'); +module.exports.Schema = require('./js-yaml/schema'); +module.exports.FAILSAFE_SCHEMA = require('./js-yaml/schema/failsafe'); +module.exports.JSON_SCHEMA = require('./js-yaml/schema/json'); +module.exports.CORE_SCHEMA = require('./js-yaml/schema/core'); +module.exports.DEFAULT_SAFE_SCHEMA = require('./js-yaml/schema/default_safe'); +module.exports.DEFAULT_FULL_SCHEMA = require('./js-yaml/schema/default_full'); +module.exports.load = loader.load; +module.exports.loadAll = loader.loadAll; +module.exports.safeLoad = loader.safeLoad; +module.exports.safeLoadAll = loader.safeLoadAll; +module.exports.dump = dumper.dump; +module.exports.safeDump = dumper.safeDump; +module.exports.YAMLException = require('./js-yaml/exception'); - if (obj.basePath.indexOf('http://') === 0) { - p = obj.basePath.substring('http://'.length); - pos = p.indexOf('/'); +// Deprecated schema names from JS-YAML 2.0.x +module.exports.MINIMAL_SCHEMA = require('./js-yaml/schema/failsafe'); +module.exports.SAFE_SCHEMA = require('./js-yaml/schema/default_safe'); +module.exports.DEFAULT_SCHEMA = require('./js-yaml/schema/default_full'); - if (pos > 0) { - swagger.host = p.substring(0, pos); - swagger.basePath = p.substring(pos); - } else { - swagger.host = p; - swagger.basePath = '/'; - } - } else if (obj.basePath.indexOf('https://') === 0) { - p = obj.basePath.substring('https://'.length); - pos = p.indexOf('/'); - - if (pos > 0) { - swagger.host = p.substring(0, pos); - swagger.basePath = p.substring(pos); - } else { - swagger.host = p; - swagger.basePath = '/'; - } - } else { - swagger.basePath = obj.basePath; - } +// Deprecated functions from JS-YAML 1.x.x +module.exports.scan = deprecated('scan'); +module.exports.parse = deprecated('parse'); +module.exports.compose = deprecated('compose'); +module.exports.addConstructor = deprecated('addConstructor'); - var resourceLevelAuth; +},{"./js-yaml/dumper":22,"./js-yaml/exception":23,"./js-yaml/loader":24,"./js-yaml/schema":26,"./js-yaml/schema/core":27,"./js-yaml/schema/default_full":28,"./js-yaml/schema/default_safe":29,"./js-yaml/schema/failsafe":30,"./js-yaml/schema/json":31,"./js-yaml/type":32}],21:[function(require,module,exports){ +'use strict'; - if (obj.authorizations) { - resourceLevelAuth = obj.authorizations; - } - if (obj.consumes) { - swagger.consumes = obj.consumes; - } +function isNothing(subject) { + return (typeof subject === 'undefined') || (subject === null); +} - if (obj.produces) { - swagger.produces = obj.produces; - } - // build a mapping of id to name for 1.0 model resolutions - if (_.isObject(obj)) { - for (name in obj.models) { - var existingModel = obj.models[name]; - var key = existingModel.id || name; +function isObject(subject) { + return (typeof subject === 'object') && (subject !== null); +} - this.modelMap[key] = name; - } - } - for (i = 0; i < obj.apis.length; i++) { - var api = obj.apis[i]; - var path = api.path; - var operations = api.operations; +function toArray(sequence) { + if (Array.isArray(sequence)) return sequence; + else if (isNothing(sequence)) return []; - this.operations(path, obj.resourcePath, operations, resourceLevelAuth, swagger); - } + return [ sequence ]; +} - var models = obj.models || {}; - this.models(models, swagger); - }; +function extend(target, source) { + var index, length, key, sourceKeys; - SwaggerSpecConverter.prototype.models = function (obj, swagger) { - if (!_.isObject(obj)) { - return; - } - var name; + if (source) { + sourceKeys = Object.keys(source); - swagger.definitions = swagger.definitions || {}; + for (index = 0, length = sourceKeys.length; index < length; index += 1) { + key = sourceKeys[index]; + target[key] = source[key]; + } + } + + return target; +} + + +function repeat(string, count) { + var result = '', cycle; + + for (cycle = 0; cycle < count; cycle += 1) { + result += string; + } + + return result; +} + + +function isNegativeZero(number) { + return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number); +} + + +module.exports.isNothing = isNothing; +module.exports.isObject = isObject; +module.exports.toArray = toArray; +module.exports.repeat = repeat; +module.exports.isNegativeZero = isNegativeZero; +module.exports.extend = extend; + +},{}],22:[function(require,module,exports){ +'use strict'; + +/*eslint-disable no-use-before-define*/ + +var common = require('./common'); +var YAMLException = require('./exception'); +var DEFAULT_FULL_SCHEMA = require('./schema/default_full'); +var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe'); + +var _toString = Object.prototype.toString; +var _hasOwnProperty = Object.prototype.hasOwnProperty; + +var CHAR_TAB = 0x09; /* Tab */ +var CHAR_LINE_FEED = 0x0A; /* LF */ +var CHAR_SPACE = 0x20; /* Space */ +var CHAR_EXCLAMATION = 0x21; /* ! */ +var CHAR_DOUBLE_QUOTE = 0x22; /* " */ +var CHAR_SHARP = 0x23; /* # */ +var CHAR_PERCENT = 0x25; /* % */ +var CHAR_AMPERSAND = 0x26; /* & */ +var CHAR_SINGLE_QUOTE = 0x27; /* ' */ +var CHAR_ASTERISK = 0x2A; /* * */ +var CHAR_COMMA = 0x2C; /* , */ +var CHAR_MINUS = 0x2D; /* - */ +var CHAR_COLON = 0x3A; /* : */ +var CHAR_GREATER_THAN = 0x3E; /* > */ +var CHAR_QUESTION = 0x3F; /* ? */ +var CHAR_COMMERCIAL_AT = 0x40; /* @ */ +var CHAR_LEFT_SQUARE_BRACKET = 0x5B; /* [ */ +var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; /* ] */ +var CHAR_GRAVE_ACCENT = 0x60; /* ` */ +var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */ +var CHAR_VERTICAL_LINE = 0x7C; /* | */ +var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */ + +var ESCAPE_SEQUENCES = {}; + +ESCAPE_SEQUENCES[0x00] = '\\0'; +ESCAPE_SEQUENCES[0x07] = '\\a'; +ESCAPE_SEQUENCES[0x08] = '\\b'; +ESCAPE_SEQUENCES[0x09] = '\\t'; +ESCAPE_SEQUENCES[0x0A] = '\\n'; +ESCAPE_SEQUENCES[0x0B] = '\\v'; +ESCAPE_SEQUENCES[0x0C] = '\\f'; +ESCAPE_SEQUENCES[0x0D] = '\\r'; +ESCAPE_SEQUENCES[0x1B] = '\\e'; +ESCAPE_SEQUENCES[0x22] = '\\"'; +ESCAPE_SEQUENCES[0x5C] = '\\\\'; +ESCAPE_SEQUENCES[0x85] = '\\N'; +ESCAPE_SEQUENCES[0xA0] = '\\_'; +ESCAPE_SEQUENCES[0x2028] = '\\L'; +ESCAPE_SEQUENCES[0x2029] = '\\P'; + +var DEPRECATED_BOOLEANS_SYNTAX = [ + 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON', + 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF' +]; + +function compileStyleMap(schema, map) { + var result, keys, index, length, tag, style, type; + + if (map === null) return {}; + + result = {}; + keys = Object.keys(map); + + for (index = 0, length = keys.length; index < length; index += 1) { + tag = keys[index]; + style = String(map[tag]); + + if (tag.slice(0, 2) === '!!') { + tag = 'tag:yaml.org,2002:' + tag.slice(2); + } - for (name in obj) { - var existingModel = obj[name]; - var _enum = []; - var schema = { - properties: {} - }; - var propertyName; + type = schema.compiledTypeMap[tag]; - for (propertyName in existingModel.properties) { - var existingProperty = existingModel.properties[propertyName]; - var property = {}; + if (type && _hasOwnProperty.call(type.styleAliases, style)) { + style = type.styleAliases[style]; + } - this.dataType(existingProperty, property); + result[tag] = style; + } + + return result; +} + +function encodeHex(character) { + var string, handle, length; + + string = character.toString(16).toUpperCase(); + + if (character <= 0xFF) { + handle = 'x'; + length = 2; + } else if (character <= 0xFFFF) { + handle = 'u'; + length = 4; + } else if (character <= 0xFFFFFFFF) { + handle = 'U'; + length = 8; + } else { + throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF'); + } + + return '\\' + handle + common.repeat('0', length - string.length) + string; +} + +function State(options) { + this.schema = options['schema'] || DEFAULT_FULL_SCHEMA; + this.indent = Math.max(1, (options['indent'] || 2)); + this.skipInvalid = options['skipInvalid'] || false; + this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']); + this.styleMap = compileStyleMap(this.schema, options['styles'] || null); + this.sortKeys = options['sortKeys'] || false; + this.lineWidth = options['lineWidth'] || 80; + this.noRefs = options['noRefs'] || false; + this.noCompatMode = options['noCompatMode'] || false; + + this.implicitTypes = this.schema.compiledImplicit; + this.explicitTypes = this.schema.compiledExplicit; + + this.tag = null; + this.result = ''; + + this.duplicates = []; + this.usedDuplicates = null; +} + +// Indents every line in a string. Empty lines (\n only) are not indented. +function indentString(string, spaces) { + var ind = common.repeat(' ', spaces), + position = 0, + next = -1, + result = '', + line, + length = string.length; + + while (position < length) { + next = string.indexOf('\n', position); + if (next === -1) { + line = string.slice(position); + position = length; + } else { + line = string.slice(position, next + 1); + position = next + 1; + } - if (existingProperty.description) { - property.description = existingProperty.description; - } + if (line.length && line !== '\n') result += ind; - if (existingProperty['enum']) { - property['enum'] = existingProperty['enum']; - } + result += line; + } - if (typeof existingProperty.required === 'boolean' && existingProperty.required === true) { - _enum.push(propertyName); - } + return result; +} - if (typeof existingProperty.required === 'string' && existingProperty.required === 'true') { - _enum.push(propertyName); - } - schema.properties[propertyName] = property; - } +function generateNextLine(state, level) { + return '\n' + common.repeat(' ', state.indent * level); +} - if (_enum.length > 0) { - schema['enum'] = _enum; - } +function testImplicitResolving(state, str) { + var index, length, type; - schema.required = existingModel.required; - swagger.definitions[name] = schema; - } - }; + for (index = 0, length = state.implicitTypes.length; index < length; index += 1) { + type = state.implicitTypes[index]; - SwaggerSpecConverter.prototype.extractTag = function (resourcePath) { - var pathString = resourcePath || 'default'; + if (type.resolve(str)) { + return true; + } + } + + return false; +} + +// [33] s-white ::= s-space | s-tab +function isWhitespace(c) { + return c === CHAR_SPACE || c === CHAR_TAB; +} + +// Returns true if the character can be printed without escaping. +// From YAML 1.2: "any allowed characters known to be non-printable +// should also be escaped. [However,] This isn’t mandatory" +// Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029. +function isPrintable(c) { + return (0x00020 <= c && c <= 0x00007E) + || ((0x000A1 <= c && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029) + || ((0x0E000 <= c && c <= 0x00FFFD) && c !== 0xFEFF /* BOM */) + || (0x10000 <= c && c <= 0x10FFFF); +} + +// Simplified test for values allowed after the first character in plain style. +function isPlainSafe(c) { + // Uses a subset of nb-char - c-flow-indicator - ":" - "#" + // where nb-char ::= c-printable - b-char - c-byte-order-mark. + return isPrintable(c) && c !== 0xFEFF + // - c-flow-indicator + && c !== CHAR_COMMA + && c !== CHAR_LEFT_SQUARE_BRACKET + && c !== CHAR_RIGHT_SQUARE_BRACKET + && c !== CHAR_LEFT_CURLY_BRACKET + && c !== CHAR_RIGHT_CURLY_BRACKET + // - ":" - "#" + && c !== CHAR_COLON + && c !== CHAR_SHARP; +} + +// Simplified test for values allowed as the first character in plain style. +function isPlainSafeFirst(c) { + // Uses a subset of ns-char - c-indicator + // where ns-char = nb-char - s-white. + return isPrintable(c) && c !== 0xFEFF + && !isWhitespace(c) // - s-white + // - (c-indicator ::= + // “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}” + && c !== CHAR_MINUS + && c !== CHAR_QUESTION + && c !== CHAR_COLON + && c !== CHAR_COMMA + && c !== CHAR_LEFT_SQUARE_BRACKET + && c !== CHAR_RIGHT_SQUARE_BRACKET + && c !== CHAR_LEFT_CURLY_BRACKET + && c !== CHAR_RIGHT_CURLY_BRACKET + // | “#” | “&” | “*” | “!” | “|” | “>” | “'” | “"” + && c !== CHAR_SHARP + && c !== CHAR_AMPERSAND + && c !== CHAR_ASTERISK + && c !== CHAR_EXCLAMATION + && c !== CHAR_VERTICAL_LINE + && c !== CHAR_GREATER_THAN + && c !== CHAR_SINGLE_QUOTE + && c !== CHAR_DOUBLE_QUOTE + // | “%” | “@” | “`”) + && c !== CHAR_PERCENT + && c !== CHAR_COMMERCIAL_AT + && c !== CHAR_GRAVE_ACCENT; +} + +var STYLE_PLAIN = 1, + STYLE_SINGLE = 2, + STYLE_LITERAL = 3, + STYLE_FOLDED = 4, + STYLE_DOUBLE = 5; + +// Determines which scalar styles are possible and returns the preferred style. +// lineWidth = -1 => no limit. +// Pre-conditions: str.length > 0. +// Post-conditions: +// STYLE_PLAIN or STYLE_SINGLE => no \n are in the string. +// STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1). +// STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1). +function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType) { + var i; + var char; + var hasLineBreak = false; + var hasFoldableLine = false; // only checked if shouldTrackWidth + var shouldTrackWidth = lineWidth !== -1; + var previousLineBreak = -1; // count the first line correctly + var plain = isPlainSafeFirst(string.charCodeAt(0)) + && !isWhitespace(string.charCodeAt(string.length - 1)); + + if (singleLineOnly) { + // Case: no block styles. + // Check for disallowed characters to rule out plain and single. + for (i = 0; i < string.length; i++) { + char = string.charCodeAt(i); + if (!isPrintable(char)) { + return STYLE_DOUBLE; + } + plain = plain && isPlainSafe(char); + } + } else { + // Case: block styles permitted. + for (i = 0; i < string.length; i++) { + char = string.charCodeAt(i); + if (char === CHAR_LINE_FEED) { + hasLineBreak = true; + // Check if any line can be folded. + if (shouldTrackWidth) { + hasFoldableLine = hasFoldableLine || + // Foldable line = too long, and not more-indented. + (i - previousLineBreak - 1 > lineWidth && + string[previousLineBreak + 1] !== ' '); + previousLineBreak = i; + } + } else if (!isPrintable(char)) { + return STYLE_DOUBLE; + } + plain = plain && isPlainSafe(char); + } + // in case the end is missing a \n + hasFoldableLine = hasFoldableLine || (shouldTrackWidth && + (i - previousLineBreak - 1 > lineWidth && + string[previousLineBreak + 1] !== ' ')); + } + // Although every style can represent \n without escaping, prefer block styles + // for multiline, since they're more readable and they don't add empty lines. + // Also prefer folding a super-long line. + if (!hasLineBreak && !hasFoldableLine) { + // Strings interpretable as another type have to be quoted; + // e.g. the string 'true' vs. the boolean true. + return plain && !testAmbiguousType(string) + ? STYLE_PLAIN : STYLE_SINGLE; + } + // Edge case: block indentation indicator can only have one digit. + if (string[0] === ' ' && indentPerLevel > 9) { + return STYLE_DOUBLE; + } + // At this point we know block styles are valid. + // Prefer literal style unless we want to fold. + return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL; +} + +// Note: line breaking/folding is implemented for only the folded style. +// NB. We drop the last trailing newline (if any) of a returned block scalar +// since the dumper adds its own newline. This always works: +// • No ending newline => unaffected; already using strip "-" chomping. +// • Ending newline => removed then restored. +// Importantly, this keeps the "+" chomp indicator from gaining an extra line. +function writeScalar(state, string, level, iskey) { + state.dump = (function () { + if (string.length === 0) { + return "''"; + } + if (!state.noCompatMode && + DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1) { + return "'" + string + "'"; + } - if (pathString.indexOf('http:') === 0 || pathString.indexOf('https:') === 0) { - pathString = pathString.split(['/']); - pathString = pathString[pathString.length - 1].substring(); - } + var indent = state.indent * Math.max(1, level); // no 0-indent scalars + // As indentation gets deeper, let the width decrease monotonically + // to the lower bound min(state.lineWidth, 40). + // Note that this implies + // state.lineWidth ≤ 40 + state.indent: width is fixed at the lower bound. + // state.lineWidth > 40 + state.indent: width decreases until the lower bound. + // This behaves better than a constant minimum width which disallows narrower options, + // or an indent threshold which causes the width to suddenly increase. + var lineWidth = state.lineWidth === -1 + ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent); + + // Without knowing if keys are implicit/explicit, assume implicit for safety. + var singleLineOnly = iskey + // No block styles in flow mode. + || (state.flowLevel > -1 && level >= state.flowLevel); + function testAmbiguity(string) { + return testImplicitResolving(state, string); + } - if (pathString.endsWith('.json')) { - pathString = pathString.substring(0, pathString.length - '.json'.length); - } + switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity)) { + case STYLE_PLAIN: + return string; + case STYLE_SINGLE: + return "'" + string.replace(/'/g, "''") + "'"; + case STYLE_LITERAL: + return '|' + blockHeader(string, state.indent) + + dropEndingNewline(indentString(string, indent)); + case STYLE_FOLDED: + return '>' + blockHeader(string, state.indent) + + dropEndingNewline(indentString(foldString(string, lineWidth), indent)); + case STYLE_DOUBLE: + return '"' + escapeString(string, lineWidth) + '"'; + default: + throw new YAMLException('impossible error: invalid scalar style'); + } + }()); +} + +// Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9. +function blockHeader(string, indentPerLevel) { + var indentIndicator = (string[0] === ' ') ? String(indentPerLevel) : ''; + + // note the special case: the string '\n' counts as a "trailing" empty line. + var clip = string[string.length - 1] === '\n'; + var keep = clip && (string[string.length - 2] === '\n' || string === '\n'); + var chomp = keep ? '+' : (clip ? '' : '-'); + + return indentIndicator + chomp + '\n'; +} + +// (See the note for writeScalar.) +function dropEndingNewline(string) { + return string[string.length - 1] === '\n' ? string.slice(0, -1) : string; +} + +// Note: a long line without a suitable break point will exceed the width limit. +// Pre-conditions: every char in str isPrintable, str.length > 0, width > 0. +function foldString(string, width) { + // In folded style, $k$ consecutive newlines output as $k+1$ newlines— + // unless they're before or after a more-indented line, or at the very + // beginning or end, in which case $k$ maps to $k$. + // Therefore, parse each chunk as newline(s) followed by a content line. + var lineRe = /(\n+)([^\n]*)/g; + + // first line (possibly an empty line) + var result = (function () { + var nextLF = string.indexOf('\n'); + nextLF = nextLF !== -1 ? nextLF : string.length; + lineRe.lastIndex = nextLF; + return foldLine(string.slice(0, nextLF), width); + }()); + // If we haven't reached the first content line yet, don't add an extra \n. + var prevMoreIndented = string[0] === '\n' || string[0] === ' '; + var moreIndented; + + // rest of the lines + var match; + while ((match = lineRe.exec(string))) { + var prefix = match[1], line = match[2]; + moreIndented = (line[0] === ' '); + result += prefix + + (!prevMoreIndented && !moreIndented && line !== '' + ? '\n' : '') + + foldLine(line, width); + prevMoreIndented = moreIndented; + } + + return result; +} + +// Greedy line breaking. +// Picks the longest line under the limit each time, +// otherwise settles for the shortest line over the limit. +// NB. More-indented lines *cannot* be folded, as that would add an extra \n. +function foldLine(line, width) { + if (line === '' || line[0] === ' ') return line; + + // Since a more-indented line adds a \n, breaks can't be followed by a space. + var breakRe = / [^ ]/g; // note: the match index will always be <= length-2. + var match; + // start is an inclusive index. end, curr, and next are exclusive. + var start = 0, end, curr = 0, next = 0; + var result = ''; + + // Invariants: 0 <= start <= length-1. + // 0 <= curr <= next <= max(0, length-2). curr - start <= width. + // Inside the loop: + // A match implies length >= 2, so curr and next are <= length-2. + while ((match = breakRe.exec(line))) { + next = match.index; + // maintain invariant: curr - start <= width + if (next - start > width) { + end = (curr > start) ? curr : next; // derive end <= length-2 + result += '\n' + line.slice(start, end); + // skip the space that was output as \n + start = end + 1; // derive start <= length-1 + } + curr = next; + } + + // By the invariants, start <= length-1, so there is something left over. + // It is either the whole string or a part starting from non-whitespace. + result += '\n'; + // Insert a break if the remainder is too long and there is a break available. + if (line.length - start > width && curr > start) { + result += line.slice(start, curr) + '\n' + line.slice(curr + 1); + } else { + result += line.slice(start); + } + + return result.slice(1); // drop extra \n joiner +} + +// Escapes a double-quoted string. +function escapeString(string) { + var result = ''; + var char; + var escapeSeq; + + for (var i = 0; i < string.length; i++) { + char = string.charCodeAt(i); + escapeSeq = ESCAPE_SEQUENCES[char]; + result += !escapeSeq && isPrintable(char) + ? string[i] + : escapeSeq || encodeHex(char); + } + + return result; +} + +function writeFlowSequence(state, level, object) { + var _result = '', + _tag = state.tag, + index, + length; + + for (index = 0, length = object.length; index < length; index += 1) { + // Write only valid elements. + if (writeNode(state, level, object[index], false, false)) { + if (index !== 0) _result += ', '; + _result += state.dump; + } + } + + state.tag = _tag; + state.dump = '[' + _result + ']'; +} + +function writeBlockSequence(state, level, object, compact) { + var _result = '', + _tag = state.tag, + index, + length; + + for (index = 0, length = object.length; index < length; index += 1) { + // Write only valid elements. + if (writeNode(state, level + 1, object[index], true, true)) { + if (!compact || index !== 0) { + _result += generateNextLine(state, level); + } + _result += '- ' + state.dump; + } + } - return pathString.replace('/', ''); - }; + state.tag = _tag; + state.dump = _result || '[]'; // Empty sequence if no valid values. +} - SwaggerSpecConverter.prototype.operations = function (path, resourcePath, obj, resourceLevelAuth, swagger) { - if (!Array.isArray(obj)) { - return; - } - var i; +function writeFlowMapping(state, level, object) { + var _result = '', + _tag = state.tag, + objectKeyList = Object.keys(object), + index, + length, + objectKey, + objectValue, + pairBuffer; - if (!swagger.paths) { - swagger.paths = {}; - } + for (index = 0, length = objectKeyList.length; index < length; index += 1) { + pairBuffer = ''; - var pathObj = swagger.paths[path] || {}; - var tag = this.extractTag(resourcePath); + if (index !== 0) pairBuffer += ', '; - swagger.tags = swagger.tags || []; - var matched = false; + objectKey = objectKeyList[index]; + objectValue = object[objectKey]; - for (i = 0; i < swagger.tags.length; i++) { - var tagObject = swagger.tags[i]; + if (!writeNode(state, level, objectKey, false, false)) { + continue; // Skip this pair because of invalid key; + } - if (tagObject.name === tag) { - matched = true; - } - } + if (state.dump.length > 1024) pairBuffer += '? '; - if (!matched) { - swagger.tags.push({ - name: tag - }); - } + pairBuffer += state.dump + ': '; - for (i = 0; i < obj.length; i++) { - var existingOperation = obj[i]; - var method = (existingOperation.method || existingOperation.httpMethod).toLowerCase(); - var operation = { - tags: [tag] - }; - var existingAuthorizations = existingOperation.authorizations; + if (!writeNode(state, level, objectValue, false, false)) { + continue; // Skip this pair because of invalid value. + } - if (existingAuthorizations && Object.keys(existingAuthorizations).length === 0) { - existingAuthorizations = resourceLevelAuth; - } + pairBuffer += state.dump; + + // Both key and value are valid. + _result += pairBuffer; + } + + state.tag = _tag; + state.dump = '{' + _result + '}'; +} + +function writeBlockMapping(state, level, object, compact) { + var _result = '', + _tag = state.tag, + objectKeyList = Object.keys(object), + index, + length, + objectKey, + objectValue, + explicitPair, + pairBuffer; + + // Allow sorting keys so that the output file is deterministic + if (state.sortKeys === true) { + // Default sorting + objectKeyList.sort(); + } else if (typeof state.sortKeys === 'function') { + // Custom sort function + objectKeyList.sort(state.sortKeys); + } else if (state.sortKeys) { + // Something is wrong + throw new YAMLException('sortKeys must be a boolean or a function'); + } + + for (index = 0, length = objectKeyList.length; index < length; index += 1) { + pairBuffer = ''; + + if (!compact || index !== 0) { + pairBuffer += generateNextLine(state, level); + } - if (typeof existingAuthorizations !== 'undefined') { - var scopesObject; + objectKey = objectKeyList[index]; + objectValue = object[objectKey]; - for (var key in existingAuthorizations) { - operation.security = operation.security || []; - var scopes = existingAuthorizations[key]; + if (!writeNode(state, level + 1, objectKey, true, true, true)) { + continue; // Skip this pair because of invalid key. + } - if (scopes) { - var securityScopes = []; + explicitPair = (state.tag !== null && state.tag !== '?') || + (state.dump && state.dump.length > 1024); - for (var j in scopes) { - securityScopes.push(scopes[j].scope); - } - scopesObject = {}; - scopesObject[key] = securityScopes; - operation.security.push(scopesObject); - } else { - scopesObject = {}; - scopesObject[key] = []; - operation.security.push(scopesObject); - } - } - } + if (explicitPair) { + if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { + pairBuffer += '?'; + } else { + pairBuffer += '? '; + } + } - if (existingOperation.consumes) { - operation.consumes = existingOperation.consumes; - } else if (swagger.consumes) { - operation.consumes = swagger.consumes; - } + pairBuffer += state.dump; - if (existingOperation.produces) { - operation.produces = existingOperation.produces; - } else if (swagger.produces) { - operation.produces = swagger.produces; - } + if (explicitPair) { + pairBuffer += generateNextLine(state, level); + } - if (existingOperation.summary) { - operation.summary = existingOperation.summary; - } + if (!writeNode(state, level + 1, objectValue, true, explicitPair)) { + continue; // Skip this pair because of invalid value. + } - if (existingOperation.notes) { - operation.description = existingOperation.notes; - } + if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { + pairBuffer += ':'; + } else { + pairBuffer += ': '; + } - if (existingOperation.nickname) { - operation.operationId = existingOperation.nickname; - } + pairBuffer += state.dump; - if (existingOperation.deprecated) { - operation.deprecated = existingOperation.deprecated; - } + // Both key and value are valid. + _result += pairBuffer; + } - this.authorizations(existingAuthorizations, swagger); - this.parameters(operation, existingOperation.parameters, swagger); - this.responseMessages(operation, existingOperation, swagger); + state.tag = _tag; + state.dump = _result || '{}'; // Empty mapping if no valid pairs. +} - pathObj[method] = operation; - } +function detectType(state, object, explicit) { + var _result, typeList, index, length, type, style; - swagger.paths[path] = pathObj; - }; + typeList = explicit ? state.explicitTypes : state.implicitTypes; - SwaggerSpecConverter.prototype.responseMessages = function (operation, existingOperation) { - if (!_.isObject(existingOperation)) { - return; - } - // build default response from the operation (1.x) - var defaultResponse = {}; - - this.dataType(existingOperation, defaultResponse); - // TODO: look into the real problem of rendering responses in swagger-ui - // ....should reponseType have an implicit schema? - if (!defaultResponse.schema && defaultResponse.type) { - defaultResponse = { - schema: defaultResponse - }; - } + for (index = 0, length = typeList.length; index < length; index += 1) { + type = typeList[index]; - operation.responses = operation.responses || {}; + if ((type.instanceOf || type.predicate) && + (!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) && + (!type.predicate || type.predicate(object))) { - // grab from responseMessages (1.2) - var has200 = false; + state.tag = explicit ? type.tag : '?'; - if (Array.isArray(existingOperation.responseMessages)) { - var i; - var existingResponses = existingOperation.responseMessages; + if (type.represent) { + style = state.styleMap[type.tag] || type.defaultStyle; - for (i = 0; i < existingResponses.length; i++) { - var existingResponse = existingResponses[i]; - var response = { - description: existingResponse.message - }; + if (_toString.call(type.represent) === '[object Function]') { + _result = type.represent(object, style); + } else if (_hasOwnProperty.call(type.represent, style)) { + _result = type.represent[style](object, style); + } else { + throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style'); + } - if (existingResponse.code === 200) { - has200 = true; - } - // Convert responseModel -> schema{$ref: responseModel} - if (existingResponse.responseModel) { - response.schema = { - '$ref': existingResponse.responseModel - }; - } - operation.responses['' + existingResponse.code] = response; - } - } + state.dump = _result; + } - if (has200) { - operation.responses['default'] = defaultResponse; - } else { - operation.responses['200'] = defaultResponse; - } - }; + return true; + } + } + + return false; +} + +// Serializes `object` and writes it to global `result`. +// Returns true on success, or false on invalid object. +// +function writeNode(state, level, object, block, compact, iskey) { + state.tag = null; + state.dump = object; + + if (!detectType(state, object, false)) { + detectType(state, object, true); + } + + var type = _toString.call(state.dump); + + if (block) { + block = (state.flowLevel < 0 || state.flowLevel > level); + } + + var objectOrArray = type === '[object Object]' || type === '[object Array]', + duplicateIndex, + duplicate; + + if (objectOrArray) { + duplicateIndex = state.duplicates.indexOf(object); + duplicate = duplicateIndex !== -1; + } + + if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) { + compact = false; + } + + if (duplicate && state.usedDuplicates[duplicateIndex]) { + state.dump = '*ref_' + duplicateIndex; + } else { + if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) { + state.usedDuplicates[duplicateIndex] = true; + } + if (type === '[object Object]') { + if (block && (Object.keys(state.dump).length !== 0)) { + writeBlockMapping(state, level, state.dump, compact); + if (duplicate) { + state.dump = '&ref_' + duplicateIndex + state.dump; + } + } else { + writeFlowMapping(state, level, state.dump); + if (duplicate) { + state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; + } + } + } else if (type === '[object Array]') { + if (block && (state.dump.length !== 0)) { + writeBlockSequence(state, level, state.dump, compact); + if (duplicate) { + state.dump = '&ref_' + duplicateIndex + state.dump; + } + } else { + writeFlowSequence(state, level, state.dump); + if (duplicate) { + state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; + } + } + } else if (type === '[object String]') { + if (state.tag !== '?') { + writeScalar(state, state.dump, level, iskey); + } + } else { + if (state.skipInvalid) return false; + throw new YAMLException('unacceptable kind of an object to dump ' + type); + } - SwaggerSpecConverter.prototype.authorizations = function (obj) { - // TODO - if (!_.isObject(obj)) { - return; - } - }; + if (state.tag !== null && state.tag !== '?') { + state.dump = '!<' + state.tag + '> ' + state.dump; + } + } + + return true; +} + +function getDuplicateReferences(object, state) { + var objects = [], + duplicatesIndexes = [], + index, + length; + + inspectNode(object, objects, duplicatesIndexes); + + for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) { + state.duplicates.push(objects[duplicatesIndexes[index]]); + } + state.usedDuplicates = new Array(length); +} + +function inspectNode(object, objects, duplicatesIndexes) { + var objectKeyList, + index, + length; + + if (object !== null && typeof object === 'object') { + index = objects.indexOf(object); + if (index !== -1) { + if (duplicatesIndexes.indexOf(index) === -1) { + duplicatesIndexes.push(index); + } + } else { + objects.push(object); + + if (Array.isArray(object)) { + for (index = 0, length = object.length; index < length; index += 1) { + inspectNode(object[index], objects, duplicatesIndexes); + } + } else { + objectKeyList = Object.keys(object); - SwaggerSpecConverter.prototype.parameters = function (operation, obj) { - if (!Array.isArray(obj)) { - return; - } - var i; + for (index = 0, length = objectKeyList.length; index < length; index += 1) { + inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes); + } + } + } + } +} - for (i = 0; i < obj.length; i++) { - var existingParameter = obj[i]; - var parameter = {}; +function dump(input, options) { + options = options || {}; - parameter.name = existingParameter.name; - parameter.description = existingParameter.description; - parameter.required = existingParameter.required; - parameter.in = existingParameter.paramType; + var state = new State(options); - // per #168 - if (parameter.in === 'body') { - parameter.name = 'body'; - } + if (!state.noRefs) getDuplicateReferences(input, state); - if (parameter.in === 'form') { - parameter.in = 'formData'; - } + if (writeNode(state, 0, input, true, true)) return state.dump + '\n'; - if (existingParameter.enum) { - parameter.enum = existingParameter.enum; - } + return ''; +} - if (existingParameter.allowMultiple === true || existingParameter.allowMultiple === 'true') { - var innerType = {}; +function safeDump(input, options) { + return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options)); +} - this.dataType(existingParameter, innerType); - parameter.type = 'array'; - parameter.items = innerType; +module.exports.dump = dump; +module.exports.safeDump = safeDump; - if (existingParameter.allowableValues) { - var av = existingParameter.allowableValues; +},{"./common":21,"./exception":23,"./schema/default_full":28,"./schema/default_safe":29}],23:[function(require,module,exports){ +// YAML error class. http://stackoverflow.com/questions/8458984 +// +'use strict'; - if (av.valueType === 'LIST') { - parameter['enum'] = av.values; - } - } - } else { - this.dataType(existingParameter, parameter); - } +function YAMLException(reason, mark) { + // Super constructor + Error.call(this); - operation.parameters = operation.parameters || []; - operation.parameters.push(parameter); - } - }; + // Include stack trace in error object + if (Error.captureStackTrace) { + // Chrome and NodeJS + Error.captureStackTrace(this, this.constructor); + } else { + // FF, IE 10+ and Safari 6+. Fallback for others + this.stack = (new Error()).stack || ''; + } - SwaggerSpecConverter.prototype.dataType = function (source, target) { - if (!_.isObject(source)) { - return; - } + this.name = 'YAMLException'; + this.reason = reason; + this.mark = mark; + this.message = (this.reason || '(unknown reason)') + (this.mark ? ' ' + this.mark.toString() : ''); +} - if (source.minimum) { - target.minimum = source.minimum; - } - if (source.maximum) { - target.maximum = source.maximum; - } +// Inherit from Error +YAMLException.prototype = Object.create(Error.prototype); +YAMLException.prototype.constructor = YAMLException; - if (source.format) { - target.format = source.format; - } - // default can be 'false' - if (typeof source.defaultValue !== 'undefined') { - target.default = source.defaultValue; - } +YAMLException.prototype.toString = function toString(compact) { + var result = this.name + ': '; - var jsonSchemaType = this.toJsonSchema(source); + result += this.reason || '(unknown reason)'; - if (jsonSchemaType) { - target = target || {}; + if (!compact && this.mark) { + result += ' ' + this.mark.toString(); + } - if (jsonSchemaType.type) { - target.type = jsonSchemaType.type; - } + return result; +}; - if (jsonSchemaType.format) { - target.format = jsonSchemaType.format; - } - if (jsonSchemaType.$ref) { - target.schema = { - $ref: jsonSchemaType.$ref - }; - } +module.exports = YAMLException; - if (jsonSchemaType.items) { - target.items = jsonSchemaType.items; - } - } - }; +},{}],24:[function(require,module,exports){ +'use strict'; - SwaggerSpecConverter.prototype.toJsonSchema = function (source) { - if (!source) { - return 'object'; - } - var detectedType = source.type || source.dataType || source.responseClass || ''; - var lcType = detectedType.toLowerCase(); - var format = (source.format || '').toLowerCase(); - - if (lcType.indexOf('list[') === 0) { - var innerType = detectedType.substring(5, detectedType.length - 1); - var jsonType = this.toJsonSchema({ - type: innerType - }); - - return { - type: 'array', items: jsonType - }; - } else if (lcType === 'int' || lcType === 'integer' && format === 'int32') { - return { - type: 'integer', format: 'int32' - }; - } else if (lcType === 'long' || lcType === 'integer' && format === 'int64') { - return { - type: 'integer', format: 'int64' - }; - } else if (lcType === 'integer') { - return { - type: 'integer', format: 'int64' - }; - } else if (lcType === 'float' || lcType === 'number' && format === 'float') { - return { - type: 'number', format: 'float' - }; - } else if (lcType === 'double' || lcType === 'number' && format === 'double') { - return { - type: 'number', format: 'double' - }; - } else if (lcType === 'string' && format === 'date-time' || lcType === 'date') { - return { - type: 'string', format: 'date-time' - }; - } else if (lcType === 'string') { - return { - type: 'string' - }; - } else if (lcType === 'file') { - return { - type: 'file' - }; - } else if (lcType === 'boolean') { - return { - type: 'boolean' - }; - } else if (lcType === 'array' || lcType === 'list') { - if (source.items) { - var it = this.toJsonSchema(source.items); - - return { - type: 'array', items: it - }; - } +/*eslint-disable max-len,no-use-before-define*/ - return { - type: 'array', items: { - type: 'object' - } - }; - - } else if (source.$ref) { - return { - $ref: '#/definitions/' + this.modelMap[source.$ref] || source.$ref - }; - } else if (lcType === 'void' || lcType === '') { - return {}; - } +var common = require('./common'); +var YAMLException = require('./exception'); +var Mark = require('./mark'); +var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe'); +var DEFAULT_FULL_SCHEMA = require('./schema/default_full'); - return { - $ref: '#/definitions/' + this.modelMap[source.type] || source.type - }; - }; +var _hasOwnProperty = Object.prototype.hasOwnProperty; - SwaggerSpecConverter.prototype.resourceListing = function (obj, swagger, callback) { - var i; - var processedCount = 0; // jshint ignore:line - var self = this; // jshint ignore:line - var expectedCount = obj.apis.length; - var _swagger = swagger; // jshint ignore:line - if (expectedCount === 0) { - this.finish(callback, swagger); - } +var CONTEXT_FLOW_IN = 1; +var CONTEXT_FLOW_OUT = 2; +var CONTEXT_BLOCK_IN = 3; +var CONTEXT_BLOCK_OUT = 4; - for (i = 0; i < expectedCount; i++) { - var api = obj.apis[i]; - var path = api.path; - var absolutePath = this.getAbsolutePath(obj.swaggerVersion, this.docLocation, path); - if (api.description) { - swagger.tags = swagger.tags || []; - swagger.tags.push({ - name: this.extractTag(api.path), - description: api.description || '' - }); - } - var http = { - url: absolutePath, - headers: { - accept: 'application/json' - }, - on: {}, - method: 'get' - }; - /* jshint ignore:start */ - - http.on.response = function (data) { - processedCount += 1; - var obj = data.obj; - - if (obj) { - self.declaration(obj, _swagger); - } +var CHOMPING_CLIP = 1; +var CHOMPING_STRIP = 2; +var CHOMPING_KEEP = 3; + - if (processedCount === expectedCount) { - self.finish(callback, _swagger); - } - }; - http.on.error = function (data) { - console.error(data); - processedCount += 1; +var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; +var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/; +var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/; +var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i; +var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i; - if (processedCount === expectedCount) { - self.finish(callback, _swagger); - } - }; - /* jshint ignore:end */ - if (this.clientAuthorizations && typeof this.clientAuthorizations.apply === 'function') { - this.clientAuthorizations.apply(http); - } +function is_EOL(c) { + return (c === 0x0A/* LF */) || (c === 0x0D/* CR */); +} - new SwaggerHttp().execute(http); - } - }; +function is_WHITE_SPACE(c) { + return (c === 0x09/* Tab */) || (c === 0x20/* Space */); +} - SwaggerSpecConverter.prototype.getAbsolutePath = function (version, docLocation, path) { - if (version === '1.0') { - if (docLocation.endsWith('.json')) { - // get root path - var pos = docLocation.lastIndexOf('/'); +function is_WS_OR_EOL(c) { + return (c === 0x09/* Tab */) || + (c === 0x20/* Space */) || + (c === 0x0A/* LF */) || + (c === 0x0D/* CR */); +} + +function is_FLOW_INDICATOR(c) { + return c === 0x2C/* , */ || + c === 0x5B/* [ */ || + c === 0x5D/* ] */ || + c === 0x7B/* { */ || + c === 0x7D/* } */; +} + +function fromHexCode(c) { + var lc; + + if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { + return c - 0x30; + } + + /*eslint-disable no-bitwise*/ + lc = c | 0x20; + + if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) { + return lc - 0x61 + 10; + } + + return -1; +} + +function escapedHexLen(c) { + if (c === 0x78/* x */) { return 2; } + if (c === 0x75/* u */) { return 4; } + if (c === 0x55/* U */) { return 8; } + return 0; +} - if (pos > 0) { - docLocation = docLocation.substring(0, pos); - } - } - } +function fromDecimalCode(c) { + if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { + return c - 0x30; + } - var location = docLocation; + return -1; +} - if (path.indexOf('http://') === 0 || path.indexOf('https://') === 0) { - location = path; - } else { - if (docLocation.endsWith('/')) { - location = docLocation.substring(0, docLocation.length - 1); - } - location += path; - } - location = location.replace('{format}', 'json'); +function simpleEscapeSequence(c) { + return (c === 0x30/* 0 */) ? '\x00' : + (c === 0x61/* a */) ? '\x07' : + (c === 0x62/* b */) ? '\x08' : + (c === 0x74/* t */) ? '\x09' : + (c === 0x09/* Tab */) ? '\x09' : + (c === 0x6E/* n */) ? '\x0A' : + (c === 0x76/* v */) ? '\x0B' : + (c === 0x66/* f */) ? '\x0C' : + (c === 0x72/* r */) ? '\x0D' : + (c === 0x65/* e */) ? '\x1B' : + (c === 0x20/* Space */) ? ' ' : + (c === 0x22/* " */) ? '\x22' : + (c === 0x2F/* / */) ? '/' : + (c === 0x5C/* \ */) ? '\x5C' : + (c === 0x4E/* N */) ? '\x85' : + (c === 0x5F/* _ */) ? '\xA0' : + (c === 0x4C/* L */) ? '\u2028' : + (c === 0x50/* P */) ? '\u2029' : ''; +} + +function charFromCodepoint(c) { + if (c <= 0xFFFF) { + return String.fromCharCode(c); + } + // Encode UTF-16 surrogate pair + // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF + return String.fromCharCode(((c - 0x010000) >> 10) + 0xD800, + ((c - 0x010000) & 0x03FF) + 0xDC00); +} + +var simpleEscapeCheck = new Array(256); // integer, for fast access +var simpleEscapeMap = new Array(256); +for (var i = 0; i < 256; i++) { + simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0; + simpleEscapeMap[i] = simpleEscapeSequence(i); +} + + +function State(input, options) { + this.input = input; + + this.filename = options['filename'] || null; + this.schema = options['schema'] || DEFAULT_FULL_SCHEMA; + this.onWarning = options['onWarning'] || null; + this.legacy = options['legacy'] || false; + this.json = options['json'] || false; + this.listener = options['listener'] || null; + + this.implicitTypes = this.schema.compiledImplicit; + this.typeMap = this.schema.compiledTypeMap; + + this.length = input.length; + this.position = 0; + this.line = 0; + this.lineStart = 0; + this.lineIndent = 0; + + this.documents = []; + + /* + this.version; + this.checkLineBreaks; + this.tagMap; + this.anchorMap; + this.tag; + this.anchor; + this.kind; + this.result;*/ + +} + + +function generateError(state, message) { + return new YAMLException( + message, + new Mark(state.filename, state.input, state.position, state.line, (state.position - state.lineStart))); +} + +function throwError(state, message) { + throw generateError(state, message); +} + +function throwWarning(state, message) { + if (state.onWarning) { + state.onWarning.call(null, generateError(state, message)); + } +} + + +var directiveHandlers = { + + YAML: function handleYamlDirective(state, name, args) { + + var match, major, minor; + + if (state.version !== null) { + throwError(state, 'duplication of %YAML directive'); + } - return location; - }; + if (args.length !== 1) { + throwError(state, 'YAML directive accepts exactly one argument'); + } - SwaggerSpecConverter.prototype.securityDefinitions = function (obj, swagger) { - if (obj.authorizations) { - var name; - - for (name in obj.authorizations) { - var isValid = false; - var securityDefinition = {}; - var definition = obj.authorizations[name]; - - if (definition.type === 'apiKey') { - securityDefinition.type = 'apiKey'; - securityDefinition.in = definition.passAs; - securityDefinition.name = definition.keyname || name; - isValid = true; - } else if (definition.type === 'oauth2') { - var existingScopes = definition.scopes || []; - var scopes = {}; - var i; - - for (i in existingScopes) { - var scope = existingScopes[i]; - - scopes[scope.scope] = scope.description; - } - securityDefinition.type = 'oauth2'; + match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]); - if (i > 0) { - securityDefinition.scopes = scopes; - } + if (match === null) { + throwError(state, 'ill-formed argument of the YAML directive'); + } - if (definition.grantTypes) { - if (definition.grantTypes.implicit) { - var implicit = definition.grantTypes.implicit; + major = parseInt(match[1], 10); + minor = parseInt(match[2], 10); - securityDefinition.flow = 'implicit'; - securityDefinition.authorizationUrl = implicit.loginEndpoint; - isValid = true; - } - /* jshint ignore:start */ - if (definition.grantTypes['authorization_code']) { - if (!securityDefinition.flow) { - // cannot set if flow is already defined - var authCode = definition.grantTypes['authorization_code']; - - securityDefinition.flow = 'accessCode'; - securityDefinition.authorizationUrl = authCode.tokenRequestEndpoint.url; - securityDefinition.tokenUrl = authCode.tokenEndpoint.url; - isValid = true; - } - } - /* jshint ignore:end */ - } - } + if (major !== 1) { + throwError(state, 'unacceptable YAML version of the document'); + } - if (isValid) { - swagger.securityDefinitions = swagger.securityDefinitions || {}; - swagger.securityDefinitions[name] = securityDefinition; - } - } - } - }; + state.version = args[0]; + state.checkLineBreaks = (minor < 2); - SwaggerSpecConverter.prototype.apiInfo = function (obj, swagger) { - // info section - if (obj.info) { - var info = obj.info; + if (minor !== 1 && minor !== 2) { + throwWarning(state, 'unsupported YAML version of the document'); + } + }, - swagger.info = {}; + TAG: function handleTagDirective(state, name, args) { - if (info.contact) { - swagger.info.contact = {}; - swagger.info.contact.email = info.contact; - } + var handle, prefix; - if (info.description) { - swagger.info.description = info.description; - } + if (args.length !== 2) { + throwError(state, 'TAG directive accepts exactly two arguments'); + } - if (info.title) { - swagger.info.title = info.title; - } + handle = args[0]; + prefix = args[1]; - if (info.termsOfServiceUrl) { - swagger.info.termsOfService = info.termsOfServiceUrl; - } + if (!PATTERN_TAG_HANDLE.test(handle)) { + throwError(state, 'ill-formed tag handle (first argument) of the TAG directive'); + } - if (info.license || info.licenseUrl) { - swagger.license = {}; + if (_hasOwnProperty.call(state.tagMap, handle)) { + throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle'); + } - if (info.license) { - swagger.license.name = info.license; - } + if (!PATTERN_TAG_URI.test(prefix)) { + throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive'); + } - if (info.licenseUrl) { - swagger.license.url = info.licenseUrl; - } - } - } else { - this.warnings.push('missing info section'); - } - }; + state.tagMap[handle] = prefix; + } +}; - SwaggerSpecConverter.prototype.finish = function (callback, obj) { - callback(obj); - }; - },{ - './http': 5,'lodash-compat/lang/isObject': 147 - }],9: [function (require, module, exports) { - 'use strict'; +function captureSegment(state, start, end, checkJson) { + var _position, _length, _character, _result; - var _ = { - isPlainObject: require('lodash-compat/lang/isPlainObject'), - isString: require('lodash-compat/lang/isString') - }; + if (start < end) { + _result = state.input.slice(start, end); - var SchemaMarkup = require('../schema-markup.js'); - var jsyaml = require('js-yaml'); + if (checkJson) { + for (_position = 0, _length = _result.length; + _position < _length; + _position += 1) { + _character = _result.charCodeAt(_position); + if (!(_character === 0x09 || + (0x20 <= _character && _character <= 0x10FFFF))) { + throwError(state, 'expected valid JSON character'); + } + } + } else if (PATTERN_NON_PRINTABLE.test(_result)) { + throwError(state, 'the stream contains non-printable characters'); + } - var Model = module.exports = function (name, definition, models, modelPropertyMacro) { - this.definition = definition || {}; - this.isArray = definition.type === 'array'; - this.models = models || {}; - this.name = definition.title || name || 'Inline Model'; - this.modelPropertyMacro = modelPropertyMacro || function (property) { - return property.default; - }; + state.result += _result; + } +} - return this; - }; +function mergeMappings(state, destination, source, overridableKeys) { + var sourceKeys, key, index, quantity; - Model.prototype.createJSONSample = Model.prototype.getSampleValue = function (modelsToIgnore) { - modelsToIgnore = modelsToIgnore || {}; + if (!common.isObject(source)) { + throwError(state, 'cannot merge mappings; the provided source object is unacceptable'); + } - modelsToIgnore[this.name] = this; + sourceKeys = Object.keys(source); - // Response support - if (this.examples && _.isPlainObject(this.examples) && this.examples['application/json']) { - this.definition.example = this.examples['application/json']; + for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) { + key = sourceKeys[index]; - if (_.isString(this.definition.example)) { - this.definition.example = jsyaml.safeLoad(this.definition.example); - } - } else if (!this.definition.example) { - this.definition.example = this.examples; - } + if (!_hasOwnProperty.call(destination, key)) { + destination[key] = source[key]; + overridableKeys[key] = true; + } + } +} - return SchemaMarkup.schemaToJSON(this.definition, this.models, modelsToIgnore, this.modelPropertyMacro); - }; +function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode) { + var index, quantity; - Model.prototype.getMockSignature = function () { - return SchemaMarkup.schemaToHTML(this.name, this.definition, this.models, this.modelPropertyMacro); - }; + keyNode = String(keyNode); - },{ - '../schema-markup.js': 7,'js-yaml': 21,'lodash-compat/lang/isPlainObject': 148,'lodash-compat/lang/isString': 149 - }],10: [function (require, module, exports) { - 'use strict'; + if (_result === null) { + _result = {}; + } - var _ = { - cloneDeep: require('lodash-compat/lang/cloneDeep'), - isUndefined: require('lodash-compat/lang/isUndefined'), - isEmpty: require('lodash-compat/lang/isEmpty'), - isObject: require('lodash-compat/lang/isObject') - }; - var helpers = require('../helpers'); - var Model = require('./model'); - var SwaggerHttp = require('../http'); + if (keyTag === 'tag:yaml.org,2002:merge') { + if (Array.isArray(valueNode)) { + for (index = 0, quantity = valueNode.length; index < quantity; index += 1) { + mergeMappings(state, _result, valueNode[index], overridableKeys); + } + } else { + mergeMappings(state, _result, valueNode, overridableKeys); + } + } else { + if (!state.json && + !_hasOwnProperty.call(overridableKeys, keyNode) && + _hasOwnProperty.call(_result, keyNode)) { + throwError(state, 'duplicated mapping key'); + } + _result[keyNode] = valueNode; + delete overridableKeys[keyNode]; + } - var Operation = module.exports = function (parent, scheme, operationId, httpMethod, path, args, definitions, models, clientAuthorizations) { - var errors = []; + return _result; +} - parent = parent || {}; - args = args || {}; +function readLineBreak(state) { + var ch; - if (parent && parent.options) { - this.client = parent.options.client || null; - this.responseInterceptor = parent.options.responseInterceptor || null; - } - this.authorizations = args.security; - this.basePath = parent.basePath || '/'; - this.clientAuthorizations = clientAuthorizations; - this.consumes = args.consumes || parent.consumes || ['application/json']; - this.produces = args.produces || parent.produces || ['application/json']; - this.deprecated = args.deprecated; - this.description = args.description; - this.host = parent.host || 'localhost'; - this.method = httpMethod || errors.push('Operation ' + operationId + ' is missing method.'); - this.models = models || {}; - this.nickname = operationId || errors.push('Operations must have a nickname.'); - this.operation = args; - this.operations = {}; - this.parameters = args !== null ? args.parameters || [] : {}; - this.parent = parent; - this.path = path || errors.push('Operation ' + this.nickname + ' is missing path.'); - this.responses = args.responses || {}; - this.scheme = scheme || parent.scheme || 'http'; - this.schemes = args.schemes || parent.schemes; - this.security = args.security; - this.summary = args.summary || ''; - this.type = null; - this.useJQuery = parent.useJQuery; - this.parameterMacro = parent.parameterMacro || function (parameter) { - return parameter.default; - }; - - this.inlineModels = []; - - if (typeof this.deprecated === 'string') { - switch (this.deprecated.toLowerCase()) { - case 'true': case 'yes': case '1': { - this.deprecated = true; - break; - } + ch = state.input.charCodeAt(state.position); - case 'false': case 'no': case '0': case null: { - this.deprecated = false; - break; - } + if (ch === 0x0A/* LF */) { + state.position++; + } else if (ch === 0x0D/* CR */) { + state.position++; + if (state.input.charCodeAt(state.position) === 0x0A/* LF */) { + state.position++; + } + } else { + throwError(state, 'a line break is expected'); + } - default: this.deprecated = Boolean(this.deprecated); - } - } + state.line += 1; + state.lineStart = state.position; +} - var i, model; +function skipSeparationSpace(state, allowComments, checkIndent) { + var lineBreaks = 0, + ch = state.input.charCodeAt(state.position); - if (definitions) { - // add to global models - var key; + while (ch !== 0) { + while (is_WHITE_SPACE(ch)) { + ch = state.input.charCodeAt(++state.position); + } - for (key in definitions) { - model = new Model(key, definitions[key], this.models, parent.modelPropertyMacro); + if (allowComments && ch === 0x23/* # */) { + do { + ch = state.input.charCodeAt(++state.position); + } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0); + } - if (model) { - this.models[key] = model; - } - } - } + if (is_EOL(ch)) { + readLineBreak(state); - for (i = 0; i < this.parameters.length; i++) { - var param = this.parameters[i]; + ch = state.input.charCodeAt(state.position); + lineBreaks++; + state.lineIndent = 0; - // Allow macro to set the default value - param.default = this.parameterMacro(param); + while (ch === 0x20/* Space */) { + state.lineIndent++; + ch = state.input.charCodeAt(++state.position); + } + } else { + break; + } + } - if (param.type === 'array') { - param.isList = true; - param.allowMultiple = true; - // the enum can be defined at the items level - if (param.items && param.items.enum) { - param['enum'] = param.items.enum; - } - } + if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) { + throwWarning(state, 'deficient indentation'); + } - var innerType = this.getType(param); + return lineBreaks; +} - if (innerType && innerType.toString().toLowerCase() === 'boolean') { - param.allowableValues = {}; - param.isList = true; - param['enum'] = [true, false]; // use actual primitives - } +function testDocumentSeparator(state) { + var _position = state.position, + ch; - if (typeof param['enum'] !== 'undefined') { - var id; + ch = state.input.charCodeAt(_position); - param.allowableValues = {}; - param.allowableValues.values = []; - param.allowableValues.descriptiveValues = []; + // Condition state.position === state.lineStart is tested + // in parent on each call, for efficiency. No needs to test here again. + if ((ch === 0x2D/* - */ || ch === 0x2E/* . */) && + ch === state.input.charCodeAt(_position + 1) && + ch === state.input.charCodeAt(_position + 2)) { - for (id = 0; id < param['enum'].length; id++) { - var value = param['enum'][id]; - var isDefault = value === param.default || value + '' === param.default; + _position += 3; - param.allowableValues.values.push(value); - // Always have string for descriptive values.... - param.allowableValues.descriptiveValues.push({ - value: value + '', isDefault: isDefault - }); - } - } + ch = state.input.charCodeAt(_position); - if (param.type === 'array') { - innerType = [innerType]; + if (ch === 0 || is_WS_OR_EOL(ch)) { + return true; + } + } + + return false; +} + +function writeFoldedLines(state, count) { + if (count === 1) { + state.result += ' '; + } else if (count > 1) { + state.result += common.repeat('\n', count - 1); + } +} + + +function readPlainScalar(state, nodeIndent, withinFlowCollection) { + var preceding, + following, + captureStart, + captureEnd, + hasPendingContent, + _line, + _lineStart, + _lineIndent, + _kind = state.kind, + _result = state.result, + ch; + + ch = state.input.charCodeAt(state.position); + + if (is_WS_OR_EOL(ch) || + is_FLOW_INDICATOR(ch) || + ch === 0x23/* # */ || + ch === 0x26/* & */ || + ch === 0x2A/* * */ || + ch === 0x21/* ! */ || + ch === 0x7C/* | */ || + ch === 0x3E/* > */ || + ch === 0x27/* ' */ || + ch === 0x22/* " */ || + ch === 0x25/* % */ || + ch === 0x40/* @ */ || + ch === 0x60/* ` */) { + return false; + } + + if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) { + following = state.input.charCodeAt(state.position + 1); + + if (is_WS_OR_EOL(following) || + withinFlowCollection && is_FLOW_INDICATOR(following)) { + return false; + } + } + + state.kind = 'scalar'; + state.result = ''; + captureStart = captureEnd = state.position; + hasPendingContent = false; + + while (ch !== 0) { + if (ch === 0x3A/* : */) { + following = state.input.charCodeAt(state.position + 1); + + if (is_WS_OR_EOL(following) || + withinFlowCollection && is_FLOW_INDICATOR(following)) { + break; + } + + } else if (ch === 0x23/* # */) { + preceding = state.input.charCodeAt(state.position - 1); + + if (is_WS_OR_EOL(preceding)) { + break; + } + + } else if ((state.position === state.lineStart && testDocumentSeparator(state)) || + withinFlowCollection && is_FLOW_INDICATOR(ch)) { + break; + + } else if (is_EOL(ch)) { + _line = state.line; + _lineStart = state.lineStart; + _lineIndent = state.lineIndent; + skipSeparationSpace(state, false, -1); + + if (state.lineIndent >= nodeIndent) { + hasPendingContent = true; + ch = state.input.charCodeAt(state.position); + continue; + } else { + state.position = captureEnd; + state.line = _line; + state.lineStart = _lineStart; + state.lineIndent = _lineIndent; + break; + } + } - if (typeof param.allowableValues === 'undefined') { - // can't show as a list if no values to select from - delete param.isList; - delete param.allowMultiple; - } - } + if (hasPendingContent) { + captureSegment(state, captureStart, captureEnd, false); + writeFoldedLines(state, state.line - _line); + captureStart = captureEnd = state.position; + hasPendingContent = false; + } - param.signature = this.getModelSignature(innerType, this.models).toString(); - param.sampleJSON = this.getModelSampleJSON(innerType, this.models); - param.responseClassSignature = param.signature; - } + if (!is_WHITE_SPACE(ch)) { + captureEnd = state.position + 1; + } - var defaultResponseCode, response, responses = this.responses; - - if (responses['200']) { - response = responses['200']; - defaultResponseCode = '200'; - } else if (responses['201']) { - response = responses['201']; - defaultResponseCode = '201'; - } else if (responses['202']) { - response = responses['202']; - defaultResponseCode = '202'; - } else if (responses['203']) { - response = responses['203']; - defaultResponseCode = '203'; - } else if (responses['204']) { - response = responses['204']; - defaultResponseCode = '204'; - } else if (responses['205']) { - response = responses['205']; - defaultResponseCode = '205'; - } else if (responses['206']) { - response = responses['206']; - defaultResponseCode = '206'; - } else if (responses['default']) { - response = responses['default']; - defaultResponseCode = 'default'; - } + ch = state.input.charCodeAt(++state.position); + } - if (response && response.schema) { - var resolvedModel = this.resolveModel(response.schema, definitions); - var successResponse; - - delete responses[defaultResponseCode]; - - if (resolvedModel) { - this.successResponse = {}; - successResponse = this.successResponse[defaultResponseCode] = resolvedModel; - } else if (!response.schema.type || response.schema.type === 'object' || response.schema.type === 'array') { - // Inline model - this.successResponse = {}; - successResponse = this.successResponse[defaultResponseCode] = new Model(undefined, response.schema || {}, this.models, parent.modelPropertyMacro); - } else { - // Primitive - this.successResponse = {}; - successResponse = this.successResponse[defaultResponseCode] = response.schema; - } + captureSegment(state, captureStart, captureEnd, false); - if (successResponse) { - // Attach response properties - if (response.description) { - successResponse.description = response.description; - } + if (state.result) { + return true; + } - if (response.examples) { - successResponse.examples = response.examples; - } + state.kind = _kind; + state.result = _result; + return false; +} - if (response.headers) { - successResponse.headers = response.headers; - } - } +function readSingleQuotedScalar(state, nodeIndent) { + var ch, + captureStart, captureEnd; - this.type = response; - } + ch = state.input.charCodeAt(state.position); - if (errors.length > 0) { - if (this.resource && this.resource.api && this.resource.api.fail) { - this.resource.api.fail(errors); - } - } + if (ch !== 0x27/* ' */) { + return false; + } - return this; - }; + state.kind = 'scalar'; + state.result = ''; + state.position++; + captureStart = captureEnd = state.position; - Operation.prototype.isDefaultArrayItemValue = function (value, param) { - if (param.default && Array.isArray(param.default)) { - return param.default.indexOf(value) !== -1; - } + while ((ch = state.input.charCodeAt(state.position)) !== 0) { + if (ch === 0x27/* ' */) { + captureSegment(state, captureStart, state.position, true); + ch = state.input.charCodeAt(++state.position); - return value === param.default; - }; + if (ch === 0x27/* ' */) { + captureStart = captureEnd = state.position; + state.position++; + } else { + return true; + } - Operation.prototype.getType = function (param) { - var type = param.type; - var format = param.format; - var isArray = false; - var str; - - if (type === 'integer' && format === 'int32') { - str = 'integer'; - } else if (type === 'integer' && format === 'int64') { - str = 'long'; - } else if (type === 'integer') { - str = 'integer'; - } else if (type === 'string') { - if (format === 'date-time') { - str = 'date-time'; - } else if (format === 'date') { - str = 'date'; - } else { - str = 'string'; - } - } else if (type === 'number' && format === 'float') { - str = 'float'; - } else if (type === 'number' && format === 'double') { - str = 'double'; - } else if (type === 'number') { - str = 'double'; - } else if (type === 'boolean') { - str = 'boolean'; - } else if (type === 'array') { - isArray = true; - - if (param.items) { - str = this.getType(param.items); - } - } + } else if (is_EOL(ch)) { + captureSegment(state, captureStart, captureEnd, true); + writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); + captureStart = captureEnd = state.position; - if (param.$ref) { - str = helpers.simpleRef(param.$ref); - } + } else if (state.position === state.lineStart && testDocumentSeparator(state)) { + throwError(state, 'unexpected end of the document within a single quoted scalar'); - var schema = param.schema; + } else { + state.position++; + captureEnd = state.position; + } + } - if (schema) { - var ref = schema.$ref; + throwError(state, 'unexpected end of the stream within a single quoted scalar'); +} - if (ref) { - ref = helpers.simpleRef(ref); +function readDoubleQuotedScalar(state, nodeIndent) { + var captureStart, + captureEnd, + hexLength, + hexResult, + tmp, + ch; - if (isArray) { - return [ref]; - } + ch = state.input.charCodeAt(state.position); - return ref; + if (ch !== 0x22/* " */) { + return false; + } - } - // If inline schema, we add it our interal hash -> which gives us it's ID (int) - if (schema.type === 'object') { - return this.addInlineModel(schema); - } + state.kind = 'scalar'; + state.result = ''; + state.position++; + captureStart = captureEnd = state.position; - return this.getType(schema); + while ((ch = state.input.charCodeAt(state.position)) !== 0) { + if (ch === 0x22/* " */) { + captureSegment(state, captureStart, state.position, true); + state.position++; + return true; - } + } else if (ch === 0x5C/* \ */) { + captureSegment(state, captureStart, state.position, true); + ch = state.input.charCodeAt(++state.position); - if (isArray) { - return [str]; - } + if (is_EOL(ch)) { + skipSeparationSpace(state, false, nodeIndent); - return str; + // TODO: rework to inline fn with no type cast? + } else if (ch < 256 && simpleEscapeCheck[ch]) { + state.result += simpleEscapeMap[ch]; + state.position++; - }; + } else if ((tmp = escapedHexLen(ch)) > 0) { + hexLength = tmp; + hexResult = 0; - /** - * adds an inline schema (model) to a hash, where we can ref it later - * @param {object} schema a schema - * @return {number} the ID of the schema being added, or null - **/ - Operation.prototype.addInlineModel = function (schema) { - var len = this.inlineModels.length; - var model = this.resolveModel(schema, {}); + for (; hexLength > 0; hexLength--) { + ch = state.input.charCodeAt(++state.position); - if (model) { - this.inlineModels.push(model); + if ((tmp = fromHexCode(ch)) >= 0) { + hexResult = (hexResult << 4) + tmp; - return 'Inline Model ' + len; // return string ref of the inline model (used with #getInlineModel) - } + } else { + throwError(state, 'expected hexadecimal character'); + } + } - return null; // report errors? - }; + state.result += charFromCodepoint(hexResult); - /** - * gets the internal ref to an inline model - * @param {string} inline_str a string reference to an inline model - * @return {Model} the model being referenced. Or null - **/ - Operation.prototype.getInlineModel = function (inlineStr) { - if (/^Inline Model \d+$/.test(inlineStr)) { - var id = parseInt(inlineStr.substr('Inline Model'.length).trim(), 10); // - var model = this.inlineModels[id]; - - return model; - } - // I'm returning null here, should I rather throw an error? - return null; - }; + state.position++; - Operation.prototype.resolveModel = function (schema, definitions) { - if (typeof schema.$ref !== 'undefined') { - var ref = schema.$ref; + } else { + throwError(state, 'unknown escape sequence'); + } - if (ref.indexOf('#/definitions/') === 0) { - ref = ref.substring('#/definitions/'.length); - } + captureStart = captureEnd = state.position; - if (definitions[ref]) { - return new Model(ref, definitions[ref], this.models, this.parent.modelPropertyMacro); - } - // schema must at least be an object to get resolved to an inline Model - } else if (schema && typeof schema === 'object' && - (schema.type === 'object' || _.isUndefined(schema.type))) { - return new Model(undefined, schema, this.models, this.parent.modelPropertyMacro); - } + } else if (is_EOL(ch)) { + captureSegment(state, captureStart, captureEnd, true); + writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); + captureStart = captureEnd = state.position; - return null; - }; + } else if (state.position === state.lineStart && testDocumentSeparator(state)) { + throwError(state, 'unexpected end of the document within a double quoted scalar'); - Operation.prototype.help = function (dontPrint) { - var out = this.nickname + ': ' + this.summary + '\n'; + } else { + state.position++; + captureEnd = state.position; + } + } + + throwError(state, 'unexpected end of the stream within a double quoted scalar'); +} + +function readFlowCollection(state, nodeIndent) { + var readNext = true, + _line, + _tag = state.tag, + _result, + _anchor = state.anchor, + following, + terminator, + isPair, + isExplicitPair, + isMapping, + overridableKeys = {}, + keyNode, + keyTag, + valueNode, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch === 0x5B/* [ */) { + terminator = 0x5D;/* ] */ + isMapping = false; + _result = []; + } else if (ch === 0x7B/* { */) { + terminator = 0x7D;/* } */ + isMapping = true; + _result = {}; + } else { + return false; + } + + if (state.anchor !== null) { + state.anchorMap[state.anchor] = _result; + } + + ch = state.input.charCodeAt(++state.position); + + while (ch !== 0) { + skipSeparationSpace(state, true, nodeIndent); + + ch = state.input.charCodeAt(state.position); + + if (ch === terminator) { + state.position++; + state.tag = _tag; + state.anchor = _anchor; + state.kind = isMapping ? 'mapping' : 'sequence'; + state.result = _result; + return true; + } else if (!readNext) { + throwError(state, 'missed comma between flow collection entries'); + } - for (var i = 0; i < this.parameters.length; i++) { - var param = this.parameters[i]; - var typeInfo = param.signature; + keyTag = keyNode = valueNode = null; + isPair = isExplicitPair = false; - out += '\n * ' + param.name + ' (' + typeInfo + '): ' + param.description; - } + if (ch === 0x3F/* ? */) { + following = state.input.charCodeAt(state.position + 1); - if (typeof dontPrint === 'undefined') { - helpers.log(out); - } + if (is_WS_OR_EOL(following)) { + isPair = isExplicitPair = true; + state.position++; + skipSeparationSpace(state, true, nodeIndent); + } + } - return out; - }; + _line = state.line; + composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); + keyTag = state.tag; + keyNode = state.result; + skipSeparationSpace(state, true, nodeIndent); - Operation.prototype.getModelSignature = function (type, definitions) { - var isPrimitive, listType; + ch = state.input.charCodeAt(state.position); - if (type instanceof Array) { - listType = true; - type = type[0]; - } + if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) { + isPair = true; + ch = state.input.charCodeAt(++state.position); + skipSeparationSpace(state, true, nodeIndent); + composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); + valueNode = state.result; + } - // Convert undefined to string of 'undefined' - if (typeof type === 'undefined') { - type = 'undefined'; - isPrimitive = true; + if (isMapping) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode); + } else if (isPair) { + _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode)); + } else { + _result.push(keyNode); + } - } else if (definitions[type]) { - // a model def exists? - type = definitions[type]; /* Model */ - isPrimitive = false; + skipSeparationSpace(state, true, nodeIndent); - } else if (this.getInlineModel(type)) { - type = this.getInlineModel(type); /* Model */ - isPrimitive = false; + ch = state.input.charCodeAt(state.position); - } else { - // We default to primitive - isPrimitive = true; - } + if (ch === 0x2C/* , */) { + readNext = true; + ch = state.input.charCodeAt(++state.position); + } else { + readNext = false; + } + } + + throwError(state, 'unexpected end of the stream within a flow collection'); +} + +function readBlockScalar(state, nodeIndent) { + var captureStart, + folding, + chomping = CHOMPING_CLIP, + didReadContent = false, + detectedIndent = false, + textIndent = nodeIndent, + emptyLines = 0, + atMoreIndented = false, + tmp, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch === 0x7C/* | */) { + folding = false; + } else if (ch === 0x3E/* > */) { + folding = true; + } else { + return false; + } + + state.kind = 'scalar'; + state.result = ''; + + while (ch !== 0) { + ch = state.input.charCodeAt(++state.position); + + if (ch === 0x2B/* + */ || ch === 0x2D/* - */) { + if (CHOMPING_CLIP === chomping) { + chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP; + } else { + throwError(state, 'repeat of a chomping mode identifier'); + } + + } else if ((tmp = fromDecimalCode(ch)) >= 0) { + if (tmp === 0) { + throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one'); + } else if (!detectedIndent) { + textIndent = nodeIndent + tmp - 1; + detectedIndent = true; + } else { + throwError(state, 'repeat of an indentation width identifier'); + } + + } else { + break; + } + } - if (isPrimitive) { - if (listType) { - return 'Array[' + type + ']'; - } + if (is_WHITE_SPACE(ch)) { + do { ch = state.input.charCodeAt(++state.position); } + while (is_WHITE_SPACE(ch)); - return type.toString(); + if (ch === 0x23/* # */) { + do { ch = state.input.charCodeAt(++state.position); } + while (!is_EOL(ch) && (ch !== 0)); + } + } - } + while (ch !== 0) { + readLineBreak(state); + state.lineIndent = 0; - if (listType) { - return 'Array[' + type.getMockSignature() + ']'; - } + ch = state.input.charCodeAt(state.position); - return type.getMockSignature(); + while ((!detectedIndent || state.lineIndent < textIndent) && + (ch === 0x20/* Space */)) { + state.lineIndent++; + ch = state.input.charCodeAt(++state.position); + } - }; + if (!detectedIndent && state.lineIndent > textIndent) { + textIndent = state.lineIndent; + } - Operation.prototype.supportHeaderParams = function () { - return true; - }; + if (is_EOL(ch)) { + emptyLines++; + continue; + } - Operation.prototype.supportedSubmitMethods = function () { - return this.parent.supportedSubmitMethods; - }; + // End of the scalar. + if (state.lineIndent < textIndent) { - Operation.prototype.getHeaderParams = function (args) { - var headers = this.setContentTypes(args, {}); + // Perform the chomping. + if (chomping === CHOMPING_KEEP) { + state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); + } else if (chomping === CHOMPING_CLIP) { + if (didReadContent) { // i.e. only if the scalar is not empty. + state.result += '\n'; + } + } - for (var i = 0; i < this.parameters.length; i++) { - var param = this.parameters[i]; + // Break this `while` cycle and go to the funciton's epilogue. + break; + } - if (typeof args[param.name] !== 'undefined') { - if (param.in === 'header') { - var value = args[param.name]; + // Folded style: use fancy rules to handle line breaks. + if (folding) { - if (Array.isArray(value)) { - value = value.toString(); - } + // Lines starting with white space characters (more-indented lines) are not folded. + if (is_WHITE_SPACE(ch)) { + atMoreIndented = true; + // except for the first content line (cf. Example 8.1) + state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); - headers[param.name] = value; - } - } - } + // End of more-indented block. + } else if (atMoreIndented) { + atMoreIndented = false; + state.result += common.repeat('\n', emptyLines + 1); - return headers; - }; + // Just one line break - perceive as the same line. + } else if (emptyLines === 0) { + if (didReadContent) { // i.e. only if we have already read some scalar content. + state.result += ' '; + } - Operation.prototype.urlify = function (args) { - var formParams = {}; - var requestUrl = this.path; - var querystring = ''; // grab params from the args, build the querystring along the way + // Several line breaks - perceive as different lines. + } else { + state.result += common.repeat('\n', emptyLines); + } - for (var i = 0; i < this.parameters.length; i++) { - var param = this.parameters[i]; + // Literal style: just add exact number of line breaks between content lines. + } else { + // Keep all line breaks except the header line break. + state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); + } - if (typeof args[param.name] !== 'undefined') { - if (param.in === 'path') { - var reg = new RegExp('\{' + param.name + '\}', 'gi'); - var value = args[param.name]; + didReadContent = true; + detectedIndent = true; + emptyLines = 0; + captureStart = state.position; - if (Array.isArray(value)) { - value = this.encodePathCollection(param.collectionFormat, param.name, value); - } else { - value = this.encodePathParam(value); - } + while (!is_EOL(ch) && (ch !== 0)) { + ch = state.input.charCodeAt(++state.position); + } - requestUrl = requestUrl.replace(reg, value); - } else if (param.in === 'query' && typeof args[param.name] !== 'undefined') { - if (querystring === '') { - querystring += '?'; - } else { - querystring += '&'; - } + captureSegment(state, captureStart, state.position, false); + } - if (typeof param.collectionFormat !== 'undefined') { - var qp = args[param.name]; + return true; +} - if (Array.isArray(qp)) { - querystring += this.encodeQueryCollection(param.collectionFormat, param.name, qp); - } else { - querystring += this.encodeQueryParam(param.name) + '=' + this.encodeQueryParam(args[param.name]); - } - } else { - querystring += this.encodeQueryParam(param.name) + '=' + this.encodeQueryParam(args[param.name]); - } - } else if (param.in === 'formData') { - formParams[param.name] = args[param.name]; - } - } - } - var url = this.scheme + '://' + this.host; +function readBlockSequence(state, nodeIndent) { + var _line, + _tag = state.tag, + _anchor = state.anchor, + _result = [], + following, + detected = false, + ch; - if (this.basePath !== '/') { - url += this.basePath; - } + if (state.anchor !== null) { + state.anchorMap[state.anchor] = _result; + } - return url + requestUrl + querystring; - }; + ch = state.input.charCodeAt(state.position); - Operation.prototype.getMissingParams = function (args) { - var missingParams = []; // check required params, track the ones that are missing - var i; + while (ch !== 0) { - for (i = 0; i < this.parameters.length; i++) { - var param = this.parameters[i]; + if (ch !== 0x2D/* - */) { + break; + } - if (param.required === true) { - if (typeof args[param.name] === 'undefined') { - missingParams = param.name; - } - } - } + following = state.input.charCodeAt(state.position + 1); - return missingParams; - }; + if (!is_WS_OR_EOL(following)) { + break; + } - Operation.prototype.getBody = function (headers, args, opts) { - var formParams = {}, - body, key, value, hasBody = false; + detected = true; + state.position++; - for (var i = 0; i < this.parameters.length; i++) { - var param = this.parameters[i]; + if (skipSeparationSpace(state, true, -1)) { + if (state.lineIndent <= nodeIndent) { + _result.push(null); + ch = state.input.charCodeAt(state.position); + continue; + } + } - if (typeof args[param.name] !== 'undefined') { - if (param.in === 'body') { - body = args[param.name]; - } else if (param.in === 'formData') { - formParams[param.name] = args[param.name]; - } - } else if (param.in === 'body') { - hasBody = true; - } - } + _line = state.line; + composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true); + _result.push(state.result); + skipSeparationSpace(state, true, -1); - // if body is null and hasBody is true, AND a JSON body is requested, send empty {} - if (hasBody && typeof body === 'undefined') { - var contentType = headers['Content-Type']; + ch = state.input.charCodeAt(state.position); - if (contentType && contentType.indexOf('application/json') === 0) { - body = '{}'; - } - } + if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { + throwError(state, 'bad indentation of a sequence entry'); + } else if (state.lineIndent < nodeIndent) { + break; + } + } + + if (detected) { + state.tag = _tag; + state.anchor = _anchor; + state.kind = 'sequence'; + state.result = _result; + return true; + } + return false; +} + +function readBlockMapping(state, nodeIndent, flowIndent) { + var following, + allowCompact, + _line, + _tag = state.tag, + _anchor = state.anchor, + _result = {}, + overridableKeys = {}, + keyTag = null, + keyNode = null, + valueNode = null, + atExplicitKey = false, + detected = false, + ch; + + if (state.anchor !== null) { + state.anchorMap[state.anchor] = _result; + } + + ch = state.input.charCodeAt(state.position); + + while (ch !== 0) { + following = state.input.charCodeAt(state.position + 1); + _line = state.line; // Save the current line. + + // + // Explicit notation case. There are two separate blocks: + // first for the key (denoted by "?") and second for the value (denoted by ":") + // + if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && is_WS_OR_EOL(following)) { + + if (ch === 0x3F/* ? */) { + if (atExplicitKey) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null); + keyTag = keyNode = valueNode = null; + } - // handle form params - if (headers['Content-Type'] === 'application/x-www-form-urlencoded') { - var encoded = ''; + detected = true; + atExplicitKey = true; + allowCompact = true; - for (key in formParams) { - value = formParams[key]; + } else if (atExplicitKey) { + // i.e. 0x3A/* : */ === character after the explicit key. + atExplicitKey = false; + allowCompact = true; - if (typeof value !== 'undefined') { - if (encoded !== '') { - encoded += '&'; - } + } else { + throwError(state, 'incomplete explicit mapping pair; a key node is missed'); + } - encoded += encodeURIComponent(key) + '=' + encodeURIComponent(value); - } - } + state.position += 1; + ch = following; - body = encoded; - } else if (headers['Content-Type'] && headers['Content-Type'].indexOf('multipart/form-data') >= 0) { - if (opts.useJQuery) { - var bodyParam = new FormData(); + // + // Implicit notation case. Flow-style node as the key first, then ":", and the value. + // + } else if (composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) { - bodyParam.type = 'formData'; + if (state.line === _line) { + ch = state.input.charCodeAt(state.position); - for (key in formParams) { - value = args[key]; + while (is_WHITE_SPACE(ch)) { + ch = state.input.charCodeAt(++state.position); + } - if (typeof value !== 'undefined') { - // required for jquery file upload - if (value.type === 'file' && value.value) { - delete headers['Content-Type']; + if (ch === 0x3A/* : */) { + ch = state.input.charCodeAt(++state.position); - bodyParam.append(key, value.value); - } else { - bodyParam.append(key, value); - } - } - } + if (!is_WS_OR_EOL(ch)) { + throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping'); + } - body = bodyParam; - } - } + if (atExplicitKey) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null); + keyTag = keyNode = valueNode = null; + } - return body; - }; + detected = true; + atExplicitKey = false; + allowCompact = false; + keyTag = state.tag; + keyNode = state.result; - /** - * gets sample response for a single operation - **/ - Operation.prototype.getModelSampleJSON = function (type, models) { - var listType, sampleJson, innerType; + } else if (detected) { + throwError(state, 'can not read an implicit mapping pair; a colon is missed'); - models = models || {}; + } else { + state.tag = _tag; + state.anchor = _anchor; + return true; // Keep the result of `composeNode`. + } - listType = type instanceof Array; - innerType = listType ? type[0] : type; + } else if (detected) { + throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key'); - if (models[innerType]) { - sampleJson = models[innerType].createJSONSample(); - } else if (this.getInlineModel(innerType)) { - sampleJson = this.getInlineModel(innerType).createJSONSample(); // may return null, if type isn't correct - } + } else { + state.tag = _tag; + state.anchor = _anchor; + return true; // Keep the result of `composeNode`. + } - if (sampleJson) { - sampleJson = listType ? [sampleJson] : sampleJson; + } else { + break; // Reading is done. Go to the epilogue. + } - if (typeof sampleJson === 'string') { - return sampleJson; - } else if (_.isObject(sampleJson)) { - var t = sampleJson; + // + // Common reading code for both explicit and implicit notations. + // + if (state.line === _line || state.lineIndent > nodeIndent) { + if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) { + if (atExplicitKey) { + keyNode = state.result; + } else { + valueNode = state.result; + } + } - if (sampleJson instanceof Array && sampleJson.length > 0) { - t = sampleJson[0]; - } + if (!atExplicitKey) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode); + keyTag = keyNode = valueNode = null; + } - if (t.nodeName) { - var xmlString = new XMLSerializer().serializeToString(t); + skipSeparationSpace(state, true, -1); + ch = state.input.charCodeAt(state.position); + } - return this.formatXml(xmlString); - } + if (state.lineIndent > nodeIndent && (ch !== 0)) { + throwError(state, 'bad indentation of a mapping entry'); + } else if (state.lineIndent < nodeIndent) { + break; + } + } + + // + // Epilogue. + // + + // Special case: last mapping's node contains only the key in explicit notation. + if (atExplicitKey) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null); + } + + // Expose the resulting mapping. + if (detected) { + state.tag = _tag; + state.anchor = _anchor; + state.kind = 'mapping'; + state.result = _result; + } + + return detected; +} + +function readTagProperty(state) { + var _position, + isVerbatim = false, + isNamed = false, + tagHandle, + tagName, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch !== 0x21/* ! */) return false; + + if (state.tag !== null) { + throwError(state, 'duplication of a tag property'); + } + + ch = state.input.charCodeAt(++state.position); + + if (ch === 0x3C/* < */) { + isVerbatim = true; + ch = state.input.charCodeAt(++state.position); + + } else if (ch === 0x21/* ! */) { + isNamed = true; + tagHandle = '!!'; + ch = state.input.charCodeAt(++state.position); + + } else { + tagHandle = '!'; + } + + _position = state.position; + + if (isVerbatim) { + do { ch = state.input.charCodeAt(++state.position); } + while (ch !== 0 && ch !== 0x3E/* > */); + + if (state.position < state.length) { + tagName = state.input.slice(_position, state.position); + ch = state.input.charCodeAt(++state.position); + } else { + throwError(state, 'unexpected end of the stream within a verbatim tag'); + } + } else { + while (ch !== 0 && !is_WS_OR_EOL(ch)) { - return JSON.stringify(sampleJson, null, 2); + if (ch === 0x21/* ! */) { + if (!isNamed) { + tagHandle = state.input.slice(_position - 1, state.position + 1); - } + if (!PATTERN_TAG_HANDLE.test(tagHandle)) { + throwError(state, 'named tag handle cannot contain such characters'); + } - return sampleJson; + isNamed = true; + _position = state.position + 1; + } else { + throwError(state, 'tag suffix cannot contain exclamation marks'); + } + } - } - }; + ch = state.input.charCodeAt(++state.position); + } - /** - * legacy binding - **/ - Operation.prototype.do = function (args, opts, callback, error, parent) { - return this.execute(args, opts, callback, error, parent); - }; + tagName = state.input.slice(_position, state.position); - /** - * executes an operation - **/ - Operation.prototype.execute = function (arg1, arg2, arg3, arg4, parent) { - var args = arg1 || {}; - var opts = {}, - success, error; - - if (_.isObject(arg2)) { - opts = arg2; - success = arg3; - error = arg4; - } + if (PATTERN_FLOW_INDICATORS.test(tagName)) { + throwError(state, 'tag suffix cannot contain flow indicator characters'); + } + } - if (this.client) { - opts.client = this.client; - } + if (tagName && !PATTERN_TAG_URI.test(tagName)) { + throwError(state, 'tag name cannot contain such characters: ' + tagName); + } - if (this.responseInterceptor) { - opts.responseInterceptor = this.responseInterceptor; - } + if (isVerbatim) { + state.tag = tagName; - if (typeof arg2 === 'function') { - success = arg2; - error = arg3; - } + } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) { + state.tag = state.tagMap[tagHandle] + tagName; - success = success || this.parent.defaultSuccessCallback || helpers.log; - error = error || this.parent.defaultErrorCallback || helpers.log; + } else if (tagHandle === '!') { + state.tag = '!' + tagName; - if (typeof opts.useJQuery === 'undefined') { - opts.useJQuery = this.useJQuery; - } - var missingParams = this.getMissingParams(args); + } else if (tagHandle === '!!') { + state.tag = 'tag:yaml.org,2002:' + tagName; - if (missingParams.length > 0) { - var message = 'missing required params: ' + missingParams; + } else { + throwError(state, 'undeclared tag handle "' + tagHandle + '"'); + } - helpers.fail(message); - error(message); + return true; +} - return; - } +function readAnchorProperty(state) { + var _position, + ch; - var allHeaders = this.getHeaderParams(args); - var contentTypeHeaders = this.setContentTypes(args, opts); - var headers = {}, - attrname; + ch = state.input.charCodeAt(state.position); - for (attrname in allHeaders) { - headers[attrname] = allHeaders[attrname]; - } + if (ch !== 0x26/* & */) return false; - for (attrname in contentTypeHeaders) { - headers[attrname] = contentTypeHeaders[attrname]; - } + if (state.anchor !== null) { + throwError(state, 'duplication of an anchor property'); + } - var body = this.getBody(contentTypeHeaders, args, opts); - var url = this.urlify(args); + ch = state.input.charCodeAt(++state.position); + _position = state.position; - if (url.indexOf('.{format}') > 0) { - if (headers) { - var format = headers.Accept || headers.accept; + while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { + ch = state.input.charCodeAt(++state.position); + } - if (format && format.indexOf('json') > 0) { - url = url.replace('.{format}', '.json'); - } else if (format && format.indexOf('xml') > 0) { - url = url.replace('.{format}', '.xml'); - } - } - } + if (state.position === _position) { + throwError(state, 'name of an anchor node must contain at least one character'); + } - var obj = { - url: url, - method: this.method.toUpperCase(), - body: body, - useJQuery: opts.useJQuery, - headers: headers, - on: { - response: function (response) { - return success(response, parent); - }, - error: function (response) { - return error(response, parent); - } - } - }; + state.anchor = state.input.slice(_position, state.position); + return true; +} - this.clientAuthorizations.apply(obj, this.operation.security); +function readAlias(state) { + var _position, alias, + ch; - if (opts.mock === true) { - return obj; - } - new SwaggerHttp().execute(obj, opts); + ch = state.input.charCodeAt(state.position); - }; + if (ch !== 0x2A/* * */) return false; - function itemByPriority(col, itemPriority) { + ch = state.input.charCodeAt(++state.position); + _position = state.position; - // No priorities? return first... - if (_.isEmpty(itemPriority)) { - return col[0]; - } + while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { + ch = state.input.charCodeAt(++state.position); + } - for (var i = 0, len = itemPriority.length; i < len; i++) { - if (col.indexOf(itemPriority[i]) > -1) { - return itemPriority[i]; - } - } + if (state.position === _position) { + throwError(state, 'name of an alias node must contain at least one character'); + } - // Otherwise return first - return col[0]; - } + alias = state.input.slice(_position, state.position); - Operation.prototype.setContentTypes = function (args, opts) { - // default type - var allDefinedParams = this.parameters; - var body; - var consumes = args.parameterContentType || itemByPriority(this.consumes, ['application/json', 'application/yaml']); - var accepts = opts.responseContentType || itemByPriority(this.produces, ['application/json', 'application/yaml']); - var definedFileParams = []; - var definedFormParams = []; - var headers = {}; - var i; - - // get params from the operation and set them in definedFileParams, definedFormParams, headers - for (i = 0; i < allDefinedParams.length; i++) { - var param = allDefinedParams[i]; - - if (param.in === 'formData') { - if (param.type === 'file') { - definedFileParams.push(param); - } else { - definedFormParams.push(param); - } - } else if (param.in === 'header' && opts) { - var key = param.name; - var headerValue = opts[param.name]; + if (!state.anchorMap.hasOwnProperty(alias)) { + throwError(state, 'unidentified alias "' + alias + '"'); + } - if (typeof opts[param.name] !== 'undefined') { - headers[key] = headerValue; - } - } else if (param.in === 'body' && typeof args[param.name] !== 'undefined') { - body = args[param.name]; - } - } + state.result = state.anchorMap[alias]; + skipSeparationSpace(state, true, -1); + return true; +} - // if there's a body, need to set the consumes header via requestContentType - if (this.method === 'post' || this.method === 'put' || this.method === 'patch' || - this.method === 'delete' && body) { - if (opts.requestContentType) { - consumes = opts.requestContentType; - } - // if any form params, content type must be set - if (definedFormParams.length > 0) { - if (opts.requestContentType) { // override if set - consumes = opts.requestContentType; - } else if (definedFileParams.length > 0) { // if a file, must be multipart/form-data - consumes = 'multipart/form-data'; - } else { // default to x-www-from-urlencoded - consumes = 'application/x-www-form-urlencoded'; - } - } - } else { - consumes = null; - } +function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) { + var allowBlockStyles, + allowBlockScalars, + allowBlockCollections, + indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this parentIndent) { + indentStatus = 1; + } else if (state.lineIndent === parentIndent) { + indentStatus = 0; + } else if (state.lineIndent < parentIndent) { + indentStatus = -1; + } + } + } + + if (indentStatus === 1) { + while (readTagProperty(state) || readAnchorProperty(state)) { + if (skipSeparationSpace(state, true, -1)) { + atNewLine = true; + allowBlockCollections = allowBlockStyles; + + if (state.lineIndent > parentIndent) { + indentStatus = 1; + } else if (state.lineIndent === parentIndent) { + indentStatus = 0; + } else if (state.lineIndent < parentIndent) { + indentStatus = -1; + } + } else { + allowBlockCollections = false; + } + } + } - /** - * Returns true if the request accepts header matches anything in this.produces. - * If this.produces contains * / *, ignore the accept header. - * @param {string=} accepts The client request accept header. - * @return {boolean} - */ - Operation.prototype.matchesAccept = function (accepts) { - // no accepts or produces, no problem! - if (!accepts || !this.produces) { - return true; - } + if (allowBlockCollections) { + allowBlockCollections = atNewLine || allowCompact; + } - return this.produces.indexOf(accepts) !== -1 || this.produces.indexOf('*/*') !== -1; - }; + if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) { + if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) { + flowIndent = parentIndent; + } else { + flowIndent = parentIndent + 1; + } - Operation.prototype.asCurl = function (args1, args2) { - var opts = { - mock: true - }; + blockIndent = state.position - state.lineStart; + + if (indentStatus === 1) { + if (allowBlockCollections && + (readBlockSequence(state, blockIndent) || + readBlockMapping(state, blockIndent, flowIndent)) || + readFlowCollection(state, flowIndent)) { + hasContent = true; + } else { + if ((allowBlockScalars && readBlockScalar(state, flowIndent)) || + readSingleQuotedScalar(state, flowIndent) || + readDoubleQuotedScalar(state, flowIndent)) { + hasContent = true; + + } else if (readAlias(state)) { + hasContent = true; + + if (state.tag !== null || state.anchor !== null) { + throwError(state, 'alias node should not have any properties'); + } + + } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) { + hasContent = true; + + if (state.tag === null) { + state.tag = '?'; + } + } - if (typeof args2 === 'object') { - for (var argKey in args2) { - opts[argKey] = args2[argKey]; - } - } - var obj = this.execute(args1, opts); + if (state.anchor !== null) { + state.anchorMap[state.anchor] = state.result; + } + } + } else if (indentStatus === 0) { + // Special case: block sequences are allowed to have same indentation level as the parent. + // http://www.yaml.org/spec/1.2/spec.html#id2799784 + hasContent = allowBlockCollections && readBlockSequence(state, blockIndent); + } + } + + if (state.tag !== null && state.tag !== '!') { + if (state.tag === '?') { + for (typeIndex = 0, typeQuantity = state.implicitTypes.length; + typeIndex < typeQuantity; + typeIndex += 1) { + type = state.implicitTypes[typeIndex]; + + // Implicit resolving is not allowed for non-scalar types, and '?' + // non-specific tag is only assigned to plain scalars. So, it isn't + // needed to check for 'kind' conformity. + + if (type.resolve(state.result)) { // `state.result` updated in resolver if matched + state.result = type.construct(state.result); + state.tag = type.tag; + if (state.anchor !== null) { + state.anchorMap[state.anchor] = state.result; + } + break; + } + } + } else if (_hasOwnProperty.call(state.typeMap, state.tag)) { + type = state.typeMap[state.tag]; + + if (state.result !== null && type.kind !== state.kind) { + throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"'); + } + + if (!type.resolve(state.result)) { // `state.result` updated in resolver if matched + throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag'); + } else { + state.result = type.construct(state.result); + if (state.anchor !== null) { + state.anchorMap[state.anchor] = state.result; + } + } + } else { + throwError(state, 'unknown tag !<' + state.tag + '>'); + } + } + + if (state.listener !== null) { + state.listener('close', state); + } + return state.tag !== null || state.anchor !== null || hasContent; +} + +function readDocument(state) { + var documentStart = state.position, + _position, + directiveName, + directiveArgs, + hasDirectives = false, + ch; + + state.version = null; + state.checkLineBreaks = state.legacy; + state.tagMap = {}; + state.anchorMap = {}; + + while ((ch = state.input.charCodeAt(state.position)) !== 0) { + skipSeparationSpace(state, true, -1); + + ch = state.input.charCodeAt(state.position); + + if (state.lineIndent > 0 || ch !== 0x25/* % */) { + break; + } - this.clientAuthorizations.apply(obj); + hasDirectives = true; + ch = state.input.charCodeAt(++state.position); + _position = state.position; - var results = []; + while (ch !== 0 && !is_WS_OR_EOL(ch)) { + ch = state.input.charCodeAt(++state.position); + } - results.push('-X ' + this.method.toUpperCase()); + directiveName = state.input.slice(_position, state.position); + directiveArgs = []; - if (obj.headers) { - var key; + if (directiveName.length < 1) { + throwError(state, 'directive name must not be less than one character in length'); + } - for (key in obj.headers) { - results.push('--header "' + key + ': ' + obj.headers[key] + '"'); - } - } + while (ch !== 0) { + while (is_WHITE_SPACE(ch)) { + ch = state.input.charCodeAt(++state.position); + } - if (obj.body) { - var body; + if (ch === 0x23/* # */) { + do { ch = state.input.charCodeAt(++state.position); } + while (ch !== 0 && !is_EOL(ch)); + break; + } - if (_.isObject(obj.body)) { - body = JSON.stringify(obj.body); - } else { - body = obj.body; - } + if (is_EOL(ch)) break; - results.push('-d "' + body.replace(/"/g, '\\"') + '"'); - } + _position = state.position; - return 'curl ' + results.join(' ') + ' "' + obj.url + '"'; - }; + while (ch !== 0 && !is_WS_OR_EOL(ch)) { + ch = state.input.charCodeAt(++state.position); + } - Operation.prototype.encodePathCollection = function (type, name, value) { - var encoded = ''; - var i; - var separator = ''; - - if (type === 'ssv') { - separator = '%20'; - } else if (type === 'tsv') { - separator = '\\t'; - } else if (type === 'pipes') { - separator = '|'; - } else { - separator = ','; - } + directiveArgs.push(state.input.slice(_position, state.position)); + } - for (i = 0; i < value.length; i++) { - if (i === 0) { - encoded = this.encodeQueryParam(value[i]); - } else { - encoded += separator + this.encodeQueryParam(value[i]); - } - } + if (ch !== 0) readLineBreak(state); - return encoded; - }; + if (_hasOwnProperty.call(directiveHandlers, directiveName)) { + directiveHandlers[directiveName](state, directiveName, directiveArgs); + } else { + throwWarning(state, 'unknown document directive "' + directiveName + '"'); + } + } - Operation.prototype.encodeQueryCollection = function (type, name, value) { - var encoded = ''; - var i; + skipSeparationSpace(state, true, -1); - if (type === 'default' || type === 'multi') { - for (i = 0; i < value.length; i++) { - if (i > 0) { - encoded += '&'; - } + if (state.lineIndent === 0 && + state.input.charCodeAt(state.position) === 0x2D/* - */ && + state.input.charCodeAt(state.position + 1) === 0x2D/* - */ && + state.input.charCodeAt(state.position + 2) === 0x2D/* - */) { + state.position += 3; + skipSeparationSpace(state, true, -1); - encoded += this.encodeQueryParam(name) + '=' + this.encodeQueryParam(value[i]); - } - } else { - var separator = ''; - - if (type === 'csv') { - separator = ','; - } else if (type === 'ssv') { - separator = '%20'; - } else if (type === 'tsv') { - separator = '\\t'; - } else if (type === 'pipes') { - separator = '|'; - } else if (type === 'brackets') { - for (i = 0; i < value.length; i++) { - if (i !== 0) { - encoded += '&'; - } + } else if (hasDirectives) { + throwError(state, 'directives end mark is expected'); + } - encoded += this.encodeQueryParam(name) + '[]=' + this.encodeQueryParam(value[i]); - } - } + composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true); + skipSeparationSpace(state, true, -1); - if (separator !== '') { - for (i = 0; i < value.length; i++) { - if (i === 0) { - encoded = this.encodeQueryParam(name) + '=' + this.encodeQueryParam(value[i]); - } else { - encoded += separator + this.encodeQueryParam(value[i]); - } - } - } - } + if (state.checkLineBreaks && + PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) { + throwWarning(state, 'non-ASCII line breaks are interpreted as content'); + } - return encoded; - }; + state.documents.push(state.result); - Operation.prototype.encodeQueryParam = function (arg) { - return encodeURIComponent(arg); - }; + if (state.position === state.lineStart && testDocumentSeparator(state)) { - /** - * TODO revisit, might not want to leave '/' - **/ - Operation.prototype.encodePathParam = function (pathParam) { - return encodeURIComponent(pathParam); - }; + if (state.input.charCodeAt(state.position) === 0x2E/* . */) { + state.position += 3; + skipSeparationSpace(state, true, -1); + } + return; + } - },{ - '../helpers': 4,'../http': 5,'./model': 9,'lodash-compat/lang/cloneDeep': 141,'lodash-compat/lang/isEmpty': 144,'lodash-compat/lang/isObject': 147,'lodash-compat/lang/isUndefined': 151 - }],11: [function (require, module, exports) { - 'use strict'; - - var OperationGroup = module.exports = function (tag, description, externalDocs, operation) { - this.description = description; - this.externalDocs = externalDocs; - this.name = tag; - this.operation = operation; - this.operationsArray = []; - this.path = tag; - this.tag = tag; - }; + if (state.position < (state.length - 1)) { + throwError(state, 'end of the stream or a document separator is expected'); + } else { + return; + } +} - OperationGroup.prototype.sort = function () { - }; +function loadDocuments(input, options) { + input = String(input); + options = options || {}; - },{}],12: [function (require, module, exports) { + if (input.length !== 0) { - },{}],13: [function (require, module, exports) { - /*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */ + // Add tailing `\n` if not exists + if (input.charCodeAt(input.length - 1) !== 0x0A/* LF */ && + input.charCodeAt(input.length - 1) !== 0x0D/* CR */) { + input += '\n'; + } - var base64 = require('base64-js'); - var ieee754 = require('ieee754'); - var isArray = require('is-array'); - - exports.Buffer = Buffer; - exports.SlowBuffer = SlowBuffer; - exports.INSPECT_MAX_BYTES = 50; - Buffer.poolSize = 8192; // not used by this implementation - - var rootParent = {}; - - /** - * If `Buffer.TYPED_ARRAY_SUPPORT`: - * === true Use Uint8Array implementation (fastest) - * === false Use Object implementation (most compatible, even IE6) - * - * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, - * Opera 11.6+, iOS 4.2+. - * - * Note: - * - * - Implementation must support adding new properties to `Uint8Array` instances. - * Firefox 4-29 lacked support, fixed in Firefox 30+. - * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. - * - * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. - * - * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of - * incorrect length in some situations. - * - * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they will - * get the Object implementation, which is slower but will work correctly. - */ - Buffer.TYPED_ARRAY_SUPPORT = (function () { - function Foo() {} - - try { - var buf = new ArrayBuffer(0); - var arr = new Uint8Array(buf); - - arr.foo = function () { - return 42; - }; - arr.constructor = Foo; - - return arr.foo() === 42 && // typed array instances can be augmented - arr.constructor === Foo && // constructor can be set - typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` - new Uint8Array(1).subarray(1, 1).byteLength === 0; // ie10 has broken `subarray` - } catch (e) { - return false; - } - })(); + // Strip BOM + if (input.charCodeAt(0) === 0xFEFF) { + input = input.slice(1); + } + } - function kMaxLength() { - return Buffer.TYPED_ARRAY_SUPPORT ? - 0x7fffffff - : 0x3fffffff; - } + var state = new State(input, options); - /** - * Class: Buffer - * ============= - * - * The Buffer constructor returns instances of `Uint8Array` that are augmented - * with function properties for all the node `Buffer` API functions. We use - * `Uint8Array` so that square bracket notation works as expected -- it returns - * a single octet. - * - * By augmenting the instances, we can avoid modifying the `Uint8Array` - * prototype. - */ - function Buffer(arg) { - if (!(this instanceof Buffer)) { - // Avoid going through an ArgumentsAdaptorTrampoline in the common case. - if (arguments.length > 1) return new Buffer(arg, arguments[1]); + // Use 0 as string terminator. That significantly simplifies bounds check. + state.input += '\0'; - return new Buffer(arg); - } + while (state.input.charCodeAt(state.position) === 0x20/* Space */) { + state.lineIndent += 1; + state.position += 1; + } - this.length = 0; - this.parent = undefined; + while (state.position < (state.length - 1)) { + readDocument(state); + } - // Common case. - if (typeof arg === 'number') { - return fromNumber(this, arg); - } + return state.documents; +} - // Slightly less common case. - if (typeof arg === 'string') { - return fromString(this, arg, arguments.length > 1 ? arguments[1] : 'utf8'); - } - // Unusual. - return fromObject(this, arg); - } +function loadAll(input, iterator, options) { + var documents = loadDocuments(input, options), index, length; - function fromNumber(that, length) { - that = allocate(that, length < 0 ? 0 : checked(length) | 0); + for (index = 0, length = documents.length; index < length; index += 1) { + iterator(documents[index]); + } +} - if (!Buffer.TYPED_ARRAY_SUPPORT) { - for (var i = 0; i < length; i++) { - that[i] = 0; - } - } - return that; - } +function load(input, options) { + var documents = loadDocuments(input, options); - function fromString(that, string, encoding) { - if (typeof encoding !== 'string' || encoding === '') encoding = 'utf8'; + if (documents.length === 0) { + /*eslint-disable no-undefined*/ + return undefined; + } else if (documents.length === 1) { + return documents[0]; + } + throw new YAMLException('expected a single document in the stream, but found more'); +} - // Assumption: byteLength() return value is always < kMaxLength. - var length = byteLength(string, encoding) | 0; - that = allocate(that, length); +function safeLoadAll(input, output, options) { + loadAll(input, output, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options)); +} - that.write(string, encoding); - return that; - } +function safeLoad(input, options) { + return load(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options)); +} - function fromObject(that, object) { - if (Buffer.isBuffer(object)) return fromBuffer(that, object); - if (isArray(object)) return fromArray(that, object); +module.exports.loadAll = loadAll; +module.exports.load = load; +module.exports.safeLoadAll = safeLoadAll; +module.exports.safeLoad = safeLoad; - if (object == null) { - throw new TypeError('must start with number, buffer, array or string'); - } +},{"./common":21,"./exception":23,"./mark":25,"./schema/default_full":28,"./schema/default_safe":29}],25:[function(require,module,exports){ +'use strict'; - if (typeof ArrayBuffer !== 'undefined' && object.buffer instanceof ArrayBuffer) { - return fromTypedArray(that, object); - } - if (object.length) return fromArrayLike(that, object); +var common = require('./common'); - return fromJsonObject(that, object); - } - function fromBuffer(that, buffer) { - var length = checked(buffer.length) | 0; +function Mark(name, buffer, position, line, column) { + this.name = name; + this.buffer = buffer; + this.position = position; + this.line = line; + this.column = column; +} - that = allocate(that, length); - buffer.copy(that, 0, 0, length); - return that; - } +Mark.prototype.getSnippet = function getSnippet(indent, maxLength) { + var head, start, tail, end, snippet; - function fromArray(that, array) { - var length = checked(array.length) | 0; + if (!this.buffer) return null; - that = allocate(that, length); + indent = indent || 4; + maxLength = maxLength || 75; - for (var i = 0; i < length; i += 1) { - that[i] = array[i] & 255; - } + head = ''; + start = this.position; - return that; - } + while (start > 0 && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(start - 1)) === -1) { + start -= 1; + if (this.position - start > (maxLength / 2 - 1)) { + head = ' ... '; + start += 5; + break; + } + } - // Duplicate of fromArray() to keep fromArray() monomorphic. - function fromTypedArray(that, array) { - var length = checked(array.length) | 0; + tail = ''; + end = this.position; - that = allocate(that, length); - // Truncating the elements is probably not what people expect from typed - // arrays with BYTES_PER_ELEMENT > 1 but it's compatible with the behavior - // of the old Buffer constructor. - for (var i = 0; i < length; i += 1) { - that[i] = array[i] & 255; - } + while (end < this.buffer.length && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(end)) === -1) { + end += 1; + if (end - this.position > (maxLength / 2 - 1)) { + tail = ' ... '; + end -= 5; + break; + } + } - return that; - } + snippet = this.buffer.slice(start, end); - function fromArrayLike(that, array) { - var length = checked(array.length) | 0; + return common.repeat(' ', indent) + head + snippet + tail + '\n' + + common.repeat(' ', indent + this.position - start + head.length) + '^'; +}; - that = allocate(that, length); - for (var i = 0; i < length; i += 1) { - that[i] = array[i] & 255; - } +Mark.prototype.toString = function toString(compact) { + var snippet, where = ''; - return that; - } + if (this.name) { + where += 'in "' + this.name + '" '; + } - // Deserialize { type: 'Buffer', data: [1,2,3,...] } into a Buffer object. - // Returns a zero-length buffer for inputs that don't conform to the spec. - function fromJsonObject(that, object) { - var array; - var length = 0; + where += 'at line ' + (this.line + 1) + ', column ' + (this.column + 1); - if (object.type === 'Buffer' && isArray(object.data)) { - array = object.data; - length = checked(array.length) | 0; - } - that = allocate(that, length); + if (!compact) { + snippet = this.getSnippet(); - for (var i = 0; i < length; i += 1) { - that[i] = array[i] & 255; - } + if (snippet) { + where += ':\n' + snippet; + } + } - return that; - } + return where; +}; - function allocate(that, length) { - if (Buffer.TYPED_ARRAY_SUPPORT) { - // Return an augmented `Uint8Array` instance, for best performance - that = Buffer._augment(new Uint8Array(length)); - } else { - // Fallback: Return an object instance of the Buffer class - that.length = length; - that._isBuffer = true; - } - var fromPool = length !== 0 && length <= Buffer.poolSize >>> 1; +module.exports = Mark; - if (fromPool) that.parent = rootParent; +},{"./common":21}],26:[function(require,module,exports){ +'use strict'; - return that; - } +/*eslint-disable max-len*/ - function checked(length) { - // Note: cannot use `length < kMaxLength` here because that fails when - // length is NaN (which is otherwise coerced to zero.) - if (length >= kMaxLength()) { - throw new RangeError('Attempt to allocate Buffer larger than maximum ' + - 'size: 0x' + kMaxLength().toString(16) + ' bytes'); - } +var common = require('./common'); +var YAMLException = require('./exception'); +var Type = require('./type'); - return length | 0; - } - function SlowBuffer(subject, encoding) { - if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding); +function compileList(schema, name, result) { + var exclude = []; - var buf = new Buffer(subject, encoding); + schema.include.forEach(function (includedSchema) { + result = compileList(includedSchema, name, result); + }); - delete buf.parent; + schema[name].forEach(function (currentType) { + result.forEach(function (previousType, previousIndex) { + if (previousType.tag === currentType.tag) { + exclude.push(previousIndex); + } + }); - return buf; - } + result.push(currentType); + }); - Buffer.isBuffer = function isBuffer(b) { - return !!(b != null && b._isBuffer); - }; + return result.filter(function (type, index) { + return exclude.indexOf(index) === -1; + }); +} - Buffer.compare = function compare(a, b) { - if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { - throw new TypeError('Arguments must be Buffers'); - } - if (a === b) return 0; +function compileMap(/* lists... */) { + var result = {}, index, length; - var x = a.length; - var y = b.length; + function collectType(type) { + result[type.tag] = type; + } - var i = 0; - var len = Math.min(x, y); + for (index = 0, length = arguments.length; index < length; index += 1) { + arguments[index].forEach(collectType); + } - while (i < len) { - if (a[i] !== b[i]) break; + return result; +} - ++i; - } - if (i !== len) { - x = a[i]; - y = b[i]; - } +function Schema(definition) { + this.include = definition.include || []; + this.implicit = definition.implicit || []; + this.explicit = definition.explicit || []; - if (x < y) return -1; + this.implicit.forEach(function (type) { + if (type.loadKind && type.loadKind !== 'scalar') { + throw new YAMLException('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.'); + } + }); - if (y < x) return 1; + this.compiledImplicit = compileList(this, 'implicit', []); + this.compiledExplicit = compileList(this, 'explicit', []); + this.compiledTypeMap = compileMap(this.compiledImplicit, this.compiledExplicit); +} - return 0; - }; - Buffer.isEncoding = function isEncoding(encoding) { - switch (String(encoding).toLowerCase()) { - case 'hex': - case 'utf8': - case 'utf-8': - case 'ascii': - case 'binary': - case 'base64': - case 'raw': - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return true; - default: - return false; - } - }; +Schema.DEFAULT = null; - Buffer.concat = function concat(list, length) { - if (!isArray(list)) throw new TypeError('list argument must be an Array of Buffers.'); - if (list.length === 0) { - return new Buffer(0); - } else if (list.length === 1) { - return list[0]; - } +Schema.create = function createSchema() { + var schemas, types; - var i; + switch (arguments.length) { + case 1: + schemas = Schema.DEFAULT; + types = arguments[0]; + break; - if (length === undefined) { - length = 0; + case 2: + schemas = arguments[0]; + types = arguments[1]; + break; - for (i = 0; i < list.length; i++) { - length += list[i].length; - } - } + default: + throw new YAMLException('Wrong number of arguments for Schema.create function'); + } - var buf = new Buffer(length); - var pos = 0; + schemas = common.toArray(schemas); + types = common.toArray(types); - for (i = 0; i < list.length; i++) { - var item = list[i]; + if (!schemas.every(function (schema) { return schema instanceof Schema; })) { + throw new YAMLException('Specified list of super schemas (or a single Schema object) contains a non-Schema object.'); + } - item.copy(buf, pos); - pos += item.length; - } + if (!types.every(function (type) { return type instanceof Type; })) { + throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.'); + } - return buf; - }; + return new Schema({ + include: schemas, + explicit: types + }); +}; - function byteLength(string, encoding) { - if (typeof string !== 'string') string = '' + string; - var len = string.length; +module.exports = Schema; - if (len === 0) return 0; +},{"./common":21,"./exception":23,"./type":32}],27:[function(require,module,exports){ +// Standard YAML's Core schema. +// http://www.yaml.org/spec/1.2/spec.html#id2804923 +// +// NOTE: JS-YAML does not support schema-specific tag resolution restrictions. +// So, Core schema has no distinctions from JSON schema is JS-YAML. - // Use a for loop to avoid recursion - var loweredCase = false; - for (;;) { - switch (encoding) { - case 'ascii': - case 'binary': - // Deprecated - case 'raw': - case 'raws': - return len; +'use strict'; - case 'utf8': - case 'utf-8': - return utf8ToBytes(string).length; - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return len * 2; +var Schema = require('../schema'); - case 'hex': - return len >>> 1; - case 'base64': - return base64ToBytes(string).length; - default: - if (loweredCase) return utf8ToBytes(string).length; // assume utf8 - encoding = ('' + encoding).toLowerCase(); - loweredCase = true; - } - } - } - Buffer.byteLength = byteLength; +module.exports = new Schema({ + include: [ + require('./json') + ] +}); - // pre-set for values that may exist in the future - Buffer.prototype.length = undefined; - Buffer.prototype.parent = undefined; +},{"../schema":26,"./json":31}],28:[function(require,module,exports){ +// JS-YAML's default schema for `load` function. +// It is not described in the YAML specification. +// +// This schema is based on JS-YAML's default safe schema and includes +// JavaScript-specific types: !!js/undefined, !!js/regexp and !!js/function. +// +// Also this schema is used as default base schema at `Schema.create` function. - function slowToString(encoding, start, end) { - var loweredCase = false; - start |= 0; - end = end === undefined || end === Infinity ? this.length : end | 0; +'use strict'; - if (!encoding) encoding = 'utf8'; - if (start < 0) start = 0; +var Schema = require('../schema'); - if (end > this.length) end = this.length; - if (end <= start) return ''; +module.exports = Schema.DEFAULT = new Schema({ + include: [ + require('./default_safe') + ], + explicit: [ + require('../type/js/undefined'), + require('../type/js/regexp'), + require('../type/js/function') + ] +}); - while (true) { - switch (encoding) { - case 'hex': - return hexSlice(this, start, end); +},{"../schema":26,"../type/js/function":37,"../type/js/regexp":38,"../type/js/undefined":39,"./default_safe":29}],29:[function(require,module,exports){ +// JS-YAML's default schema for `safeLoad` function. +// It is not described in the YAML specification. +// +// This schema is based on standard YAML's Core schema and includes most of +// extra types described at YAML tag repository. (http://yaml.org/type/) - case 'utf8': - case 'utf-8': - return utf8Slice(this, start, end); - case 'ascii': - return asciiSlice(this, start, end); +'use strict'; - case 'binary': - return binarySlice(this, start, end); - case 'base64': - return base64Slice(this, start, end); +var Schema = require('../schema'); - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return utf16leSlice(this, start, end); - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding); - encoding = (encoding + '').toLowerCase(); - loweredCase = true; - } - } - } +module.exports = new Schema({ + include: [ + require('./core') + ], + implicit: [ + require('../type/timestamp'), + require('../type/merge') + ], + explicit: [ + require('../type/binary'), + require('../type/omap'), + require('../type/pairs'), + require('../type/set') + ] +}); - Buffer.prototype.toString = function toString() { - var length = this.length | 0; +},{"../schema":26,"../type/binary":33,"../type/merge":41,"../type/omap":43,"../type/pairs":44,"../type/set":46,"../type/timestamp":48,"./core":27}],30:[function(require,module,exports){ +// Standard YAML's Failsafe schema. +// http://www.yaml.org/spec/1.2/spec.html#id2802346 - if (length === 0) return ''; - if (arguments.length === 0) return utf8Slice(this, 0, length); +'use strict'; - return slowToString.apply(this, arguments); - }; - Buffer.prototype.equals = function equals(b) { - if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer'); +var Schema = require('../schema'); - if (this === b) return true; - return Buffer.compare(this, b) === 0; - }; +module.exports = new Schema({ + explicit: [ + require('../type/str'), + require('../type/seq'), + require('../type/map') + ] +}); - Buffer.prototype.inspect = function inspect() { - var str = ''; - var max = exports.INSPECT_MAX_BYTES; +},{"../schema":26,"../type/map":40,"../type/seq":45,"../type/str":47}],31:[function(require,module,exports){ +// Standard YAML's JSON schema. +// http://www.yaml.org/spec/1.2/spec.html#id2803231 +// +// NOTE: JS-YAML does not support schema-specific tag resolution restrictions. +// So, this schema is not such strict as defined in the YAML specification. +// It allows numbers in binary notaion, use `Null` and `NULL` as `null`, etc. - if (this.length > 0) { - str = this.toString('hex', 0, max).match(/.{2}/g).join(' '); - if (this.length > max) str += ' ... '; - } +'use strict'; - return ''; - }; - Buffer.prototype.compare = function compare(b) { - if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer'); +var Schema = require('../schema'); - if (this === b) return 0; - return Buffer.compare(this, b); - }; +module.exports = new Schema({ + include: [ + require('./failsafe') + ], + implicit: [ + require('../type/null'), + require('../type/bool'), + require('../type/int'), + require('../type/float') + ] +}); - Buffer.prototype.indexOf = function indexOf(val, byteOffset) { - if (byteOffset > 0x7fffffff) byteOffset = 0x7fffffff; - else if (byteOffset < -0x80000000) byteOffset = -0x80000000; - byteOffset >>= 0; +},{"../schema":26,"../type/bool":34,"../type/float":35,"../type/int":36,"../type/null":42,"./failsafe":30}],32:[function(require,module,exports){ +'use strict'; - if (this.length === 0) return -1; +var YAMLException = require('./exception'); - if (byteOffset >= this.length) return -1; +var TYPE_CONSTRUCTOR_OPTIONS = [ + 'kind', + 'resolve', + 'construct', + 'instanceOf', + 'predicate', + 'represent', + 'defaultStyle', + 'styleAliases' +]; + +var YAML_NODE_KINDS = [ + 'scalar', + 'sequence', + 'mapping' +]; - // Negative offsets start from the end of the buffer - if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0); +function compileStyleAliases(map) { + var result = {}; - if (typeof val === 'string') { - if (val.length === 0) return -1; // special case: looking for empty string always fails - return String.prototype.indexOf.call(this, val, byteOffset); - } + if (map !== null) { + Object.keys(map).forEach(function (style) { + map[style].forEach(function (alias) { + result[String(alias)] = style; + }); + }); + } - if (Buffer.isBuffer(val)) { - return arrayIndexOf(this, val, byteOffset); - } + return result; +} - if (typeof val === 'number') { - if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') { - return Uint8Array.prototype.indexOf.call(this, val, byteOffset); - } +function Type(tag, options) { + options = options || {}; - return arrayIndexOf(this, [val], byteOffset); - } + Object.keys(options).forEach(function (name) { + if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) { + throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.'); + } + }); - function arrayIndexOf(arr, val, byteOffset) { - var foundIndex = -1; + // TODO: Add tag format check. + this.tag = tag; + this.kind = options['kind'] || null; + this.resolve = options['resolve'] || function () { return true; }; + this.construct = options['construct'] || function (data) { return data; }; + this.instanceOf = options['instanceOf'] || null; + this.predicate = options['predicate'] || null; + this.represent = options['represent'] || null; + this.defaultStyle = options['defaultStyle'] || null; + this.styleAliases = compileStyleAliases(options['styleAliases'] || null); - for (var i = 0; byteOffset + i < arr.length; i++) { - if (arr[byteOffset + i] === val[foundIndex === -1 ? 0 : i - foundIndex]) { - if (foundIndex === -1) foundIndex = i; + if (YAML_NODE_KINDS.indexOf(this.kind) === -1) { + throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.'); + } +} - if (i - foundIndex + 1 === val.length) return byteOffset + foundIndex; - } else { - foundIndex = -1; - } - } +module.exports = Type; - return -1; - } +},{"./exception":23}],33:[function(require,module,exports){ +'use strict'; - throw new TypeError('val must be string, number or Buffer'); - }; +/*eslint-disable no-bitwise*/ - // `get` will be removed in Node 0.13+ - Buffer.prototype.get = function get(offset) { - console.log('.get() is deprecated. Access using array indexes instead.'); +var NodeBuffer; - return this.readUInt8(offset); - }; +try { + // A trick for browserified version, to not include `Buffer` shim + var _require = require; + NodeBuffer = _require('buffer').Buffer; +} catch (__) {} - // `set` will be removed in Node 0.13+ - Buffer.prototype.set = function set(v, offset) { - console.log('.set() is deprecated. Access using array indexes instead.'); +var Type = require('../type'); - return this.writeUInt8(v, offset); - }; - function hexWrite(buf, string, offset, length) { - offset = Number(offset) || 0; - var remaining = buf.length - offset; +// [ 64, 65, 66 ] -> [ padding, CR, LF ] +var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r'; - if (!length) { - length = remaining; - } else { - length = Number(length); - if (length > remaining) { - length = remaining; - } - } +function resolveYamlBinary(data) { + if (data === null) return false; - // must be an even number of digits - var strLen = string.length; + var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP; - if (strLen % 2 !== 0) throw new Error('Invalid hex string'); + // Convert one by one. + for (idx = 0; idx < max; idx++) { + code = map.indexOf(data.charAt(idx)); - if (length > strLen / 2) { - length = strLen / 2; - } + // Skip CR/LF + if (code > 64) continue; - for (var i = 0; i < length; i++) { - var parsed = parseInt(string.substr(i * 2, 2), 16); + // Fail on illegal characters + if (code < 0) return false; - if (isNaN(parsed)) throw new Error('Invalid hex string'); - buf[offset + i] = parsed; - } + bitlen += 6; + } - return i; - } + // If there are any bits left, source was corrupted + return (bitlen % 8) === 0; +} - function utf8Write(buf, string, offset, length) { - return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length); - } +function constructYamlBinary(data) { + var idx, tailbits, + input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan + max = input.length, + map = BASE64_MAP, + bits = 0, + result = []; - function asciiWrite(buf, string, offset, length) { - return blitBuffer(asciiToBytes(string), buf, offset, length); - } + // Collect by 6*4 bits (3 bytes) - function binaryWrite(buf, string, offset, length) { - return asciiWrite(buf, string, offset, length); - } + for (idx = 0; idx < max; idx++) { + if ((idx % 4 === 0) && idx) { + result.push((bits >> 16) & 0xFF); + result.push((bits >> 8) & 0xFF); + result.push(bits & 0xFF); + } - function base64Write(buf, string, offset, length) { - return blitBuffer(base64ToBytes(string), buf, offset, length); - } + bits = (bits << 6) | map.indexOf(input.charAt(idx)); + } - function ucs2Write(buf, string, offset, length) { - return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length); - } + // Dump tail - Buffer.prototype.write = function write(string, offset, length, encoding) { - // Buffer#write(string) - if (offset === undefined) { - encoding = 'utf8'; - length = this.length; - offset = 0; - // Buffer#write(string, encoding) - } else if (length === undefined && typeof offset === 'string') { - encoding = offset; - length = this.length; - offset = 0; - // Buffer#write(string, offset[, length][, encoding]) - } else if (isFinite(offset)) { - offset |= 0; - - if (isFinite(length)) { - length |= 0; - - if (encoding === undefined) encoding = 'utf8'; - } else { - encoding = length; - length = undefined; - } - // legacy write(string, encoding, offset, length) - remove in v0.13 - } else { - var swap = encoding; + tailbits = (max % 4) * 6; - encoding = offset; - offset = length | 0; - length = swap; - } + if (tailbits === 0) { + result.push((bits >> 16) & 0xFF); + result.push((bits >> 8) & 0xFF); + result.push(bits & 0xFF); + } else if (tailbits === 18) { + result.push((bits >> 10) & 0xFF); + result.push((bits >> 2) & 0xFF); + } else if (tailbits === 12) { + result.push((bits >> 4) & 0xFF); + } - var remaining = this.length - offset; + // Wrap into Buffer for NodeJS and leave Array for browser + if (NodeBuffer) return new NodeBuffer(result); - if (length === undefined || length > remaining) length = remaining; + return result; +} - if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) { - throw new RangeError('attempt to write outside buffer bounds'); - } +function representYamlBinary(object /*, style*/) { + var result = '', bits = 0, idx, tail, + max = object.length, + map = BASE64_MAP; - if (!encoding) encoding = 'utf8'; + // Convert every three bytes to 4 ASCII characters. - var loweredCase = false; + for (idx = 0; idx < max; idx++) { + if ((idx % 3 === 0) && idx) { + result += map[(bits >> 18) & 0x3F]; + result += map[(bits >> 12) & 0x3F]; + result += map[(bits >> 6) & 0x3F]; + result += map[bits & 0x3F]; + } - for (;;) { - switch (encoding) { - case 'hex': - return hexWrite(this, string, offset, length); + bits = (bits << 8) + object[idx]; + } + + // Dump tail + + tail = max % 3; + + if (tail === 0) { + result += map[(bits >> 18) & 0x3F]; + result += map[(bits >> 12) & 0x3F]; + result += map[(bits >> 6) & 0x3F]; + result += map[bits & 0x3F]; + } else if (tail === 2) { + result += map[(bits >> 10) & 0x3F]; + result += map[(bits >> 4) & 0x3F]; + result += map[(bits << 2) & 0x3F]; + result += map[64]; + } else if (tail === 1) { + result += map[(bits >> 2) & 0x3F]; + result += map[(bits << 4) & 0x3F]; + result += map[64]; + result += map[64]; + } + + return result; +} + +function isBinary(object) { + return NodeBuffer && NodeBuffer.isBuffer(object); +} + +module.exports = new Type('tag:yaml.org,2002:binary', { + kind: 'scalar', + resolve: resolveYamlBinary, + construct: constructYamlBinary, + predicate: isBinary, + represent: representYamlBinary +}); + +},{"../type":32}],34:[function(require,module,exports){ +'use strict'; + +var Type = require('../type'); + +function resolveYamlBoolean(data) { + if (data === null) return false; + + var max = data.length; + + return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) || + (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE')); +} + +function constructYamlBoolean(data) { + return data === 'true' || + data === 'True' || + data === 'TRUE'; +} + +function isBoolean(object) { + return Object.prototype.toString.call(object) === '[object Boolean]'; +} + +module.exports = new Type('tag:yaml.org,2002:bool', { + kind: 'scalar', + resolve: resolveYamlBoolean, + construct: constructYamlBoolean, + predicate: isBoolean, + represent: { + lowercase: function (object) { return object ? 'true' : 'false'; }, + uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; }, + camelcase: function (object) { return object ? 'True' : 'False'; } + }, + defaultStyle: 'lowercase' +}); + +},{"../type":32}],35:[function(require,module,exports){ +'use strict'; + +var common = require('../common'); +var Type = require('../type'); + +var YAML_FLOAT_PATTERN = new RegExp( + '^(?:[-+]?(?:[0-9][0-9_]*)\\.[0-9_]*(?:[eE][-+][0-9]+)?' + + '|\\.[0-9_]+(?:[eE][-+][0-9]+)?' + + '|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' + + '|[-+]?\\.(?:inf|Inf|INF)' + + '|\\.(?:nan|NaN|NAN))$'); + +function resolveYamlFloat(data) { + if (data === null) return false; + + if (!YAML_FLOAT_PATTERN.test(data)) return false; + + return true; +} + +function constructYamlFloat(data) { + var value, sign, base, digits; + + value = data.replace(/_/g, '').toLowerCase(); + sign = value[0] === '-' ? -1 : 1; + digits = []; + + if ('+-'.indexOf(value[0]) >= 0) { + value = value.slice(1); + } + + if (value === '.inf') { + return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY; + + } else if (value === '.nan') { + return NaN; + + } else if (value.indexOf(':') >= 0) { + value.split(':').forEach(function (v) { + digits.unshift(parseFloat(v, 10)); + }); - case 'utf8': - case 'utf-8': - return utf8Write(this, string, offset, length); + value = 0.0; + base = 1; - case 'ascii': - return asciiWrite(this, string, offset, length); + digits.forEach(function (d) { + value += d * base; + base *= 60; + }); - case 'binary': - return binaryWrite(this, string, offset, length); + return sign * value; - case 'base64': - // Warning: maxLength not taken into account in base64Write - return base64Write(this, string, offset, length); + } + return sign * parseFloat(value, 10); +} - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return ucs2Write(this, string, offset, length); - default: - if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding); - encoding = ('' + encoding).toLowerCase(); - loweredCase = true; - } - } - }; +var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/; - Buffer.prototype.toJSON = function toJSON() { - return { - type: 'Buffer', - data: Array.prototype.slice.call(this._arr || this, 0) - }; - }; +function representYamlFloat(object, style) { + var res; - function base64Slice(buf, start, end) { - if (start === 0 && end === buf.length) { - return base64.fromByteArray(buf); - } + if (isNaN(object)) { + switch (style) { + case 'lowercase': return '.nan'; + case 'uppercase': return '.NAN'; + case 'camelcase': return '.NaN'; + } + } else if (Number.POSITIVE_INFINITY === object) { + switch (style) { + case 'lowercase': return '.inf'; + case 'uppercase': return '.INF'; + case 'camelcase': return '.Inf'; + } + } else if (Number.NEGATIVE_INFINITY === object) { + switch (style) { + case 'lowercase': return '-.inf'; + case 'uppercase': return '-.INF'; + case 'camelcase': return '-.Inf'; + } + } else if (common.isNegativeZero(object)) { + return '-0.0'; + } + + res = object.toString(10); + + // JS stringifier can build scientific format without dots: 5e-100, + // while YAML requres dot: 5.e-100. Fix it with simple hack + + return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res; +} + +function isFloat(object) { + return (Object.prototype.toString.call(object) === '[object Number]') && + (object % 1 !== 0 || common.isNegativeZero(object)); +} + +module.exports = new Type('tag:yaml.org,2002:float', { + kind: 'scalar', + resolve: resolveYamlFloat, + construct: constructYamlFloat, + predicate: isFloat, + represent: representYamlFloat, + defaultStyle: 'lowercase' +}); + +},{"../common":21,"../type":32}],36:[function(require,module,exports){ +'use strict'; + +var common = require('../common'); +var Type = require('../type'); + +function isHexCode(c) { + return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) || + ((0x41/* A */ <= c) && (c <= 0x46/* F */)) || + ((0x61/* a */ <= c) && (c <= 0x66/* f */)); +} + +function isOctCode(c) { + return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */)); +} + +function isDecCode(c) { + return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)); +} + +function resolveYamlInteger(data) { + if (data === null) return false; + + var max = data.length, + index = 0, + hasDigits = false, + ch; + + if (!max) return false; + + ch = data[index]; + + // sign + if (ch === '-' || ch === '+') { + ch = data[++index]; + } + + if (ch === '0') { + // 0 + if (index + 1 === max) return true; + ch = data[++index]; + + // base 2, base 8, base 16 + + if (ch === 'b') { + // base 2 + index++; + + for (; index < max; index++) { + ch = data[index]; + if (ch === '_') continue; + if (ch !== '0' && ch !== '1') return false; + hasDigits = true; + } + return hasDigits; + } - return base64.fromByteArray(buf.slice(start, end)); - } + if (ch === 'x') { + // base 16 + index++; - function utf8Slice(buf, start, end) { - var res = ''; - var tmp = ''; + for (; index < max; index++) { + ch = data[index]; + if (ch === '_') continue; + if (!isHexCode(data.charCodeAt(index))) return false; + hasDigits = true; + } + return hasDigits; + } - end = Math.min(buf.length, end); + // base 8 + for (; index < max; index++) { + ch = data[index]; + if (ch === '_') continue; + if (!isOctCode(data.charCodeAt(index))) return false; + hasDigits = true; + } + return hasDigits; + } - for (var i = start; i < end; i++) { - if (buf[i] <= 0x7F) { - res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i]); - tmp = ''; - } else { - tmp += '%' + buf[i].toString(16); - } - } + // base 10 (except 0) or base 60 - return res + decodeUtf8Char(tmp); - } + for (; index < max; index++) { + ch = data[index]; + if (ch === '_') continue; + if (ch === ':') break; + if (!isDecCode(data.charCodeAt(index))) { + return false; + } + hasDigits = true; + } - function asciiSlice(buf, start, end) { - var ret = ''; + if (!hasDigits) return false; - end = Math.min(buf.length, end); + // if !base60 - done; + if (ch !== ':') return true; - for (var i = start; i < end; i++) { - ret += String.fromCharCode(buf[i] & 0x7F); - } + // base60 almost not used, no needs to optimize + return /^(:[0-5]?[0-9])+$/.test(data.slice(index)); +} - return ret; - } +function constructYamlInteger(data) { + var value = data, sign = 1, ch, base, digits = []; - function binarySlice(buf, start, end) { - var ret = ''; + if (value.indexOf('_') !== -1) { + value = value.replace(/_/g, ''); + } - end = Math.min(buf.length, end); + ch = value[0]; - for (var i = start; i < end; i++) { - ret += String.fromCharCode(buf[i]); - } + if (ch === '-' || ch === '+') { + if (ch === '-') sign = -1; + value = value.slice(1); + ch = value[0]; + } - return ret; - } + if (value === '0') return 0; - function hexSlice(buf, start, end) { - var len = buf.length; + if (ch === '0') { + if (value[1] === 'b') return sign * parseInt(value.slice(2), 2); + if (value[1] === 'x') return sign * parseInt(value, 16); + return sign * parseInt(value, 8); + } - if (!start || start < 0) start = 0; + if (value.indexOf(':') !== -1) { + value.split(':').forEach(function (v) { + digits.unshift(parseInt(v, 10)); + }); - if (!end || end < 0 || end > len) end = len; + value = 0; + base = 1; - var out = ''; + digits.forEach(function (d) { + value += (d * base); + base *= 60; + }); - for (var i = start; i < end; i++) { - out += toHex(buf[i]); - } + return sign * value; + + } + + return sign * parseInt(value, 10); +} + +function isInteger(object) { + return (Object.prototype.toString.call(object)) === '[object Number]' && + (object % 1 === 0 && !common.isNegativeZero(object)); +} + +module.exports = new Type('tag:yaml.org,2002:int', { + kind: 'scalar', + resolve: resolveYamlInteger, + construct: constructYamlInteger, + predicate: isInteger, + represent: { + binary: function (object) { return '0b' + object.toString(2); }, + octal: function (object) { return '0' + object.toString(8); }, + decimal: function (object) { return object.toString(10); }, + hexadecimal: function (object) { return '0x' + object.toString(16).toUpperCase(); } + }, + defaultStyle: 'decimal', + styleAliases: { + binary: [ 2, 'bin' ], + octal: [ 8, 'oct' ], + decimal: [ 10, 'dec' ], + hexadecimal: [ 16, 'hex' ] + } +}); + +},{"../common":21,"../type":32}],37:[function(require,module,exports){ +'use strict'; + +var esprima; + +// Browserified version does not have esprima +// +// 1. For node.js just require module as deps +// 2. For browser try to require mudule via external AMD system. +// If not found - try to fallback to window.esprima. If not +// found too - then fail to parse. +// +try { + // workaround to exclude package from browserify list. + var _require = require; + esprima = _require('esprima'); +} catch (_) { + /*global window */ + if (typeof window !== 'undefined') esprima = window.esprima; +} + +var Type = require('../../type'); + +function resolveJavascriptFunction(data) { + if (data === null) return false; + + try { + var source = '(' + data + ')', + ast = esprima.parse(source, { range: true }); + + if (ast.type !== 'Program' || + ast.body.length !== 1 || + ast.body[0].type !== 'ExpressionStatement' || + ast.body[0].expression.type !== 'FunctionExpression') { + return false; + } - return out; - } + return true; + } catch (err) { + return false; + } +} + +function constructJavascriptFunction(data) { + /*jslint evil:true*/ + + var source = '(' + data + ')', + ast = esprima.parse(source, { range: true }), + params = [], + body; + + if (ast.type !== 'Program' || + ast.body.length !== 1 || + ast.body[0].type !== 'ExpressionStatement' || + ast.body[0].expression.type !== 'FunctionExpression') { + throw new Error('Failed to resolve function'); + } + + ast.body[0].expression.params.forEach(function (param) { + params.push(param.name); + }); + + body = ast.body[0].expression.body.range; + + // Esprima's ranges include the first '{' and the last '}' characters on + // function expressions. So cut them out. + /*eslint-disable no-new-func*/ + return new Function(params, source.slice(body[0] + 1, body[1] - 1)); +} + +function representJavascriptFunction(object /*, style*/) { + return object.toString(); +} + +function isFunction(object) { + return Object.prototype.toString.call(object) === '[object Function]'; +} + +module.exports = new Type('tag:yaml.org,2002:js/function', { + kind: 'scalar', + resolve: resolveJavascriptFunction, + construct: constructJavascriptFunction, + predicate: isFunction, + represent: representJavascriptFunction +}); + +},{"../../type":32}],38:[function(require,module,exports){ +'use strict'; + +var Type = require('../../type'); + +function resolveJavascriptRegExp(data) { + if (data === null) return false; + if (data.length === 0) return false; + + var regexp = data, + tail = /\/([gim]*)$/.exec(data), + modifiers = ''; + + // if regexp starts with '/' it can have modifiers and must be properly closed + // `/foo/gim` - modifiers tail can be maximum 3 chars + if (regexp[0] === '/') { + if (tail) modifiers = tail[1]; + + if (modifiers.length > 3) return false; + // if expression starts with /, is should be properly terminated + if (regexp[regexp.length - modifiers.length - 1] !== '/') return false; + } + + return true; +} - function utf16leSlice(buf, start, end) { - var bytes = buf.slice(start, end); - var res = ''; +function constructJavascriptRegExp(data) { + var regexp = data, + tail = /\/([gim]*)$/.exec(data), + modifiers = ''; - for (var i = 0; i < bytes.length; i += 2) { - res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256); - } + // `/foo/gim` - tail can be maximum 4 chars + if (regexp[0] === '/') { + if (tail) modifiers = tail[1]; + regexp = regexp.slice(1, regexp.length - modifiers.length - 1); + } - return res; - } + return new RegExp(regexp, modifiers); +} - Buffer.prototype.slice = function slice(start, end) { - var len = this.length; +function representJavascriptRegExp(object /*, style*/) { + var result = '/' + object.source + '/'; + + if (object.global) result += 'g'; + if (object.multiline) result += 'm'; + if (object.ignoreCase) result += 'i'; + + return result; +} + +function isRegExp(object) { + return Object.prototype.toString.call(object) === '[object RegExp]'; +} + +module.exports = new Type('tag:yaml.org,2002:js/regexp', { + kind: 'scalar', + resolve: resolveJavascriptRegExp, + construct: constructJavascriptRegExp, + predicate: isRegExp, + represent: representJavascriptRegExp +}); + +},{"../../type":32}],39:[function(require,module,exports){ +'use strict'; + +var Type = require('../../type'); + +function resolveJavascriptUndefined() { + return true; +} - start = ~~start; - end = end === undefined ? len : ~~end; +function constructJavascriptUndefined() { + /*eslint-disable no-undefined*/ + return undefined; +} - if (start < 0) { - start += len; +function representJavascriptUndefined() { + return ''; +} + +function isUndefined(object) { + return typeof object === 'undefined'; +} - if (start < 0) start = 0; - } else if (start > len) { - start = len; - } +module.exports = new Type('tag:yaml.org,2002:js/undefined', { + kind: 'scalar', + resolve: resolveJavascriptUndefined, + construct: constructJavascriptUndefined, + predicate: isUndefined, + represent: representJavascriptUndefined +}); - if (end < 0) { - end += len; +},{"../../type":32}],40:[function(require,module,exports){ +'use strict'; - if (end < 0) end = 0; - } else if (end > len) { - end = len; - } +var Type = require('../type'); - if (end < start) end = start; +module.exports = new Type('tag:yaml.org,2002:map', { + kind: 'mapping', + construct: function (data) { return data !== null ? data : {}; } +}); - var newBuf; +},{"../type":32}],41:[function(require,module,exports){ +'use strict'; - if (Buffer.TYPED_ARRAY_SUPPORT) { - newBuf = Buffer._augment(this.subarray(start, end)); - } else { - var sliceLen = end - start; +var Type = require('../type'); - newBuf = new Buffer(sliceLen, undefined); +function resolveYamlMerge(data) { + return data === '<<' || data === null; +} - for (var i = 0; i < sliceLen; i++) { - newBuf[i] = this[i + start]; - } - } +module.exports = new Type('tag:yaml.org,2002:merge', { + kind: 'scalar', + resolve: resolveYamlMerge +}); - if (newBuf.length) newBuf.parent = this.parent || this; +},{"../type":32}],42:[function(require,module,exports){ +'use strict'; - return newBuf; - }; +var Type = require('../type'); - /* - * Need to make sure that buffer isn't trying to write out of bounds. - */ - function checkOffset(offset, ext, length) { - if (offset % 1 !== 0 || offset < 0) throw new RangeError('offset is not uint'); +function resolveYamlNull(data) { + if (data === null) return true; - if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length'); - } + var max = data.length; - Buffer.prototype.readUIntLE = function readUIntLE(offset, byteLength, noAssert) { - offset |= 0; - byteLength |= 0; + return (max === 1 && data === '~') || + (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL')); +} - if (!noAssert) checkOffset(offset, byteLength, this.length); +function constructYamlNull() { + return null; +} - var val = this[offset]; - var mul = 1; - var i = 0; +function isNull(object) { + return object === null; +} - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul; - } +module.exports = new Type('tag:yaml.org,2002:null', { + kind: 'scalar', + resolve: resolveYamlNull, + construct: constructYamlNull, + predicate: isNull, + represent: { + canonical: function () { return '~'; }, + lowercase: function () { return 'null'; }, + uppercase: function () { return 'NULL'; }, + camelcase: function () { return 'Null'; } + }, + defaultStyle: 'lowercase' +}); - return val; - }; +},{"../type":32}],43:[function(require,module,exports){ +'use strict'; - Buffer.prototype.readUIntBE = function readUIntBE(offset, byteLength, noAssert) { - offset |= 0; - byteLength |= 0; +var Type = require('../type'); - if (!noAssert) { - checkOffset(offset, byteLength, this.length); - } +var _hasOwnProperty = Object.prototype.hasOwnProperty; +var _toString = Object.prototype.toString; - var val = this[offset + --byteLength]; - var mul = 1; +function resolveYamlOmap(data) { + if (data === null) return true; - while (byteLength > 0 && (mul *= 0x100)) { - val += this[offset + --byteLength] * mul; - } + var objectKeys = [], index, length, pair, pairKey, pairHasKey, + object = data; - return val; - }; + for (index = 0, length = object.length; index < length; index += 1) { + pair = object[index]; + pairHasKey = false; - Buffer.prototype.readUInt8 = function readUInt8(offset, noAssert) { - if (!noAssert) checkOffset(offset, 1, this.length); + if (_toString.call(pair) !== '[object Object]') return false; - return this[offset]; - }; + for (pairKey in pair) { + if (_hasOwnProperty.call(pair, pairKey)) { + if (!pairHasKey) pairHasKey = true; + else return false; + } + } - Buffer.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) { - if (!noAssert) checkOffset(offset, 2, this.length); + if (!pairHasKey) return false; - return this[offset] | this[offset + 1] << 8; - }; + if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey); + else return false; + } - Buffer.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) { - if (!noAssert) checkOffset(offset, 2, this.length); + return true; +} - return this[offset] << 8 | this[offset + 1]; - }; +function constructYamlOmap(data) { + return data !== null ? data : []; +} - Buffer.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length); +module.exports = new Type('tag:yaml.org,2002:omap', { + kind: 'sequence', + resolve: resolveYamlOmap, + construct: constructYamlOmap +}); - return (this[offset] | - this[offset + 1] << 8 | - this[offset + 2] << 16) + - this[offset + 3] * 0x1000000; - }; +},{"../type":32}],44:[function(require,module,exports){ +'use strict'; - Buffer.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length); +var Type = require('../type'); - return this[offset] * 0x1000000 + - (this[offset + 1] << 16 | - this[offset + 2] << 8 | - this[offset + 3]); - }; +var _toString = Object.prototype.toString; - Buffer.prototype.readIntLE = function readIntLE(offset, byteLength, noAssert) { - offset |= 0; - byteLength |= 0; +function resolveYamlPairs(data) { + if (data === null) return true; - if (!noAssert) checkOffset(offset, byteLength, this.length); + var index, length, pair, keys, result, + object = data; - var val = this[offset]; - var mul = 1; - var i = 0; + result = new Array(object.length); - while (++i < byteLength && (mul *= 0x100)) { - val += this[offset + i] * mul; - } - mul *= 0x80; + for (index = 0, length = object.length; index < length; index += 1) { + pair = object[index]; - if (val >= mul) val -= Math.pow(2, 8 * byteLength); + if (_toString.call(pair) !== '[object Object]') return false; - return val; - }; + keys = Object.keys(pair); - Buffer.prototype.readIntBE = function readIntBE(offset, byteLength, noAssert) { - offset |= 0; - byteLength |= 0; + if (keys.length !== 1) return false; - if (!noAssert) checkOffset(offset, byteLength, this.length); + result[index] = [ keys[0], pair[keys[0]] ]; + } - var i = byteLength; - var mul = 1; - var val = this[offset + --i]; + return true; +} - while (i > 0 && (mul *= 0x100)) { - val += this[offset + --i] * mul; - } - mul *= 0x80; +function constructYamlPairs(data) { + if (data === null) return []; - if (val >= mul) val -= Math.pow(2, 8 * byteLength); + var index, length, pair, keys, result, + object = data; - return val; - }; + result = new Array(object.length); - Buffer.prototype.readInt8 = function readInt8(offset, noAssert) { - if (!noAssert) checkOffset(offset, 1, this.length); + for (index = 0, length = object.length; index < length; index += 1) { + pair = object[index]; - if (!(this[offset] & 0x80)) return this[offset]; + keys = Object.keys(pair); - return (0xff - this[offset] + 1) * -1; - }; + result[index] = [ keys[0], pair[keys[0]] ]; + } - Buffer.prototype.readInt16LE = function readInt16LE(offset, noAssert) { - if (!noAssert) checkOffset(offset, 2, this.length); - var val = this[offset] | this[offset + 1] << 8; + return result; +} - return val & 0x8000 ? val | 0xFFFF0000 : val; - }; +module.exports = new Type('tag:yaml.org,2002:pairs', { + kind: 'sequence', + resolve: resolveYamlPairs, + construct: constructYamlPairs +}); - Buffer.prototype.readInt16BE = function readInt16BE(offset, noAssert) { - if (!noAssert) checkOffset(offset, 2, this.length); - var val = this[offset + 1] | this[offset] << 8; +},{"../type":32}],45:[function(require,module,exports){ +'use strict'; - return val & 0x8000 ? val | 0xFFFF0000 : val; - }; +var Type = require('../type'); - Buffer.prototype.readInt32LE = function readInt32LE(offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length); +module.exports = new Type('tag:yaml.org,2002:seq', { + kind: 'sequence', + construct: function (data) { return data !== null ? data : []; } +}); - return this[offset] | - this[offset + 1] << 8 | - this[offset + 2] << 16 | - this[offset + 3] << 24; - }; +},{"../type":32}],46:[function(require,module,exports){ +'use strict'; - Buffer.prototype.readInt32BE = function readInt32BE(offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length); +var Type = require('../type'); - return this[offset] << 24 | - this[offset + 1] << 16 | - this[offset + 2] << 8 | - this[offset + 3]; - }; +var _hasOwnProperty = Object.prototype.hasOwnProperty; - Buffer.prototype.readFloatLE = function readFloatLE(offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length); +function resolveYamlSet(data) { + if (data === null) return true; - return ieee754.read(this, offset, true, 23, 4); - }; + var key, object = data; - Buffer.prototype.readFloatBE = function readFloatBE(offset, noAssert) { - if (!noAssert) checkOffset(offset, 4, this.length); + for (key in object) { + if (_hasOwnProperty.call(object, key)) { + if (object[key] !== null) return false; + } + } - return ieee754.read(this, offset, false, 23, 4); - }; + return true; +} - Buffer.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) { - if (!noAssert) checkOffset(offset, 8, this.length); +function constructYamlSet(data) { + return data !== null ? data : {}; +} - return ieee754.read(this, offset, true, 52, 8); - }; +module.exports = new Type('tag:yaml.org,2002:set', { + kind: 'mapping', + resolve: resolveYamlSet, + construct: constructYamlSet +}); - Buffer.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) { - if (!noAssert) checkOffset(offset, 8, this.length); +},{"../type":32}],47:[function(require,module,exports){ +'use strict'; - return ieee754.read(this, offset, false, 52, 8); - }; +var Type = require('../type'); - function checkInt(buf, value, offset, ext, max, min) { - if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance'); +module.exports = new Type('tag:yaml.org,2002:str', { + kind: 'scalar', + construct: function (data) { return data !== null ? data : ''; } +}); - if (value > max || value < min) throw new RangeError('value is out of bounds'); +},{"../type":32}],48:[function(require,module,exports){ +'use strict'; - if (offset + ext > buf.length) throw new RangeError('index out of range'); - } +var Type = require('../type'); - Buffer.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength, noAssert) { - value = +value; - offset |= 0; - byteLength |= 0; +var YAML_DATE_REGEXP = new RegExp( + '^([0-9][0-9][0-9][0-9])' + // [1] year + '-([0-9][0-9])' + // [2] month + '-([0-9][0-9])$'); // [3] day - if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0); +var YAML_TIMESTAMP_REGEXP = new RegExp( + '^([0-9][0-9][0-9][0-9])' + // [1] year + '-([0-9][0-9]?)' + // [2] month + '-([0-9][0-9]?)' + // [3] day + '(?:[Tt]|[ \\t]+)' + // ... + '([0-9][0-9]?)' + // [4] hour + ':([0-9][0-9])' + // [5] minute + ':([0-9][0-9])' + // [6] second + '(?:\\.([0-9]*))?' + // [7] fraction + '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour + '(?::([0-9][0-9]))?))?$'); // [11] tz_minute - var mul = 1; - var i = 0; +function resolveYamlTimestamp(data) { + if (data === null) return false; + if (YAML_DATE_REGEXP.exec(data) !== null) return true; + if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true; + return false; +} - this[offset] = value & 0xFF; +function constructYamlTimestamp(data) { + var match, year, month, day, hour, minute, second, fraction = 0, + delta = null, tz_hour, tz_minute, date; - while (++i < byteLength && (mul *= 0x100)) { - this[offset + i] = value / mul & 0xFF; - } + match = YAML_DATE_REGEXP.exec(data); + if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data); - return offset + byteLength; - }; + if (match === null) throw new Error('Date resolve error'); - Buffer.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength, noAssert) { - value = +value; - offset |= 0; - byteLength |= 0; + // match: [1] year [2] month [3] day - if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0); + year = +(match[1]); + month = +(match[2]) - 1; // JS month starts with 0 + day = +(match[3]); - var i = byteLength - 1; - var mul = 1; + if (!match[4]) { // no hour + return new Date(Date.UTC(year, month, day)); + } - this[offset + i] = value & 0xFF; + // match: [4] hour [5] minute [6] second [7] fraction - while (--i >= 0 && (mul *= 0x100)) { - this[offset + i] = value / mul & 0xFF; - } + hour = +(match[4]); + minute = +(match[5]); + second = +(match[6]); - return offset + byteLength; - }; + if (match[7]) { + fraction = match[7].slice(0, 3); + while (fraction.length < 3) { // milli-seconds + fraction += '0'; + } + fraction = +fraction; + } - Buffer.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) { - value = +value; - offset |= 0; + // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute - if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0); + if (match[9]) { + tz_hour = +(match[10]); + tz_minute = +(match[11] || 0); + delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds + if (match[9] === '-') delta = -delta; + } - if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value); - this[offset] = value; + date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction)); - return offset + 1; - }; + if (delta) date.setTime(date.getTime() - delta); - function objectWriteUInt16(buf, value, offset, littleEndian) { - if (value < 0) value = 0xffff + value + 1; + return date; +} - for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) { - buf[offset + i] = (value & 0xff << 8 * (littleEndian ? i : 1 - i)) >>> - (littleEndian ? i : 1 - i) * 8; - } - } +function representYamlTimestamp(object /*, style*/) { + return object.toISOString(); +} - Buffer.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) { - value = +value; - offset |= 0; +module.exports = new Type('tag:yaml.org,2002:timestamp', { + kind: 'scalar', + resolve: resolveYamlTimestamp, + construct: constructYamlTimestamp, + instanceOf: Date, + represent: representYamlTimestamp +}); - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0); +},{"../type":32}],49:[function(require,module,exports){ +var baseIndexOf = require('../internal/baseIndexOf'), + binaryIndex = require('../internal/binaryIndex'); - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = value; - this[offset + 1] = value >>> 8; - } else { - objectWriteUInt16(this, value, offset, true); - } +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeMax = Math.max; - return offset + 2; - }; +/** + * Gets the index at which the first occurrence of `value` is found in `array` + * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * for equality comparisons. If `fromIndex` is negative, it's used as the offset + * from the end of `array`. If `array` is sorted providing `true` for `fromIndex` + * performs a faster binary search. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to search. + * @param {*} value The value to search for. + * @param {boolean|number} [fromIndex=0] The index to search from or `true` + * to perform a binary search on a sorted array. + * @returns {number} Returns the index of the matched value, else `-1`. + * @example + * + * _.indexOf([1, 2, 1, 2], 2); + * // => 1 + * + * // using `fromIndex` + * _.indexOf([1, 2, 1, 2], 2, 2); + * // => 3 + * + * // performing a binary search + * _.indexOf([1, 1, 2, 2], 2, true); + * // => 2 + */ +function indexOf(array, value, fromIndex) { + var length = array ? array.length : 0; + if (!length) { + return -1; + } + if (typeof fromIndex == 'number') { + fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex; + } else if (fromIndex) { + var index = binaryIndex(array, value); + if (index < length && + (value === value ? (value === array[index]) : (array[index] !== array[index]))) { + return index; + } + return -1; + } + return baseIndexOf(array, value, fromIndex || 0); +} - Buffer.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) { - value = +value; - offset |= 0; +module.exports = indexOf; - if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0); +},{"../internal/baseIndexOf":78,"../internal/binaryIndex":92}],50:[function(require,module,exports){ +/** + * Gets the last element of `array`. + * + * @static + * @memberOf _ + * @category Array + * @param {Array} array The array to query. + * @returns {*} Returns the last element of `array`. + * @example + * + * _.last([1, 2, 3]); + * // => 3 + */ +function last(array) { + var length = array ? array.length : 0; + return length ? array[length - 1] : undefined; +} - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = value >>> 8; - this[offset + 1] = value; - } else { - objectWriteUInt16(this, value, offset, false); - } +module.exports = last; - return offset + 2; - }; +},{}],51:[function(require,module,exports){ +var LazyWrapper = require('../internal/LazyWrapper'), + LodashWrapper = require('../internal/LodashWrapper'), + baseLodash = require('../internal/baseLodash'), + isArray = require('../lang/isArray'), + isObjectLike = require('../internal/isObjectLike'), + wrapperClone = require('../internal/wrapperClone'); - function objectWriteUInt32(buf, value, offset, littleEndian) { - if (value < 0) value = 0xffffffff + value + 1; +/** Used for native method references. */ +var objectProto = Object.prototype; - for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) { - buf[offset + i] = value >>> (littleEndian ? i : 3 - i) * 8 & 0xff; - } - } +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; - Buffer.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) { - value = +value; - offset |= 0; +/** + * Creates a `lodash` object which wraps `value` to enable implicit chaining. + * Methods that operate on and return arrays, collections, and functions can + * be chained together. Methods that retrieve a single value or may return a + * primitive value will automatically end the chain returning the unwrapped + * value. Explicit chaining may be enabled using `_.chain`. The execution of + * chained methods is lazy, that is, execution is deferred until `_#value` + * is implicitly or explicitly called. + * + * Lazy evaluation allows several methods to support shortcut fusion. Shortcut + * fusion is an optimization strategy which merge iteratee calls; this can help + * to avoid the creation of intermediate data structures and greatly reduce the + * number of iteratee executions. + * + * Chaining is supported in custom builds as long as the `_#value` method is + * directly or indirectly included in the build. + * + * In addition to lodash methods, wrappers have `Array` and `String` methods. + * + * The wrapper `Array` methods are: + * `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, + * `splice`, and `unshift` + * + * The wrapper `String` methods are: + * `replace` and `split` + * + * The wrapper methods that support shortcut fusion are: + * `compact`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `filter`, + * `first`, `initial`, `last`, `map`, `pluck`, `reject`, `rest`, `reverse`, + * `slice`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `toArray`, + * and `where` + * + * The chainable wrapper methods are: + * `after`, `ary`, `assign`, `at`, `before`, `bind`, `bindAll`, `bindKey`, + * `callback`, `chain`, `chunk`, `commit`, `compact`, `concat`, `constant`, + * `countBy`, `create`, `curry`, `debounce`, `defaults`, `defaultsDeep`, + * `defer`, `delay`, `difference`, `drop`, `dropRight`, `dropRightWhile`, + * `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flow`, `flowRight`, + * `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, + * `functions`, `groupBy`, `indexBy`, `initial`, `intersection`, `invert`, + * `invoke`, `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, + * `matchesProperty`, `memoize`, `merge`, `method`, `methodOf`, `mixin`, + * `modArgs`, `negate`, `omit`, `once`, `pairs`, `partial`, `partialRight`, + * `partition`, `pick`, `plant`, `pluck`, `property`, `propertyOf`, `pull`, + * `pullAt`, `push`, `range`, `rearg`, `reject`, `remove`, `rest`, `restParam`, + * `reverse`, `set`, `shuffle`, `slice`, `sort`, `sortBy`, `sortByAll`, + * `sortByOrder`, `splice`, `spread`, `take`, `takeRight`, `takeRightWhile`, + * `takeWhile`, `tap`, `throttle`, `thru`, `times`, `toArray`, `toPlainObject`, + * `transform`, `union`, `uniq`, `unshift`, `unzip`, `unzipWith`, `values`, + * `valuesIn`, `where`, `without`, `wrap`, `xor`, `zip`, `zipObject`, `zipWith` + * + * The wrapper methods that are **not** chainable by default are: + * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clone`, `cloneDeep`, + * `deburr`, `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, + * `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, + * `floor`, `get`, `gt`, `gte`, `has`, `identity`, `includes`, `indexOf`, + * `inRange`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, + * `isEmpty`, `isEqual`, `isError`, `isFinite` `isFunction`, `isMatch`, + * `isNative`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`, + * `isRegExp`, `isString`, `isUndefined`, `isTypedArray`, `join`, `kebabCase`, + * `last`, `lastIndexOf`, `lt`, `lte`, `max`, `min`, `noConflict`, `noop`, + * `now`, `pad`, `padLeft`, `padRight`, `parseInt`, `pop`, `random`, `reduce`, + * `reduceRight`, `repeat`, `result`, `round`, `runInContext`, `shift`, `size`, + * `snakeCase`, `some`, `sortedIndex`, `sortedLastIndex`, `startCase`, + * `startsWith`, `sum`, `template`, `trim`, `trimLeft`, `trimRight`, `trunc`, + * `unescape`, `uniqueId`, `value`, and `words` + * + * The wrapper method `sample` will return a wrapped value when `n` is provided, + * otherwise an unwrapped value is returned. + * + * @name _ + * @constructor + * @category Chain + * @param {*} value The value to wrap in a `lodash` instance. + * @returns {Object} Returns the new `lodash` wrapper instance. + * @example + * + * var wrapped = _([1, 2, 3]); + * + * // returns an unwrapped value + * wrapped.reduce(function(total, n) { + * return total + n; + * }); + * // => 6 + * + * // returns a wrapped value + * var squares = wrapped.map(function(n) { + * return n * n; + * }); + * + * _.isArray(squares); + * // => false + * + * _.isArray(squares.value()); + * // => true + */ +function lodash(value) { + if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) { + if (value instanceof LodashWrapper) { + return value; + } + if (hasOwnProperty.call(value, '__chain__') && hasOwnProperty.call(value, '__wrapped__')) { + return wrapperClone(value); + } + } + return new LodashWrapper(value); +} - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0); +// Ensure wrappers are instances of `baseLodash`. +lodash.prototype = baseLodash.prototype; - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset + 3] = value >>> 24; - this[offset + 2] = value >>> 16; - this[offset + 1] = value >>> 8; - this[offset] = value; - } else { - objectWriteUInt32(this, value, offset, true); - } +module.exports = lodash; - return offset + 4; - }; +},{"../internal/LazyWrapper":60,"../internal/LodashWrapper":61,"../internal/baseLodash":82,"../internal/isObjectLike":126,"../internal/wrapperClone":137,"../lang/isArray":140}],52:[function(require,module,exports){ +module.exports = require('./forEach'); - Buffer.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) { - value = +value; - offset |= 0; +},{"./forEach":54}],53:[function(require,module,exports){ +var baseEach = require('../internal/baseEach'), + createFind = require('../internal/createFind'); - if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0); +/** + * Iterates over elements of `collection`, returning the first element + * `predicate` returns truthy for. The predicate is bound to `thisArg` and + * invoked with three arguments: (value, index|key, collection). + * + * If a property name is provided for `predicate` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @alias detect + * @category Collection + * @param {Array|Object|string} collection The collection to search. + * @param {Function|Object|string} [predicate=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `predicate`. + * @returns {*} Returns the matched element, else `undefined`. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36, 'active': true }, + * { 'user': 'fred', 'age': 40, 'active': false }, + * { 'user': 'pebbles', 'age': 1, 'active': true } + * ]; + * + * _.result(_.find(users, function(chr) { + * return chr.age < 40; + * }), 'user'); + * // => 'barney' + * + * // using the `_.matches` callback shorthand + * _.result(_.find(users, { 'age': 1, 'active': true }), 'user'); + * // => 'pebbles' + * + * // using the `_.matchesProperty` callback shorthand + * _.result(_.find(users, 'active', false), 'user'); + * // => 'fred' + * + * // using the `_.property` callback shorthand + * _.result(_.find(users, 'active'), 'user'); + * // => 'barney' + */ +var find = createFind(baseEach); - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = value >>> 24; - this[offset + 1] = value >>> 16; - this[offset + 2] = value >>> 8; - this[offset + 3] = value; - } else { - objectWriteUInt32(this, value, offset, false); - } +module.exports = find; - return offset + 4; - }; +},{"../internal/baseEach":71,"../internal/createFind":102}],54:[function(require,module,exports){ +var arrayEach = require('../internal/arrayEach'), + baseEach = require('../internal/baseEach'), + createForEach = require('../internal/createForEach'); - Buffer.prototype.writeIntLE = function writeIntLE(value, offset, byteLength, noAssert) { - value = +value; - offset |= 0; +/** + * Iterates over elements of `collection` invoking `iteratee` for each element. + * The `iteratee` is bound to `thisArg` and invoked with three arguments: + * (value, index|key, collection). Iteratee functions may exit iteration early + * by explicitly returning `false`. + * + * **Note:** As with other "Collections" methods, objects with a "length" property + * are iterated like arrays. To avoid this behavior `_.forIn` or `_.forOwn` + * may be used for object iteration. + * + * @static + * @memberOf _ + * @alias each + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {Array|Object|string} Returns `collection`. + * @example + * + * _([1, 2]).forEach(function(n) { + * console.log(n); + * }).value(); + * // => logs each value from left to right and returns the array + * + * _.forEach({ 'a': 1, 'b': 2 }, function(n, key) { + * console.log(n, key); + * }); + * // => logs each value-key pair and returns the object (iteration order is not guaranteed) + */ +var forEach = createForEach(arrayEach, baseEach); - if (!noAssert) { - var limit = Math.pow(2, 8 * byteLength - 1); +module.exports = forEach; - checkInt(this, value, offset, byteLength, limit - 1, -limit); - } +},{"../internal/arrayEach":63,"../internal/baseEach":71,"../internal/createForEach":103}],55:[function(require,module,exports){ +var baseIndexOf = require('../internal/baseIndexOf'), + getLength = require('../internal/getLength'), + isArray = require('../lang/isArray'), + isIterateeCall = require('../internal/isIterateeCall'), + isLength = require('../internal/isLength'), + isString = require('../lang/isString'), + values = require('../object/values'); - var i = 0; - var mul = 1; - var sub = value < 0 ? 1 : 0; +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeMax = Math.max; - this[offset] = value & 0xFF; +/** + * Checks if `target` is in `collection` using + * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * for equality comparisons. If `fromIndex` is negative, it's used as the offset + * from the end of `collection`. + * + * @static + * @memberOf _ + * @alias contains, include + * @category Collection + * @param {Array|Object|string} collection The collection to search. + * @param {*} target The value to search for. + * @param {number} [fromIndex=0] The index to search from. + * @param- {Object} [guard] Enables use as a callback for functions like `_.reduce`. + * @returns {boolean} Returns `true` if a matching element is found, else `false`. + * @example + * + * _.includes([1, 2, 3], 1); + * // => true + * + * _.includes([1, 2, 3], 1, 2); + * // => false + * + * _.includes({ 'user': 'fred', 'age': 40 }, 'fred'); + * // => true + * + * _.includes('pebbles', 'eb'); + * // => true + */ +function includes(collection, target, fromIndex, guard) { + var length = collection ? getLength(collection) : 0; + if (!isLength(length)) { + collection = values(collection); + length = collection.length; + } + if (typeof fromIndex != 'number' || (guard && isIterateeCall(target, fromIndex, guard))) { + fromIndex = 0; + } else { + fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0); + } + return (typeof collection == 'string' || !isArray(collection) && isString(collection)) + ? (fromIndex <= length && collection.indexOf(target, fromIndex) > -1) + : (!!length && baseIndexOf(collection, target, fromIndex) > -1); +} + +module.exports = includes; + +},{"../internal/baseIndexOf":78,"../internal/getLength":112,"../internal/isIterateeCall":122,"../internal/isLength":125,"../lang/isArray":140,"../lang/isString":146,"../object/values":152}],56:[function(require,module,exports){ +var arrayMap = require('../internal/arrayMap'), + baseCallback = require('../internal/baseCallback'), + baseMap = require('../internal/baseMap'), + isArray = require('../lang/isArray'); - while (++i < byteLength && (mul *= 0x100)) { - this[offset + i] = (value / mul >> 0) - sub & 0xFF; - } +/** + * Creates an array of values by running each element in `collection` through + * `iteratee`. The `iteratee` is bound to `thisArg` and invoked with three + * arguments: (value, index|key, collection). + * + * If a property name is provided for `iteratee` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `iteratee` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * Many lodash methods are guarded to work as iteratees for methods like + * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. + * + * The guarded methods are: + * `ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`, + * `drop`, `dropRight`, `every`, `fill`, `flatten`, `invert`, `max`, `min`, + * `parseInt`, `slice`, `sortBy`, `take`, `takeRight`, `template`, `trim`, + * `trimLeft`, `trimRight`, `trunc`, `random`, `range`, `sample`, `some`, + * `sum`, `uniq`, and `words` + * + * @static + * @memberOf _ + * @alias collect + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [iteratee=_.identity] The function invoked + * per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {Array} Returns the new mapped array. + * @example + * + * function timesThree(n) { + * return n * 3; + * } + * + * _.map([1, 2], timesThree); + * // => [3, 6] + * + * _.map({ 'a': 1, 'b': 2 }, timesThree); + * // => [3, 6] (iteration order is not guaranteed) + * + * var users = [ + * { 'user': 'barney' }, + * { 'user': 'fred' } + * ]; + * + * // using the `_.property` callback shorthand + * _.map(users, 'user'); + * // => ['barney', 'fred'] + */ +function map(collection, iteratee, thisArg) { + var func = isArray(collection) ? arrayMap : baseMap; + iteratee = baseCallback(iteratee, thisArg, 3); + return func(collection, iteratee); +} - return offset + byteLength; - }; +module.exports = map; - Buffer.prototype.writeIntBE = function writeIntBE(value, offset, byteLength, noAssert) { - value = +value; - offset |= 0; +},{"../internal/arrayMap":64,"../internal/baseCallback":67,"../internal/baseMap":83,"../lang/isArray":140}],57:[function(require,module,exports){ +var getNative = require('../internal/getNative'); - if (!noAssert) { - var limit = Math.pow(2, 8 * byteLength - 1); +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeNow = getNative(Date, 'now'); - checkInt(this, value, offset, byteLength, limit - 1, -limit); - } +/** + * Gets the number of milliseconds that have elapsed since the Unix epoch + * (1 January 1970 00:00:00 UTC). + * + * @static + * @memberOf _ + * @category Date + * @example + * + * _.defer(function(stamp) { + * console.log(_.now() - stamp); + * }, _.now()); + * // => logs the number of milliseconds it took for the deferred function to be invoked + */ +var now = nativeNow || function() { + return new Date().getTime(); +}; - var i = byteLength - 1; - var mul = 1; - var sub = value < 0 ? 1 : 0; +module.exports = now; - this[offset + i] = value & 0xFF; +},{"../internal/getNative":114}],58:[function(require,module,exports){ +var createWrapper = require('../internal/createWrapper'), + replaceHolders = require('../internal/replaceHolders'), + restParam = require('./restParam'); - while (--i >= 0 && (mul *= 0x100)) { - this[offset + i] = (value / mul >> 0) - sub & 0xFF; - } +/** Used to compose bitmasks for wrapper metadata. */ +var BIND_FLAG = 1, + PARTIAL_FLAG = 32; - return offset + byteLength; - }; +/** + * Creates a function that invokes `func` with the `this` binding of `thisArg` + * and prepends any additional `_.bind` arguments to those provided to the + * bound function. + * + * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds, + * may be used as a placeholder for partially applied arguments. + * + * **Note:** Unlike native `Function#bind` this method does not set the "length" + * property of bound functions. + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to bind. + * @param {*} thisArg The `this` binding of `func`. + * @param {...*} [partials] The arguments to be partially applied. + * @returns {Function} Returns the new bound function. + * @example + * + * var greet = function(greeting, punctuation) { + * return greeting + ' ' + this.user + punctuation; + * }; + * + * var object = { 'user': 'fred' }; + * + * var bound = _.bind(greet, object, 'hi'); + * bound('!'); + * // => 'hi fred!' + * + * // using placeholders + * var bound = _.bind(greet, object, _, '!'); + * bound('hi'); + * // => 'hi fred!' + */ +var bind = restParam(function(func, thisArg, partials) { + var bitmask = BIND_FLAG; + if (partials.length) { + var holders = replaceHolders(partials, bind.placeholder); + bitmask |= PARTIAL_FLAG; + } + return createWrapper(func, bitmask, thisArg, partials, holders); +}); - Buffer.prototype.writeInt8 = function writeInt8(value, offset, noAssert) { - value = +value; - offset |= 0; +// Assign default placeholders. +bind.placeholder = {}; - if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80); +module.exports = bind; - if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value); +},{"../internal/createWrapper":106,"../internal/replaceHolders":132,"./restParam":59}],59:[function(require,module,exports){ +/** Used as the `TypeError` message for "Functions" methods. */ +var FUNC_ERROR_TEXT = 'Expected a function'; - if (value < 0) value = 0xff + value + 1; - this[offset] = value; +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeMax = Math.max; - return offset + 1; - }; +/** + * Creates a function that invokes `func` with the `this` binding of the + * created function and arguments from `start` and beyond provided as an array. + * + * **Note:** This method is based on the [rest parameter](https://developer.mozilla.org/Web/JavaScript/Reference/Functions/rest_parameters). + * + * @static + * @memberOf _ + * @category Function + * @param {Function} func The function to apply a rest parameter to. + * @param {number} [start=func.length-1] The start position of the rest parameter. + * @returns {Function} Returns the new function. + * @example + * + * var say = _.restParam(function(what, names) { + * return what + ' ' + _.initial(names).join(', ') + + * (_.size(names) > 1 ? ', & ' : '') + _.last(names); + * }); + * + * say('hello', 'fred', 'barney', 'pebbles'); + * // => 'hello fred, barney, & pebbles' + */ +function restParam(func, start) { + if (typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + start = nativeMax(start === undefined ? (func.length - 1) : (+start || 0), 0); + return function() { + var args = arguments, + index = -1, + length = nativeMax(args.length - start, 0), + rest = Array(length); + + while (++index < length) { + rest[index] = args[start + index]; + } + switch (start) { + case 0: return func.call(this, rest); + case 1: return func.call(this, args[0], rest); + case 2: return func.call(this, args[0], args[1], rest); + } + var otherArgs = Array(start + 1); + index = -1; + while (++index < start) { + otherArgs[index] = args[index]; + } + otherArgs[start] = rest; + return func.apply(this, otherArgs); + }; +} - Buffer.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) { - value = +value; - offset |= 0; +module.exports = restParam; - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000); +},{}],60:[function(require,module,exports){ +var baseCreate = require('./baseCreate'), + baseLodash = require('./baseLodash'); - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = value; - this[offset + 1] = value >>> 8; - } else { - objectWriteUInt16(this, value, offset, true); - } +/** Used as references for `-Infinity` and `Infinity`. */ +var POSITIVE_INFINITY = Number.POSITIVE_INFINITY; - return offset + 2; - }; +/** + * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation. + * + * @private + * @param {*} value The value to wrap. + */ +function LazyWrapper(value) { + this.__wrapped__ = value; + this.__actions__ = []; + this.__dir__ = 1; + this.__filtered__ = false; + this.__iteratees__ = []; + this.__takeCount__ = POSITIVE_INFINITY; + this.__views__ = []; +} - Buffer.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) { - value = +value; - offset |= 0; +LazyWrapper.prototype = baseCreate(baseLodash.prototype); +LazyWrapper.prototype.constructor = LazyWrapper; - if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000); +module.exports = LazyWrapper; - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = value >>> 8; - this[offset + 1] = value; - } else { - objectWriteUInt16(this, value, offset, false); - } +},{"./baseCreate":70,"./baseLodash":82}],61:[function(require,module,exports){ +var baseCreate = require('./baseCreate'), + baseLodash = require('./baseLodash'); - return offset + 2; - }; +/** + * The base constructor for creating `lodash` wrapper objects. + * + * @private + * @param {*} value The value to wrap. + * @param {boolean} [chainAll] Enable chaining for all wrapper methods. + * @param {Array} [actions=[]] Actions to peform to resolve the unwrapped value. + */ +function LodashWrapper(value, chainAll, actions) { + this.__wrapped__ = value; + this.__actions__ = actions || []; + this.__chain__ = !!chainAll; +} - Buffer.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) { - value = +value; - offset |= 0; +LodashWrapper.prototype = baseCreate(baseLodash.prototype); +LodashWrapper.prototype.constructor = LodashWrapper; - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000); +module.exports = LodashWrapper; - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = value; - this[offset + 1] = value >>> 8; - this[offset + 2] = value >>> 16; - this[offset + 3] = value >>> 24; - } else { - objectWriteUInt32(this, value, offset, true); - } +},{"./baseCreate":70,"./baseLodash":82}],62:[function(require,module,exports){ +/** + * Copies the values of `source` to `array`. + * + * @private + * @param {Array} source The array to copy values from. + * @param {Array} [array=[]] The array to copy values to. + * @returns {Array} Returns `array`. + */ +function arrayCopy(source, array) { + var index = -1, + length = source.length; - return offset + 4; - }; + array || (array = Array(length)); + while (++index < length) { + array[index] = source[index]; + } + return array; +} - Buffer.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) { - value = +value; - offset |= 0; +module.exports = arrayCopy; - if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000); +},{}],63:[function(require,module,exports){ +/** + * A specialized version of `_.forEach` for arrays without support for callback + * shorthands and `this` binding. + * + * @private + * @param {Array} array The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns `array`. + */ +function arrayEach(array, iteratee) { + var index = -1, + length = array.length; - if (value < 0) value = 0xffffffff + value + 1; + while (++index < length) { + if (iteratee(array[index], index, array) === false) { + break; + } + } + return array; +} - if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = value >>> 24; - this[offset + 1] = value >>> 16; - this[offset + 2] = value >>> 8; - this[offset + 3] = value; - } else { - objectWriteUInt32(this, value, offset, false); - } +module.exports = arrayEach; - return offset + 4; - }; +},{}],64:[function(require,module,exports){ +/** + * A specialized version of `_.map` for arrays without support for callback + * shorthands and `this` binding. + * + * @private + * @param {Array} array The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the new mapped array. + */ +function arrayMap(array, iteratee) { + var index = -1, + length = array.length, + result = Array(length); - function checkIEEE754(buf, value, offset, ext, max, min) { - if (value > max || value < min) throw new RangeError('value is out of bounds'); + while (++index < length) { + result[index] = iteratee(array[index], index, array); + } + return result; +} - if (offset + ext > buf.length) throw new RangeError('index out of range'); +module.exports = arrayMap; - if (offset < 0) throw new RangeError('index out of range'); - } +},{}],65:[function(require,module,exports){ +/** + * A specialized version of `_.some` for arrays without support for callback + * shorthands and `this` binding. + * + * @private + * @param {Array} array The array to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if any element passes the predicate check, + * else `false`. + */ +function arraySome(array, predicate) { + var index = -1, + length = array.length; - function writeFloat(buf, value, offset, littleEndian, noAssert) { - if (!noAssert) { - checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38); - } - ieee754.write(buf, value, offset, littleEndian, 23, 4); + while (++index < length) { + if (predicate(array[index], index, array)) { + return true; + } + } + return false; +} - return offset + 4; - } +module.exports = arraySome; - Buffer.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) { - return writeFloat(this, value, offset, true, noAssert); - }; +},{}],66:[function(require,module,exports){ +var baseCopy = require('./baseCopy'), + keys = require('../object/keys'); - Buffer.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) { - return writeFloat(this, value, offset, false, noAssert); - }; +/** + * The base implementation of `_.assign` without support for argument juggling, + * multiple sources, and `customizer` functions. + * + * @private + * @param {Object} object The destination object. + * @param {Object} source The source object. + * @returns {Object} Returns `object`. + */ +function baseAssign(object, source) { + return source == null + ? object + : baseCopy(source, keys(source), object); +} - function writeDouble(buf, value, offset, littleEndian, noAssert) { - if (!noAssert) { - checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308); - } - ieee754.write(buf, value, offset, littleEndian, 52, 8); +module.exports = baseAssign; - return offset + 8; - } +},{"../object/keys":149,"./baseCopy":69}],67:[function(require,module,exports){ +var baseMatches = require('./baseMatches'), + baseMatchesProperty = require('./baseMatchesProperty'), + bindCallback = require('./bindCallback'), + identity = require('../utility/identity'), + property = require('../utility/property'); - Buffer.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) { - return writeDouble(this, value, offset, true, noAssert); - }; +/** + * The base implementation of `_.callback` which supports specifying the + * number of arguments to provide to `func`. + * + * @private + * @param {*} [func=_.identity] The value to convert to a callback. + * @param {*} [thisArg] The `this` binding of `func`. + * @param {number} [argCount] The number of arguments to provide to `func`. + * @returns {Function} Returns the callback. + */ +function baseCallback(func, thisArg, argCount) { + var type = typeof func; + if (type == 'function') { + return thisArg === undefined + ? func + : bindCallback(func, thisArg, argCount); + } + if (func == null) { + return identity; + } + if (type == 'object') { + return baseMatches(func); + } + return thisArg === undefined + ? property(func) + : baseMatchesProperty(func, thisArg); +} + +module.exports = baseCallback; + +},{"../utility/identity":154,"../utility/property":156,"./baseMatches":84,"./baseMatchesProperty":85,"./bindCallback":94}],68:[function(require,module,exports){ +var arrayCopy = require('./arrayCopy'), + arrayEach = require('./arrayEach'), + baseAssign = require('./baseAssign'), + baseForOwn = require('./baseForOwn'), + initCloneArray = require('./initCloneArray'), + initCloneByTag = require('./initCloneByTag'), + initCloneObject = require('./initCloneObject'), + isArray = require('../lang/isArray'), + isHostObject = require('./isHostObject'), + isObject = require('../lang/isObject'); + +/** `Object#toString` result references. */ +var argsTag = '[object Arguments]', + arrayTag = '[object Array]', + boolTag = '[object Boolean]', + dateTag = '[object Date]', + errorTag = '[object Error]', + funcTag = '[object Function]', + mapTag = '[object Map]', + numberTag = '[object Number]', + objectTag = '[object Object]', + regexpTag = '[object RegExp]', + setTag = '[object Set]', + stringTag = '[object String]', + weakMapTag = '[object WeakMap]'; + +var arrayBufferTag = '[object ArrayBuffer]', + float32Tag = '[object Float32Array]', + float64Tag = '[object Float64Array]', + int8Tag = '[object Int8Array]', + int16Tag = '[object Int16Array]', + int32Tag = '[object Int32Array]', + uint8Tag = '[object Uint8Array]', + uint8ClampedTag = '[object Uint8ClampedArray]', + uint16Tag = '[object Uint16Array]', + uint32Tag = '[object Uint32Array]'; + +/** Used to identify `toStringTag` values supported by `_.clone`. */ +var cloneableTags = {}; +cloneableTags[argsTag] = cloneableTags[arrayTag] = +cloneableTags[arrayBufferTag] = cloneableTags[boolTag] = +cloneableTags[dateTag] = cloneableTags[float32Tag] = +cloneableTags[float64Tag] = cloneableTags[int8Tag] = +cloneableTags[int16Tag] = cloneableTags[int32Tag] = +cloneableTags[numberTag] = cloneableTags[objectTag] = +cloneableTags[regexpTag] = cloneableTags[stringTag] = +cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = +cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; +cloneableTags[errorTag] = cloneableTags[funcTag] = +cloneableTags[mapTag] = cloneableTags[setTag] = +cloneableTags[weakMapTag] = false; + +/** Used for native method references. */ +var objectProto = Object.prototype; - Buffer.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) { - return writeDouble(this, value, offset, false, noAssert); - }; +/** + * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * of values. + */ +var objToString = objectProto.toString; - // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) - Buffer.prototype.copy = function copy(target, targetStart, start, end) { - if (!start) start = 0; +/** + * The base implementation of `_.clone` without support for argument juggling + * and `this` binding `customizer` functions. + * + * @private + * @param {*} value The value to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @param {Function} [customizer] The function to customize cloning values. + * @param {string} [key] The key of `value`. + * @param {Object} [object] The object `value` belongs to. + * @param {Array} [stackA=[]] Tracks traversed source objects. + * @param {Array} [stackB=[]] Associates clones with source counterparts. + * @returns {*} Returns the cloned value. + */ +function baseClone(value, isDeep, customizer, key, object, stackA, stackB) { + var result; + if (customizer) { + result = object ? customizer(value, key, object) : customizer(value); + } + if (result !== undefined) { + return result; + } + if (!isObject(value)) { + return value; + } + var isArr = isArray(value); + if (isArr) { + result = initCloneArray(value); + if (!isDeep) { + return arrayCopy(value, result); + } + } else { + var tag = objToString.call(value), + isFunc = tag == funcTag; + + if (tag == objectTag || tag == argsTag || (isFunc && !object)) { + if (isHostObject(value)) { + return object ? value : {}; + } + result = initCloneObject(isFunc ? {} : value); + if (!isDeep) { + return baseAssign(result, value); + } + } else { + return cloneableTags[tag] + ? initCloneByTag(value, tag, isDeep) + : (object ? value : {}); + } + } + // Check for circular references and return its corresponding clone. + stackA || (stackA = []); + stackB || (stackB = []); + + var length = stackA.length; + while (length--) { + if (stackA[length] == value) { + return stackB[length]; + } + } + // Add the source value to the stack of traversed objects and associate it with its clone. + stackA.push(value); + stackB.push(result); - if (!end && end !== 0) end = this.length; + // Recursively populate clone (susceptible to call stack limits). + (isArr ? arrayEach : baseForOwn)(value, function(subValue, key) { + result[key] = baseClone(subValue, isDeep, customizer, key, value, stackA, stackB); + }); + return result; +} - if (targetStart >= target.length) targetStart = target.length; +module.exports = baseClone; - if (!targetStart) targetStart = 0; +},{"../lang/isArray":140,"../lang/isObject":144,"./arrayCopy":62,"./arrayEach":63,"./baseAssign":66,"./baseForOwn":76,"./initCloneArray":116,"./initCloneByTag":117,"./initCloneObject":118,"./isHostObject":120}],69:[function(require,module,exports){ +/** + * Copies properties of `source` to `object`. + * + * @private + * @param {Object} source The object to copy properties from. + * @param {Array} props The property names to copy. + * @param {Object} [object={}] The object to copy properties to. + * @returns {Object} Returns `object`. + */ +function baseCopy(source, props, object) { + object || (object = {}); - if (end > 0 && end < start) end = start; + var index = -1, + length = props.length; - // Copy 0 bytes; we're done - if (end === start) return 0; + while (++index < length) { + var key = props[index]; + object[key] = source[key]; + } + return object; +} - if (target.length === 0 || this.length === 0) return 0; +module.exports = baseCopy; - // Fatal error conditions - if (targetStart < 0) { - throw new RangeError('targetStart out of bounds'); - } +},{}],70:[function(require,module,exports){ +var isObject = require('../lang/isObject'); - if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds'); +/** + * The base implementation of `_.create` without support for assigning + * properties to the created object. + * + * @private + * @param {Object} prototype The object to inherit from. + * @returns {Object} Returns the new object. + */ +var baseCreate = (function() { + function object() {} + return function(prototype) { + if (isObject(prototype)) { + object.prototype = prototype; + var result = new object; + object.prototype = undefined; + } + return result || {}; + }; +}()); - if (end < 0) throw new RangeError('sourceEnd out of bounds'); +module.exports = baseCreate; - // Are we oob? - if (end > this.length) end = this.length; +},{"../lang/isObject":144}],71:[function(require,module,exports){ +var baseForOwn = require('./baseForOwn'), + createBaseEach = require('./createBaseEach'); - if (target.length - targetStart < end - start) { - end = target.length - targetStart + start; - } +/** + * The base implementation of `_.forEach` without support for callback + * shorthands and `this` binding. + * + * @private + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array|Object|string} Returns `collection`. + */ +var baseEach = createBaseEach(baseForOwn); - var len = end - start; +module.exports = baseEach; - if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { - for (var i = 0; i < len; i++) { - target[i + targetStart] = this[i + start]; - } - } else { - target._set(this.subarray(start, start + len), targetStart); - } +},{"./baseForOwn":76,"./createBaseEach":98}],72:[function(require,module,exports){ +/** + * The base implementation of `_.find`, `_.findLast`, `_.findKey`, and `_.findLastKey`, + * without support for callback shorthands and `this` binding, which iterates + * over `collection` using the provided `eachFunc`. + * + * @private + * @param {Array|Object|string} collection The collection to search. + * @param {Function} predicate The function invoked per iteration. + * @param {Function} eachFunc The function to iterate over `collection`. + * @param {boolean} [retKey] Specify returning the key of the found element + * instead of the element itself. + * @returns {*} Returns the found element or its key, else `undefined`. + */ +function baseFind(collection, predicate, eachFunc, retKey) { + var result; + eachFunc(collection, function(value, key, collection) { + if (predicate(value, key, collection)) { + result = retKey ? key : value; + return false; + } + }); + return result; +} - return len; - }; +module.exports = baseFind; - // fill(value, start=0, end=buffer.length) - Buffer.prototype.fill = function fill(value, start, end) { - if (!value) value = 0; +},{}],73:[function(require,module,exports){ +/** + * The base implementation of `_.findIndex` and `_.findLastIndex` without + * support for callback shorthands and `this` binding. + * + * @private + * @param {Array} array The array to search. + * @param {Function} predicate The function invoked per iteration. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {number} Returns the index of the matched value, else `-1`. + */ +function baseFindIndex(array, predicate, fromRight) { + var length = array.length, + index = fromRight ? length : -1; - if (!start) start = 0; + while ((fromRight ? index-- : ++index < length)) { + if (predicate(array[index], index, array)) { + return index; + } + } + return -1; +} - if (!end) end = this.length; +module.exports = baseFindIndex; - if (end < start) throw new RangeError('end < start'); +},{}],74:[function(require,module,exports){ +var createBaseFor = require('./createBaseFor'); - // Fill 0 bytes; we're done - if (end === start) return; +/** + * The base implementation of `baseForIn` and `baseForOwn` which iterates + * over `object` properties returned by `keysFunc` invoking `iteratee` for + * each property. Iteratee functions may exit iteration early by explicitly + * returning `false`. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {Function} keysFunc The function to get the keys of `object`. + * @returns {Object} Returns `object`. + */ +var baseFor = createBaseFor(); - if (this.length === 0) return; +module.exports = baseFor; - if (start < 0 || start >= this.length) throw new RangeError('start out of bounds'); +},{"./createBaseFor":99}],75:[function(require,module,exports){ +var baseFor = require('./baseFor'), + keysIn = require('../object/keysIn'); - if (end < 0 || end > this.length) throw new RangeError('end out of bounds'); +/** + * The base implementation of `_.forIn` without support for callback + * shorthands and `this` binding. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Object} Returns `object`. + */ +function baseForIn(object, iteratee) { + return baseFor(object, iteratee, keysIn); +} - var i; +module.exports = baseForIn; - if (typeof value === 'number') { - for (i = start; i < end; i++) { - this[i] = value; - } - } else { - var bytes = utf8ToBytes(value.toString()); - var len = bytes.length; +},{"../object/keysIn":150,"./baseFor":74}],76:[function(require,module,exports){ +var baseFor = require('./baseFor'), + keys = require('../object/keys'); - for (i = start; i < end; i++) { - this[i] = bytes[i % len]; - } - } +/** + * The base implementation of `_.forOwn` without support for callback + * shorthands and `this` binding. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Object} Returns `object`. + */ +function baseForOwn(object, iteratee) { + return baseFor(object, iteratee, keys); +} - return this; - }; +module.exports = baseForOwn; - /** - * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance. - * Added in Node 0.12. Only available in browsers that support ArrayBuffer. - */ - Buffer.prototype.toArrayBuffer = function toArrayBuffer() { - if (typeof Uint8Array !== 'undefined') { - if (Buffer.TYPED_ARRAY_SUPPORT) { - return (new Buffer(this)).buffer; - } - var buf = new Uint8Array(this.length); +},{"../object/keys":149,"./baseFor":74}],77:[function(require,module,exports){ +var toObject = require('./toObject'); - for (var i = 0, len = buf.length; i < len; i += 1) { - buf[i] = this[i]; - } +/** + * The base implementation of `get` without support for string paths + * and default values. + * + * @private + * @param {Object} object The object to query. + * @param {Array} path The path of the property to get. + * @param {string} [pathKey] The key representation of path. + * @returns {*} Returns the resolved value. + */ +function baseGet(object, path, pathKey) { + if (object == null) { + return; + } + object = toObject(object); + if (pathKey !== undefined && pathKey in object) { + path = [pathKey]; + } + var index = 0, + length = path.length; + + while (object != null && index < length) { + object = toObject(object)[path[index++]]; + } + return (index && index == length) ? object : undefined; +} + +module.exports = baseGet; + +},{"./toObject":135}],78:[function(require,module,exports){ +var indexOfNaN = require('./indexOfNaN'); - return buf.buffer; +/** + * The base implementation of `_.indexOf` without support for binary searches. + * + * @private + * @param {Array} array The array to search. + * @param {*} value The value to search for. + * @param {number} fromIndex The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. + */ +function baseIndexOf(array, value, fromIndex) { + if (value !== value) { + return indexOfNaN(array, fromIndex); + } + var index = fromIndex - 1, + length = array.length; + + while (++index < length) { + if (array[index] === value) { + return index; + } + } + return -1; +} - } - throw new TypeError('Buffer.toArrayBuffer not supported in this browser'); - - }; +module.exports = baseIndexOf; - // HELPER FUNCTIONS - // ================ +},{"./indexOfNaN":115}],79:[function(require,module,exports){ +var baseIsEqualDeep = require('./baseIsEqualDeep'), + isObject = require('../lang/isObject'), + isObjectLike = require('./isObjectLike'); - var BP = Buffer.prototype; +/** + * The base implementation of `_.isEqual` without support for `this` binding + * `customizer` functions. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @param {Function} [customizer] The function to customize comparing values. + * @param {boolean} [isLoose] Specify performing partial comparisons. + * @param {Array} [stackA] Tracks traversed `value` objects. + * @param {Array} [stackB] Tracks traversed `other` objects. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + */ +function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) { + if (value === other) { + return true; + } + if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) { + return value !== value && other !== other; + } + return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB); +} + +module.exports = baseIsEqual; + +},{"../lang/isObject":144,"./baseIsEqualDeep":80,"./isObjectLike":126}],80:[function(require,module,exports){ +var equalArrays = require('./equalArrays'), + equalByTag = require('./equalByTag'), + equalObjects = require('./equalObjects'), + isArray = require('../lang/isArray'), + isHostObject = require('./isHostObject'), + isTypedArray = require('../lang/isTypedArray'); + +/** `Object#toString` result references. */ +var argsTag = '[object Arguments]', + arrayTag = '[object Array]', + objectTag = '[object Object]'; + +/** Used for native method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; - /** - * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods - */ - Buffer._augment = function _augment(arr) { - arr.constructor = Buffer; - arr._isBuffer = true; - - // save reference to original Uint8Array set method before overwriting - arr._set = arr.set; - - // deprecated, will be removed in node 0.13+ - arr.get = BP.get; - arr.set = BP.set; - - arr.write = BP.write; - arr.toString = BP.toString; - arr.toLocaleString = BP.toString; - arr.toJSON = BP.toJSON; - arr.equals = BP.equals; - arr.compare = BP.compare; - arr.indexOf = BP.indexOf; - arr.copy = BP.copy; - arr.slice = BP.slice; - arr.readUIntLE = BP.readUIntLE; - arr.readUIntBE = BP.readUIntBE; - arr.readUInt8 = BP.readUInt8; - arr.readUInt16LE = BP.readUInt16LE; - arr.readUInt16BE = BP.readUInt16BE; - arr.readUInt32LE = BP.readUInt32LE; - arr.readUInt32BE = BP.readUInt32BE; - arr.readIntLE = BP.readIntLE; - arr.readIntBE = BP.readIntBE; - arr.readInt8 = BP.readInt8; - arr.readInt16LE = BP.readInt16LE; - arr.readInt16BE = BP.readInt16BE; - arr.readInt32LE = BP.readInt32LE; - arr.readInt32BE = BP.readInt32BE; - arr.readFloatLE = BP.readFloatLE; - arr.readFloatBE = BP.readFloatBE; - arr.readDoubleLE = BP.readDoubleLE; - arr.readDoubleBE = BP.readDoubleBE; - arr.writeUInt8 = BP.writeUInt8; - arr.writeUIntLE = BP.writeUIntLE; - arr.writeUIntBE = BP.writeUIntBE; - arr.writeUInt16LE = BP.writeUInt16LE; - arr.writeUInt16BE = BP.writeUInt16BE; - arr.writeUInt32LE = BP.writeUInt32LE; - arr.writeUInt32BE = BP.writeUInt32BE; - arr.writeIntLE = BP.writeIntLE; - arr.writeIntBE = BP.writeIntBE; - arr.writeInt8 = BP.writeInt8; - arr.writeInt16LE = BP.writeInt16LE; - arr.writeInt16BE = BP.writeInt16BE; - arr.writeInt32LE = BP.writeInt32LE; - arr.writeInt32BE = BP.writeInt32BE; - arr.writeFloatLE = BP.writeFloatLE; - arr.writeFloatBE = BP.writeFloatBE; - arr.writeDoubleLE = BP.writeDoubleLE; - arr.writeDoubleBE = BP.writeDoubleBE; - arr.fill = BP.fill; - arr.inspect = BP.inspect; - arr.toArrayBuffer = BP.toArrayBuffer; - - return arr; - }; +/** + * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * of values. + */ +var objToString = objectProto.toString; - var INVALID_BASE64_RE = /[^+\/0-9A-z\-]/g; +/** + * A specialized version of `baseIsEqual` for arrays and objects which performs + * deep comparisons and tracks traversed objects enabling objects with circular + * references to be compared. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Function} [customizer] The function to customize comparing objects. + * @param {boolean} [isLoose] Specify performing partial comparisons. + * @param {Array} [stackA=[]] Tracks traversed `value` objects. + * @param {Array} [stackB=[]] Tracks traversed `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ +function baseIsEqualDeep(object, other, equalFunc, customizer, isLoose, stackA, stackB) { + var objIsArr = isArray(object), + othIsArr = isArray(other), + objTag = arrayTag, + othTag = arrayTag; + + if (!objIsArr) { + objTag = objToString.call(object); + if (objTag == argsTag) { + objTag = objectTag; + } else if (objTag != objectTag) { + objIsArr = isTypedArray(object); + } + } + if (!othIsArr) { + othTag = objToString.call(other); + if (othTag == argsTag) { + othTag = objectTag; + } else if (othTag != objectTag) { + othIsArr = isTypedArray(other); + } + } + var objIsObj = objTag == objectTag && !isHostObject(object), + othIsObj = othTag == objectTag && !isHostObject(other), + isSameTag = objTag == othTag; + + if (isSameTag && !(objIsArr || objIsObj)) { + return equalByTag(object, other, objTag); + } + if (!isLoose) { + var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), + othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); + + if (objIsWrapped || othIsWrapped) { + return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, isLoose, stackA, stackB); + } + } + if (!isSameTag) { + return false; + } + // Assume cyclic values are equal. + // For more information on detecting circular references see https://es5.github.io/#JO. + stackA || (stackA = []); + stackB || (stackB = []); + + var length = stackA.length; + while (length--) { + if (stackA[length] == object) { + return stackB[length] == other; + } + } + // Add `object` and `other` to the stack of traversed objects. + stackA.push(object); + stackB.push(other); - function base64clean(str) { - // Node strips out invalid characters like \n and \t from the string, base64-js does not - str = stringtrim(str).replace(INVALID_BASE64_RE, ''); - // Node converts strings with length < 2 to '' - if (str.length < 2) return ''; - // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not - while (str.length % 4 !== 0) { - str += '='; - } + var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isLoose, stackA, stackB); - return str; - } + stackA.pop(); + stackB.pop(); - function stringtrim(str) { - if (str.trim) return str.trim(); + return result; +} - return str.replace(/^\s+|\s+$/g, ''); - } +module.exports = baseIsEqualDeep; - function toHex(n) { - if (n < 16) return '0' + n.toString(16); +},{"../lang/isArray":140,"../lang/isTypedArray":147,"./equalArrays":107,"./equalByTag":108,"./equalObjects":109,"./isHostObject":120}],81:[function(require,module,exports){ +var baseIsEqual = require('./baseIsEqual'), + toObject = require('./toObject'); - return n.toString(16); - } +/** + * The base implementation of `_.isMatch` without support for callback + * shorthands and `this` binding. + * + * @private + * @param {Object} object The object to inspect. + * @param {Array} matchData The propery names, values, and compare flags to match. + * @param {Function} [customizer] The function to customize comparing objects. + * @returns {boolean} Returns `true` if `object` is a match, else `false`. + */ +function baseIsMatch(object, matchData, customizer) { + var index = matchData.length, + length = index, + noCustomizer = !customizer; + + if (object == null) { + return !length; + } + object = toObject(object); + while (index--) { + var data = matchData[index]; + if ((noCustomizer && data[2]) + ? data[1] !== object[data[0]] + : !(data[0] in object) + ) { + return false; + } + } + while (++index < length) { + data = matchData[index]; + var key = data[0], + objValue = object[key], + srcValue = data[1]; + + if (noCustomizer && data[2]) { + if (objValue === undefined && !(key in object)) { + return false; + } + } else { + var result = customizer ? customizer(objValue, srcValue, key) : undefined; + if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, true) : result)) { + return false; + } + } + } + return true; +} - function utf8ToBytes(string, units) { - units = units || Infinity; - var codePoint; - var length = string.length; - var leadSurrogate = null; - var bytes = []; - var i = 0; - - for (; i < length; i++) { - codePoint = string.charCodeAt(i); - - // is surrogate component - if (codePoint > 0xD7FF && codePoint < 0xE000) { - // last char was a lead - if (leadSurrogate) { - // 2 leads in a row - if (codePoint < 0xDC00) { - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); - leadSurrogate = codePoint; - continue; - } else { - // valid surrogate pair - codePoint = leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00 | 0x10000; - leadSurrogate = null; - } - } else { - // no lead yet - - if (codePoint > 0xDBFF) { - // unexpected trail - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); - continue; - } else if (i + 1 === length) { - // unpaired lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); - continue; - } else { - // valid lead - leadSurrogate = codePoint; - continue; - } - } - } else if (leadSurrogate) { - // valid bmp char, but last char was a lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD); - leadSurrogate = null; - } +module.exports = baseIsMatch; - // encode utf8 - if (codePoint < 0x80) { - if ((units -= 1) < 0) break; - bytes.push(codePoint); - } else if (codePoint < 0x800) { - if ((units -= 2) < 0) break; - bytes.push( - codePoint >> 0x6 | 0xC0, - codePoint & 0x3F | 0x80 - ); - } else if (codePoint < 0x10000) { - if ((units -= 3) < 0) break; - bytes.push( - codePoint >> 0xC | 0xE0, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ); - } else if (codePoint < 0x200000) { - if ((units -= 4) < 0) break; - bytes.push( - codePoint >> 0x12 | 0xF0, - codePoint >> 0xC & 0x3F | 0x80, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ); - } else { - throw new Error('Invalid code point'); - } - } +},{"./baseIsEqual":79,"./toObject":135}],82:[function(require,module,exports){ +/** + * The function whose prototype all chaining wrappers inherit from. + * + * @private + */ +function baseLodash() { + // No operation performed. +} - return bytes; - } +module.exports = baseLodash; - function asciiToBytes(str) { - var byteArray = []; +},{}],83:[function(require,module,exports){ +var baseEach = require('./baseEach'), + isArrayLike = require('./isArrayLike'); - for (var i = 0; i < str.length; i++) { - // Node's code seems to be doing this and not & 0x7F.. - byteArray.push(str.charCodeAt(i) & 0xFF); - } +/** + * The base implementation of `_.map` without support for callback shorthands + * and `this` binding. + * + * @private + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the new mapped array. + */ +function baseMap(collection, iteratee) { + var index = -1, + result = isArrayLike(collection) ? Array(collection.length) : []; - return byteArray; - } + baseEach(collection, function(value, key, collection) { + result[++index] = iteratee(value, key, collection); + }); + return result; +} - function utf16leToBytes(str, units) { - var c, hi, lo; - var byteArray = []; +module.exports = baseMap; - for (var i = 0; i < str.length; i++) { - if ((units -= 2) < 0) break; +},{"./baseEach":71,"./isArrayLike":119}],84:[function(require,module,exports){ +var baseIsMatch = require('./baseIsMatch'), + getMatchData = require('./getMatchData'), + toObject = require('./toObject'); - c = str.charCodeAt(i); - hi = c >> 8; - lo = c % 256; - byteArray.push(lo); - byteArray.push(hi); - } +/** + * The base implementation of `_.matches` which does not clone `source`. + * + * @private + * @param {Object} source The object of property values to match. + * @returns {Function} Returns the new function. + */ +function baseMatches(source) { + var matchData = getMatchData(source); + if (matchData.length == 1 && matchData[0][2]) { + var key = matchData[0][0], + value = matchData[0][1]; + + return function(object) { + if (object == null) { + return false; + } + object = toObject(object); + return object[key] === value && (value !== undefined || (key in object)); + }; + } + return function(object) { + return baseIsMatch(object, matchData); + }; +} + +module.exports = baseMatches; + +},{"./baseIsMatch":81,"./getMatchData":113,"./toObject":135}],85:[function(require,module,exports){ +var baseGet = require('./baseGet'), + baseIsEqual = require('./baseIsEqual'), + baseSlice = require('./baseSlice'), + isArray = require('../lang/isArray'), + isKey = require('./isKey'), + isStrictComparable = require('./isStrictComparable'), + last = require('../array/last'), + toObject = require('./toObject'), + toPath = require('./toPath'); - return byteArray; - } +/** + * The base implementation of `_.matchesProperty` which does not clone `srcValue`. + * + * @private + * @param {string} path The path of the property to get. + * @param {*} srcValue The value to compare. + * @returns {Function} Returns the new function. + */ +function baseMatchesProperty(path, srcValue) { + var isArr = isArray(path), + isCommon = isKey(path) && isStrictComparable(srcValue), + pathKey = (path + ''); + + path = toPath(path); + return function(object) { + if (object == null) { + return false; + } + var key = pathKey; + object = toObject(object); + if ((isArr || !isCommon) && !(key in object)) { + object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1)); + if (object == null) { + return false; + } + key = last(path); + object = toObject(object); + } + return object[key] === srcValue + ? (srcValue !== undefined || (key in object)) + : baseIsEqual(srcValue, object[key], undefined, true); + }; +} - function base64ToBytes(str) { - return base64.toByteArray(base64clean(str)); - } +module.exports = baseMatchesProperty; - function blitBuffer(src, dst, offset, length) { - for (var i = 0; i < length; i++) { - if (i + offset >= dst.length || i >= src.length) break; - dst[i + offset] = src[i]; - } +},{"../array/last":50,"../lang/isArray":140,"./baseGet":77,"./baseIsEqual":79,"./baseSlice":89,"./isKey":123,"./isStrictComparable":127,"./toObject":135,"./toPath":136}],86:[function(require,module,exports){ +var toObject = require('./toObject'); - return i; - } +/** + * The base implementation of `_.property` without support for deep paths. + * + * @private + * @param {string} key The key of the property to get. + * @returns {Function} Returns the new function. + */ +function baseProperty(key) { + return function(object) { + return object == null ? undefined : toObject(object)[key]; + }; +} - function decodeUtf8Char(str) { - try { - return decodeURIComponent(str); - } catch (err) { - return String.fromCharCode(0xFFFD); // UTF 8 invalid char - } - } +module.exports = baseProperty; - },{ - 'base64-js': 14,'ieee754': 15,'is-array': 16 - }],14: [function (require, module, exports) { - var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; +},{"./toObject":135}],87:[function(require,module,exports){ +var baseGet = require('./baseGet'), + toPath = require('./toPath'); - (function (exports) { - 'use strict'; +/** + * A specialized version of `baseProperty` which supports deep paths. + * + * @private + * @param {Array|string} path The path of the property to get. + * @returns {Function} Returns the new function. + */ +function basePropertyDeep(path) { + var pathKey = (path + ''); + path = toPath(path); + return function(object) { + return baseGet(object, path, pathKey); + }; +} - var Arr = typeof Uint8Array !== 'undefined' ? - Uint8Array - : Array; - - var PLUS = '+'.charCodeAt(0); - var SLASH = '/'.charCodeAt(0); - var NUMBER = '0'.charCodeAt(0); - var LOWER = 'a'.charCodeAt(0); - var UPPER = 'A'.charCodeAt(0); - var PLUS_URL_SAFE = '-'.charCodeAt(0); - var SLASH_URL_SAFE = '_'.charCodeAt(0); - - function decode(elt) { - var code = elt.charCodeAt(0); - - if (code === PLUS || - code === PLUS_URL_SAFE) - return 62; // '+' - if (code === SLASH || - code === SLASH_URL_SAFE) - return 63; // '/' - if (code < NUMBER) - return -1; //no match - if (code < NUMBER + 10) - return code - NUMBER + 26 + 26; - - if (code < UPPER + 26) - return code - UPPER; - - if (code < LOWER + 26) - return code - LOWER + 26; - } +module.exports = basePropertyDeep; - function b64ToByteArray(b64) { - var i, j, l, tmp, placeHolders, arr; +},{"./baseGet":77,"./toPath":136}],88:[function(require,module,exports){ +var identity = require('../utility/identity'), + metaMap = require('./metaMap'); - if (b64.length % 4 > 0) { - throw new Error('Invalid string. Length must be a multiple of 4.'); - } +/** + * The base implementation of `setData` without support for hot loop detection. + * + * @private + * @param {Function} func The function to associate metadata with. + * @param {*} data The metadata. + * @returns {Function} Returns `func`. + */ +var baseSetData = !metaMap ? identity : function(func, data) { + metaMap.set(func, data); + return func; +}; - // the number of equal signs (place holders) - // if there are two placeholders, than the two characters before it - // represent one byte - // if there is only one, then the three characters before it represent 2 bytes - // this is just a cheap hack to not do indexOf twice - var len = b64.length; +module.exports = baseSetData; - placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0; +},{"../utility/identity":154,"./metaMap":129}],89:[function(require,module,exports){ +/** + * The base implementation of `_.slice` without an iteratee call guard. + * + * @private + * @param {Array} array The array to slice. + * @param {number} [start=0] The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns the slice of `array`. + */ +function baseSlice(array, start, end) { + var index = -1, + length = array.length; + + start = start == null ? 0 : (+start || 0); + if (start < 0) { + start = -start > length ? 0 : (length + start); + } + end = (end === undefined || end > length) ? length : (+end || 0); + if (end < 0) { + end += length; + } + length = start > end ? 0 : ((end - start) >>> 0); + start >>>= 0; + + var result = Array(length); + while (++index < length) { + result[index] = array[index + start]; + } + return result; +} + +module.exports = baseSlice; + +},{}],90:[function(require,module,exports){ +/** + * Converts `value` to a string if it's not one. An empty string is returned + * for `null` or `undefined` values. + * + * @private + * @param {*} value The value to process. + * @returns {string} Returns the string. + */ +function baseToString(value) { + return value == null ? '' : (value + ''); +} - // base64 is 4/3 + up to two characters of the original data - arr = new Arr(b64.length * 3 / 4 - placeHolders); +module.exports = baseToString; - // if there are placeholders, only get up to the last complete 4 chars - l = placeHolders > 0 ? b64.length - 4 : b64.length; +},{}],91:[function(require,module,exports){ +/** + * The base implementation of `_.values` and `_.valuesIn` which creates an + * array of `object` property values corresponding to the property names + * of `props`. + * + * @private + * @param {Object} object The object to query. + * @param {Array} props The property names to get values for. + * @returns {Object} Returns the array of property values. + */ +function baseValues(object, props) { + var index = -1, + length = props.length, + result = Array(length); - var L = 0; + while (++index < length) { + result[index] = object[props[index]]; + } + return result; +} - function push(v) { - arr[L++] = v; - } +module.exports = baseValues; - for (i = 0, j = 0; i < l; i += 4, j += 3) { - tmp = decode(b64.charAt(i)) << 18 | decode(b64.charAt(i + 1)) << 12 | decode(b64.charAt(i + 2)) << 6 | decode(b64.charAt(i + 3)); - push((tmp & 0xFF0000) >> 16); - push((tmp & 0xFF00) >> 8); - push(tmp & 0xFF); - } +},{}],92:[function(require,module,exports){ +var binaryIndexBy = require('./binaryIndexBy'), + identity = require('../utility/identity'); - if (placeHolders === 2) { - tmp = decode(b64.charAt(i)) << 2 | decode(b64.charAt(i + 1)) >> 4; - push(tmp & 0xFF); - } else if (placeHolders === 1) { - tmp = decode(b64.charAt(i)) << 10 | decode(b64.charAt(i + 1)) << 4 | decode(b64.charAt(i + 2)) >> 2; - push(tmp >> 8 & 0xFF); - push(tmp & 0xFF); - } +/** Used as references for the maximum length and index of an array. */ +var MAX_ARRAY_LENGTH = 4294967295, + HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; - return arr; - } +/** + * Performs a binary search of `array` to determine the index at which `value` + * should be inserted into `array` in order to maintain its sort order. + * + * @private + * @param {Array} array The sorted array to inspect. + * @param {*} value The value to evaluate. + * @param {boolean} [retHighest] Specify returning the highest qualified index. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. + */ +function binaryIndex(array, value, retHighest) { + var low = 0, + high = array ? array.length : low; + + if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) { + while (low < high) { + var mid = (low + high) >>> 1, + computed = array[mid]; + + if ((retHighest ? (computed <= value) : (computed < value)) && computed !== null) { + low = mid + 1; + } else { + high = mid; + } + } + return high; + } + return binaryIndexBy(array, value, identity, retHighest); +} - function uint8ToBase64(uint8) { - var i, - extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes - output = '', - temp, length; +module.exports = binaryIndex; - function encode(num) { - return lookup.charAt(num); - } +},{"../utility/identity":154,"./binaryIndexBy":93}],93:[function(require,module,exports){ +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeFloor = Math.floor, + nativeMin = Math.min; - function tripletToBase64(num) { - return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F); - } +/** Used as references for the maximum length and index of an array. */ +var MAX_ARRAY_LENGTH = 4294967295, + MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1; - // go through the array every three bytes, we'll deal with trailing stuff later - for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) { - temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + uint8[i + 2]; - output += tripletToBase64(temp); - } +/** + * This function is like `binaryIndex` except that it invokes `iteratee` for + * `value` and each element of `array` to compute their sort ranking. The + * iteratee is invoked with one argument; (value). + * + * @private + * @param {Array} array The sorted array to inspect. + * @param {*} value The value to evaluate. + * @param {Function} iteratee The function invoked per iteration. + * @param {boolean} [retHighest] Specify returning the highest qualified index. + * @returns {number} Returns the index at which `value` should be inserted + * into `array`. + */ +function binaryIndexBy(array, value, iteratee, retHighest) { + value = iteratee(value); + + var low = 0, + high = array ? array.length : 0, + valIsNaN = value !== value, + valIsNull = value === null, + valIsUndef = value === undefined; + + while (low < high) { + var mid = nativeFloor((low + high) / 2), + computed = iteratee(array[mid]), + isDef = computed !== undefined, + isReflexive = computed === computed; + + if (valIsNaN) { + var setLow = isReflexive || retHighest; + } else if (valIsNull) { + setLow = isReflexive && isDef && (retHighest || computed != null); + } else if (valIsUndef) { + setLow = isReflexive && (retHighest || isDef); + } else if (computed == null) { + setLow = false; + } else { + setLow = retHighest ? (computed <= value) : (computed < value); + } + if (setLow) { + low = mid + 1; + } else { + high = mid; + } + } + return nativeMin(high, MAX_ARRAY_INDEX); +} - // pad the end with zeros, but make sure to not forget the extra bytes - switch (extraBytes) { - case 1: - temp = uint8[uint8.length - 1]; - output += encode(temp >> 2); - output += encode(temp << 4 & 0x3F); - output += '=='; - break; - - case 2: - temp = (uint8[uint8.length - 2] << 8) + uint8[uint8.length - 1]; - output += encode(temp >> 10); - output += encode(temp >> 4 & 0x3F); - output += encode(temp << 2 & 0x3F); - output += '='; - break; - } +module.exports = binaryIndexBy; - return output; - } +},{}],94:[function(require,module,exports){ +var identity = require('../utility/identity'); - exports.toByteArray = b64ToByteArray; - exports.fromByteArray = uint8ToBase64; - }(typeof exports === 'undefined' ? this.base64js = {} : exports)); +/** + * A specialized version of `baseCallback` which only supports `this` binding + * and specifying the number of arguments to provide to `func`. + * + * @private + * @param {Function} func The function to bind. + * @param {*} thisArg The `this` binding of `func`. + * @param {number} [argCount] The number of arguments to provide to `func`. + * @returns {Function} Returns the callback. + */ +function bindCallback(func, thisArg, argCount) { + if (typeof func != 'function') { + return identity; + } + if (thisArg === undefined) { + return func; + } + switch (argCount) { + case 1: return function(value) { + return func.call(thisArg, value); + }; + case 3: return function(value, index, collection) { + return func.call(thisArg, value, index, collection); + }; + case 4: return function(accumulator, value, index, collection) { + return func.call(thisArg, accumulator, value, index, collection); + }; + case 5: return function(value, other, key, object, source) { + return func.call(thisArg, value, other, key, object, source); + }; + } + return function() { + return func.apply(thisArg, arguments); + }; +} - },{}],15: [function (require, module, exports) { - exports.read = function (buffer, offset, isLE, mLen, nBytes) { - var e, m; - var eLen = nBytes * 8 - mLen - 1; - var eMax = (1 << eLen) - 1; - var eBias = eMax >> 1; - var nBits = -7; - var i = isLE ? nBytes - 1 : 0; - var d = isLE ? -1 : 1; - var s = buffer[offset + i]; +module.exports = bindCallback; - i += d; +},{"../utility/identity":154}],95:[function(require,module,exports){ +(function (global){ +/** Native method references. */ +var ArrayBuffer = global.ArrayBuffer, + Uint8Array = global.Uint8Array; - e = s & (1 << -nBits) - 1; - s >>= -nBits; - nBits += eLen; +/** + * Creates a clone of the given array buffer. + * + * @private + * @param {ArrayBuffer} buffer The array buffer to clone. + * @returns {ArrayBuffer} Returns the cloned array buffer. + */ +function bufferClone(buffer) { + var result = new ArrayBuffer(buffer.byteLength), + view = new Uint8Array(result); - for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} + view.set(new Uint8Array(buffer)); + return result; +} - m = e & (1 << -nBits) - 1; - e >>= -nBits; - nBits += mLen; +module.exports = bufferClone; - for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) - if (e === 0) { - e = 1 - eBias; - } else if (e === eMax) { - return m ? NaN : (s ? -1 : 1) * Infinity; - } else { - m += Math.pow(2, mLen); - e -= eBias; - } +},{}],96:[function(require,module,exports){ +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeMax = Math.max; - return (s ? -1 : 1) * m * Math.pow(2, e - mLen); - }; +/** + * Creates an array that is the composition of partially applied arguments, + * placeholders, and provided arguments into a single array of arguments. + * + * @private + * @param {Array|Object} args The provided arguments. + * @param {Array} partials The arguments to prepend to those provided. + * @param {Array} holders The `partials` placeholder indexes. + * @returns {Array} Returns the new array of composed arguments. + */ +function composeArgs(args, partials, holders) { + var holdersLength = holders.length, + argsIndex = -1, + argsLength = nativeMax(args.length - holdersLength, 0), + leftIndex = -1, + leftLength = partials.length, + result = Array(leftLength + argsLength); + + while (++leftIndex < leftLength) { + result[leftIndex] = partials[leftIndex]; + } + while (++argsIndex < holdersLength) { + result[holders[argsIndex]] = args[argsIndex]; + } + while (argsLength--) { + result[leftIndex++] = args[argsIndex++]; + } + return result; +} + +module.exports = composeArgs; + +},{}],97:[function(require,module,exports){ +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeMax = Math.max; - exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { - var e, m, c; - var eLen = nBytes * 8 - mLen - 1; - var eMax = (1 << eLen) - 1; - var eBias = eMax >> 1; - var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0; - var i = isLE ? 0 : nBytes - 1; - var d = isLE ? 1 : -1; - var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0; - - value = Math.abs(value); - - if (isNaN(value) || value === Infinity) { - m = isNaN(value) ? 1 : 0; - e = eMax; - } else { - e = Math.floor(Math.log(value) / Math.LN2); +/** + * This function is like `composeArgs` except that the arguments composition + * is tailored for `_.partialRight`. + * + * @private + * @param {Array|Object} args The provided arguments. + * @param {Array} partials The arguments to append to those provided. + * @param {Array} holders The `partials` placeholder indexes. + * @returns {Array} Returns the new array of composed arguments. + */ +function composeArgsRight(args, partials, holders) { + var holdersIndex = -1, + holdersLength = holders.length, + argsIndex = -1, + argsLength = nativeMax(args.length - holdersLength, 0), + rightIndex = -1, + rightLength = partials.length, + result = Array(argsLength + rightLength); + + while (++argsIndex < argsLength) { + result[argsIndex] = args[argsIndex]; + } + var offset = argsIndex; + while (++rightIndex < rightLength) { + result[offset + rightIndex] = partials[rightIndex]; + } + while (++holdersIndex < holdersLength) { + result[offset + holders[holdersIndex]] = args[argsIndex++]; + } + return result; +} + +module.exports = composeArgsRight; + +},{}],98:[function(require,module,exports){ +var getLength = require('./getLength'), + isLength = require('./isLength'), + toObject = require('./toObject'); - if (value * (c = Math.pow(2, -e)) < 1) { - e--; - c *= 2; - } +/** + * Creates a `baseEach` or `baseEachRight` function. + * + * @private + * @param {Function} eachFunc The function to iterate over a collection. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new base function. + */ +function createBaseEach(eachFunc, fromRight) { + return function(collection, iteratee) { + var length = collection ? getLength(collection) : 0; + if (!isLength(length)) { + return eachFunc(collection, iteratee); + } + var index = fromRight ? length : -1, + iterable = toObject(collection); - if (e + eBias >= 1) { - value += rt / c; - } else { - value += rt * Math.pow(2, 1 - eBias); - } + while ((fromRight ? index-- : ++index < length)) { + if (iteratee(iterable[index], index, iterable) === false) { + break; + } + } + return collection; + }; +} - if (value * c >= 2) { - e++; - c /= 2; - } +module.exports = createBaseEach; - if (e + eBias >= eMax) { - m = 0; - e = eMax; - } else if (e + eBias >= 1) { - m = (value * c - 1) * Math.pow(2, mLen); - e += eBias; - } else { - m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); - e = 0; - } - } +},{"./getLength":112,"./isLength":125,"./toObject":135}],99:[function(require,module,exports){ +var toObject = require('./toObject'); - for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} +/** + * Creates a base function for `_.forIn` or `_.forInRight`. + * + * @private + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new base function. + */ +function createBaseFor(fromRight) { + return function(object, iteratee, keysFunc) { + var iterable = toObject(object), + props = keysFunc(object), + length = props.length, + index = fromRight ? length : -1; + + while ((fromRight ? index-- : ++index < length)) { + var key = props[index]; + if (iteratee(iterable[key], key, iterable) === false) { + break; + } + } + return object; + }; +} - e = e << mLen | m; - eLen += mLen; +module.exports = createBaseFor; - for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} +},{"./toObject":135}],100:[function(require,module,exports){ +(function (global){ +var createCtorWrapper = require('./createCtorWrapper'); - buffer[offset + i - d] |= s * 128; - }; +/** + * Creates a function that wraps `func` and invokes it with the `this` + * binding of `thisArg`. + * + * @private + * @param {Function} func The function to bind. + * @param {*} [thisArg] The `this` binding of `func`. + * @returns {Function} Returns the new bound function. + */ +function createBindWrapper(func, thisArg) { + var Ctor = createCtorWrapper(func); - },{}],16: [function (require, module, exports) { + function wrapper() { + var fn = (this && this !== global && this instanceof wrapper) ? Ctor : func; + return fn.apply(thisArg, arguments); + } + return wrapper; +} - /** - * isArray - */ +module.exports = createBindWrapper; - var isArray = Array.isArray; +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) - /** - * toString - */ +},{"./createCtorWrapper":101}],101:[function(require,module,exports){ +var baseCreate = require('./baseCreate'), + isObject = require('../lang/isObject'); - var str = Object.prototype.toString; - - /** - * Whether or not the given `val` - * is an array. - * - * example: - * - * isArray([]); - * // > true - * isArray(arguments); - * // > false - * isArray(''); - * // > false - * - * @param {mixed} val - * @return {bool} - */ +/** + * Creates a function that produces an instance of `Ctor` regardless of + * whether it was invoked as part of a `new` expression or by `call` or `apply`. + * + * @private + * @param {Function} Ctor The constructor to wrap. + * @returns {Function} Returns the new wrapped function. + */ +function createCtorWrapper(Ctor) { + return function() { + // Use a `switch` statement to work with class constructors. + // See http://ecma-international.org/ecma-262/6.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist + // for more details. + var args = arguments; + switch (args.length) { + case 0: return new Ctor; + case 1: return new Ctor(args[0]); + case 2: return new Ctor(args[0], args[1]); + case 3: return new Ctor(args[0], args[1], args[2]); + case 4: return new Ctor(args[0], args[1], args[2], args[3]); + case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]); + case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]); + case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); + } + var thisBinding = baseCreate(Ctor.prototype), + result = Ctor.apply(thisBinding, args); - module.exports = isArray || function (val) { - return !!val && '[object Array]' == str.call(val); - }; + // Mimic the constructor's `return` behavior. + // See https://es5.github.io/#x13.2.2 for more details. + return isObject(result) ? result : thisBinding; + }; +} - },{}],17: [function (require, module, exports) { - // shim for using process in browser +module.exports = createCtorWrapper; - var process = module.exports = {}; - var queue = []; - var draining = false; +},{"../lang/isObject":144,"./baseCreate":70}],102:[function(require,module,exports){ +var baseCallback = require('./baseCallback'), + baseFind = require('./baseFind'), + baseFindIndex = require('./baseFindIndex'), + isArray = require('../lang/isArray'); - function drainQueue() { - if (draining) { - return; - } - draining = true; - var currentQueue; - var len = queue.length; +/** + * Creates a `_.find` or `_.findLast` function. + * + * @private + * @param {Function} eachFunc The function to iterate over a collection. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new find function. + */ +function createFind(eachFunc, fromRight) { + return function(collection, predicate, thisArg) { + predicate = baseCallback(predicate, thisArg, 3); + if (isArray(collection)) { + var index = baseFindIndex(collection, predicate, fromRight); + return index > -1 ? collection[index] : undefined; + } + return baseFind(collection, predicate, eachFunc); + }; +} - while (len) { - currentQueue = queue; - queue = []; - var i = -1; +module.exports = createFind; - while (++i < len) { - currentQueue[i](); - } - len = queue.length; - } - draining = false; - } - process.nextTick = function (fun) { - queue.push(fun); +},{"../lang/isArray":140,"./baseCallback":67,"./baseFind":72,"./baseFindIndex":73}],103:[function(require,module,exports){ +var bindCallback = require('./bindCallback'), + isArray = require('../lang/isArray'); - if (!draining) { - setTimeout(drainQueue, 0); - } - }; +/** + * Creates a function for `_.forEach` or `_.forEachRight`. + * + * @private + * @param {Function} arrayFunc The function to iterate over an array. + * @param {Function} eachFunc The function to iterate over a collection. + * @returns {Function} Returns the new each function. + */ +function createForEach(arrayFunc, eachFunc) { + return function(collection, iteratee, thisArg) { + return (typeof iteratee == 'function' && thisArg === undefined && isArray(collection)) + ? arrayFunc(collection, iteratee) + : eachFunc(collection, bindCallback(iteratee, thisArg, 3)); + }; +} + +module.exports = createForEach; + +},{"../lang/isArray":140,"./bindCallback":94}],104:[function(require,module,exports){ +(function (global){ +var arrayCopy = require('./arrayCopy'), + composeArgs = require('./composeArgs'), + composeArgsRight = require('./composeArgsRight'), + createCtorWrapper = require('./createCtorWrapper'), + isLaziable = require('./isLaziable'), + reorder = require('./reorder'), + replaceHolders = require('./replaceHolders'), + setData = require('./setData'); + +/** Used to compose bitmasks for wrapper metadata. */ +var BIND_FLAG = 1, + BIND_KEY_FLAG = 2, + CURRY_BOUND_FLAG = 4, + CURRY_FLAG = 8, + CURRY_RIGHT_FLAG = 16, + PARTIAL_FLAG = 32, + PARTIAL_RIGHT_FLAG = 64, + ARY_FLAG = 128; + +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeMax = Math.max; - process.title = 'browser'; - process.browser = true; - process.env = {}; - process.argv = []; - process.version = ''; // empty string to avoid regexp issues - process.versions = {}; - - function noop() {} - - process.on = noop; - process.addListener = noop; - process.once = noop; - process.off = noop; - process.removeListener = noop; - process.removeAllListeners = noop; - process.emit = noop; - - process.binding = function (name) { - throw new Error('process.binding is not supported'); - }; +/** + * Creates a function that wraps `func` and invokes it with optional `this` + * binding of, partial application, and currying. + * + * @private + * @param {Function|string} func The function or method name to reference. + * @param {number} bitmask The bitmask of flags. See `createWrapper` for more details. + * @param {*} [thisArg] The `this` binding of `func`. + * @param {Array} [partials] The arguments to prepend to those provided to the new function. + * @param {Array} [holders] The `partials` placeholder indexes. + * @param {Array} [partialsRight] The arguments to append to those provided to the new function. + * @param {Array} [holdersRight] The `partialsRight` placeholder indexes. + * @param {Array} [argPos] The argument positions of the new function. + * @param {number} [ary] The arity cap of `func`. + * @param {number} [arity] The arity of `func`. + * @returns {Function} Returns the new wrapped function. + */ +function createHybridWrapper(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) { + var isAry = bitmask & ARY_FLAG, + isBind = bitmask & BIND_FLAG, + isBindKey = bitmask & BIND_KEY_FLAG, + isCurry = bitmask & CURRY_FLAG, + isCurryBound = bitmask & CURRY_BOUND_FLAG, + isCurryRight = bitmask & CURRY_RIGHT_FLAG, + Ctor = isBindKey ? undefined : createCtorWrapper(func); + + function wrapper() { + // Avoid `arguments` object use disqualifying optimizations by + // converting it to an array before providing it to other functions. + var length = arguments.length, + index = length, + args = Array(length); + + while (index--) { + args[index] = arguments[index]; + } + if (partials) { + args = composeArgs(args, partials, holders); + } + if (partialsRight) { + args = composeArgsRight(args, partialsRight, holdersRight); + } + if (isCurry || isCurryRight) { + var placeholder = wrapper.placeholder, + argsHolders = replaceHolders(args, placeholder); + + length -= argsHolders.length; + if (length < arity) { + var newArgPos = argPos ? arrayCopy(argPos) : undefined, + newArity = nativeMax(arity - length, 0), + newsHolders = isCurry ? argsHolders : undefined, + newHoldersRight = isCurry ? undefined : argsHolders, + newPartials = isCurry ? args : undefined, + newPartialsRight = isCurry ? undefined : args; + + bitmask |= (isCurry ? PARTIAL_FLAG : PARTIAL_RIGHT_FLAG); + bitmask &= ~(isCurry ? PARTIAL_RIGHT_FLAG : PARTIAL_FLAG); + + if (!isCurryBound) { + bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG); + } + var newData = [func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, newArity], + result = createHybridWrapper.apply(undefined, newData); - // TODO(shtylman) - process.cwd = function () { - return '/'; - }; - process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); - }; - process.umask = function () { - return 0; - }; + if (isLaziable(func)) { + setData(result, newData); + } + result.placeholder = placeholder; + return result; + } + } + var thisBinding = isBind ? thisArg : this, + fn = isBindKey ? thisBinding[func] : func; - },{}],18: [function (require, module, exports) { - (function (Buffer) { - (function () { - 'use strict'; + if (argPos) { + args = reorder(args, argPos); + } + if (isAry && ary < args.length) { + args.length = ary; + } + if (this && this !== global && this instanceof wrapper) { + fn = Ctor || createCtorWrapper(func); + } + return fn.apply(thisBinding, args); + } + return wrapper; +} - function btoa(str) { - var buffer +module.exports = createHybridWrapper; - ; +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) - if (str instanceof Buffer) { - buffer = str; - } else { - buffer = new Buffer(str.toString(), 'binary'); - } +},{"./arrayCopy":62,"./composeArgs":96,"./composeArgsRight":97,"./createCtorWrapper":101,"./isLaziable":124,"./reorder":131,"./replaceHolders":132,"./setData":133}],105:[function(require,module,exports){ +(function (global){ +var createCtorWrapper = require('./createCtorWrapper'); - return buffer.toString('base64'); - } +/** Used to compose bitmasks for wrapper metadata. */ +var BIND_FLAG = 1; - module.exports = btoa; - }()); +/** + * Creates a function that wraps `func` and invokes it with the optional `this` + * binding of `thisArg` and the `partials` prepended to those provided to + * the wrapper. + * + * @private + * @param {Function} func The function to partially apply arguments to. + * @param {number} bitmask The bitmask of flags. See `createWrapper` for more details. + * @param {*} thisArg The `this` binding of `func`. + * @param {Array} partials The arguments to prepend to those provided to the new function. + * @returns {Function} Returns the new bound function. + */ +function createPartialWrapper(func, bitmask, thisArg, partials) { + var isBind = bitmask & BIND_FLAG, + Ctor = createCtorWrapper(func); + + function wrapper() { + // Avoid `arguments` object use disqualifying optimizations by + // converting it to an array before providing it `func`. + var argsIndex = -1, + argsLength = arguments.length, + leftIndex = -1, + leftLength = partials.length, + args = Array(leftLength + argsLength); + + while (++leftIndex < leftLength) { + args[leftIndex] = partials[leftIndex]; + } + while (argsLength--) { + args[leftIndex++] = arguments[++argsIndex]; + } + var fn = (this && this !== global && this instanceof wrapper) ? Ctor : func; + return fn.apply(isBind ? thisArg : this, args); + } + return wrapper; +} - }).call(this, require('buffer').Buffer); - //# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9idG9hL2luZGV4LmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsImZpbGUiOiJnZW5lcmF0ZWQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlc0NvbnRlbnQiOlsiKGZ1bmN0aW9uICgpIHtcbiAgXCJ1c2Ugc3RyaWN0XCI7XG5cbiAgZnVuY3Rpb24gYnRvYShzdHIpIHtcbiAgICB2YXIgYnVmZmVyXG4gICAgICA7XG5cbiAgICBpZiAoc3RyIGluc3RhbmNlb2YgQnVmZmVyKSB7XG4gICAgICBidWZmZXIgPSBzdHI7XG4gICAgfSBlbHNlIHtcbiAgICAgIGJ1ZmZlciA9IG5ldyBCdWZmZXIoc3RyLnRvU3RyaW5nKCksICdiaW5hcnknKTtcbiAgICB9XG5cbiAgICByZXR1cm4gYnVmZmVyLnRvU3RyaW5nKCdiYXNlNjQnKTtcbiAgfVxuXG4gIG1vZHVsZS5leHBvcnRzID0gYnRvYTtcbn0oKSk7XG4iXX0= - },{ - 'buffer': 13 - }],19: [function (require, module, exports) { - /* jshint node: true */ - (function () { - 'use strict'; +module.exports = createPartialWrapper; - function CookieAccessInfo(domain, path, secure, script) { - if (this instanceof CookieAccessInfo) { - this.domain = domain || undefined; - this.path = path || '/'; - this.secure = !!secure; - this.script = !!script; +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) - return this; - } +},{"./createCtorWrapper":101}],106:[function(require,module,exports){ +var baseSetData = require('./baseSetData'), + createBindWrapper = require('./createBindWrapper'), + createHybridWrapper = require('./createHybridWrapper'), + createPartialWrapper = require('./createPartialWrapper'), + getData = require('./getData'), + mergeData = require('./mergeData'), + setData = require('./setData'); - return new CookieAccessInfo(domain, path, secure, script); - } - exports.CookieAccessInfo = CookieAccessInfo; +/** Used to compose bitmasks for wrapper metadata. */ +var BIND_FLAG = 1, + BIND_KEY_FLAG = 2, + PARTIAL_FLAG = 32, + PARTIAL_RIGHT_FLAG = 64; - function Cookie(cookiestr, request_domain, request_path) { - if (cookiestr instanceof Cookie) { - return cookiestr; - } +/** Used as the `TypeError` message for "Functions" methods. */ +var FUNC_ERROR_TEXT = 'Expected a function'; - if (this instanceof Cookie) { - this.name = null; - this.value = null; - this.expiration_date = Infinity; - this.path = String(request_path || '/'); - this.explicit_path = false; - this.domain = request_domain || null; - this.explicit_domain = false; - this.secure = false; //how to define default? - this.noscript = false; //httponly - if (cookiestr) { - this.parse(cookiestr, request_domain, request_path); - } +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeMax = Math.max; - return this; - } +/** + * Creates a function that either curries or invokes `func` with optional + * `this` binding and partially applied arguments. + * + * @private + * @param {Function|string} func The function or method name to reference. + * @param {number} bitmask The bitmask of flags. + * The bitmask may be composed of the following flags: + * 1 - `_.bind` + * 2 - `_.bindKey` + * 4 - `_.curry` or `_.curryRight` of a bound function + * 8 - `_.curry` + * 16 - `_.curryRight` + * 32 - `_.partial` + * 64 - `_.partialRight` + * 128 - `_.rearg` + * 256 - `_.ary` + * @param {*} [thisArg] The `this` binding of `func`. + * @param {Array} [partials] The arguments to be partially applied. + * @param {Array} [holders] The `partials` placeholder indexes. + * @param {Array} [argPos] The argument positions of the new function. + * @param {number} [ary] The arity cap of `func`. + * @param {number} [arity] The arity of `func`. + * @returns {Function} Returns the new wrapped function. + */ +function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ary, arity) { + var isBindKey = bitmask & BIND_KEY_FLAG; + if (!isBindKey && typeof func != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + var length = partials ? partials.length : 0; + if (!length) { + bitmask &= ~(PARTIAL_FLAG | PARTIAL_RIGHT_FLAG); + partials = holders = undefined; + } + length -= (holders ? holders.length : 0); + if (bitmask & PARTIAL_RIGHT_FLAG) { + var partialsRight = partials, + holdersRight = holders; + + partials = holders = undefined; + } + var data = isBindKey ? undefined : getData(func), + newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity]; + + if (data) { + mergeData(newData, data); + bitmask = newData[1]; + arity = newData[9]; + } + newData[9] = arity == null + ? (isBindKey ? 0 : func.length) + : (nativeMax(arity - length, 0) || 0); + + if (bitmask == BIND_FLAG) { + var result = createBindWrapper(newData[0], newData[2]); + } else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !newData[4].length) { + result = createPartialWrapper.apply(undefined, newData); + } else { + result = createHybridWrapper.apply(undefined, newData); + } + var setter = data ? baseSetData : setData; + return setter(result, newData); +} + +module.exports = createWrapper; + +},{"./baseSetData":88,"./createBindWrapper":100,"./createHybridWrapper":104,"./createPartialWrapper":105,"./getData":110,"./mergeData":128,"./setData":133}],107:[function(require,module,exports){ +var arraySome = require('./arraySome'); - return new Cookie(cookiestr); - } - exports.Cookie = Cookie; +/** + * A specialized version of `baseIsEqualDeep` for arrays with support for + * partial deep comparisons. + * + * @private + * @param {Array} array The array to compare. + * @param {Array} other The other array to compare. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Function} [customizer] The function to customize comparing arrays. + * @param {boolean} [isLoose] Specify performing partial comparisons. + * @param {Array} [stackA] Tracks traversed `value` objects. + * @param {Array} [stackB] Tracks traversed `other` objects. + * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. + */ +function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) { + var index = -1, + arrLength = array.length, + othLength = other.length; + + if (arrLength != othLength && !(isLoose && othLength > arrLength)) { + return false; + } + // Ignore non-index properties. + while (++index < arrLength) { + var arrValue = array[index], + othValue = other[index], + result = customizer ? customizer(isLoose ? othValue : arrValue, isLoose ? arrValue : othValue, index) : undefined; + + if (result !== undefined) { + if (result) { + continue; + } + return false; + } + // Recursively compare arrays (susceptible to call stack limits). + if (isLoose) { + if (!arraySome(other, function(othValue) { + return arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB); + })) { + return false; + } + } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB))) { + return false; + } + } + return true; +} - Cookie.prototype.toString = function toString() { - var str = [this.name + '=' + this.value]; +module.exports = equalArrays; - if (this.expiration_date !== Infinity) { - str.push('expires=' + (new Date(this.expiration_date)).toGMTString()); - } +},{"./arraySome":65}],108:[function(require,module,exports){ +/** `Object#toString` result references. */ +var boolTag = '[object Boolean]', + dateTag = '[object Date]', + errorTag = '[object Error]', + numberTag = '[object Number]', + regexpTag = '[object RegExp]', + stringTag = '[object String]'; - if (this.domain) { - str.push('domain=' + this.domain); - } +/** + * A specialized version of `baseIsEqualDeep` for comparing objects of + * the same `toStringTag`. + * + * **Note:** This function only supports comparing values with tags of + * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {string} tag The `toStringTag` of the objects to compare. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ +function equalByTag(object, other, tag) { + switch (tag) { + case boolTag: + case dateTag: + // Coerce dates and booleans to numbers, dates to milliseconds and booleans + // to `1` or `0` treating invalid dates coerced to `NaN` as not equal. + return +object == +other; + + case errorTag: + return object.name == other.name && object.message == other.message; + + case numberTag: + // Treat `NaN` vs. `NaN` as equal. + return (object != +object) + ? other != +other + : object == +other; + + case regexpTag: + case stringTag: + // Coerce regexes to strings and treat strings primitives and string + // objects as equal. See https://es5.github.io/#x15.10.6.4 for more details. + return object == (other + ''); + } + return false; +} + +module.exports = equalByTag; + +},{}],109:[function(require,module,exports){ +var keys = require('../object/keys'); + +/** Used for native method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; - if (this.path) { - str.push('path=' + this.path); - } +/** + * A specialized version of `baseIsEqualDeep` for objects with support for + * partial deep comparisons. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Function} [customizer] The function to customize comparing values. + * @param {boolean} [isLoose] Specify performing partial comparisons. + * @param {Array} [stackA] Tracks traversed `value` objects. + * @param {Array} [stackB] Tracks traversed `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ +function equalObjects(object, other, equalFunc, customizer, isLoose, stackA, stackB) { + var objProps = keys(object), + objLength = objProps.length, + othProps = keys(other), + othLength = othProps.length; + + if (objLength != othLength && !isLoose) { + return false; + } + var index = objLength; + while (index--) { + var key = objProps[index]; + if (!(isLoose ? key in other : hasOwnProperty.call(other, key))) { + return false; + } + } + var skipCtor = isLoose; + while (++index < objLength) { + key = objProps[index]; + var objValue = object[key], + othValue = other[key], + result = customizer ? customizer(isLoose ? othValue : objValue, isLoose? objValue : othValue, key) : undefined; + + // Recursively compare objects (susceptible to call stack limits). + if (!(result === undefined ? equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB) : result)) { + return false; + } + skipCtor || (skipCtor = key == 'constructor'); + } + if (!skipCtor) { + var objCtor = object.constructor, + othCtor = other.constructor; + + // Non `Object` object instances with different constructors are not equal. + if (objCtor != othCtor && + ('constructor' in object && 'constructor' in other) && + !(typeof objCtor == 'function' && objCtor instanceof objCtor && + typeof othCtor == 'function' && othCtor instanceof othCtor)) { + return false; + } + } + return true; +} - if (this.secure) { - str.push('secure'); - } +module.exports = equalObjects; - if (this.noscript) { - str.push('httponly'); - } +},{"../object/keys":149}],110:[function(require,module,exports){ +var metaMap = require('./metaMap'), + noop = require('../utility/noop'); - return str.join('; '); - }; - - Cookie.prototype.toValueString = function toValueString() { - return this.name + '=' + this.value; - }; - - var cookie_str_splitter = /[:](?=\s*[a-zA-Z0-9_\-]+\s*[=])/g; - - Cookie.prototype.parse = function parse(str, request_domain, request_path) { - if (this instanceof Cookie) { - var parts = str.split(';').filter(function (value) { - return !!value; - }), - pair = parts[0].match(/([^=]+)=([\s\S]*)/), - key = pair[1], - value = pair[2], - i; - - this.name = key; - this.value = value; - - for (i = 1; i < parts.length; i += 1) { - pair = parts[i].match(/([^=]+)(?:=([\s\S]*))?/); - key = pair[1].trim().toLowerCase(); - value = pair[2]; - - switch (key) { - case 'httponly': - this.noscript = true; - break; - - case 'expires': - this.expiration_date = value ? - Number(Date.parse(value)) : - Infinity; - break; - - case 'path': - this.path = value ? - value.trim() : - ''; - this.explicit_path = true; - break; - - case 'domain': - this.domain = value ? - value.trim() : - ''; - this.explicit_domain = !!this.domain; - break; - - case 'secure': - this.secure = true; - break; - } - } +/** + * Gets metadata for `func`. + * + * @private + * @param {Function} func The function to query. + * @returns {*} Returns the metadata for `func`. + */ +var getData = !metaMap ? noop : function(func) { + return metaMap.get(func); +}; - if (!this.explicit_path) { - this.path = request_path || '/'; - } +module.exports = getData; - if (!this.explicit_domain) { - this.domain = request_domain; - } +},{"../utility/noop":155,"./metaMap":129}],111:[function(require,module,exports){ +var realNames = require('./realNames'); - return this; - } +/** + * Gets the name of `func`. + * + * @private + * @param {Function} func The function to query. + * @returns {string} Returns the function name. + */ +function getFuncName(func) { + var result = (func.name + ''), + array = realNames[result], + length = array ? array.length : 0; + + while (length--) { + var data = array[length], + otherFunc = data.func; + if (otherFunc == null || otherFunc == func) { + return data.name; + } + } + return result; +} - return new Cookie().parse(str, request_domain, request_path); - }; +module.exports = getFuncName; - Cookie.prototype.matches = function matches(access_info) { - if (this.noscript && access_info.script || - this.secure && !access_info.secure || - !this.collidesWith(access_info)) { - return false; - } +},{"./realNames":130}],112:[function(require,module,exports){ +var baseProperty = require('./baseProperty'); - return true; - }; +/** + * Gets the "length" property value of `object`. + * + * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) + * that affects Safari on at least iOS 8.1-8.3 ARM64. + * + * @private + * @param {Object} object The object to query. + * @returns {*} Returns the "length" value. + */ +var getLength = baseProperty('length'); - Cookie.prototype.collidesWith = function collidesWith(access_info) { - if (this.path && !access_info.path || this.domain && !access_info.domain) { - return false; - } +module.exports = getLength; - if (this.path && access_info.path.indexOf(this.path) !== 0) { - return false; - } +},{"./baseProperty":86}],113:[function(require,module,exports){ +var isStrictComparable = require('./isStrictComparable'), + pairs = require('../object/pairs'); - if (!this.explicit_path) { - if (this.path !== access_info.path) { - return false; - } - } - var access_domain = access_info.domain && access_info.domain.replace(/^[\.]/, ''); - var cookie_domain = this.domain && this.domain.replace(/^[\.]/, ''); +/** + * Gets the propery names, values, and compare flags of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the match data of `object`. + */ +function getMatchData(object) { + var result = pairs(object), + length = result.length; - if (cookie_domain === access_domain) { - return true; - } + while (length--) { + result[length][2] = isStrictComparable(result[length][1]); + } + return result; +} - if (cookie_domain) { - if (!this.explicit_domain) { - return false; // we already checked if the domains were exactly the same - } - var wildcard = access_domain.indexOf(cookie_domain); +module.exports = getMatchData; - if (wildcard === -1 || wildcard !== access_domain.length - cookie_domain.length) { - return false; - } +},{"../object/pairs":151,"./isStrictComparable":127}],114:[function(require,module,exports){ +var isNative = require('../lang/isNative'); - return true; - } +/** + * Gets the native function at `key` of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {string} key The key of the method to get. + * @returns {*} Returns the function if it's native, else `undefined`. + */ +function getNative(object, key) { + var value = object == null ? undefined : object[key]; + return isNative(value) ? value : undefined; +} - return true; - }; +module.exports = getNative; - function CookieJar() { - var cookies, cookies_list, collidable_cookie; +},{"../lang/isNative":143}],115:[function(require,module,exports){ +/** + * Gets the index at which the first occurrence of `NaN` is found in `array`. + * + * @private + * @param {Array} array The array to search. + * @param {number} fromIndex The index to search from. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {number} Returns the index of the matched `NaN`, else `-1`. + */ +function indexOfNaN(array, fromIndex, fromRight) { + var length = array.length, + index = fromIndex + (fromRight ? 0 : -1); + + while ((fromRight ? index-- : ++index < length)) { + var other = array[index]; + if (other !== other) { + return index; + } + } + return -1; +} - if (this instanceof CookieJar) { - cookies = Object.create(null); //name: [Cookie] +module.exports = indexOfNaN; - this.setCookie = function setCookie(cookie, request_domain, request_path) { - var remove, i; +},{}],116:[function(require,module,exports){ +/** Used for native method references. */ +var objectProto = Object.prototype; - cookie = new Cookie(cookie, request_domain, request_path); - //Delete the cookie if the set is past the current time - remove = cookie.expiration_date <= Date.now(); +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; - if (cookies[cookie.name] !== undefined) { - cookies_list = cookies[cookie.name]; +/** + * Initializes an array clone. + * + * @private + * @param {Array} array The array to clone. + * @returns {Array} Returns the initialized clone. + */ +function initCloneArray(array) { + var length = array.length, + result = new array.constructor(length); + + // Add array properties assigned by `RegExp#exec`. + if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { + result.index = array.index; + result.input = array.input; + } + return result; +} + +module.exports = initCloneArray; + +},{}],117:[function(require,module,exports){ +(function (global){ +var bufferClone = require('./bufferClone'); + +/** `Object#toString` result references. */ +var boolTag = '[object Boolean]', + dateTag = '[object Date]', + numberTag = '[object Number]', + regexpTag = '[object RegExp]', + stringTag = '[object String]'; + +var arrayBufferTag = '[object ArrayBuffer]', + float32Tag = '[object Float32Array]', + float64Tag = '[object Float64Array]', + int8Tag = '[object Int8Array]', + int16Tag = '[object Int16Array]', + int32Tag = '[object Int32Array]', + uint8Tag = '[object Uint8Array]', + uint8ClampedTag = '[object Uint8ClampedArray]', + uint16Tag = '[object Uint16Array]', + uint32Tag = '[object Uint32Array]'; + +/** Used to match `RegExp` flags from their coerced string values. */ +var reFlags = /\w*$/; + +/** Native method references. */ +var Uint8Array = global.Uint8Array; + +/** Used to lookup a type array constructors by `toStringTag`. */ +var ctorByTag = {}; +ctorByTag[float32Tag] = global.Float32Array; +ctorByTag[float64Tag] = global.Float64Array; +ctorByTag[int8Tag] = global.Int8Array; +ctorByTag[int16Tag] = global.Int16Array; +ctorByTag[int32Tag] = global.Int32Array; +ctorByTag[uint8Tag] = Uint8Array; +ctorByTag[uint8ClampedTag] = global.Uint8ClampedArray; +ctorByTag[uint16Tag] = global.Uint16Array; +ctorByTag[uint32Tag] = global.Uint32Array; - for (i = 0; i < cookies_list.length; i += 1) { - collidable_cookie = cookies_list[i]; +/** + * Initializes an object clone based on its `toStringTag`. + * + * **Note:** This function only supports cloning values with tags of + * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. + * + * @private + * @param {Object} object The object to clone. + * @param {string} tag The `toStringTag` of the object to clone. + * @param {boolean} [isDeep] Specify a deep clone. + * @returns {Object} Returns the initialized clone. + */ +function initCloneByTag(object, tag, isDeep) { + var Ctor = object.constructor; + switch (tag) { + case arrayBufferTag: + return bufferClone(object); + + case boolTag: + case dateTag: + return new Ctor(+object); + + case float32Tag: case float64Tag: + case int8Tag: case int16Tag: case int32Tag: + case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: + // Safari 5 mobile incorrectly has `Object` as the constructor of typed arrays. + if (Ctor instanceof Ctor) { + Ctor = ctorByTag[tag]; + } + var buffer = object.buffer; + return new Ctor(isDeep ? bufferClone(buffer) : buffer, object.byteOffset, object.length); + + case numberTag: + case stringTag: + return new Ctor(object); + + case regexpTag: + var result = new Ctor(object.source, reFlags.exec(object)); + result.lastIndex = object.lastIndex; + } + return result; +} + +module.exports = initCloneByTag; + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) + +},{"./bufferClone":95}],118:[function(require,module,exports){ +/** + * Initializes an object clone. + * + * @private + * @param {Object} object The object to clone. + * @returns {Object} Returns the initialized clone. + */ +function initCloneObject(object) { + var Ctor = object.constructor; + if (!(typeof Ctor == 'function' && Ctor instanceof Ctor)) { + Ctor = Object; + } + return new Ctor; +} - if (collidable_cookie.collidesWith(cookie)) { - if (remove) { - cookies_list.splice(i, 1); +module.exports = initCloneObject; - if (cookies_list.length === 0) { - delete cookies[cookie.name]; - } +},{}],119:[function(require,module,exports){ +var getLength = require('./getLength'), + isLength = require('./isLength'); - return false; - } - cookies_list[i] = cookie; +/** + * Checks if `value` is array-like. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is array-like, else `false`. + */ +function isArrayLike(value) { + return value != null && isLength(getLength(value)); +} - return cookie; - } - } +module.exports = isArrayLike; - if (remove) { - return false; - } - cookies_list.push(cookie); +},{"./getLength":112,"./isLength":125}],120:[function(require,module,exports){ +/** + * Checks if `value` is a host object in IE < 9. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a host object, else `false`. + */ +var isHostObject = (function() { + try { + Object({ 'toString': 0 } + ''); + } catch(e) { + return function() { return false; }; + } + return function(value) { + // IE < 9 presents many host objects as `Object` objects that can coerce + // to strings despite having improperly defined `toString` methods. + return typeof value.toString != 'function' && typeof (value + '') == 'string'; + }; +}()); + +module.exports = isHostObject; + +},{}],121:[function(require,module,exports){ +/** Used to detect unsigned integer values. */ +var reIsUint = /^\d+$/; - return cookie; - } +/** + * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer) + * of an array-like value. + */ +var MAX_SAFE_INTEGER = 9007199254740991; - if (remove) { - return false; - } - cookies[cookie.name] = [cookie]; +/** + * Checks if `value` is a valid array-like index. + * + * @private + * @param {*} value The value to check. + * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. + * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. + */ +function isIndex(value, length) { + value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1; + length = length == null ? MAX_SAFE_INTEGER : length; + return value > -1 && value % 1 == 0 && value < length; +} - return cookies[cookie.name]; - }; - //returns a cookie - this.getCookie = function getCookie(cookie_name, access_info) { - var cookie, i; +module.exports = isIndex; - cookies_list = cookies[cookie_name]; +},{}],122:[function(require,module,exports){ +var isArrayLike = require('./isArrayLike'), + isIndex = require('./isIndex'), + isObject = require('../lang/isObject'); - if (!cookies_list) { - return; - } +/** + * Checks if the provided arguments are from an iteratee call. + * + * @private + * @param {*} value The potential iteratee value argument. + * @param {*} index The potential iteratee index or key argument. + * @param {*} object The potential iteratee object argument. + * @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`. + */ +function isIterateeCall(value, index, object) { + if (!isObject(object)) { + return false; + } + var type = typeof index; + if (type == 'number' + ? (isArrayLike(object) && isIndex(index, object.length)) + : (type == 'string' && index in object)) { + var other = object[index]; + return value === value ? (value === other) : (other !== other); + } + return false; +} + +module.exports = isIterateeCall; + +},{"../lang/isObject":144,"./isArrayLike":119,"./isIndex":121}],123:[function(require,module,exports){ +var isArray = require('../lang/isArray'), + toObject = require('./toObject'); + +/** Used to match property names within property paths. */ +var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/, + reIsPlainProp = /^\w*$/; - for (i = 0; i < cookies_list.length; i += 1) { - cookie = cookies_list[i]; +/** + * Checks if `value` is a property name and not a property path. + * + * @private + * @param {*} value The value to check. + * @param {Object} [object] The object to query keys on. + * @returns {boolean} Returns `true` if `value` is a property name, else `false`. + */ +function isKey(value, object) { + var type = typeof value; + if ((type == 'string' && reIsPlainProp.test(value)) || type == 'number') { + return true; + } + if (isArray(value)) { + return false; + } + var result = !reIsDeepProp.test(value); + return result || (object != null && value in toObject(object)); +} + +module.exports = isKey; + +},{"../lang/isArray":140,"./toObject":135}],124:[function(require,module,exports){ +var LazyWrapper = require('./LazyWrapper'), + getData = require('./getData'), + getFuncName = require('./getFuncName'), + lodash = require('../chain/lodash'); - if (cookie.expiration_date <= Date.now()) { - if (cookies_list.length === 0) { - delete cookies[cookie.name]; - } - continue; - } +/** + * Checks if `func` has a lazy counterpart. + * + * @private + * @param {Function} func The function to check. + * @returns {boolean} Returns `true` if `func` has a lazy counterpart, else `false`. + */ +function isLaziable(func) { + var funcName = getFuncName(func), + other = lodash[funcName]; + + if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) { + return false; + } + if (func === other) { + return true; + } + var data = getData(other); + return !!data && func === data[0]; +} + +module.exports = isLaziable; + +},{"../chain/lodash":51,"./LazyWrapper":60,"./getData":110,"./getFuncName":111}],125:[function(require,module,exports){ +/** + * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer) + * of an array-like value. + */ +var MAX_SAFE_INTEGER = 9007199254740991; - if (cookie.matches(access_info)) { - return cookie; - } - } - }; - //returns a list of cookies - this.getCookies = function getCookies(access_info) { - var matches = [], - cookie_name, cookie; +/** + * Checks if `value` is a valid array-like length. + * + * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. + */ +function isLength(value) { + return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; +} - for (cookie_name in cookies) { - cookie = this.getCookie(cookie_name, access_info); +module.exports = isLength; - if (cookie) { - matches.push(cookie); - } - } - matches.toString = function toString() { - return matches.join(':'); - }; - matches.toValueString = function toValueString() { - return matches.map(function (c) { - return c.toValueString(); - }).join(';'); - }; - - return matches; - }; - - return this; - } +},{}],126:[function(require,module,exports){ +/** + * Checks if `value` is object-like. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is object-like, else `false`. + */ +function isObjectLike(value) { + return !!value && typeof value == 'object'; +} - return new CookieJar(); - } - exports.CookieJar = CookieJar; +module.exports = isObjectLike; - //returns list of cookies that were set correctly. Cookies that are expired and removed are not returned. - CookieJar.prototype.setCookies = function setCookies(cookies, request_domain, request_path) { - cookies = Array.isArray(cookies) ? - cookies : - cookies.split(cookie_str_splitter); - var successful = [], - i, - cookie; +},{}],127:[function(require,module,exports){ +var isObject = require('../lang/isObject'); - cookies = cookies.map(Cookie); +/** + * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` if suitable for strict + * equality comparisons, else `false`. + */ +function isStrictComparable(value) { + return value === value && !isObject(value); +} - for (i = 0; i < cookies.length; i += 1) { - cookie = cookies[i]; +module.exports = isStrictComparable; - if (this.setCookie(cookie, request_domain, request_path)) { - successful.push(cookie); - } - } +},{"../lang/isObject":144}],128:[function(require,module,exports){ +var arrayCopy = require('./arrayCopy'), + composeArgs = require('./composeArgs'), + composeArgsRight = require('./composeArgsRight'), + replaceHolders = require('./replaceHolders'); - return successful; - }; - }()); - - },{}],20: [function (require, module, exports) { - /*! - * jQuery JavaScript Library v2.1.4 - * http://jquery.com/ - * - * Includes Sizzle.js - * http://sizzlejs.com/ - * - * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors - * Released under the MIT license - * http://jquery.org/license - * - * Date: 2015-04-28T16:01Z - */ +/** Used to compose bitmasks for wrapper metadata. */ +var BIND_FLAG = 1, + CURRY_BOUND_FLAG = 4, + CURRY_FLAG = 8, + ARY_FLAG = 128, + REARG_FLAG = 256; - (function (global, factory) { - - if (typeof module === 'object' && typeof module.exports === 'object') { - // For CommonJS and CommonJS-like environments where a proper `window` - // is present, execute the factory and get jQuery. - // For environments that do not have a `window` with a `document` - // (such as Node.js), expose a factory as module.exports. - // This accentuates the need for the creation of a real `window`. - // e.g. var jQuery = require("jquery")(window); - // See ticket #14549 for more info. - module.exports = global.document ? - factory(global, true) : - function (w) { - if (!w.document) { - throw new Error('jQuery requires a window with a document'); - } +/** Used as the internal argument placeholder. */ +var PLACEHOLDER = '__lodash_placeholder__'; - return factory(w); - }; - } else { - factory(global); - } +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeMin = Math.min; - // Pass this if window is not defined yet - }(typeof window !== 'undefined' ? window : this, function (window, noGlobal) { +/** + * Merges the function metadata of `source` into `data`. + * + * Merging metadata reduces the number of wrappers required to invoke a function. + * This is possible because methods like `_.bind`, `_.curry`, and `_.partial` + * may be applied regardless of execution order. Methods like `_.ary` and `_.rearg` + * augment function arguments, making the order in which they are executed important, + * preventing the merging of metadata. However, we make an exception for a safe + * common case where curried functions have `_.ary` and or `_.rearg` applied. + * + * @private + * @param {Array} data The destination metadata. + * @param {Array} source The source metadata. + * @returns {Array} Returns `data`. + */ +function mergeData(data, source) { + var bitmask = data[1], + srcBitmask = source[1], + newBitmask = bitmask | srcBitmask, + isCommon = newBitmask < ARY_FLAG; + + var isCombo = + (srcBitmask == ARY_FLAG && bitmask == CURRY_FLAG) || + (srcBitmask == ARY_FLAG && bitmask == REARG_FLAG && data[7].length <= source[8]) || + (srcBitmask == (ARY_FLAG | REARG_FLAG) && bitmask == CURRY_FLAG); + + // Exit early if metadata can't be merged. + if (!(isCommon || isCombo)) { + return data; + } + // Use source `thisArg` if available. + if (srcBitmask & BIND_FLAG) { + data[2] = source[2]; + // Set when currying a bound function. + newBitmask |= (bitmask & BIND_FLAG) ? 0 : CURRY_BOUND_FLAG; + } + // Compose partial arguments. + var value = source[3]; + if (value) { + var partials = data[3]; + data[3] = partials ? composeArgs(partials, value, source[4]) : arrayCopy(value); + data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : arrayCopy(source[4]); + } + // Compose partial right arguments. + value = source[5]; + if (value) { + partials = data[5]; + data[5] = partials ? composeArgsRight(partials, value, source[6]) : arrayCopy(value); + data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : arrayCopy(source[6]); + } + // Use source `argPos` if available. + value = source[7]; + if (value) { + data[7] = arrayCopy(value); + } + // Use source `ary` if it's smaller. + if (srcBitmask & ARY_FLAG) { + data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]); + } + // Use source `arity` if one is not provided. + if (data[9] == null) { + data[9] = source[9]; + } + // Use source `func` and merge bitmasks. + data[0] = source[0]; + data[1] = newBitmask; + + return data; +} + +module.exports = mergeData; + +},{"./arrayCopy":62,"./composeArgs":96,"./composeArgsRight":97,"./replaceHolders":132}],129:[function(require,module,exports){ +(function (global){ +var getNative = require('./getNative'); + +/** Native method references. */ +var WeakMap = getNative(global, 'WeakMap'); + +/** Used to store function metadata. */ +var metaMap = WeakMap && new WeakMap; + +module.exports = metaMap; + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) + +},{"./getNative":114}],130:[function(require,module,exports){ +/** Used to lookup unminified function names. */ +var realNames = {}; + +module.exports = realNames; + +},{}],131:[function(require,module,exports){ +var arrayCopy = require('./arrayCopy'), + isIndex = require('./isIndex'); + +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeMin = Math.min; - // Support: Firefox 18+ - // Can't be in strict mode, several libs including ASP.NET trace - // the stack via arguments.caller.callee and Firefox dies if - // you try to trace through "use strict" call chains. (#13335) - // +/** + * Reorder `array` according to the specified indexes where the element at + * the first index is assigned as the first element, the element at + * the second index is assigned as the second element, and so on. + * + * @private + * @param {Array} array The array to reorder. + * @param {Array} indexes The arranged array indexes. + * @returns {Array} Returns `array`. + */ +function reorder(array, indexes) { + var arrLength = array.length, + length = nativeMin(indexes.length, arrLength), + oldArray = arrayCopy(array); - var arr = []; + while (length--) { + var index = indexes[length]; + array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined; + } + return array; +} - var slice = arr.slice; +module.exports = reorder; - var concat = arr.concat; +},{"./arrayCopy":62,"./isIndex":121}],132:[function(require,module,exports){ +/** Used as the internal argument placeholder. */ +var PLACEHOLDER = '__lodash_placeholder__'; - var push = arr.push; +/** + * Replaces all `placeholder` elements in `array` with an internal placeholder + * and returns an array of their indexes. + * + * @private + * @param {Array} array The array to modify. + * @param {*} placeholder The placeholder to replace. + * @returns {Array} Returns the new array of placeholder indexes. + */ +function replaceHolders(array, placeholder) { + var index = -1, + length = array.length, + resIndex = -1, + result = []; + + while (++index < length) { + if (array[index] === placeholder) { + array[index] = PLACEHOLDER; + result[++resIndex] = index; + } + } + return result; +} - var indexOf = arr.indexOf; +module.exports = replaceHolders; - var class2type = {}; +},{}],133:[function(require,module,exports){ +var baseSetData = require('./baseSetData'), + now = require('../date/now'); - var toString = class2type.toString; +/** Used to detect when a function becomes hot. */ +var HOT_COUNT = 150, + HOT_SPAN = 16; - var hasOwn = class2type.hasOwnProperty; +/** + * Sets metadata for `func`. + * + * **Note:** If this function becomes hot, i.e. is invoked a lot in a short + * period of time, it will trip its breaker and transition to an identity function + * to avoid garbage collection pauses in V8. See [V8 issue 2070](https://code.google.com/p/v8/issues/detail?id=2070) + * for more details. + * + * @private + * @param {Function} func The function to associate metadata with. + * @param {*} data The metadata. + * @returns {Function} Returns `func`. + */ +var setData = (function() { + var count = 0, + lastCalled = 0; + + return function(key, value) { + var stamp = now(), + remaining = HOT_SPAN - (stamp - lastCalled); + + lastCalled = stamp; + if (remaining > 0) { + if (++count >= HOT_COUNT) { + return key; + } + } else { + count = 0; + } + return baseSetData(key, value); + }; +}()); - var support = {}; +module.exports = setData; - var - // Use the correct document accordingly with window argument (sandbox) - document = window.document, +},{"../date/now":57,"./baseSetData":88}],134:[function(require,module,exports){ +var isArguments = require('../lang/isArguments'), + isArray = require('../lang/isArray'), + isIndex = require('./isIndex'), + isLength = require('./isLength'), + isString = require('../lang/isString'), + keysIn = require('../object/keysIn'); - version = '2.1.4', +/** Used for native method references. */ +var objectProto = Object.prototype; - // Define a local copy of jQuery - jQuery = function (selector, context) { - // The jQuery object is actually just the init constructor 'enhanced' - // Need init if jQuery is called (just allow error to be thrown if not included) - return new jQuery.fn.init(selector, context); - }, +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; - // Support: Android<4.1 - // Make sure we trim BOM and NBSP - rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, +/** + * A fallback implementation of `Object.keys` which creates an array of the + * own enumerable property names of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ +function shimKeys(object) { + var props = keysIn(object), + propsLength = props.length, + length = propsLength && object.length; - // Matches dashed string for camelizing - rmsPrefix = /^-ms-/, - rdashAlpha = /-([\da-z])/gi, + var allowIndexes = !!length && isLength(length) && + (isArray(object) || isArguments(object) || isString(object)); - // Used by jQuery.camelCase as callback to replace() - fcamelCase = function (all, letter) { - return letter.toUpperCase(); - }; + var index = -1, + result = []; - jQuery.fn = jQuery.prototype = { - // The current version of jQuery being used - jquery: version, + while (++index < propsLength) { + var key = props[index]; + if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) { + result.push(key); + } + } + return result; +} - constructor: jQuery, +module.exports = shimKeys; - // Start with an empty selector - selector: '', +},{"../lang/isArguments":139,"../lang/isArray":140,"../lang/isString":146,"../object/keysIn":150,"./isIndex":121,"./isLength":125}],135:[function(require,module,exports){ +var isObject = require('../lang/isObject'), + isString = require('../lang/isString'), + support = require('../support'); - // The default length of a jQuery object is 0 - length: 0, +/** + * Converts `value` to an object if it's not one. + * + * @private + * @param {*} value The value to process. + * @returns {Object} Returns the object. + */ +function toObject(value) { + if (support.unindexedChars && isString(value)) { + var index = -1, + length = value.length, + result = Object(value); + + while (++index < length) { + result[index] = value.charAt(index); + } + return result; + } + return isObject(value) ? value : Object(value); +} - toArray: function () { - return slice.call(this); - }, +module.exports = toObject; - // Get the Nth element in the matched element set OR - // Get the whole matched element set as a clean array - get: function (num) { - return num != null ? +},{"../lang/isObject":144,"../lang/isString":146,"../support":153}],136:[function(require,module,exports){ +var baseToString = require('./baseToString'), + isArray = require('../lang/isArray'); - // Return just the one element from the set - num < 0 ? this[ num + this.length ] : this[ num ] : +/** Used to match property names within property paths. */ +var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g; - // Return all the elements in a clean array - slice.call(this); - }, +/** Used to match backslashes in property paths. */ +var reEscapeChar = /\\(\\)?/g; - // Take an array of elements and push it onto the stack - // (returning the new matched element set) - pushStack: function (elems) { +/** + * Converts `value` to property path array if it's not one. + * + * @private + * @param {*} value The value to process. + * @returns {Array} Returns the property path array. + */ +function toPath(value) { + if (isArray(value)) { + return value; + } + var result = []; + baseToString(value).replace(rePropName, function(match, number, quote, string) { + result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match)); + }); + return result; +} + +module.exports = toPath; + +},{"../lang/isArray":140,"./baseToString":90}],137:[function(require,module,exports){ +var LazyWrapper = require('./LazyWrapper'), + LodashWrapper = require('./LodashWrapper'), + arrayCopy = require('./arrayCopy'); - // Build a new jQuery matched element set - var ret = jQuery.merge(this.constructor(), elems); +/** + * Creates a clone of `wrapper`. + * + * @private + * @param {Object} wrapper The wrapper to clone. + * @returns {Object} Returns the cloned wrapper. + */ +function wrapperClone(wrapper) { + return wrapper instanceof LazyWrapper + ? wrapper.clone() + : new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__, arrayCopy(wrapper.__actions__)); +} - // Add the old object onto the stack (as a reference) - ret.prevObject = this; - ret.context = this.context; +module.exports = wrapperClone; - // Return the newly-formed element set - return ret; - }, +},{"./LazyWrapper":60,"./LodashWrapper":61,"./arrayCopy":62}],138:[function(require,module,exports){ +var baseClone = require('../internal/baseClone'), + bindCallback = require('../internal/bindCallback'); - // Execute a callback for every element in the matched set. - // (You can seed the arguments with an array of args, but this is - // only used internally.) - each: function (callback, args) { - return jQuery.each(this, callback, args); - }, +/** + * Creates a deep clone of `value`. If `customizer` is provided it's invoked + * to produce the cloned values. If `customizer` returns `undefined` cloning + * is handled by the method instead. The `customizer` is bound to `thisArg` + * and invoked with up to three argument; (value [, index|key, object]). + * + * **Note:** This method is loosely based on the + * [structured clone algorithm](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm). + * The enumerable properties of `arguments` objects and objects created by + * constructors other than `Object` are cloned to plain `Object` objects. An + * empty object is returned for uncloneable values such as functions, DOM nodes, + * Maps, Sets, and WeakMaps. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to deep clone. + * @param {Function} [customizer] The function to customize cloning values. + * @param {*} [thisArg] The `this` binding of `customizer`. + * @returns {*} Returns the deep cloned value. + * @example + * + * var users = [ + * { 'user': 'barney' }, + * { 'user': 'fred' } + * ]; + * + * var deep = _.cloneDeep(users); + * deep[0] === users[0]; + * // => false + * + * // using a customizer callback + * var el = _.cloneDeep(document.body, function(value) { + * if (_.isElement(value)) { + * return value.cloneNode(true); + * } + * }); + * + * el === document.body + * // => false + * el.nodeName + * // => BODY + * el.childNodes.length; + * // => 20 + */ +function cloneDeep(value, customizer, thisArg) { + return typeof customizer == 'function' + ? baseClone(value, true, bindCallback(customizer, thisArg, 3)) + : baseClone(value, true); +} - map: function (callback) { - return this.pushStack(jQuery.map(this, function (elem, i) { - return callback.call(elem, i, elem); - })); - }, +module.exports = cloneDeep; - slice: function () { - return this.pushStack(slice.apply(this, arguments)); - }, +},{"../internal/baseClone":68,"../internal/bindCallback":94}],139:[function(require,module,exports){ +var isArrayLike = require('../internal/isArrayLike'), + isObjectLike = require('../internal/isObjectLike'); - first: function () { - return this.eq(0); - }, +/** Used for native method references. */ +var objectProto = Object.prototype; - last: function () { - return this.eq(-1); - }, +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; - eq: function (i) { - var len = this.length, - j = +i + (i < 0 ? len : 0); - - return this.pushStack(j >= 0 && j < len ? [this[j]] : []); - }, - - end: function () { - return this.prevObject || this.constructor(null); - }, - - // For internal use only. - // Behaves like an Array's method, not like a jQuery method. - push: push, - sort: arr.sort, - splice: arr.splice - }; - - jQuery.extend = jQuery.fn.extend = function () { - var options, name, src, copy, copyIsArray, clone, - target = arguments[0] || {}, - i = 1, - length = arguments.length, - deep = false; - - // Handle a deep copy situation - if (typeof target === 'boolean') { - deep = target; - - // Skip the boolean and the target - target = arguments[ i ] || {}; - i++; - } +/** Native method references. */ +var propertyIsEnumerable = objectProto.propertyIsEnumerable; - // Handle case when target is a string or something (possible in deep copy) - if (typeof target !== 'object' && !jQuery.isFunction(target)) { - target = {}; - } +/** + * Checks if `value` is classified as an `arguments` object. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @example + * + * _.isArguments(function() { return arguments; }()); + * // => true + * + * _.isArguments([1, 2, 3]); + * // => false + */ +function isArguments(value) { + return isObjectLike(value) && isArrayLike(value) && + hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee'); +} - // Extend jQuery itself if only one argument is passed - if (i === length) { - target = this; - i--; - } +module.exports = isArguments; - for (; i < length; i++) { - // Only deal with non-null/undefined values - if ((options = arguments[ i ]) != null) { - // Extend the base object - for (name in options) { - src = target[ name ]; - copy = options[ name ]; - - // Prevent never-ending loop - if (target === copy) { - continue; - } +},{"../internal/isArrayLike":119,"../internal/isObjectLike":126}],140:[function(require,module,exports){ +var getNative = require('../internal/getNative'), + isLength = require('../internal/isLength'), + isObjectLike = require('../internal/isObjectLike'); - // Recurse if we're merging plain objects or arrays - if (deep && copy && (jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)))) { - if (copyIsArray) { - copyIsArray = false; - clone = src && jQuery.isArray(src) ? src : []; +/** `Object#toString` result references. */ +var arrayTag = '[object Array]'; - } else { - clone = src && jQuery.isPlainObject(src) ? src : {}; - } +/** Used for native method references. */ +var objectProto = Object.prototype; - // Never move original objects, clone them - target[ name ] = jQuery.extend(deep, clone, copy); +/** + * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * of values. + */ +var objToString = objectProto.toString; - // Don't bring in undefined values - } else if (copy !== undefined) { - target[ name ] = copy; - } - } - } - } +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeIsArray = getNative(Array, 'isArray'); - // Return the modified object - return target; - }; +/** + * Checks if `value` is classified as an `Array` object. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @example + * + * _.isArray([1, 2, 3]); + * // => true + * + * _.isArray(function() { return arguments; }()); + * // => false + */ +var isArray = nativeIsArray || function(value) { + return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag; +}; - jQuery.extend({ - // Unique for each copy of jQuery on the page - expando: 'jQuery' + (version + Math.random()).replace(/\D/g, ''), +module.exports = isArray; - // Assume jQuery is ready without the ready module - isReady: true, +},{"../internal/getNative":114,"../internal/isLength":125,"../internal/isObjectLike":126}],141:[function(require,module,exports){ +var isArguments = require('./isArguments'), + isArray = require('./isArray'), + isArrayLike = require('../internal/isArrayLike'), + isFunction = require('./isFunction'), + isObjectLike = require('../internal/isObjectLike'), + isString = require('./isString'), + keys = require('../object/keys'); - error: function (msg) { - throw new Error(msg); - }, +/** + * Checks if `value` is empty. A value is considered empty unless it's an + * `arguments` object, array, string, or jQuery-like collection with a length + * greater than `0` or an object with own enumerable properties. + * + * @static + * @memberOf _ + * @category Lang + * @param {Array|Object|string} value The value to inspect. + * @returns {boolean} Returns `true` if `value` is empty, else `false`. + * @example + * + * _.isEmpty(null); + * // => true + * + * _.isEmpty(true); + * // => true + * + * _.isEmpty(1); + * // => true + * + * _.isEmpty([1, 2, 3]); + * // => false + * + * _.isEmpty({ 'a': 1 }); + * // => false + */ +function isEmpty(value) { + if (value == null) { + return true; + } + if (isArrayLike(value) && (isArray(value) || isString(value) || isArguments(value) || + (isObjectLike(value) && isFunction(value.splice)))) { + return !value.length; + } + return !keys(value).length; +} - noop: function () {}, +module.exports = isEmpty; - isFunction: function (obj) { - return jQuery.type(obj) === 'function'; - }, +},{"../internal/isArrayLike":119,"../internal/isObjectLike":126,"../object/keys":149,"./isArguments":139,"./isArray":140,"./isFunction":142,"./isString":146}],142:[function(require,module,exports){ +var isObject = require('./isObject'); - isArray: Array.isArray, +/** `Object#toString` result references. */ +var funcTag = '[object Function]'; - isWindow: function (obj) { - return obj != null && obj === obj.window; - }, +/** Used for native method references. */ +var objectProto = Object.prototype; - isNumeric: function (obj) { - // parseFloat NaNs numeric-cast false positives (null|true|false|"") - // ...but misinterprets leading-number strings, particularly hex literals ("0x...") - // subtraction forces infinities to NaN - // adding 1 corrects loss of precision from parseFloat (#15100) - return !jQuery.isArray(obj) && obj - parseFloat(obj) + 1 >= 0; - }, +/** + * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * of values. + */ +var objToString = objectProto.toString; - isPlainObject: function (obj) { - // Not plain objects: - // - Any object or value whose internal [[Class]] property is not "[object Object]" - // - DOM nodes - // - window - if (jQuery.type(obj) !== 'object' || obj.nodeType || jQuery.isWindow(obj)) { - return false; - } +/** + * Checks if `value` is classified as a `Function` object. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @example + * + * _.isFunction(_); + * // => true + * + * _.isFunction(/abc/); + * // => false + */ +function isFunction(value) { + // The use of `Object#toString` avoids issues with the `typeof` operator + // in older versions of Chrome and Safari which return 'function' for regexes + // and Safari 8 which returns 'object' for typed array constructors. + return isObject(value) && objToString.call(value) == funcTag; +} - if (obj.constructor && - !hasOwn.call(obj.constructor.prototype, 'isPrototypeOf')) { - return false; - } +module.exports = isFunction; - // If the function hasn't returned already, we're confident that - // |obj| is a plain object, created by {} or constructed with new Object - return true; - }, +},{"./isObject":144}],143:[function(require,module,exports){ +var isFunction = require('./isFunction'), + isHostObject = require('../internal/isHostObject'), + isObjectLike = require('../internal/isObjectLike'); - isEmptyObject: function (obj) { - var name; +/** Used to detect host constructors (Safari > 5). */ +var reIsHostCtor = /^\[object .+?Constructor\]$/; - for (name in obj) { - return false; - } +/** Used for native method references. */ +var objectProto = Object.prototype; - return true; - }, +/** Used to resolve the decompiled source of functions. */ +var fnToString = Function.prototype.toString; - type: function (obj) { - if (obj == null) { - return obj + ''; - } - // Support: Android<4.0, iOS<6 (functionish RegExp) - return typeof obj === 'object' || typeof obj === 'function' ? - class2type[ toString.call(obj) ] || 'object' : - typeof obj; - }, - - // Evaluates a script in a global context - globalEval: function (code) { - var script, - indirect = eval; - - code = jQuery.trim(code); - - if (code) { - // If the code includes a valid, prologue position - // strict mode pragma, execute code by injecting a - // script tag into the document. - if (code.indexOf('use strict') === 1) { - script = document.createElement('script'); - script.text = code; - document.head.appendChild(script).parentNode.removeChild(script); - } else { - // Otherwise, avoid the DOM node creation, insertion - // and removal by using an indirect global eval - indirect(code); - } - } - }, - - // Convert dashed to camelCase; used by the css and data modules - // Support: IE9-11+ - // Microsoft forgot to hump their vendor prefix (#9572) - camelCase: function (string) { - return string.replace(rmsPrefix, 'ms-').replace(rdashAlpha, fcamelCase); - }, - - nodeName: function (elem, name) { - return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); - }, - - // args is for internal usage only - each: function (obj, callback, args) { - var value, - i = 0, - length = obj.length, - isArray = isArraylike(obj); - - if (args) { - if (isArray) { - for (; i < length; i++) { - value = callback.apply(obj[ i ], args); - - if (value === false) { - break; - } - } - } else { - for (i in obj) { - value = callback.apply(obj[ i ], args); +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; - if (value === false) { - break; - } - } - } +/** Used to detect if a method is native. */ +var reIsNative = RegExp('^' + + fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&') + .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' +); - // A special, fast, case for the most common use of each - } else if (isArray) { - for (; i < length; i++) { - value = callback.call(obj[ i ], i, obj[ i ]); +/** + * Checks if `value` is a native function. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a native function, else `false`. + * @example + * + * _.isNative(Array.prototype.push); + * // => true + * + * _.isNative(_); + * // => false + */ +function isNative(value) { + if (value == null) { + return false; + } + if (isFunction(value)) { + return reIsNative.test(fnToString.call(value)); + } + return isObjectLike(value) && (isHostObject(value) ? reIsNative : reIsHostCtor).test(value); +} + +module.exports = isNative; + +},{"../internal/isHostObject":120,"../internal/isObjectLike":126,"./isFunction":142}],144:[function(require,module,exports){ +/** + * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`. + * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an object, else `false`. + * @example + * + * _.isObject({}); + * // => true + * + * _.isObject([1, 2, 3]); + * // => true + * + * _.isObject(1); + * // => false + */ +function isObject(value) { + // Avoid a V8 JIT bug in Chrome 19-20. + // See https://code.google.com/p/v8/issues/detail?id=2291 for more details. + var type = typeof value; + return !!value && (type == 'object' || type == 'function'); +} - if (value === false) { - break; - } - } - } else { - for (i in obj) { - value = callback.call(obj[ i ], i, obj[ i ]); +module.exports = isObject; - if (value === false) { - break; - } - } - } +},{}],145:[function(require,module,exports){ +var baseForIn = require('../internal/baseForIn'), + isArguments = require('./isArguments'), + isHostObject = require('../internal/isHostObject'), + isObjectLike = require('../internal/isObjectLike'), + support = require('../support'); - return obj; - }, - - // Support: Android<4.1 - trim: function (text) { - return text == null ? - '' : - (text + '').replace(rtrim, ''); - }, - - // results is for internal usage only - makeArray: function (arr, results) { - var ret = results || []; - - if (arr != null) { - if (isArraylike(Object(arr))) { - jQuery.merge(ret, - typeof arr === 'string' ? - [arr] : arr - ); - } else { - push.call(ret, arr); - } - } +/** `Object#toString` result references. */ +var objectTag = '[object Object]'; - return ret; - }, +/** Used for native method references. */ +var objectProto = Object.prototype; - inArray: function (elem, arr, i) { - return arr == null ? -1 : indexOf.call(arr, elem, i); - }, +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; - merge: function (first, second) { - var len = +second.length, - j = 0, - i = first.length; +/** + * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * of values. + */ +var objToString = objectProto.toString; - for (; j < len; j++) { - first[ i++ ] = second[ j ]; - } +/** + * Checks if `value` is a plain object, that is, an object created by the + * `Object` constructor or one with a `[[Prototype]]` of `null`. + * + * **Note:** This method assumes objects created by the `Object` constructor + * have no inherited enumerable properties. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. + * @example + * + * function Foo() { + * this.a = 1; + * } + * + * _.isPlainObject(new Foo); + * // => false + * + * _.isPlainObject([1, 2, 3]); + * // => false + * + * _.isPlainObject({ 'x': 0, 'y': 0 }); + * // => true + * + * _.isPlainObject(Object.create(null)); + * // => true + */ +function isPlainObject(value) { + var Ctor; + + // Exit early for non `Object` objects. + if (!(isObjectLike(value) && objToString.call(value) == objectTag && !isHostObject(value) && !isArguments(value)) || + (!hasOwnProperty.call(value, 'constructor') && (Ctor = value.constructor, typeof Ctor == 'function' && !(Ctor instanceof Ctor)))) { + return false; + } + // IE < 9 iterates inherited properties before own properties. If the first + // iterated property is an object's own property then there are no inherited + // enumerable properties. + var result; + if (support.ownLast) { + baseForIn(value, function(subValue, key, object) { + result = hasOwnProperty.call(object, key); + return false; + }); + return result !== false; + } + // In most environments an object's own properties are iterated before + // its inherited properties. If the last iterated property is an object's + // own property then there are no inherited enumerable properties. + baseForIn(value, function(subValue, key) { + result = key; + }); + return result === undefined || hasOwnProperty.call(value, result); +} - first.length = i; +module.exports = isPlainObject; - return first; - }, +},{"../internal/baseForIn":75,"../internal/isHostObject":120,"../internal/isObjectLike":126,"../support":153,"./isArguments":139}],146:[function(require,module,exports){ +var isObjectLike = require('../internal/isObjectLike'); - grep: function (elems, callback, invert) { - var callbackInverse, - matches = [], - i = 0, - length = elems.length, - callbackExpect = !invert; +/** `Object#toString` result references. */ +var stringTag = '[object String]'; - // Go through the array, only saving the items - // that pass the validator function - for (; i < length; i++) { - callbackInverse = !callback(elems[ i ], i); +/** Used for native method references. */ +var objectProto = Object.prototype; - if (callbackInverse !== callbackExpect) { - matches.push(elems[ i ]); - } - } +/** + * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * of values. + */ +var objToString = objectProto.toString; - return matches; - }, +/** + * Checks if `value` is classified as a `String` primitive or object. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @example + * + * _.isString('abc'); + * // => true + * + * _.isString(1); + * // => false + */ +function isString(value) { + return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag); +} + +module.exports = isString; + +},{"../internal/isObjectLike":126}],147:[function(require,module,exports){ +var isLength = require('../internal/isLength'), + isObjectLike = require('../internal/isObjectLike'); + +/** `Object#toString` result references. */ +var argsTag = '[object Arguments]', + arrayTag = '[object Array]', + boolTag = '[object Boolean]', + dateTag = '[object Date]', + errorTag = '[object Error]', + funcTag = '[object Function]', + mapTag = '[object Map]', + numberTag = '[object Number]', + objectTag = '[object Object]', + regexpTag = '[object RegExp]', + setTag = '[object Set]', + stringTag = '[object String]', + weakMapTag = '[object WeakMap]'; + +var arrayBufferTag = '[object ArrayBuffer]', + float32Tag = '[object Float32Array]', + float64Tag = '[object Float64Array]', + int8Tag = '[object Int8Array]', + int16Tag = '[object Int16Array]', + int32Tag = '[object Int32Array]', + uint8Tag = '[object Uint8Array]', + uint8ClampedTag = '[object Uint8ClampedArray]', + uint16Tag = '[object Uint16Array]', + uint32Tag = '[object Uint32Array]'; + +/** Used to identify `toStringTag` values of typed arrays. */ +var typedArrayTags = {}; +typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = +typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = +typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = +typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = +typedArrayTags[uint32Tag] = true; +typedArrayTags[argsTag] = typedArrayTags[arrayTag] = +typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = +typedArrayTags[dateTag] = typedArrayTags[errorTag] = +typedArrayTags[funcTag] = typedArrayTags[mapTag] = +typedArrayTags[numberTag] = typedArrayTags[objectTag] = +typedArrayTags[regexpTag] = typedArrayTags[setTag] = +typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false; + +/** Used for native method references. */ +var objectProto = Object.prototype; - // arg is for internal usage only - map: function (elems, callback, arg) { - var value, - i = 0, - length = elems.length, - isArray = isArraylike(elems), - ret = []; +/** + * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * of values. + */ +var objToString = objectProto.toString; - // Go through the array, translating each of the items to their new values - if (isArray) { - for (; i < length; i++) { - value = callback(elems[ i ], i, arg); +/** + * Checks if `value` is classified as a typed array. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + * @example + * + * _.isTypedArray(new Uint8Array); + * // => true + * + * _.isTypedArray([]); + * // => false + */ +function isTypedArray(value) { + return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)]; +} - if (value != null) { - ret.push(value); - } - } +module.exports = isTypedArray; - // Go through every key on the object, - } else { - for (i in elems) { - value = callback(elems[ i ], i, arg); +},{"../internal/isLength":125,"../internal/isObjectLike":126}],148:[function(require,module,exports){ +/** + * Checks if `value` is `undefined`. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`. + * @example + * + * _.isUndefined(void 0); + * // => true + * + * _.isUndefined(null); + * // => false + */ +function isUndefined(value) { + return value === undefined; +} - if (value != null) { - ret.push(value); - } - } - } +module.exports = isUndefined; - // Flatten any nested arrays - return concat.apply([], ret); - }, +},{}],149:[function(require,module,exports){ +var getNative = require('../internal/getNative'), + isArrayLike = require('../internal/isArrayLike'), + isObject = require('../lang/isObject'), + shimKeys = require('../internal/shimKeys'), + support = require('../support'); - // A global GUID counter for objects - guid: 1, +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeKeys = getNative(Object, 'keys'); - // Bind a function to a context, optionally partially applying any - // arguments. - proxy: function (fn, context) { - var tmp, args, proxy; +/** + * Creates an array of the own enumerable property names of `object`. + * + * **Note:** Non-object values are coerced to objects. See the + * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys) + * for more details. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.keys(new Foo); + * // => ['a', 'b'] (iteration order is not guaranteed) + * + * _.keys('hi'); + * // => ['0', '1'] + */ +var keys = !nativeKeys ? shimKeys : function(object) { + var Ctor = object == null ? undefined : object.constructor; + if ((typeof Ctor == 'function' && Ctor.prototype === object) || + (typeof object == 'function' ? support.enumPrototypes : isArrayLike(object))) { + return shimKeys(object); + } + return isObject(object) ? nativeKeys(object) : []; +}; + +module.exports = keys; + +},{"../internal/getNative":114,"../internal/isArrayLike":119,"../internal/shimKeys":134,"../lang/isObject":144,"../support":153}],150:[function(require,module,exports){ +var arrayEach = require('../internal/arrayEach'), + isArguments = require('../lang/isArguments'), + isArray = require('../lang/isArray'), + isFunction = require('../lang/isFunction'), + isIndex = require('../internal/isIndex'), + isLength = require('../internal/isLength'), + isObject = require('../lang/isObject'), + isString = require('../lang/isString'), + support = require('../support'); + +/** `Object#toString` result references. */ +var arrayTag = '[object Array]', + boolTag = '[object Boolean]', + dateTag = '[object Date]', + errorTag = '[object Error]', + funcTag = '[object Function]', + numberTag = '[object Number]', + objectTag = '[object Object]', + regexpTag = '[object RegExp]', + stringTag = '[object String]'; + +/** Used to fix the JScript `[[DontEnum]]` bug. */ +var shadowProps = [ + 'constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', + 'toLocaleString', 'toString', 'valueOf' +]; + +/** Used for native method references. */ +var errorProto = Error.prototype, + objectProto = Object.prototype, + stringProto = String.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; - if (typeof context === 'string') { - tmp = fn[ context ]; - context = fn; - fn = tmp; - } +/** + * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * of values. + */ +var objToString = objectProto.toString; + +/** Used to avoid iterating over non-enumerable properties in IE < 9. */ +var nonEnumProps = {}; +nonEnumProps[arrayTag] = nonEnumProps[dateTag] = nonEnumProps[numberTag] = { 'constructor': true, 'toLocaleString': true, 'toString': true, 'valueOf': true }; +nonEnumProps[boolTag] = nonEnumProps[stringTag] = { 'constructor': true, 'toString': true, 'valueOf': true }; +nonEnumProps[errorTag] = nonEnumProps[funcTag] = nonEnumProps[regexpTag] = { 'constructor': true, 'toString': true }; +nonEnumProps[objectTag] = { 'constructor': true }; + +arrayEach(shadowProps, function(key) { + for (var tag in nonEnumProps) { + if (hasOwnProperty.call(nonEnumProps, tag)) { + var props = nonEnumProps[tag]; + props[key] = hasOwnProperty.call(props, key); + } + } +}); - // Quick check to determine if target is callable, in the spec - // this throws a TypeError, but we will just return undefined. - if (!jQuery.isFunction(fn)) { - return undefined; - } +/** + * Creates an array of the own and inherited enumerable property names of `object`. + * + * **Note:** Non-object values are coerced to objects. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.keysIn(new Foo); + * // => ['a', 'b', 'c'] (iteration order is not guaranteed) + */ +function keysIn(object) { + if (object == null) { + return []; + } + if (!isObject(object)) { + object = Object(object); + } + var length = object.length; + + length = (length && isLength(length) && + (isArray(object) || isArguments(object) || isString(object)) && length) || 0; + + var Ctor = object.constructor, + index = -1, + proto = (isFunction(Ctor) && Ctor.prototype) || objectProto, + isProto = proto === object, + result = Array(length), + skipIndexes = length > 0, + skipErrorProps = support.enumErrorProps && (object === errorProto || object instanceof Error), + skipProto = support.enumPrototypes && isFunction(object); + + while (++index < length) { + result[index] = (index + ''); + } + // lodash skips the `constructor` property when it infers it's iterating + // over a `prototype` object because IE < 9 can't set the `[[Enumerable]]` + // attribute of an existing property and the `constructor` property of a + // prototype defaults to non-enumerable. + for (var key in object) { + if (!(skipProto && key == 'prototype') && + !(skipErrorProps && (key == 'message' || key == 'name')) && + !(skipIndexes && isIndex(key, length)) && + !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { + result.push(key); + } + } + if (support.nonEnumShadows && object !== objectProto) { + var tag = object === stringProto ? stringTag : (object === errorProto ? errorTag : objToString.call(object)), + nonEnums = nonEnumProps[tag] || nonEnumProps[objectTag]; - // Simulated bind - args = slice.call(arguments, 2); - proxy = function () { - return fn.apply(context || this, args.concat(slice.call(arguments))); - }; + if (tag == objectTag) { + proto = objectProto; + } + length = shadowProps.length; + while (length--) { + key = shadowProps[length]; + var nonEnum = nonEnums[key]; + if (!(isProto && nonEnum) && + (nonEnum ? hasOwnProperty.call(object, key) : object[key] !== proto[key])) { + result.push(key); + } + } + } + return result; +} - // Set the guid of unique handler to the same of original handler, so it can be removed - proxy.guid = fn.guid = fn.guid || jQuery.guid++; +module.exports = keysIn; - return proxy; - }, +},{"../internal/arrayEach":63,"../internal/isIndex":121,"../internal/isLength":125,"../lang/isArguments":139,"../lang/isArray":140,"../lang/isFunction":142,"../lang/isObject":144,"../lang/isString":146,"../support":153}],151:[function(require,module,exports){ +var keys = require('./keys'), + toObject = require('../internal/toObject'); - now: Date.now, +/** + * Creates a two dimensional array of the key-value pairs for `object`, + * e.g. `[[key1, value1], [key2, value2]]`. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the new array of key-value pairs. + * @example + * + * _.pairs({ 'barney': 36, 'fred': 40 }); + * // => [['barney', 36], ['fred', 40]] (iteration order is not guaranteed) + */ +function pairs(object) { + object = toObject(object); - // jQuery.support is not used in Core but other projects attach their - // properties to it so it needs to exist. - support: support - }); + var index = -1, + props = keys(object), + length = props.length, + result = Array(length); - // Populate the class2type map - jQuery.each('Boolean Number String Function Array Date RegExp Object Error'.split(' '), function (i, name) { - class2type[ '[object ' + name + ']' ] = name.toLowerCase(); - }); + while (++index < length) { + var key = props[index]; + result[index] = [key, object[key]]; + } + return result; +} - function isArraylike(obj) { +module.exports = pairs; - // Support: iOS 8.2 (not reproducible in simulator) - // `in` check used to prevent JIT error (gh-2145) - // hasOwn isn't used here due to false negatives - // regarding Nodelist length in IE - var length = 'length' in obj && obj.length, - type = jQuery.type(obj); +},{"../internal/toObject":135,"./keys":149}],152:[function(require,module,exports){ +var baseValues = require('../internal/baseValues'), + keys = require('./keys'); - if (type === 'function' || jQuery.isWindow(obj)) { - return false; - } +/** + * Creates an array of the own enumerable property values of `object`. + * + * **Note:** Non-object values are coerced to objects. + * + * @static + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property values. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.values(new Foo); + * // => [1, 2] (iteration order is not guaranteed) + * + * _.values('hi'); + * // => ['h', 'i'] + */ +function values(object) { + return baseValues(object, keys(object)); +} - if (obj.nodeType === 1 && length) { - return true; - } +module.exports = values; - return type === 'array' || length === 0 || - typeof length === 'number' && length > 0 && length - 1 in obj; - } - var Sizzle = - - /*! - * Sizzle CSS Selector Engine v2.2.0-pre - * http://sizzlejs.com/ - * - * Copyright 2008, 2014 jQuery Foundation, Inc. and other contributors - * Released under the MIT license - * http://jquery.org/license - * - * Date: 2014-12-16 - */ - (function (window) { - - var i, - support, - Expr, - getText, - isXML, - tokenize, - compile, - select, - outermostContext, - sortInput, - hasDuplicate, - - // Local document vars - setDocument, - document, - docElem, - documentIsHTML, - rbuggyQSA, - rbuggyMatches, - matches, - contains, - - // Instance-specific data - expando = 'sizzle' + 1 * new Date(), - preferredDoc = window.document, - dirruns = 0, - done = 0, - classCache = createCache(), - tokenCache = createCache(), - compilerCache = createCache(), - sortOrder = function (a, b) { - if (a === b) { - hasDuplicate = true; - } +},{"../internal/baseValues":91,"./keys":149}],153:[function(require,module,exports){ +/** Used for native method references. */ +var arrayProto = Array.prototype, + errorProto = Error.prototype, + objectProto = Object.prototype; - return 0; - }, - - // General-purpose constants - MAX_NEGATIVE = 1 << 31, - - // Instance methods - hasOwn = {}.hasOwnProperty, - arr = [], - pop = arr.pop, - push_native = arr.push, - push = arr.push, - slice = arr.slice, - // Use a stripped-down indexOf as it's faster than native - // http://jsperf.com/thor-indexof-vs-for/5 - indexOf = function (list, elem) { - var i = 0, - len = list.length; - - for (; i < len; i++) { - if (list[i] === elem) { - return i; - } - } +/** Native method references. */ +var propertyIsEnumerable = objectProto.propertyIsEnumerable, + splice = arrayProto.splice; - return -1; - }, - - booleans = 'checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped', - - // Regular expressions - - // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace - whitespace = '[\\x20\\t\\r\\n\\f]', - // http://www.w3.org/TR/css3-syntax/#characters - characterEncoding = '(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+', - - // Loosely modeled on CSS identifier characters - // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors - // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier - identifier = characterEncoding.replace('w', 'w#'), - - // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors - attributes = '\\[' + whitespace + '*(' + characterEncoding + ')(?:' + whitespace + - // Operator (capture 2) - '*([*^$|!~]?=)' + whitespace + - // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]" - '*(?:\'((?:\\\\.|[^\\\\\'])*)\'|"((?:\\\\.|[^\\\\\"])*)"|(' + identifier + '))|)' + whitespace + - '*\\]', - - pseudos = ':(' + characterEncoding + ')(?:\\((' + - // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments: - // 1. quoted (capture 3; capture 4 or capture 5) - '(\'((?:\\\\.|[^\\\\\'])*)\'|"((?:\\\\.|[^\\\\\"])*)")|' + - // 2. simple (capture 6) - '((?:\\\\.|[^\\\\()[\\]]|' + attributes + ')*)|' + - // 3. anything else (capture 2) - '.*' + - ')\\)|)', - - // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter - rwhitespace = new RegExp(whitespace + '+', 'g'), - rtrim = new RegExp('^' + whitespace + '+|((?:^|[^\\\\])(?:\\\\.)*)' + whitespace + '+$', 'g'), - - rcomma = new RegExp('^' + whitespace + '*,' + whitespace + '*'), - rcombinators = new RegExp('^' + whitespace + '*([>+~]|' + whitespace + ')' + whitespace + '*'), - - rattributeQuotes = new RegExp('=' + whitespace + '*([^\\]\'"]*?)' + whitespace + '*\\]', 'g'), - - rpseudo = new RegExp(pseudos), - ridentifier = new RegExp('^' + identifier + '$'), - - matchExpr = { - 'ID': new RegExp('^#(' + characterEncoding + ')'), - 'CLASS': new RegExp('^\\.(' + characterEncoding + ')'), - 'TAG': new RegExp('^(' + characterEncoding.replace('w', 'w*') + ')'), - 'ATTR': new RegExp('^' + attributes), - 'PSEUDO': new RegExp('^' + pseudos), - 'CHILD': new RegExp('^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(' + whitespace + - '*(even|odd|(([+-]|)(\\d*)n|)' + whitespace + '*(?:([+-]|)' + whitespace + - '*(\\d+)|))' + whitespace + '*\\)|)', 'i'), - 'bool': new RegExp('^(?:' + booleans + ')$', 'i'), - // For use in libraries implementing .is() - // We use this for POS matching in `select` - 'needsContext': new RegExp('^' + whitespace + '*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(' + - whitespace + '*((?:-\\d)?\\d*)' + whitespace + '*\\)|)(?=[^-]|$)', 'i') - }, - - rinputs = /^(?:input|select|textarea|button)$/i, - rheader = /^h\d$/i, - - rnative = /^[^{]+\{\s*\[native \w/, - - // Easily-parseable/retrievable ID or TAG or CLASS selectors - rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, - - rsibling = /[+~]/, - rescape = /'|\\/g, - - // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters - runescape = new RegExp('\\\\([\\da-f]{1,6}' + whitespace + '?|(' + whitespace + ')|.)', 'ig'), - funescape = function (_, escaped, escapedWhitespace) { - var high = '0x' + escaped - 0x10000; - // NaN means non-codepoint - // Support: Firefox<24 - // Workaround erroneous numeric interpretation of +"0x" - - return high !== high || escapedWhitespace ? - escaped : - high < 0 ? - // BMP codepoint - String.fromCharCode(high + 0x10000) : - // Supplemental Plane codepoint (surrogate pair) - String.fromCharCode(high >> 10 | 0xD800, high & 0x3FF | 0xDC00); - }, - - // Used for iframes - // See setDocument() - // Removing the function wrapper causes a "Permission Denied" - // error in IE - unloadHandler = function () { - setDocument(); - }; - - // Optimize for push.apply( _, NodeList ) - try { - push.apply( - arr = slice.call(preferredDoc.childNodes), - preferredDoc.childNodes - ); - // Support: Android<4.0 - // Detect silently failing push.apply - arr[ preferredDoc.childNodes.length ].nodeType; - } catch (e) { - push = { - apply: arr.length ? - - // Leverage slice if possible - function (target, els) { - push_native.apply(target, slice.call(els)); - } : - - // Support: IE<9 - // Otherwise append directly - function (target, els) { - var j = target.length, - i = 0; - // Can't trust NodeList.length - - while (target[j++] = els[i++]) {} - target.length = j - 1; - } - }; - } +/** + * An object environment feature flags. + * + * @static + * @memberOf _ + * @type Object + */ +var support = {}; + +(function(x) { + var Ctor = function() { this.x = x; }, + object = { '0': x, 'length': x }, + props = []; + + Ctor.prototype = { 'valueOf': x, 'y': x }; + for (var key in new Ctor) { props.push(key); } + + /** + * Detect if `name` or `message` properties of `Error.prototype` are + * enumerable by default (IE < 9, Safari < 5.1). + * + * @memberOf _.support + * @type boolean + */ + support.enumErrorProps = propertyIsEnumerable.call(errorProto, 'message') || + propertyIsEnumerable.call(errorProto, 'name'); + + /** + * Detect if `prototype` properties are enumerable by default. + * + * Firefox < 3.6, Opera > 9.50 - Opera < 11.60, and Safari < 5.1 + * (if the prototype or a property on the prototype has been set) + * incorrectly set the `[[Enumerable]]` value of a function's `prototype` + * property to `true`. + * + * @memberOf _.support + * @type boolean + */ + support.enumPrototypes = propertyIsEnumerable.call(Ctor, 'prototype'); + + /** + * Detect if properties shadowing those on `Object.prototype` are non-enumerable. + * + * In IE < 9 an object's own properties, shadowing non-enumerable ones, + * are made non-enumerable as well (a.k.a the JScript `[[DontEnum]]` bug). + * + * @memberOf _.support + * @type boolean + */ + support.nonEnumShadows = !/valueOf/.test(props); + + /** + * Detect if own properties are iterated after inherited properties (IE < 9). + * + * @memberOf _.support + * @type boolean + */ + support.ownLast = props[0] != 'x'; + + /** + * Detect if `Array#shift` and `Array#splice` augment array-like objects + * correctly. + * + * Firefox < 10, compatibility modes of IE 8, and IE < 9 have buggy Array + * `shift()` and `splice()` functions that fail to remove the last element, + * `value[0]`, of array-like objects even though the "length" property is + * set to `0`. The `shift()` method is buggy in compatibility modes of IE 8, + * while `splice()` is buggy regardless of mode in IE < 9. + * + * @memberOf _.support + * @type boolean + */ + support.spliceObjects = (splice.call(object, 0, 1), !object[0]); + + /** + * Detect lack of support for accessing string characters by index. + * + * IE < 8 can't access characters by index. IE 8 can only access characters + * by index on string literals, not string objects. + * + * @memberOf _.support + * @type boolean + */ + support.unindexedChars = ('x'[0] + Object('x')[0]) != 'xx'; +}(1, 0)); + +module.exports = support; + +},{}],154:[function(require,module,exports){ +/** + * This method returns the first argument provided to it. + * + * @static + * @memberOf _ + * @category Utility + * @param {*} value Any value. + * @returns {*} Returns `value`. + * @example + * + * var object = { 'user': 'fred' }; + * + * _.identity(object) === object; + * // => true + */ +function identity(value) { + return value; +} - function Sizzle(selector, context, results, seed) { - var match, elem, m, nodeType, - // QSA vars - i, groups, old, nid, newContext, newSelector; +module.exports = identity; - if ((context ? context.ownerDocument || context : preferredDoc) !== document) { - setDocument(context); - } +},{}],155:[function(require,module,exports){ +/** + * A no-operation function that returns `undefined` regardless of the + * arguments it receives. + * + * @static + * @memberOf _ + * @category Utility + * @example + * + * var object = { 'user': 'fred' }; + * + * _.noop(object) === undefined; + * // => true + */ +function noop() { + // No operation performed. +} - context = context || document; - results = results || []; - nodeType = context.nodeType; +module.exports = noop; - if (typeof selector !== 'string' || !selector || - nodeType !== 1 && nodeType !== 9 && nodeType !== 11) { +},{}],156:[function(require,module,exports){ +var baseProperty = require('../internal/baseProperty'), + basePropertyDeep = require('../internal/basePropertyDeep'), + isKey = require('../internal/isKey'); - return results; - } +/** + * Creates a function that returns the property value at `path` on a + * given object. + * + * @static + * @memberOf _ + * @category Utility + * @param {Array|string} path The path of the property to get. + * @returns {Function} Returns the new function. + * @example + * + * var objects = [ + * { 'a': { 'b': { 'c': 2 } } }, + * { 'a': { 'b': { 'c': 1 } } } + * ]; + * + * _.map(objects, _.property('a.b.c')); + * // => [2, 1] + * + * _.pluck(_.sortBy(objects, _.property(['a', 'b', 'c'])), 'a.b.c'); + * // => [1, 2] + */ +function property(path) { + return isKey(path) ? baseProperty(path) : basePropertyDeep(path); +} - if (!seed && documentIsHTML) { - - // Try to shortcut find operations when possible (e.g., not under DocumentFragment) - if (nodeType !== 11 && (match = rquickExpr.exec(selector))) { - // Speed-up: Sizzle("#ID") - if (m = match[1]) { - if (nodeType === 9) { - elem = context.getElementById(m); - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document (jQuery #6963) - if (elem && elem.parentNode) { - // Handle the case where IE, Opera, and Webkit return items - // by name instead of ID - if (elem.id === m) { - results.push(elem); - - return results; - } - } else { - return results; - } - } else { - // Context is not a document - if (context.ownerDocument && (elem = context.ownerDocument.getElementById(m)) && - contains(context, elem) && elem.id === m) { - results.push(elem); - - return results; - } - } - - // Speed-up: Sizzle("TAG") - } else if (match[2]) { - push.apply(results, context.getElementsByTagName(selector)); - - return results; - - // Speed-up: Sizzle(".CLASS") - } else if ((m = match[3]) && support.getElementsByClassName) { - push.apply(results, context.getElementsByClassName(m)); - - return results; - } - } +module.exports = property; - // QSA path - if (support.qsa && (!rbuggyQSA || !rbuggyQSA.test(selector))) { - nid = old = expando; - newContext = context; - newSelector = nodeType !== 1 && selector; - - // qSA works strangely on Element-rooted queries - // We can work around this by specifying an extra ID on the root - // and working up from there (Thanks to Andrew Dupont for the technique) - // IE 8 doesn't work on object elements - if (nodeType === 1 && context.nodeName.toLowerCase() !== 'object') { - groups = tokenize(selector); - - if (old = context.getAttribute('id')) { - nid = old.replace(rescape, '\\$&'); - } else { - context.setAttribute('id', nid); - } - nid = '[id=\'' + nid + '\'] '; - - i = groups.length; - - while (i--) { - groups[i] = nid + toSelector(groups[i]); - } - newContext = rsibling.test(selector) && testContext(context.parentNode) || context; - newSelector = groups.join(','); - } - - if (newSelector) { - try { - push.apply(results, - newContext.querySelectorAll(newSelector) - ); - - return results; - } catch (qsaError) { - } finally { - if (!old) { - context.removeAttribute('id'); - } - } - } - } - } - - // All others - return select(selector.replace(rtrim, '$1'), context, results, seed); - } - - /** - * Create key-value caches of limited size - * @returns {Function(string, Object)} Returns the Object data after storing it on itself with - * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) - * deleting the oldest entry - */ - function createCache() { - var keys = []; - - function cache(key, value) { - // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) - if (keys.push(key + ' ') > Expr.cacheLength) { - // Only keep the most recent entries - delete cache[ keys.shift() ]; - } - - return cache[ key + ' ' ] = value; - } - - return cache; - } - - /** - * Mark a function for special use by Sizzle - * @param {Function} fn The function to mark - */ - function markFunction(fn) { - fn[ expando ] = true; - - return fn; - } - - /** - * Support testing using an element - * @param {Function} fn Passed the created div and expects a boolean result - */ - function assert(fn) { - var div = document.createElement('div'); - - try { - return !!fn(div); - } catch (e) { - return false; - } finally { - // Remove from its parent by default - if (div.parentNode) { - div.parentNode.removeChild(div); - } - // release memory in IE - div = null; - } - } - - /** - * Adds the same handler for all of the specified attrs - * @param {String} attrs Pipe-separated list of attributes - * @param {Function} handler The method that will be applied - */ - function addHandle(attrs, handler) { - var arr = attrs.split('|'), - i = attrs.length; - - while (i--) { - Expr.attrHandle[ arr[i] ] = handler; - } - } - - /** - * Checks document order of two siblings - * @param {Element} a - * @param {Element} b - * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b - */ - function siblingCheck(a, b) { - var cur = b && a, - diff = cur && a.nodeType === 1 && b.nodeType === 1 && - (~b.sourceIndex || MAX_NEGATIVE) - - (~a.sourceIndex || MAX_NEGATIVE); - - // Use IE sourceIndex if available on both nodes - if (diff) { - return diff; - } - - // Check if b follows a - if (cur) { - while (cur = cur.nextSibling) { - if (cur === b) { - return -1; - } - } - } - - return a ? 1 : -1; - } - - /** - * Returns a function to use in pseudos for input types - * @param {String} type - */ - function createInputPseudo(type) { - return function (elem) { - var name = elem.nodeName.toLowerCase(); - - return name === 'input' && elem.type === type; - }; - } - - /** - * Returns a function to use in pseudos for buttons - * @param {String} type - */ - function createButtonPseudo(type) { - return function (elem) { - var name = elem.nodeName.toLowerCase(); - - return (name === 'input' || name === 'button') && elem.type === type; - }; - } - - /** - * Returns a function to use in pseudos for positionals - * @param {Function} fn - */ - function createPositionalPseudo(fn) { - return markFunction(function (argument) { - argument = +argument; - - return markFunction(function (seed, matches) { - var j, - matchIndexes = fn([], seed.length, argument), - i = matchIndexes.length; - - // Match elements found at the specified indexes - while (i--) { - if (seed[ j = matchIndexes[i] ]) { - seed[j] = !(matches[j] = seed[j]); - } - } - }); - }); - } - - /** - * Checks a node for validity as a Sizzle context - * @param {Element|Object=} context - * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value - */ - function testContext(context) { - return context && typeof context.getElementsByTagName !== 'undefined' && context; - } - - // Expose support vars for convenience - support = Sizzle.support = {}; - - /** - * Detects XML nodes - * @param {Element|Object} elem An element or a document - * @returns {Boolean} True iff elem is a non-HTML XML node - */ - isXML = Sizzle.isXML = function (elem) { - // documentElement is verified for cases where it doesn't yet exist - // (such as loading iframes in IE - #4833) - var documentElement = elem && (elem.ownerDocument || elem).documentElement; - - return documentElement ? documentElement.nodeName !== 'HTML' : false; - }; - - /** - * Sets document-related variables once based on the current document - * @param {Element|Object} [doc] An element or document object to use to set the document - * @returns {Object} Returns the current document - */ - setDocument = Sizzle.setDocument = function (node) { - var hasCompare, parent, - doc = node ? node.ownerDocument || node : preferredDoc; - - // If no document and documentElement is available, return - if (doc === document || doc.nodeType !== 9 || !doc.documentElement) { - return document; - } - - // Set our document - document = doc; - docElem = doc.documentElement; - parent = doc.defaultView; - - // Support: IE>8 - // If iframe document is assigned to "document" variable and if iframe has been reloaded, - // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936 - // IE6-8 do not support the defaultView property so parent will be undefined - if (parent && parent !== parent.top) { - // IE11 does not have attachEvent, so all must suffer - if (parent.addEventListener) { - parent.addEventListener('unload', unloadHandler, false); - } else if (parent.attachEvent) { - parent.attachEvent('onunload', unloadHandler); - } - } - - /* Support tests - ---------------------------------------------------------------------- */ - documentIsHTML = !isXML(doc); - - /* Attributes - ---------------------------------------------------------------------- */ - - // Support: IE<8 - // Verify that getAttribute really returns attributes and not properties - // (excepting IE8 booleans) - support.attributes = assert(function (div) { - div.className = 'i'; - - return !div.getAttribute('className'); - }); - - /* getElement(s)By* - ---------------------------------------------------------------------- */ - - // Check if getElementsByTagName("*") returns only elements - support.getElementsByTagName = assert(function (div) { - div.appendChild(doc.createComment('')); - - return !div.getElementsByTagName('*').length; - }); - - // Support: IE<9 - support.getElementsByClassName = rnative.test(doc.getElementsByClassName); - - // Support: IE<10 - // Check if getElementById returns elements by name - // The broken getElementById methods don't pick up programatically-set names, - // so use a roundabout getElementsByName test - support.getById = assert(function (div) { - docElem.appendChild(div).id = expando; - - return !doc.getElementsByName || !doc.getElementsByName(expando).length; - }); - - // ID find and filter - if (support.getById) { - Expr.find['ID'] = function (id, context) { - if (typeof context.getElementById !== 'undefined' && documentIsHTML) { - var m = context.getElementById(id); - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document #6963 - - return m && m.parentNode ? [m] : []; - } - }; - Expr.filter['ID'] = function (id) { - var attrId = id.replace(runescape, funescape); - - return function (elem) { - return elem.getAttribute('id') === attrId; - }; - }; - } else { - // Support: IE6/7 - // getElementById is not reliable as a find shortcut - delete Expr.find['ID']; - - Expr.filter['ID'] = function (id) { - var attrId = id.replace(runescape, funescape); - - return function (elem) { - var node = typeof elem.getAttributeNode !== 'undefined' && elem.getAttributeNode('id'); - - return node && node.value === attrId; - }; - }; - } - - // Tag - Expr.find['TAG'] = support.getElementsByTagName ? - function (tag, context) { - if (typeof context.getElementsByTagName !== 'undefined') { - return context.getElementsByTagName(tag); - - // DocumentFragment nodes don't have gEBTN - } else if (support.qsa) { - return context.querySelectorAll(tag); - } - } : - - function (tag, context) { - var elem, - tmp = [], - i = 0, - // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too - results = context.getElementsByTagName(tag); - - // Filter out possible comments - if (tag === '*') { - while (elem = results[i++]) { - if (elem.nodeType === 1) { - tmp.push(elem); - } - } - - return tmp; - } - - return results; - }; - - // Class - Expr.find['CLASS'] = support.getElementsByClassName && function (className, context) { - if (documentIsHTML) { - return context.getElementsByClassName(className); - } - }; - - /* QSA/matchesSelector - ---------------------------------------------------------------------- */ - - // QSA and matchesSelector support - - // matchesSelector(:active) reports false when true (IE9/Opera 11.5) - rbuggyMatches = []; - - // qSa(:focus) reports false when true (Chrome 21) - // We allow this because of a bug in IE8/9 that throws an error - // whenever `document.activeElement` is accessed on an iframe - // So, we allow :focus to pass through QSA all the time to avoid the IE error - // See http://bugs.jquery.com/ticket/13378 - rbuggyQSA = []; - - if (support.qsa = rnative.test(doc.querySelectorAll)) { - // Build QSA regex - // Regex strategy adopted from Diego Perini - assert(function (div) { - // Select is set to empty string on purpose - // This is to test IE's treatment of not explicitly - // setting a boolean content attribute, - // since its presence should be enough - // http://bugs.jquery.com/ticket/12359 - docElem.appendChild(div).innerHTML = '' + - ''; - - // Support: IE8, Opera 11-12.16 - // Nothing should be selected when empty strings follow ^= or $= or *= - // The test attribute must be unknown in Opera but "safe" for WinRT - // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section - if (div.querySelectorAll('[msallowcapture^=\'\']').length) { - rbuggyQSA.push('[*^$]=' + whitespace + '*(?:\'\'|"\")'); - } - - // Support: IE8 - // Boolean attributes and "value" are not treated correctly - if (!div.querySelectorAll('[selected]').length) { - rbuggyQSA.push('\\[' + whitespace + '*(?:value|' + booleans + ')'); - } - - // Support: Chrome<29, Android<4.2+, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.7+ - if (!div.querySelectorAll('[id~=' + expando + '-]').length) { - rbuggyQSA.push('~='); - } - - // Webkit/Opera - :checked should return selected option elements - // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked - // IE8 throws error here and will not see later tests - if (!div.querySelectorAll(':checked').length) { - rbuggyQSA.push(':checked'); - } - - // Support: Safari 8+, iOS 8+ - // https://bugs.webkit.org/show_bug.cgi?id=136851 - // In-page `selector#id sibing-combinator selector` fails - if (!div.querySelectorAll('a#' + expando + '+*').length) { - rbuggyQSA.push('.#.+[+~]'); - } - }); - - assert(function (div) { - // Support: Windows 8 Native Apps - // The type and name attributes are restricted during .innerHTML assignment - var input = doc.createElement('input'); - - input.setAttribute('type', 'hidden'); - div.appendChild(input).setAttribute('name', 'D'); - - // Support: IE8 - // Enforce case-sensitivity of name attribute - if (div.querySelectorAll('[name=d]').length) { - rbuggyQSA.push('name' + whitespace + '*[*^$|!~]?='); - } - - // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) - // IE8 throws error here and will not see later tests - if (!div.querySelectorAll(':enabled').length) { - rbuggyQSA.push(':enabled', ':disabled'); - } - - // Opera 10-11 does not throw on post-comma invalid pseudos - div.querySelectorAll('*,:x'); - rbuggyQSA.push(',.*:'); - }); - } - - if (support.matchesSelector = rnative.test(matches = docElem.matches || - docElem.webkitMatchesSelector || - docElem.mozMatchesSelector || - docElem.oMatchesSelector || - docElem.msMatchesSelector)) { - - assert(function (div) { - // Check to see if it's possible to do matchesSelector - // on a disconnected node (IE 9) - support.disconnectedMatch = matches.call(div, 'div'); - - // This should fail with an exception - // Gecko does not error, returns false instead - matches.call(div, '[s!=\'\']:x'); - rbuggyMatches.push('!=', pseudos); - }); - } - - rbuggyQSA = rbuggyQSA.length && new RegExp(rbuggyQSA.join('|')); - rbuggyMatches = rbuggyMatches.length && new RegExp(rbuggyMatches.join('|')); - - /* Contains - ---------------------------------------------------------------------- */ - hasCompare = rnative.test(docElem.compareDocumentPosition); - - // Element contains another - // Purposefully does not implement inclusive descendent - // As in, an element does not contain itself - contains = hasCompare || rnative.test(docElem.contains) ? - function (a, b) { - var adown = a.nodeType === 9 ? a.documentElement : a, - bup = b && b.parentNode; - - return a === bup || !!(bup && bup.nodeType === 1 && ( - adown.contains ? - adown.contains(bup) : - a.compareDocumentPosition && a.compareDocumentPosition(bup) & 16 - )); - } : - function (a, b) { - if (b) { - while (b = b.parentNode) { - if (b === a) { - return true; - } - } - } - - return false; - }; - - /* Sorting - ---------------------------------------------------------------------- */ - - // Document order sorting - sortOrder = hasCompare ? - function (a, b) { - - // Flag for duplicate removal - if (a === b) { - hasDuplicate = true; - - return 0; - } - - // Sort on method existence if only one input has compareDocumentPosition - var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; - - if (compare) { - return compare; - } - - // Calculate position if both inputs belong to the same document - compare = (a.ownerDocument || a) === (b.ownerDocument || b) ? - a.compareDocumentPosition(b) : - - // Otherwise we know they are disconnected - 1; - - // Disconnected nodes - if (compare & 1 || - !support.sortDetached && b.compareDocumentPosition(a) === compare) { - - // Choose the first element that is related to our preferred document - if (a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a)) { - return -1; - } - - if (b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b)) { - return 1; - } - - // Maintain original order - return sortInput ? - indexOf(sortInput, a) - indexOf(sortInput, b) : - 0; - } - - return compare & 4 ? -1 : 1; - } : - function (a, b) { - // Exit early if the nodes are identical - if (a === b) { - hasDuplicate = true; - - return 0; - } - - var cur, - i = 0, - aup = a.parentNode, - bup = b.parentNode, - ap = [a], - bp = [b]; - - // Parentless nodes are either documents or disconnected - if (!aup || !bup) { - return a === doc ? -1 : - b === doc ? 1 : - aup ? -1 : - bup ? 1 : - sortInput ? - indexOf(sortInput, a) - indexOf(sortInput, b) : - 0; - - // If the nodes are siblings, we can do a quick check - } else if (aup === bup) { - return siblingCheck(a, b); - } - - // Otherwise we need full lists of their ancestors for comparison - cur = a; - - while (cur = cur.parentNode) { - ap.unshift(cur); - } - cur = b; - - while (cur = cur.parentNode) { - bp.unshift(cur); - } - - // Walk down the tree looking for a discrepancy - while (ap[i] === bp[i]) { - i++; - } - - return i ? - // Do a sibling check if the nodes have a common ancestor - siblingCheck(ap[i], bp[i]) : - - // Otherwise nodes in our document sort first - ap[i] === preferredDoc ? -1 : - bp[i] === preferredDoc ? 1 : - 0; - }; - - return doc; - }; - - Sizzle.matches = function (expr, elements) { - return Sizzle(expr, null, null, elements); - }; - - Sizzle.matchesSelector = function (elem, expr) { - // Set document vars if needed - if ((elem.ownerDocument || elem) !== document) { - setDocument(elem); - } - - // Make sure that attribute selectors are quoted - expr = expr.replace(rattributeQuotes, '=\'$1\']'); - - if (support.matchesSelector && documentIsHTML && - (!rbuggyMatches || !rbuggyMatches.test(expr)) && - (!rbuggyQSA || !rbuggyQSA.test(expr))) { - - try { - var ret = matches.call(elem, expr); - - // IE 9's matchesSelector returns false on disconnected nodes - if (ret || support.disconnectedMatch || - // As well, disconnected nodes are said to be in a document - // fragment in IE 9 - elem.document && elem.document.nodeType !== 11) { - return ret; - } - } catch (e) {} - } - - return Sizzle(expr, document, null, [elem]).length > 0; - }; - - Sizzle.contains = function (context, elem) { - // Set document vars if needed - if ((context.ownerDocument || context) !== document) { - setDocument(context); - } - - return contains(context, elem); - }; - - Sizzle.attr = function (elem, name) { - // Set document vars if needed - if ((elem.ownerDocument || elem) !== document) { - setDocument(elem); - } - - var fn = Expr.attrHandle[ name.toLowerCase() ], - // Don't get fooled by Object.prototype properties (jQuery #13807) - val = fn && hasOwn.call(Expr.attrHandle, name.toLowerCase()) ? - fn(elem, name, !documentIsHTML) : - undefined; - - return val !== undefined ? - val : - support.attributes || !documentIsHTML ? - elem.getAttribute(name) : - (val = elem.getAttributeNode(name)) && val.specified ? - val.value : - null; - }; - - Sizzle.error = function (msg) { - throw new Error('Syntax error, unrecognized expression: ' + msg); - }; - - /** - * Document sorting and removing duplicates - * @param {ArrayLike} results - */ - Sizzle.uniqueSort = function (results) { - var elem, - duplicates = [], - j = 0, - i = 0; - - // Unless we *know* we can detect duplicates, assume their presence - hasDuplicate = !support.detectDuplicates; - sortInput = !support.sortStable && results.slice(0); - results.sort(sortOrder); - - if (hasDuplicate) { - while (elem = results[i++]) { - if (elem === results[ i ]) { - j = duplicates.push(i); - } - } - - while (j--) { - results.splice(duplicates[ j ], 1); - } - } - - // Clear input after sorting to release objects - // See https://github.com/jquery/sizzle/pull/225 - sortInput = null; - - return results; - }; - - /** - * Utility function for retrieving the text value of an array of DOM nodes - * @param {Array|Element} elem - */ - getText = Sizzle.getText = function (elem) { - var node, - ret = '', - i = 0, - nodeType = elem.nodeType; - - if (!nodeType) { - // If no nodeType, this is expected to be an array - while (node = elem[i++]) { - // Do not traverse comment nodes - ret += getText(node); - } - } else if (nodeType === 1 || nodeType === 9 || nodeType === 11) { - // Use textContent for elements - // innerText usage removed for consistency of new lines (jQuery #11153) - if (typeof elem.textContent === 'string') { - return elem.textContent; - } - // Traverse its children - for (elem = elem.firstChild; elem; elem = elem.nextSibling) { - ret += getText(elem); - } - - } else if (nodeType === 3 || nodeType === 4) { - return elem.nodeValue; - } - // Do not include comment or processing instruction nodes - - return ret; - }; - - Expr = Sizzle.selectors = { - - // Can be adjusted by the user - cacheLength: 50, - - createPseudo: markFunction, - - match: matchExpr, - - attrHandle: {}, - - find: {}, - - relative: { - '>': { - dir: 'parentNode', first: true - }, - ' ': { - dir: 'parentNode' - }, - '+': { - dir: 'previousSibling', first: true - }, - '~': { - dir: 'previousSibling' - } - }, - - preFilter: { - 'ATTR': function (match) { - match[1] = match[1].replace(runescape, funescape); - - // Move the given value to match[3] whether quoted or unquoted - match[3] = (match[3] || match[4] || match[5] || '').replace(runescape, funescape); - - if (match[2] === '~=') { - match[3] = ' ' + match[3] + ' '; - } - - return match.slice(0, 4); - }, - - 'CHILD': function (match) { - /* matches from matchExpr["CHILD"] - 1 type (only|nth|...) - 2 what (child|of-type) - 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) - 4 xn-component of xn+y argument ([+-]?\d*n|) - 5 sign of xn-component - 6 x of xn-component - 7 sign of y-component - 8 y of y-component - */ - match[1] = match[1].toLowerCase(); - - if (match[1].slice(0, 3) === 'nth') { - // nth-* requires argument - if (!match[3]) { - Sizzle.error(match[0]); - } - - // numeric x and y parameters for Expr.filter.CHILD - // remember that false/true cast respectively to 0/1 - match[4] = +(match[4] ? match[5] + (match[6] || 1) : 2 * (match[3] === 'even' || match[3] === 'odd')); - match[5] = +(match[7] + match[8] || match[3] === 'odd'); - - // other types prohibit arguments - } else if (match[3]) { - Sizzle.error(match[0]); - } - - return match; - }, - - 'PSEUDO': function (match) { - var excess, - unquoted = !match[6] && match[2]; - - if (matchExpr['CHILD'].test(match[0])) { - return null; - } - - // Accept quoted arguments as-is - if (match[3]) { - match[2] = match[4] || match[5] || ''; - - // Strip excess characters from unquoted arguments - } else if (unquoted && rpseudo.test(unquoted) && - // Get excess from tokenize (recursively) - (excess = tokenize(unquoted, true)) && - // advance to the next closing parenthesis - (excess = unquoted.indexOf(')', unquoted.length - excess) - unquoted.length)) { - - // excess is a negative index - match[0] = match[0].slice(0, excess); - match[2] = unquoted.slice(0, excess); - } - - // Return only captures needed by the pseudo filter method (type and argument) - return match.slice(0, 3); - } - }, - - filter: { - - 'TAG': function (nodeNameSelector) { - var nodeName = nodeNameSelector.replace(runescape, funescape).toLowerCase(); - - return nodeNameSelector === '*' ? - function () { - return true; - } : - function (elem) { - return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; - }; - }, - - 'CLASS': function (className) { - var pattern = classCache[ className + ' ' ]; - - return pattern || - (pattern = new RegExp('(^|' + whitespace + ')' + className + '(' + whitespace + '|$)')) && - classCache(className, function (elem) { - return pattern.test(typeof elem.className === 'string' && elem.className || typeof elem.getAttribute !== 'undefined' && elem.getAttribute('class') || ''); - }); - }, - - 'ATTR': function (name, operator, check) { - return function (elem) { - var result = Sizzle.attr(elem, name); - - if (result == null) { - return operator === '!='; - } - - if (!operator) { - return true; - } - - result += ''; - - return operator === '=' ? result === check : - operator === '!=' ? result !== check : - operator === '^=' ? check && result.indexOf(check) === 0 : - operator === '*=' ? check && result.indexOf(check) > -1 : - operator === '$=' ? check && result.slice(-check.length) === check : - operator === '~=' ? (' ' + result.replace(rwhitespace, ' ') + ' ').indexOf(check) > -1 : - operator === '|=' ? result === check || result.slice(0, check.length + 1) === check + '-' : - false; - }; - }, - - 'CHILD': function (type, what, argument, first, last) { - var simple = type.slice(0, 3) !== 'nth', - forward = type.slice(-4) !== 'last', - ofType = what === 'of-type'; - - return first === 1 && last === 0 ? - - // Shortcut for :nth-*(n) - function (elem) { - return !!elem.parentNode; - } : - - function (elem, context, xml) { - var cache, outerCache, node, diff, nodeIndex, start, - dir = simple !== forward ? 'nextSibling' : 'previousSibling', - parent = elem.parentNode, - name = ofType && elem.nodeName.toLowerCase(), - useCache = !xml && !ofType; - - if (parent) { - - // :(first|last|only)-(child|of-type) - if (simple) { - while (dir) { - node = elem; - - while (node = node[ dir ]) { - if (ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1) { - return false; - } - } - // Reverse direction for :only-* (if we haven't yet done so) - start = dir = type === 'only' && !start && 'nextSibling'; - } - - return true; - } - - start = [forward ? parent.firstChild : parent.lastChild]; - - // non-xml :nth-child(...) stores cache data on `parent` - if (forward && useCache) { - // Seek `elem` from a previously-cached index - outerCache = parent[ expando ] || (parent[ expando ] = {}); - cache = outerCache[ type ] || []; - nodeIndex = cache[0] === dirruns && cache[1]; - diff = cache[0] === dirruns && cache[2]; - node = nodeIndex && parent.childNodes[ nodeIndex ]; - - while (node = ++nodeIndex && node && node[ dir ] || - - // Fallback to seeking `elem` from the start - (diff = nodeIndex = 0) || start.pop()) { - - // When found, cache indexes on `parent` and break - if (node.nodeType === 1 && ++diff && node === elem) { - outerCache[ type ] = [dirruns, nodeIndex, diff]; - break; - } - } - - // Use previously-cached element index if available - } else if (useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns) { - diff = cache[1]; - - // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...) - } else { - // Use the same loop as above to seek `elem` from the start - while (node = ++nodeIndex && node && node[ dir ] || - (diff = nodeIndex = 0) || start.pop()) { - - if ((ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1) && ++diff) { - // Cache the index of each encountered element - if (useCache) { - (node[ expando ] || (node[ expando ] = {}))[ type ] = [dirruns, diff]; - } - - if (node === elem) { - break; - } - } - } - } - - // Incorporate the offset, then check against cycle size - diff -= last; - - return diff === first || diff % first === 0 && diff / first >= 0; - } - }; - }, - - 'PSEUDO': function (pseudo, argument) { - // pseudo-class names are case-insensitive - // http://www.w3.org/TR/selectors/#pseudo-classes - // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters - // Remember that setFilters inherits from pseudos - var args, - fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || - Sizzle.error('unsupported pseudo: ' + pseudo); - - // The user may use createPseudo to indicate that - // arguments are needed to create the filter function - // just as Sizzle does - if (fn[ expando ]) { - return fn(argument); - } - - // But maintain support for old signatures - if (fn.length > 1) { - args = [pseudo, pseudo, '', argument]; - - return Expr.setFilters.hasOwnProperty(pseudo.toLowerCase()) ? - markFunction(function (seed, matches) { - var idx, - matched = fn(seed, argument), - i = matched.length; - - while (i--) { - idx = indexOf(seed, matched[i]); - seed[ idx ] = !(matches[ idx ] = matched[i]); - } - }) : - function (elem) { - return fn(elem, 0, args); - }; - } - - return fn; - } - }, - - pseudos: { - // Potentially complex pseudos - 'not': markFunction(function (selector) { - // Trim the selector passed to compile - // to avoid treating leading and trailing - // spaces as combinators - var input = [], - results = [], - matcher = compile(selector.replace(rtrim, '$1')); - - return matcher[ expando ] ? - markFunction(function (seed, matches, context, xml) { - var elem, - unmatched = matcher(seed, null, xml, []), - i = seed.length; - - // Match elements unmatched by `matcher` - while (i--) { - if (elem = unmatched[i]) { - seed[i] = !(matches[i] = elem); - } - } - }) : - function (elem, context, xml) { - input[0] = elem; - matcher(input, null, xml, results); - // Don't keep the element (issue #299) - input[0] = null; - - return !results.pop(); - }; - }), - - 'has': markFunction(function (selector) { - return function (elem) { - return Sizzle(selector, elem).length > 0; - }; - }), - - 'contains': markFunction(function (text) { - text = text.replace(runescape, funescape); - - return function (elem) { - return (elem.textContent || elem.innerText || getText(elem)).indexOf(text) > -1; - }; - }), - - // "Whether an element is represented by a :lang() selector - // is based solely on the element's language value - // being equal to the identifier C, - // or beginning with the identifier C immediately followed by "-". - // The matching of C against the element's language value is performed case-insensitively. - // The identifier C does not have to be a valid language name." - // http://www.w3.org/TR/selectors/#lang-pseudo - 'lang': markFunction(function (lang) { - // lang value must be a valid identifier - if (!ridentifier.test(lang || '')) { - Sizzle.error('unsupported lang: ' + lang); - } - lang = lang.replace(runescape, funescape).toLowerCase(); - - return function (elem) { - var elemLang; - - do { - if (elemLang = documentIsHTML ? - elem.lang : - elem.getAttribute('xml:lang') || elem.getAttribute('lang')) { - - elemLang = elemLang.toLowerCase(); - - return elemLang === lang || elemLang.indexOf(lang + '-') === 0; - } - } while ((elem = elem.parentNode) && elem.nodeType === 1); - - return false; - }; - }), - - // Miscellaneous - 'target': function (elem) { - var hash = window.location && window.location.hash; - - return hash && hash.slice(1) === elem.id; - }, - - 'root': function (elem) { - return elem === docElem; - }, - - 'focus': function (elem) { - return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex); - }, - - // Boolean properties - 'enabled': function (elem) { - return elem.disabled === false; - }, - - 'disabled': function (elem) { - return elem.disabled === true; - }, - - 'checked': function (elem) { - // In CSS3, :checked should return both checked and selected elements - // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked - var nodeName = elem.nodeName.toLowerCase(); - - return nodeName === 'input' && !!elem.checked || nodeName === 'option' && !!elem.selected; - }, - - 'selected': function (elem) { - // Accessing this property makes selected-by-default - // options in Safari work properly - if (elem.parentNode) { - elem.parentNode.selectedIndex; - } - - return elem.selected === true; - }, - - // Contents - 'empty': function (elem) { - // http://www.w3.org/TR/selectors/#empty-pseudo - // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5), - // but not by others (comment: 8; processing instruction: 7; etc.) - // nodeType < 6 works because attributes (2) do not appear as children - for (elem = elem.firstChild; elem; elem = elem.nextSibling) { - if (elem.nodeType < 6) { - return false; - } - } - - return true; - }, - - 'parent': function (elem) { - return !Expr.pseudos['empty'](elem); - }, - - // Element/input types - 'header': function (elem) { - return rheader.test(elem.nodeName); - }, - - 'input': function (elem) { - return rinputs.test(elem.nodeName); - }, - - 'button': function (elem) { - var name = elem.nodeName.toLowerCase(); - - return name === 'input' && elem.type === 'button' || name === 'button'; - }, - - 'text': function (elem) { - var attr; - - return elem.nodeName.toLowerCase() === 'input' && - elem.type === 'text' && - - // Support: IE<8 - // New HTML5 attribute values (e.g., "search") appear with elem.type === "text" - ((attr = elem.getAttribute('type')) == null || attr.toLowerCase() === 'text'); - }, - - // Position-in-collection - 'first': createPositionalPseudo(function () { - return [0]; - }), - - 'last': createPositionalPseudo(function (matchIndexes, length) { - return [length - 1]; - }), - - 'eq': createPositionalPseudo(function (matchIndexes, length, argument) { - return [argument < 0 ? argument + length : argument]; - }), - - 'even': createPositionalPseudo(function (matchIndexes, length) { - var i = 0; - - for (; i < length; i += 2) { - matchIndexes.push(i); - } - - return matchIndexes; - }), - - 'odd': createPositionalPseudo(function (matchIndexes, length) { - var i = 1; - - for (; i < length; i += 2) { - matchIndexes.push(i); - } - - return matchIndexes; - }), - - 'lt': createPositionalPseudo(function (matchIndexes, length, argument) { - var i = argument < 0 ? argument + length : argument; - - for (; --i >= 0;) { - matchIndexes.push(i); - } - - return matchIndexes; - }), - - 'gt': createPositionalPseudo(function (matchIndexes, length, argument) { - var i = argument < 0 ? argument + length : argument; - - for (; ++i < length;) { - matchIndexes.push(i); - } - - return matchIndexes; - }) - } - }; - - Expr.pseudos['nth'] = Expr.pseudos['eq']; - - // Add button/input type pseudos - for (i in { - radio: true, checkbox: true, file: true, password: true, image: true - }) { - Expr.pseudos[ i ] = createInputPseudo(i); - } - - for (i in { - submit: true, reset: true - }) { - Expr.pseudos[ i ] = createButtonPseudo(i); - } - - // Easy API for creating new setFilters - function setFilters() {} - setFilters.prototype = Expr.filters = Expr.pseudos; - Expr.setFilters = new setFilters(); - - tokenize = Sizzle.tokenize = function (selector, parseOnly) { - var matched, match, tokens, type, - soFar, groups, preFilters, - cached = tokenCache[ selector + ' ' ]; - - if (cached) { - return parseOnly ? 0 : cached.slice(0); - } - - soFar = selector; - groups = []; - preFilters = Expr.preFilter; - - while (soFar) { - - // Comma and first run - if (!matched || (match = rcomma.exec(soFar))) { - if (match) { - // Don't consume trailing commas as valid - soFar = soFar.slice(match[0].length) || soFar; - } - groups.push(tokens = []); - } - - matched = false; - - // Combinators - if (match = rcombinators.exec(soFar)) { - matched = match.shift(); - tokens.push({ - value: matched, - // Cast descendant combinators to space - type: match[0].replace(rtrim, ' ') - }); - soFar = soFar.slice(matched.length); - } - - // Filters - for (type in Expr.filter) { - if ((match = matchExpr[ type ].exec(soFar)) && (!preFilters[ type ] || - (match = preFilters[ type ](match)))) { - matched = match.shift(); - tokens.push({ - value: matched, - type: type, - matches: match - }); - soFar = soFar.slice(matched.length); - } - } - - if (!matched) { - break; - } - } - - // Return the length of the invalid excess - // if we're just parsing - // Otherwise, throw an error or return tokens - return parseOnly ? - soFar.length : - soFar ? - Sizzle.error(selector) : - // Cache the tokens - tokenCache(selector, groups).slice(0); - }; - - function toSelector(tokens) { - var i = 0, - len = tokens.length, - selector = ''; - - for (; i < len; i++) { - selector += tokens[i].value; - } - - return selector; - } - - function addCombinator(matcher, combinator, base) { - var dir = combinator.dir, - checkNonElements = base && dir === 'parentNode', - doneName = done++; - - return combinator.first ? - // Check against closest ancestor/preceding element - function (elem, context, xml) { - while (elem = elem[ dir ]) { - if (elem.nodeType === 1 || checkNonElements) { - return matcher(elem, context, xml); - } - } - } : - - // Check against all ancestor/preceding elements - function (elem, context, xml) { - var oldCache, outerCache, - newCache = [dirruns, doneName]; - - // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching - if (xml) { - while (elem = elem[ dir ]) { - if (elem.nodeType === 1 || checkNonElements) { - if (matcher(elem, context, xml)) { - return true; - } - } - } - } else { - while (elem = elem[ dir ]) { - if (elem.nodeType === 1 || checkNonElements) { - outerCache = elem[ expando ] || (elem[ expando ] = {}); - - if ((oldCache = outerCache[ dir ]) && - oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName) { - - // Assign to newCache so results back-propagate to previous elements - return newCache[ 2 ] = oldCache[ 2 ]; - } - // Reuse newcache so results back-propagate to previous elements - outerCache[ dir ] = newCache; - - // A match means we're done; a fail means we have to keep checking - if (newCache[ 2 ] = matcher(elem, context, xml)) { - return true; - } - - } - } - } - }; - } - - function elementMatcher(matchers) { - return matchers.length > 1 ? - function (elem, context, xml) { - var i = matchers.length; - - while (i--) { - if (!matchers[i](elem, context, xml)) { - return false; - } - } - - return true; - } : - matchers[0]; - } - - function multipleContexts(selector, contexts, results) { - var i = 0, - len = contexts.length; - - for (; i < len; i++) { - Sizzle(selector, contexts[i], results); - } - - return results; - } - - function condense(unmatched, map, filter, context, xml) { - var elem, - newUnmatched = [], - i = 0, - len = unmatched.length, - mapped = map != null; - - for (; i < len; i++) { - if (elem = unmatched[i]) { - if (!filter || filter(elem, context, xml)) { - newUnmatched.push(elem); - - if (mapped) { - map.push(i); - } - } - } - } - - return newUnmatched; - } - - function setMatcher(preFilter, selector, matcher, postFilter, postFinder, postSelector) { - if (postFilter && !postFilter[ expando ]) { - postFilter = setMatcher(postFilter); - } - - if (postFinder && !postFinder[ expando ]) { - postFinder = setMatcher(postFinder, postSelector); - } - - return markFunction(function (seed, results, context, xml) { - var temp, i, elem, - preMap = [], - postMap = [], - preexisting = results.length, - - // Get initial elements from seed or context - elems = seed || multipleContexts(selector || '*', context.nodeType ? [context] : context, []), - - // Prefilter to get matcher input, preserving a map for seed-results synchronization - matcherIn = preFilter && (seed || !selector) ? - condense(elems, preMap, preFilter, context, xml) : - elems, - - matcherOut = matcher ? - // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, - postFinder || (seed ? preFilter : preexisting || postFilter) ? - - // ...intermediate processing is necessary - [] : - - // ...otherwise use results directly - results : - matcherIn; - - // Find primary matches - if (matcher) { - matcher(matcherIn, matcherOut, context, xml); - } - - // Apply postFilter - if (postFilter) { - temp = condense(matcherOut, postMap); - postFilter(temp, [], context, xml); - - // Un-match failing elements by moving them back to matcherIn - i = temp.length; - - while (i--) { - if (elem = temp[i]) { - matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); - } - } - } - - if (seed) { - if (postFinder || preFilter) { - if (postFinder) { - // Get the final matcherOut by condensing this intermediate into postFinder contexts - temp = []; - i = matcherOut.length; - - while (i--) { - if (elem = matcherOut[i]) { - // Restore matcherIn since elem is not yet a final match - temp.push(matcherIn[i] = elem); - } - } - postFinder(null, matcherOut = [], temp, xml); - } - - // Move matched elements from seed to results to keep them synchronized - i = matcherOut.length; - - while (i--) { - if ((elem = matcherOut[i]) && - (temp = postFinder ? indexOf(seed, elem) : preMap[i]) > -1) { - - seed[temp] = !(results[temp] = elem); - } - } - } - - // Add elements to results, through postFinder if defined - } else { - matcherOut = condense( - matcherOut === results ? - matcherOut.splice(preexisting, matcherOut.length) : - matcherOut - ); - - if (postFinder) { - postFinder(null, results, matcherOut, xml); - } else { - push.apply(results, matcherOut); - } - } - }); - } - - function matcherFromTokens(tokens) { - var checkContext, matcher, j, - len = tokens.length, - leadingRelative = Expr.relative[ tokens[0].type ], - implicitRelative = leadingRelative || Expr.relative[' '], - i = leadingRelative ? 1 : 0, - - // The foundational matcher ensures that elements are reachable from top-level context(s) - matchContext = addCombinator(function (elem) { - return elem === checkContext; - }, implicitRelative, true), - matchAnyContext = addCombinator(function (elem) { - return indexOf(checkContext, elem) > -1; - }, implicitRelative, true), - matchers = [function (elem, context, xml) { - var ret = !leadingRelative && (xml || context !== outermostContext) || ( - (checkContext = context).nodeType ? - matchContext(elem, context, xml) : - matchAnyContext(elem, context, xml)); - // Avoid hanging onto element (issue #299) - - checkContext = null; - - return ret; - }]; - - for (; i < len; i++) { - if (matcher = Expr.relative[ tokens[i].type ]) { - matchers = [addCombinator(elementMatcher(matchers), matcher)]; - } else { - matcher = Expr.filter[ tokens[i].type ].apply(null, tokens[i].matches); - - // Return special upon seeing a positional matcher - if (matcher[ expando ]) { - // Find the next relative operator (if any) for proper handling - j = ++i; - - for (; j < len; j++) { - if (Expr.relative[ tokens[j].type ]) { - break; - } - } - - return setMatcher( - i > 1 && elementMatcher(matchers), - i > 1 && toSelector( - // If the preceding token was a descendant combinator, insert an implicit any-element `*` - tokens.slice(0, i - 1).concat({ - value: tokens[ i - 2 ].type === ' ' ? '*' : '' - }) - ).replace(rtrim, '$1'), - matcher, - i < j && matcherFromTokens(tokens.slice(i, j)), - j < len && matcherFromTokens(tokens = tokens.slice(j)), - j < len && toSelector(tokens) - ); - } - matchers.push(matcher); - } - } - - return elementMatcher(matchers); - } - - function matcherFromGroupMatchers(elementMatchers, setMatchers) { - var bySet = setMatchers.length > 0, - byElement = elementMatchers.length > 0, - superMatcher = function (seed, context, xml, results, outermost) { - var elem, j, matcher, - matchedCount = 0, - i = '0', - unmatched = seed && [], - setMatched = [], - contextBackup = outermostContext, - // We must always have either seed elements or outermost context - elems = seed || byElement && Expr.find['TAG']('*', outermost), - // Use integer dirruns iff this is the outermost matcher - dirrunsUnique = dirruns += contextBackup == null ? 1 : Math.random() || 0.1, - len = elems.length; - - if (outermost) { - outermostContext = context !== document && context; - } - - // Add elements passing elementMatchers directly to results - // Keep `i` a string if there are no elements so `matchedCount` will be "00" below - // Support: IE<9, Safari - // Tolerate NodeList properties (IE: "length"; Safari: ) matching elements by id - for (; i !== len && (elem = elems[i]) != null; i++) { - if (byElement && elem) { - j = 0; - - while (matcher = elementMatchers[j++]) { - if (matcher(elem, context, xml)) { - results.push(elem); - break; - } - } - - if (outermost) { - dirruns = dirrunsUnique; - } - } - - // Track unmatched elements for set filters - if (bySet) { - // They will have gone through all possible matchers - if (elem = !matcher && elem) { - matchedCount--; - } - - // Lengthen the array for every element, matched or not - if (seed) { - unmatched.push(elem); - } - } - } - - // Apply set filters to unmatched elements - matchedCount += i; - - if (bySet && i !== matchedCount) { - j = 0; - - while (matcher = setMatchers[j++]) { - matcher(unmatched, setMatched, context, xml); - } - - if (seed) { - // Reintegrate element matches to eliminate the need for sorting - if (matchedCount > 0) { - while (i--) { - if (!(unmatched[i] || setMatched[i])) { - setMatched[i] = pop.call(results); - } - } - } - - // Discard index placeholder values to get only actual matches - setMatched = condense(setMatched); - } - - // Add matches to results - push.apply(results, setMatched); - - // Seedless set matches succeeding multiple successful matchers stipulate sorting - if (outermost && !seed && setMatched.length > 0 && - matchedCount + setMatchers.length > 1) { - - Sizzle.uniqueSort(results); - } - } - - // Override manipulation of globals by nested matchers - if (outermost) { - dirruns = dirrunsUnique; - outermostContext = contextBackup; - } - - return unmatched; - }; - - return bySet ? - markFunction(superMatcher) : - superMatcher; - } - - compile = Sizzle.compile = function (selector, match /* Internal Use Only */) { - var i, - setMatchers = [], - elementMatchers = [], - cached = compilerCache[ selector + ' ' ]; - - if (!cached) { - // Generate a function of recursive functions that can be used to check each element - if (!match) { - match = tokenize(selector); - } - i = match.length; - - while (i--) { - cached = matcherFromTokens(match[i]); - - if (cached[ expando ]) { - setMatchers.push(cached); - } else { - elementMatchers.push(cached); - } - } - - // Cache the compiled function - cached = compilerCache(selector, matcherFromGroupMatchers(elementMatchers, setMatchers)); - - // Save selector and tokenization - cached.selector = selector; - } - - return cached; - }; - - /** - * A low-level selection function that works with Sizzle's compiled - * selector functions - * @param {String|Function} selector A selector or a pre-compiled - * selector function built with Sizzle.compile - * @param {Element} context - * @param {Array} [results] - * @param {Array} [seed] A set of elements to match against - */ - select = Sizzle.select = function (selector, context, results, seed) { - var i, tokens, token, type, find, - compiled = typeof selector === 'function' && selector, - match = !seed && tokenize(selector = compiled.selector || selector); - - results = results || []; - - // Try to minimize operations if there is no seed and only one group - if (match.length === 1) { - - // Take a shortcut and set the context if the root selector is an ID - tokens = match[0] = match[0].slice(0); - - if (tokens.length > 2 && (token = tokens[0]).type === 'ID' && - support.getById && context.nodeType === 9 && documentIsHTML && - Expr.relative[ tokens[1].type ]) { - - context = (Expr.find['ID'](token.matches[0].replace(runescape, funescape), context) || [])[0]; - - if (!context) { - return results; - - // Precompiled matchers will still verify ancestry, so step up a level - } else if (compiled) { - context = context.parentNode; - } - - selector = selector.slice(tokens.shift().value.length); - } - - // Fetch a seed set for right-to-left matching - i = matchExpr['needsContext'].test(selector) ? 0 : tokens.length; - - while (i--) { - token = tokens[i]; - - // Abort if we hit a combinator - if (Expr.relative[ type = token.type ]) { - break; - } - - if (find = Expr.find[ type ]) { - // Search, expanding context for leading sibling combinators - if (seed = find( - token.matches[0].replace(runescape, funescape), - rsibling.test(tokens[0].type) && testContext(context.parentNode) || context - )) { - - // If seed is empty or no tokens remain, we can return early - tokens.splice(i, 1); - selector = seed.length && toSelector(tokens); - - if (!selector) { - push.apply(results, seed); - - return results; - } - - break; - } - } - } - } - - // Compile and execute a filtering function if one is not provided - // Provide `match` to avoid retokenization if we modified the selector above - (compiled || compile(selector, match))( - seed, - context, - !documentIsHTML, - results, - rsibling.test(selector) && testContext(context.parentNode) || context - ); - - return results; - }; - - // One-time assignments - - // Sort stability - support.sortStable = expando.split('').sort(sortOrder).join('') === expando; - - // Support: Chrome 14-35+ - // Always assume duplicates if they aren't passed to the comparison function - support.detectDuplicates = !!hasDuplicate; - - // Initialize against the default document - setDocument(); - - // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27) - // Detached nodes confoundingly follow *each other* - support.sortDetached = assert(function (div1) { - // Should return 1, but returns 4 (following) - return div1.compareDocumentPosition(document.createElement('div')) & 1; - }); - - // Support: IE<8 - // Prevent attribute/property "interpolation" - // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx - if (!assert(function (div) { - div.innerHTML = ''; - - return div.firstChild.getAttribute('href') === '#'; - })) { - addHandle('type|href|height|width', function (elem, name, isXML) { - if (!isXML) { - return elem.getAttribute(name, name.toLowerCase() === 'type' ? 1 : 2); - } - }); - } - - // Support: IE<9 - // Use defaultValue in place of getAttribute("value") - if (!support.attributes || !assert(function (div) { - div.innerHTML = ''; - div.firstChild.setAttribute('value', ''); - - return div.firstChild.getAttribute('value') === ''; - })) { - addHandle('value', function (elem, name, isXML) { - if (!isXML && elem.nodeName.toLowerCase() === 'input') { - return elem.defaultValue; - } - }); - } - - // Support: IE<9 - // Use getAttributeNode to fetch booleans when getAttribute lies - if (!assert(function (div) { - return div.getAttribute('disabled') == null; - })) { - addHandle(booleans, function (elem, name, isXML) { - var val; - - if (!isXML) { - return elem[ name ] === true ? name.toLowerCase() : - (val = elem.getAttributeNode(name)) && val.specified ? - val.value : - null; - } - }); - } - - return Sizzle; - - })(window); - - jQuery.find = Sizzle; - jQuery.expr = Sizzle.selectors; - jQuery.expr[':'] = jQuery.expr.pseudos; - jQuery.unique = Sizzle.uniqueSort; - jQuery.text = Sizzle.getText; - jQuery.isXMLDoc = Sizzle.isXML; - jQuery.contains = Sizzle.contains; - - var rneedsContext = jQuery.expr.match.needsContext; - - var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/); - - var risSimple = /^.[^:#\[\.,]*$/; - - // Implement the identical functionality for filter and not - function winnow(elements, qualifier, not) { - if (jQuery.isFunction(qualifier)) { - return jQuery.grep(elements, function (elem, i) { - /* jshint -W018 */ - return !!qualifier.call(elem, i, elem) !== not; - }); - - } - - if (qualifier.nodeType) { - return jQuery.grep(elements, function (elem) { - return elem === qualifier !== not; - }); - - } - - if (typeof qualifier === 'string') { - if (risSimple.test(qualifier)) { - return jQuery.filter(qualifier, elements, not); - } - - qualifier = jQuery.filter(qualifier, elements); - } - - return jQuery.grep(elements, function (elem) { - return indexOf.call(qualifier, elem) >= 0 !== not; - }); - } - - jQuery.filter = function (expr, elems, not) { - var elem = elems[ 0 ]; - - if (not) { - expr = ':not(' + expr + ')'; - } - - return elems.length === 1 && elem.nodeType === 1 ? - jQuery.find.matchesSelector(elem, expr) ? [elem] : [] : - jQuery.find.matches(expr, jQuery.grep(elems, function (elem) { - return elem.nodeType === 1; - })); - }; - - jQuery.fn.extend({ - find: function (selector) { - var i, - len = this.length, - ret = [], - self = this; - - if (typeof selector !== 'string') { - return this.pushStack(jQuery(selector).filter(function () { - for (i = 0; i < len; i++) { - if (jQuery.contains(self[ i ], this)) { - return true; - } - } - })); - } - - for (i = 0; i < len; i++) { - jQuery.find(selector, self[ i ], ret); - } - - // Needed because $( selector, context ) becomes $( context ).find( selector ) - ret = this.pushStack(len > 1 ? jQuery.unique(ret) : ret); - ret.selector = this.selector ? this.selector + ' ' + selector : selector; - - return ret; - }, - filter: function (selector) { - return this.pushStack(winnow(this, selector || [], false)); - }, - not: function (selector) { - return this.pushStack(winnow(this, selector || [], true)); - }, - is: function (selector) { - return !!winnow( - this, - - // If this is a positional/relative selector, check membership in the returned set - // so $("p:first").is("p:last") won't return true for a doc with two "p". - typeof selector === 'string' && rneedsContext.test(selector) ? - jQuery(selector) : - selector || [], - false - ).length; - } - }); - - - // Initialize a jQuery object - - - // A central reference to the root jQuery(document) - var rootjQuery, - - // A simple way to check for HTML strings - // Prioritize #id over to avoid XSS via location.hash (#9521) - // Strict HTML recognition (#11290: must start with <) - rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, - - init = jQuery.fn.init = function (selector, context) { - var match, elem; - - // HANDLE: $(""), $(null), $(undefined), $(false) - if (!selector) { - return this; - } - - // Handle HTML strings - if (typeof selector === 'string') { - if (selector[0] === '<' && selector[ selector.length - 1 ] === '>' && selector.length >= 3) { - // Assume that strings that start and end with <> are HTML and skip the regex check - match = [null, selector, null]; - - } else { - match = rquickExpr.exec(selector); - } - - // Match html or make sure no context is specified for #id - if (match && (match[1] || !context)) { - - // HANDLE: $(html) -> $(array) - if (match[1]) { - context = context instanceof jQuery ? context[0] : context; - - // Option to run scripts is true for back-compat - // Intentionally let the error be thrown if parseHTML is not present - jQuery.merge(this, jQuery.parseHTML( - match[1], - context && context.nodeType ? context.ownerDocument || context : document, - true - )); - - // HANDLE: $(html, props) - if (rsingleTag.test(match[1]) && jQuery.isPlainObject(context)) { - for (match in context) { - // Properties of context are called as methods if possible - if (jQuery.isFunction(this[ match ])) { - this[ match ](context[ match ]); - - // ...and otherwise set as attributes - } else { - this.attr(match, context[ match ]); - } - } - } - - return this; - - // HANDLE: $(#id) - } - elem = document.getElementById(match[2]); - - // Support: Blackberry 4.6 - // gEBID returns nodes no longer in the document (#6963) - if (elem && elem.parentNode) { - // Inject the element directly into the jQuery object - this.length = 1; - this[0] = elem; - } - - this.context = document; - this.selector = selector; - - return this; - - - // HANDLE: $(expr, $(...)) - } else if (!context || context.jquery) { - return (context || rootjQuery).find(selector); - - // HANDLE: $(expr, context) - // (which is just equivalent to: $(context).find(expr) - } - - return this.constructor(context).find(selector); - - - // HANDLE: $(DOMElement) - } else if (selector.nodeType) { - this.context = this[0] = selector; - this.length = 1; - - return this; - - // HANDLE: $(function) - // Shortcut for document ready - } else if (jQuery.isFunction(selector)) { - return typeof rootjQuery.ready !== 'undefined' ? - rootjQuery.ready(selector) : - // Execute immediately if ready is not present - selector(jQuery); - } - - if (selector.selector !== undefined) { - this.selector = selector.selector; - this.context = selector.context; - } - - return jQuery.makeArray(selector, this); - }; - - // Give the init function the jQuery prototype for later instantiation - init.prototype = jQuery.fn; - - // Initialize central reference - rootjQuery = jQuery(document); - - var rparentsprev = /^(?:parents|prev(?:Until|All))/, - // Methods guaranteed to produce a unique set when starting from a unique set - guaranteedUnique = { - children: true, - contents: true, - next: true, - prev: true - }; - - jQuery.extend({ - dir: function (elem, dir, until) { - var matched = [], - truncate = until !== undefined; - - while ((elem = elem[ dir ]) && elem.nodeType !== 9) { - if (elem.nodeType === 1) { - if (truncate && jQuery(elem).is(until)) { - break; - } - matched.push(elem); - } - } - - return matched; - }, - - sibling: function (n, elem) { - var matched = []; - - for (; n; n = n.nextSibling) { - if (n.nodeType === 1 && n !== elem) { - matched.push(n); - } - } - - return matched; - } - }); - - jQuery.fn.extend({ - has: function (target) { - var targets = jQuery(target, this), - l = targets.length; - - return this.filter(function () { - var i = 0; - - for (; i < l; i++) { - if (jQuery.contains(this, targets[i])) { - return true; - } - } - }); - }, - - closest: function (selectors, context) { - var cur, - i = 0, - l = this.length, - matched = [], - pos = rneedsContext.test(selectors) || typeof selectors !== 'string' ? - jQuery(selectors, context || this.context) : - 0; - - for (; i < l; i++) { - for (cur = this[i]; cur && cur !== context; cur = cur.parentNode) { - // Always skip document fragments - if (cur.nodeType < 11 && (pos ? - pos.index(cur) > -1 : - - // Don't pass non-elements to Sizzle - cur.nodeType === 1 && - jQuery.find.matchesSelector(cur, selectors))) { - - matched.push(cur); - break; - } - } - } - - return this.pushStack(matched.length > 1 ? jQuery.unique(matched) : matched); - }, - - // Determine the position of an element within the set - index: function (elem) { - - // No argument, return index in parent - if (!elem) { - return this[ 0 ] && this[ 0 ].parentNode ? this.first().prevAll().length : -1; - } - - // Index in selector - if (typeof elem === 'string') { - return indexOf.call(jQuery(elem), this[ 0 ]); - } - - // Locate the position of the desired element - return indexOf.call(this, - - // If it receives a jQuery object, the first element is used - elem.jquery ? elem[ 0 ] : elem - ); - }, - - add: function (selector, context) { - return this.pushStack( - jQuery.unique( - jQuery.merge(this.get(), jQuery(selector, context)) - ) - ); - }, - - addBack: function (selector) { - return this.add(selector == null ? - this.prevObject : this.prevObject.filter(selector) - ); - } - }); - - function sibling(cur, dir) { - while ((cur = cur[dir]) && cur.nodeType !== 1) {} - - return cur; - } - - jQuery.each({ - parent: function (elem) { - var parent = elem.parentNode; - - return parent && parent.nodeType !== 11 ? parent : null; - }, - parents: function (elem) { - return jQuery.dir(elem, 'parentNode'); - }, - parentsUntil: function (elem, i, until) { - return jQuery.dir(elem, 'parentNode', until); - }, - next: function (elem) { - return sibling(elem, 'nextSibling'); - }, - prev: function (elem) { - return sibling(elem, 'previousSibling'); - }, - nextAll: function (elem) { - return jQuery.dir(elem, 'nextSibling'); - }, - prevAll: function (elem) { - return jQuery.dir(elem, 'previousSibling'); - }, - nextUntil: function (elem, i, until) { - return jQuery.dir(elem, 'nextSibling', until); - }, - prevUntil: function (elem, i, until) { - return jQuery.dir(elem, 'previousSibling', until); - }, - siblings: function (elem) { - return jQuery.sibling((elem.parentNode || {}).firstChild, elem); - }, - children: function (elem) { - return jQuery.sibling(elem.firstChild); - }, - contents: function (elem) { - return elem.contentDocument || jQuery.merge([], elem.childNodes); - } - }, function (name, fn) { - jQuery.fn[ name ] = function (until, selector) { - var matched = jQuery.map(this, fn, until); - - if (name.slice(-5) !== 'Until') { - selector = until; - } - - if (selector && typeof selector === 'string') { - matched = jQuery.filter(selector, matched); - } - - if (this.length > 1) { - // Remove duplicates - if (!guaranteedUnique[ name ]) { - jQuery.unique(matched); - } - - // Reverse order for parents* and prev-derivatives - if (rparentsprev.test(name)) { - matched.reverse(); - } - } - - return this.pushStack(matched); - }; - }); - var rnotwhite = (/\S+/g); - - - - // String to Object options format cache - var optionsCache = {}; - - // Convert String-formatted options into Object-formatted ones and store in cache - function createOptions(options) { - var object = optionsCache[ options ] = {}; - - jQuery.each(options.match(rnotwhite) || [], function (_, flag) { - object[ flag ] = true; - }); - - return object; - } - - /* - * Create a callback list using the following parameters: - * - * options: an optional list of space-separated options that will change how - * the callback list behaves or a more traditional option object - * - * By default a callback list will act like an event callback list and can be - * "fired" multiple times. - * - * Possible options: - * - * once: will ensure the callback list can only be fired once (like a Deferred) - * - * memory: will keep track of previous values and will call any callback added - * after the list has been fired right away with the latest "memorized" - * values (like a Deferred) - * - * unique: will ensure a callback can only be added once (no duplicate in the list) - * - * stopOnFalse: interrupt callings when a callback returns false - * - */ - jQuery.Callbacks = function (options) { - - // Convert options from String-formatted to Object-formatted if needed - // (we check in cache first) - options = typeof options === 'string' ? - optionsCache[ options ] || createOptions(options) : - jQuery.extend({}, options); - - var // Last fire value (for non-forgettable lists) - memory, - // Flag to know if list was already fired - fired, - // Flag to know if list is currently firing - firing, - // First callback to fire (used internally by add and fireWith) - firingStart, - // End of the loop when firing - firingLength, - // Index of currently firing callback (modified by remove if needed) - firingIndex, - // Actual callback list - list = [], - // Stack of fire calls for repeatable lists - stack = !options.once && [], - // Fire callbacks - fire = function (data) { - memory = options.memory && data; - fired = true; - firingIndex = firingStart || 0; - firingStart = 0; - firingLength = list.length; - firing = true; - - for (; list && firingIndex < firingLength; firingIndex++) { - if (list[ firingIndex ].apply(data[ 0 ], data[ 1 ]) === false && options.stopOnFalse) { - memory = false; // To prevent further calls using add - break; - } - } - firing = false; - - if (list) { - if (stack) { - if (stack.length) { - fire(stack.shift()); - } - } else if (memory) { - list = []; - } else { - self.disable(); - } - } - }, - // Actual Callbacks object - self = { - // Add a callback or a collection of callbacks to the list - add: function () { - if (list) { - // First, we save the current length - var start = list.length; - - (function add(args) { - jQuery.each(args, function (_, arg) { - var type = jQuery.type(arg); - - if (type === 'function') { - if (!options.unique || !self.has(arg)) { - list.push(arg); - } - } else if (arg && arg.length && type !== 'string') { - // Inspect recursively - add(arg); - } - }); - })(arguments); - // Do we need to add the callbacks to the - // current firing batch? - if (firing) { - firingLength = list.length; - // With memory, if we're not firing then - // we should call right away - } else if (memory) { - firingStart = start; - fire(memory); - } - } - - return this; - }, - // Remove a callback from the list - remove: function () { - if (list) { - jQuery.each(arguments, function (_, arg) { - var index; - - while ((index = jQuery.inArray(arg, list, index)) > -1) { - list.splice(index, 1); - // Handle firing indexes - if (firing) { - if (index <= firingLength) { - firingLength--; - } - - if (index <= firingIndex) { - firingIndex--; - } - } - } - }); - } - - return this; - }, - // Check if a given callback is in the list. - // If no argument is given, return whether or not list has callbacks attached. - has: function (fn) { - return fn ? jQuery.inArray(fn, list) > -1 : !!(list && list.length); - }, - // Remove all callbacks from the list - empty: function () { - list = []; - firingLength = 0; - - return this; - }, - // Have the list do nothing anymore - disable: function () { - list = stack = memory = undefined; - - return this; - }, - // Is it disabled? - disabled: function () { - return !list; - }, - // Lock the list in its current state - lock: function () { - stack = undefined; - - if (!memory) { - self.disable(); - } - - return this; - }, - // Is it locked? - locked: function () { - return !stack; - }, - // Call all callbacks with the given context and arguments - fireWith: function (context, args) { - if (list && (!fired || stack)) { - args = args || []; - args = [context, args.slice ? args.slice() : args]; - - if (firing) { - stack.push(args); - } else { - fire(args); - } - } - - return this; - }, - // Call all the callbacks with the given arguments - fire: function () { - self.fireWith(this, arguments); - - return this; - }, - // To know if the callbacks have already been called at least once - fired: function () { - return !!fired; - } - }; - - return self; - }; - - jQuery.extend({ - - Deferred: function (func) { - var tuples = [ - // action, add listener, listener list, final state - ['resolve', 'done', jQuery.Callbacks('once memory'), 'resolved'], - ['reject', 'fail', jQuery.Callbacks('once memory'), 'rejected'], - ['notify', 'progress', jQuery.Callbacks('memory')] - ], - state = 'pending', - promise = { - state: function () { - return state; - }, - always: function () { - deferred.done(arguments).fail(arguments); - - return this; - }, - then: function ( /* fnDone, fnFail, fnProgress */) { - var fns = arguments; - - return jQuery.Deferred(function (newDefer) { - jQuery.each(tuples, function (i, tuple) { - var fn = jQuery.isFunction(fns[ i ]) && fns[ i ]; - // deferred[ done | fail | progress ] for forwarding actions to newDefer - - deferred[ tuple[1] ](function () { - var returned = fn && fn.apply(this, arguments); - - if (returned && jQuery.isFunction(returned.promise)) { - returned.promise() - .done(newDefer.resolve) - .fail(newDefer.reject) - .progress(newDefer.notify); - } else { - newDefer[ tuple[ 0 ] + 'With' ](this === promise ? newDefer.promise() : this, fn ? [returned] : arguments); - } - }); - }); - fns = null; - }).promise(); - }, - // Get a promise for this deferred - // If obj is provided, the promise aspect is added to the object - promise: function (obj) { - return obj != null ? jQuery.extend(obj, promise) : promise; - } - }, - deferred = {}; - - // Keep pipe for back-compat - promise.pipe = promise.then; - - // Add list-specific methods - jQuery.each(tuples, function (i, tuple) { - var list = tuple[ 2 ], - stateString = tuple[ 3 ]; - - // promise[ done | fail | progress ] = list.add - promise[ tuple[1] ] = list.add; - - // Handle state - if (stateString) { - list.add(function () { - // state = [ resolved | rejected ] - state = stateString; - - // [ reject_list | resolve_list ].disable; progress_list.lock - }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock); - } - - // deferred[ resolve | reject | notify ] - deferred[ tuple[0] ] = function () { - deferred[ tuple[0] + 'With' ](this === deferred ? promise : this, arguments); - - return this; - }; - deferred[ tuple[0] + 'With' ] = list.fireWith; - }); - - // Make the deferred a promise - promise.promise(deferred); - - // Call given func if any - if (func) { - func.call(deferred, deferred); - } - - // All done! - return deferred; - }, - - // Deferred helper - when: function (subordinate /* , ..., subordinateN */) { - var i = 0, - resolveValues = slice.call(arguments), - length = resolveValues.length, - - // the count of uncompleted subordinates - remaining = length !== 1 || subordinate && jQuery.isFunction(subordinate.promise) ? length : 0, - - // the master Deferred. If resolveValues consist of only a single Deferred, just use that. - deferred = remaining === 1 ? subordinate : jQuery.Deferred(), - - // Update function for both resolve and progress values - updateFunc = function (i, contexts, values) { - return function (value) { - contexts[ i ] = this; - values[ i ] = arguments.length > 1 ? slice.call(arguments) : value; - - if (values === progressValues) { - deferred.notifyWith(contexts, values); - } else if (!--remaining) { - deferred.resolveWith(contexts, values); - } - }; - }, - - progressValues, progressContexts, resolveContexts; - - // Add listeners to Deferred subordinates; treat others as resolved - if (length > 1) { - progressValues = new Array(length); - progressContexts = new Array(length); - resolveContexts = new Array(length); - - for (; i < length; i++) { - if (resolveValues[ i ] && jQuery.isFunction(resolveValues[ i ].promise)) { - resolveValues[ i ].promise() - .done(updateFunc(i, resolveContexts, resolveValues)) - .fail(deferred.reject) - .progress(updateFunc(i, progressContexts, progressValues)); - } else { - --remaining; - } - } - } - - // If we're not waiting on anything, resolve the master - if (!remaining) { - deferred.resolveWith(resolveContexts, resolveValues); - } - - return deferred.promise(); - } - }); - - - // The deferred used on DOM ready - var readyList; - - jQuery.fn.ready = function (fn) { - // Add the callback - jQuery.ready.promise().done(fn); - - return this; - }; - - jQuery.extend({ - // Is the DOM ready to be used? Set to true once it occurs. - isReady: false, - - // A counter to track how many items to wait for before - // the ready event fires. See #6781 - readyWait: 1, - - // Hold (or release) the ready event - holdReady: function (hold) { - if (hold) { - jQuery.readyWait++; - } else { - jQuery.ready(true); - } - }, - - // Handle when the DOM is ready - ready: function (wait) { - - // Abort if there are pending holds or we're already ready - if (wait === true ? --jQuery.readyWait : jQuery.isReady) { - return; - } - - // Remember that the DOM is ready - jQuery.isReady = true; - - // If a normal DOM Ready event fired, decrement, and wait if need be - if (wait !== true && --jQuery.readyWait > 0) { - return; - } - - // If there are functions bound, to execute - readyList.resolveWith(document, [jQuery]); - - // Trigger any bound ready events - if (jQuery.fn.triggerHandler) { - jQuery(document).triggerHandler('ready'); - jQuery(document).off('ready'); - } - } - }); - - /** - * The ready event handler and self cleanup method - */ - function completed() { - document.removeEventListener('DOMContentLoaded', completed, false); - window.removeEventListener('load', completed, false); - jQuery.ready(); - } - - jQuery.ready.promise = function (obj) { - if (!readyList) { - - readyList = jQuery.Deferred(); - - // Catch cases where $(document).ready() is called after the browser event has already occurred. - // We once tried to use readyState "interactive" here, but it caused issues like the one - // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 - if (document.readyState === 'complete') { - // Handle it asynchronously to allow scripts the opportunity to delay ready - setTimeout(jQuery.ready); - - } else { - - // Use the handy event callback - document.addEventListener('DOMContentLoaded', completed, false); - - // A fallback to window.onload, that will always work - window.addEventListener('load', completed, false); - } - } - - return readyList.promise(obj); - }; - - // Kick off the DOM ready check even if the user does not - jQuery.ready.promise(); - - - - - // Multifunctional method to get and set values of a collection - // The value/s can optionally be executed if it's a function - var access = jQuery.access = function (elems, fn, key, value, chainable, emptyGet, raw) { - var i = 0, - len = elems.length, - bulk = key == null; - - // Sets many values - if (jQuery.type(key) === 'object') { - chainable = true; - - for (i in key) { - jQuery.access(elems, fn, i, key[i], true, emptyGet, raw); - } - - // Sets one value - } else if (value !== undefined) { - chainable = true; - - if (!jQuery.isFunction(value)) { - raw = true; - } - - if (bulk) { - // Bulk operations run against the entire set - if (raw) { - fn.call(elems, value); - fn = null; - - // ...except when executing function values - } else { - bulk = fn; - fn = function (elem, key, value) { - return bulk.call(jQuery(elem), value); - }; - } - } - - if (fn) { - for (; i < len; i++) { - fn(elems[i], key, raw ? value : value.call(elems[i], i, fn(elems[i], key))); - } - } - } - - return chainable ? - elems : - - // Gets - bulk ? - fn.call(elems) : - len ? fn(elems[0], key) : emptyGet; - }; - - - /** - * Determines whether an object can have data - */ - jQuery.acceptData = function (owner) { - // Accepts only: - // - Node - // - Node.ELEMENT_NODE - // - Node.DOCUMENT_NODE - // - Object - // - Any - /* jshint -W018 */ - return owner.nodeType === 1 || owner.nodeType === 9 || !+owner.nodeType; - }; - - function Data() { - // Support: Android<4, - // Old WebKit does not have Object.preventExtensions/freeze method, - // return new empty object instead with no [[set]] accessor - Object.defineProperty(this.cache = {}, 0, { - get: function () { - return {}; - } - }); - - this.expando = jQuery.expando + Data.uid++; - } - - Data.uid = 1; - Data.accepts = jQuery.acceptData; - - Data.prototype = { - key: function (owner) { - // We can accept data for non-element nodes in modern browsers, - // but we should not, see #8335. - // Always return the key for a frozen object. - if (!Data.accepts(owner)) { - return 0; - } - - var descriptor = {}, - // Check if the owner object already has a cache key - unlock = owner[ this.expando ]; - - // If not, create one - if (!unlock) { - unlock = Data.uid++; - - // Secure it in a non-enumerable, non-writable property - try { - descriptor[ this.expando ] = { - value: unlock - }; - Object.defineProperties(owner, descriptor); - - // Support: Android<4 - // Fallback to a less secure definition - } catch (e) { - descriptor[ this.expando ] = unlock; - jQuery.extend(owner, descriptor); - } - } - - // Ensure the cache object - if (!this.cache[ unlock ]) { - this.cache[ unlock ] = {}; - } - - return unlock; - }, - set: function (owner, data, value) { - var prop, - // There may be an unlock assigned to this node, - // if there is no entry for this "owner", create one inline - // and set the unlock as though an owner entry had always existed - unlock = this.key(owner), - cache = this.cache[ unlock ]; - - // Handle: [ owner, key, value ] args - if (typeof data === 'string') { - cache[ data ] = value; - - // Handle: [ owner, { properties } ] args - } else { - // Fresh assignments by object are shallow copied - if (jQuery.isEmptyObject(cache)) { - jQuery.extend(this.cache[ unlock ], data); - // Otherwise, copy the properties one-by-one to the cache object - } else { - for (prop in data) { - cache[ prop ] = data[ prop ]; - } - } - } - - return cache; - }, - get: function (owner, key) { - // Either a valid cache is found, or will be created. - // New caches will be created and the unlock returned, - // allowing direct access to the newly created - // empty data object. A valid owner object must be provided. - var cache = this.cache[ this.key(owner) ]; - - return key === undefined ? - cache : cache[ key ]; - }, - access: function (owner, key, value) { - var stored; - // In cases where either: - // - // 1. No key was specified - // 2. A string key was specified, but no value provided - // - // Take the "read" path and allow the get method to determine - // which value to return, respectively either: - // - // 1. The entire cache object - // 2. The data stored at the key - // - - if (key === undefined || - key && typeof key === 'string' && value === undefined) { - - stored = this.get(owner, key); - - return stored !== undefined ? - stored : this.get(owner, jQuery.camelCase(key)); - } - - // [*]When the key is not a string, or both a key and value - // are specified, set or extend (existing objects) with either: - // - // 1. An object of properties - // 2. A key and value - // - this.set(owner, key, value); - - // Since the "set" path can have two possible entry points - // return the expected data based on which path was taken[*] - return value !== undefined ? value : key; - }, - remove: function (owner, key) { - var i, name, camel, - unlock = this.key(owner), - cache = this.cache[ unlock ]; - - if (key === undefined) { - this.cache[ unlock ] = {}; - - } else { - // Support array or space separated string of keys - if (jQuery.isArray(key)) { - // If "name" is an array of keys... - // When data is initially created, via ("key", "val") signature, - // keys will be converted to camelCase. - // Since there is no way to tell _how_ a key was added, remove - // both plain key and camelCase key. #12786 - // This will only penalize the array argument path. - name = key.concat(key.map(jQuery.camelCase)); - } else { - camel = jQuery.camelCase(key); - // Try the string as a key before any manipulation - if (key in cache) { - name = [key, camel]; - } else { - // If a key with the spaces exists, use it. - // Otherwise, create an array by matching non-whitespace - name = camel; - name = name in cache ? - [name] : name.match(rnotwhite) || []; - } - } - - i = name.length; - - while (i--) { - delete cache[ name[ i ] ]; - } - } - }, - hasData: function (owner) { - return !jQuery.isEmptyObject( - this.cache[ owner[ this.expando ] ] || {} - ); - }, - discard: function (owner) { - if (owner[ this.expando ]) { - delete this.cache[ owner[ this.expando ] ]; - } - } - }; - var data_priv = new Data(); - - var data_user = new Data(); - - - - // Implementation Summary - // - // 1. Enforce API surface and semantic compatibility with 1.9.x branch - // 2. Improve the module's maintainability by reducing the storage - // paths to a single mechanism. - // 3. Use the same single mechanism to support "private" and "user" data. - // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData) - // 5. Avoid exposing implementation details on user objects (eg. expando properties) - // 6. Provide a clear path for implementation upgrade to WeakMap in 2014 - - var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, - rmultiDash = /([A-Z])/g; - - function dataAttr(elem, key, data) { - var name; - - // If nothing was found internally, try to fetch any - // data from the HTML5 data-* attribute - if (data === undefined && elem.nodeType === 1) { - name = 'data-' + key.replace(rmultiDash, '-$1').toLowerCase(); - data = elem.getAttribute(name); - - if (typeof data === 'string') { - try { - data = data === 'true' ? true : - data === 'false' ? false : - data === 'null' ? null : - // Only convert to a number if it doesn't change the string - +data + '' === data ? +data : - rbrace.test(data) ? jQuery.parseJSON(data) : - data; - } catch (e) {} - - // Make sure we set the data so it isn't changed later - data_user.set(elem, key, data); - } else { - data = undefined; - } - } - - return data; - } - - jQuery.extend({ - hasData: function (elem) { - return data_user.hasData(elem) || data_priv.hasData(elem); - }, - - data: function (elem, name, data) { - return data_user.access(elem, name, data); - }, - - removeData: function (elem, name) { - data_user.remove(elem, name); - }, - - // TODO: Now that all calls to _data and _removeData have been replaced - // with direct calls to data_priv methods, these can be deprecated. - _data: function (elem, name, data) { - return data_priv.access(elem, name, data); - }, - - _removeData: function (elem, name) { - data_priv.remove(elem, name); - } - }); - - jQuery.fn.extend({ - data: function (key, value) { - var i, name, data, - elem = this[ 0 ], - attrs = elem && elem.attributes; - - // Gets all values - if (key === undefined) { - if (this.length) { - data = data_user.get(elem); - - if (elem.nodeType === 1 && !data_priv.get(elem, 'hasDataAttrs')) { - i = attrs.length; - - while (i--) { - - // Support: IE11+ - // The attrs elements can be null (#14894) - if (attrs[ i ]) { - name = attrs[ i ].name; - - if (name.indexOf('data-') === 0) { - name = jQuery.camelCase(name.slice(5)); - dataAttr(elem, name, data[ name ]); - } - } - } - data_priv.set(elem, 'hasDataAttrs', true); - } - } - - return data; - } - - // Sets multiple values - if (typeof key === 'object') { - return this.each(function () { - data_user.set(this, key); - }); - } - - return access(this, function (value) { - var data, - camelKey = jQuery.camelCase(key); - - // The calling jQuery object (element matches) is not empty - // (and therefore has an element appears at this[ 0 ]) and the - // `value` parameter was not undefined. An empty jQuery object - // will result in `undefined` for elem = this[ 0 ] which will - // throw an exception if an attempt to read a data cache is made. - if (elem && value === undefined) { - // Attempt to get data from the cache - // with the key as-is - data = data_user.get(elem, key); - - if (data !== undefined) { - return data; - } - - // Attempt to get data from the cache - // with the key camelized - data = data_user.get(elem, camelKey); - - if (data !== undefined) { - return data; - } - - // Attempt to "discover" the data in - // HTML5 custom data-* attrs - data = dataAttr(elem, camelKey, undefined); - - if (data !== undefined) { - return data; - } - - // We tried really hard, but the data doesn't exist. - return; - } - - // Set the data... - this.each(function () { - // First, attempt to store a copy or reference of any - // data that might've been store with a camelCased key. - var data = data_user.get(this, camelKey); - - // For HTML5 data-* attribute interop, we have to - // store property names with dashes in a camelCase form. - // This might not apply to all properties...* - data_user.set(this, camelKey, value); - - // *... In the case of properties that might _actually_ - // have dashes, we need to also store a copy of that - // unchanged property. - if (key.indexOf('-') !== -1 && data !== undefined) { - data_user.set(this, key, value); - } - }); - }, null, value, arguments.length > 1, null, true); - }, - - removeData: function (key) { - return this.each(function () { - data_user.remove(this, key); - }); - } - }); - - jQuery.extend({ - queue: function (elem, type, data) { - var queue; - - if (elem) { - type = (type || 'fx') + 'queue'; - queue = data_priv.get(elem, type); - - // Speed up dequeue by getting out quickly if this is just a lookup - if (data) { - if (!queue || jQuery.isArray(data)) { - queue = data_priv.access(elem, type, jQuery.makeArray(data)); - } else { - queue.push(data); - } - } - - return queue || []; - } - }, - - dequeue: function (elem, type) { - type = type || 'fx'; - - var queue = jQuery.queue(elem, type), - startLength = queue.length, - fn = queue.shift(), - hooks = jQuery._queueHooks(elem, type), - next = function () { - jQuery.dequeue(elem, type); - }; - - // If the fx queue is dequeued, always remove the progress sentinel - if (fn === 'inprogress') { - fn = queue.shift(); - startLength--; - } - - if (fn) { - - // Add a progress sentinel to prevent the fx queue from being - // automatically dequeued - if (type === 'fx') { - queue.unshift('inprogress'); - } - - // Clear up the last queue stop function - delete hooks.stop; - fn.call(elem, next, hooks); - } - - if (!startLength && hooks) { - hooks.empty.fire(); - } - }, - - // Not public - generate a queueHooks object, or return the current one - _queueHooks: function (elem, type) { - var key = type + 'queueHooks'; - - return data_priv.get(elem, key) || data_priv.access(elem, key, { - empty: jQuery.Callbacks('once memory').add(function () { - data_priv.remove(elem, [type + 'queue', key]); - }) - }); - } - }); - - jQuery.fn.extend({ - queue: function (type, data) { - var setter = 2; - - if (typeof type !== 'string') { - data = type; - type = 'fx'; - setter--; - } - - if (arguments.length < setter) { - return jQuery.queue(this[0], type); - } - - return data === undefined ? - this : - this.each(function () { - var queue = jQuery.queue(this, type, data); - - // Ensure a hooks for this queue - jQuery._queueHooks(this, type); - - if (type === 'fx' && queue[0] !== 'inprogress') { - jQuery.dequeue(this, type); - } - }); - }, - dequeue: function (type) { - return this.each(function () { - jQuery.dequeue(this, type); - }); - }, - clearQueue: function (type) { - return this.queue(type || 'fx', []); - }, - // Get a promise resolved when queues of a certain type - // are emptied (fx is the type by default) - promise: function (type, obj) { - var tmp, - count = 1, - defer = jQuery.Deferred(), - elements = this, - i = this.length, - resolve = function () { - if (!--count) { - defer.resolveWith(elements, [elements]); - } - }; - - if (typeof type !== 'string') { - obj = type; - type = undefined; - } - type = type || 'fx'; - - while (i--) { - tmp = data_priv.get(elements[ i ], type + 'queueHooks'); - - if (tmp && tmp.empty) { - count++; - tmp.empty.add(resolve); - } - } - resolve(); - - return defer.promise(obj); - } - }); - var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source; - - var cssExpand = ['Top', 'Right', 'Bottom', 'Left']; - - var isHidden = function (elem, el) { - // isHidden might be called from jQuery#filter function; - // in that case, element will be second argument - elem = el || elem; - - return jQuery.css(elem, 'display') === 'none' || !jQuery.contains(elem.ownerDocument, elem); - }; - - var rcheckableType = (/^(?:checkbox|radio)$/i); - - (function () { - var fragment = document.createDocumentFragment(), - div = fragment.appendChild(document.createElement('div')), - input = document.createElement('input'); - - // Support: Safari<=5.1 - // Check state lost if the name is set (#11217) - // Support: Windows Web Apps (WWA) - // `name` and `type` must use .setAttribute for WWA (#14901) - input.setAttribute('type', 'radio'); - input.setAttribute('checked', 'checked'); - input.setAttribute('name', 't'); - - div.appendChild(input); - - // Support: Safari<=5.1, Android<4.2 - // Older WebKit doesn't clone checked state correctly in fragments - support.checkClone = div.cloneNode(true).cloneNode(true).lastChild.checked; - - // Support: IE<=11+ - // Make sure textarea (and checkbox) defaultValue is properly cloned - div.innerHTML = ''; - support.noCloneChecked = !!div.cloneNode(true).lastChild.defaultValue; - })(); - var strundefined = typeof undefined; - - support.focusinBubbles = 'onfocusin' in window; - - var - rkeyEvent = /^key/, - rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/, - rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, - rtypenamespace = /^([^.]*)(?:\.(.+)|)$/; - - function returnTrue() { - return true; - } - - function returnFalse() { - return false; - } - - function safeActiveElement() { - try { - return document.activeElement; - } catch (err) { } - } - - /* - * Helper functions for managing events -- not part of the public interface. - * Props to Dean Edwards' addEvent library for many of the ideas. - */ - jQuery.event = { - - global: {}, - - add: function (elem, types, handler, data, selector) { - - var handleObjIn, eventHandle, tmp, - events, t, handleObj, - special, handlers, type, namespaces, origType, - elemData = data_priv.get(elem); - - // Don't attach events to noData or text/comment nodes (but allow plain objects) - if (!elemData) { - return; - } - - // Caller can pass in an object of custom data in lieu of the handler - if (handler.handler) { - handleObjIn = handler; - handler = handleObjIn.handler; - selector = handleObjIn.selector; - } - - // Make sure that the handler has a unique ID, used to find/remove it later - if (!handler.guid) { - handler.guid = jQuery.guid++; - } - - // Init the element's event structure and main handler, if this is the first - if (!(events = elemData.events)) { - events = elemData.events = {}; - } - - if (!(eventHandle = elemData.handle)) { - eventHandle = elemData.handle = function (e) { - // Discard the second event of a jQuery.event.trigger() and - // when an event is called after a page has unloaded - return typeof jQuery !== strundefined && jQuery.event.triggered !== e.type ? - jQuery.event.dispatch.apply(elem, arguments) : undefined; - }; - } - - // Handle multiple events separated by a space - types = (types || '').match(rnotwhite) || ['']; - t = types.length; - - while (t--) { - tmp = rtypenamespace.exec(types[t]) || []; - type = origType = tmp[1]; - namespaces = (tmp[2] || '').split('.').sort(); - - // There *must* be a type, no attaching namespace-only handlers - if (!type) { - continue; - } - - // If event changes its type, use the special event handlers for the changed type - special = jQuery.event.special[ type ] || {}; - - // If selector defined, determine special event api type, otherwise given type - type = (selector ? special.delegateType : special.bindType) || type; - - // Update special based on newly reset type - special = jQuery.event.special[ type ] || {}; - - // handleObj is passed to all event handlers - handleObj = jQuery.extend({ - type: type, - origType: origType, - data: data, - handler: handler, - guid: handler.guid, - selector: selector, - needsContext: selector && jQuery.expr.match.needsContext.test(selector), - namespace: namespaces.join('.') - }, handleObjIn); - - // Init the event handler queue if we're the first - if (!(handlers = events[ type ])) { - handlers = events[ type ] = []; - handlers.delegateCount = 0; - - // Only use addEventListener if the special events handler returns false - if (!special.setup || special.setup.call(elem, data, namespaces, eventHandle) === false) { - if (elem.addEventListener) { - elem.addEventListener(type, eventHandle, false); - } - } - } - - if (special.add) { - special.add.call(elem, handleObj); - - if (!handleObj.handler.guid) { - handleObj.handler.guid = handler.guid; - } - } - - // Add to the element's handler list, delegates in front - if (selector) { - handlers.splice(handlers.delegateCount++, 0, handleObj); - } else { - handlers.push(handleObj); - } - - // Keep track of which events have ever been used, for event optimization - jQuery.event.global[ type ] = true; - } - - }, - - // Detach an event or set of events from an element - remove: function (elem, types, handler, selector, mappedTypes) { - - var j, origCount, tmp, - events, t, handleObj, - special, handlers, type, namespaces, origType, - elemData = data_priv.hasData(elem) && data_priv.get(elem); - - if (!elemData || !(events = elemData.events)) { - return; - } - - // Once for each type.namespace in types; type may be omitted - types = (types || '').match(rnotwhite) || ['']; - t = types.length; - - while (t--) { - tmp = rtypenamespace.exec(types[t]) || []; - type = origType = tmp[1]; - namespaces = (tmp[2] || '').split('.').sort(); - - // Unbind all events (on this namespace, if provided) for the element - if (!type) { - for (type in events) { - jQuery.event.remove(elem, type + types[ t ], handler, selector, true); - } - continue; - } - - special = jQuery.event.special[ type ] || {}; - type = (selector ? special.delegateType : special.bindType) || type; - handlers = events[ type ] || []; - tmp = tmp[2] && new RegExp('(^|\\.)' + namespaces.join('\\.(?:.*\\.|)') + '(\\.|$)'); - - // Remove matching events - origCount = j = handlers.length; - - while (j--) { - handleObj = handlers[ j ]; - - if ((mappedTypes || origType === handleObj.origType) && - (!handler || handler.guid === handleObj.guid) && - (!tmp || tmp.test(handleObj.namespace)) && - (!selector || selector === handleObj.selector || selector === '**' && handleObj.selector)) { - handlers.splice(j, 1); - - if (handleObj.selector) { - handlers.delegateCount--; - } - - if (special.remove) { - special.remove.call(elem, handleObj); - } - } - } - - // Remove generic event handler if we removed something and no more handlers exist - // (avoids potential for endless recursion during removal of special event handlers) - if (origCount && !handlers.length) { - if (!special.teardown || special.teardown.call(elem, namespaces, elemData.handle) === false) { - jQuery.removeEvent(elem, type, elemData.handle); - } - - delete events[ type ]; - } - } - - // Remove the expando if it's no longer used - if (jQuery.isEmptyObject(events)) { - delete elemData.handle; - data_priv.remove(elem, 'events'); - } - }, - - trigger: function (event, data, elem, onlyHandlers) { - - var i, cur, tmp, bubbleType, ontype, handle, special, - eventPath = [elem || document], - type = hasOwn.call(event, 'type') ? event.type : event, - namespaces = hasOwn.call(event, 'namespace') ? event.namespace.split('.') : []; - - cur = tmp = elem = elem || document; - - // Don't do events on text and comment nodes - if (elem.nodeType === 3 || elem.nodeType === 8) { - return; - } - - // focus/blur morphs to focusin/out; ensure we're not firing them right now - if (rfocusMorph.test(type + jQuery.event.triggered)) { - return; - } - - if (type.indexOf('.') >= 0) { - // Namespaced trigger; create a regexp to match event type in handle() - namespaces = type.split('.'); - type = namespaces.shift(); - namespaces.sort(); - } - ontype = type.indexOf(':') < 0 && 'on' + type; - - // Caller can pass in a jQuery.Event object, Object, or just an event type string - event = event[ jQuery.expando ] ? - event : - new jQuery.Event(type, typeof event === 'object' && event); - - // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) - event.isTrigger = onlyHandlers ? 2 : 3; - event.namespace = namespaces.join('.'); - event.namespace_re = event.namespace ? - new RegExp('(^|\\.)' + namespaces.join('\\.(?:.*\\.|)') + '(\\.|$)') : - null; - - // Clean up the event in case it is being reused - event.result = undefined; - - if (!event.target) { - event.target = elem; - } - - // Clone any incoming data and prepend the event, creating the handler arg list - data = data == null ? - [event] : - jQuery.makeArray(data, [event]); - - // Allow special events to draw outside the lines - special = jQuery.event.special[ type ] || {}; - - if (!onlyHandlers && special.trigger && special.trigger.apply(elem, data) === false) { - return; - } - - // Determine event propagation path in advance, per W3C events spec (#9951) - // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) - if (!onlyHandlers && !special.noBubble && !jQuery.isWindow(elem)) { - - bubbleType = special.delegateType || type; - - if (!rfocusMorph.test(bubbleType + type)) { - cur = cur.parentNode; - } - - for (; cur; cur = cur.parentNode) { - eventPath.push(cur); - tmp = cur; - } - - // Only add window if we got to document (e.g., not plain obj or detached DOM) - if (tmp === (elem.ownerDocument || document)) { - eventPath.push(tmp.defaultView || tmp.parentWindow || window); - } - } - - // Fire handlers on the event path - i = 0; - - while ((cur = eventPath[i++]) && !event.isPropagationStopped()) { - - event.type = i > 1 ? - bubbleType : - special.bindType || type; - - // jQuery handler - handle = (data_priv.get(cur, 'events') || {})[ event.type ] && data_priv.get(cur, 'handle'); - - if (handle) { - handle.apply(cur, data); - } - - // Native handler - handle = ontype && cur[ ontype ]; - - if (handle && handle.apply && jQuery.acceptData(cur)) { - event.result = handle.apply(cur, data); - - if (event.result === false) { - event.preventDefault(); - } - } - } - event.type = type; - - // If nobody prevented the default action, do it now - if (!onlyHandlers && !event.isDefaultPrevented()) { - - if ((!special._default || special._default.apply(eventPath.pop(), data) === false) && - jQuery.acceptData(elem)) { - - // Call a native DOM method on the target with the same name name as the event. - // Don't do default actions on window, that's where global variables be (#6170) - if (ontype && jQuery.isFunction(elem[ type ]) && !jQuery.isWindow(elem)) { - - // Don't re-trigger an onFOO event when we call its FOO() method - tmp = elem[ ontype ]; - - if (tmp) { - elem[ ontype ] = null; - } - - // Prevent re-triggering of the same event, since we already bubbled it above - jQuery.event.triggered = type; - elem[ type ](); - jQuery.event.triggered = undefined; - - if (tmp) { - elem[ ontype ] = tmp; - } - } - } - } - - return event.result; - }, - - dispatch: function (event) { - - // Make a writable jQuery.Event from the native event object - event = jQuery.event.fix(event); - - var i, j, ret, matched, handleObj, - handlerQueue = [], - args = slice.call(arguments), - handlers = (data_priv.get(this, 'events') || {})[ event.type ] || [], - special = jQuery.event.special[ event.type ] || {}; - - // Use the fix-ed jQuery.Event rather than the (read-only) native event - args[0] = event; - event.delegateTarget = this; - - // Call the preDispatch hook for the mapped type, and let it bail if desired - if (special.preDispatch && special.preDispatch.call(this, event) === false) { - return; - } - - // Determine handlers - handlerQueue = jQuery.event.handlers.call(this, event, handlers); - - // Run delegates first; they may want to stop propagation beneath us - i = 0; - - while ((matched = handlerQueue[ i++ ]) && !event.isPropagationStopped()) { - event.currentTarget = matched.elem; - - j = 0; - - while ((handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped()) { - - // Triggered event must either 1) have no namespace, or 2) have namespace(s) - // a subset or equal to those in the bound event (both can have no namespace). - if (!event.namespace_re || event.namespace_re.test(handleObj.namespace)) { - - event.handleObj = handleObj; - event.data = handleObj.data; - - ret = ((jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler) - .apply(matched.elem, args); - - if (ret !== undefined) { - if ((event.result = ret) === false) { - event.preventDefault(); - event.stopPropagation(); - } - } - } - } - } - - // Call the postDispatch hook for the mapped type - if (special.postDispatch) { - special.postDispatch.call(this, event); - } - - return event.result; - }, - - handlers: function (event, handlers) { - var i, matches, sel, handleObj, - handlerQueue = [], - delegateCount = handlers.delegateCount, - cur = event.target; - - // Find delegate handlers - // Black-hole SVG instance trees (#13180) - // Avoid non-left-click bubbling in Firefox (#3861) - if (delegateCount && cur.nodeType && (!event.button || event.type !== 'click')) { - - for (; cur !== this; cur = cur.parentNode || this) { - - // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) - if (cur.disabled !== true || event.type !== 'click') { - matches = []; - - for (i = 0; i < delegateCount; i++) { - handleObj = handlers[ i ]; - - // Don't conflict with Object.prototype properties (#13203) - sel = handleObj.selector + ' '; - - if (matches[ sel ] === undefined) { - matches[ sel ] = handleObj.needsContext ? - jQuery(sel, this).index(cur) >= 0 : - jQuery.find(sel, this, null, [cur]).length; - } - - if (matches[ sel ]) { - matches.push(handleObj); - } - } - - if (matches.length) { - handlerQueue.push({ - elem: cur, handlers: matches - }); - } - } - } - } - - // Add the remaining (directly-bound) handlers - if (delegateCount < handlers.length) { - handlerQueue.push({ - elem: this, handlers: handlers.slice(delegateCount) - }); - } - - return handlerQueue; - }, - - // Includes some event props shared by KeyEvent and MouseEvent - props: 'altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which'.split(' '), - - fixHooks: {}, - - keyHooks: { - props: 'char charCode key keyCode'.split(' '), - filter: function (event, original) { - - // Add which for key events - if (event.which == null) { - event.which = original.charCode != null ? original.charCode : original.keyCode; - } - - return event; - } - }, - - mouseHooks: { - props: 'button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement'.split(' '), - filter: function (event, original) { - var eventDoc, doc, body, - button = original.button; - - // Calculate pageX/Y if missing and clientX/Y available - if (event.pageX == null && original.clientX != null) { - eventDoc = event.target.ownerDocument || document; - doc = eventDoc.documentElement; - body = eventDoc.body; - - event.pageX = original.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0); - event.pageY = original.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0); - } - - // Add which for click: 1 === left; 2 === middle; 3 === right - // Note: button is not normalized, so don't use it - if (!event.which && button !== undefined) { - event.which = button & 1 ? 1 : button & 2 ? 3 : button & 4 ? 2 : 0; - } - - return event; - } - }, - - fix: function (event) { - if (event[ jQuery.expando ]) { - return event; - } - - // Create a writable copy of the event object and normalize some properties - var i, prop, copy, - type = event.type, - originalEvent = event, - fixHook = this.fixHooks[ type ]; - - if (!fixHook) { - this.fixHooks[ type ] = fixHook = - rmouseEvent.test(type) ? this.mouseHooks : - rkeyEvent.test(type) ? this.keyHooks : - {}; - } - copy = fixHook.props ? this.props.concat(fixHook.props) : this.props; - - event = new jQuery.Event(originalEvent); - - i = copy.length; - - while (i--) { - prop = copy[ i ]; - event[ prop ] = originalEvent[ prop ]; - } - - // Support: Cordova 2.5 (WebKit) (#13255) - // All events should have a target; Cordova deviceready doesn't - if (!event.target) { - event.target = document; - } - - // Support: Safari 6.0+, Chrome<28 - // Target should not be a text node (#504, #13143) - if (event.target.nodeType === 3) { - event.target = event.target.parentNode; - } - - return fixHook.filter ? fixHook.filter(event, originalEvent) : event; - }, - - special: { - load: { - // Prevent triggered image.load events from bubbling to window.load - noBubble: true - }, - focus: { - // Fire native event if possible so blur/focus sequence is correct - trigger: function () { - if (this !== safeActiveElement() && this.focus) { - this.focus(); - - return false; - } - }, - delegateType: 'focusin' - }, - blur: { - trigger: function () { - if (this === safeActiveElement() && this.blur) { - this.blur(); - - return false; - } - }, - delegateType: 'focusout' - }, - click: { - // For checkbox, fire native event so checked state will be right - trigger: function () { - if (this.type === 'checkbox' && this.click && jQuery.nodeName(this, 'input')) { - this.click(); - - return false; - } - }, - - // For cross-browser consistency, don't fire native .click() on links - _default: function (event) { - return jQuery.nodeName(event.target, 'a'); - } - }, - - beforeunload: { - postDispatch: function (event) { - - // Support: Firefox 20+ - // Firefox doesn't alert if the returnValue field is not set. - if (event.result !== undefined && event.originalEvent) { - event.originalEvent.returnValue = event.result; - } - } - } - }, - - simulate: function (type, elem, event, bubble) { - // Piggyback on a donor event to simulate a different one. - // Fake originalEvent to avoid donor's stopPropagation, but if the - // simulated event prevents default then we do the same on the donor. - var e = jQuery.extend( - new jQuery.Event(), - event, - { - type: type, - isSimulated: true, - originalEvent: {} - } - ); - - if (bubble) { - jQuery.event.trigger(e, null, elem); - } else { - jQuery.event.dispatch.call(elem, e); - } - - if (e.isDefaultPrevented()) { - event.preventDefault(); - } - } - }; - - jQuery.removeEvent = function (elem, type, handle) { - if (elem.removeEventListener) { - elem.removeEventListener(type, handle, false); - } - }; - - jQuery.Event = function (src, props) { - // Allow instantiation without the 'new' keyword - if (!(this instanceof jQuery.Event)) { - return new jQuery.Event(src, props); - } - - // Event object - if (src && src.type) { - this.originalEvent = src; - this.type = src.type; - - // Events bubbling up the document may have been marked as prevented - // by a handler lower down the tree; reflect the correct value. - this.isDefaultPrevented = src.defaultPrevented || - src.defaultPrevented === undefined && - // Support: Android<4.0 - src.returnValue === false ? - returnTrue : - returnFalse; - - // Event type - } else { - this.type = src; - } - - // Put explicitly provided properties onto the event object - if (props) { - jQuery.extend(this, props); - } - - // Create a timestamp if incoming event doesn't have one - this.timeStamp = src && src.timeStamp || jQuery.now(); - - // Mark it as fixed - this[ jQuery.expando ] = true; - }; - - // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding - // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html - jQuery.Event.prototype = { - isDefaultPrevented: returnFalse, - isPropagationStopped: returnFalse, - isImmediatePropagationStopped: returnFalse, - - preventDefault: function () { - var e = this.originalEvent; - - this.isDefaultPrevented = returnTrue; - - if (e && e.preventDefault) { - e.preventDefault(); - } - }, - stopPropagation: function () { - var e = this.originalEvent; - - this.isPropagationStopped = returnTrue; - - if (e && e.stopPropagation) { - e.stopPropagation(); - } - }, - stopImmediatePropagation: function () { - var e = this.originalEvent; - - this.isImmediatePropagationStopped = returnTrue; - - if (e && e.stopImmediatePropagation) { - e.stopImmediatePropagation(); - } - - this.stopPropagation(); - } - }; - - // Create mouseenter/leave events using mouseover/out and event-time checks - // Support: Chrome 15+ - jQuery.each({ - mouseenter: 'mouseover', - mouseleave: 'mouseout', - pointerenter: 'pointerover', - pointerleave: 'pointerout' - }, function (orig, fix) { - jQuery.event.special[ orig ] = { - delegateType: fix, - bindType: fix, - - handle: function (event) { - var ret, - target = this, - related = event.relatedTarget, - handleObj = event.handleObj; - - // For mousenter/leave call the handler if related is outside the target. - // NB: No relatedTarget if the mouse left/entered the browser window - if (!related || related !== target && !jQuery.contains(target, related)) { - event.type = handleObj.origType; - ret = handleObj.handler.apply(this, arguments); - event.type = fix; - } - - return ret; - } - }; - }); - - // Support: Firefox, Chrome, Safari - // Create "bubbling" focus and blur events - if (!support.focusinBubbles) { - jQuery.each({ - focus: 'focusin', blur: 'focusout' - }, function (orig, fix) { - - // Attach a single capturing handler on the document while someone wants focusin/focusout - var handler = function (event) { - jQuery.event.simulate(fix, event.target, jQuery.event.fix(event), true); - }; - - jQuery.event.special[ fix ] = { - setup: function () { - var doc = this.ownerDocument || this, - attaches = data_priv.access(doc, fix); - - if (!attaches) { - doc.addEventListener(orig, handler, true); - } - data_priv.access(doc, fix, (attaches || 0) + 1); - }, - teardown: function () { - var doc = this.ownerDocument || this, - attaches = data_priv.access(doc, fix) - 1; - - if (!attaches) { - doc.removeEventListener(orig, handler, true); - data_priv.remove(doc, fix); - - } else { - data_priv.access(doc, fix, attaches); - } - } - }; - }); - } - - jQuery.fn.extend({ - - on: function (types, selector, data, fn, /*INTERNAL*/ one) { - var origFn, type; - - // Types can be a map of types/handlers - if (typeof types === 'object') { - // ( types-Object, selector, data ) - if (typeof selector !== 'string') { - // ( types-Object, data ) - data = data || selector; - selector = undefined; - } - - for (type in types) { - this.on(type, selector, data, types[ type ], one); - } - - return this; - } - - if (data == null && fn == null) { - // ( types, fn ) - fn = selector; - data = selector = undefined; - } else if (fn == null) { - if (typeof selector === 'string') { - // ( types, selector, fn ) - fn = data; - data = undefined; - } else { - // ( types, data, fn ) - fn = data; - data = selector; - selector = undefined; - } - } - - if (fn === false) { - fn = returnFalse; - } else if (!fn) { - return this; - } - - if (one === 1) { - origFn = fn; - fn = function (event) { - // Can use an empty set, since event contains the info - jQuery().off(event); - - return origFn.apply(this, arguments); - }; - // Use same guid so caller can remove using origFn - fn.guid = origFn.guid || (origFn.guid = jQuery.guid++); - } - - return this.each(function () { - jQuery.event.add(this, types, fn, data, selector); - }); - }, - one: function (types, selector, data, fn) { - return this.on(types, selector, data, fn, 1); - }, - off: function (types, selector, fn) { - var handleObj, type; - - if (types && types.preventDefault && types.handleObj) { - // ( event ) dispatched jQuery.Event - handleObj = types.handleObj; - jQuery(types.delegateTarget).off( - handleObj.namespace ? handleObj.origType + '.' + handleObj.namespace : handleObj.origType, - handleObj.selector, - handleObj.handler - ); - - return this; - } - - if (typeof types === 'object') { - // ( types-object [, selector] ) - for (type in types) { - this.off(type, selector, types[ type ]); - } - - return this; - } - - if (selector === false || typeof selector === 'function') { - // ( types [, fn] ) - fn = selector; - selector = undefined; - } - - if (fn === false) { - fn = returnFalse; - } - - return this.each(function () { - jQuery.event.remove(this, types, fn, selector); - }); - }, - - trigger: function (type, data) { - return this.each(function () { - jQuery.event.trigger(type, data, this); - }); - }, - triggerHandler: function (type, data) { - var elem = this[0]; - - if (elem) { - return jQuery.event.trigger(type, data, elem, true); - } - } - }); - - var - rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, - rtagName = /<([\w:]+)/, - rhtml = /<|&#?\w+;/, - rnoInnerhtml = /<(?:script|style|link)/i, - // checked="checked" or checked - rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, - rscriptType = /^$|\/(?:java|ecma)script/i, - rscriptTypeMasked = /^true\/(.*)/, - rcleanScript = /^\s*\s*$/g, - - // We have to close these tags to support XHTML (#13200) - wrapMap = { - - // Support: IE9 - option: [1, ''], - - thead: [1, '', '
        '], - col: [2, '', '
        '], - tr: [2, '', '
        '], - td: [3, '', '
        '], - - _default: [0, '', ''] - }; - - // Support: IE9 - wrapMap.optgroup = wrapMap.option; - - wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; - wrapMap.th = wrapMap.td; - - // Support: 1.x compatibility - // Manipulating tables requires a tbody - function manipulationTarget(elem, content) { - return jQuery.nodeName(elem, 'table') && - jQuery.nodeName(content.nodeType !== 11 ? content : content.firstChild, 'tr') ? - - elem.getElementsByTagName('tbody')[0] || - elem.appendChild(elem.ownerDocument.createElement('tbody')) : - elem; - } - - // Replace/restore the type attribute of script elements for safe DOM manipulation - function disableScript(elem) { - elem.type = (elem.getAttribute('type') !== null) + '/' + elem.type; - - return elem; - } - function restoreScript(elem) { - var match = rscriptTypeMasked.exec(elem.type); - - if (match) { - elem.type = match[ 1 ]; - } else { - elem.removeAttribute('type'); - } - - return elem; - } - - // Mark scripts as having already been evaluated - function setGlobalEval(elems, refElements) { - var i = 0, - l = elems.length; - - for (; i < l; i++) { - data_priv.set( - elems[ i ], 'globalEval', !refElements || data_priv.get(refElements[ i ], 'globalEval') - ); - } - } - - function cloneCopyEvent(src, dest) { - var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events; - - if (dest.nodeType !== 1) { - return; - } - - // 1. Copy private data: events, handlers, etc. - if (data_priv.hasData(src)) { - pdataOld = data_priv.access(src); - pdataCur = data_priv.set(dest, pdataOld); - events = pdataOld.events; - - if (events) { - delete pdataCur.handle; - pdataCur.events = {}; - - for (type in events) { - for (i = 0, l = events[ type ].length; i < l; i++) { - jQuery.event.add(dest, type, events[ type ][ i ]); - } - } - } - } - - // 2. Copy user data - if (data_user.hasData(src)) { - udataOld = data_user.access(src); - udataCur = jQuery.extend({}, udataOld); - - data_user.set(dest, udataCur); - } - } - - function getAll(context, tag) { - var ret = context.getElementsByTagName ? context.getElementsByTagName(tag || '*') : - context.querySelectorAll ? context.querySelectorAll(tag || '*') : - []; - - return tag === undefined || tag && jQuery.nodeName(context, tag) ? - jQuery.merge([context], ret) : - ret; - } - - // Fix IE bugs, see support tests - function fixInput(src, dest) { - var nodeName = dest.nodeName.toLowerCase(); - - // Fails to persist the checked state of a cloned checkbox or radio button. - if (nodeName === 'input' && rcheckableType.test(src.type)) { - dest.checked = src.checked; - - // Fails to return the selected option to the default selected state when cloning options - } else if (nodeName === 'input' || nodeName === 'textarea') { - dest.defaultValue = src.defaultValue; - } - } - - jQuery.extend({ - clone: function (elem, dataAndEvents, deepDataAndEvents) { - var i, l, srcElements, destElements, - clone = elem.cloneNode(true), - inPage = jQuery.contains(elem.ownerDocument, elem); - - // Fix IE cloning issues - if (!support.noCloneChecked && (elem.nodeType === 1 || elem.nodeType === 11) && - !jQuery.isXMLDoc(elem)) { - - // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2 - destElements = getAll(clone); - srcElements = getAll(elem); - - for (i = 0, l = srcElements.length; i < l; i++) { - fixInput(srcElements[ i ], destElements[ i ]); - } - } - - // Copy the events from the original to the clone - if (dataAndEvents) { - if (deepDataAndEvents) { - srcElements = srcElements || getAll(elem); - destElements = destElements || getAll(clone); - - for (i = 0, l = srcElements.length; i < l; i++) { - cloneCopyEvent(srcElements[ i ], destElements[ i ]); - } - } else { - cloneCopyEvent(elem, clone); - } - } - - // Preserve script evaluation history - destElements = getAll(clone, 'script'); - - if (destElements.length > 0) { - setGlobalEval(destElements, !inPage && getAll(elem, 'script')); - } - - // Return the cloned set - return clone; - }, - - buildFragment: function (elems, context, scripts, selection) { - var elem, tmp, tag, wrap, contains, j, - fragment = context.createDocumentFragment(), - nodes = [], - i = 0, - l = elems.length; - - for (; i < l; i++) { - elem = elems[ i ]; - - if (elem || elem === 0) { - - // Add nodes directly - if (jQuery.type(elem) === 'object') { - // Support: QtWebKit, PhantomJS - // push.apply(_, arraylike) throws on ancient WebKit - jQuery.merge(nodes, elem.nodeType ? [elem] : elem); - - // Convert non-html into a text node - } else if (!rhtml.test(elem)) { - nodes.push(context.createTextNode(elem)); - - // Convert html into DOM nodes - } else { - tmp = tmp || fragment.appendChild(context.createElement('div')); - - // Deserialize a standard representation - tag = (rtagName.exec(elem) || ['', ''])[ 1 ].toLowerCase(); - wrap = wrapMap[ tag ] || wrapMap._default; - tmp.innerHTML = wrap[ 1 ] + elem.replace(rxhtmlTag, '<$1>') + wrap[ 2 ]; - - // Descend through wrappers to the right content - j = wrap[ 0 ]; - - while (j--) { - tmp = tmp.lastChild; - } - - // Support: QtWebKit, PhantomJS - // push.apply(_, arraylike) throws on ancient WebKit - jQuery.merge(nodes, tmp.childNodes); - - // Remember the top-level container - tmp = fragment.firstChild; - - // Ensure the created nodes are orphaned (#12392) - tmp.textContent = ''; - } - } - } - - // Remove wrapper from fragment - fragment.textContent = ''; - - i = 0; - - while (elem = nodes[ i++ ]) { - - // #4087 - If origin and destination elements are the same, and this is - // that element, do not do anything - if (selection && jQuery.inArray(elem, selection) !== -1) { - continue; - } - - contains = jQuery.contains(elem.ownerDocument, elem); - - // Append to fragment - tmp = getAll(fragment.appendChild(elem), 'script'); - - // Preserve script evaluation history - if (contains) { - setGlobalEval(tmp); - } - - // Capture executables - if (scripts) { - j = 0; - - while (elem = tmp[ j++ ]) { - if (rscriptType.test(elem.type || '')) { - scripts.push(elem); - } - } - } - } - - return fragment; - }, - - cleanData: function (elems) { - var data, elem, type, key, - special = jQuery.event.special, - i = 0; - - for (; (elem = elems[ i ]) !== undefined; i++) { - if (jQuery.acceptData(elem)) { - key = elem[ data_priv.expando ]; - - if (key && (data = data_priv.cache[ key ])) { - if (data.events) { - for (type in data.events) { - if (special[ type ]) { - jQuery.event.remove(elem, type); - - // This is a shortcut to avoid jQuery.event.remove's overhead - } else { - jQuery.removeEvent(elem, type, data.handle); - } - } - } - - if (data_priv.cache[ key ]) { - // Discard any remaining `private` data - delete data_priv.cache[ key ]; - } - } - } - // Discard any remaining `user` data - delete data_user.cache[ elem[ data_user.expando ] ]; - } - } - }); - - jQuery.fn.extend({ - text: function (value) { - return access(this, function (value) { - return value === undefined ? - jQuery.text(this) : - this.empty().each(function () { - if (this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9) { - this.textContent = value; - } - }); - }, null, value, arguments.length); - }, - - append: function () { - return this.domManip(arguments, function (elem) { - if (this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9) { - var target = manipulationTarget(this, elem); - - target.appendChild(elem); - } - }); - }, - - prepend: function () { - return this.domManip(arguments, function (elem) { - if (this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9) { - var target = manipulationTarget(this, elem); - - target.insertBefore(elem, target.firstChild); - } - }); - }, - - before: function () { - return this.domManip(arguments, function (elem) { - if (this.parentNode) { - this.parentNode.insertBefore(elem, this); - } - }); - }, - - after: function () { - return this.domManip(arguments, function (elem) { - if (this.parentNode) { - this.parentNode.insertBefore(elem, this.nextSibling); - } - }); - }, - - remove: function (selector, keepData /* Internal Use Only */) { - var elem, - elems = selector ? jQuery.filter(selector, this) : this, - i = 0; - - for (; (elem = elems[i]) != null; i++) { - if (!keepData && elem.nodeType === 1) { - jQuery.cleanData(getAll(elem)); - } - - if (elem.parentNode) { - if (keepData && jQuery.contains(elem.ownerDocument, elem)) { - setGlobalEval(getAll(elem, 'script')); - } - elem.parentNode.removeChild(elem); - } - } - - return this; - }, - - empty: function () { - var elem, - i = 0; - - for (; (elem = this[i]) != null; i++) { - if (elem.nodeType === 1) { - - // Prevent memory leaks - jQuery.cleanData(getAll(elem, false)); - - // Remove any remaining nodes - elem.textContent = ''; - } - } - - return this; - }, - - clone: function (dataAndEvents, deepDataAndEvents) { - dataAndEvents = dataAndEvents == null ? false : dataAndEvents; - deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; - - return this.map(function () { - return jQuery.clone(this, dataAndEvents, deepDataAndEvents); - }); - }, - - html: function (value) { - return access(this, function (value) { - var elem = this[ 0 ] || {}, - i = 0, - l = this.length; - - if (value === undefined && elem.nodeType === 1) { - return elem.innerHTML; - } - - // See if we can take a shortcut and just use innerHTML - if (typeof value === 'string' && !rnoInnerhtml.test(value) && - !wrapMap[ (rtagName.exec(value) || ['', ''])[ 1 ].toLowerCase() ]) { - - value = value.replace(rxhtmlTag, '<$1>'); - - try { - for (; i < l; i++) { - elem = this[ i ] || {}; - - // Remove element nodes and prevent memory leaks - if (elem.nodeType === 1) { - jQuery.cleanData(getAll(elem, false)); - elem.innerHTML = value; - } - } - - elem = 0; - - // If using innerHTML throws an exception, use the fallback method - } catch (e) {} - } - - if (elem) { - this.empty().append(value); - } - }, null, value, arguments.length); - }, - - replaceWith: function () { - var arg = arguments[ 0 ]; - - // Make the changes, replacing each context element with the new content - this.domManip(arguments, function (elem) { - arg = this.parentNode; - - jQuery.cleanData(getAll(this)); - - if (arg) { - arg.replaceChild(elem, this); - } - }); - - // Force removal if there was no new content (e.g., from empty arguments) - return arg && (arg.length || arg.nodeType) ? this : this.remove(); - }, - - detach: function (selector) { - return this.remove(selector, true); - }, - - domManip: function (args, callback) { - - // Flatten any nested arrays - args = concat.apply([], args); - - var fragment, first, scripts, hasScripts, node, doc, - i = 0, - l = this.length, - set = this, - iNoClone = l - 1, - value = args[ 0 ], - isFunction = jQuery.isFunction(value); - - // We can't cloneNode fragments that contain checked, in WebKit - if (isFunction || - l > 1 && typeof value === 'string' && - !support.checkClone && rchecked.test(value)) { - return this.each(function (index) { - var self = set.eq(index); - - if (isFunction) { - args[ 0 ] = value.call(this, index, self.html()); - } - self.domManip(args, callback); - }); - } - - if (l) { - fragment = jQuery.buildFragment(args, this[ 0 ].ownerDocument, false, this); - first = fragment.firstChild; - - if (fragment.childNodes.length === 1) { - fragment = first; - } - - if (first) { - scripts = jQuery.map(getAll(fragment, 'script'), disableScript); - hasScripts = scripts.length; - - // Use the original fragment for the last item instead of the first because it can end up - // being emptied incorrectly in certain situations (#8070). - for (; i < l; i++) { - node = fragment; - - if (i !== iNoClone) { - node = jQuery.clone(node, true, true); - - // Keep references to cloned scripts for later restoration - if (hasScripts) { - // Support: QtWebKit - // jQuery.merge because push.apply(_, arraylike) throws - jQuery.merge(scripts, getAll(node, 'script')); - } - } - - callback.call(this[ i ], node, i); - } - - if (hasScripts) { - doc = scripts[ scripts.length - 1 ].ownerDocument; - - // Reenable scripts - jQuery.map(scripts, restoreScript); - - // Evaluate executable scripts on first document insertion - for (i = 0; i < hasScripts; i++) { - node = scripts[ i ]; - - if (rscriptType.test(node.type || '') && - !data_priv.access(node, 'globalEval') && jQuery.contains(doc, node)) { - - if (node.src) { - // Optional AJAX dependency, but won't run scripts if not present - if (jQuery._evalUrl) { - jQuery._evalUrl(node.src); - } - } else { - jQuery.globalEval(node.textContent.replace(rcleanScript, '')); - } - } - } - } - } - } - - return this; - } - }); - - jQuery.each({ - appendTo: 'append', - prependTo: 'prepend', - insertBefore: 'before', - insertAfter: 'after', - replaceAll: 'replaceWith' - }, function (name, original) { - jQuery.fn[ name ] = function (selector) { - var elems, - ret = [], - insert = jQuery(selector), - last = insert.length - 1, - i = 0; - - for (; i <= last; i++) { - elems = i === last ? this : this.clone(true); - jQuery(insert[ i ])[ original ](elems); - - // Support: QtWebKit - // .get() because push.apply(_, arraylike) throws - push.apply(ret, elems.get()); - } - - return this.pushStack(ret); - }; - }); - - var iframe, - elemdisplay = {}; - - /** - * Retrieve the actual display of a element - * @param {String} name nodeName of the element - * @param {Object} doc Document object - */ - // Called only from within defaultDisplay - function actualDisplay(name, doc) { - var style, - elem = jQuery(doc.createElement(name)).appendTo(doc.body), - - // getDefaultComputedStyle might be reliably used only on attached element - display = window.getDefaultComputedStyle && (style = window.getDefaultComputedStyle(elem[ 0 ])) ? - - // Use of this method is a temporary fix (more like optimization) until something better comes along, - // since it was removed from specification and supported only in FF - style.display : jQuery.css(elem[ 0 ], 'display'); - - // We don't have any data stored on the element, - // so use "detach" method as fast way to get rid of the element - elem.detach(); - - return display; - } - - /** - * Try to determine the default display value of an element - * @param {String} nodeName - */ - function defaultDisplay(nodeName) { - var doc = document, - display = elemdisplay[ nodeName ]; - - if (!display) { - display = actualDisplay(nodeName, doc); - - // If the simple way fails, read from inside an iframe - if (display === 'none' || !display) { - - // Use the already-created iframe if possible - iframe = (iframe || jQuery('