Skip to content

Commit 0550a73

Browse files
committed
ADO-313: adds phpunit test for customer section data
1 parent 7b89c86 commit 0550a73

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Meta\Conversion\Test\Unit\CustomerData;
5+
6+
use PHPUnit\Framework\TestCase;
7+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
8+
use Meta\Conversion\CustomerData\EventData;
9+
use Magento\Customer\Model\Session as CustomerSession;
10+
11+
class EventDataTest extends TestCase
12+
{
13+
private $customerSessionMock;
14+
private $subject;
15+
16+
public function setUp(): void
17+
{
18+
$this->customerSessionMock = $this->getMockBuilder(CustomerSession::class)
19+
->addMethods(['getMetaEventIds'])
20+
->disableOriginalConstructor()
21+
->getMock();
22+
23+
$object = new ObjectManager($this);
24+
$this->subject = $object->getObject(EventData::class, ['customerSession' => $this->customerSessionMock]);
25+
}
26+
27+
public function testGetSectionDataWithData()
28+
{
29+
$metaEventIds = [
30+
'addtocart' => '123423hbv-3243r1hb-1324r4t'
31+
];
32+
$sectionData = [
33+
'eventIds' => $metaEventIds
34+
];
35+
36+
$this->customerSessionMock->expects($this->once())->method('getMetaEventIds')->willReturn($metaEventIds);
37+
$this->assertEquals($sectionData, $this->subject->getSectionData());
38+
}
39+
40+
public function testGetSectionDataWithoutData()
41+
{
42+
$sectionData = [
43+
'eventIds' => []
44+
];
45+
46+
$this->customerSessionMock->expects($this->once())->method('getMetaEventIds')->willReturn(null);
47+
$this->assertEquals($sectionData, $this->subject->getSectionData());
48+
}
49+
}

0 commit comments

Comments
 (0)