configHashMock = $this->getMockBuilder(Hash::class) ->disableOriginalConstructor() ->getMock(); $this->input = $this->getMockBuilder(InputInterface::class) ->getMockForAbstractClass(); $this->output = $this->getMockBuilder(OutputInterface::class) ->getMockForAbstractClass(); $this->writer = $this->getMockBuilder(Writer::class) ->disableOriginalConstructor() ->getMock(); $this->source = $this->getMockBuilder(SourceInterface::class) ->disableOriginalConstructor() ->getMock(); $this->sourceEnv = $this->getMockBuilder(SourceInterface::class) ->disableOriginalConstructor() ->getMock(); $this->commentMock = $this->getMockBuilder(Comment::class) ->disableOriginalConstructor() ->getMock(); $this->command = new ApplicationDumpCommand( $this->writer, [ [ 'namespace' => 'system', 'source' => $this->source, 'pool' => ConfigFilePool::APP_CONFIG, 'comment' => $this->commentMock ], [ 'namespace' => 'system', 'source' => $this->sourceEnv, 'pool' => ConfigFilePool::APP_ENV ] ], $this->configHashMock ); } public function testExport() { $dump = [ 'system' => ['systemDATA'] ]; $this->configHashMock->expects($this->once()) ->method('regenerate'); $this->source ->expects($this->once()) ->method('get') ->willReturn(['systemDATA']); $this->sourceEnv ->expects($this->once()) ->method('get') ->willReturn(['systemDATA']); $this->commentMock->expects($this->once()) ->method('get') ->willReturn('Some comment message'); $this->writer->expects($this->exactly(2)) ->method('saveConfig') ->withConsecutive( [[ConfigFilePool::APP_CONFIG => $dump]], [[ConfigFilePool::APP_ENV => $dump]] ); $this->output->expects($this->exactly(2)) ->method('writeln') ->withConsecutive( [['system' => 'Some comment message']], ['Done. Config types dumped: system'] ); $method = new \ReflectionMethod(ApplicationDumpCommand::class, 'execute'); $method->setAccessible(true); $this->assertEquals( Cli::RETURN_SUCCESS, $method->invokeArgs( $this->command, [$this->input, $this->output] ) ); } }