Skip to content
Snippets Groups Projects
Select Git revision
  • 0502e99f797d2159eb0f7c48654842a5ba411f47
  • develop default protected
  • ZERO-162-changes
  • 1.3 protected
  • 1.1
  • 1.2 protected
  • 1.0
  • 13-export-cli-command
  • 1.5.0
  • 1.4.3
  • 1.4.2
  • 1.4.1
  • 1.4.0
  • 1.3.7
  • 1.3.6
  • 1.3.5
  • 1.3.4
  • 1.3.3
  • 1.3.2
  • 1.3.1
  • 1.3.0
  • 1.1.4
  • 1.2.5
  • 1.2.4
  • 1.2.3
  • 1.0.6
  • 1.1.3
  • 1.2.2
28 results

FetchMediaFilesChainTest.php

Blame
  • FetchMediaFilesChainTest.php 1.74 KiB
    <?php
    declare(strict_types=1);
    
    namespace Firegento\ContentProvisioning\Test\Integration\Model\Config\Parser\Query;
    
    use Firegento\ContentProvisioning\Api\MediaFilesParserInterface;
    use Firegento\ContentProvisioning\Model\Config\Parser\Query\FetchMediaFilesChain;
    use PHPUnit\Framework\MockObject\MockObject;
    
    class FetchMediaFilesChainTest extends \PHPUnit\Framework\TestCase
    {
        /**
         * @var FetchMediaFilesChain
         */
        private $chain;
    
        /**
         * @var MediaFilesParserInterface|MockObject
         */
        private $parser1;
    
        /**
         * @var MediaFilesParserInterface|MockObject
         */
        private $parser2;
    
        protected function setUp()
        {
            $this->parser1 = self::getMockBuilder(MediaFilesParserInterface::class)
                ->disableOriginalConstructor()
                ->getMock();
    
            $this->parser2 = self::getMockBuilder(MediaFilesParserInterface::class)
                ->disableOriginalConstructor()
                ->getMock();
    
            $this->chain = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
                ->create(FetchMediaFilesChain::class, ['parsers' => [
                    $this->parser1,
                    $this->parser2,
                ]]);
        }
    
        public function testMergingData()
        {
            $this->parser1->method('execute')->willReturn([
                'path/to/file1.png',
                'path/to/file2.png',
                'file3.png',
            ]);
            $this->parser2->method('execute')->willReturn([
                'file3.png',
                'some/other/path.jpg',
            ]);
    
            $result = $this->chain->execute('');
    
            $this->assertSame([
                'path/to/file1.png',
                'path/to/file2.png',
                'file3.png',
                'file3.png',
                'some/other/path.jpg',
            ], $result);
        }
    }