ltsecurityinc安防产品在线商城代码

This commit is contained in:
2026-09-14 17:47:10 +08:00
parent 57d8444c15
commit 6a3c9c5bd8
14539 changed files with 1775310 additions and 0 deletions
@@ -0,0 +1,119 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* Core layout utility
*/
namespace Magento\Framework\View\Utility;
/**
* The integration testsuite for Layout view utility
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Layout
{
/**
* @var \PHPUnit\Framework\TestCase
*/
protected $_testCase;
/**
* @param \PHPUnit\Framework\TestCase $testCase
*/
public function __construct(\PHPUnit\Framework\TestCase $testCase)
{
$this->_testCase = $testCase;
}
/**
* Retrieve new layout update model instance with XML data from a fixture file
*
* @param string|array $layoutUpdatesFile
* @return \Magento\Framework\View\Layout\ProcessorInterface
*/
public function getLayoutUpdateFromFixture($layoutUpdatesFile)
{
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
/** @var \Magento\Framework\View\File\Factory $fileFactory */
$fileFactory = $objectManager->get(\Magento\Framework\View\File\Factory::class);
$files = [];
foreach ((array)$layoutUpdatesFile as $filename) {
$files[] = $fileFactory->create($filename, 'Magento_View');
}
$fileSource = $this->_testCase
->getMockBuilder(\Magento\Framework\View\File\CollectorInterface::class)->getMockForAbstractClass();
$fileSource->expects(
\PHPUnit\Framework\TestCase::any()
)->method(
'getFiles'
)->will(
\PHPUnit\Framework\TestCase::returnValue($files)
);
$pageLayoutFileSource = $this->_testCase
->getMockBuilder(\Magento\Framework\View\File\CollectorInterface::class)->getMockForAbstractClass();
$pageLayoutFileSource->expects(\PHPUnit\Framework\TestCase::any())
->method('getFiles')
->willReturn([]);
$cache = $this->_testCase
->getMockBuilder(\Magento\Framework\Cache\FrontendInterface::class)->getMockForAbstractClass();
return $objectManager->create(
\Magento\Framework\View\Layout\ProcessorInterface::class,
['fileSource' => $fileSource, 'pageLayoutFileSource' => $pageLayoutFileSource, 'cache' => $cache]
);
}
/**
* Retrieve new layout model instance with layout updates from a fixture file
*
* @param string|array $layoutUpdatesFile
* @param array $args
* @return \Magento\Framework\View\Layout|\PHPUnit\Framework\MockObject\MockObject
*/
public function getLayoutFromFixture($layoutUpdatesFile, array $args = [])
{
$layout = $this->_testCase->getMockBuilder(\Magento\Framework\View\Layout::class)
->setMethods(['getUpdate'])
->setConstructorArgs($args)
->getMock();
$layoutUpdate = $this->getLayoutUpdateFromFixture($layoutUpdatesFile);
$layoutUpdate->asSimplexml();
$layout->expects(
\PHPUnit\Framework\TestCase::any()
)->method(
'getUpdate'
)->will(
\PHPUnit\Framework\TestCase::returnValue($layoutUpdate)
);
return $layout;
}
/**
* Retrieve object that will be used for layout instantiation
*
* @return array
*/
public function getLayoutDependencies()
{
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
return [
'processorFactory' => $objectManager->get(\Magento\Framework\View\Layout\ProcessorFactory::class),
'eventManager' => $objectManager->get(\Magento\Framework\Event\ManagerInterface::class),
'structure' => $objectManager->create(\Magento\Framework\View\Layout\Data\Structure::class, []),
'messageManager' => $objectManager->get(\Magento\Framework\Message\ManagerInterface::class),
'themeResolver' => $objectManager->get(\Magento\Framework\View\Design\Theme\ResolverInterface::class),
'readerPool' => $objectManager->get('commonRenderPool'),
'generatorPool' => $objectManager->get(\Magento\Framework\View\Layout\GeneratorPool::class),
'cache' => $objectManager->get(\Magento\Framework\App\Cache\Type\Layout::class),
'readerContextFactory' => $objectManager->get(\Magento\Framework\View\Layout\Reader\ContextFactory::class),
'generatorContextFactory' => $objectManager->get(
\Magento\Framework\View\Layout\Generator\ContextFactory::class
),
'appState' => $objectManager->get(\Magento\Framework\App\State::class),
'logger' => $objectManager->get(\Psr\Log\LoggerInterface::class),
];
}
}
@@ -0,0 +1,83 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Framework\View\Utility;
use Magento\Framework\App\Bootstrap;
use Magento\Framework\App\Filesystem\DirectoryList;
class LayoutTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Framework\View\Utility\Layout
*/
protected $_utility;
protected function setUp(): void
{
\Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize(
[
Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS => [
DirectoryList::APP => ['path' => BP . '/dev/tests/integration'],
],
]
);
$this->_utility = new \Magento\Framework\View\Utility\Layout($this);
}
/**
* Assert that the actual layout update instance represents the expected layout update file
*
* @param string $expectedUpdateFile
* @param \Magento\Framework\View\Layout\ProcessorInterface $actualUpdate
*/
protected function _assertLayoutUpdate($expectedUpdateFile, $actualUpdate)
{
$this->assertInstanceOf(\Magento\Framework\View\Layout\ProcessorInterface::class, $actualUpdate);
$layoutUpdateXml = $actualUpdate->getFileLayoutUpdatesXml();
$this->assertInstanceOf(\Magento\Framework\View\Layout\Element::class, $layoutUpdateXml);
$this->assertXmlStringEqualsXmlFile($expectedUpdateFile, $layoutUpdateXml->asNiceXml());
}
/**
* @param string|array $inputFiles
* @param string $expectedFile
*
* @dataProvider getLayoutFromFixtureDataProvider
*/
public function testGetLayoutUpdateFromFixture($inputFiles, $expectedFile)
{
$layoutUpdate = $this->_utility->getLayoutUpdateFromFixture($inputFiles);
$this->_assertLayoutUpdate($expectedFile, $layoutUpdate);
}
/**
* @param string|array $inputFiles
* @param string $expectedFile
*
* @dataProvider getLayoutFromFixtureDataProvider
*/
public function testGetLayoutFromFixture($inputFiles, $expectedFile)
{
$layout = $this->_utility->getLayoutFromFixture($inputFiles, $this->_utility->getLayoutDependencies());
$this->assertInstanceOf(\Magento\Framework\View\LayoutInterface::class, $layout);
$this->_assertLayoutUpdate($expectedFile, $layout->getUpdate());
}
public function getLayoutFromFixtureDataProvider()
{
return [
'single fixture file' => [
__DIR__ . '/_files/layout/handle_two.xml',
__DIR__ . '/_files/layout_merged/single_handle.xml',
],
'multiple fixture files' => [
glob(__DIR__ . '/_files/layout/*.xml'),
__DIR__ . '/_files/layout_merged/multiple_handles.xml',
]
];
}
}
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<block class="Magento\Framework\View\Element\Text" name="some_text_block">
<action method="setText">
<text>Some Default Text</text>
</action>
</block>
</page>
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page label="Handle Three" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="handle_one"/>
</page>
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page label="Handle Two" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="handle_one"/>
<referenceBlock name="some_text_block">
<action method="setText">
<text>Some Custom Text</text>
</action>
</referenceBlock>
</page>
@@ -0,0 +1,27 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<layouts>
<handle id="handle_one">
<block class="Magento\Framework\View\Element\Text" name="some_text_block">
<action method="setText">
<text>Some Default Text</text>
</action>
</block>
</handle>
<handle id="handle_three" label="Handle Three">
<update handle="handle_one"/>
</handle>
<handle id="handle_two" label="Handle Two">
<update handle="handle_one"/>
<referenceBlock name="some_text_block">
<action method="setText">
<text>Some Custom Text</text>
</action>
</referenceBlock>
</handle>
</layouts>
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<layouts>
<handle id="handle_two" label="Handle Two">
<update handle="handle_one"/>
<referenceBlock name="some_text_block">
<action method="setText">
<text>Some Custom Text</text>
</action>
</referenceBlock>
</handle>
</layouts>