15
15
use Magento \Framework \Event \ManagerInterface ;
16
16
use Magento \Framework \TestFramework \Unit \Helper \ObjectManager ;
17
17
use Magento \Quote \Model \ResourceModel \Quote ;
18
+ use Magento \Reports \Model \ResourceModel \Quote \Collection ;
18
19
use PHPUnit \Framework \MockObject \MockObject ;
19
20
use PHPUnit \Framework \TestCase ;
20
21
@@ -42,7 +43,7 @@ protected function setUp(): void
42
43
public function testGetSelectCountSql ()
43
44
{
44
45
/** @var MockObject $collection */
45
- $ collection = $ this ->getMockBuilder (\ Magento \ Reports \ Model \ ResourceModel \ Quote \ Collection::class)
46
+ $ collection = $ this ->getMockBuilder (Collection::class)
46
47
->setMethods (['getSelect ' ])
47
48
->disableOriginalConstructor ()
48
49
->getMock ();
@@ -62,20 +63,25 @@ public function testPrepareActiveCartItems()
62
63
$ constructArgs = $ this ->objectManager
63
64
->getConstructArguments (\Magento \Reports \Model \ResourceModel \Quote \Item \Collection::class);
64
65
$ collection = $ this ->getMockBuilder (\Magento \Reports \Model \ResourceModel \Quote \Item \Collection::class)
65
- ->setMethods (['getSelect ' , 'getTable ' ])
66
+ ->setMethods (['getSelect ' , 'getTable ' , ' getFlag ' , ' setFlag ' ])
66
67
->disableOriginalConstructor ()
67
68
->setConstructorArgs ($ constructArgs )
68
69
->getMock ();
69
70
70
- $ collection ->expects ($ this ->once ( ))->method ('getSelect ' )->willReturn ($ this ->selectMock );
71
+ $ collection ->expects ($ this ->exactly ( 2 ))->method ('getSelect ' )->willReturn ($ this ->selectMock );
71
72
$ this ->selectMock ->expects ($ this ->once ())->method ('reset ' )->willReturnSelf ();
72
73
$ this ->selectMock ->expects ($ this ->once ())->method ('from ' )->willReturnSelf ();
73
74
$ this ->selectMock ->expects ($ this ->atLeastOnce ())->method ('columns ' )->willReturnSelf ();
74
75
$ this ->selectMock ->expects ($ this ->once ())->method ('joinInner ' )->willReturnSelf ();
75
76
$ this ->selectMock ->expects ($ this ->once ())->method ('where ' )->willReturnSelf ();
76
77
$ this ->selectMock ->expects ($ this ->once ())->method ('group ' )->willReturnSelf ();
77
78
$ collection ->expects ($ this ->exactly (2 ))->method ('getTable ' )->willReturn ('table ' );
79
+ $ collection ->expects ($ this ->once ())->method ('setFlag ' )
80
+ ->with ('reports_collection_prepared ' )->willReturnSelf ();
78
81
$ collection ->prepareActiveCartItems ();
82
+ $ collection ->method ('getFlag ' )
83
+ ->with ('reports_collection_prepared ' )->willReturn (true );
84
+ $ this ->assertEquals ($ this ->selectMock , $ collection ->prepareActiveCartItems ());
79
85
}
80
86
81
87
public function testLoadWithFilter ()
0 commit comments