Skip to content

Commit 94b1301

Browse files
committed
Add PHPUnit tests for GitChangelog::setOptions()
1 parent 2357497 commit 94b1301

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

tests/GitChangeLogTest.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<?php /** @noinspection PhpUnhandledExceptionInspection */
1+
<?php
2+
/** @noinspection PhpUnhandledExceptionInspection */
23

34
/*
45
* BSD 3-Clause License
@@ -385,4 +386,29 @@ public function testSaveThrowsExceptionOnWrite()
385386
$this->expectException('RunTimeException');
386387
$changeLog->save(vfsStream::url('testFolder/changelog.md'));
387388
}
389+
390+
public function testSetOptions()
391+
{
392+
$changeLog = new GitChangeLog();
393+
394+
// Set multiple options at once.
395+
$changeLog->setOptions([
396+
'logHeader' => 'Test1',
397+
'headSubject' => 'Test2',
398+
]);
399+
$this->assertEquals('Test1', $this->getPrivateProperty($changeLog, 'options')['logHeader']);
400+
$this->assertEquals('Test2', $this->getPrivateProperty($changeLog, 'options')['headSubject']);
401+
402+
// Set single option.
403+
$changeLog->setOptions('logHeader', 'Test');
404+
$this->assertEquals('Test', $this->getPrivateProperty($changeLog, 'options')['logHeader']);
405+
}
406+
407+
public function testSetOptionsThrowsException()
408+
{
409+
$changeLog = new GitChangeLog();
410+
411+
$this->expectException('InvalidArgumentException');
412+
$changeLog->setOptions('NotExistingOption', 'Test');
413+
}
388414
}

0 commit comments

Comments
 (0)