<?php

declare(strict_types=1);
namespace Tests\git2;
use git2\git;
use git2\git_repository_init_flag_t;
use git2\git_repository_init_mode_t;
use git2\git_repository_init_options;

final class RepositoryInitOptionsTest extends GitTestCase
{

	public function testDefault(): void
	{
		$nullOptions = new git_repository_init_options;
		$this->assertSame(0, $nullOptions->version);
		$this->assertOK(git::repository_init_options_init($options, git_repository_init_options::VERSION));
		$this->assertInstanceOf(git_repository_init_options::class, $options);
		$this->assertSame(1, $options->version);
		$this->assertSame(0, $options->flags);
		$this->assertSame(git_repository_init_mode_t::UMASK, $options->mode);
		$this->assertNull($options->workdir_path);
		$this->assertNull($options->description);
		$this->assertNull($options->template_path);
		$this->assertNull($options->initial_head);
		$this->assertNull($options->origin_url);

		$options->version       = 2;
		$options->flags         = git_repository_init_flag_t::BARE | git_repository_init_flag_t::MKDIR;
		$options->mode          = git_repository_init_mode_t::ALL;
		$options->workdir_path  = 'workdir path';
		$options->description   = 'description';
		$options->template_path = 'template path';
		$options->initial_head  = 'initial head';
		$options->origin_url    = 'origin url';

		$this->assertSame(2, $options->version);
		$this->assertSame(git_repository_init_flag_t::BARE | git_repository_init_flag_t::MKDIR, $options->flags);
		$this->assertSame(git_repository_init_mode_t::ALL, $options->mode);
		$this->assertSame('workdir path', $options->workdir_path);
		$this->assertSame('description', $options->description);
		$this->assertSame('template path', $options->template_path);
		$this->assertSame('initial head', $options->initial_head);
		$this->assertSame('origin url', $options->origin_url);
	}

}