ltsecurityinc安防产品在线商城代码
This commit is contained in:
+97
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\TestModuleOverrideConfig\MagentoDataFixture;
|
||||
|
||||
use Magento\TestModuleOverrideConfig\AbstractOverridesTest;
|
||||
use Magento\TestModuleOverrideConfig\Model\FixtureCallStorage;
|
||||
|
||||
/**
|
||||
* Class checks that magentoDataFixtures can be added using override config
|
||||
*
|
||||
* @magentoAppIsolation enabled
|
||||
*/
|
||||
class AddFixtureTest extends AbstractOverridesTest
|
||||
{
|
||||
/** @var FixtureCallStorage */
|
||||
private $fixtureCallStorage;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->fixtureCallStorage = $this->objectManager->get(FixtureCallStorage::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that fixtures added in all nodes successfully applied
|
||||
*
|
||||
* @dataProvider addedFixturesProvider
|
||||
*
|
||||
* @param array $fixtures
|
||||
* @return void
|
||||
*/
|
||||
public function testAddFixtures(array $fixtures): void
|
||||
{
|
||||
foreach ($fixtures as $scope => $fixture) {
|
||||
$this->assertEquals(
|
||||
1,
|
||||
$this->fixtureCallStorage->getFixturesCount($fixture),
|
||||
sprintf('Fixture added in %s scope was not called', $scope)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function addedFixturesProvider(): array
|
||||
{
|
||||
return [
|
||||
'first_data_set' => [
|
||||
[
|
||||
'class' => 'fixture1_second_module.php',
|
||||
'method' => 'fixture2_second_module.php',
|
||||
'data_set' => 'fixture3_second_module.php',
|
||||
],
|
||||
],
|
||||
'second_data_set' => [
|
||||
[
|
||||
'class' => 'fixture1_second_module.php',
|
||||
'method' => 'fixture2_second_module.php',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that same fixture can be added via override config from few files
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddSameFixtures(): void
|
||||
{
|
||||
$this->assertEquals(
|
||||
3,
|
||||
$this->fixtureCallStorage->getFixturesCount('fixture2_second_module.php')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that fixture which require another fixture can be added using override
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddFixtureWithRequiredFixture(): void
|
||||
{
|
||||
$this->assertEquals(1, $this->fixtureCallStorage->getFixturesCount('fixture_with_required_fixture.php'));
|
||||
$this->assertEquals(1, $this->fixtureCallStorage->getFixturesCount('fixture3_second_module.php'));
|
||||
}
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\TestModuleOverrideConfig\MagentoDataFixture;
|
||||
|
||||
use Magento\TestModuleOverrideConfig\AbstractOverridesTest;
|
||||
use Magento\TestModuleOverrideConfig\Model\FixtureCallStorage;
|
||||
|
||||
/**
|
||||
* Checks that magentoDataFixture can be removed using override config
|
||||
*
|
||||
* @magentoAppIsolation enabled
|
||||
*/
|
||||
class RemoveFixtureTest extends AbstractOverridesTest
|
||||
{
|
||||
/** @var FixtureCallStorage */
|
||||
private $fixtureCallStorage;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->fixtureCallStorage = $this->objectManager->get(FixtureCallStorage::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that fixture can be removed in test class node
|
||||
*
|
||||
* @magentoDataFixture Magento/TestModuleOverrideConfig/_files/fixture1_first_module.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testRemoveFixtureForClass(): void
|
||||
{
|
||||
$this->assertEmpty($this->fixtureCallStorage->getFixturesCount('fixture1_first_module.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that fixture can be removed in method and data set nodes
|
||||
*
|
||||
* @magentoDataFixture Magento/TestModuleOverrideConfig/_files/fixture2_first_module.php
|
||||
* @magentoDataFixture Magento/TestModuleOverrideConfig/_files/fixture3_first_module.php
|
||||
*
|
||||
* @dataProvider testDataProvider
|
||||
*
|
||||
* @param string $fixtureName
|
||||
* @return void
|
||||
*/
|
||||
public function testRemoveFixtureForMethod(string $fixtureName): void
|
||||
{
|
||||
$this->assertEmpty($this->fixtureCallStorage->getFixturesCount($fixtureName));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function testDataProvider(): array
|
||||
{
|
||||
return [
|
||||
'first_data_set' => ['fixture2_first_module.php'],
|
||||
'second_data_set' => ['fixture3_first_module.php'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that same fixtures can be removed few times
|
||||
*
|
||||
* @magentoDataFixture Magento/TestModuleOverrideConfig/_files/fixture2_first_module.php
|
||||
* @magentoDataFixture Magento/TestModuleOverrideConfig/_files/fixture2_first_module.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testRemoveSameFixtures(): void
|
||||
{
|
||||
$this->assertEmpty($this->fixtureCallStorage->getFixturesCount('fixture3_first_module.php'));
|
||||
}
|
||||
}
|
||||
+136
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\TestModuleOverrideConfig\MagentoDataFixture;
|
||||
|
||||
use Magento\TestModuleOverrideConfig\AbstractOverridesTest;
|
||||
use Magento\TestModuleOverrideConfig\Model\FixtureCallStorage;
|
||||
|
||||
/**
|
||||
* Class check that magentoDataFixtures can be replaced using override config
|
||||
*
|
||||
* @magentoAppIsolation enabled
|
||||
*/
|
||||
class ReplaceFixtureTest extends AbstractOverridesTest
|
||||
{
|
||||
/** @var FixtureCallStorage */
|
||||
private $fixtureCallStorage;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->fixtureCallStorage = $this->objectManager->get(FixtureCallStorage::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that fixture can be replaced in test class node
|
||||
*
|
||||
* @magentoDataFixture Magento/TestModuleOverrideConfig/_files/fixture1_first_module.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testReplaceFixtureForClass(): void
|
||||
{
|
||||
$this->assertEquals(0, $this->fixtureCallStorage->getFixturesCount('fixture1_first_module.php'));
|
||||
$this->assertEquals(1, $this->fixtureCallStorage->getFixturesCount('fixture1_second_module.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that fixture can be replaced in method and data set nodes
|
||||
*
|
||||
* @dataProvider replacedFixturesProvider
|
||||
*
|
||||
* @magentoDataFixture Magento/TestModuleOverrideConfig/_files/fixture1_first_module.php
|
||||
*
|
||||
* @param string $fixture
|
||||
* @return void
|
||||
*/
|
||||
public function testReplaceFixturesForMethod(string $fixture): void
|
||||
{
|
||||
$this->assertEquals(0, $this->fixtureCallStorage->getFixturesCount('fixture1_first_module.php'));
|
||||
$this->assertEquals(1, $this->fixtureCallStorage->getFixturesCount($fixture));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function replacedFixturesProvider(): array
|
||||
{
|
||||
return [
|
||||
'first_data_set' => [
|
||||
'fixture2_second_module.php',
|
||||
],
|
||||
'second_data_set' => [
|
||||
'fixture3_second_module.php',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that replace config from last loaded file will be applied
|
||||
*
|
||||
* @dataProvider dataProvider
|
||||
*
|
||||
* @magentoDataFixture Magento/TestModuleOverrideConfig/_files/fixture1_first_module.php
|
||||
*
|
||||
* @param string $fixture
|
||||
* @return void
|
||||
*/
|
||||
public function testReplaceFixtureViaThirdModule(string $fixture): void
|
||||
{
|
||||
$this->assertEquals(0, $this->fixtureCallStorage->getFixturesCount('fixture1_first_module.php'));
|
||||
$this->assertEquals(1, $this->fixtureCallStorage->getFixturesCount($fixture));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function dataProvider(): array
|
||||
{
|
||||
return [
|
||||
'first_data_set' => [
|
||||
'fixture2_second_module.php',
|
||||
],
|
||||
'second_data_set' => [
|
||||
'fixture3_second_module.php',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that fixture required in the another fixture can be replaced using override
|
||||
*
|
||||
* @magentoDataFixture Magento/TestModuleOverrideConfig2/_files/fixture_with_required_fixture.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testReplaceRequiredFixture(): void
|
||||
{
|
||||
$this->assertEquals(1, $this->fixtureCallStorage->getFixturesCount('fixture_with_required_fixture.php'));
|
||||
$this->assertEquals(1, $this->fixtureCallStorage->getFixturesCount('fixture2_second_module.php'));
|
||||
$this->assertEmpty($this->fixtureCallStorage->getFixturesCount('fixture3_second_module.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that fixture required in the another fixture will be replaced according to last loaded override
|
||||
*
|
||||
* @magentoDataFixture Magento/TestModuleOverrideConfig2/_files/fixture_with_required_fixture.php
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testReplaceRequiredFixtureViaThirdModule(): void
|
||||
{
|
||||
$this->assertEquals(1, $this->fixtureCallStorage->getFixturesCount('fixture_with_required_fixture.php'));
|
||||
$this->assertEquals(1, $this->fixtureCallStorage->getFixturesCount('fixture1_third_module.php'));
|
||||
$this->assertEmpty($this->fixtureCallStorage->getFixturesCount('fixture2_second_module.php'));
|
||||
$this->assertEmpty($this->fixtureCallStorage->getFixturesCount('fixture3_second_module.php'));
|
||||
}
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\TestModuleOverrideConfig\MagentoDataFixture;
|
||||
|
||||
use Magento\TestModuleOverrideConfig\AbstractOverridesTest;
|
||||
use Magento\TestModuleOverrideConfig\Model\FixtureCallStorage;
|
||||
|
||||
/**
|
||||
* Class checks that magentoConfigFixtures can be placed into certain place using override config
|
||||
*
|
||||
* @magentoAppIsolation enabled
|
||||
*/
|
||||
class SortFixturesTest extends AbstractOverridesTest
|
||||
{
|
||||
/** @var FixtureCallStorage */
|
||||
private $fixtureCallStorage;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
// phpstan:ignore "Class Magento\TestModuleOverrideConfig\Model\FixtureCallStorage not found."
|
||||
$this->fixtureCallStorage = $this->objectManager->get(FixtureCallStorage::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that fixtures can be placed to specific place according to config
|
||||
*
|
||||
* @dataProvider sortFixturesProvider
|
||||
*
|
||||
* @magentoDataFixture Magento/TestModuleOverrideConfig/_files/fixture1_first_module.php
|
||||
* @magentoDataFixture Magento/TestModuleOverrideConfig/_files/fixture2_first_module.php
|
||||
* @magentoDataFixture Magento/TestModuleOverrideConfig/_files/fixture3_first_module.php
|
||||
*
|
||||
* @param array $sortedFixtures
|
||||
* @return void
|
||||
*/
|
||||
public function testSortFixtures(array $sortedFixtures): void
|
||||
{
|
||||
$this->assertEquals($sortedFixtures, $this->fixtureCallStorage->getStorage());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function sortFixturesProvider(): array
|
||||
{
|
||||
return [
|
||||
'first_data_set' => [
|
||||
'sorted_fixtures' => [
|
||||
'fixture3_second_module.php',
|
||||
'fixture1_first_module.php',
|
||||
'fixture1_second_module.php',
|
||||
'fixture2_first_module.php',
|
||||
'fixture1_third_module.php',
|
||||
'fixture3_first_module.php',
|
||||
'global_fixture_first_module.php',// globally added fixture
|
||||
'fixture2_second_module.php',
|
||||
],
|
||||
],
|
||||
'second_data_set' => [
|
||||
'sorted_fixtures' => [
|
||||
'fixture1_first_module.php',
|
||||
'fixture1_second_module.php',
|
||||
'fixture2_first_module.php',
|
||||
'fixture3_first_module.php',
|
||||
'global_fixture_first_module.php',// globally added fixture
|
||||
'fixture2_second_module.php',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user