Skip to content

Commit

Permalink
Harden the tests (#237)
Browse files Browse the repository at this point in the history
- Fix the coverage of some files (whitelist the files that should not be covered)
- Make `MapFile` return the unchanged path if no mapping is found for the given path: this allows to simplify some code
- Update the `ComposerOrchestrator` to not change the original `vendor/autoload.php` file if not necessary and make the changer prettier and more accurate (pure styling, no semantic change) when the file is changed
- Remove the config JSON imports support
- Fix some typos
- Add a lot of tests and rework some
  • Loading branch information
theofidry authored May 25, 2018
1 parent d85640e commit a040770
Show file tree
Hide file tree
Showing 48 changed files with 5,576 additions and 200 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
!/bin/dump-requirements-checker.php
/dist/
/fixtures/default_stub.php
/fixtures/composer-dump/dir001/vendor/
/fixtures/build/dir010/*.phar
/fixtures/check-requirements/*/actual-output
/fixtures/check-requirements/*/*.phar
Expand Down
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ tu: tu_requirement_checker tu_box

.PHONY: tu_box
tu_box: ## Run the unit tests
tu_box: bin/phpunit fixtures/default_stub.php .requirement-checker
TU_BOX_DEPS = bin/phpunit fixtures/default_stub.php .requirement-checker fixtures/composer-dump/dir001/vendor
tu_box: $(TU_BOX_DEPS)
$(PHPNOGC) bin/phpunit

.PHONY: tu_requirement_checker
Expand All @@ -69,7 +70,7 @@ tc: bin/phpunit

.PHONY: tm
tm: ## Run Infection
tm: bin/phpunit fixtures/default_stub.php tu_requirement_checker .requirement-checker
tm: $(TU_BOX_DEPS)
$(PHPNOGC) bin/infection

.PHONY: e2e
Expand Down Expand Up @@ -164,6 +165,14 @@ vendor-bin/php-cs-fixer/vendor/bin/php-cs-fixer: vendor/bamarni
composer bin php-cs-fixer install
touch $@

fixtures/composer-dump/dir001/composer.lock: fixtures/composer-dump/dir001/composer.json
composer install --working-dir fixtures/composer-dump/dir001
touch $@

fixtures/composer-dump/dir001/vendor: fixtures/composer-dump/dir001/composer.lock
composer install --working-dir fixtures/composer-dump/dir001
touch $@

.PHONY: fixtures/default_stub.php
fixtures/default_stub.php:
bin/generate_default_stub
Expand Down
46 changes: 46 additions & 0 deletions fixtures/PhpScoper/FakeScoper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

declare(strict_types=1);

/*
* This file is part of the box project.
*
* (c) Kevin Herrera <[email protected]>
* Théo Fidry <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace KevinGH\Box\PhpScoper;

use KevinGH\Box\NotCallable;

final class FakeScoper implements Scoper
{
use NotCallable;

/**
* {@inheritdoc}
*/
public function scope(string $filePath, string $contents): string
{
$this->__call(__METHOD__, func_get_args());
}

/**
* {@inheritdoc}
*/
public function getWhitelist(): array
{
$this->__call(__METHOD__, func_get_args());
}

/**
* {@inheritdoc}
*/
public function getPrefix(): string
{
$this->__call(__METHOD__, func_get_args());
}
}
5 changes: 5 additions & 0 deletions fixtures/composer-dump/dir000/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": {
"beberlei/assert": "^2.8"
}
}
5 changes: 5 additions & 0 deletions fixtures/composer-dump/dir001/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": {
"beberlei/assert": "^2.8"
}
}
73 changes: 73 additions & 0 deletions fixtures/composer-dump/dir001/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions fixtures/composer-dump/dir002/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": {
"beberlei/assert": "^2.8"
}
}
73 changes: 73 additions & 0 deletions fixtures/composer-dump/dir002/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions fixtures/composer-dump/dir002/vendor/beberlei/assert/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Copyright (c) 2011-2013, Benjamin Eberlei
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

- Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
54 changes: 54 additions & 0 deletions fixtures/composer-dump/dir002/vendor/beberlei/assert/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "beberlei/assert",
"description": "Thin assertion library for input validation in business models.",
"authors": [
{
"name": "Benjamin Eberlei",
"email": "[email protected]",
"role": "Lead Developer"
},
{
"name": "Richard Quadling",
"email": "[email protected]",
"role": "Collaborator"
}
],
"license": "BSD-2-Clause",
"keywords": [
"assert",
"assertion",
"validation"
],
"config": {
"sort-packages": true
},
"require": {
"php": ">=5.3",
"ext-mbstring": "*"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.1.1",
"phpunit/phpunit": "^4.8.35|^5.7"
},
"autoload": {
"psr-4": {
"Assert\\": "lib/Assert"
},
"files": [
"lib/Assert/functions.php"
]
},
"autoload-dev": {
"psr-4": {
"Assert\\Tests\\": "tests/Assert/Tests"
},
"files": [
"tests/Assert/Tests/Fixtures/functions.php"
]
},
"scripts": {
"assert:generate-docs": "php bin/generate_method_docs.php",
"assert:cs-lint": "php-cs-fixer fix --diff -vvv --dry-run",
"assert:cs-fix": "php-cs-fixer fix . -vvv || true"
}
}
Loading

0 comments on commit a040770

Please sign in to comment.