123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- /**
- * File DiscriminatorTest.php
- *
- * @author Edward Pfremmer <epfremme@nerdery.com>
- */
- namespace Epfremme\Swagger\Tests\Annotations;
- use Epfremme\Swagger\Annotations\Discriminator;
- /**
- * Class DiscriminatorTest
- *
- * @package Epfremme\Swagger
- * @subPackage Tests\Annotations
- */
- class DiscriminatorTest extends \PHPUnit_Framework_TestCase
- {
- /**
- * @covers Epfremme\Swagger\Annotations\Discriminator::getClass
- */
- public function testGetClass()
- {
- $annotation = new Discriminator();
- $annotation->default = 'default';
- $annotation->field = 'type';
- $annotation->map = [
- 'default' => 'Default\Class',
- 'type_1' => 'Type\One\Class',
- ];
- $result = $annotation->getClass([
- 'type' => 'type_1'
- ]);
- $this->assertEquals('Type\One\Class', $result);
- }
- /**
- * @covers Epfremme\Swagger\Annotations\Discriminator::getClass
- * @covers Epfremme\Swagger\Annotations\Discriminator::getDefault
- */
- public function testGetClassDefault()
- {
- $annotation = new Discriminator();
- $annotation->default = 'default';
- $annotation->field = 'type';
- $annotation->map = [
- 'default' => 'Default\Class',
- 'type_1' => 'Type\One\Class',
- ];
- $result = $annotation->getClass([
- 'type' => 'type_2'
- ]);
- $this->assertEquals('Default\Class', $result);
- }
- /**
- * @expectedException \Doctrine\Common\Annotations\AnnotationException
- */
- public function testGetClassException()
- {
- $annotation = new Discriminator();
- $annotation->default = 'unknown';
- $annotation->field = 'type';
- $annotation->map = [
- 'default' => 'Default\Class',
- 'type_1' => 'Type\One\Class',
- ];
- $annotation->getClass([]);
- }
- }
|