b374k
m1n1 1.01
Apache/2.4.41 (Ubuntu)
Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64
uid=33(www-data) gid=33(www-data) groups=33(www-data)
server ip : 62.171.164.128 | your ip : 127.0.0.1
safemode OFF
 >  / home / dev2.destoffenstraat.com / vendor / magento / framework / Filesystem / Test / Unit / Directory /
Filename/home/dev2.destoffenstraat.com/vendor/magento/framework/Filesystem/Test/Unit/Directory/ReadTest.php
Size2.35 kb
Permissionrw-r--r--
Ownerroot : root
Create time17-Aug-2025 10:26
Last modified07-Jan-2021 21:08
Last accessed23-Aug-2025 03:56
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
<?php declare(strict_types=1);
/**
* Unit Test for \Magento\Framework\Filesystem\Directory\Read
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Framework\Filesystem\Test\Unit\Directory;

use Magento\Framework\Filesystem\Directory\Read;
use Magento\Framework\Filesystem\Driver\File;
use Magento\Framework\Filesystem\File\ReadFactory;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

class ReadTest extends TestCase
{
/**
* \Magento\Framework\Filesystem\Driver
*
* @var MockObject
*/
protected $driver;

/**
* @var Read
*/
protected $read;

/**
* \Magento\Framework\Filesystem\File\ReadFactory
*
* @var MockObject
*/
protected $fileFactory;

/**
* Directory path
*
* @var string
*/
protected $path;

/**
* Set up
*/
protected function setUp(): void
{
$this->driver = $this->createMock(File::class);
$this->fileFactory = $this->createMock(ReadFactory::class);
$this->read = new Read(
$this->fileFactory,
$this->driver,
$this->path
);
}

/**
* Tear down
*/
protected function tearDown(): void
{
$this->driver = null;
$this->fileFactory = null;
$this->read = null;
}

public function testIsExist()
{
$this->driver->expects($this->once())->method('isExists')->willReturn(true);
$this->assertTrue($this->read->isExist('correct-path'));
}

public function testStat()
{
$this->driver->expects($this->once())->method('stat')->willReturn(['some-stat-data']);
$this->assertEquals(['some-stat-data'], $this->read->stat('correct-path'));
}

public function testReadFile()
{
$path = 'filepath';
$flag = 'flag';
$context = 'context';
$contents = 'contents';

$this->driver->expects($this->once())
->method('getAbsolutePath')
->with($this->path, $path)
->willReturn($path);
$this->driver->expects($this->once())
->method('fileGetContents')
->with($path, $flag, $context)
->willReturn($contents);

$this->assertEquals($contents, $this->read->readFile($path, $flag, $context));
}
}