8000 minor #12017 [Validator] Fixed StaticMethodLoaderTest to actually tes… · symfony/symfony@d671406 · GitHub
[go: up one dir, main page]

Skip to content

Commit d671406

Browse files
committed
minor #12017 [Validator] Fixed StaticMethodLoaderTest to actually test something (webmozart)
This PR was merged into the 2.3 branch. Discussion ---------- [Validator] Fixed StaticMethodLoaderTest to actually test something | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - This test is not testing anything, except for whether PHP throws a strict standards error when invalid code is loaded. I disabled error reporting for this test, so that the actual functionality (ignoring static+abstract functions) is tested. Commits ------- 1b1303a [Validator] Fixed StaticMethodLoaderTest to actually test something
2 parents 45ac2c4 + 1b1303a commit d671406

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

src/Symfony/Component/Validator/Tests/Mapping/Loader/AbstractMethodStaticLoader.php renamed to src/Symfony/Component/Validator/Tests/Mapping/Loader/AbstractStaticMethodLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Symfony\Component\Validator\Mapping\ClassMetadata;
66

7-
abstract class AbstractMethodStaticLoader
7+
abstract class AbstractStaticMethodLoader
88
{
99
abstract public static function loadMetadata(ClassMetadata $metadata);
1010
}

src/Symfony/Component/Validator/Tests/Mapping/Loader/StaticMethodLoaderTest.php

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,19 @@ public function testLoadClassMetadataInAbstractClasses()
9090

9191
public function testLoadClassMetadataIgnoresAbstractMethods()
9292
{
93-
error_reporting(E_ALL | E_STRICT);
93+
// Disable error reporting, as AbstractStaticMethodLoader produces a
94+
// strict standards error
95+
error_reporting(0);
9496

95-
$loader = new StaticMethodLoader('loadMetadata');
96-
$caught = false;
97-
try {
98-
include __DIR__.'/AbstractMethodStaticLoader.php';
99-
} catch (\Exception $e) {
100-
// catching the PHP notice that is converted to an exception by PHPUnit
101-
$caught = true;
97+
if (0 !== error_reporting()) {
98+
$this->markTestSkipped('Could not disable error reporting');
10299
}
103100

104-
if (!$caught) {
105-
$this->fail('AbstractMethodStaticLoader should produce a strict standard error.');
106-
}
101+
include __DIR__.'/AbstractStaticMethodLoader.php';
107102

108-
$metadata = new ClassMetadata(__NAMESPACE__.'\AbstractMethodStaticLoader');
103+
$metadata = new ClassMetadata(__NAMESPACE__.'\AbstractStaticMethodLoader');
104+
105+
$loader = new StaticMethodLoader('loadMetadata');
109106
$loader->loadClassMetadata($metadata);
110107

111108
$this->assertCount(0, $metadata->getConstraints());

0 commit comments

Comments
 (0)
0