HEX
Server: Apache
System: Linux webm019.cluster128.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64
User: petsclubcc (68997)
PHP: 5.4.45
Disabled: _dyuweyrj4,_dyuweyrj4r,dl
Upload Files
File: /home/p/e/t/petsclubcc/magento/setup/src/Magento/Setup/Test/Unit/Model/Cron/Queue/ReaderTest.php
<?php
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
namespace Magento\Setup\Test\Unit\Model\Cron\Queue;

use Magento\Setup\Model\Cron\Queue\Reader;

class ReaderTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Filesystem
     */
    private $filesystem;

    /**
     * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Filesystem\Directory\ReadInterface
     */
    private $directoryRead;

    /**
     * @var Reader
     */
    private $reader;

    public function setUp()
    {
        $this->filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false);
        $this->directoryRead = $this->getMockForAbstractClass(
            'Magento\Framework\Filesystem\Directory\ReadInterface',
            [],
            '',
            false
        );
        $this->filesystem->expects($this->once())->method('getDirectoryRead')->willReturn($this->directoryRead);
        $this->reader = new Reader($this->filesystem);
    }

    public function testReadEmpty()
    {
        $this->directoryRead->expects($this->once())->method('isExist')->willReturn(false);
        $this->assertEquals('', $this->reader->read());
    }

    /**
     * @expectedException \RuntimeException
     * @expectedExceptionMessage must be a valid JSON
     */
    public function testReadException()
    {
        $this->directoryRead->expects($this->once())->method('isExist')->willReturn(true);
        $this->directoryRead->expects($this->once())->method('readFile')->willReturn('invalid json');
        $this->reader->read();
    }

    public function testRead()
    {
        $this->directoryRead->expects($this->once())->method('isExist')->willReturn(true);
        $this->directoryRead->expects($this->once())
            ->method('readFile')
            ->willReturn('{"jobs":[{"name": "job A", "params": []}]}');
        $this->assertEquals('{"jobs":[{"name": "job A", "params": []}]}', $this->reader->read());
    }
}