MediaWiki  1.28.1
GitInfoTest.php
Go to the documentation of this file.
1 <?php
6 
7  protected function setUp() {
8  parent::setUp();
9  $this->setMwGlobals( 'wgGitInfoCacheDirectory', __DIR__ . '/../data/gitinfo' );
10  }
11 
12  protected function assertValidGitInfo( GitInfo $gitInfo ) {
13  $this->assertTrue( $gitInfo->cacheIsComplete() );
14  $this->assertEquals( 'refs/heads/master', $gitInfo->getHead() );
15  $this->assertEquals( '0123456789abcdef0123456789abcdef01234567',
16  $gitInfo->getHeadSHA1() );
17  $this->assertEquals( '1070884800', $gitInfo->getHeadCommitDate() );
18  $this->assertEquals( 'master', $gitInfo->getCurrentBranch() );
19  $this->assertContains( '0123456789abcdef0123456789abcdef01234567',
20  $gitInfo->getHeadViewUrl() );
21 
22  }
23 
24  public function testValidJsonData() {
25  global $IP;
26 
27  $this->assertValidGitInfo( new GitInfo( "$IP/testValidJsonData") );
28  $this->assertValidGitInfo( new GitInfo( __DIR__ . "/../data/gitinfo/extension" ) );
29  }
30 
31  public function testMissingJsonData() {
32  $dir = $GLOBALS['IP'] . '/testMissingJsonData';
33  $fixture = new GitInfo( $dir );
34 
35  $this->assertFalse( $fixture->cacheIsComplete() );
36 
37  $this->assertEquals( false, $fixture->getHead() );
38  $this->assertEquals( false, $fixture->getHeadSHA1() );
39  $this->assertEquals( false, $fixture->getHeadCommitDate() );
40  $this->assertEquals( false, $fixture->getCurrentBranch() );
41  $this->assertEquals( false, $fixture->getHeadViewUrl() );
42 
43  // After calling all the outputs, the cache should be complete
44  $this->assertTrue( $fixture->cacheIsComplete() );
45  }
46 
47 }
if(count($args)==0) $dir
$IP
Definition: WebStart.php:58
getHeadCommitDate()
Get the commit date of HEAD entry of the git code repository.
Definition: GitInfo.php:209
getHead()
Get the HEAD of the repo (without any opening "ref: ")
Definition: GitInfo.php:159
when a variable name is used in a it is silently declared as a new local masking the global
Definition: design.txt:93
$GLOBALS['IP']
getHeadViewUrl()
Get an URL to a web viewer link to the HEAD revision.
Definition: GitInfo.php:255
GitInfo.
Definition: GitInfoTest.php:5
getCurrentBranch()
Get the name of the current branch, or HEAD if not found.
Definition: GitInfo.php:237
getHeadSHA1()
Get the SHA1 for the current HEAD of the repo.
Definition: GitInfo.php:183
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
assertValidGitInfo(GitInfo $gitInfo)
Definition: GitInfoTest.php:12
cacheIsComplete()
Check to see if the current cache is fully populated.
Definition: GitInfo.php:320
testMissingJsonData()
Definition: GitInfoTest.php:31
setMwGlobals($pairs, $value=null)