Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
150 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
.../Symfony/PropertyInfo/Metadata/Property/PropertyInfoPropertyNameCollectionFactoryTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <dunglas@gmail.com> | ||
* | ||
* 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\Bridge\Symfony\PropertyInfo\Metadata\Property; | ||
|
||
use ApiPlatform\Core\Bridge\Symfony\PropertyInfo\Metadata\Property\PropertyInfoPropertyNameCollectionFactory; | ||
use ApiPlatform\Core\Tests\Fixtures\DummyObjectWithOnlyPrivateProperty; | ||
use ApiPlatform\Core\Tests\Fixtures\DummyObjectWithOnlyPublicProperty; | ||
use ApiPlatform\Core\Tests\Fixtures\DummyObjectWithoutProperty; | ||
use ApiPlatform\Core\Tests\Fixtures\DummyObjectWithPublicAndPrivateProperty; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor; | ||
use Symfony\Component\PropertyInfo\PropertyInfoExtractor; | ||
|
||
/** | ||
* @author Oskar Stark <oskarstark@googlemail.com> | ||
*/ | ||
class PropertyInfoPropertyNameCollectionFactoryTest extends TestCase | ||
{ | ||
public function testCreateMethodReturnsEmptyPropertyNameCollectionForObjectWithOnlyPrivateProperty() | ||
{ | ||
$factory = new PropertyInfoPropertyNameCollectionFactory(new PropertyInfoExtractor([ | ||
new ReflectionExtractor(), | ||
])); | ||
|
||
$collection = $factory->create(DummyObjectWithOnlyPrivateProperty::class); | ||
|
||
self::assertCount(0, $collection->getIterator()); | ||
} | ||
|
||
public function testCreateMethodReturnsEmptyPropertyNameCollectionForObjectWithoutProperties() | ||
{ | ||
$factory = new PropertyInfoPropertyNameCollectionFactory(new PropertyInfoExtractor([ | ||
new ReflectionExtractor(), | ||
])); | ||
|
||
$collection = $factory->create(DummyObjectWithoutProperty::class); | ||
|
||
self::assertCount(0, $collection->getIterator()); | ||
} | ||
|
||
public function testCreateMethodReturnsProperPropertyNameCollectionForObjectWithPublicAndPrivateProperty() | ||
{ | ||
$factory = new PropertyInfoPropertyNameCollectionFactory(new PropertyInfoExtractor([ | ||
new ReflectionExtractor(), | ||
])); | ||
|
||
$collection = $factory->create(DummyObjectWithPublicAndPrivateProperty::class); | ||
|
||
self::assertCount(1, $collection->getIterator()); | ||
} | ||
|
||
public function testCreateMethodReturnsProperPropertyNameCollectionForObjectWithPublicProperty() | ||
{ | ||
$factory = new PropertyInfoPropertyNameCollectionFactory(new PropertyInfoExtractor([ | ||
new ReflectionExtractor(), | ||
])); | ||
|
||
$collection = $factory->create(DummyObjectWithOnlyPublicProperty::class); | ||
|
||
self::assertCount(1, $collection->getIterator()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <dunglas@gmail.com> | ||
* | ||
* 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\Fixtures; | ||
|
||
class DummyObjectWithOnlyPrivateProperty | ||
{ | ||
private $foo; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <dunglas@gmail.com> | ||
* | ||
* 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\Fixtures; | ||
|
||
class DummyObjectWithOnlyPublicProperty | ||
{ | ||
public $foo; | ||
} |
20 changes: 20 additions & 0 deletions
20
tests/Fixtures/DummyObjectWithPublicAndPrivateProperty.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <dunglas@gmail.com> | ||
* | ||
* 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\Fixtures; | ||
|
||
class DummyObjectWithPublicAndPrivateProperty | ||
{ | ||
public $foo; | ||
private $bar; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <dunglas@gmail.com> | ||
* | ||
* 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\Fixtures; | ||
|
||
class DummyObjectWithoutProperty | ||
{ | ||
} |