Skip to content

Commit 9902d10

Browse files
committed
Remove dead code and over-engineering from test app
1 parent c55b239 commit 9902d10

6 files changed

Lines changed: 2 additions & 46 deletions

File tree

tests/_app/Controller/AppController.php

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use Symfony\Component\Validator\Constraints\Email as EmailConstraint;
2121
use Symfony\Component\Validator\Constraints\NotBlank;
2222
use Symfony\Contracts\HttpClient\HttpClientInterface;
23-
use Symfony\Contracts\Translation\TranslatorInterface;
2423
use Tests\App\Event\TestEvent;
2524
use Tests\App\Mailer\RegistrationMailer;
2625
use Twig\Environment;
@@ -130,11 +129,6 @@ public function redirectToHome(): RedirectResponse
130129
return new RedirectResponse('/');
131130
}
132131

133-
public function redirectToSample(): RedirectResponse
134-
{
135-
return new RedirectResponse('/sample');
136-
}
137-
138132
public function register(Request $request, Environment $twig): Response
139133
{
140134
if ($request->isMethod('POST')) {
@@ -169,14 +163,9 @@ public function responseWithCookie(): Response
169163
return $response;
170164
}
171165

172-
public function sample(Request $request, Environment $twig): Response
166+
public function sample(Environment $twig): Response
173167
{
174-
$request->attributes->set('foo', 'bar');
175-
176-
$response = new Response($twig->render('sample.html.twig'), 200, ['X-Test' => '1']);
177-
$response->headers->setCookie(new Cookie('response_cookie', 'yum'));
178-
179-
return $response;
168+
return new Response($twig->render('sample.html.twig'));
180169
}
181170

182171
public function sendEmail(RegistrationMailer $mailer): Response
@@ -191,18 +180,6 @@ public function testPage(Environment $twig): Response
191180
return new Response($twig->render('test_page.html.twig'));
192181
}
193182

194-
public function translation(TranslatorInterface $translator): Response
195-
{
196-
$translator->trans('defined_message');
197-
198-
return new Response('Translation');
199-
}
200-
201-
public function twig(Environment $twig): Response
202-
{
203-
return new Response($twig->render('home.html.twig'));
204-
}
205-
206183
public function unprocessableEntity(): JsonResponse
207184
{
208185
return new JsonResponse([

tests/_app/Repository/UserRepository.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@
1010
/** @extends EntityRepository<User> */
1111
final class UserRepository extends EntityRepository implements UserRepositoryInterface
1212
{
13-
public function save(User $user): void
14-
{
15-
$this->_em->persist($user);
16-
$this->_em->flush();
17-
$this->_em->clear();
18-
}
19-
2013
public function getByEmail(string $email): ?User
2114
{
2215
return $this->findOneBy(['email' => $email]);

tests/_app/Repository/UserRepositoryInterface.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,5 @@
88

99
interface UserRepositoryInterface
1010
{
11-
public function save(User $user): void;
12-
1311
public function getByEmail(string $email): ?User;
1412
}

tests/_app/config/routes.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,12 @@
1717
$routes->add('http_client', '/http-client')->controller(AppController::class . '::httpClientRequests');
1818
$routes->add('index', '/')->controller(AppController::class . '::index');
1919
$routes->add('logout', '/logout')->controller(AppController::class . '::logout');
20-
$routes->add('redirect', '/redirect')->controller(AppController::class . '::redirectToSample');
2120
$routes->add('redirect_home', '/redirect_home')->controller(AppController::class . '::redirectToHome');
2221
$routes->add('request_attr', '/request_attr')->controller(AppController::class . '::requestWithAttribute');
2322
$routes->add('response_cookie', '/response_cookie')->controller(AppController::class . '::responseWithCookie');
2423
$routes->add('response_json', '/response_json')->controller(AppController::class . '::responseJsonFormat');
2524
$routes->add('sample', '/sample')->controller(AppController::class . '::sample');
2625
$routes->add('send_email', '/send-email')->controller(AppController::class . '::sendEmail');
2726
$routes->add('test_page', '/test_page')->controller(AppController::class . '::testPage');
28-
$routes->add('translation', '/translation')->controller(AppController::class . '::translation');
29-
$routes->add('twig', '/twig')->controller(AppController::class . '::twig');
3027
$routes->add('unprocessable_entity', '/unprocessable_entity')->controller(AppController::class . '::unprocessableEntity');
3128
};

tests/_app/config/services.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use Symfony\Component\HttpClient\MockHttpClient;
1414
use Symfony\Component\HttpClient\TraceableHttpClient;
1515
use Symfony\Component\HttpKernel\DataCollector\LoggerDataCollector;
16-
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
1716
use Symfony\Component\Mailer\EventListener\MessageLoggerListener;
1817
use Symfony\Component\Notifier\EventListener\NotificationLoggerListener;
1918
use Tests\App\Command\TestCommand;
@@ -57,7 +56,6 @@
5756
->tag('security.user_provider');
5857

5958
$services->alias('security.password_hasher', 'security.user_password_hasher')->public();
60-
$services->alias(UserPasswordHasherInterface::class, 'security.user_password_hasher')->public();
6159

6260
if (class_exists(Security::class)) {
6361
$services->set(Security::class)->arg('$container', service('test.service_container'));
@@ -106,9 +104,4 @@
106104
->tag('data_collector', ['id' => 'logger', 'template' => '@WebProfiler/Collector/logger.html.twig', 'priority' => 300]);
107105
$services->alias('data_collector.logger', LoggerDataCollector::class)->public();
108106

109-
if (BaseKernel::VERSION_ID < 60100) {
110-
$services->defaults()
111-
->bind(\Symfony\Contracts\HttpClient\HttpClientInterface::class . ' $httpClient', service('app.http_client'))
112-
->bind(\Symfony\Contracts\HttpClient\HttpClientInterface::class . ' $jsonClient', service('app.http_client.json_client'));
113-
}
114107
};

tests/_app/templates/home.html.twig

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)