getProperty('portableItemParser'); $reflectionProperty->setAccessible(true); $this->assertInstanceOf(PortableElementItemParser::class, $reflectionProperty->getValue($this->getPortableAssetHandler(new Item()))); } /** * @dataProvider isApplicableProvider */ public function testIsApplicable($isPciFixture, $isPciFileFixture, $expected) { $relPathFixture = 'polop/polop/fixture.txt'; $mock = $this->getMockBuilder(PortableElementItemParser::class) ->setMethods(['isPortableElementAsset','hasPortableElement']) ->getMock(); $mock->expects($this->any()) ->method('isPortableElementAsset') ->with($relPathFixture) ->willReturn($isPciFileFixture); $mock->expects($this->once()) ->method('hasPortableElement') ->willReturn($isPciFixture); $instance = $this->getPortableAssetHandler(new Item()); $this->setInaccessibleProperty($instance, 'portableItemParser', $mock); $this->assertEquals($expected, $instance->isApplicable($relPathFixture)); } public function isApplicableProvider() { return [ [true, false, false], [false, false, false], [false, true, false], [true, true, true], ]; } public function testHandle() { $absolutePath = 'fixture1'; $relativePath = 'fixture2'; $mock = $this->getMockBuilder(PortableElementItemParser::class) ->setMethods(['importPortableElementFile']) ->getMock(); $mock->expects($this->once()) ->method('importPortableElementFile') ->with($absolutePath, $relativePath); $instance = $this->getPortableAssetHandler(new Item()); $this->setInaccessibleProperty($instance, 'portableItemParser', $mock); $instance->handle($absolutePath, $relativePath); } }