Ejemplo n.º 1
0
 /**
  * @param BaseTestCase $testCase
  * @param array $output
  * @param int $statusCode
  * @return Command A stub configured with $output and $statuCode
  */
 public static function withStubbedResult(BaseTestCase $testCase, $output, $statusCode)
 {
     $resultStub = new StubbedCommandResult($output, $statusCode);
     return $testCase->shmock('Bart\\Shell\\Command', function ($cmd) use($resultStub) {
         $cmd->disable_original_constructor();
         $cmd->getResult()->once()->return_value($resultStub);
     });
 }
Ejemplo n.º 2
0
 /**
  * Utility method to create a stub Commit for any tests that need one
  * Custom expectations can be set via the $configure parameter
  * @param BaseTestCase $phpu
  * @param string $revision
  * @param callable $configure Shmock configuration function
  * @return Commit
  */
 public static function getStubCommit(BaseTestCase $phpu, $revision = 'HEAD', callable $configure = null)
 {
     return $phpu->shmock('\\Bart\\Git\\Commit', function ($commit) use($revision, $configure) {
         $commit->disable_original_constructor();
         $commit->__toString()->any()->return_value($revision);
         $commit->revision()->any()->return_value($revision);
         if ($configure) {
             $configure($commit);
         }
     });
 }