vclGeneratorInterfaceFactory = $this->createMock(VclGeneratorInterfaceFactory::class); $this->vclGenerator = $this->createMock(VclGenerator::class); $this->vclGenerator->method('generateVcl')->willReturn('test.vcl" file can\'t be read.'); $this->vclGeneratorInterfaceFactory->method('create')->willReturn($this->vclGenerator); $this->writeFactoryMock = $this->createMock(WriteFactory::class); $this->scopeConfigMock = $this->createMock(ScopeConfigInterface::class); $this->serializer = $this->getMockBuilder(Json::class) ->onlyMethods(['unserialize']) ->getMockForAbstractClass(); $this->command = new GenerateVclCommand( $this->vclGeneratorInterfaceFactory, $this->writeFactoryMock, $this->scopeConfigMock, $this->serializer ); } public function testConfigure() { $this->assertEquals('varnish:vcl:generate', $this->command->getName()); $this->assertEquals( 'Generates Varnish VCL and echos it to the command line', $this->command->getDescription() ); } public function testInputOption() { $options = [ '--' . GenerateVclCommand::INPUT_FILE_OPTION => 'test.vcl', '--' . GenerateVclCommand::EXPORT_VERSION_OPTION => 6, ]; $commandTester = new CommandTester($this->command); $commandTester->execute($options, ['interactive' => false]); $this->assertStringContainsString( 'test.vcl" file can\'t be read.', $commandTester->getDisplay() ); } }