Skip to content

Commit

Permalink
Merge pull request #2 from richcongress/feature/v1.0.1
Browse files Browse the repository at this point in the history
Fix annotation autoloading
  • Loading branch information
NicolasGuilloux authored Feb 4, 2020
2 parents 4c25911 + 652f06d commit d7d2c3e
Show file tree
Hide file tree
Showing 23 changed files with 52 additions and 57 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Version 1.0.1

#### Bug fix

- Fix composer annotation autoloading
- Fix inspector errors and code cleaning
- Fix some documentation issue
2 changes: 1 addition & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);

namespace RichCongress\Bundle\UnitBundle\DependencyInjection;

Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/RichCongressUnitExtension.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);

namespace RichCongress\Bundle\UnitBundle\DependencyInjection;

Expand Down
2 changes: 1 addition & 1 deletion Docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ This is a list of default stubs provided by the unit-bundle. Find out the availa

- `test_roles`

This is a list of available roles for the DataProvider. Check out the [documentation](RoleProvider.md) to learn more about this feature.
This is a list of available roles for the DataProvider. Check out the [documentation](RolesProvider.md) to learn more about this feature.
23 changes: 17 additions & 6 deletions Docs/TestFixtures.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,22 @@ class LoadUserData extends AbstractFixture
'roles' => ['ROLE_ADMIN', 'ROLE_USER'],
]);

self::createObject('user-2', User::class, [
'username' => 'username_2',
'password' => 'unicorn_2',
'roles' => ['ROLE_USER'],
]);
self::createObject(
['user-2', 'second-unicorn'],
User::class,
[
'username' => 'username_2',
'password' => 'unicorn_2',
'roles' => ['ROLE_USER'],
]
);
}
}
```

The `createObject()` function is provided by the `AbstractFixture`. It creates an instance of the input class, set all the properties given in the input data, persist it and finally set the appropriate references.
We strongly recommand you to use this function as it avoids to create or use setters only for tests, where this approach gives a lot of flexibility instead.

You can also get an entity with a reference initialized from another fixture. Doctrine provided a handy interface that can manage to load fixtures in the approriated order.

```php
Expand All @@ -37,7 +44,11 @@ use RichCongress\Bundle\UnitBundle\Tests\Resources\DataFixture\LoadUserData;

