mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-24 04:15:16 +00:00
55 lines
No EOL
1.3 KiB
PHP
55 lines
No EOL
1.3 KiB
PHP
<?php
|
|
|
|
use PHPGit\Git;
|
|
|
|
require_once __DIR__ . '/../BaseTestCase.php';
|
|
|
|
class ConfigCommandTest extends BaseTestCase
|
|
{
|
|
|
|
public function testConfigSetAndList()
|
|
{
|
|
$git = new Git();
|
|
$git->init($this->directory);
|
|
$git->setRepository($this->directory);
|
|
|
|
$before = $git->config();
|
|
|
|
$git->config->set('user.name', 'John Doe');
|
|
|
|
$config = $git->config();
|
|
$this->assertArrayHasKey('user.name', $config);
|
|
|
|
$expected = 'John Doe';
|
|
|
|
if (isset($before['user.name'])) {
|
|
$expected = $before['user.name'] . "\n" . $expected;
|
|
}
|
|
|
|
$this->assertEquals($expected, $config['user.name']);
|
|
}
|
|
|
|
public function testConfigAdd()
|
|
{
|
|
$git = new Git();
|
|
$git->init($this->directory);
|
|
$git->setRepository($this->directory);
|
|
|
|
$before = $git->config();
|
|
|
|
$git->config->set('user.name', 'John Doe');
|
|
$git->config->add('user.name', 'Foo');
|
|
|
|
$config = $git->config();
|
|
$this->assertArrayHasKey('user.name', $config);
|
|
|
|
$expected = "John Doe\nFoo";
|
|
|
|
if (isset($before['user.name'])) {
|
|
$expected = $before['user.name'] . "\n" . $expected;
|
|
}
|
|
|
|
$this->assertEquals($expected, $config['user.name']);
|
|
}
|
|
|
|
}
|