Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
magento2-functional-testing-framework
dev
tests
unit
Magento
FunctionalTestFramework
DataGenerator
Handlers
DataObjectHandlerTest.php
Go to the documentation of this file.
1
<?php
7
namespace
tests\unit\Magento\FunctionalTestFramework\DataGenerator\Handlers
;
8
9
use AspectMock\Test as AspectMock;
10
use
Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler
;
11
use
Magento\FunctionalTestingFramework\DataGenerator\Objects\EntityDataObject
;
12
use
Magento\FunctionalTestingFramework\DataGenerator\Parsers\DataProfileSchemaParser
;
13
use
Magento\FunctionalTestingFramework\ObjectManager
;
14
use
Magento\FunctionalTestingFramework\ObjectManagerFactory
;
15
use
Magento\FunctionalTestingFramework\Util\MagentoTestCase
;
16
20
class
DataObjectHandlerTest
extends
MagentoTestCase
21
{
22
// All tests share this array, feel free to add but be careful modifying or removing
23
const
PARSER_OUTPUT
= [
24
'entity'
=> [
25
'EntityOne'
=> [
26
'type'
=>
'testType'
,
27
'data'
=> [
28
0 => [
29
'key'
=>
'testKey'
,
30
'value'
=>
'testValue'
31
]
32
]
33
]
34
]
35
];
36
42
public
static
function
setUpBeforeClass
()
43
{
44
$mockDataProfileSchemaParser = AspectMock::double(DataProfileSchemaParser::class, [
45
'readDataProfiles'
=> self::PARSER_OUTPUT
46
])->make();
47
48
$mockObjectManager = AspectMock::double(ObjectManager::class, [
49
'create'
=> $mockDataProfileSchemaParser
50
])->make();
51
52
AspectMock::double(ObjectManagerFactory::class, [
53
'getObjectManager'
=> $mockObjectManager
54
]);
55
}
56
60
public
function
testGetAllObjects
()
61
{
62
// Call the method under test
63
64
$actual =
DataObjectHandler::getInstance
()->getAllObjects();
65
66
// Assert
67
68
$expected =
new
EntityDataObject
(
'EntityOne'
,
'testType'
, [
'testkey'
=>
'testValue'
], [],
null
, []);
69
$this->assertArrayHasKey(
'EntityOne'
, $actual);
70
$this->assertEquals($expected, $actual[
'EntityOne'
]);
71
}
72
76
public
function
testGetObject
()
77
{
78
// Call the method under test
79
80
$actual =
DataObjectHandler::getInstance
()->getObject(
'EntityOne'
);
81
82
// Assert
83
84
$expected =
new
EntityDataObject
(
'EntityOne'
,
'testType'
, [
'testkey'
=>
'testValue'
], [],
null
, []);
85
$this->assertEquals($expected, $actual);
86
}
87
91
public
function
testGetObjectNull
()
92
{
93
$actual =
DataObjectHandler::getInstance
()->getObject(
'h953u789h0g73t521'
);
// doesnt exist
94
$this->assertNull($actual);
95
}
96
}
tests\unit\Magento\FunctionalTestFramework\DataGenerator\Handlers\DataObjectHandlerTest\testGetObject
testGetObject()
Definition:
DataObjectHandlerTest.php:76
Magento\FunctionalTestingFramework\DataGenerator\Objects\EntityDataObject
Definition:
EntityDataObject.php:16
tests\unit\Magento\FunctionalTestFramework\DataGenerator\Handlers\DataObjectHandlerTest\PARSER_OUTPUT
const PARSER_OUTPUT
Definition:
DataObjectHandlerTest.php:23
tests\unit\Magento\FunctionalTestFramework\DataGenerator\Handlers\DataObjectHandlerTest
Definition:
DataObjectHandlerTest.php:20
tests\unit\Magento\FunctionalTestFramework\DataGenerator\Handlers\DataObjectHandlerTest\testGetAllObjects
testGetAllObjects()
Definition:
DataObjectHandlerTest.php:60
Magento\FunctionalTestingFramework\ObjectManager
tests\unit\Magento\FunctionalTestFramework\DataGenerator\Handlers\DataObjectHandlerTest\testGetObjectNull
testGetObjectNull()
Definition:
DataObjectHandlerTest.php:91
Magento\FunctionalTestingFramework\ObjectManagerFactory
Definition:
ObjectManagerFactory.php:19
Magento\FunctionalTestingFramework\DataGenerator\Parsers\DataProfileSchemaParser
Definition:
DataProfileSchemaParser.php:14
tests\unit\Magento\FunctionalTestFramework\DataGenerator\Handlers
Definition:
CredentialStoreTest.php:7
Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler
Definition:
DataObjectHandler.php:16
Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler\getInstance
static getInstance()
Definition:
DataObjectHandler.php:78
Magento\FunctionalTestingFramework\Util\MagentoTestCase
Definition:
MagentoTestCase.php:15
tests\unit\Magento\FunctionalTestFramework\DataGenerator\Handlers\DataObjectHandlerTest\setUpBeforeClass
static setUpBeforeClass()
Definition:
DataObjectHandlerTest.php:42