<?php
declare(strict_types=1);
namespace Tests\git2\Internal;
use git2\git;
use git2\git_error_code;
use Tests\git2\GitTestCase;
final class ReferenceTest extends GitTestCase
{
public function testHandle(): void
{
$dir = $this->mkdir('handle');
$this->assertSame(git_error_code::ENOTFOUND, git::repository_open($repo, $dir));
$this->assertNull($repo);
$this->assertOK(git::repository_init($repo, $dir, false));
$orig = $repo;
$this->assertSame(git_error_code::ENOTFOUND, git::repository_open($repo, $dir . '/foo'));
$this->assertSame($orig, $repo);
$this->assertOK(git::repository_open($repo, $dir));
$this->assertNotSame($orig, $repo);
}
public function testStruct(): void
{
$this->assertSame(git_error_code::ERROR, git::oid_fromstr($oid, ''));
$this->assertNull($oid);
$this->assertOK(git::oid_fromstr($oid, '0000000000000000000000000000000000000000'));
$this->assertNotNull($oid);
$orig = $oid;
$this->assertSame(git_error_code::ERROR, git::oid_fromstr($oid, ''));
$this->assertSame($orig, $oid);
$this->assertOK(git::oid_fromstr($oid, '0000000000000000000000000000000000000001'));
$this->assertSame($orig, $oid);
}
}