Skip to content

Commit

Permalink
Removed null description @var in ApiResource (#1260)
Browse files Browse the repository at this point in the history
  • Loading branch information
wizbit authored and dunglas committed Jul 20, 2017
1 parent 89b9364 commit a0bd34b
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Annotation/ApiResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class ApiResource
public $shortName;

/**
* @var string|null
* @var string
*/
public $description;

Expand Down
32 changes: 32 additions & 0 deletions tests/Annotation/AnnotatedClass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

/*
* This file is part of the API Platform project.
*
* (c) Kévin Dunglas <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace ApiPlatform\Core\Tests\Annotation;

use ApiPlatform\Core\Annotation\ApiResource;

/**
* @ApiResource(
* shortName="shortName",
* description="description",
* iri="http://example.com/res",
* itemOperations={"foo":{"bar"}},
* collectionOperations={"bar":{"foo"}},
* attributes={"foo":"bar"}
* )
*
* @author Marcus Speight <[email protected]>
*/
class AnnotatedClass
{
}
13 changes: 13 additions & 0 deletions tests/Annotation/ApiResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace ApiPlatform\Core\Tests\Annotation;

use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\Common\Annotations\AnnotationReader;

/**
* @author Kévin Dunglas <[email protected]>
Expand All @@ -36,4 +37,16 @@ public function testAssignation()
$this->assertEquals(['bar' => ['foo']], $resource->collectionOperations);
$this->assertEquals(['foo' => 'bar'], $resource->attributes);
}

public function testApiResourceAnnotation()
{
$reader = new AnnotationReader();
$resource = $reader->getClassAnnotation(new \ReflectionClass(AnnotatedClass::class), ApiResource::class);

$this->assertEquals('shortName', $resource->shortName);
$this->assertEquals('description', $resource->description);
$this->assertEquals('http://example.com/res', $resource->iri);
$this->assertEquals(['bar' => ['foo']], $resource->collectionOperations);
$this->assertEquals(['foo' => 'bar'], $resource->attributes);
}
}

0 comments on commit a0bd34b

Please sign in to comment.