ElementTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\View\Layout;
  7. class ElementTest extends \PHPUnit\Framework\TestCase
  8. {
  9. /**
  10. * @var \Magento\Framework\View\Layout\Element
  11. */
  12. protected $model;
  13. public function testPrepare()
  14. {
  15. /**
  16. * @TODO: Need to use ObjectManager instead 'new'.
  17. * On this moment we have next bug MAGETWO-4274 which blocker for this key.
  18. */
  19. $this->model = new \Magento\Framework\View\Layout\Element(__DIR__ . '/_files/_layout_update.xml', 0, true);
  20. list($blockNode) = $this->model->xpath('//block[@name="nodeForTesting"]');
  21. list($actionNode) = $this->model->xpath('//action[@method="setSomething"]');
  22. $this->assertEmpty($blockNode->attributes()->parent);
  23. $this->assertEmpty($actionNode->attributes()->block);
  24. $this->model->prepare();
  25. $this->assertEquals('root', (string)$blockNode->attributes()->parent);
  26. $this->assertEquals(\Magento\Backend\Block\Page::class, (string)$blockNode->attributes()->class);
  27. $this->assertEquals('nodeForTesting', (string)$actionNode->attributes()->block);
  28. }
  29. }