Skip to content

Commit 3a79bcf

Browse files
committed
- change directory structure
- add .travis.yml - add build file (phing)
1 parent cff3aca commit 3a79bcf

23 files changed

+279
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.idea
22

3+
build
34
composer.lock
45
vendor

.travis.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
language: php
2+
php:
3+
- 5.5
4+
- 5.6
5+
- 7.0
6+
before_script:
7+
- echo \{\"http-basic\":\{\"repo.magento.com\":\{\"username\":\"${REPO_MAGENTO_PUBLIC}\",\"password\":\"${REPO_MAGENTO_PRIVATE}\"\}\},\"github-oauth\":\{\"github.com\":\"${GITHUB_TOKEN}\"\}\} > ~/.composer/auth.json
8+
- composer install
9+
script:
10+
- vendor/bin/phing
11+
after_script:
12+
- vendor/bin/coveralls -v

build.xml

Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<project name="DR_PaymentMethodFilter" default="full-build" basedir=".">
3+
<property name="builddir" value="${project.basedir}/build" override="true"/>
4+
<property name="srcdir" value="${project.basedir}/src" override="true"/>
5+
<property name="testdir" value="${project.basedir}/src" override="true"/>
6+
<property name="vendordir" value="${project.basedir}/vendor" override="true"/>
7+
8+
<property name="pdepend" value="${vendordir}/bin/pdepend"/>
9+
<property name="phpcpd" value="${vendordir}/bin/phpcpd"/>
10+
<property name="phpcs" value="${vendordir}/bin/phpcs"/>
11+
<property name="phploc" value="${vendordir}/bin/phploc"/>
12+
<property name="phpmd" value="${vendordir}/bin/phpmd"/>
13+
<property name="phpunit" value="${vendordir}/bin/phpunit"/>
14+
15+
<target name="full-build"
16+
depends="prepare,static-analysis,phpunit,-check-failure"
17+
description="Performs static analysis, runs the tests, and generates project documentation"/>
18+
19+
<target name="full-build-parallel"
20+
depends="prepare,static-analysis-parallel,phpunit,-check-failure"
21+
description="Performs static analysis (executing the tools in parallel), runs the tests, and generates project documentation"/>
22+
23+
<target name="quick-build"
24+
depends="prepare,lint,phpunit-no-coverage"
25+
description="Performs a lint check and runs the tests (without generating code coverage reports)"/>
26+
27+
<target name="static-analysis"
28+
depends="lint,phploc-ci,pdepend,phpmd-ci,phpcs-ci,phpcpd-ci"
29+
description="Performs static analysis"/>
30+
31+
<target name="static-analysis-parallel"
32+
description="Performs static analysis (executing the tools in parallel)">
33+
<parallel threadCount="2">
34+
<sequential>
35+
<phingcall target="pdepend"/>
36+
<phingcall target="phpmd-ci"/>
37+
</sequential>
38+
<phingcall target="lint"/>
39+
<phingcall target="phpcpd-ci"/>
40+
<phingcall target="phpcs-ci"/>
41+
<phingcall target="phploc-ci"/>
42+
</parallel>
43+
</target>
44+
45+
<target name="clean" unless="clean.done" description="Cleanup build artifacts">
46+
<delete dir="${builddir}/api"/>
47+
<delete dir="${builddir}/coverage"/>
48+
<delete dir="${builddir}/logs"/>
49+
<delete dir="${builddir}/pdepend"/>
50+
<property name="clean.done" value="true"/>
51+
</target>
52+
53+
<target name="prepare" unless="prepare.done" depends="clean" description="Prepare for build">
54+
<mkdir dir="${builddir}/api"/>
55+
<mkdir dir="${builddir}/coverage"/>
56+
<mkdir dir="${builddir}/logs"/>
57+
<mkdir dir="${builddir}/pdepend"/>
58+
<property name="prepare.done" value="true"/>
59+
</target>
60+
61+
<target name="lint" unless="lint.done" description="Perform syntax check of sourcecode files">
62+
<apply executable="php" checkreturn="true">
63+
<arg value="-l"/>
64+
65+
<fileset dir="${srcdir}">
66+
<include name="**/*.php"/>
67+
</fileset>
68+
69+
<fileset dir="${testdir}">
70+
<include name="**/*.php"/>
71+
</fileset>
72+
</apply>
73+
74+
<property name="lint.done" value="true"/>
75+
</target>
76+
77+
<target name="phploc" unless="phploc.done"
78+
description="Measure project size using PHPLOC and print human readable output. Intended for usage on the command line.">
79+
<exec executable="${phploc}">
80+
<arg value="--count-tests"/>
81+
<arg path="${srcdir}"/>
82+
<arg path="${testdir}"/>
83+
</exec>
84+
85+
<property name="phploc.done" value="true"/>
86+
</target>
87+
88+
<target name="phploc-ci" unless="phploc.done" depends="prepare"
89+
description="Measure project size using PHPLOC and log result in CSV and XML format. Intended for usage within a continuous integration environment.">
90+
<exec executable="${phploc}">
91+
<arg value="--count-tests"/>
92+
<arg value="--log-csv"/>
93+
<arg path="${builddir}/logs/phploc.csv"/>
94+
<arg value="--log-xml"/>
95+
<arg path="${builddir}/logs/phploc.xml"/>
96+
<arg path="${srcdir}"/>
97+
<arg path="${testdir}"/>
98+
</exec>
99+
100+
<property name="phploc.done" value="true"/>
101+
</target>
102+
103+
<target name="pdepend" unless="pdepend.done" depends="prepare"
104+
description="Calculate software metrics using PHP_Depend and log result in XML format. Intended for usage within a continuous integration environment.">
105+
<exec executable="${pdepend}">
106+
<arg value="--jdepend-xml=${builddir}/logs/jdepend.xml"/>
107+
<arg value="--jdepend-chart=${builddir}/pdepend/dependencies.svg"/>
108+
<arg value="--overview-pyramid=${builddir}/pdepend/overview-pyramid.svg"/>
109+
<arg path="${srcdir}"/>
110+
</exec>
111+
112+
<property name="pdepend.done" value="true"/>
113+
</target>
114+
115+
<target name="phpmd" unless="phpmd.done"
116+
description="Perform project mess detection using PHPMD and print human readable output. Intended for usage on the command line before committing.">
117+
<exec executable="${phpmd}">
118+
<arg path="${srcdir}"/>
119+
<arg value="text"/>
120+
<arg path="${builddir}/phpmd.xml"/>
121+
</exec>
122+
123+
<property name="phpmd.done" value="true"/>
124+
</target>
125+
126+
<target name="phpmd-ci" unless="phpmd.done" depends="prepare"
127+
description="Perform project mess detection using PHPMD and log result in XML format. Intended for usage within a continuous integration environment.">
128+
<exec executable="${phpmd}">
129+
<arg path="${srcdir}"/>
130+
<arg value="xml"/>
131+
<arg path="${builddir}/phpmd.xml"/>
132+
<arg value="--reportfile"/>
133+
<arg path="${builddir}/logs/pmd.xml"/>
134+
</exec>
135+
136+
<property name="phpmd.done" value="true"/>
137+
</target>
138+
139+
<target name="phpcs" unless="phpcs.done"
140+
description="Find coding standard violations using PHP_CodeSniffer and print human readable output. Intended for usage on the command line before committing.">
141+
<exec executable="${phpcs}">
142+
<arg value="--standard=PSR2"/>
143+
<arg value="--extensions=php"/>
144+
<arg path="${srcdir}"/>
145+
<arg path="${testdir}"/>
146+
</exec>
147+
148+
<property name="phpcs.done" value="true"/>
149+
</target>
150+
151+
<target name="phpcs-ci" unless="phpcs.done" depends="prepare"
152+
description="Find coding standard violations using PHP_CodeSniffer and log result in XML format. Intended for usage within a continuous integration environment.">
153+
<exec executable="${phpcs}" output="/dev/null">
154+
<arg value="--report=checkstyle"/>
155+
<arg value="--report-file=${builddir}/logs/checkstyle.xml"/>
156+
<arg value="--standard=PSR2"/>
157+
<arg value="--extensions=php"/>
158+
<arg value="--ignore=autoload.php"/>
159+
<arg path="${srcdir}"/>
160+
<arg path="${testdir}"/>
161+
</exec>
162+
163+
<property name="phpcs.done" value="true"/>
164+
</target>
165+
166+
<target name="phpcpd" unless="phpcpd.done"
167+
description="Find duplicate code using PHPCPD and print human readable output. Intended for usage on the command line before committing.">
168+
<exec executable="${phpcpd}">
169+
<arg path="${srcdir}"/>
170+
</exec>
171+
172+
<property name="phpcpd.done" value="true"/>
173+
</target>
174+
175+
<target name="phpcpd-ci" unless="phpcpd.done" depends="prepare"
176+
description="Find duplicate code using PHPCPD and log result in XML format. Intended for usage within a continuous integration environment.">
177+
<exec executable="${phpcpd}">
178+
<arg value="--log-pmd"/>
179+
<arg path="${builddir}/logs/pmd-cpd.xml"/>
180+
<arg path="${srcdir}"/>
181+
</exec>
182+
183+
<property name="phpcpd.done" value="true"/>
184+
</target>
185+
186+
<target name="phpunit" unless="phpunit.done" depends="prepare" description="Run unit tests with PHPUnit">
187+
<exec executable="${phpunit}" returnProperty="result.phpunit">
188+
<arg value="--configuration"/>
189+
<arg path="${project.basedir}/phpunit.xml.dist"/>
190+
</exec>
191+
192+
<property name="phpunit.done" value="true"/>
193+
</target>
194+
195+
<target name="phpunit-no-coverage" unless="phpunit.done" depends="prepare"
196+
description="Run unit tests with PHPUnit (without generating code coverage reports)">
197+
<exec executable="${phpunit}" checkreturn="true">
198+
<arg value="--configuration"/>
199+
<arg path="${project.basedir}/phpunit.xml.dist"/>
200+
<arg value="--no-coverage"/>
201+
</exec>
202+
203+
<property name="phpunit.done" value="true"/>
204+
</target>
205+
206+
<target name="-check-failure">
207+
<if>
208+
<isfailure code="${result.phpunit}"/>
209+
<then>
210+
<fail message="PHPUnit did not finish successfully"/>
211+
</then>
212+
</if>
213+
</target>
214+
</project>

composer.json

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
{
22
"name": "dr/payment-method-filter",
33
"description": "This module excludes payment methods from checkout by using filters.",
4+
"authors": [
5+
{
6+
"name": "Daniel Rose",
7+
"email": "[email protected]"
8+
}
9+
],
410
"type": "magento2-module",
511
"repositories": [
612
{
@@ -12,8 +18,14 @@
1218
"magento/module-payment": "100.0.*"
1319
},
1420
"require-dev": {
15-
"phpunit/phpunit": "5.3.*",
16-
"squizlabs/php_codesniffer": "2.6.*",
21+
"phpunit/phpunit": "4.1.0",
22+
"squizlabs/php_codesniffer": "1.5.3",
23+
"phpmd/phpmd": "@stable",
24+
"pdepend/pdepend": "2.2.2",
25+
"sebastian/phpcpd": "2.0.0",
26+
"zendframework/zend-http": "~2.4.6",
27+
"phing/phing": "@stable",
28+
"satooshi/php-coveralls": "@stable",
1729
"magento/module-offline-payments": "100.0.*"
1830
},
1931
"license": "MIT",
@@ -23,10 +35,15 @@
2335
],
2436
"autoload": {
2537
"files": [
26-
"registration.php"
38+
"src/registration.php"
2739
],
2840
"psr-4": {
29-
"DR\\PaymentMethodFilter\\": ""
41+
"DR\\PaymentMethodFilter\\": "src"
42+
}
43+
},
44+
"autoload-dev": {
45+
"psr-4": {
46+
"DR\\PaymentMethodFilter\\Test\\": "tests"
3047
}
3148
}
3249
}

phpunit.xml.dist

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
4+
bootstrap="./tests/Unit/bootstrap.php"
5+
backupGlobals="false"
6+
backupStaticAttributes="false"
7+
strict="true"
8+
verbose="true">
9+
<testsuites>
10+
<testsuite name="Unit Tests">
11+
<directory suffix="Test.php">tests/Unit/</directory>
12+
</testsuite>
13+
</testsuites>
14+
15+
<logging>
16+
<log type="coverage-html" target="./build/coverage"/>
17+
<log type="coverage-clover" target="./build/logs/clover.xml"/>
18+
<log type="coverage-crap4j" target="./build/logs/crap4j.xml"/>
19+
<log type="junit" target="./build/logs/junit.xml" logIncompleteSkipped="false"/>
20+
</logging>
21+
22+
<filter>
23+
<whitelist addUncoveredFilesFromWhitelist="true">
24+
<directory suffix=".php">src</directory>
25+
<exclude>
26+
<directory>test</directory>
27+
<directory>vendor</directory>
28+
</exclude>
29+
</whitelist>
30+
</filter>
31+
</phpunit>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)