File tree Expand file tree Collapse file tree 7 files changed +171
-1
lines changed
app/code/Magento/Catalog/Test/Unit/Pricing/Price
dev/tests/integration/testsuite/Magento
Controller/Adminhtml/Report/Product
Model/ResourceModel/Report/Sold
lib/internal/Magento/Framework/Serialize/Test/Unit/Serializer Expand file tree Collapse file tree 7 files changed +171
-1
lines changed Original file line number Diff line number Diff line change @@ -393,4 +393,40 @@ public function dataProviderGetSavePercent()
393393 ['basePrice ' => '20.80 ' , 'tierPrice ' => '18.72 ' , 'savedPercent ' => '10 ' ]
394394 ];
395395 }
396+
397+ /**
398+ * @param null|string|float $quantity
399+ * @param float $expectedValue
400+ * @dataProvider getQuantityDataProvider
401+ */
402+ public function testGetQuantity ($ quantity , $ expectedValue )
403+ {
404+ $ tierPrice = new TierPrice (
405+ $ this ->product ,
406+ $ quantity ,
407+ $ this ->calculator ,
408+ $ this ->priceCurrencyMock ,
409+ $ this ->session ,
410+ $ this ->groupManagement ,
411+ $ this ->customerGroupRetriever
412+ );
413+
414+ $ this ->assertEquals ($ expectedValue , $ tierPrice ->getQuantity ());
415+ }
416+
417+ /**
418+ * @return array
419+ */
420+ public function getQuantityDataProvider ()
421+ {
422+ return [
423+ [null , 1 ],
424+ ['one ' , 1 ],
425+ ['' , 1 ],
426+ [4 , 4 ],
427+ [4.5 , 4.5 ],
428+ ['0.7 ' , 0.7 ],
429+ ['0.0000000 ' , 1 ]
430+ ];
431+ }
396432}
Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * Copyright © Magento, Inc. All rights reserved.
4+ * See COPYING.txt for license details.
5+ */
6+
7+ namespace Magento \Reports \Controller \Adminhtml \Report \Product ;
8+
9+ /**
10+ * @magentoAppArea adminhtml
11+ */
12+ class SoldTest extends \Magento \TestFramework \TestCase \AbstractBackendController
13+ {
14+ public function testExecute ()
15+ {
16+ $ this ->dispatch ('backend/reports/report_product/sold ' );
17+ $ actual = $ this ->getResponse ()->getBody ();
18+ $ this ->assertContains ('Ordered Products Report ' , $ actual );
19+ //verify if SKU column is presented on grid
20+ $ this ->assertContains ('SKU ' , $ actual );
21+ }
22+ }
Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * Copyright © Magento, Inc. All rights reserved.
4+ * See COPYING.txt for license details.
5+ */
6+ namespace Magento \Reports \Model \ResourceModel \Report \Sold ;
7+
8+ /**
9+ * Class CollectionTest
10+ */
11+ class CollectionTest extends \PHPUnit \Framework \TestCase
12+ {
13+ /**
14+ * @var \Magento\Reports\Model\ResourceModel\Product\Sold\Collection
15+ */
16+ private $ collection ;
17+
18+ protected function setUp ()
19+ {
20+ /**
21+ * @var \Magento\Reports\Model\ResourceModel\Product\Sold\Collection
22+ */
23+ $ this ->collection = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
24+ \Magento \Reports \Model \ResourceModel \Product \Sold \Collection::class
25+ );
26+ }
27+
28+ /**
29+ * @magentoDataFixture Magento/Sales/_files/order_item_with_configurable_for_reorder.php
30+ */
31+ public function testFilterByProductTypeException ()
32+ {
33+ $ items = $ this ->collection ->addOrderedQty ()->getItems ();
34+ $ this ->assertEquals (1 , count ($ items ));
35+ $ orderItem = array_shift ($ items );
36+ $ this ->assertEquals ('1.0000 ' , $ orderItem ['ordered_qty ' ]);
37+ $ this ->assertEquals ('Configurable Product ' , $ orderItem ['order_items_name ' ]);
38+ //verify if order_item_sku exists in return data
39+ $ this ->assertEquals ('simple_20 ' , $ orderItem ['order_items_sku ' ]);
40+ }
41+ }
Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * Copyright © Magento, Inc. All rights reserved.
4+ * See COPYING.txt for license details.
5+ */
6+
7+ namespace Magento \Review \Block \Product ;
8+
9+ /**
10+ * Class ReviewRendererTest
11+ */
12+ class ReviewRendererTest extends \PHPUnit \Framework \TestCase
13+ {
14+ /**
15+ * Test verifies ReviewRenderer::getReviewsSummaryHtml call with $displayIfNoReviews = false
16+ * The reviews summary will be shown as expected only if there is at least one review available
17+ *
18+ * @magentoDataFixture Magento/Review/_files/different_reviews.php
19+ * @magentoAppArea frontend
20+ */
21+ public function testGetReviewSummaryHtml ()
22+ {
23+ $ productSku = 'simple ' ;
24+ $ objectManager = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ();
25+ /** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */
26+ $ productRepository = $ objectManager ->create (\Magento \Catalog \Api \ProductRepositoryInterface::class);
27+ $ product = $ productRepository ->get ($ productSku );
28+ /** @var ReviewRenderer $reviewRenderer */
29+ $ reviewRenderer = $ objectManager ->create (ReviewRenderer::class);
30+ $ actualResult = $ reviewRenderer ->getReviewsSummaryHtml ($ product );
31+ $ this ->assertEquals (2 , $ reviewRenderer ->getReviewsCount ());
32+ $ this ->assertContains ('<span itemprop="reviewCount">2</span> ' , $ actualResult );
33+ }
34+ }
Original file line number Diff line number Diff line change 44 * See COPYING.txt for license details.
55 */
66
7+ // phpcs:ignore Magento2.Security.IncludeFile
78require __DIR__ . '/../../../Magento/Catalog/_files/product_simple.php ' ;
89
910$ review = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
7172 )->getStore ()->getId ()
7273 ]
7374)->save ();
75+ $ review ->aggregate ();
Original file line number Diff line number Diff line change 77use Magento \Catalog \Api \ProductRepositoryInterface ;
88use Magento \Catalog \Model \ProductRepository ;
99
10+ // phpcs:ignore Magento2.Security.IncludeFile
1011require __DIR__ . '/../../../Magento/ConfigurableProduct/_files/product_configurable.php ' ;
1112
1213$ objectManager = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ();
13-
14+ // phpcs:ignore Magento2.Security.IncludeFile
1415$ addressData = include __DIR__ . '/../../../Magento/Sales/_files/address_data.php ' ;
1516
1617$ billingAddress = $ objectManager ->create (\Magento \Sales \Model \Order \Address::class, ['data ' => $ addressData ]);
6263$ orderItem ->setProductType ($ product ->getTypeId ());
6364$ orderItem ->setProductOptions (['info_buyRequest ' => $ requestInfo ]);
6465$ orderItemSimple ->setProductId ($ simpleProduct ->getId ());
66+ $ orderItem ->setName ($ product ->getName ());
67+ $ orderItem ->setSku ($ simpleProduct ->getSku ());
6568$ orderItemSimple ->setParentItem ($ orderItem );
6669$ orderItemSimple ->setStoreId (0 );
6770$ orderItemSimple ->setProductType ($ simpleProduct ->getTypeId ());
Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * Copyright © Magento, Inc. All rights reserved.
4+ * See COPYING.txt for license details.
5+ */
6+
7+ namespace Magento \Framework \Serialize \Test \Unit \Serializer ;
8+
9+ /**
10+ * Class JsonConverterTest
11+ */
12+ class JsonConverterTest extends \PHPUnit \Framework \TestCase
13+ {
14+ public function testConvert ()
15+ {
16+ $ data = [
17+ 'key ' => 'value '
18+ ];
19+
20+ $ this ->assertEquals (json_encode ($ data ), \Magento \Framework \Serialize \JsonConverter::convert ($ data ));
21+ }
22+
23+ /**
24+ * @expectedException \InvalidArgumentException
25+ * @expectedExceptionMessage Unable to serialize value.
26+ */
27+ public function testConvertWithException ()
28+ {
29+ //verify that exception will be thrown with invalid UTF8 sequence
30+ \Magento \Framework \Serialize \JsonConverter::convert ("\xB1\x31" );
31+ }
32+ }
You can’t perform that action at this time.
0 commit comments