public function testExecute() { $fileName = __DIR__ . DIRECTORY_SEPARATOR . 'CHANGELOG'; $services = new Container(); $services['project'] = function () { $project = new Project(); $project->setDirectoryPath(__DIR__); return $project; }; $input = new ArrayInput([]); $output = new BufferedOutput(); touch($fileName); $this->assertTrue(file_exists($fileName)); $task = new CleaningTask($services); $result = $task->execute($input, $output); $this->assertSame(ITask::NO_ERROR_CODE, $result); $this->assertSame("Cleaning files\nRemoving file {$fileName}\n", $output->fetch()); $this->assertFalse(file_exists($fileName)); }
/** * */ public function testExecute() { $git = $this->getMockBuilder('PHPGit\\Git')->disableOriginalConstructor()->getMock(); $git->expects($this->at(0))->method('__call')->with('status', [])->will($this->throwException(new \Exception())); $git->expects($this->at(1))->method('__call', ['path' => 'dir/path'])->with('init'); $input = new ArrayInput([]); $output = new BufferedOutput(); $services = new Container(); $services['project'] = function () { $project = new Project(); $project->setDirectoryPath('dir/path'); return $project; }; $services['git'] = function () use($git) { return $git; }; $task = new GitTask($services); $this->assertSame(ITask::NO_ERROR_CODE, $task->execute($input, $output)); $this->assertSame("Initializing Git\n", $output->fetch()); }
public function testDumpAutoload() { $project = new Project(); $project->setDirectoryPath(__DIR__ . '/../resources'); $executor = $this->getMockBuilder('TRex\\Cli\\Executor')->getMock(); $executor->expects($this->once())->method('flush')->with('composer dump-autoload', [STDIN, STDOUT, STDERR], [], __DIR__ . '/../resources')->will($this->returnValue(0)); $composer = new Composer($executor, new BalloonFactory(new DummyFileReaderFactory())); $this->assertSame(0, $composer->dumpAutoload($project->getDirectoryPath())); }