Skip to content

Commit

Permalink
Merge pull request #180 from localheinz/fix/magic-get-and-set
Browse files Browse the repository at this point in the history
Fix: Add test for __get() and __set()
  • Loading branch information
Ocramius committed Feb 4, 2018
2 parents ed47056 + 2f3362b commit 9419fd5
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/Doctrine/Tests/Common/Annotations/AnnotationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace Doctrine\Tests\Common\Annotations;

use Doctrine\Common\Annotations\Annotation;
use PHPUnit\Framework\TestCase;

final class AnnotationTest extends TestCase
{
public function testMagicGetThrowsBadMethodCallException()
{
$name = 'foo';

$annotation = new Annotation([]);

$this->expectException(\BadMethodCallException::class);
$this->expectExceptionMessage(sprintf(
"Unknown property '%s' on annotation '%s'.",
$name,
Annotation::class
));

$annotation->{$name};
}

public function testMagicSetThrowsBadMethodCallException()
{
$name = 'foo';

$annotation = new Annotation([]);

$this->expectException(\BadMethodCallException::class);
$this->expectExceptionMessage(sprintf(
"Unknown property '%s' on annotation '%s'.",
$name,
Annotation::class
));

$annotation->{$name} = 9001;
}
}

0 comments on commit 9419fd5

Please sign in to comment.