Skip to content

Commit

Permalink
tec: Move factories under tests/ folder
Browse files Browse the repository at this point in the history
I placed the factories under src/ initially because it didn't work under
tests/. I found out that factories under tests/ folder weren't autowired
by Symfony. Then, I just had to declare the factories in the
services.yaml configuration file.

References:

- https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html
- zenstruck/foundry#332
  • Loading branch information
marien-probesys committed Dec 8, 2022
1 parent 5a0cc15 commit 3849b6e
Show file tree
Hide file tree
Showing 17 changed files with 37 additions and 28 deletions.
9 changes: 9 additions & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,12 @@ when@dev:
App\Twig\ViteTagsExtension:
arguments:
- "%kernel.project_dir%/public/manifest.dev.json"

when@test:
services:
_defaults:
autowire: true
autoconfigure: true

App\Tests\Factory\:
resource: '../tests/Factory'
2 changes: 1 addition & 1 deletion tests/Command/Users/CreateCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

namespace App\Tests\Command\Users;

use App\Factory\UserFactory;
use App\Tests\CommandTestsHelper;
use App\Tests\Factory\UserFactory;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Console\Command\Command;
use Zenstruck\Foundry\Test\Factories;
Expand Down
2 changes: 1 addition & 1 deletion tests/Controller/HomeControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace App\Tests\Controller;

use App\Factory\UserFactory;
use App\Tests\Factory\UserFactory;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Zenstruck\Foundry\Test\Factories;
use Zenstruck\Foundry\Test\ResetDatabase;
Expand Down
2 changes: 1 addition & 1 deletion tests/Controller/LoginControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace App\Tests\Controller;

use App\Entity\User;
use App\Factory\UserFactory;
use App\Tests\Factory\UserFactory;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Zenstruck\Foundry\Test\Factories;
use Zenstruck\Foundry\Test\ResetDatabase;
Expand Down
8 changes: 4 additions & 4 deletions tests/Controller/Organizations/TicketsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

use App\Entity\Organization;
use App\Entity\Ticket;
use App\Factory\MessageFactory;
use App\Factory\OrganizationFactory;
use App\Factory\TicketFactory;
use App\Factory\UserFactory;
use App\Tests\Factory\MessageFactory;
use App\Tests\Factory\OrganizationFactory;
use App\Tests\Factory\TicketFactory;
use App\Tests\Factory\UserFactory;
use App\Utils\Time;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Zenstruck\Foundry\Factory;
Expand Down
4 changes: 2 additions & 2 deletions tests/Controller/OrganizationsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
namespace App\Tests\Controller;

use App\Entity\Organization;
use App\Factory\OrganizationFactory;
use App\Factory\UserFactory;
use App\Tests\Factory\OrganizationFactory;
use App\Tests\Factory\UserFactory;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Zenstruck\Foundry\Test\Factories;
use Zenstruck\Foundry\Test\ResetDatabase;
Expand Down
2 changes: 1 addition & 1 deletion tests/Controller/PreferencesControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace App\Tests\Controller;

use App\Entity\User;
use App\Factory\UserFactory;
use App\Tests\Factory\UserFactory;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Zenstruck\Foundry\Test\Factories;
use Zenstruck\Foundry\Test\ResetDatabase;
Expand Down
4 changes: 2 additions & 2 deletions tests/Controller/Tickets/ActorsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

namespace App\Tests\Controller\Tickets;

use App\Factory\TicketFactory;
use App\Factory\UserFactory;
use App\Tests\Factory\TicketFactory;
use App\Tests\Factory\UserFactory;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Zenstruck\Foundry\Test\Factories;
use Zenstruck\Foundry\Test\ResetDatabase;
Expand Down
6 changes: 3 additions & 3 deletions tests/Controller/Tickets/MessagesControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
namespace App\Tests\Controller\Tickets;

use App\Entity\Ticket;
use App\Factory\MessageFactory;
use App\Factory\TicketFactory;
use App\Factory\UserFactory;
use App\Tests\Factory\MessageFactory;
use App\Tests\Factory\TicketFactory;
use App\Tests\Factory\UserFactory;
use App\Utils\Time;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Zenstruck\Foundry\Factory;
Expand Down
4 changes: 2 additions & 2 deletions tests/Controller/Tickets/PriorityControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

namespace App\Tests\Controller\Tickets;

use App\Factory\TicketFactory;
use App\Factory\UserFactory;
use App\Tests\Factory\TicketFactory;
use App\Tests\Factory\UserFactory;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Zenstruck\Foundry\Test\Factories;
use Zenstruck\Foundry\Test\ResetDatabase;
Expand Down
4 changes: 2 additions & 2 deletions tests/Controller/Tickets/TitleControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

namespace App\Tests\Controller\Tickets;

use App\Factory\TicketFactory;
use App\Factory\UserFactory;
use App\Tests\Factory\TicketFactory;
use App\Tests\Factory\UserFactory;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Zenstruck\Foundry\Test\Factories;
use Zenstruck\Foundry\Test\ResetDatabase;
Expand Down
4 changes: 2 additions & 2 deletions tests/Controller/Tickets/TypeControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

namespace App\Tests\Controller\Tickets;

use App\Factory\TicketFactory;
use App\Factory\UserFactory;
use App\Tests\Factory\TicketFactory;
use App\Tests\Factory\UserFactory;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Zenstruck\Foundry\Test\Factories;
use Zenstruck\Foundry\Test\ResetDatabase;
Expand Down
6 changes: 3 additions & 3 deletions tests/Controller/TicketsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
namespace App\Tests\Controller;

use App\Entity\Organization;
use App\Factory\OrganizationFactory;
use App\Factory\TicketFactory;
use App\Factory\UserFactory;
use App\Tests\Factory\OrganizationFactory;
use App\Tests\Factory\TicketFactory;
use App\Tests\Factory\UserFactory;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Zenstruck\Foundry\Test\Factories;
use Zenstruck\Foundry\Test\ResetDatabase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Copyright 2022 Probesys
// SPDX-License-Identifier: AGPL-3.0-or-later

namespace App\Factory;
namespace App\Tests\Factory;

use App\Entity\Message;
use App\Repository\MessageRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Copyright 2022 Probesys
// SPDX-License-Identifier: AGPL-3.0-or-later

namespace App\Factory;
namespace App\Tests\Factory;

use App\Entity\Organization;
use App\Repository\OrganizationRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Copyright 2022 Probesys
// SPDX-License-Identifier: AGPL-3.0-or-later

namespace App\Factory;
namespace App\Tests\Factory;

use App\Entity\Ticket;
use App\Repository\TicketRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Copyright 2022 Probesys
// SPDX-License-Identifier: AGPL-3.0-or-later

namespace App\Factory;
namespace App\Tests\Factory;

use App\Entity\User;
use App\Repository\UserRepository;
Expand Down

0 comments on commit 3849b6e

Please sign in to comment.