ltsecurityinc安防产品在线商城代码
This commit is contained in:
+56
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Widget\Controller\Adminhtml\Widget\Instance;
|
||||
|
||||
use Magento\Framework\App\Request\Http;
|
||||
use Magento\Framework\Message\MessageInterface;
|
||||
use Magento\TestFramework\TestCase\AbstractBackendController;
|
||||
use Magento\Widget\Model\ResourceModel\Widget\Instance\Collection;
|
||||
use Magento\Widget\Model\ResourceModel\Widget\Instance\CollectionFactory;
|
||||
|
||||
/**
|
||||
* Test for delete widget controller
|
||||
*
|
||||
* @see \Magento\Widget\Controller\Adminhtml\Widget\Instance\Delete
|
||||
* @magentoAppArea adminhtml
|
||||
* @magentoDbIsolation enabled
|
||||
*/
|
||||
class DeleteTest extends AbstractBackendController
|
||||
{
|
||||
/** @var Collection */
|
||||
private $widgetCollection;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->widgetCollection = $this->_objectManager->get(CollectionFactory::class)->create();
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Widget/_files/new_widget.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testDeleteWidget(): void
|
||||
{
|
||||
$widget = $this->widgetCollection->addFieldToFilter('title', 'New Sample widget title')->getFirstItem();
|
||||
$this->assertNotNull($widget->getInstanceId());
|
||||
$this->getRequest()->setMethod(Http::METHOD_POST);
|
||||
$this->getRequest()->setParams(['instance_id' => $widget->getInstanceId()]);
|
||||
$this->dispatch('backend/admin/widget_instance/delete');
|
||||
$this->assertSessionMessages(
|
||||
$this->containsEqual((string)__('The widget instance has been deleted.')),
|
||||
MessageInterface::TYPE_SUCCESS
|
||||
);
|
||||
$this->assertRedirect($this->stringContains('admin/widget_instance/index'));
|
||||
}
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Widget\Controller\Adminhtml\Widget;
|
||||
|
||||
use Magento\Backend\App\Area\FrontNameResolver;
|
||||
use Magento\Cms\Block\Widget\Page\Link;
|
||||
use Magento\Framework\App\Area;
|
||||
use Magento\Framework\View\DesignInterface;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\TestFramework\TestCase\AbstractBackendController;
|
||||
use Magento\Widget\Model\Widget\Instance;
|
||||
|
||||
/**
|
||||
* @magentoAppArea adminhtml
|
||||
*/
|
||||
class InstanceTest extends AbstractBackendController
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Bootstrap::getInstance()
|
||||
->loadArea(FrontNameResolver::AREA_CODE);
|
||||
|
||||
$theme = Bootstrap::getObjectManager()->get(
|
||||
DesignInterface::class
|
||||
)->setDefaultDesignTheme()->getDesignTheme();
|
||||
$type = Link::class;
|
||||
/** @var $model Instance */
|
||||
$model = Bootstrap::getObjectManager()->create(
|
||||
Instance::class
|
||||
);
|
||||
$code = $model->setType($type)->getWidgetReference('type', $type, 'code');
|
||||
$this->getRequest()->setParam('code', $code);
|
||||
$this->getRequest()->setParam('theme_id', $theme->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testEditAction(): void
|
||||
{
|
||||
$this->dispatch('backend/admin/widget_instance/edit');
|
||||
$this->assertMatchesRegularExpression(
|
||||
'/<option value="cms_page_link".*?selected="selected"\>/is',
|
||||
$this->getResponse()->getBody()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testBlocksAction(): void
|
||||
{
|
||||
Bootstrap::getInstance()
|
||||
->loadArea(Area::AREA_FRONTEND);
|
||||
$theme = Bootstrap::getObjectManager()->get(
|
||||
DesignInterface::class
|
||||
)->setDefaultDesignTheme()->getDesignTheme();
|
||||
$this->getRequest()->setParam('theme_id', $theme->getId());
|
||||
$this->dispatch('backend/admin/widget_instance/blocks');
|
||||
$this->assertStringStartsWith('<select name="block" id=""', $this->getResponse()->getBody());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testTemplateAction(): void
|
||||
{
|
||||
$this->getRequest()->setMethod('POST');
|
||||
$this->dispatch('backend/admin/widget_instance/template');
|
||||
$this->assertStringStartsWith('<select name="template" id=""', $this->getResponse()->getBody());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Widget\Controller\Adminhtml;
|
||||
|
||||
/**
|
||||
* @magentoAppArea adminhtml
|
||||
*/
|
||||
class WidgetTest extends \Magento\TestFramework\TestCase\AbstractBackendController
|
||||
{
|
||||
/**
|
||||
* Partially covers \Magento\Widget\Block\Adminhtml\Widget\Options::_addField()
|
||||
*/
|
||||
public function testLoadOptionsAction()
|
||||
{
|
||||
$this->getRequest()->setParam(
|
||||
'widget',
|
||||
'{"widget_type":"Magento\\\\Cms\\\\Block\\\\Widget\\\\Page\\\\Link","values":{}}'
|
||||
);
|
||||
$this->dispatch('backend/admin/widget/loadOptions');
|
||||
$output = $this->getResponse()->getBody();
|
||||
//searching for label with text "CMS Page"
|
||||
$this->assertStringContainsString(
|
||||
'data-ui-id="wysiwyg-widget-options-fieldset-element-label-parameters-page-id-label" >' . '<span>CMS Page',
|
||||
$output
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user