<?php
declare(strict_types=1);
namespace Tests\git2;
use git2\git;
use git2\git_direction;
use git2\git_error_code;
final class RefspecTest extends GitTestCase
{
public function testParse(): void
{
$this->assertOK(git::refspec_parse($spec, '+master:refs/remotes/origin/master', true));
$this->assertSame('+master:refs/remotes/origin/master', git::refspec_string($spec));
$this->assertSame(git_direction::FETCH, git::refspec_direction($spec));
$this->assertSame('master', git::refspec_src($spec));
$this->assertTrue(git::refspec_src_matches($spec, 'master'));
$this->assertFalse(git::refspec_src_matches($spec, 'feature'));
$this->assertSame('refs/remotes/origin/master', git::refspec_dst($spec));
$this->assertTrue(git::refspec_dst_matches($spec, 'refs/remotes/origin/master'));
$this->assertFalse(git::refspec_dst_matches($spec, 'refs/remotes/origin/feature'));
$this->assertTrue(git::refspec_force($spec));
$this->assertSame(git_error_code::ERROR, git::refspec_parse($spec, '', false));
}
public function testTransform(): void
{
$this->assertOK(git::refspec_parse($spec, 'refs/pull/*/head:refs/remotes/origin/pr/*', true));
$this->assertOK(git::refspec_transform($transform, $spec, 'refs/pull/23/head'));
$this->assertSame('refs/remotes/origin/pr/23', (string) $transform);
}
public function testRTransform(): void
{
$this->assertOK(git::refspec_parse($spec, 'refs/pull/*/head:refs/remotes/origin/pr/*', true));
$this->assertOK(git::refspec_rtransform($rtransform, $spec, 'refs/remotes/origin/pr/23'));
$this->assertSame('refs/pull/23/head', (string) $rtransform);
}
}