Skip to content

Commit

Permalink
phpcs tests/Feature/Middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
TomHAnderson committed Oct 28, 2024
1 parent 4e17f4e commit 25d0b4a
Showing 1 changed file with 24 additions and 28 deletions.
52 changes: 24 additions & 28 deletions tests/Feature/Middleware/SubstituteBindingsTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace LaravelDoctrineTest\ORM\Feature\Middleware;

use Doctrine\ORM\EntityManager;
Expand All @@ -21,37 +23,31 @@

class SubstituteBindingsTest extends TestCase
{
/**
* @var Mock
*/
private $registry;
/** @var Mock */
private ManagerRegistry $registry;

/**
* @var Mock
*/
private $em;
/** @var Mock */
private EntityManager $em;

/**
* @var Mock
*/
private $repository;
/** @var Mock */
private ObjectRepository $repository;

public function setUp(): void
{
$this->registry = m::mock(ManagerRegistry::class);
$this->em = m::mock(EntityManager::class);
$this->repository = m::mock(ObjectRepository::class);
$this->registry = m::mock(ManagerRegistry::class);
$this->em = m::mock(EntityManager::class);
$this->repository = m::mock(ObjectRepository::class);

parent::setUp();
}

protected function getRouter()
protected function getRouter(): Router
{
$container = new Container;
$container->bind(CallableDispatcherContract::class, fn ($app) => new CallableDispatcher($app));
$router = new Router(new Dispatcher, $container);
$container = new Container();
$container->bind(CallableDispatcherContract::class, static fn ($app) => new CallableDispatcher($app));
$router = new Router(new Dispatcher(), $container);

$container->singleton(Registrar::class, function () use ($router) {
$container->singleton(Registrar::class, static function () use ($router) {
return $router;
});

Expand All @@ -62,12 +58,12 @@ protected function getRouter()
return $router;
}

protected function mockRegistry()
protected function mockRegistry(): void
{
$this->registry->shouldReceive('getRepository')->once()->with('LaravelDoctrineTest\ORM\Assets\Middleware\BindableEntity')->andReturn($this->repository);
}

public function test_entity_binding()
public function testEntityBinding(): void
{
$router = $this->getRouter();
$router->get('foo/{entity}', [
Expand All @@ -84,7 +80,7 @@ public function test_entity_binding()
$this->assertEquals('namevalue', $router->dispatch(Request::create('foo/1', 'GET'))->getContent());
}

public function test_entity_binding_expect_entity_not_found_exception()
public function testEntityBindingExpectEntityNotFoundException(): void
{
$this->expectException('Doctrine\ORM\EntityNotFoundException');

Expand All @@ -101,7 +97,7 @@ public function test_entity_binding_expect_entity_not_found_exception()
$router->dispatch(Request::create('foo/1', 'GET'))->getContent();
}

public function test_entity_binding_get_null_entity()
public function testEntityBindingGetNullEntity(): void
{
$router = $this->getRouter();
$router->get('foo/{entity}', [
Expand All @@ -115,7 +111,7 @@ public function test_entity_binding_get_null_entity()
$this->assertEquals('', $router->dispatch(Request::create('foo/1', 'GET'))->getContent());
}

public function test_binding_value()
public function testBindingValue(): void
{
$router = $this->getRouter();
$router->get('foo/{value}', [
Expand All @@ -133,7 +129,7 @@ public function test_binding_value()
$this->assertEquals('request', $router->dispatch(Request::create('doc/trine', 'GET'))->getContent());
}

public function test_controller_entity_binding()
public function testControllerEntityBinding(): void
{
$router = $this->getRouter();
$router->get('foo/{entity}', [
Expand All @@ -150,7 +146,7 @@ public function test_controller_entity_binding()
$this->assertEquals('namevalue', $router->dispatch(Request::create('foo/1', 'GET'))->getContent());
}

public function test_not_id_binding()
public function testNotIdBinding(): void
{
$router = $this->getRouter();
$router->get('foo/{entity}', [
Expand All @@ -167,7 +163,7 @@ public function test_not_id_binding()
$this->assertEquals(1, $router->dispatch(Request::create('foo/NAMEVALUE', 'GET'))->getContent());
}

public function test_for_typed_value_binding()
public function testForTypedValueBinding(): void
{
$router = $this->getRouter();
$router->get('foo/{value}', [
Expand Down

0 comments on commit 25d0b4a

Please sign in to comment.