Skip to content

Commit e1a6519

Browse files
committed
fix some risky tests
1 parent b3fbe31 commit e1a6519

File tree

6 files changed

+25
-7
lines changed

6 files changed

+25
-7
lines changed

Tests/ConstraintTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ public function testRequiredOptionsMustBeDefined()
115115

116116
public function testRequiredOptionsPassed()
117117
{
118-
new ConstraintC(array('option1' => 'default'));
118+
$constraint = new ConstraintC(array('option1' => 'default'));
119+
120+
$this->assertSame('default', $constraint->option1);
119121
}
120122

121123
public function testGroupsAreConvertedToArray()
@@ -140,7 +142,9 @@ public function testAllowsSettingZeroRequiredPropertyValue()
140142

141143
public function testCanCreateConstraintWithNoDefaultOptionAndEmptyArray()
142144
{
143-
new ConstraintB(array());
145+
$constraint = new ConstraintB(array());
146+
147+
$this->assertSame(array(Constraint::PROPERTY_CONSTRAINT, Constraint::CLASS_CONSTRAINT), $constraint->getTargets());
144148
}
145149

146150
public function testGetTargetsCanBeString()

Tests/Constraints/CallbackValidatorTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,9 @@ public function testConstraintGetTargets()
330330
// Should succeed. Needed when defining constraints as annotations.
331331
public function testNoConstructorArguments()
332332
{
333-
new Callback();
333+
$constraint = new Callback();
334+
335+
$this->assertSame(array(Constraint::CLASS_CONSTRAINT, Constraint::PROPERTY_CONSTRAINT), $constraint->getTargets());
334336
}
335337

336338
public function testAnnotationInvocationSingleValued()

Tests/Constraints/GroupSequenceTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,7 @@ public function testLegacyUnsetIgnoresNonExistingKeys()
9494

9595
// should not fail
9696
unset($sequence[2]);
97+
98+
$this->assertCount(2, $sequence);
9799
}
98100
}

Tests/Mapping/ClassMetadataTest.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,19 +245,23 @@ public function testSerialize()
245245
public function testGroupSequencesWorkIfContainingDefaultGroup()
246246
{
247247
$this->metadata->setGroupSequence(array('Foo', $this->metadata->getDefaultGroup()));
248+
249+
$this->assertInstanceOf('Symfony\Component\Validator\Constraints\GroupSequence', $this->metadata->getGroupSequence());
248250
}
249251

252+
/**
253+
* @expectedException \Symfony\Component\Validator\Exception\GroupDefinitionException
254+
*/
250255
public function testGroupSequencesFailIfNotContainingDefaultGroup()
251256
{
252-
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\GroupDefinitionException');
253-
254257
$this->metadata->setGroupSequence(array('Foo', 'Bar'));
255258
}
256259

260+
/**
261+
* @expectedException \Symfony\Component\Validator\Exception\GroupDefinitionException
262+
*/
257263
public function testGroupSequencesFailIfContainingDefault()
258264
{
259-
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Validator\Exception\GroupDefinitionException');
260-
261265
$this->metadata->setGroupSequence(array('Foo', $this->metadata->getDefaultGroup(), Constraint::DEFAULT_GROUP));
262266
}
263267

Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,11 @@ public function testMetadataCacheWithRuntimeConstraint()
167167
$metadata = $factory->getMetadataFor(self::PARENT_CLASS);
168168
$metadata->addConstraint(new Callback(function () {}));
169169

170+
$this->assertCount(3, $metadata->getConstraints());
171+
170172
$metadata = $factory->getMetadataFor(self::CLASS_NAME);
173+
174+
$this->assertCount(6, $metadata->getConstraints());
171175
}
172176

173177
public function testGroupsFromParent()

Tests/Resources/TranslationFilesTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public function testTranslationFileIsValid($filePath)
2525
} else {
2626
\PHPUnit\Util\XML::loadfile($filePath, false, false, true);
2727
}
28+
29+
$this->addToAssertionCount(1);
2830
}
2931

3032
public function provideTranslationFiles()

0 commit comments

Comments
 (0)