class LoadDummyEntityData extends AbstractFixture implements DependentFixtureInterface
{
// ...
public function loadFixtures() : void{
/** @var User $user */
$user = $this->getReference('user-1');
// ...
}

public function getDependencies(): array
{
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class MainControllerTest extends ControllerTestCase
2. [Getting started](#2-getting-started)
- [Configuration](Docs/Configuration.md)
- [Available test cases](Docs/TestCases.md)
- [MockeryTestCase](Docs/TestCases.md#mockerytestcase)
- [CommandTestCase](Docs/TestCases.md#commandtestcase)
- [ConstraintTestCase](Docs/TestCases.md#constrainttestcase)
- [ControllerTestCase](Docs/TestCases.md#controllertestcase)
Expand All @@ -71,7 +70,7 @@ class MainControllerTest extends ControllerTestCase
- [Overriding services with stub services](Docs/OverrideServices.md#overriding-services-with-stub-services)
- [Use dynamic mocks (legacy)](Docs/OverrideServices.md#use-dynamic-mocks-legacy)
- [Available default service stubs](Docs/OverrideServices.md#available-default-service-stubs)
- [Role provider](Docs/RoleProvider.md)
- [Role provider](Docs/RolesProvider.md)
4. [Versioning](#3-versioning)
5. [Contributing](#4-contributing)
6. [Hacking](#5-hacking)
Expand Down Expand Up @@ -143,7 +142,6 @@ doctrine:
- [Configuration](Docs/Configuration.md)
- [Available test cases](Docs/TestCases.md)
- [MockeryTestCase](Docs/TestCases.md#mockerytestcase)
- [CommandTestCase](Docs/TestCases.md#commandtestcase)
- [ConstraintTestCase](Docs/TestCases.md#constrainttestcase)
- [ControllerTestCase](Docs/TestCases.md#controllertestcase)
Expand All @@ -154,7 +152,7 @@ doctrine:
- [Overriding services with stub services](Docs/OverrideServices.md#overriding-services-with-stub-services)
- [Use dynamic mocks (legacy)](Docs/OverrideServices.md#use-dynamic-mocks-legacy)
- [Available default service stubs](Docs/OverrideServices.md#available-default-service-stubs)
- [Role provider](Docs/RoleProvider.md)
- [Role provider](Docs/RolesProvider.md)
# 3. Versioning
Expand Down
2 changes: 1 addition & 1 deletion RichCongressUnitBundle.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);

namespace RichCongress\Bundle\UnitBundle;

Expand Down
5 changes: 1 addition & 4 deletions Stubs/SecurityStub.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<?php /** @noinspection ProperNullCoalescingOperatorUsageInspection */
/** @noinspection PhpDocMissingThrowsInspection */
/** @noinspection PhpUnhandledExceptionInspection */
declare(strict_types=1);
<?php declare(strict_types=1);

namespace RichCongress\Bundle\UnitBundle\Stubs;

Expand Down
2 changes: 1 addition & 1 deletion Stubs/TranslatorStub.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class TranslatorStub implements TranslatorInterface
*
* @return string|void
*/
public function trans($id, array $parameters = [], $domain = null, $locale = null): string
public function trans($id, array $parameters = [], string $domain = null, string $locale = null): string
{
if (!array_key_exists($id, $this->translations)) {
return '';
Expand Down
4 changes: 1 addition & 3 deletions TestCase/ControllerTestCase.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?php /** @noinspection PhpDeprecationInspection */

declare(strict_types=1);
<?php declare(strict_types=1);

namespace RichCongress\Bundle\UnitBundle\TestCase;

Expand Down
7 changes: 1 addition & 6 deletions TestCase/Internal/FixturesTestCase.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
<?php
/** @noinspection PhpDeprecationInspection */
/** @noinspection TraitsPropertiesConflictsInspection */
/** @noinspection PhpDocMissingThrowsInspection */
/** @noinspection PhpUnhandledExceptionInspection */
declare(strict_types=1);
<?php declare(strict_types=1);

namespace RichCongress\Bundle\UnitBundle\TestCase\Internal;

Expand Down
5 changes: 1 addition & 4 deletions TestCase/Internal/WebTestCase.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<?php
/** @noinspection PhpUnhandledExceptionInspection */
/** @noinspection PhpDocMissingThrowsInspection */
declare(strict_types=1);
<?php declare(strict_types=1);

namespace RichCongress\Bundle\UnitBundle\TestCase\Internal;

Expand Down
4 changes: 1 addition & 3 deletions TestTrait/AuthenticationTrait.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?php
/** @noinspection ALL */
declare(strict_types=1);
<?php declare(strict_types=1);

namespace RichCongress\Bundle\UnitBundle\TestTrait;

Expand Down
6 changes: 1 addition & 5 deletions TestTrait/FixtureCreationTrait.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
<?php
/** @noinspection PhpUnhandledExceptionInspection */
/** @noinspection PhpDocMissingThrowsInspection */
/** @noinspection CallableParameterUseCaseInTypeContextInspection */
declare(strict_types=1);
<?php declare(strict_types=1);

namespace RichCongress\Bundle\UnitBundle\TestTrait;

Expand Down
3 changes: 1 addition & 2 deletions Tests/Resources/DummyDatabaseTool.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php /** @noinspection PhpMissingParentConstructorInspection */
declare(strict_types=1);
<?php declare(strict_types=1);

namespace RichCongress\Bundle\UnitBundle\Tests\Resources;

Expand Down
3 changes: 1 addition & 2 deletions Tests/Resources/Stub/ReferenceRepositoryStub.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php /** @noinspection PhpMissingParentConstructorInspection */
declare(strict_types=1);
<?php declare(strict_types=1);

namespace RichCongress\Bundle\UnitBundle\Tests\Resources\Stub;

Expand Down
8 changes: 6 additions & 2 deletions Tests/Resources/config/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,13 @@ public function getProjectDir(): string
}

/**
* @inheritDoc
* @param LoaderInterface $loader
*
* @return void
*
* @throws \Exception
*/
public function registerContainerConfiguration(LoaderInterface $loader)
public function registerContainerConfiguration(LoaderInterface $loader): void
{
$loader->load(__DIR__ . '/config.yml');
$loader->load(__DIR__ . '/services.yml');
Expand Down
1 change: 0 additions & 1 deletion Tests/Stubs/RepositoryStubTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use RichCongress\Bundle\UnitBundle\DataFixture\AbstractFixture;
use RichCongress\Bundle\UnitBundle\Stubs\RepositoryStub;
use RichCongress\Bundle\UnitBundle\Tests\Resources\Entity\DummyEntity;
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Dummy;

/**
* Class RepositoryStubTest
Expand Down
1 change: 0 additions & 1 deletion Tests/TestCase/ConstraintTestCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use RichCongress\Bundle\UnitBundle\TestCase\ConstraintTestCase;
use RichCongress\Bundle\UnitBundle\Tests\Resources\Validator\DummyConstraint;
use RichCongress\Bundle\UnitBundle\Tests\Resources\Validator\DummyConstraintValidator;
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;

/**
* Class ConstraintTestCaseTest
Expand Down
4 changes: 1 addition & 3 deletions Tests/TestCase/ControllerTestCaseTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?php /** @noinspection PhpDeprecationInspection */

declare(strict_types=1);
<?php declare(strict_types=1);

namespace RichCongress\Bundle\UnitBundle\Tests\TestCase;

Expand Down
2 changes: 0 additions & 2 deletions Tests/TestCase/Internal/FixturesTestCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
use RichCongress\Bundle\UnitBundle\Tests\Resources\Entity\DummyEntity;
use RichCongress\Bundle\UnitBundle\Tests\Resources\Entity\User;
use RichCongress\Bundle\UnitBundle\Utility\FixturesManager;
use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyMessage;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
use Symfony\Component\HttpKernel\Client;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
Expand Down
4 changes: 1 addition & 3 deletions Utility/TestConfigurationExtractor.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?php /** @noinspection PhpDocMissingThrowsInspection */
/** @noinspection PhpUnhandledExceptionInspection */
declare(strict_types=1);
<?php declare(strict_types=1);

namespace RichCongress\Bundle\UnitBundle\Utility;

Expand Down
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@
"autoload": {
"psr-4": {
"RichCongress\\Bundle\\UnitBundle\\": ""
}
},
"files": [
"./TestConfiguration/Annotation/WithContainer.php",
"./TestConfiguration/Annotation/WithFixtures.php"
]
},
"autoload-dev": {
"psr-4": {
Expand Down

0 comments on commit d7d2c3e

Please sign in to comment.