refactor: get the repository from the container
This commit is contained in:
parent
78841ad9d6
commit
bc747a1f70
5
.editorconfig
Normal file
5
.editorconfig
Normal file
|
@ -0,0 +1,5 @@
|
|||
root = true
|
||||
|
||||
[*.yaml]
|
||||
indent_style = space
|
||||
indent_size = 4
|
|
@ -8,20 +8,23 @@ parameters:
|
|||
services:
|
||||
# default configuration for services in *this* file
|
||||
_defaults:
|
||||
autowire: true # Automatically injects dependencies in your services.
|
||||
autowire: true # Automatically injects dependencies in your services.
|
||||
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
|
||||
|
||||
# makes classes in src/ available to be used as services
|
||||
# this creates a service per class whose id is the fully-qualified class name
|
||||
App\:
|
||||
resource: '../src/*'
|
||||
exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'
|
||||
resource: "../src/*"
|
||||
exclude: "../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}"
|
||||
|
||||
# controllers are imported separately to make sure services can be injected
|
||||
# as action arguments even if you don't extend any base controller class
|
||||
App\Controller\:
|
||||
resource: '../src/Controller'
|
||||
tags: ['controller.service_arguments']
|
||||
resource: "../src/Controller"
|
||||
tags: ["controller.service_arguments"]
|
||||
|
||||
# add more service definitions when explicit configuration is needed
|
||||
# please note that last definitions always *replace* previous ones
|
||||
App\EventRepository:
|
||||
class: App\Tests\FakeEventRepository
|
||||
public: true
|
||||
|
|
|
@ -2,13 +2,16 @@
|
|||
|
||||
namespace App\Tests;
|
||||
|
||||
use App\EventRepository;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
final class FakeEventRepositoryTest extends KernelTestCase
|
||||
{
|
||||
/** @test */
|
||||
public function should_only_return_attendees_with_a_yes_rsvp(): void {
|
||||
$repository = new FakeEventRepository();
|
||||
$container = self::bootKernel()->getContainer();
|
||||
$repository = $container->get(EventRepository::class);
|
||||
|
||||
$attendees = $repository->getConfirmedAttendees();
|
||||
|
||||
$this->assertCount(3, $attendees->pluck('name'));
|
||||
|
|
Loading…
Reference in a new issue