Skip to content

Commit 25e2747

Browse files
committed
init
0 parents  commit 25e2747

File tree

9 files changed

+283
-0
lines changed

9 files changed

+283
-0
lines changed

Source/Autoload.php

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
spl_autoload_register(function ( $class ) {
4+
5+
$parts = explode('\\', $class);
6+
$root = __DIR__ . DIRECTORY_SEPARATOR . 'Vendor';
7+
8+
if('Test' === $parts[0]) {
9+
10+
$root = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'Test' .
11+
DIRECTORY_SEPARATOR . 'Vendor';
12+
array_shift($parts);
13+
}
14+
15+
$path = $root . DIRECTORY_SEPARATOR .
16+
implode(DIRECTORY_SEPARATOR, $parts) . '.php';
17+
18+
if(false === file_exists($path))
19+
return false;
20+
21+
require_once $path;
22+
23+
return true;
24+
});

Test/.atoum.php

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
$xunit = new atoum\reports\asynchronous\xunit();
4+
$clover = new atoum\reports\asynchronous\clover();
5+
$runner->addReport($xunit);
6+
$runner->addReport($clover);
7+
8+
$report = $script->addDefaultReport();
9+
$runner->setBootstrapFile(__DIR__ . DIRECTORY_SEPARATOR . '.bootstrap.atoum.php');
10+
$runner->addTestsFromDirectory(__DIR__ . DIRECTORY_SEPARATOR);
11+
12+
$writer = new atoum\writers\file('build/logs/xunit.xml');
13+
$writer1 = new atoum\writers\file('../atoum.xunit.xml');
14+
$writer2 = new atoum\writers\file('../atoum.coverage.xml');
15+
$writer3 = new atoum\writers\file('build/logs/clover.xml');
16+
$xunit->addWriter($writer);
17+
$xunit->addWriter($writer1);
18+
$clover->addWriter($writer2);
19+
$clover->addWriter($writer3);
20+
?>

Test/.bootstrap.atoum.php

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
require_once '/usr/local/lib/Hoa/Core/Core.php';
4+
5+
// Autoloader.
6+
require __DIR__ .
7+
DIRECTORY_SEPARATOR .
8+
'..' .
9+
DIRECTORY_SEPARATOR .
10+
'Source' .
11+
DIRECTORY_SEPARATOR .
12+
'Autoload.php';
13+
14+
// Test.php
15+
require __DIR__ .
16+
DIRECTORY_SEPARATOR .
17+
'Test.php';

Test/Test.php

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
abstract class Test extends \atoum\test {
4+
5+
public function __construct ( \atoum\score $score = null,
6+
\atoum\locale $locale = null,
7+
\atoum\adapter $adapter = null ) {
8+
9+
$this->setTestNamespace('\\Test');
10+
11+
return parent::__construct($score, $locale, $adapter);
12+
}
13+
}

build.xml

