Skip to content

Commit 2742fe2

Browse files
committed
MTA-344: Update page and block generators to merge blocks and pages into one file from all modules
1 parent ffe96d8 commit 2742fe2

File tree

5 files changed

+16
-13
lines changed

5 files changed

+16
-13
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
* Added an ability to skip variation execution by specifying a value in 'issue' column in data set file
2+
* Rewrote page generator to collect related blocks from all modules
23

34
1.0.0-dev.4
45
=============

Mtf/Block/Block.php

+8-7
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ abstract class Block implements BlockInterface
5959
* @param BlockFactory $blockFactory
6060
* @param array $config
6161
*/
62-
public function __construct(Element $element, BlockFactory $blockFactory, array $config)
62+
public function __construct(Element $element, BlockFactory $blockFactory, array $config = [])
6363
{
6464
$this->_rootElement = $element;
6565
$this->blockFactory = $blockFactory;
@@ -140,20 +140,23 @@ function () use ($browser, $selector, $strategy) {
140140
* @param string $type
141141
* @param string $method
142142
* @param array $arguments
143-
* @return void
143+
* @return bool
144144
*/
145145
protected function callRender($type, $method, array $arguments = [])
146146
{
147147
$block = $this->getRenderInstance($type);
148-
call_user_func_array([$block, $method], $arguments);
148+
if ($block !== null) {
149+
call_user_func_array([$block, $method], $arguments);
150+
return true;
151+
}
152+
return false;
149153
}
150154

151155
/**
152156
* Get render instance by name
153157
*
154158
* @param string $renderName
155159
* @return BlockInterface
156-
* @throws \InvalidArgumentException
157160
*/
158161
protected function getRenderInstance($renderName)
159162
{
@@ -173,9 +176,7 @@ protected function getRenderInstance($renderName)
173176
]
174177
);
175178
} else {
176-
throw new \InvalidArgumentException(
177-
sprintf('There is no such render "%s" declared for the block "%s" ', $renderName, $class)
178-
);
179+
return null;
179180
}
180181

181182
$this->renderInstances[$renderName] = $block;

Mtf/Block/Form.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ class Form extends Block
6767
* @param Element $element
6868
* @param BlockFactory $blockFactory
6969
* @param Mapper $mapper
70-
* @param array $config
70+
* @param array $config [optional]
7171
*/
72-
public function __construct(Element $element, BlockFactory $blockFactory, Mapper $mapper, array $config)
72+
public function __construct(Element $element, BlockFactory $blockFactory, Mapper $mapper, array $config = [])
7373
{
7474
$this->mapper = $mapper;
7575
parent::__construct($element, $blockFactory, $config);

Mtf/ObjectManagerFactory.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,11 @@ public static function configure(\Magento\Framework\ObjectManager $objectManager
165165
);
166166

167167
$objectManager->configure(
168-
$objectManager->get('Mtf\ObjectManager\ConfigLoader\Module')->load('ui')
168+
$objectManager->get('Mtf\ObjectManager\ConfigLoader\Module')->load('etc\\ui')
169169
);
170170

171171
$objectManager->configure(
172-
$objectManager->get('Mtf\ObjectManager\ConfigLoader\Module')->load('curl')
172+
$objectManager->get('Mtf\ObjectManager\ConfigLoader\Module')->load('etc\\curl')
173173
);
174174
}
175175
}

Mtf/Util/Generate/BlockFactory.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@ protected function _addBlockToFactory($item)
5858
$realClass = $this->_resolveClass($item);
5959
$fallbackComment = $this->_buildFallbackComment($item, '$element');
6060

61+
$arguments = "\$element, \$driver = null, \$config = []";
6162
$this->_factoryContent .= "\n /**\n";
6263
$this->_factoryContent .= " * @return \\{$item['class']}\n";
6364
$this->_factoryContent .= " */\n";
64-
$this->_factoryContent .= " public function get{$methodNameSuffix}(\$element, \$driver = null)\n";
65+
$this->_factoryContent .= " public function get{$methodNameSuffix}({$arguments})\n";
6566
$this->_factoryContent .= " {";
6667

6768
if (!empty($fallbackComment)) {
@@ -70,7 +71,7 @@ protected function _addBlockToFactory($item)
7071
$this->_factoryContent .= "\n";
7172
}
7273

73-
$this->_factoryContent .= ' return new \\' . $realClass . '($element, $driver);';
74+
$this->_factoryContent .= ' return new \\' . $realClass . '($element, $driver, $config);';
7475
$this->_factoryContent .= "\n }\n";
7576

7677
$this->_cnt++;

0 commit comments

Comments
 (0)