Skip to content

Commit f3848f1

Browse files
committed
MQE-421: Create Unit Tests for the object model
- Fixed CR feedback - Merged in sprint-develop and fixed conflicts
1 parent e87c464 commit f3848f1

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

dev/tests/unit/Magento/FunctionalTestFramework/Page/Objects/ElementObjectTest.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace tests\unit\Magento\FunctionalTestFramework\Page\Objects;
88

9+
use Magento\FunctionalTestingFramework\Exceptions\XmlException;
910
use Magento\FunctionalTestingFramework\Page\Objects\ElementObject;
1011
use PHPUnit\Framework\TestCase;
1112

@@ -19,7 +20,7 @@ class ElementObjectTest extends TestCase
1920
*/
2021
public function testTimeoutDefault()
2122
{
22-
$element = new ElementObject('name', 'type', 'selector', '-', false);
23+
$element = new ElementObject('name', 'type', 'selector', null, '-', false);
2324
$this->assertNull($element->getTimeout());
2425
}
2526

@@ -28,7 +29,7 @@ public function testTimeoutDefault()
2829
*/
2930
public function testTimeoutNotNull()
3031
{
31-
$element = new ElementObject('name', 'type', 'selector', '15', false);
32+
$element = new ElementObject('name', 'type', 'selector', null, '15', false);
3233
$timeout = $element->getTimeout();
3334
$this->assertEquals(15, $timeout);
3435
$this->assertInternalType('int', $timeout);
@@ -39,9 +40,19 @@ public function testTimeoutNotNull()
3940
*/
4041
public function testTimeoutCastFromString()
4142
{
42-
$element = new ElementObject('name', 'type', 'selector', 'helloString', true);
43+
$element = new ElementObject('name', 'type', 'selector', null, 'helloString', true);
4344
$timeout = $element->getTimeout();
4445
$this->assertEquals(0, $timeout);
4546
$this->assertInternalType('int', $timeout);
4647
}
48+
49+
50+
/**
51+
* An exception should be thrown if both a selector and locatorFunction are passed
52+
*/
53+
public function testBothSelectorAndLocatorFunction()
54+
{
55+
$this->expectException(XmlException::class);
56+
new ElementObject('name', 'type', 'selector', 'cantDoThis', 'helloString', true);
57+
}
4758
}

dev/tests/unit/Magento/FunctionalTestFramework/Page/Objects/SectionObjectTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ class SectionObjectTest extends TestCase
1919
* Assert that the section object has an element
2020
*/
2121
public function testHasElement() {
22-
$element1 = new ElementObject('element1', 'type', '#selector', '41', false);
23-
$element2 = new ElementObject('element2', 'type', '#selector', '42', true);
22+
$element1 = new ElementObject('element1', 'type', '#selector', null, '41', false);
23+
$element2 = new ElementObject('element2', 'type', '#selector', null, '42', true);
2424
$elements = [
2525
'element1' => $element1,
2626
'element2' => $element2
@@ -33,7 +33,7 @@ public function testHasElement() {
3333
* Assert that the section object doesn't have an element
3434
*/
3535
public function testDoesntHaveElement() {
36-
$element2 = new ElementObject('element2', 'type', '#selector', '42', true);
36+
$element2 = new ElementObject('element2', 'type', '#selector', null, '42', true);
3737
$elements = [
3838
'element2' => $element2
3939
];
@@ -45,8 +45,8 @@ public function testDoesntHaveElement() {
4545
* Assert that an element object is returned
4646
*/
4747
public function testGetElement() {
48-
$element1 = new ElementObject('element1', 'type', '#selector', '41', false);
49-
$element2 = new ElementObject('element2', 'type', '#selector', '42', true);
48+
$element1 = new ElementObject('element1', 'type', '#selector', null, '41', false);
49+
$element2 = new ElementObject('element2', 'type', '#selector', null, '42', true);
5050
$elements = [
5151
'element1' => $element1,
5252
'element2' => $element2
@@ -61,7 +61,7 @@ public function testGetElement() {
6161
* Assert that null is returned if no such element
6262
*/
6363
public function testNullGetElement() {
64-
$element1 = new ElementObject('element1', 'type', '#selector', '41', false);
64+
$element1 = new ElementObject('element1', 'type', '#selector', null, '41', false);
6565
$elements = [
6666
'element1' => $element1
6767
];

dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionObjectTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function testResolveElementInSelector()
5050
'selector' => '{{SectionObject.elementObject}}',
5151
'userInput' => 'Hello world'
5252
]);
53-
$elementObject = new ElementObject('elementObject', 'button', '#replacementSelector', '42', false);
53+
$elementObject = new ElementObject('elementObject', 'button', '#replacementSelector', null, '42', false);
5454
$sectionObject = new SectionObject('SectionObject', ['elementObject' => $elementObject]);
5555
$instance = AspectMock::double(SectionObjectHandler::class, ['getObject' => $sectionObject])
5656
->make(); // bypass the private constructor
@@ -92,7 +92,7 @@ public function testTimeoutFromElement()
9292
$actionObject = new ActionObject('merge123', 'click', [
9393
'selector' => '{{SectionObject.elementObject}}'
9494
]);
95-
$elementObject = new ElementObject('elementObject', 'button', '#replacementSelector', '42', false);
95+
$elementObject = new ElementObject('elementObject', 'button', '#replacementSelector', null, '42', false);
9696
$sectionObject = new SectionObject('SectionObject', ['elementObject' => $elementObject]);
9797
$instance = AspectMock::double(SectionObjectHandler::class, ['getObject' => $sectionObject])
9898
->make(); // bypass the private constructor

0 commit comments

Comments
 (0)