Skip to content

Commit 6c6bb3c

Browse files
Add config generator test
1 parent f866247 commit 6c6bb3c

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

src/Cmd.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ private function handleConfigGeneration()
332332

333333
\file_put_contents(
334334
$file,
335-
$generator->generateDefaultConfiguration(
335+
$generator->generateConfigurationSkeleton(
336336
Version::minor(),
337337
$format,
338338
$bootstrapScript

src/Configuration/Generator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ final class Generator
7474
* @param string $bootstrapScript
7575
* @return string
7676
*/
77-
public function generateDefaultConfiguration(string $version, string $format, string $bootstrapScript) : string
77+
public function generateConfigurationSkeleton(string $version, string $format, string $bootstrapScript) : string
7878
{
7979
return \str_replace(
8080
[
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
namespace phpbu\App\Configuration;
3+
4+
use PHPUnit\Framework\TestCase;
5+
6+
/**
7+
* Generator test
8+
*
9+
* @package phpbu
10+
* @subpackage tests
11+
* @author Sebastian Feldmann <sebastian@phpbu.de>
12+
* @copyright Sebastian Feldmann <sebastian@phpbu.de>
13+
* @license https://opensource.org/licenses/MIT The MIT License (MIT)
14+
* @link http://www.phpbu.de/
15+
* @since Class available since Release 6.0.0
16+
*/
17+
class GeneratorTest extends TestCase
18+
{
19+
/**
20+
* Tests Generator::generateConfigurationSkeleton
21+
*/
22+
public function testGenerateConfigurationSkeletonXml()
23+
{
24+
$generator = new Generator();
25+
$config = $generator->generateConfigurationSkeleton('X.Y', 'xml', 'boot.php');
26+
27+
$this->assertContains('bootstrap="boot.php"', $config);
28+
$this->assertContains('xsi:noNamespaceSchemaLocation="https://schema.phpbu.de/X.Y/phpbu.xsd"', $config);
29+
}
30+
31+
/**
32+
* Tests Generator::generateConfigurationSkeleton
33+
*/
34+
public function testGenerateConfigurationSkeletonJson()
35+
{
36+
$generator = new Generator();
37+
$config = $generator->generateConfigurationSkeleton('X.Y', 'json', 'boot.php');
38+
39+
$this->assertContains('"bootstrap": "boot.php"', $config);
40+
}
41+
}

0 commit comments

Comments
 (0)