Skip to content

Commit

Permalink
Removes expected error type and validate only the message
Browse files Browse the repository at this point in the history
Signed-off-by: George Steel <[email protected]>
  • Loading branch information
gsteel committed Jul 25, 2022
1 parent 9c1bfa1 commit 6766141
Showing 1 changed file with 33 additions and 21 deletions.
54 changes: 33 additions & 21 deletions test/Annotation/AbstractBuilderTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace LaminasTest\Form\Annotation;

use Doctrine\Common\Annotations\AnnotationException;
use Generator;
use Laminas\Form\Annotation;
use Laminas\Form\Element;
Expand All @@ -23,6 +22,7 @@
use LaminasTest\Form\TestAsset\Annotation\InputFilter;
use LaminasTest\Form\TestAsset\Annotation\InputFilterInput;
use PHPUnit\Framework\TestCase;
use Throwable;

use function getenv;

Expand Down Expand Up @@ -407,37 +407,49 @@ public function testInputFilterAnnotationAllowsComposition(): void

public function testLegacyComposedObjectAnnotation(): void
{
$this->expectException(AnnotationException::class);
$this->expectExceptionMessageMatches('/Passing a single array .* is deprecated/');
$entity = new TestAsset\Annotation\LegacyComposedObjectAnnotation();
$builder = $this->createBuilder();
$builder->createForm($entity);
try {
$entity = new TestAsset\Annotation\LegacyComposedObjectAnnotation();
$builder = $this->createBuilder();
$builder->createForm($entity);
self::fail('Neither a deprecation nor an exception were thrown');
} catch (Throwable $error) {
self::assertMatchesRegularExpression('/Passing a single array .* is deprecated/', $error->getMessage());
}
}

public function testLegacyStyleFilterAnnotations(): void
{
$this->expectException(AnnotationException::class);
$this->expectExceptionMessageMatches('/Passing a single array .* is deprecated/');
$entity = new TestAsset\Annotation\LegacyFilterAnnotation();
$builder = $this->createBuilder();
$builder->createForm($entity);
try {
$entity = new TestAsset\Annotation\LegacyFilterAnnotation();
$builder = $this->createBuilder();
$builder->createForm($entity);
self::fail('Neither a deprecation nor an exception were thrown');
} catch (Throwable $error) {
self::assertMatchesRegularExpression('/Passing a single array .* is deprecated/', $error->getMessage());
}
}

public function testLegacyStyleHydratorAnnotations(): void
{
$this->expectException(AnnotationException::class);
$this->expectExceptionMessageMatches('/Passing a single array .* is deprecated/');
$entity = new TestAsset\Annotation\LegacyHydratorAnnotation();
$builder = $this->createBuilder();
$builder->createForm($entity);
try {
$entity = new TestAsset\Annotation\LegacyHydratorAnnotation();
$builder = $this->createBuilder();
$builder->createForm($entity);
self::fail('Neither a deprecation nor an exception were thrown');
} catch (Throwable $error) {
self::assertMatchesRegularExpression('/Passing a single array .* is deprecated/', $error->getMessage());
}
}

public function testLegacyStyleValidatorAnnotations(): void
{
$this->expectException(AnnotationException::class);
$this->expectExceptionMessageMatches('/Passing a single array .* is deprecated/');
$entity = new TestAsset\Annotation\LegacyValidatorAnnotation();
$builder = $this->createBuilder();
$builder->createForm($entity);
try {
$entity = new TestAsset\Annotation\LegacyValidatorAnnotation();
$builder = $this->createBuilder();
$builder->createForm($entity);
self::fail('Neither a deprecation nor an exception were thrown');
} catch (Throwable $error) {
self::assertMatchesRegularExpression('/Passing a single array .* is deprecated/', $error->getMessage());
}
}
}

0 comments on commit 6766141

Please sign in to comment.