init
This commit is contained in:
+61
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Theme\Block\Adminhtml\System\Design\Theme\Edit\Tab;
|
||||
|
||||
/**
|
||||
* @magentoAppArea adminhtml
|
||||
*/
|
||||
class GeneralTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/** @var \Magento\Framework\View\LayoutInterface */
|
||||
protected $_layout;
|
||||
|
||||
/** @var \Magento\Framework\View\Design\ThemeInterface */
|
||||
protected $_theme;
|
||||
|
||||
/** @var \Magento\Theme\Block\Adminhtml\System\Design\Theme\Edit\Tab\General */
|
||||
protected $_block;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->_layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
|
||||
\Magento\Framework\View\LayoutInterface::class
|
||||
);
|
||||
$this->_theme = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Framework\View\Design\ThemeInterface::class
|
||||
);
|
||||
$this->_theme->setType(\Magento\Framework\View\Design\ThemeInterface::TYPE_VIRTUAL);
|
||||
$this->_block = $this->_layout->createBlock(
|
||||
\Magento\Theme\Block\Adminhtml\System\Design\Theme\Edit\Tab\General::class
|
||||
);
|
||||
}
|
||||
|
||||
public function testToHtmlPreviewImageNote()
|
||||
{
|
||||
/** @var $objectManager \Magento\TestFramework\ObjectManager */
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
$objectManager->get(\Magento\Framework\Registry::class)->register('current_theme', $this->_theme);
|
||||
$this->_block->setArea('adminhtml');
|
||||
|
||||
$this->_block->toHtml();
|
||||
|
||||
$noticeText = $this->_block->getForm()->getElement('preview_image')->getNote();
|
||||
$this->assertNotEmpty($noticeText);
|
||||
}
|
||||
|
||||
public function testToHtmlPreviewImageUrl()
|
||||
{
|
||||
/** @var $objectManager \Magento\TestFramework\ObjectManager */
|
||||
$this->_theme->setType(\Magento\Framework\View\Design\ThemeInterface::TYPE_PHYSICAL);
|
||||
$this->_theme->setPreviewImage('preview_image_test.jpg');
|
||||
$this->_block->setArea('adminhtml');
|
||||
|
||||
$html = $this->_block->toHtml();
|
||||
preg_match_all('/pub\/static\/adminhtml\/_view\/en_US/', $html, $result);
|
||||
$this->assertEmpty($result[0]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Theme\Block\Html;
|
||||
|
||||
use Magento\Framework\Serialize\SerializerInterface;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
|
||||
/**
|
||||
* @magentoAppArea frontend
|
||||
*/
|
||||
class BreadcrumbsTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Theme\Block\Html\Breadcrumbs
|
||||
*/
|
||||
private $block;
|
||||
|
||||
/**
|
||||
* @var SerializerInterface
|
||||
*/
|
||||
private $serializer;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
Bootstrap::getObjectManager()->get(\Magento\Framework\App\State::class)->setAreaCode('frontend');
|
||||
$this->block = Bootstrap::getObjectManager()
|
||||
->get(\Magento\Framework\View\LayoutInterface::class)
|
||||
->createBlock(\Magento\Theme\Block\Html\Breadcrumbs::class);
|
||||
$this->serializer = Bootstrap::getObjectManager()->get(SerializerInterface::class);
|
||||
}
|
||||
|
||||
public function testAddCrumb()
|
||||
{
|
||||
$this->assertEmpty($this->block->toHtml());
|
||||
$info = ['label' => 'test label', 'title' => 'test title', 'link' => 'test link'];
|
||||
$this->block->addCrumb('test', $info);
|
||||
$html = $this->block->toHtml();
|
||||
$this->assertStringContainsString('test label', $html);
|
||||
$this->assertStringContainsString('test title', $html);
|
||||
$this->assertStringContainsString('test link', $html);
|
||||
}
|
||||
|
||||
public function testGetCacheKeyInfo()
|
||||
{
|
||||
$crumbs = ['test' => ['label' => 'test label', 'title' => 'test title', 'link' => 'test link']];
|
||||
foreach ($crumbs as $crumbName => &$crumb) {
|
||||
$this->block->addCrumb($crumbName, $crumb);
|
||||
$crumb += ['first' => null, 'last' => null, 'readonly' => null];
|
||||
}
|
||||
|
||||
$cacheKeyInfo = $this->block->getCacheKeyInfo();
|
||||
$crumbsFromCacheKey = $this->serializer->unserialize(base64_decode($cacheKeyInfo['crumbs']));
|
||||
$this->assertEquals($crumbs, $crumbsFromCacheKey);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Theme\Block\Html;
|
||||
|
||||
use Magento\Customer\Model\Context;
|
||||
|
||||
class FooterTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Theme\Model\Theme
|
||||
*/
|
||||
protected $_theme;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Framework\App\State::class)
|
||||
->setAreaCode('frontend');
|
||||
$design = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
|
||||
\Magento\Framework\View\DesignInterface::class
|
||||
);
|
||||
$this->_theme = $design->setDefaultDesignTheme()->getDesignTheme();
|
||||
}
|
||||
|
||||
public function testGetCacheKeyInfo()
|
||||
{
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
$context = $objectManager->get(\Magento\Framework\App\Http\Context::class);
|
||||
$context->setValue(Context::CONTEXT_AUTH, false, false);
|
||||
$block = $objectManager->get(\Magento\Framework\View\LayoutInterface::class)
|
||||
->createBlock(\Magento\Theme\Block\Html\Footer::class)
|
||||
->setTemplate('html/copyright.phtml');
|
||||
$storeId = $objectManager->get(\Magento\Store\Model\StoreManagerInterface::class)->getStore()->getId();
|
||||
$expected = [
|
||||
'PAGE_FOOTER',
|
||||
$storeId,
|
||||
0,
|
||||
$this->_theme->getId(),
|
||||
false,
|
||||
$block->getTemplateFile(),
|
||||
'template' => 'html/copyright.phtml'
|
||||
];
|
||||
$this->assertEquals(
|
||||
$expected,
|
||||
$block->getCacheKeyInfo()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Theme\Block\Html\Header;
|
||||
|
||||
use Magento\Framework\View\LayoutInterface;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\TestFramework\Helper\Xpath;
|
||||
use Magento\Theme\ViewModel\Block\Html\Header\LogoSizeResolver;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test logo page header block
|
||||
*/
|
||||
class LogoTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var Logo
|
||||
*/
|
||||
private $block;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
$logoSizeResolver = $objectManager->get(LogoSizeResolver::class);
|
||||
$this->block = $objectManager->create(LayoutInterface::class)
|
||||
->createBlock(
|
||||
Logo::class,
|
||||
'logo',
|
||||
[
|
||||
'data' => [
|
||||
'logo_size_resolver' => $logoSizeResolver
|
||||
]
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoAppArea frontend
|
||||
* @magentoConfigFixture current_store design/header/logo_width 260
|
||||
* @magentoConfigFixture current_store design/header/logo_height 240
|
||||
*/
|
||||
public function testStoreLogoSize()
|
||||
{
|
||||
$xpath = '//a[@class="logo"]/img';
|
||||
$elements = Xpath::getElementsForXpath($xpath, $this->block->toHtml());
|
||||
$this->assertGreaterThan(0, $elements->count(), 'Cannot find element \'' . $xpath . '"\' in the HTML');
|
||||
$this->assertEquals(260, $elements->item(0)->getAttribute('width'));
|
||||
$this->assertEquals(240, $elements->item(0)->getAttribute('height'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user