|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * This file is part of Gitonomy. |
| 5 | + * |
| 6 | + * (c) Alexandre Salomé <[email protected]> |
| 7 | + * (c) Julien DIDIER <[email protected]> |
| 8 | + * |
| 9 | + * This source file is subject to the MIT license that is bundled |
| 10 | + * with this source code in the file LICENSE. |
| 11 | + */ |
| 12 | + |
| 13 | +namespace Gitonomy\Git\Tests; |
| 14 | + |
| 15 | +use Gitonomy\Git\Repository; |
| 16 | + |
| 17 | +class ReferenceBagTest extends AbstractTest |
| 18 | +{ |
| 19 | + /** |
| 20 | + * @dataProvider provideFoobar |
| 21 | + */ |
| 22 | + public function testUnknownReference(Repository $repository) |
| 23 | + { |
| 24 | + $hash = $repository->getLog()->getSingleCommit()->getHash(); |
| 25 | + |
| 26 | + $repository->run('update-ref', ['refs/pipelines/1', $hash]); |
| 27 | + $repository->run('update-ref', ['refs/merge-request/1/head', $hash]); |
| 28 | + $repository->run('update-ref', ['refs/pull/1/head', $hash]); |
| 29 | + $repository->run('update-ref', ['refs/notes/gtm-data', $hash]); |
| 30 | + |
| 31 | + $refs = $repository->getReferences()->getAll(); |
| 32 | + if (method_exists($this, 'assertIsArray')) { |
| 33 | + $this->assertIsArray($refs); |
| 34 | + } else { |
| 35 | + $this->assertInternalType('array', $refs); |
| 36 | + } |
| 37 | + |
| 38 | + // Check that at least it has the master ref |
| 39 | + $this->assertArrayHasKey('refs/heads/master', $refs); |
| 40 | + |
| 41 | + // Check that our custom refs have been ignored |
| 42 | + $this->assertArrayNotHasKey('refs/pipelines/1', $refs); |
| 43 | + $this->assertArrayNotHasKey('refs/merge-request/1/head', $refs); |
| 44 | + $this->assertArrayNotHasKey('refs/pull/1/head', $refs); |
| 45 | + $this->assertArrayNotHasKey('refs/notes/gtm-data', $refs); |
| 46 | + } |
| 47 | +} |
0 commit comments