Skip to content

Commit f259c0e

Browse files
committed
First commit.
0 parents  commit f259c0e

26 files changed

+4225
-0
lines changed

.gitattributes

Whitespace-only changes.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/vendor
2+
/.phpcs-cache
3+

.scrutinizer.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
build:
2+
nodes:
3+
analysis:
4+
environment:
5+
php:
6+
version: 7.1
7+
cache:
8+
disabled: false
9+
directories:
10+
- ~/.composer/cache
11+
project_setup:
12+
override: true
13+
tests:
14+
override:
15+
- php-scrutinizer-run
16+
- phpcs-run
17+
dependencies:
18+
override:
19+
- composer install --ignore-platform-reqs --no-interaction
20+
21+
tools:
22+
external_code_coverage:
23+
timeout: 600
24+
25+
build_failure_conditions:
26+
- 'elements.rating(<= C).new.exists' # No new classes/methods with a rating of C or worse allowed
27+
- 'issues.label("coding-style").new.exists' # No new coding style issues allowed
28+
- 'issues.severity(>= MAJOR).new.exists' # New issues of major or higher severity
29+
- 'project.metric_change("scrutinizer.test_coverage", < 0)' # Code Coverage decreased from previous inspection

.travis.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
dist: trusty
2+
sudo: false
3+
language: php
4+
5+
php:
6+
- 7.1
7+
- 7.2
8+
- nightly
9+
10+
cache:
11+
directories:
12+
- $HOME/.composer/cache
13+
14+
before_install:
15+
- mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{,.disabled} || echo "xdebug not available"
16+
17+
install:
18+
- rm composer.lock
19+
- travis_retry composer update --prefer-dist
20+
21+
script:
22+
- ./vendor/bin/phpunit
23+
24+
jobs:
25+
allow_failures:
26+
- php: nightly
27+
28+
include:
29+
- stage: Test
30+
env: DEPENDENCIES=low
31+
install:
32+
- rm composer.lock
33+
- travis_retry composer update --prefer-dist --prefer-lowest
34+
35+
- stage: Test
36+
env: COVERAGE
37+
before_script:
38+
- mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{.disabled,}
39+
- if [[ ! $(php -m | grep -si xdebug) ]]; then echo "xdebug required for coverage"; exit 1; fi
40+
script:
41+
- ./vendor/bin/phpunit --coverage-clover clover.xml
42+
after_script:
43+
- wget https://scrutinizer-ci.com/ocular.phar
44+
- php ocular.phar code-coverage:upload --format=php-clover clover.xml
45+
46+
- stage: Code Quality
47+
env: CODING_STANDARDS
48+
install: travis_retry composer install --prefer-dist
49+
script: ./vendor/bin/phpcs
50+
51+
- stage: Code Quality
52+
env: STATIC_ANALYSIS
53+
install: travis_retry composer install --prefer-dist
54+
script: vendor/bin/phpstan analyse

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2018 Jonathan H. Wage
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of
4+
this software and associated documentation files (the "Software"), to deal in
5+
the Software without restriction, including without limitation the rights to
6+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7+
of the Software, and to permit persons to whom the Software is furnished to do
8+
so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
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 THE
19+
SOFTWARE.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# PHPUnit Test Generator

bin/generate-unit-test

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
declare(strict_types=1);
5+
6+
namespace JWage\PHPUnitTestGenerator;
7+
8+
require __DIR__ . '/generate-unit-test.php';

bin/generate-unit-test.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace JWage\PHPUnitTestGenerator;
6+
7+
use JWage\PHPUnitTestGenerator\Command\GenerateTestClassCommand;
8+
use Symfony\Component\Console\Application;
9+
use const PHP_EOL;
10+
use function extension_loaded;
11+
use function file_exists;
12+
13+
(static function () : void {
14+
$autoloadFiles = [
15+
__DIR__ . '/../vendor/autoload.php',
16+
__DIR__ . '/../../../autoload.php',
17+
];
18+
19+
$autoloaderFound = false;
20+
21+
foreach ($autoloadFiles as $autoloadFile) {
22+
if (! file_exists($autoloadFile)) {
23+
continue;
24+
}
25+
26+
require_once $autoloadFile;
27+
$autoloaderFound = true;
28+
}
29+
30+
if (! $autoloaderFound) {
31+
if (extension_loaded('phar') && Phar::running() !== '') {
32+
echo 'The PHAR was built without dependencies!' . PHP_EOL;
33+
exit(1);
34+
}
35+
36+
echo 'vendor/autoload.php could not be found. Did you run `composer install`?', PHP_EOL;
37+
exit(1);
38+
}
39+
40+
$application = new Application();
41+
$application->add(new GenerateTestClassCommand());
42+
$application->run();
43+
})();

composer.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "jwage/phpunit-test-generator",
3+
"description": "Generate PHPUnit test classes for a PHP class.",
4+
"type": "library",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Jonathan H. Wage",
9+
"email": "[email protected]"
10+
}
11+
],
12+
"require": {
13+
"doctrine/inflector": "2.0.x-dev",
14+
"twig/twig": "^2.5",
15+
"symfony/console": "^4.1"
16+
},
17+
"require-dev": {
18+
"doctrine/coding-standard": "^5.0",
19+
"phpstan/phpstan": "^0.10",
20+
"phpstan/phpstan-deprecation-rules": "^0.10",
21+
"phpstan/phpstan-phpunit": "^0.10",
22+
"phpstan/phpstan-strict-rules": "^0.10",
23+
"phpunit/phpunit": "^7.4"
24+
},
25+
"autoload": {
26+
"psr-4": {
27+
"JWage\\PHPUnitTestGenerator\\": "lib/"
28+
}
29+
},
30+
"autoload-dev": {
31+
"psr-4": {
32+
"JWage\\PHPUnitTestGenerator\\Tests\\": "tests/"
33+
}
34+
},
35+
"bin": [
36+
"bin/generate-test-class"
37+
]
38+
}

0 commit comments

Comments
 (0)