Skip to content

Commit

Permalink
MAGETWO-32829: [GITHUB] Add tests for View\Layout\Reader\Block and sl…
Browse files Browse the repository at this point in the history
…ight refactoring #906

- fixed code style and added lost copyright blocks
  • Loading branch information
vpelipenko committed Jan 20, 2015
1 parent 5167e01 commit ee882bf
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php

/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Framework\View\Layout\Reader;

class BlockTest extends \PHPUnit_Framework_TestCase
Expand All @@ -17,28 +20,35 @@ class BlockTest extends \PHPUnit_Framework_TestCase
*/
private $readerContext;

/**
* @var string
*/
private $blockName = 'test.block';

/**
* @var string
*/
private $childBlockName = 'test.child.block';

public function setUp()
{
$this->block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
'Magento\Framework\View\Layout\Reader\Block'
);

$this->readerContext = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
'Magento\Framework\View\Layout\Reader\Context'
);
}

public function testInterpretBlockDirective()
{
$pageXml = new \Magento\Framework\View\Layout\Element(__DIR__ . '/_files/_layout_update_block.xml', 0, true);
$pageXml = new \Magento\Framework\View\Layout\Element(
__DIR__ . '/_files/_layout_update_block.xml', 0, true
);
$parentElement = new \Magento\Framework\View\Layout\Element('<page></page>');

foreach ($pageXml->xpath('body/block') as $blockElement) {
$this->assertTrue(in_array($blockElement->getName(), $this->block->getSupportedNodes()));

$this->block->interpret($this->readerContext, $blockElement, $parentElement);
}

Expand Down Expand Up @@ -73,7 +83,6 @@ public function testInterpretReferenceBlockDirective()

foreach ($pageXml->xpath('body/*') as $element) {
$this->assertTrue(in_array($element->getName(), $this->block->getSupportedNodes()));

$this->block->interpret($this->readerContext, $element, $parentElement);
}

Expand All @@ -88,4 +97,4 @@ public function testInterpretReferenceBlockDirective()
$resultElementData['arguments']
);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<!--
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<body>
<block class="Dummy\Class"
name="test.block"
group="test.group"
template="test.phtml"
ttl="3">
<block class="Dummy\Class" name="test.block" group="test.group" template="test.phtml" ttl="3">
<arguments>
<argument name="test_arg" xsi:type="string">test-argument-value</argument>
</arguments>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<!--
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<body>
<block class="Dummy\Class" name="test.block"/>
<referenceBlock name="test.block">
Expand Down

0 comments on commit ee882bf

Please sign in to comment.