Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitee495f8

Browse files
committed
merged branch kriswallsmith/class-loader/idempotent (PR#7245)
This PR was merged into the 2.1 branch.Commits-------27cc0df Merge pull request#1 from merk/class-loader/idempotent95af84c Fixed test to use Reflectionbb08247 [ClassLoader] tweaked test73bead7 [ClassLoader] made DebugClassLoader idempotentDiscussion----------[ClassLoader] made DebugClassLoader idempotentThe DebugClassLoader will wrap itself if `enable()` is called multiple time, such as when running functional tests.Please merge to 2.2 and master ASAP.| Q | A| ------------- | ---| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets | ~| License | MIT| Doc PR | ~---------------------------------------------------------------------------by kriswallsmith at 2013-03-07T16:38:55Zping@fabpot: this will speed up lots of functional tests :)---------------------------------------------------------------------------by kriswallsmith at 2013-03-08T04:51:51Z@fabpot fixed by@merk
2 parents7241be9 +27cc0df commitee495f8

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

‎src/Symfony/Component/ClassLoader/DebugClassLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static function enable()
5353
}
5454

5555
foreach ($functionsas$function) {
56-
if (is_array($function) &&method_exists($function[0],'findFile')) {
56+
if (is_array($function) &&!$function[0]instanceof self &&method_exists($function[0],'findFile')) {
5757
$function =array(newstatic($function[0]),'loadClass');
5858
}
5959

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
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+
namespaceSymfony\Component\ClassLoader\Tests;
13+
14+
useSymfony\Component\ClassLoader\ClassLoader;
15+
useSymfony\Component\ClassLoader\DebugClassLoader;
16+
17+
class DebugClassLoaderTestextends \PHPUnit_Framework_TestCase
18+
{
19+
private$loader;
20+
21+
protectedfunctionsetUp()
22+
{
23+
$this->loader =newClassLoader();
24+
spl_autoload_register(array($this->loader,'loadClass'));
25+
}
26+
27+
protectedfunctiontearDown()
28+
{
29+
spl_autoload_unregister(array($this->loader,'loadClass'));
30+
}
31+
32+
publicfunctiontestIdempotence()
33+
{
34+
DebugClassLoader::enable();
35+
DebugClassLoader::enable();
36+
37+
$functions =spl_autoload_functions();
38+
foreach ($functionsas$function) {
39+
if (is_array($function) &&$function[0]instanceof DebugClassLoader) {
40+
$reflClass =new \ReflectionClass($function[0]);
41+
$reflProp =$reflClass->getProperty('classFinder');
42+
$reflProp->setAccessible(true);
43+
44+
$this->assertNotInstanceOf('Symfony\Component\ClassLoader\DebugClassLoader',$reflProp->getValue($function[0]));
45+
return;
46+
}
47+
}
48+
49+
thrownew \Exception('DebugClassLoader did not register');
50+
}
51+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp