Skip to content

Commit 807e820

Browse files
committed
Initial commit
- Dependencies and testing infrastructure - End-to-end test with empty implementation - License, README, etc
0 parents  commit 807e820

File tree

13 files changed

+511
-0
lines changed

13 files changed

+511
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
build/
2+
vendor/
3+
composer.lock
4+
composer.phar

DEVELOPING.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Developing
2+
3+
- Get the source
4+
5+
$ git clone https://github.com/codeclimate/php-test-reporter
6+
7+
- Install dependencies
8+
9+
$ curl -sS https://getcomposer.org/installer | php
10+
$ php composer.phar install --dev
11+
12+
- Run the tests
13+
14+
$ ./vendor/bin/phpunit
15+
16+
- Submit PRs to https://github.com/codeclimate/php-test-reporter
17+
18+
*Note*: all changes and fixes must have appropriate test coverage.

LICENSE

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Copyright (c) 2014 Code Climate LLC
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.
20+
21+
This package includes code by Kitamura Satoshi, distributed under the MIT license:
22+
23+
Permission is hereby granted, free of charge, to any person obtaining
24+
a copy of this software and associated documentation files (the
25+
"Software"), to deal in the Software without restriction, including
26+
without limitation the rights to use, copy, modify, merge, publish,
27+
distribute, sublicense, and/or sell copies of the Software, and to
28+
permit persons to whom the Software is furnished to do so, subject to
29+
the following conditions:
30+
31+
The above copyright notice and this permission notice shall be
32+
included in all copies or substantial portions of the Software.
33+
34+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
35+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
36+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
37+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
38+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
39+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
40+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# codeclimate-test-reporter
2+
3+
Collects test coverage data from your PHP test suite and sends it to
4+
Code Climate's hosted, automated code review service.
5+
6+
Code Climate - https://codeclimate.com
7+
8+
## Installation
9+
10+
This gem requires a user, but not necessarily a paid account, on Code
11+
Climate, so if you don't have one the first step is to signup at:
12+
https://codeclimate.com. Then:
13+
14+
*TODO*
15+
16+
## Configuration
17+
18+
*TODO*
19+
20+
## Contributions
21+
22+
Patches, bug fixes, feature requests, and pull requests are welcome on
23+
the GitHub page for this project:
24+
25+
https://github.com/codeclimate/php-test-reporter
26+
27+
This package is maintained by Bryan Helmkamp (bryan@codeclimate.com).
28+
29+
## Copyright
30+
31+
See LICENSE.txt
32+
33+
Portions of the implementation were inspired by the php-coveralls
34+
project.

composer.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "codeclimate/php-test-reporter",
3+
"description": "PHP client for reporting test coverage to Code Climate",
4+
"keywords": ["codeclimate", "coverage"],
5+
"homepage": "https://github.com/codeclimate/php-test-reporter",
6+
"type": "library",
7+
"license": "MIT",
8+
"minimum-stability": "stable",
9+
"authors": [
10+
{
11+
"name": "Code Climate",
12+
"email": "hello@codeclimate.com",
13+
"homepage": "https://codeclimate.com"
14+
}
15+
],
16+
"require": {
17+
"php": ">=5.3",
18+
"symfony/console": ">=2.0",
19+
"satooshi/php-coveralls": "dev-master"
20+
},
21+
"require-dev": {
22+
"phpunit/phpunit": "3.7.*@stable"
23+
},
24+
"autoload": {
25+
"psr-0": {
26+
"CodeClimate\\Component": "src/",
27+
"CodeClimate\\Bundle": "src/"
28+
}
29+
},
30+
"bin": ["composer/bin/test-reporter"],
31+
"extra": { }
32+
}

composer/bin/test-reporter

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
$files = array(
5+
__DIR__ . '/../../vendor/autoload.php',
6+
__DIR__ . '/../../../../autoload.php'
7+
);
8+
9+
foreach ($files as $file) {
10+
if (file_exists($file)) {
11+
include_once $file;
12+
13+
define('PHP_TEST_REPORTER_COMPOSER_INSTALL', $file);
14+
15+
break;
16+
}
17+
}
18+
19+
if (!defined('PHP_TEST_REPORTER_COMPOSER_INSTALL')) {
20+
die(
21+
'You need to set up the project dependencies using the following commands:' . PHP_EOL .
22+
'curl -s http://getcomposer.org/installer | php' . PHP_EOL .
23+
'php composer.phar install' . PHP_EOL
24+
);
25+
}
26+
27+
use CodeClimate\Bundle\TestReporterBundle\Version;
28+
use CodeClimate\Bundle\TestReporterBundle\Console\Application;
29+
30+
$rootDir = realpath(dirname(PHP_TEST_REPORTER_COMPOSER_INSTALL) . '/..');
31+
32+
$app = new Application($rootDir, 'Code Climate PHP Test Reporter', Version::VERSION);
33+
$app->run();

phpunit.xml.dist

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<phpunit backupGlobals="false"
4+
backupStaticAttributes="false"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
processIsolation="false"
10+
stopOnFailure="false"
11+
syntaxCheck="false"
12+
bootstrap="tests/bootstrap.php">
13+
<testsuites>
14+
<testsuite name="PHP test reporter test suite">
15+
<directory>./tests/</directory>
16+
</testsuite>
17+
</testsuites>
18+
19+
<filter>
20+
<whitelist>
21+
<directory>./src</directory>
22+
<exclude>
23+
<directory>./composer</directory>
24+
<directory>./tests</directory>
25+
<directory>./vendor</directory>
26+
</exclude>
27+
</whitelist>
28+
</filter>
29+
</phpunit>
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
namespace CodeClimate\Bundle\TestReporterBundle\Command;
3+
4+
/* use Satooshi\Bundle\CoverallsV1Bundle\Api\Jobs; */
5+
/* use Satooshi\Bundle\CoverallsV1Bundle\Config\Configuration; */
6+
/* use Satooshi\Bundle\CoverallsV1Bundle\Config\Configurator; */
7+
/* use Satooshi\Bundle\CoverallsV1Bundle\Repository\JobsRepository; */
8+
/* use Satooshi\Component\Log\ConsoleLogger; */
9+
/* use Guzzle\Http\Client; */
10+
/* use Psr\Log\NullLogger; */
11+
use Symfony\Component\Console\Command\Command;
12+
use Symfony\Component\Console\Input\InputInterface;
13+
/* use Symfony\Component\Console\Input\InputOption; */
14+
use Symfony\Component\Console\Output\OutputInterface;
15+
16+
/**
17+
* Test reporter command
18+
*/
19+
class TestReporterCommand extends Command
20+
{
21+
/**
22+
* Path to project root directory.
23+
*
24+
* @var string
25+
*/
26+
protected $rootDir;
27+
28+
/**
29+
* {@inheritdoc}
30+
*
31+
* @see \Symfony\Component\Console\Command\Command::configure()
32+
*/
33+
protected function configure()
34+
{
35+
$this
36+
->setName('test-reporter')
37+
->setDescription('Code Climate PHP Test Reporter');
38+
}
39+
40+
/**
41+
* {@inheritdoc}
42+
*
43+
* @see \Symfony\Component\Console\Command\Command::execute()
44+
*/
45+
protected function execute(InputInterface $input, OutputInterface $output)
46+
{
47+
// TODO: Parse clover.xml -> Upload to API
48+
49+
return 0;
50+
}
51+
52+
// accessor
53+
54+
/**
55+
* Set root directory.
56+
*
57+
* @param string $rootDir Path to project root directory.
58+
*
59+
* @return void
60+
*/
61+
public function setRootDir($rootDir)
62+
{
63+
$this->rootDir = $rootDir;
64+
}
65+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?php
2+
namespace CodeClimate\Bundle\TestReporterBundle\Console;
3+
4+
use CodeClimate\Bundle\TestReporterBundle\Command\TestReporterCommand;
5+
use Symfony\Component\Console\Application as BaseApplication;
6+
use Symfony\Component\Console\Input\InputInterface;
7+
8+
/**
9+
* Coveralls API application.
10+
*
11+
* @author Kitamura Satoshi <with.no.parachute@gmail.com>
12+
*/
13+
class Application extends BaseApplication
14+
{
15+
/**
16+
* Path to project root directory.
17+
*
18+
* @var string
19+
*/
20+
private $rootDir;
21+
22+
/**
23+
* Constructor.
24+
*
25+
* @param string $rootDir Path to project root directory.
26+
* @param string $name The name of the application
27+
* @param string $version The version of the application
28+
*/
29+
public function __construct($rootDir, $name = 'UNKNOWN', $version = 'UNKNOWN')
30+
{
31+
$this->rootDir = $rootDir;
32+
33+
parent::__construct($name, $version);
34+
}
35+
36+
// internal method
37+
38+
/**
39+
* {@inheritdoc}
40+
*
41+
* @see \Symfony\Component\Console\Application::getCommandName()
42+
*/
43+
protected function getCommandName(InputInterface $input)
44+
{
45+
return 'test-reporter';
46+
}
47+
48+
/**
49+
* {@inheritdoc}
50+
*
51+
* @see \Symfony\Component\Console\Application::getDefaultCommands()
52+
*/
53+
protected function getDefaultCommands()
54+
{
55+
// Keep the core default commands to have the HelpCommand
56+
// which is used when using the --help option
57+
$defaultCommands = parent::getDefaultCommands();
58+
$defaultCommands[] = $this->createTestReporterCommand();
59+
60+
return $defaultCommands;
61+
}
62+
63+
/**
64+
* Create TestReporterCommand.
65+
*
66+
* @return \CodeClimate\Bundle\TestReporterBundle\Command\TestReporterCommand
67+
*/
68+
protected function createTestReporterCommand()
69+
{
70+
$command = new TestReporterCommand();
71+
$command->setRootDir($this->rootDir);
72+
73+
return $command;
74+
}
75+
76+
// accessor
77+
78+
/**
79+
* {@inheritdoc}
80+
*
81+
* @see \Symfony\Component\Console\Application::getDefinition()
82+
*/
83+
public function getDefinition()
84+
{
85+
$inputDefinition = parent::getDefinition();
86+
// clear out the normal first argument, which is the command name
87+
$inputDefinition->setArguments();
88+
89+
return $inputDefinition;
90+
}
91+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
namespace CodeClimate\Bundle\TestReporterBundle;
3+
4+
/**
5+
* TestReporterBundle version.
6+
*/
7+
final class Version
8+
{
9+
/**
10+
* TestReporter version.
11+
*
12+
* @var string
13+
*/
14+
const VERSION = '0.1.0-dev';
15+
}

0 commit comments

Comments
 (0)