![]() 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/Filesystem/Test/Unit/File/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\Framework\Filesystem\Test\Unit\File; use Magento\Framework\Filesystem\DriverInterface; use Magento\Framework\Filesystem\DriverPool; use Magento\Framework\Filesystem\File\Write; use Magento\Framework\Filesystem\File\WriteFactory; use PHPUnit\Framework\TestCase; class WriteFactoryTest extends TestCase { public function testCreate() { $driverPool = $this->createPartialMock(DriverPool::class, ['getDriver']); $driverPool->expects($this->never())->method('getDriver'); $factory = new WriteFactory($driverPool); $driver = $this->getMockForAbstractClass(DriverInterface::class); $driver->expects($this->any())->method('isExists')->willReturn(true); $result = $factory->create('path', $driver); $this->assertInstanceOf(Write::class, $result); } public function testCreateWithDriverCode() { $driverPool = $this->createPartialMock(DriverPool::class, ['getDriver']); $driverMock = $this->getMockForAbstractClass(DriverInterface::class); $driverMock->expects($this->any())->method('isExists')->willReturn(true); $driverPool->expects($this->once())->method('getDriver')->willReturn($driverMock); $factory = new WriteFactory($driverPool); $result = $factory->create('path', 'driverCode'); $this->assertInstanceOf(Write::class, $result); } public function testCreateWithMode() { $driverPool = $this->createPartialMock(DriverPool::class, ['getDriver']); $driverPool->expects($this->never())->method('getDriver'); $driver = $this->getMockForAbstractClass(DriverInterface::class); $driver->expects($this->any())->method('isExists')->willReturn(true); $factory = new WriteFactory($driverPool); $result = $factory->create('path', $driver, 'a+'); $this->assertInstanceOf(Write::class, $result); } }