1515use Magento \Framework \Event \ManagerInterface ;
1616use Magento \Framework \TestFramework \Unit \Helper \ObjectManager ;
1717use Magento \Quote \Model \ResourceModel \Quote ;
18+ use Magento \Reports \Model \ResourceModel \Quote \Collection ;
1819use PHPUnit \Framework \MockObject \MockObject ;
1920use PHPUnit \Framework \TestCase ;
2021
@@ -42,7 +43,7 @@ protected function setUp(): void
4243 public function testGetSelectCountSql ()
4344 {
4445 /** @var MockObject $collection */
45- $ collection = $ this ->getMockBuilder (\ Magento \ Reports \ Model \ ResourceModel \ Quote \ Collection::class)
46+ $ collection = $ this ->getMockBuilder (Collection::class)
4647 ->setMethods (['getSelect ' ])
4748 ->disableOriginalConstructor ()
4849 ->getMock ();
@@ -62,20 +63,25 @@ public function testPrepareActiveCartItems()
6263 $ constructArgs = $ this ->objectManager
6364 ->getConstructArguments (\Magento \Reports \Model \ResourceModel \Quote \Item \Collection::class);
6465 $ collection = $ this ->getMockBuilder (\Magento \Reports \Model \ResourceModel \Quote \Item \Collection::class)
65- ->setMethods (['getSelect ' , 'getTable ' ])
66+ ->setMethods (['getSelect ' , 'getTable ' , ' getFlag ' , ' setFlag ' ])
6667 ->disableOriginalConstructor ()
6768 ->setConstructorArgs ($ constructArgs )
6869 ->getMock ();
6970
70- $ collection ->expects ($ this ->once ( ))->method ('getSelect ' )->willReturn ($ this ->selectMock );
71+ $ collection ->expects ($ this ->exactly ( 2 ))->method ('getSelect ' )->willReturn ($ this ->selectMock );
7172 $ this ->selectMock ->expects ($ this ->once ())->method ('reset ' )->willReturnSelf ();
7273 $ this ->selectMock ->expects ($ this ->once ())->method ('from ' )->willReturnSelf ();
7374 $ this ->selectMock ->expects ($ this ->atLeastOnce ())->method ('columns ' )->willReturnSelf ();
7475 $ this ->selectMock ->expects ($ this ->once ())->method ('joinInner ' )->willReturnSelf ();
7576 $ this ->selectMock ->expects ($ this ->once ())->method ('where ' )->willReturnSelf ();
7677 $ this ->selectMock ->expects ($ this ->once ())->method ('group ' )->willReturnSelf ();
7778 $ collection ->expects ($ this ->exactly (2 ))->method ('getTable ' )->willReturn ('table ' );
79+ $ collection ->expects ($ this ->once ())->method ('setFlag ' )
80+ ->with ('reports_collection_prepared ' )->willReturnSelf ();
7881 $ collection ->prepareActiveCartItems ();
82+ $ collection ->method ('getFlag ' )
83+ ->with ('reports_collection_prepared ' )->willReturn (true );
84+ $ this ->assertEquals ($ this ->selectMock , $ collection ->prepareActiveCartItems ());
7985 }
8086
8187 public function testLoadWithFilter ()
0 commit comments