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,58 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Newsletter\Block\Adminhtml\Queue\Edit;
/**
* Test class for \Magento\Newsletter\Block\Adminhtml\Queue\Edit\Form
* @magentoAppArea adminhtml
*/
class FormTest extends \PHPUnit\Framework\TestCase
{
/**
* @magentoAppIsolation enabled
*/
public function testPrepareForm()
{
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$queue = $objectManager->get(\Magento\Newsletter\Model\Queue::class);
/** @var \Magento\Framework\Registry $registry */
$registry = $objectManager->get(\Magento\Framework\Registry::class);
$registry->register('current_queue', $queue);
$objectManager->get(
\Magento\Framework\View\DesignInterface::class
)->setArea(
\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE
)->setDefaultDesignTheme();
$objectManager->get(
\Magento\Framework\Config\ScopeInterface::class
)->setCurrentScope(
\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE
);
$block = $objectManager->create(
\Magento\Newsletter\Block\Adminhtml\Queue\Edit\Form::class,
['registry' => $registry]
);
$prepareFormMethod = new \ReflectionMethod(
\Magento\Newsletter\Block\Adminhtml\Queue\Edit\Form::class,
'_prepareForm'
);
$prepareFormMethod->setAccessible(true);
$statuses = [
\Magento\Newsletter\Model\Queue::STATUS_NEVER,
\Magento\Newsletter\Model\Queue::STATUS_PAUSE,
];
foreach ($statuses as $status) {
$queue->setQueueStatus($status);
$prepareFormMethod->invoke($block);
$element = $block->getForm()->getElement('date');
$this->assertNotNull($element);
$this->assertNotEmpty($element->getTimeFormat());
$this->assertNotEmpty($element->getDateFormat());
}
}
}
@@ -0,0 +1,105 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\Newsletter\Block\Adminhtml\Subscriber;
/**
* @magentoAppArea adminhtml
* @magentoDbIsolation enabled
*
* @see \Magento\Newsletter\Block\Adminhtml\Subscriber\Grid
*/
class GridTest extends \PHPUnit\Framework\TestCase
{
/**
* @var null|\Magento\Framework\ObjectManagerInterface
*/
private $objectManager = null;
/**
* @var null|\Magento\Framework\View\LayoutInterface
*/
private $layout = null;
/**
* Set up layout.
*/
protected function setUp(): void
{
parent::setUp();
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$this->layout = $this->objectManager->create(\Magento\Framework\View\LayoutInterface::class);
$this->layout->getUpdate()->load('newsletter_subscriber_grid');
$this->layout->generateXml();
$this->layout->generateElements();
}
/**
* Check if mass action block exists.
*/
public function testMassActionBlockExists()
{
$this->assertNotFalse(
$this->getMassActionBlock(),
'Mass action block does not exist in the grid, or it name was changed.'
);
}
/**
* Check if mass action id field is correct.
*/
public function testMassActionFieldIdIsCorrect()
{
$this->assertEquals(
'subscriber_id',
$this->getMassActionBlock()->getMassactionIdField(),
'Mass action id field is incorrect.'
);
}
/**
* Check if function returns correct result.
*
* @magentoDataFixture Magento/Newsletter/_files/subscribers.php
*/
public function testMassActionBlockContainsCorrectIdList()
{
$this->assertEquals(
implode(',', $this->getAllSubscriberIdList()),
$this->getMassActionBlock()->getGridIdsJson(),
'Function returns incorrect result.'
);
}
/**
* Retrieve mass action block.
*
* @return bool|\Magento\Backend\Block\Widget\Grid\Massaction
*/
private function getMassActionBlock()
{
return $this->layout->getBlock('adminhtml.newslettrer.subscriber.grid.massaction');
}
/**
* Retrieve list of id of all subscribers.
*
* @return array
*/
private function getAllSubscriberIdList()
{
/** @var \Magento\Framework\App\ResourceConnection $resourceConnection */
$resourceConnection = $this->objectManager->get(\Magento\Framework\App\ResourceConnection::class);
$select = $resourceConnection->getConnection()
->select()
->from($resourceConnection->getTableName('newsletter_subscriber'))
->columns(['subscriber_id' => 'subscriber_id']);
return $resourceConnection->getConnection()->fetchCol($select);
}
}
@@ -0,0 +1,29 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Newsletter\Block\Adminhtml;
/**
* @magentoAppArea adminhtml
*/
class SubscriberTest extends \PHPUnit\Framework\TestCase
{
public function testGetShowQueueAdd()
{
/** @var $layout \Magento\Framework\View\Layout */
$layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
\Magento\Framework\View\LayoutInterface::class
);
/** @var $block \Magento\Newsletter\Block\Adminhtml\Subscriber */
$block = $layout->createBlock(\Magento\Newsletter\Block\Adminhtml\Subscriber::class, 'block');
/** @var $childBlock \Magento\Framework\View\Element\Template */
$childBlock = $layout->addBlock(\Magento\Framework\View\Element\Template::class, 'grid', 'block');
$expected = 'test_data';
$this->assertNotEquals($expected, $block->getShowQueueAdd());
$childBlock->setShowQueueAdd($expected);
$this->assertEquals($expected, $block->getShowQueueAdd());
}
}