forked from gitonomy/gitlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReferenceBagTest.php
More file actions
56 lines (47 loc) · 1.71 KB
/
ReferenceBagTest.php
File metadata and controls
56 lines (47 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
/**
* This file is part of Gitonomy.
*
* (c) Alexandre Salomé <alexandre.salome@gmail.com>
* (c) Julien DIDIER <genzo.wm@gmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Gitonomy\Git\Tests;
use Gitonomy\Git\Repository;
class ReferenceBagTest extends AbstractTest
{
/**
* @dataProvider provideFoobar
*/
public function testUnknownReference(Repository $repository)
{
$hash = $repository->getLog()->getSingleCommit()->getHash();
$repository->run('update-ref', ['refs/pipelines/1', $hash]);
$repository->run('update-ref', ['refs/merge-request/1/head', $hash]);
$repository->run('update-ref', ['refs/pull/1/head', $hash]);
$repository->run('update-ref', ['refs/notes/gtm-data', $hash]);
$refs = $repository->getReferences()->getAll();
if (method_exists($this, 'assertIsArray')) {
$this->assertIsArray($refs);
} else {
$this->assertInternalType('array', $refs);
}
// Check that at least it has the master ref
$this->assertArrayHasKey('refs/heads/master', $refs);
// Check that our custom refs have been ignored
$this->assertArrayNotHasKey('refs/pipelines/1', $refs);
$this->assertArrayNotHasKey('refs/merge-request/1/head', $refs);
$this->assertArrayNotHasKey('refs/pull/1/head', $refs);
$this->assertArrayNotHasKey('refs/notes/gtm-data', $refs);
}
/**
* @dataProvider provideEmpty
*/
public function testEmptyRepo(Repository $repository)
{
$refs = $repository->getReferences()->getAll();
$this->assertSame([], $refs);
}
}