Skip to content

Commit 7d1639d

Browse files
committed
Initial commit.
0 parents  commit 7d1639d

19 files changed

+1112
-0
lines changed

.editorconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
; top-most EditorConfig file
2+
root = true
3+
4+
; Unix-style newlines
5+
[*]
6+
end_of_line = LF
7+
8+
[*.php]
9+
indent_style = space
10+
indent_size = 4

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# IDEs
2+
.buildpath
3+
.project
4+
.settings
5+
.build
6+
.idea
7+
8+
# OS generated files
9+
desktop.ini
10+
.DS_Store*
11+
ehthumbs.db
12+
Icon?
13+
Thumbs.db
14+
15+
# Build files
16+
/build
17+
18+
# Composer
19+
/composer.phar
20+
/vendor
21+
/composer.lock
22+
23+
# Misc
24+
phpunit.xml

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Version 1.0
2+
3+
This is the list of changes for the Version 1.0 release series.
4+
5+
## Version 1.0.0
6+
7+
* Initial release.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014, Andreas Weber <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# php-junit-merge
2+
3+
**php-junit-merge** is a library that merges multiple junit result xml files.
4+
5+
## Installation
6+
7+
Simply add a dependency on `andreas-weber/php-junit-merge` to your project's `composer.json` file if you use [Composer](http://getcomposer.org/) to manage the dependencies of your project.
8+
9+
## Usage
10+
11+
After updating dependencies by composer a new binary `php-junit-merge` is available for usage.
12+
13+
root@dev:~/projects/sample/vendor/bin ./phpjunitmerge
14+
phpjunitmerge 1.0.0 by Andreas Weber
15+
16+
Usage:
17+
phpjunitmerge [--names="..."] [--ignore="..."] dir file
18+
19+
Arguments:
20+
dir Directory where all files ready to get merged are stored
21+
file The target file in which the merged result should be written
22+
23+
Options:
24+
--names A comma-separated list of file names to check (default: ["*.xml"])
25+
--ignore A comma-separated list of file names to ignore (default: ["result.xml"])
26+
--help (-h) Display this help message.
27+
--quiet (-q) Do not output any message.
28+
--verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
29+
--version (-V) Display this application version.
30+
--ansi Force ANSI output.
31+
--no-ansi Disable ANSI output.
32+
--no-interaction (-n) Do not ask any interactive question.
33+
34+
35+
The binary expects at least two parameters:
36+
37+
- `dir` is the directory, where the application should search for xml files
38+
- `file` is the result file, in which the application should write the merged content
39+
40+
A simple call could look like this:
41+
42+
root@dev:~/projects/sample/vendor/bin ./phpjunitmerge src/Tests/Unit/Fixtures result.xml
43+
phpjunitmerge 1.0.0 by Andreas Weber
44+
45+
Found and processed 3 files. Wrote merged result in 'result.xml'.
46+
47+
## Attributions
48+
- Thanks to [Sebastian Bergmann](https://gist.github.com/sebastianbergmann) for his gist [merge-phpunit-xml.php](https://gist.github.com/sebastianbergmann/4405658), which was the base and inspired me to develop this library.
49+
50+
## Thoughts
51+
Built with love. Hope you'll enjoy.. :-)

build.xml

Lines changed: 268 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,268 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project name="Project" default="help">
3+
4+
<!-- ++++++++++++++++++++++++++++++++++++++++++ -->
5+
<!-- | Init -->
6+
<!-- ++++++++++++++++++++++++++++++++++++++++++ -->
7+
8+
<!-- Vars -->
9+
<property name="basedir" value="."/>
10+
11+
<!-- Command help -->
12+
<target name="help">
13+
<echo message="Error: No command passed"/>
14+
<echo message="The following commands are available:"/>
15+
<echo message="|"/>
16+
<echo message="| +++ Build +++"/>
17+
<echo message="|-- build (Run the build)"/>
18+
<echo message="| |-- dependencies (Install dependencies)"/>
19+
<echo message="| |-- tests (Lint all files and run tests)"/>
20+
<echo message="| |-- metrics (Generate quality metrics)"/>
21+
<echo message="|-- cleanup (Cleanup the build directory)"/>
22+
<echo message="|"/>
23+
<echo message="| +++ Composer +++"/>
24+
<echo message="|-- composer -> composer-download, composer-install"/>
25+
<echo message="|-- composer-download (Downloads composer.phar to project)"/>
26+
<echo message="|-- composer-install (Install all dependencies)"/>
27+
<echo message="|-- composer-update (Update dependencies and generate new lockfile)"/>
28+
<echo message="|"/>
29+
<echo message="| +++ Testing +++"/>
30+
<echo message="|-- phpunit -> phpunit-full"/>
31+
<echo message="|-- phpunit-tests (Run unit tests)"/>
32+
<echo message="|-- phpunit-full (Run unit tests and generate code coverage report / logs)"/>
33+
<echo message="|"/>
34+
<echo message="| +++ Metrics +++"/>
35+
<echo message="|-- phploc (Generate lines of code metric)"/>
36+
<echo message="|-- phpcpd (Generate copy paste metric)"/>
37+
<echo message="|-- phpcs (Generate code sniffer metric)"/>
38+
<echo message="|-- phpmd (Generate mess detector metric)"/>
39+
<echo message="|"/>
40+
<echo message="| +++ Tools +++"/>
41+
<echo message="|-- lint (Lint all php files)"/>
42+
<echo message=""/>
43+
</target>
44+
45+
<!-- ++++++++++++++++++++++++++++++++++++++++++ -->
46+
<!-- | Build -->
47+
<!-- ++++++++++++++++++++++++++++++++++++++++++ -->
48+
49+
<!-- run the build -->
50+
<target name="build" depends="cleanup, prepare">
51+
<!-- get all the dependencies necessary for the build -->
52+
<antcall target="dependencies"/>
53+
<!-- ok, looks good - now run all the tests -->
54+
<antcall target="tests"/>
55+
<!-- great, no errors - now we should generate some cool quality metrics -->
56+
<antcall target="metrics"/>
57+
</target>
58+
59+
<!-- fetch dependencies -->
60+
<target name="dependencies">
61+
<antcall target="composer"/>
62+
</target>
63+
64+
<!-- run tests -->
65+
<target name="tests">
66+
<!-- when there is a syntax error we're failing right at the beginning -->
67+
<antcall target="lint"/>
68+
<!-- ahh boy, the unit tests -->
69+
<antcall target="phpunit-full"/>
70+
</target>
71+
72+
<!-- generate metrics -->
73+
<target name="metrics">
74+
<antcall target="phploc"/>
75+
<antcall target="phpcpd"/>
76+
<antcall target="phpcs"/>
77+
<antcall target="phpmd"/>
78+
</target>
79+
80+
<!-- cleanup -->
81+
<target name="cleanup">
82+
<delete dir="${basedir}/build"/>
83+
</target>
84+
85+
<!-- prepare -->
86+
<target name="prepare">
87+
<mkdir dir="${basedir}/build"/>
88+
</target>
89+
90+
<!-- ++++++++++++++++++++++++++++++++++++++++++ -->
91+
<!-- | Composer -->
92+
<!-- ++++++++++++++++++++++++++++++++++++++++++ -->
93+
94+
<!-- main target -->
95+
<target name="composer" depends="composer-download, composer-install"/>
96+
97+
<!-- preconditions -->
98+
<target name="composer-preconditions">
99+
<available file="${basedir}/composer.phar" property="binary.present"/>
100+
<available file="${basedir}/vendor" property="vendor.present"/>
101+
</target>
102+
103+
<!-- download the latest composer release -->
104+
<target name="composer-download" depends="composer-preconditions" unless="binary.present">
105+
<exec dir="${basedir}" executable="wget">
106+
<arg value="https://getcomposer.org/installer"/>
107+
</exec>
108+
<exec dir="${basedir}" executable="php">
109+
<arg value="installer"/>
110+
</exec>
111+
<delete file="${basedir}/installer"/>
112+
</target>
113+
114+
<!-- install dependencies -->
115+
<target name="composer-install" depends="composer-preconditions"> <!-- unless="vendor.present" -->
116+
<exec dir="${basedir}" executable="php">
117+
<arg value="composer.phar"/>
118+
<arg value="install"/>
119+
</exec>
120+
</target>
121+
122+
<!-- update dependencies and generate new lockfile-->
123+
<target name="composer-update" depends="composer-preconditions">
124+
<exec dir="${basedir}" executable="php">
125+
<arg value="composer.phar"/>
126+
<arg value="update"/>
127+
</exec>
128+
</target>
129+
130+
<!-- cleanup -->
131+
<target name="composer-cleanup">
132+
<delete dir="${basedir}/vendor"/>
133+
<delete file="${basedir}/composer.phar"/>
134+
</target>
135+
136+
<!-- ++++++++++++++++++++++++++++++++++++++++++ -->
137+
<!-- | PHP-Unit -->
138+
<!-- ++++++++++++++++++++++++++++++++++++++++++ -->
139+
140+
<!-- main target -->
141+
<target name="phpunit" depends="phpunit-full"/>
142+
143+
<!-- create necessary directories -->
144+
<target name="phpunit-prepare">
145+
<mkdir dir="${basedir}/build/phpunit"/>
146+
<mkdir dir="${basedir}/build/coverage"/>
147+
</target>
148+
149+
<!-- run all tests -->
150+
<target name="phpunit-tests">
151+
<exec dir="${basedir}/src/Tests" executable="${basedir}/vendor/bin/phpunit" failonerror="true">
152+
<arg line="--verbose --stderr"/>
153+
<arg line="."/>
154+
</exec>
155+
</target>
156+
157+
<!-- run all tests and generate logs / code coverage -->
158+
<target name="phpunit-full" depends="phpunit-prepare">
159+
<exec dir="${basedir}/src/Tests" executable="${basedir}/vendor/bin/phpunit" failonerror="true">
160+
<arg line="--verbose --stderr"/>
161+
<arg line="--log-junit ${basedir}/build/phpunit/phpunit.xml"/>
162+
<arg line="--coverage-html ${basedir}/build/coverage"/>
163+
<arg line="."/>
164+
</exec>
165+
</target>
166+
167+
<!-- ++++++++++++++++++++++++++++++++++++++++++ -->
168+
<!-- | PHP Lines of Code -->
169+
<!-- ++++++++++++++++++++++++++++++++++++++++++ -->
170+
171+
<!-- create necessary directories -->
172+
<target name="phploc-prepare">
173+
<mkdir dir="${basedir}/build/phploc"/>
174+
</target>
175+
176+
<!-- generate lines of code metric -->
177+
<target name="phploc" depends="phploc-prepare">
178+
<exec dir="${basedir}" executable="${basedir}/vendor/bin/phploc">
179+
<arg value="--log-xml"/>
180+
<arg value="${basedir}/build/phploc/phploc.xml"/>
181+
<arg path="${basedir}/src"/>
182+
</exec>
183+
</target>
184+
185+
<!-- ++++++++++++++++++++++++++++++++++++++++++ -->
186+
<!-- | PHP Copy-Paste-Detector -->
187+
<!-- ++++++++++++++++++++++++++++++++++++++++++ -->
188+
189+
<!-- create necessary directories -->
190+
<target name="phpcpd-prepare">
191+
<mkdir dir="${basedir}/build/phpcpd"/>
192+
</target>
193+
194+
<!-- run copy paste detector -->
195+
<target name="phpcpd" depends="phpcpd-prepare">
196+
<exec dir="${basedir}" executable="${basedir}/vendor/bin/phpcpd">
197+
<arg value="--log-pmd"/>
198+
<arg path="${basedir}/build/phpcpd/phpcpd.xml"/>
199+
<arg path="${basedir}/src"/>
200+
</exec>
201+
</target>
202+
203+
<!-- ++++++++++++++++++++++++++++++++++++++++++ -->
204+
<!-- | PHP Code-Sniffer -->
205+
<!-- ++++++++++++++++++++++++++++++++++++++++++ -->
206+
207+
<!-- create necessary directories -->
208+
<target name="phpcs-prepare">
209+
<mkdir dir="${basedir}/build/phpcs"/>
210+
</target>
211+
212+
<!-- generate code sniffer metric -->
213+
<target name="phpcs" depends="phpcs-prepare">
214+
<exec dir="${basedir}" executable="${basedir}/vendor/bin/phpcs">
215+
<arg value="--standard=PSR2"/>
216+
<arg value="--extensions=php"/>
217+
<arg value="-n"/>
218+
<arg value="--report=checkstyle"/>
219+
<arg value="--report-file=${basedir}/build/phpcs/phpcs-checkstyle.xml"/>
220+
<arg path="${basedir}/src"/>
221+
</exec>
222+
</target>
223+
224+
<!-- ++++++++++++++++++++++++++++++++++++++++++ -->
225+
<!-- | PHP Mess-Detector -->
226+
<!-- ++++++++++++++++++++++++++++++++++++++++++ -->
227+
228+
<!-- create necessary directories -->
229+
<target name="phpmd-prepare">
230+
<mkdir dir="${basedir}/build/phpmd"/>
231+
</target>
232+
233+
<!-- generate mess detector metric -->
234+
<target name="phpmd" depends="phpmd-prepare">
235+
<exec dir="${basedir}" executable="${basedir}/vendor/bin/phpmd">
236+
<arg path="${basedir}/src"/>
237+
<arg value="xml"/>
238+
<arg value="cleancode,codesize,controversial,design,naming,unusedcode"/>
239+
<arg value="--reportfile"/>
240+
<arg value="${basedir}/build/phpmd/phpmd.xml"/>
241+
</exec>
242+
</target>
243+
244+
<!-- ++++++++++++++++++++++++++++++++++++++++++ -->
245+
<!-- | Lint -->
246+
<!-- ++++++++++++++++++++++++++++++++++++++++++ -->
247+
248+
<!-- check syntax of all php files in src/ directory -->
249+
<target name="lint">
250+
<apply executable="php" failonerror="true">
251+
<arg value="-l"/>
252+
<fileset dir="${basedir}">
253+
<include name="**/*.php"/>
254+
<exclude name="**/vendor/**"/>
255+
</fileset>
256+
</apply>
257+
</target>
258+
259+
<!-- ++++++++++++++++++++++++++++++++++++++++++ -->
260+
<!-- | PHP-Doc -->
261+
<!-- ++++++++++++++++++++++++++++++++++++++++++ -->
262+
263+
<!-- create necessary directories -->
264+
<target name="phpdoc-prepare">
265+
<mkdir dir="${basedir}/build/phpdoc"/>
266+
</target>
267+
268+
</project>

0 commit comments

Comments
 (0)