aboutsummaryrefslogtreecommitdiffstats
path: root/library/kzykhys/git/test/PHPGit/Command/TagCommandTest.php
blob: 5715ba92e2206a67c4b5bdde0a02ca6171aa5859 (plain) (blame)
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
57
58
<?php

use PHPGit\Git;
use Symfony\Component\Filesystem\Filesystem;

require_once __DIR__ . '/../BaseTestCase.php';

class TagCommandTest extends BaseTestCase
{

    public function testTagDelete()
    {
        $filesystem = new Filesystem();

        $git = new Git();
        $git->init($this->directory);
        $git->setRepository($this->directory);
        $filesystem->dumpFile($this->directory . '/README.md', 'hello');
        $git->add('.');
        $git->commit('Initial commit');
        $git->tag->create('v1.0.0');
        $git->tag->delete('v1.0.0');
        $this->assertCount(0, $git->tag());
    }

    /**
     * @expectedException \PHPGit\Exception\GitException
     */
    public function testTagVerify()
    {
        $filesystem = new Filesystem();

        $git = new Git();
        $git->init($this->directory);
        $git->setRepository($this->directory);
        $filesystem->dumpFile($this->directory . '/README.md', 'hello');
        $git->add('.');
        $git->commit('Initial commit');
        $git->tag->create('v1.0.0');
        $git->tag->verify('v1.0.0');
    }

    public function testCreateTagFromCommit()
    {
        $filesystem = new Filesystem();

        $git = new Git();
        $git->init($this->directory);
        $git->setRepository($this->directory);
        $filesystem->dumpFile($this->directory . '/README.md', 'hello');
        $git->add('.');
        $git->commit('Initial commit');
        $log = $git->log(null, null, array('limit' => 1));
        $git->tag->create('v1.0.0', $log[0]['hash']);
        $this->assertCount(1, $git->tag());
    }

}