File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
app/code/Magento/CatalogInventory/Test/Unit/Model/Source Expand file tree Collapse file tree 1 file changed +44
-0
lines changed 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 \CatalogInventory \Test \Unit \Model \Source ;
8
+
9
+ use PHPUnit \Framework \TestCase ;
10
+
11
+ class StockTest extends TestCase
12
+ {
13
+ /**
14
+ * @var \Magento\CatalogInventory\Model\Source\Stock
15
+ */
16
+ private $ model ;
17
+
18
+ protected function setUp ()
19
+ {
20
+ $ this ->model = new \Magento \CatalogInventory \Model \Source \Stock ();
21
+ }
22
+
23
+ public function testAddValueSortToCollection ()
24
+ {
25
+ $ selectMock = $ this ->createMock (\Magento \Framework \DB \Select::class);
26
+ $ collectionMock = $ this ->createMock (\Magento \Eav \Model \Entity \Collection \AbstractCollection::class);
27
+ $ collectionMock ->expects ($ this ->atLeastOnce ())->method ('getSelect ' )->willReturn ($ selectMock );
28
+
29
+ $ selectMock ->expects ($ this ->once ())
30
+ ->method ('joinLeft ' )
31
+ ->with (
32
+ ['stock_item_table ' => 'cataloginventory_stock_item ' ],
33
+ "e.entity_id=stock_item_table.product_id " ,
34
+ []
35
+ )
36
+ ->willReturnSelf ();
37
+ $ selectMock ->expects ($ this ->once ())
38
+ ->method ('order ' )
39
+ ->with ("stock_item_table.qty DESC " )
40
+ ->willReturnSelf ();
41
+
42
+ $ this ->model ->addValueSortToCollection ($ collectionMock );
43
+ }
44
+ }
You can’t perform that action at this time.
0 commit comments