Skip to content

Commit e7f8766

Browse files
authored
Merge pull request #2052 from jaapio/test/config-target
Add test for target config
2 parents 7f7db1c + ed3bad9 commit e7f8766

File tree

4 files changed

+93
-0
lines changed

4 files changed

+93
-0
lines changed

behat.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ default:
1818
paths: [ "%paths.base%/tests/features/cli" ]
1919
filters:
2020
tags: "~@php5.6+"
21+
config_features:
22+
contexts:
23+
- phpDocumentor\Behat\Contexts\EnvironmentContext:
24+
workingDir: /tmp/phpdoc-behat/config
25+
paths: [ "%paths.base%/tests/features/config" ]
26+
filters:
27+
tags: "~@php5.6+"
2128
php56_features:
2229
contexts:
2330
- phpDocumentor\Behat\Contexts\EnvironmentContext:
@@ -43,6 +50,15 @@ phar:
4350
workingDir: /tmp/phpdoc-behat/cli
4451
pharPath: /build/phpDocumentor.phar
4552
- phpDocumentor\Behat\Contexts\Ast\ApiContext
53+
config_features:
54+
contexts:
55+
- phpDocumentor\Behat\Contexts\EnvironmentContext:
56+
workingDir: /tmp/phpdoc-behat/config
57+
pharPath: /build/phpDocumentor.phar
58+
paths: [ "%paths.base%/tests/features/config" ]
59+
filters:
60+
tags: "~@php5.6+"
61+
4662
php56_features:
4763
contexts:
4864
- phpDocumentor\Behat\Contexts\EnvironmentContext:
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!--
3+
~ This file is part of phpDocumentor.
4+
~
5+
~ For the full copyright and license information, please view the LICENSE
6+
~ file that was distributed with this source code.
7+
~
8+
~ @author Mike van Riel <mike.vanriel@naenius.com>
9+
~ @copyright 2010-2019 Mike van Riel / Naenius (http://www.naenius.com)
10+
~ @license http://www.opensource.org/licenses/mit-license.php MIT
11+
~ @link http://phpdoc.org
12+
~
13+
~
14+
-->
15+
16+
<phpdocumentor>
17+
<parser>
18+
<default-package-name>Default</default-package-name>
19+
<encoding>utf-8</encoding>
20+
<target>build/docs</target>
21+
</parser>
22+
<files>
23+
<directory>src</directory>
24+
</files>
25+
<transformer>
26+
<target>build/api/docs</target>
27+
</transformer>
28+
<logging>
29+
<level>error</level>
30+
</logging>
31+
<transformations>
32+
<template name="clean"/>
33+
</transformations>
34+
</phpdocumentor>

tests/features/bootstrap/EnvironmentContext.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
namespace phpDocumentor\Behat\Contexts;
1414

1515
use Behat\Behat\Context;
16+
use Behat\Behat\Tester\Exception\PendingException;
1617
use FilesystemIterator;
1718
use RecursiveDirectoryIterator;
1819
use RecursiveIteratorIterator;
@@ -113,6 +114,29 @@ public function loadAProject($dest, $source)
113114
}
114115
}
115116

117+
118+
/**
119+
* @Given /^configuration file based on "([^"]*)" in "([^"]*)"$/
120+
*/
121+
public function configurationFileBasedOnIn($configFile, $destDir)
122+
{
123+
Assert::fileExists(__DIR__ . '/../assets/config/' . $configFile);
124+
copy(
125+
__DIR__ . '/../assets/config/' . $configFile,
126+
$this->getWorkingDir() . DIRECTORY_SEPARATOR . $destDir . DIRECTORY_SEPARATOR . 'phpdoc.xml'
127+
);
128+
}
129+
130+
/**
131+
* @Given /^working directory is "([^"]*)"$/
132+
*/
133+
public function workingDirectoryIs($dir)
134+
{
135+
$fullDir = $this->getWorkingDir() . DIRECTORY_SEPARATOR . $dir;
136+
$this->process->setWorkingDirectory($fullDir);
137+
chdir($fullDir);
138+
}
139+
116140
/**
117141
* @Given /^I ran "phpdoc(?: ((?:\"|[^"])*))?"$/
118142
* @When /^I run "phpdoc(?: ((?:\"|[^"])*))?"$/
@@ -178,4 +202,12 @@ public function getErrorOutput()
178202
{
179203
return $this->process->getErrorOutput();
180204
}
205+
206+
/**
207+
* @Then /^documentation should be found in "([^"]*)"$/
208+
*/
209+
public function documentationShouldBeFoundIn($expectedDir)
210+
{
211+
Assert::directory($this->getWorkingDir() . DIRECTORY_SEPARATOR . $expectedDir);
212+
}
181213
}

tests/features/config/v2.feature

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Feature: phpdocumentor should be able to use v2 format config file.
2+
To make the step to phpdoc v3 as small as possible we want to be backwards compatible in the configuration
3+
of phpdocumentor.
4+
5+
Scenario: User has provided a custom target directory in the config
6+
Given A project named "v2" based on "simple"
7+
And configuration file based on "v2Target.xml" in "v2"
8+
And working directory is "v2"
9+
When I run "phpdoc"
10+
Then the application must have run successfully
11+
And documentation should be found in "v2/build/api/docs"

0 commit comments

Comments
 (0)