Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 25b69fd

Browse files
[Testing] new testing component
1 parent 40854ed commit 25b69fd

File tree

9 files changed

+138
-31
lines changed

9 files changed

+138
-31
lines changed

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@
8686
],
8787
"files": [ "src/Symfony/Component/Intl/Resources/stubs/functions.php" ]
8888
},
89+
"autoload-dev": {
90+
"files": [ "src/Symfony/Component/Testing/Resources/bootstrap/symfony.php" ]
91+
},
8992
"minimum-stability": "dev",
9093
"extra": {
9194
"branch-alias": {

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
55
backupGlobals="false"
66
colors="true"
7-
bootstrap="autoload.php.dist"
7+
bootstrap="vendor/autoload.php"
88
>
99
<php>
1010
<!-- Disable E_USER_DEPRECATED until 3.0 -->
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
vendor/
2+
composer.lock
3+
phpunit.xml

autoload.php.dist renamed to src/Symfony/Component/Testing/DeprecationErrorHandler.php

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
<?php
22

3-
if (PHP_VERSION_ID >= 50400 && gc_enabled()) {
4-
// Disabling Zend Garbage Collection to prevent segfaults with PHP5.4+
5-
// https://bugs.php.net/bug.php?id=53976
6-
gc_disable();
7-
}
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Testing;
813

914
/**
1015
* Catch deprecation notices and print a summary report at the end of the test suite
1116
*
12-
* @internal
17+
* @author Nicolas Grekas <[email protected]>
1318
*/
1419
class DeprecationErrorHandler
1520
{
@@ -68,20 +73,16 @@ public static function register()
6873
}
6974
} else {
7075
self::$isRegistered = true;
71-
register_shutdown_function(function () use (&$deprecations, $deprecationHandler) {
72-
73-
$colorize = new \SebastianBergmann\Environment\Console();
74-
75-
if ($colorize->hasColorSupport()) {
76-
$colorize = function ($str, $red) {
77-
$color = $red ? '41;37' : '43;30';
78-
79-
return "\x1B[{$color}m{$str}\x1B[0m";
80-
};
81-
} else {
82-
$colorize = function ($str) {return $str;};
83-
}
76+
if (self::hasColorSupport()) {
77+
$colorize = function ($str, $red) {
78+
$color = $red ? '41;37' : '43;30';
8479

80+
return "\x1B[{$color}m{$str}\x1B[0m";
81+
};
82+
} else {
83+
$colorize = function ($str) {return $str;};
84+
}
85+
register_shutdown_function(function () use (&$deprecations, $deprecationHandler, $colorize) {
8586
$currErrorHandler = set_error_handler('var_dump');
8687
restore_error_handler();
8788

@@ -118,16 +119,13 @@ public static function register()
118119
});
119120
}
120121
}
121-
}
122-
123-
if (class_exists('PHPUnit_Util_ErrorHandler')) {
124-
DeprecationErrorHandler::register();
125-
}
126-
127-
$loader = require_once __DIR__.'/vendor/autoload.php';
128122

129-
use Doctrine\Common\Annotations\AnnotationRegistry;
130-
131-
AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
123+
private static function hasColorSupport()
124+
{
125+
if ('\\' === DIRECTORY_SEPARATOR) {
126+
return false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI');
127+
}
132128

133-
return $loader;
129+
return defined('STDOUT') && function_exists('posix_isatty') && @posix_isatty(STDOUT);
130+
}
131+
}

src/Symfony/Component/Testing/LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2015-2015 Fabien Potencier
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 furnished
8+
to do 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
19+
THE SOFTWARE.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Testing Component
2+
=================
3+
4+
Tools for helping with testing PHP projects.
5+
Should be used only in the `require-dev` section
6+
of your composer.json file (not in `require`).
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
use Doctrine\Common\Annotations\AnnotationRegistry;
4+
use Symfony\Component\Testing\DeprecationErrorHandler;
5+
6+
if (!class_exists('PHPUnit_Util_ErrorHandler')) {
7+
return;
8+
}
9+
10+
if (PHP_VERSION_ID >= 50400 && gc_enabled()) {
11+
// Disabling Zend Garbage Collection to prevent segfaults with PHP5.4+
12+
// https://bugs.php.net/bug.php?id=53976
13+
gc_disable();
14+
}
15+
16+
DeprecationErrorHandler::register();
17+
18+
if (class_exists('Doctrine\Common\Annotations\AnnotationRegistry')) {
19+
AnnotationRegistry::registerLoader('class_exists');
20+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "symfony/testing",
3+
"type": "library",
4+
"description": "Symfony Testing Component",
5+
"keywords": [],
6+
"homepage": "http://symfony.com",
7+
"license": "MIT",
8+
"authors": [
9+
{
10+
"name": "Nicolas Grekas",
11+
"email": "[email protected]"
12+
},
13+
{
14+
"name": "Symfony Community",
15+
"homepage": "http://symfony.com/contributors"
16+
}
17+
],
18+
"require": {
19+
"php": ">=5.3.3"
20+
},
21+
"autoload": {
22+
"psr-0": { "Symfony\\Component\\Testing\\": "" }
23+
},
24+
"autoload-dev": {
25+
"files": [ "Resources/bootstrap/symfony.php" ]
26+
},
27+
"target-dir": "Symfony/Component/Testing",
28+
"minimum-stability": "dev",
29+
"extra": {
30+
"branch-alias": {
31+
"dev-master": "2.7-dev"
32+
}
33+
}
34+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
5+
backupGlobals="false"
6+
colors="true"
7+
bootstrap="vendor/autoload.php"
8+
>
9+
<testsuites>
10+
<testsuite name="Symfony Testing Component Test Suite">
11+
<directory>./Tests/</directory>
12+
</testsuite>
13+
</testsuites>
14+
15+
<filter>
16+
<whitelist>
17+
<directory>./</directory>
18+
<exclude>
19+
<directory>./Tests</directory>
20+
<directory>./vendor</directory>
21+
</exclude>
22+
</whitelist>
23+
</filter>
24+
</phpunit>

0 commit comments

Comments
 (0)