Skip to content

Commit fdeff23

Browse files
author
Jonathan Gaillard
committed
Merge pull request #27 from nubs/master
Update build scripts to use phpunit/phpcs as a library and more.
2 parents c6d7a86 + 9d5daca commit fdeff23

8 files changed

Lines changed: 175 additions & 70 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
/clover.xml
22
/vendor
3-
*~
43
/coverage/

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ ADD provisioning/set-env.sh /set-env.sh
1010
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
1111

1212
VOLUME ["/code"]
13+
WORKDIR /code
1314

1415
ENTRYPOINT ["/set-env.sh"]
1516
CMD ["/code/build.php"]

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#mongo-queue-php
2-
[![Build Status](https://travis-ci.org/dominionenterprises/mongo-queue-php.png)](https://travis-ci.org/dominionenterprises/mongo-queue-php)
2+
[![Build Status](http://img.shields.io/travis/dominionenterprises/mongo-queue-php.svg?style=flat)](https://travis-ci.org/dominionenterprises/mongo-queue-php)
3+
[![Latest Stable Version](http://img.shields.io/packagist/v/dominionenterprises/mongo-queue-php.svg?style=flat)](https://packagist.org/packages/dominionenterprises/mongo-queue-php)
4+
[![Total Downloads](http://img.shields.io/packagist/dt/dominionenterprises/mongo-queue-php.svg?style=flat)](https://packagist.org/packages/dominionenterprises/mongo-queue-php)
5+
[![License](http://img.shields.io/packagist/l/dominionenterprises/mongo-queue-php.svg?style=flat)](https://packagist.org/packages/dominionenterprises/mongo-queue-php)
36

47
PHP message queue using MongoDB as a backend.
58
Adheres to the 1.0.0 [specification](https://github.com/dominionenterprises/mongo-queue-specification).

build.php

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,37 @@
33
chdir(__DIR__);
44

55
$returnStatus = null;
6-
passthru('composer install --dev', $returnStatus);
6+
passthru('composer install', $returnStatus);
77
if ($returnStatus !== 0) {
88
exit(1);
99
}
1010

11-
passthru('./vendor/bin/phpcs --standard=' . __DIR__ . '/vendor/dominionenterprises/dws-coding-standard/DWS -n src tests *.php', $returnStatus);
12-
if ($returnStatus !== 0) {
11+
require 'vendor/autoload.php';
12+
13+
$phpcsCLI = new PHP_CodeSniffer_CLI();
14+
$phpcsArguments = array(
15+
'standard' => array(__DIR__ . '/vendor/dominionenterprises/dws-coding-standard/DWS'),
16+
'files' => array('src', 'tests', 'build.php'),
17+
'warningSeverity' => 0,
18+
);
19+
$phpcsViolations = $phpcsCLI->process($phpcsArguments);
20+
if ($phpcsViolations > 0) {
1321
exit(1);
1422
}
1523

16-
passthru('vendor/bin/phpunit --coverage-html coverage --coverage-clover clover.xml tests', $returnStatus);
17-
if ($returnStatus !== 0) {
24+
$phpunitConfiguration = PHPUnit_Util_Configuration::getInstance(__DIR__ . '/phpunit.xml');
25+
$phpunitArguments = array('coverageHtml' => __DIR__ . '/coverage', 'configuration' => $phpunitConfiguration);
26+
$testRunner = new PHPUnit_TextUI_TestRunner();
27+
$result = $testRunner->doRun($phpunitConfiguration->getTestSuiteConfiguration(), $phpunitArguments);
28+
if (!$result->wasSuccessful()) {
1829
exit(1);
1930
}
2031

21-
$xml = new SimpleXMLElement(file_get_contents('clover.xml'));
22-
foreach ($xml->xpath('//file/metrics') as $metric) {
23-
if ((int)$metric['elements'] !== (int)$metric['coveredelements']) {
24-
file_put_contents('php://stderr', "Code coverage was NOT 100%\n");
25-
exit(1);
26-
}
32+
$coverageFactory = new PHP_CodeCoverage_Report_Factory();
33+
$coverageReport = $coverageFactory->create($result->getCodeCoverage());
34+
if ($coverageReport->getNumExecutedLines() !== $coverageReport->getNumExecutableLines()) {
35+
file_put_contents('php://stderr', "Code coverage was NOT 100%\n");
36+
exit(1);
2737
}
2838

2939
echo "Code coverage was 100%\n";

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
},
2727
"require-dev": {
2828
"dominionenterprises/dws-coding-standard": "~1.1",
29-
"phpunit/phpunit": "~4.0",
30-
"lib-libxml": "*"
29+
"phpunit/phpunit": "~4.0"
3130
},
3231
"autoload": {
3332
"psr-4": { "DominionEnterprises\\Mongo\\": "src/" }

0 commit comments

Comments
 (0)