+138
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project name="name-of-project" default="build">
4+
<target name="build"
5+
depends="prepare,lint,atoum,phploc,pdepend,phpmd-ci,phpcs-ci,phpcpd,phpdox,phpcb"/>
6+
7+
<target name="build-parallel"
8+
depends="prepare,lint,tools-parallel,phpcb"/>
9+
10+
<target name="tools-parallel" description="Run tools in parallel">
11+
<parallel threadCount="2">
12+
<sequential>
13+
<antcall target="pdepend"/>
14+
<antcall target="phpmd-ci"/>
15+
</sequential>
16+
<antcall target="phpcpd"/>
17+
<antcall target="phpcs-ci"/>
18+
<antcall target="phploc"/>
19+
<antcall target="phpdox"/>
20+
</parallel>
21+
</target>
22+
23+
<target name="clean" description="Cleanup build artifacts">
24+
<delete dir="${basedir}/build/api"/>
25+
<delete dir="${basedir}/build/code-browser"/>
26+
<delete dir="${basedir}/build/coverage"/>
27+
<delete dir="${basedir}/build/logs"/>
28+
<delete dir="${basedir}/build/pdepend"/>
29+
</target>
30+
31+
<target name="prepare" depends="clean" description="Prepare for build">
32+
<mkdir dir="${basedir}/build/api"/>
33+
<mkdir dir="${basedir}/build/code-browser"/>
34+
<mkdir dir="${basedir}/build/coverage"/>
35+
<mkdir dir="${basedir}/build/logs"/>
36+
<mkdir dir="${basedir}/build/pdepend"/>
37+
<mkdir dir="${basedir}/build/phpdox"/>
38+
</target>
39+
40+
<target name="lint" description="Perform syntax check of sourcecode files">
41+
<apply executable="php" failonerror="true">
42+
<arg value="-l" />
43+
44+
<fileset dir="${basedir}/Source">
45+
<include name="**/*.php" />
46+
<modified />
47+
</fileset>
48+
49+
<fileset dir="${basedir}/Test">
50+
<include name="**/*.php" />
51+
<modified />
52+
</fileset>
53+
</apply>
54+
</target>
55+
56+
<target name="phploc" description="Measure project size using PHPLOC">
57+
<exec executable="phploc">
58+
<arg value="--log-csv" />
59+
<arg value="${basedir}/build/logs/phploc.csv" />
60+
<arg path="${basedir}/Source" />
61+
</exec>
62+
</target>
63+
64+
<target name="atoum" description="Test unitaire">
65+
<exec executable="atoum">
66+
<arg line="-c ${basedir}/Test/.atoum.php" />
67+
<arg line="-d ${basedir}/Test/" />
68+
</exec>
69+
</target>
70+
71+
<target name="pdepend" description="Calculate software metrics using PHP_Depend">
72+
<exec executable="pdepend">
73+
<arg value="--jdepend-xml=${basedir}/build/logs/jdepend.xml" />
74+
<arg value="--jdepend-chart=${basedir}/build/pdepend/dependencies.svg" />
75+
<arg value="--overview-pyramid=${basedir}/build/pdepend/overview-pyramid.svg" />
76+
<arg path="${basedir}/Source" />
77+
</exec>
78+
</target>
79+
80+
<target name="phpmd"
81+
description="Perform project mess detection using PHPMD and print human readable output. Intended for usage on the command line before committing.">
82+
<exec executable="phpmd">
83+
<arg path="${basedir}/Source" />
84+
<arg value="text" />
85+
<arg value="${basedir}/build/phpmd.xml" />
86+
</exec>
87+
</target>
88+
89+
<target name="phpmd-ci" description="Perform project mess detection using PHPMD creating a log file for the continuous integration server">
90+
<exec executable="phpmd">
91+
<arg path="${basedir}/Source" />
92+
<arg value="xml" />
93+
<arg value="${basedir}/build/phpmd.xml" />
94+
<arg value="--reportfile" />
95+
<arg value="${basedir}/build/logs/pmd.xml" />
96+
</exec>
97+
</target>
98+
99+
<target name="phpcs"
100+
description="Find coding standard violations using PHP_CodeSniffer and print human readable output. Intended for usage on the command line before committing.">
101+
<exec executable="phpcs">
102+
<arg value="--standard=${basedir}/build/phpcs.xml" />
103+
<arg path="${basedir}/Source" />
104+
</exec>
105+
</target>
106+
107+
<target name="phpcs-ci" description="Find coding standard violations using PHP_CodeSniffer creating a log file for the continuous integration server">
108+
<exec executable="phpcs" output="/dev/null">
109+
<arg value="--report=checkstyle" />
110+
<arg value="--report-file=${basedir}/build/logs/checkstyle.xml" />
111+
<arg value="--standard=${basedir}/build/phpcs.xml" />
112+
<arg path="${basedir}/Source" />
113+
</exec>
114+
</target>
115+
116+
<target name="phpcpd" description="Find duplicate code using PHPCPD">
117+
<exec executable="phpcpd">
118+
<arg value="--log-pmd" />
119+
<arg value="${basedir}/build/logs/pmd-cpd.xml" />
120+
<arg path="${basedir}/Source" />
121+
</exec>
122+
</target>
123+
124+
<target name="phpdox" description="Generate API documentation using phpDox">
125+
<exec executable="phpdox"/>
126+
</target>
127+
128+
<target name="phpcb" description="Aggregate tool output with PHP_CodeBrowser">
129+
<exec executable="phpcb">
130+
<arg value="--log" />
131+
<arg path="${basedir}/build/logs" />
132+
<arg value="--source" />
133+
<arg path="${basedir}/Source" />
134+
<arg value="--output" />
135+
<arg path="${basedir}/build/code-browser" />
136+
</exec>
137+
</target>
138+
</project>

build/phpcs.xml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="MyRuleset">
3+
<description>My rule set for PHP_CodeSniffer</description>
4+
5+
<rule ref="Generic.Functions.OpeningFunctionBraceBsdAllman"/>
6+
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
7+
<rule ref="Generic.WhiteSpace.ScopeIndent"/>
8+
</ruleset>

build/phpmd.xml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0"?>
2+
3+
<ruleset name="MyRuleset"
4+
xmlns="http://pmd.sf.net/ruleset/1.0.0"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
7+
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
8+
<description>My rule set for PHPMD</description>
9+
10+
<rule ref="rulesets/codesize.xml/CyclomaticComplexity" />
11+
<rule ref="rulesets/codesize.xml/NPathComplexity" />
12+
13+
<rule ref="rulesets/design.xml/EvalExpression" />
14+
<rule ref="rulesets/design.xml/ExitExpression" />
15+
<rule ref="rulesets/design.xml/GotoStatement" />
16+
17+
<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter" />
18+
<rule ref="rulesets/unusedcode.xml/UnusedLocalVariable" />
19+
<rule ref="rulesets/unusedcode.xml/UnusedPrivateField" />
20+
<rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod" />
21+
</ruleset>

phpdox.xml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<phpdox xmlns="http://phpdox.de/config">
2+
<project name="name-of-project" source="Source" workdir="build/phpdox">
3+
<collector publiconly="false">
4+
<include mask="*.php" />
5+
<exclude mask="*Autoload.php" />
6+
</collector>
7+
8+
<generator output="build">
9+
<build engine="html" enabled="true" output="api"/>
10+
</generator>
11+
</project>
12+
</phpdox>

pom.xml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>unitestor</groupId>
4+
<artifactId>unitestor.php</artifactId>
5+
<version>1.0-SNAPSHOT</version>
6+
<build>
7+
<plugins>
8+
<plugin>
9+
<artifactId>exec-maven-plugin</artifactId>
10+
<groupId>org.codehaus.mojo</groupId>
11+
<executions>
12+
<execution>
13+
<goals>
14+
<goal>exec</goal>
15+
</goals>
16+
</execution>
17+
</executions>
18+
<configuration>
19+
<executable>atoum</executable>
20+
<arguments>
21+
<argument>-d</argument>
22+
<argument>${basedir}/Test/</argument>
23+
<argument>-c</argument>
24+
<argument>${basedir}/Test/.atoum.php</argument>
25+
</arguments>
26+
</configuration>
27+
</plugin>
28+
</plugins>
29+
</build>
30+
</project>

0 commit comments

Comments
 (0)