ltsecurityinc安防产品在线商城代码
This commit is contained in:
+36
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Framework\Code\File\Validator;
|
||||
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
|
||||
/**
|
||||
* Class NotProtectedExtension
|
||||
*/
|
||||
class NotProtectedExtensionTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* Test that phpt, pht is invalid extension type
|
||||
* @dataProvider isValidDataProvider
|
||||
*/
|
||||
public function testIsValid($extension)
|
||||
{
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
/** @var \Magento\MediaStorage\Model\File\Validator\NotProtectedExtension $model */
|
||||
$model = $objectManager->create(\Magento\MediaStorage\Model\File\Validator\NotProtectedExtension::class);
|
||||
$this->assertFalse($model->isValid($extension));
|
||||
}
|
||||
|
||||
public function isValidDataProvider()
|
||||
{
|
||||
return [
|
||||
['phpt'],
|
||||
['pht']
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php declare(strict_types=1);
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
namespace Magento\Framework\Code\Generator;
|
||||
|
||||
use Magento\Framework\Code\Generator;
|
||||
use Magento\Framework\Logger\Monolog as MagentoMonologLogger;
|
||||
use Magento\TestFramework\ObjectManager;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\MockObject\MockObject as MockObject;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* @magentoAppIsolation enabled
|
||||
*/
|
||||
class AutoloaderTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* This method exists to fix the wrong return type hint on \Magento\Framework\App\ObjectManager::getInstance.
|
||||
* This way the IDE knows it's dealing with an instance of \Magento\TestFramework\ObjectManager and
|
||||
* not \Magento\Framework\App\ObjectManager. The former has the method addSharedInstance, the latter does not.
|
||||
*
|
||||
* @return ObjectManager|\Magento\Framework\App\ObjectManager
|
||||
* @SuppressWarnings(PHPMD.StaticAccess)
|
||||
*/
|
||||
private function getTestFrameworkObjectManager()
|
||||
{
|
||||
return ObjectManager::getInstance();
|
||||
}
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$loggerTestDouble = $this->createMock(LoggerInterface::class);
|
||||
$this->getTestFrameworkObjectManager()->addSharedInstance($loggerTestDouble, LoggerInterface::class, true);
|
||||
// magentoAppIsolation will cleanup the mess
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RuntimeException $testException
|
||||
* @return Generator|MockObject
|
||||
*/
|
||||
private function createExceptionThrowingGeneratorTestDouble(\RuntimeException $testException)
|
||||
{
|
||||
/** @var Generator|MockObject $generatorStub */
|
||||
$generatorStub = $this->createMock(Generator::class);
|
||||
$generatorStub->method('generateClass')->willThrowException($testException);
|
||||
|
||||
return $generatorStub;
|
||||
}
|
||||
|
||||
public function testLogsExceptionDuringGeneration(): void
|
||||
{
|
||||
$exceptionMessage = 'Test exception thrown during generation';
|
||||
$testException = new \RuntimeException($exceptionMessage);
|
||||
|
||||
$loggerMock = ObjectManager::getInstance()->get(LoggerInterface::class);
|
||||
$loggerMock->expects($this->once())->method('debug')->with($exceptionMessage, ['exception' => $testException]);
|
||||
|
||||
$autoloader = new Autoloader($this->createExceptionThrowingGeneratorTestDouble($testException));
|
||||
$this->assertNull($autoloader->load(NonExistingClassName::class));
|
||||
}
|
||||
|
||||
public function testFiltersDuplicateExceptionMessages(): void
|
||||
{
|
||||
$exceptionMessage = 'Test exception thrown during generation';
|
||||
$testException = new \RuntimeException($exceptionMessage);
|
||||
|
||||
$loggerMock = ObjectManager::getInstance()->get(LoggerInterface::class);
|
||||
$loggerMock->expects($this->once())->method('debug')->with($exceptionMessage, ['exception' => $testException]);
|
||||
|
||||
$autoloader = new Autoloader($this->createExceptionThrowingGeneratorTestDouble($testException));
|
||||
$autoloader->load(OneNonExistingClassName::class);
|
||||
$autoloader->load(AnotherNonExistingClassName::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,220 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Framework\Code;
|
||||
|
||||
use Magento\Framework\Api\Code\Generator\ExtensionAttributesInterfaceFactoryGenerator;
|
||||
use Magento\Framework\App\Filesystem\DirectoryList;
|
||||
use Magento\Framework\Filesystem;
|
||||
use Magento\Framework\Interception\Code\Generator as InterceptionGenerator;
|
||||
use Magento\Framework\ObjectManager\Code\Generator as DIGenerator;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
require_once __DIR__ . '/GeneratorTest/SourceClassWithNamespace.php';
|
||||
require_once __DIR__ . '/GeneratorTest/ParentClassWithNamespace.php';
|
||||
require_once __DIR__ . '/GeneratorTest/SourceClassWithNamespaceExtension.php';
|
||||
require_once __DIR__ . '/GeneratorTest/NestedNamespace/SourceClassWithNestedNamespace.php';
|
||||
require_once __DIR__ . '/GeneratorTest/NestedNamespace/SourceClassWithNestedNamespaceExtension.php';
|
||||
|
||||
/**
|
||||
* @magentoAppIsolation enabled
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
||||
*/
|
||||
class GeneratorTest extends TestCase
|
||||
{
|
||||
const CLASS_NAME_WITH_NAMESPACE = GeneratorTest\SourceClassWithNamespace::class;
|
||||
const CLASS_NAME_WITH_NESTED_NAMESPACE = GeneratorTest\NestedNamespace\SourceClassWithNestedNamespace::class;
|
||||
const EXTENSION_CLASS_NAME_WITH_NAMESPACE = GeneratorTest\SourceClassWithNamespaceExtension::class;
|
||||
const EXTENSION_CLASS_NAME_WITH_NESTED_NAMESPACE =
|
||||
GeneratorTest\NestedNamespace\SourceClassWithNestedNamespaceExtension::class;
|
||||
|
||||
/**
|
||||
* @var Generator
|
||||
*/
|
||||
protected $_generator;
|
||||
|
||||
/**
|
||||
* @var Generator/Io
|
||||
*/
|
||||
protected $_ioObject;
|
||||
|
||||
/**
|
||||
* @var Filesystem\Directory\Write
|
||||
*/
|
||||
private $generatedDirectory;
|
||||
|
||||
/**
|
||||
* @var Filesystem\Directory\Read
|
||||
*/
|
||||
private $logDirectory;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $testRelativePath = './Magento/Framework/Code/GeneratorTest/';
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
/** @var Filesystem $filesystem */
|
||||
$filesystem = $objectManager->get(Filesystem::class);
|
||||
$this->generatedDirectory = $filesystem->getDirectoryWrite(DirectoryList::GENERATED_CODE);
|
||||
$this->generatedDirectory->create($this->testRelativePath);
|
||||
$this->logDirectory = $filesystem->getDirectoryRead(DirectoryList::LOG);
|
||||
$generatedDirectoryAbsolutePath = $this->generatedDirectory->getAbsolutePath();
|
||||
$this->_ioObject = new Generator\Io(new Filesystem\Driver\File(), $generatedDirectoryAbsolutePath);
|
||||
$this->_generator = $objectManager->create(
|
||||
Generator::class,
|
||||
[
|
||||
'ioObject' => $this->_ioObject,
|
||||
'generatedEntities' => [
|
||||
ExtensionAttributesInterfaceFactoryGenerator::ENTITY_TYPE =>
|
||||
ExtensionAttributesInterfaceFactoryGenerator::class,
|
||||
DIGenerator\Factory::ENTITY_TYPE => DIGenerator\Factory::class,
|
||||
DIGenerator\Proxy::ENTITY_TYPE => DIGenerator\Proxy::class,
|
||||
InterceptionGenerator\Interceptor::ENTITY_TYPE => InterceptionGenerator\Interceptor::class,
|
||||
]
|
||||
]
|
||||
);
|
||||
$this->_generator->setObjectManager($objectManager);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->_generator = null;
|
||||
if ($this->generatedDirectory->isExist($this->testRelativePath)) {
|
||||
if (!$this->generatedDirectory->isWritable($this->testRelativePath)) {
|
||||
$this->generatedDirectory->changePermissionsRecursively($this->testRelativePath, 0775, 0664);
|
||||
}
|
||||
$this->generatedDirectory->delete($this->testRelativePath);
|
||||
}
|
||||
}
|
||||
|
||||
protected function _clearDocBlock($classBody)
|
||||
{
|
||||
return preg_replace('/(\/\*[\w\W]*)\nclass/', 'class', $classBody);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a new class Factory file and compares with the sample.
|
||||
*
|
||||
* @param $className
|
||||
* @param $generateType
|
||||
* @param $expectedDataPath
|
||||
* @dataProvider generateClassFactoryDataProvider
|
||||
*/
|
||||
public function testGenerateClassFactory($className, $generateType, $expectedDataPath)
|
||||
{
|
||||
$factoryClassName = $className . $generateType;
|
||||
$this->assertEquals(Generator::GENERATION_SUCCESS, $this->_generator->generateClass($factoryClassName));
|
||||
$factory = Bootstrap::getObjectManager()->create($factoryClassName);
|
||||
$this->assertInstanceOf($className, $factory->create());
|
||||
$content = $this->_clearDocBlock(
|
||||
file_get_contents($this->_ioObject->generateResultFileName($factoryClassName))
|
||||
);
|
||||
$expectedContent = $this->_clearDocBlock(
|
||||
file_get_contents(__DIR__ . $expectedDataPath)
|
||||
);
|
||||
$this->assertEquals($expectedContent, $content);
|
||||
}
|
||||
|
||||
/**
|
||||
* DataProvider for testGenerateClassFactory
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function generateClassFactoryDataProvider()
|
||||
{
|
||||
return [
|
||||
'factory_with_namespace' => [
|
||||
'className' => self::CLASS_NAME_WITH_NAMESPACE,
|
||||
'generateType' => 'Factory',
|
||||
'expectedDataPath' => '/_expected/SourceClassWithNamespaceFactory.php.sample'
|
||||
],
|
||||
'factory_with_nested_namespace' => [
|
||||
'classToGenerate' => self::CLASS_NAME_WITH_NESTED_NAMESPACE,
|
||||
'generateType' => 'Factory',
|
||||
'expectedDataPath' => '/_expected/SourceClassWithNestedNamespaceFactory.php.sample'
|
||||
],
|
||||
'ext_interface_factory_with_namespace' => [
|
||||
'classToGenerate' => self::EXTENSION_CLASS_NAME_WITH_NAMESPACE,
|
||||
'generateType' => 'InterfaceFactory',
|
||||
'expectedDataPath' => '/_expected/SourceClassWithNamespaceExtensionInterfaceFactory.php.sample'
|
||||
],
|
||||
'ext_interface_factory_with_nested_namespace' => [
|
||||
'classToGenerate' => self::EXTENSION_CLASS_NAME_WITH_NESTED_NAMESPACE,
|
||||
'generateType' => 'InterfaceFactory',
|
||||
'expectedDataPath' => '/_expected/SourceClassWithNestedNamespaceExtensionInterfaceFactory.php.sample'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $className
|
||||
* @param $generateType
|
||||
* @param $expectedDataPath
|
||||
* @dataProvider generateClassDataProvider
|
||||
*/
|
||||
public function testGenerateClass($className, $generateType, $expectedDataPath)
|
||||
{
|
||||
$generateClassName = $className . $generateType;
|
||||
$this->assertEquals(Generator::GENERATION_SUCCESS, $this->_generator->generateClass($generateClassName));
|
||||
$instance = Bootstrap::getObjectManager()->create($generateClassName);
|
||||
$this->assertInstanceOf($className, $instance);
|
||||
$content = $this->_clearDocBlock(
|
||||
file_get_contents($this->_ioObject->generateResultFileName($generateClassName))
|
||||
);
|
||||
$expectedContent = $this->_clearDocBlock(
|
||||
file_get_contents(__DIR__ . $expectedDataPath)
|
||||
);
|
||||
$this->assertEquals($expectedContent, $content);
|
||||
}
|
||||
|
||||
/**
|
||||
* DataProvider for testGenerateClass
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function generateClassDataProvider()
|
||||
{
|
||||
return [
|
||||
'proxy' => [
|
||||
'className' => self::CLASS_NAME_WITH_NAMESPACE,
|
||||
'generateType' => '\Proxy',
|
||||
'expectedDataPath' => '/_expected/SourceClassWithNamespaceProxy.php.sample'
|
||||
],
|
||||
'interceptor' => [
|
||||
'className' => self::CLASS_NAME_WITH_NAMESPACE,
|
||||
'generateType' => '\Interceptor',
|
||||
'expectedDataPath' => '/_expected/SourceClassWithNamespaceInterceptor.php.sample'
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* It tries to generate a new class file when the generated directory is read-only
|
||||
*/
|
||||
public function testGeneratorClassWithErrorSaveClassFile()
|
||||
{
|
||||
$factoryClassName = self::CLASS_NAME_WITH_NAMESPACE . 'Factory';
|
||||
$msgPart = 'Class ' . $factoryClassName . ' generation error: The requested class did not generate properly, '
|
||||
. 'because the \'generated\' directory permission is read-only.';
|
||||
$regexpMsgPart = preg_quote($msgPart);
|
||||
$this->expectException(\RuntimeException::class);
|
||||
$this->expectExceptionMessageMatches("/.*$regexpMsgPart.*/");
|
||||
$this->generatedDirectory->changePermissionsRecursively($this->testRelativePath, 0555, 0444);
|
||||
$generatorResult = $this->_generator->generateClass($factoryClassName);
|
||||
$this->assertFalse($generatorResult);
|
||||
$pathToSystemLog = $this->logDirectory->getAbsolutePath('system.log');
|
||||
$this->assertContains($msgPart, file_get_contents($pathToSystemLog));
|
||||
}
|
||||
}
|
||||
+170
@@ -0,0 +1,170 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Framework\Code\GeneratorTest\NestedNamespace;
|
||||
|
||||
use Laminas\Code\Generator\ClassGenerator;
|
||||
|
||||
/**
|
||||
* phpcs:ignoreFile
|
||||
*/
|
||||
class SourceClassWithNestedNamespace extends \Magento\Framework\Code\GeneratorTest\ParentClassWithNamespace
|
||||
{
|
||||
/**
|
||||
* Public child constructor
|
||||
*
|
||||
* @param string $param1
|
||||
* @param string $param2
|
||||
* @param string $param3
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function __construct($param1 = '', $param2 = '\\', $param3 = '\'')
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Public child method
|
||||
*
|
||||
* @param \Laminas\Code\Generator\ClassGenerator $classGenerator
|
||||
* @param string $param1
|
||||
* @param string $param2
|
||||
* @param string $param3
|
||||
* @param array $array
|
||||
* @return void
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function publicChildMethod(
|
||||
ClassGenerator $classGenerator,
|
||||
$param1 = '',
|
||||
$param2 = '\\',
|
||||
$param3 = '\'',
|
||||
array $array = []
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Public child method with reference
|
||||
*
|
||||
* @param \Laminas\Code\Generator\ClassGenerator $classGenerator
|
||||
* @param string $param1
|
||||
* @param array $array
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function publicMethodWithReference(ClassGenerator &$classGenerator, &$param1, array &$array)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Protected child method
|
||||
*
|
||||
* @param \Laminas\Code\Generator\ClassGenerator $classGenerator
|
||||
* @param string $param1
|
||||
* @param string $param2
|
||||
* @param string $param3
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
protected function _protectedChildMethod(
|
||||
ClassGenerator $classGenerator,
|
||||
$param1 = '',
|
||||
$param2 = '\\',
|
||||
$param3 = '\''
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Private child method
|
||||
*
|
||||
* @param \Laminas\Code\Generator\ClassGenerator $classGenerator
|
||||
* @param string $param1
|
||||
* @param string $param2
|
||||
* @param string $param3
|
||||
* @param array $array
|
||||
* @return void
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedPrivateMethod)
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
private function _privateChildMethod(
|
||||
ClassGenerator $classGenerator,
|
||||
$param1 = '',
|
||||
$param2 = '\\',
|
||||
$param3 = '\'',
|
||||
array $array = []
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method
|
||||
*/
|
||||
public function publicChildWithoutParameters()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method
|
||||
*/
|
||||
public static function publicChildStatic()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method
|
||||
*/
|
||||
final public function publicChildFinal()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method
|
||||
*
|
||||
* @param mixed $arg1
|
||||
* @param string $arg2
|
||||
* @param int|null $arg3
|
||||
* @param int|null $arg4
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function public71(
|
||||
$arg1,
|
||||
string $arg2,
|
||||
?int $arg3,
|
||||
?int $arg4 = null
|
||||
): void {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method
|
||||
*
|
||||
* @param \DateTime|null $arg1
|
||||
* @param mixed $arg2
|
||||
*
|
||||
* @return null|string
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function public71Another(?\DateTime $arg1, $arg2 = false): ?string
|
||||
{
|
||||
// phpstan:ignore
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method
|
||||
*
|
||||
* @param bool $arg
|
||||
* @return SourceClassWithNamespace
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function publicWithSelf($arg = false): self
|
||||
{
|
||||
// phpstan:ignore
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
namespace Magento\Framework\Code\GeneratorTest\NestedNamespace;
|
||||
|
||||
/**
|
||||
* Source class for ExtensionInterfaceFactory generator.
|
||||
*/
|
||||
class SourceClassWithNestedNamespaceExtension extends \Magento\Framework\Code\GeneratorTest\ParentClassWithNamespace
|
||||
{
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Framework\Code\GeneratorTest;
|
||||
|
||||
use Laminas\Code\Generator\DocBlockGenerator;
|
||||
|
||||
/**
|
||||
* phpcs:ignoreFile
|
||||
*/
|
||||
class ParentClassWithNamespace
|
||||
{
|
||||
/**
|
||||
* Public parent method
|
||||
*
|
||||
* @param \Laminas\Code\Generator\DocBlockGenerator $docBlockGenerator
|
||||
* @param string $param1
|
||||
* @param string $param2
|
||||
* @param string $param3
|
||||
* @param array $array
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function publicParentMethod(
|
||||
DocBlockGenerator $docBlockGenerator,
|
||||
$param1 = '',
|
||||
$param2 = '\\',
|
||||
$param3 = '\'',
|
||||
array $array = []
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Protected parent method
|
||||
*
|
||||
* @param \Laminas\Code\Generator\DocBlockGenerator $docBlockGenerator
|
||||
* @param string $param1
|
||||
* @param string $param2
|
||||
* @param string $param3
|
||||
* @param array $array
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
protected function _protectedParentMethod(
|
||||
DocBlockGenerator $docBlockGenerator,
|
||||
$param1 = '',
|
||||
$param2 = '\\',
|
||||
$param3 = '\'',
|
||||
array $array = []
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Private parent method
|
||||
*
|
||||
* @param \Laminas\Code\Generator\DocBlockGenerator $docBlockGenerator
|
||||
* @param string $param1
|
||||
* @param string $param2
|
||||
* @param string $param3
|
||||
* @param array $array
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedPrivateMethod)
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
private function _privateParentMethod(
|
||||
DocBlockGenerator $docBlockGenerator,
|
||||
$param1 = '',
|
||||
$param2 = '\\',
|
||||
$param3 = '\'',
|
||||
array $array = []
|
||||
) {
|
||||
}
|
||||
|
||||
public function publicParentWithoutParameters()
|
||||
{
|
||||
}
|
||||
|
||||
public static function publicParentStatic()
|
||||
{
|
||||
}
|
||||
|
||||
final public function publicParentFinal()
|
||||
{
|
||||
}
|
||||
}
|
||||
+170
@@ -0,0 +1,170 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Framework\Code\GeneratorTest;
|
||||
|
||||
use Laminas\Code\Generator\ClassGenerator;
|
||||
|
||||
/**
|
||||
* phpcs:ignoreFile
|
||||
*/
|
||||
class SourceClassWithNamespace extends ParentClassWithNamespace
|
||||
{
|
||||
/**
|
||||
* Public child constructor
|
||||
*
|
||||
* @param string $param1
|
||||
* @param string $param2
|
||||
* @param string $param3
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function __construct($param1 = '', $param2 = '\\', $param3 = '\'')
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Public child method
|
||||
*
|
||||
* @param \Laminas\Code\Generator\ClassGenerator $classGenerator
|
||||
* @param string $param1
|
||||
* @param string $param2
|
||||
* @param string $param3
|
||||
* @param array $array
|
||||
* @return void
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function publicChildMethod(
|
||||
ClassGenerator $classGenerator,
|
||||
$param1 = '',
|
||||
$param2 = '\\',
|
||||
$param3 = '\'',
|
||||
array $array = []
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Public child method with reference
|
||||
*
|
||||
* @param \Laminas\Code\Generator\ClassGenerator $classGenerator
|
||||
* @param string $param1
|
||||
* @param array $array
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function publicMethodWithReference(ClassGenerator &$classGenerator, &$param1, array &$array)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Protected child method
|
||||
*
|
||||
* @param \Laminas\Code\Generator\ClassGenerator $classGenerator
|
||||
* @param string $param1
|
||||
* @param string $param2
|
||||
* @param string $param3
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
protected function _protectedChildMethod(
|
||||
ClassGenerator $classGenerator,
|
||||
$param1 = '',
|
||||
$param2 = '\\',
|
||||
$param3 = '\''
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Private child method
|
||||
*
|
||||
* @param \Laminas\Code\Generator\ClassGenerator $classGenerator
|
||||
* @param string $param1
|
||||
* @param string $param2
|
||||
* @param string $param3
|
||||
* @param array $array
|
||||
* @return void
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedPrivateMethod)
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
private function _privateChildMethod(
|
||||
ClassGenerator $classGenerator,
|
||||
$param1 = '',
|
||||
$param2 = '\\',
|
||||
$param3 = '\'',
|
||||
array $array = []
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method
|
||||
*/
|
||||
public function publicChildWithoutParameters()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method
|
||||
*/
|
||||
public static function publicChildStatic()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method
|
||||
*/
|
||||
final public function publicChildFinal()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method
|
||||
*
|
||||
* @param mixed $arg1
|
||||
* @param string $arg2
|
||||
* @param int|null $arg3
|
||||
* @param int|null $arg4
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function public71(
|
||||
$arg1,
|
||||
string $arg2,
|
||||
?int $arg3,
|
||||
?int $arg4 = null
|
||||
): void {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method
|
||||
*
|
||||
* @param \DateTime|null $arg1
|
||||
* @param mixed $arg2
|
||||
*
|
||||
* @return null|string
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function public71Another(?\DateTime $arg1, $arg2 = false): ?string
|
||||
{
|
||||
// phpstan:ignore
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method
|
||||
*
|
||||
* @param bool $arg
|
||||
* @return SourceClassWithNamespace
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||
*/
|
||||
public function publicWithSelf($arg = false): self
|
||||
{
|
||||
// phpstan:ignore
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
namespace Magento\Framework\Code\GeneratorTest;
|
||||
|
||||
/**
|
||||
* Source class for ExtensionInterfaceFactory generator.
|
||||
*/
|
||||
class SourceClassWithNamespaceExtension extends ParentClassWithNamespace
|
||||
{
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Framework\Code\Reader;
|
||||
|
||||
require_once __DIR__ . '/_files/SourceArgumentsReaderTest.php.sample';
|
||||
|
||||
class SourceArgumentsReaderTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Framework\Code\Reader\SourceArgumentsReader
|
||||
*/
|
||||
protected $sourceArgumentsReader;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->sourceArgumentsReader = new \Magento\Framework\Code\Reader\SourceArgumentsReader();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
* @param array $expectedResult
|
||||
* @dataProvider getConstructorArgumentTypesDataProvider
|
||||
*/
|
||||
public function testGetConstructorArgumentTypes($class, $expectedResult)
|
||||
{
|
||||
$class = new \ReflectionClass($class);
|
||||
$actualResult = $this->sourceArgumentsReader->getConstructorArgumentTypes($class);
|
||||
$this->assertEquals($expectedResult, $actualResult);
|
||||
}
|
||||
|
||||
public function getConstructorArgumentTypesDataProvider()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'Some\Testing\Name\Space\AnotherSimpleClass',
|
||||
[
|
||||
'\Some\Testing\Name\Space\Item',
|
||||
'\Imported\Name\Space\One',
|
||||
'\Imported\Name\Space\AnotherTest\Extended',
|
||||
'\Imported\Name\Space\Test',
|
||||
'\Imported\Name\Space\ClassName\Under\Test',
|
||||
'\Imported\Name\Space\ClassName',
|
||||
'\Some\Testing\Name\Space\Test',
|
||||
'\Exception',
|
||||
'',
|
||||
'\Imported\Name\Space\ClassName',
|
||||
'array',
|
||||
''
|
||||
],
|
||||
],
|
||||
[
|
||||
'\stdClass',
|
||||
[null]
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Some\Testing\Name\Space;
|
||||
|
||||
use Imported\Name\Space\One as FirstImport;
|
||||
use Imported\Name\Space\ClassName;
|
||||
use Imported\Name\Space\Test as Testing, \Imported\Name\Space\AnotherTest ;
|
||||
|
||||
class AnotherSimpleClass
|
||||
{
|
||||
public function __construct(
|
||||
\Some\Testing\Name\Space\Item $itemOne,
|
||||
FirstImport $itemTwo,
|
||||
AnotherTest\Extended $itemThree,
|
||||
Testing $itemFour,
|
||||
ClassName\Under\Test $itemFive,
|
||||
ClassName $itemSix,
|
||||
Test $itemSeven,
|
||||
?\Exception $optionalException,
|
||||
$defaultString = '$default),value;',
|
||||
?ClassName $optionalWithDefaultValue = null,
|
||||
array $itemEight = [],
|
||||
$itemNine = 'test'
|
||||
) {
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
namespace Magento\Framework\Code\GeneratorTest;
|
||||
|
||||
/**
|
||||
* Factory class for @see \Magento\Framework\Code\GeneratorTest\SourceClassWithNamespaceExtension
|
||||
*
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
class SourceClassWithNamespaceExtensionInterfaceFactory
|
||||
{
|
||||
/**
|
||||
* Object Manager instance
|
||||
*
|
||||
* @var \Magento\Framework\ObjectManagerInterface
|
||||
*/
|
||||
protected $_objectManager = null;
|
||||
|
||||
/**
|
||||
* Instance name to create
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_instanceName = null;
|
||||
|
||||
/**
|
||||
* ExtensionInterfaceFactory constructor
|
||||
*
|
||||
* @param \Magento\Framework\ObjectManagerInterface $objectManager
|
||||
* @param string $instanceName
|
||||
*/
|
||||
public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager, $instanceName = '\\Magento\\Framework\\Code\\GeneratorTest\\SourceClassWithNamespaceExtension')
|
||||
{
|
||||
$this->_objectManager = $objectManager;
|
||||
$this->_instanceName = $instanceName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create class instance with specified parameters
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Magento\Framework\Code\GeneratorTest\SourceClassWithNamespaceExtension
|
||||
*/
|
||||
public function create(array $data = [])
|
||||
{
|
||||
return $this->_objectManager->create($this->_instanceName, $data);
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
namespace Magento\Framework\Code\GeneratorTest;
|
||||
|
||||
/**
|
||||
* Factory class for @see \Magento\Framework\Code\GeneratorTest\SourceClassWithNamespace
|
||||
*
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
class SourceClassWithNamespaceFactory
|
||||
{
|
||||
/**
|
||||
* Object Manager instance
|
||||
*
|
||||
* @var \Magento\Framework\ObjectManagerInterface
|
||||
*/
|
||||
protected $_objectManager = null;
|
||||
|
||||
/**
|
||||
* Instance name to create
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_instanceName = null;
|
||||
|
||||
/**
|
||||
* Factory constructor
|
||||
*
|
||||
* @param \Magento\Framework\ObjectManagerInterface $objectManager
|
||||
* @param string $instanceName
|
||||
*/
|
||||
public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager, $instanceName = '\\Magento\\Framework\\Code\\GeneratorTest\\SourceClassWithNamespace')
|
||||
{
|
||||
$this->_objectManager = $objectManager;
|
||||
$this->_instanceName = $instanceName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create class instance with specified parameters
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Magento\Framework\Code\GeneratorTest\SourceClassWithNamespace
|
||||
*/
|
||||
public function create(array $data = [])
|
||||
{
|
||||
return $this->_objectManager->create($this->_instanceName, $data);
|
||||
}
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
namespace Magento\Framework\Code\GeneratorTest\SourceClassWithNamespace;
|
||||
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
class Interceptor extends \Magento\Framework\Code\GeneratorTest\SourceClassWithNamespace implements \Magento\Framework\Interception\InterceptorInterface
|
||||
{
|
||||
use \Magento\Framework\Interception\Interceptor;
|
||||
|
||||
public function __construct($param1 = '', $param2 = '\\', $param3 = '\'')
|
||||
{
|
||||
$this->___init();
|
||||
parent::__construct($param1, $param2, $param3);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function publicChildMethod(\Laminas\Code\Generator\ClassGenerator $classGenerator, $param1 = '', $param2 = '\\', $param3 = '\'', array $array = [])
|
||||
{
|
||||
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'publicChildMethod');
|
||||
return $pluginInfo ? $this->___callPlugins('publicChildMethod', func_get_args(), $pluginInfo) : parent::publicChildMethod($classGenerator, $param1, $param2, $param3, $array);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function publicMethodWithReference(\Laminas\Code\Generator\ClassGenerator &$classGenerator, &$param1, array &$array)
|
||||
{
|
||||
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'publicMethodWithReference');
|
||||
return $pluginInfo ? $this->___callPlugins('publicMethodWithReference', func_get_args(), $pluginInfo) : parent::publicMethodWithReference($classGenerator, $param1, $array);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function publicChildWithoutParameters()
|
||||
{
|
||||
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'publicChildWithoutParameters');
|
||||
return $pluginInfo ? $this->___callPlugins('publicChildWithoutParameters', func_get_args(), $pluginInfo) : parent::publicChildWithoutParameters();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function public71($arg1, string $arg2, ?int $arg3, ?int $arg4 = null) : void
|
||||
{
|
||||
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'public71');
|
||||
$pluginInfo ? $this->___callPlugins('public71', func_get_args(), $pluginInfo) : parent::public71($arg1, $arg2, $arg3, $arg4);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function public71Another(?\DateTime $arg1, $arg2 = false) : ?string
|
||||
{
|
||||
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'public71Another');
|
||||
return $pluginInfo ? $this->___callPlugins('public71Another', func_get_args(), $pluginInfo) : parent::public71Another($arg1, $arg2);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function publicWithSelf($arg = false) : \Magento\Framework\Code\GeneratorTest\SourceClassWithNamespace
|
||||
{
|
||||
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'publicWithSelf');
|
||||
return $pluginInfo ? $this->___callPlugins('publicWithSelf', func_get_args(), $pluginInfo) : parent::publicWithSelf($arg);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function publicParentMethod(\Laminas\Code\Generator\DocBlockGenerator $docBlockGenerator, $param1 = '', $param2 = '\\', $param3 = '\'', array $array = [])
|
||||
{
|
||||
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'publicParentMethod');
|
||||
return $pluginInfo ? $this->___callPlugins('publicParentMethod', func_get_args(), $pluginInfo) : parent::publicParentMethod($docBlockGenerator, $param1, $param2, $param3, $array);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function publicParentWithoutParameters()
|
||||
{
|
||||
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'publicParentWithoutParameters');
|
||||
return $pluginInfo ? $this->___callPlugins('publicParentWithoutParameters', func_get_args(), $pluginInfo) : parent::publicParentWithoutParameters();
|
||||
}
|
||||
}
|
||||
+156
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
namespace Magento\Framework\Code\GeneratorTest\SourceClassWithNamespace;
|
||||
|
||||
/**
|
||||
* Proxy class for @see \Magento\Framework\Code\GeneratorTest\SourceClassWithNamespace
|
||||
*
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
class Proxy extends \Magento\Framework\Code\GeneratorTest\SourceClassWithNamespace implements \Magento\Framework\ObjectManager\NoninterceptableInterface
|
||||
{
|
||||
/**
|
||||
* Object Manager instance
|
||||
*
|
||||
* @var \Magento\Framework\ObjectManagerInterface
|
||||
*/
|
||||
protected $_objectManager = null;
|
||||
|
||||
/**
|
||||
* Proxied instance name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_instanceName = null;
|
||||
|
||||
/**
|
||||
* Proxied instance
|
||||
*
|
||||
* @var \Magento\Framework\Code\GeneratorTest\SourceClassWithNamespace
|
||||
*/
|
||||
protected $_subject = null;
|
||||
|
||||
/**
|
||||
* Instance shareability flag
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $_isShared = null;
|
||||
|
||||
/**
|
||||
* Proxy constructor
|
||||
*
|
||||
* @param \Magento\Framework\ObjectManagerInterface $objectManager
|
||||
* @param string $instanceName
|
||||
* @param bool $shared
|
||||
*/
|
||||
public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager, $instanceName = '\\Magento\\Framework\\Code\\GeneratorTest\\SourceClassWithNamespace', $shared = true)
|
||||
{
|
||||
$this->_objectManager = $objectManager;
|
||||
$this->_instanceName = $instanceName;
|
||||
$this->_isShared = $shared;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function __sleep()
|
||||
{
|
||||
return ['_subject', '_isShared', '_instanceName'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve ObjectManager from global scope
|
||||
*/
|
||||
public function __wakeup()
|
||||
{
|
||||
$this->_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone proxied instance
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
$this->_subject = clone $this->_getSubject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get proxied instance
|
||||
*
|
||||
* @return \Magento\Framework\Code\GeneratorTest\SourceClassWithNamespace
|
||||
*/
|
||||
protected function _getSubject()
|
||||
{
|
||||
if (!$this->_subject) {
|
||||
$this->_subject = true === $this->_isShared
|
||||
? $this->_objectManager->get($this->_instanceName)
|
||||
: $this->_objectManager->create($this->_instanceName);
|
||||
}
|
||||
return $this->_subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function publicChildMethod(\Laminas\Code\Generator\ClassGenerator $classGenerator, $param1 = '', $param2 = '\\', $param3 = '\'', array $array = [])
|
||||
{
|
||||
return $this->_getSubject()->publicChildMethod($classGenerator, $param1, $param2, $param3, $array);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function publicMethodWithReference(\Laminas\Code\Generator\ClassGenerator &$classGenerator, &$param1, array &$array)
|
||||
{
|
||||
return $this->_getSubject()->publicMethodWithReference($classGenerator, $param1, $array);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function publicChildWithoutParameters()
|
||||
{
|
||||
return $this->_getSubject()->publicChildWithoutParameters();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function public71($arg1, string $arg2, ?int $arg3, ?int $arg4 = null) : void
|
||||
{
|
||||
$this->_getSubject()->public71($arg1, $arg2, $arg3, $arg4);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function public71Another(?\DateTime $arg1, $arg2 = false) : ?string
|
||||
{
|
||||
return $this->_getSubject()->public71Another($arg1, $arg2);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function publicWithSelf($arg = false) : \Magento\Framework\Code\GeneratorTest\SourceClassWithNamespace
|
||||
{
|
||||
return $this->_getSubject()->publicWithSelf($arg);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function publicParentMethod(\Laminas\Code\Generator\DocBlockGenerator $docBlockGenerator, $param1 = '', $param2 = '\\', $param3 = '\'', array $array = [])
|
||||
{
|
||||
return $this->_getSubject()->publicParentMethod($docBlockGenerator, $param1, $param2, $param3, $array);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function publicParentWithoutParameters()
|
||||
{
|
||||
return $this->_getSubject()->publicParentWithoutParameters();
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
namespace Magento\Framework\Code\GeneratorTest\NestedNamespace;
|
||||
|
||||
/**
|
||||
* Factory class for @see \Magento\Framework\Code\GeneratorTest\SourceClassWithNamespaceExtension
|
||||
*
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
class SourceClassWithNestedNamespaceExtensionInterfaceFactory
|
||||
{
|
||||
/**
|
||||
* Object Manager instance
|
||||
*
|
||||
* @var \Magento\Framework\ObjectManagerInterface
|
||||
*/
|
||||
protected $_objectManager = null;
|
||||
|
||||
/**
|
||||
* Instance name to create
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_instanceName = null;
|
||||
|
||||
/**
|
||||
* ExtensionInterfaceFactory constructor
|
||||
*
|
||||
* @param \Magento\Framework\ObjectManagerInterface $objectManager
|
||||
* @param string $instanceName
|
||||
*/
|
||||
public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager, $instanceName = '\\Magento\\Framework\\Code\\GeneratorTest\\NestedNamespace\\SourceClassWithNestedNamespaceExtension')
|
||||
{
|
||||
$this->_objectManager = $objectManager;
|
||||
$this->_instanceName = $instanceName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create class instance with specified parameters
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Magento\Framework\Code\GeneratorTest\NestedNamespace\SourceClassWithNestedNamespaceExtension
|
||||
*/
|
||||
public function create(array $data = [])
|
||||
{
|
||||
return $this->_objectManager->create($this->_instanceName, $data);
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
namespace Magento\Framework\Code\GeneratorTest\NestedNamespace;
|
||||
|
||||
/**
|
||||
* Factory class for @see \Magento\Framework\Code\GeneratorTest\SourceClassWithNamespace
|
||||
*
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
class SourceClassWithNestedNamespaceFactory
|
||||
{
|
||||
/**
|
||||
* Object Manager instance
|
||||
*
|
||||
* @var \Magento\Framework\ObjectManagerInterface
|
||||
*/
|
||||
protected $_objectManager = null;
|
||||
|
||||
/**
|
||||
* Instance name to create
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_instanceName = null;
|
||||
|
||||
/**
|
||||
* Factory constructor
|
||||
*
|
||||
* @param \Magento\Framework\ObjectManagerInterface $objectManager
|
||||
* @param string $instanceName
|
||||
*/
|
||||
public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager, $instanceName = '\\Magento\\Framework\\Code\\GeneratorTest\\NestedNamespace\\SourceClassWithNestedNamespace')
|
||||
{
|
||||
$this->_objectManager = $objectManager;
|
||||
$this->_instanceName = $instanceName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create class instance with specified parameters
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Magento\Framework\Code\GeneratorTest\NestedNamespace\SourceClassWithNestedNamespace
|
||||
*/
|
||||
public function create(array $data = [])
|
||||
{
|
||||
return $this->_objectManager->create($this->_instanceName, $data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*
|
||||
* Exists for testing FileResolver.
|
||||
*
|
||||
* \Magento\Framework\Code\Generator\FileResolverTest
|
||||
*/
|
||||
Reference in New Issue
Block a user