ltsecurityinc安防产品在线商城代码
This commit is contained in:
+75
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Review\Controller\Adminhtml\Customer;
|
||||
|
||||
use Magento\Framework\App\Request\Http;
|
||||
use Magento\Framework\App\Request\Http as HttpRequest;
|
||||
use Magento\Framework\View\LayoutInterface;
|
||||
use Magento\TestFramework\TestCase\AbstractBackendController;
|
||||
|
||||
/**
|
||||
* Test for customer product reviews page.
|
||||
*
|
||||
* @magentoAppArea adminhtml
|
||||
*/
|
||||
class ProductReviewsTest extends AbstractBackendController
|
||||
{
|
||||
/** @var LayoutInterface */
|
||||
private $layout;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->layout = $this->_objectManager->get(LayoutInterface::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Customer product review action.
|
||||
*
|
||||
* @magentoDataFixture Magento/Customer/_files/customer_sample.php
|
||||
* @return void
|
||||
*/
|
||||
public function testProductReviewsAction(): void
|
||||
{
|
||||
$this->dispatchWithIdParam(1);
|
||||
$this->assertStringContainsString('<div id="reviewGrid"', $this->getResponse()->getBody());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testProductReviews(): void
|
||||
{
|
||||
$customerId = 1;
|
||||
$this->dispatchWithIdParam($customerId);
|
||||
$block = $this->layout->getBlock('admin.customer.reviews');
|
||||
$this->assertNotFalse($block);
|
||||
$this->assertEquals(
|
||||
$customerId,
|
||||
$block->getCustomerId(),
|
||||
'Block customer id value does not match expected value'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch request with id parameter
|
||||
*
|
||||
* @param int $id
|
||||
* @return void
|
||||
*/
|
||||
private function dispatchWithIdParam(int $id): void
|
||||
{
|
||||
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
|
||||
$this->getRequest()->setParams(['id' => $id]);
|
||||
$this->dispatch('backend/review/customer/productReviews');
|
||||
}
|
||||
}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Review\Controller\Adminhtml\Product;
|
||||
|
||||
use Magento\Review\Model\Review;
|
||||
use Magento\TestFramework\TestCase\AbstractBackendController;
|
||||
use Magento\Framework\Acl\Builder;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\Framework\UrlInterface;
|
||||
use Magento\Review\Model\ResourceModel\Review\CollectionFactory;
|
||||
|
||||
/**
|
||||
* Test Edit action.
|
||||
*
|
||||
* @magentoAppArea adminhtml
|
||||
*/
|
||||
class EditTest extends AbstractBackendController
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Framework\ObjectManagerInterface
|
||||
*/
|
||||
private $objectManager;
|
||||
|
||||
/**
|
||||
* @var Builder
|
||||
*/
|
||||
private $aclBuilder;
|
||||
|
||||
/**
|
||||
* @var UrlInterface
|
||||
*/
|
||||
private $urlBuilder;
|
||||
|
||||
/**
|
||||
* @var CollectionFactory
|
||||
*/
|
||||
private $collectionFactory;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->objectManager = Bootstrap::getObjectManager();
|
||||
$this->aclBuilder = $this->objectManager->get(Builder::class);
|
||||
$this->urlBuilder = $this->objectManager->get(UrlInterface::class);
|
||||
$this->collectionFactory = $this->objectManager->get(CollectionFactory::class);
|
||||
$this->aclBuilder->resetRuntimeAcl();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Edit action without reviews_all resource when manipulating Pending review.
|
||||
*
|
||||
* @return void
|
||||
* @magentoDataFixture Magento/Review/_files/reviews.php
|
||||
*/
|
||||
public function testAclHasAccess(): void
|
||||
{
|
||||
$collection = $this->collectionFactory->create();
|
||||
$collection->addFilter('detail.nickname', 'Nickname');
|
||||
/** @var Review $review */
|
||||
$review = $collection->getItemByColumnValue('status_id', Review::STATUS_PENDING);
|
||||
|
||||
// Exclude resource from ACL.
|
||||
$this->aclBuilder->getAcl()->deny(
|
||||
\Magento\TestFramework\Bootstrap::ADMIN_ROLE_ID,
|
||||
'Magento_Review::reviews_all'
|
||||
);
|
||||
$this->uri = 'backend/review/product/edit/id/' . $review->getId();
|
||||
|
||||
parent::testAclHasAccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Edit action without pending and reviews_all resources.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAclNoAccess(): void
|
||||
{
|
||||
// Exclude resource from ACL.
|
||||
$this->resource = ['Magento_Review::reviews_all', 'Magento_Review::pending'];
|
||||
$this->uri = 'backend/review/product/edit/id/' . 'doesn\'t matter';
|
||||
|
||||
parent::testAclNoAccess();
|
||||
}
|
||||
}
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Review\Controller\Adminhtml\Product;
|
||||
|
||||
use Magento\Review\Model\Review;
|
||||
use Magento\TestFramework\TestCase\AbstractBackendController;
|
||||
use Magento\Framework\Acl\Builder;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\Framework\UrlInterface;
|
||||
use Magento\Review\Model\ResourceModel\Review\CollectionFactory;
|
||||
use Laminas\Http\Request;
|
||||
|
||||
/**
|
||||
* Test Mass Update action.
|
||||
*
|
||||
* @magentoAppArea adminhtml
|
||||
*/
|
||||
class MassUpdateTest extends AbstractBackendController
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Framework\ObjectManagerInterface
|
||||
*/
|
||||
private $objectManager;
|
||||
|
||||
/**
|
||||
* @var Builder
|
||||
*/
|
||||
private $aclBuilder;
|
||||
|
||||
/**
|
||||
* @var UrlInterface
|
||||
*/
|
||||
private $urlBuilder;
|
||||
|
||||
/**
|
||||
* @var CollectionFactory
|
||||
*/
|
||||
private $collectionFactory;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->objectManager = Bootstrap::getObjectManager();
|
||||
$this->aclBuilder = $this->objectManager->get(Builder::class);
|
||||
$this->urlBuilder = $this->objectManager->get(UrlInterface::class);
|
||||
$this->collectionFactory = $this->objectManager->get(CollectionFactory::class);
|
||||
$this->aclBuilder->resetRuntimeAcl();
|
||||
$this->httpMethod = Request::METHOD_POST;
|
||||
$this->uri = 'backend/review/product/massUpdateStatus';
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Mass Update action without reviews_all resource when manipulating Pending reviews.
|
||||
*
|
||||
* @return void
|
||||
* @magentoDataFixture Magento/Review/_files/reviews.php
|
||||
*/
|
||||
public function testAclHasAccess(): void
|
||||
{
|
||||
$collection = $this->collectionFactory->create();
|
||||
$collection->addFilter('detail.nickname', 'Nickname');
|
||||
/** @var Review $review */
|
||||
$review = $collection->getItemByColumnValue('status_id', Review::STATUS_PENDING);
|
||||
|
||||
// Exclude resource from ACL.
|
||||
$this->aclBuilder->getAcl()->deny(
|
||||
\Magento\TestFramework\Bootstrap::ADMIN_ROLE_ID,
|
||||
'Magento_Review::reviews_all'
|
||||
);
|
||||
$this->getRequest()->setPostValue(['reviews' => $review->getId()]);
|
||||
|
||||
parent::testAclHasAccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Mass Update action without pending and reviews_all resources.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAclNoAccess(): void
|
||||
{
|
||||
// Exclude resource from ACL.
|
||||
$this->resource = ['Magento_Review::reviews_all', 'Magento_Review::pending'];
|
||||
|
||||
parent::testAclNoAccess();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user