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,47 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Multishipping\Block\Checkout\Address;
use Magento\TestFramework\Helper\Bootstrap;
/**
* @magentoAppArea frontend
*/
class SelectTest extends \PHPUnit\Framework\TestCase
{
/** @var \Magento\Multishipping\Block\Checkout\Address\Select */
protected $_selectBlock;
protected function setUp(): void
{
$this->_selectBlock = Bootstrap::getObjectManager()->create(
\Magento\Multishipping\Block\Checkout\Address\Select::class
);
parent::setUp();
}
/**
* @magentoDataFixture Magento/Customer/_files/customer.php
* @magentoDataFixture Magento/Customer/_files/customer_two_addresses.php
*/
public function testGetAddressAsHtml()
{
/** @var \Magento\Customer\Api\AddressRepositoryInterface $addressRepository */
$addressRepository = Bootstrap::getObjectManager()->create(
\Magento\Customer\Api\AddressRepositoryInterface::class
);
$fixtureAddressId = 1;
$address = $addressRepository->getById($fixtureAddressId);
$addressAsHtml = $this->_selectBlock->getAddressAsHtml($address);
$this->assertEquals(
"John Smith<br />CompanyName<br />Green str, 67<br />CityM, Alabama, 75477"
. "<br />United States<br />T: <a href=\"tel:3468676\">3468676</a>",
str_replace("\n", '', $addressAsHtml),
"Address was represented as HTML incorrectly"
);
}
}
@@ -0,0 +1,72 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Multishipping\Block\Checkout;
use Magento\TestFramework\Helper\Bootstrap;
/**
* @magentoAppArea frontend
*/
class AddressesTest extends \PHPUnit\Framework\TestCase
{
const FIXTURE_CUSTOMER_ID = 1;
/**
* @var \Magento\Multishipping\Block\Checkout\Addresses
*/
protected $_addresses;
/**
* @var \Magento\Framework\ObjectManagerInterface
*/
protected $_objectManager;
protected function setUp(): void
{
$this->_objectManager = Bootstrap::getObjectManager();
/** @var \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository */
$customerRepository = Bootstrap::getObjectManager()->create(
\Magento\Customer\Api\CustomerRepositoryInterface::class
);
$customerData = $customerRepository->getById(self::FIXTURE_CUSTOMER_ID);
/** @var \Magento\Customer\Model\Session $customerSession */
$customerSession = $this->_objectManager->get(\Magento\Customer\Model\Session::class);
$customerSession->setCustomerData($customerData);
/** @var \Magento\Quote\Model\ResourceModel\Quote\Collection $quoteCollection */
$quoteCollection = $this->_objectManager->get(\Magento\Quote\Model\ResourceModel\Quote\Collection::class);
/** @var $quote \Magento\Quote\Model\Quote */
$quote = $quoteCollection->getLastItem();
/** @var $checkoutSession \Magento\Checkout\Model\Session */
$checkoutSession = $this->_objectManager->get(\Magento\Checkout\Model\Session::class);
$checkoutSession->setQuoteId($quote->getId());
$checkoutSession->setLoadInactive(true);
$this->_addresses = $this->_objectManager->create(
\Magento\Multishipping\Block\Checkout\Addresses::class
);
}
/**
* @magentoDataFixture Magento/Customer/_files/customer.php
* @magentoDataFixture Magento/Customer/_files/customer_address.php
* @magentoDataFixture Magento/Checkout/_files/quote_with_product_and_payment.php
*/
public function testGetAddressOptions()
{
$expectedResult = [
[
'value' => '1',
'label' => 'John Smith, Green str, 67, CityM, Alabama 75477, United States',
],
];
$addressAsHtml = $this->_addresses->getAddressOptions();
$this->assertEquals($expectedResult, $addressAsHtml);
}
}
@@ -0,0 +1,116 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Multishipping\Block\Checkout;
use Magento\Catalog\Model\ProductRepository;
use Magento\Checkout\Block\Cart\Item\Renderer;
use Magento\Framework\App\Area;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\View\Element\RendererList;
use Magento\Framework\View\LayoutInterface;
use Magento\Quote\Model\Quote;
use Magento\Quote\Model\Quote\Item;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\Helper\Xpath;
use PHPUnit\Framework\TestCase;
/**
* Verify default items template
*/
class OverviewTest extends TestCase
{
/**
* @var Overview
*/
private $block;
/**
* @var ObjectManagerInterface
*/
private $objectManager;
/**
* @var Quote
*/
private $quote;
/**
* @var ProductRepository
*/
private $product;
/**
* @var Item
*/
private $item;
/**
* @inheritdoc
*/
protected function setUp(): void
{
Bootstrap::getInstance()->loadArea(Area::AREA_FRONTEND);
$this->objectManager = Bootstrap::getObjectManager();
$this->block = $this->objectManager->get(LayoutInterface::class)
->createBlock(
Overview::class,
'checkout_overview',
[
'data' => [
'renderer_template' => 'Magento_Multishipping::checkout/item/default.phtml',
'row_renderer_template' => 'Magento_Multishipping::checkout/overview/item.phtml',
],
]
);
$this->block->addChild('renderer.list', RendererList::class);
$this->block->getChildBlock(
'renderer.list'
)->addChild(
'default',
Renderer::class,
['template' => 'cart/item/default.phtml']
);
$this->quote = $this->objectManager->create(Quote::class);
$this->product = $this->objectManager->create(ProductRepository::class);
$this->item = $this->objectManager->create(Item::class);
}
/**
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
*/
public function testGetRowItemHtml()
{
$product = $this->product->get('simple');
$item = $this->item->setProduct($product);
$item->setQuote($this->quote);
// assure that default renderer was obtained
$this->assertEquals(
1,
Xpath::getElementsCountForXpath(
'//*[contains(@class,"product") and contains(@class,"name")]/a',
$this->block->getRowItemHtml($item)
)
);
}
/**
* @magentoDataFixture Magento/Checkout/_files/customer_quote_with_items_simple_product_options.php
*/
public function testLinkOptionalProductFileItemHtml()
{
$quote = $this->quote->load('customer_quote_product_custom_options', 'reserved_order_id');
$item = current($quote->getAllItems());
$this->assertEquals(
1,
Xpath::getElementsCountForXpath(
'//dd/a[contains(text(), "test.jpg")]',
$this->block->getRowItemHtml($item)
)
);
}
}