getStubCommit() public static method

Utility method to create a stub Commit for any tests that need one Custom expectations can be set via the $configure parameter
public static getStubCommit ( Bart\BaseTestCase $phpu, string $revision = 'HEAD', callable $configure = null ) : Commit
$phpu Bart\BaseTestCase
$revision string
$configure callable Shmock configuration function
return Commit
Beispiel #1
0
 public function setUp()
 {
     parent::setUp();
     $this->head = CommitTest::getStubCommit($this, $this->commitHash, function ($commit) {
         $commit->gerritChangeId()->once()->return_value($this->changeId);
     });
 }
Beispiel #2
0
 public function testBadClassNamesIgnored()
 {
     $this->shmockAndDieselify('\\Bart\\GitHook\\GitHookConfig', function ($configs) {
         $configs->getPreReceiveHookActions()->once()->return_value(['\\This\\Class\\DNE']);
     }, true);
     $head = CommitTest::getStubCommit($this);
     $preReceive = new PreReceiveRunner($head);
     // This should pass with no side effects
     $preReceive->runAllActions();
 }
Beispiel #3
0
 /**
  * @dataProvider dataProviderInvalidBuildFixDirectives
  * @param string $message Git commit message subject
  */
 public function testUnhealthyBuildAndInvalidBuildFixDirectives($message)
 {
     $this->mockJenkinsJobWithDependencies(false);
     $mockCommit = CommitTest::getStubCommit($this, 'HEAD', function ($head) use($message) {
         $head->messageSubject()->once()->return_value($message);
     });
     $stopTheLineJenkins = new StopTheLineJenkins();
     $this->setExpectedException('\\Bart\\GitHook\\GitHookException');
     $stopTheLineJenkins->run($mockCommit);
 }
Beispiel #4
0
 public function testOneJira()
 {
     $this->shmockAndDieselify('\\chobie\\Jira\\Api', function ($jiraClient) {
         // Expect request to comment on JIRA referenced in commit with
         // ...the configured template string
         $jiraClient->addComment('TEST-123', 'merged HEAD')->once();
     }, true);
     $head = CommitTest::getStubCommit($this, 'HEAD', function ($head) {
         $head->jiras()->once()->return_value([new JiraIssue('TEST-123')]);
     });
     $jiraComment = new JiraComment();
     $jiraComment->run($head);
 }