-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
09921b3
commit 815c403
Showing
13 changed files
with
2,129 additions
and
718 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,6 @@ | |
|
||
// Web Profiler | ||
$framework->profiler([ | ||
'collect' => false | ||
'collect' => false, | ||
]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{% extends 'layout.html.twig' %} | ||
|
||
{% block body %} | ||
<h1>{{ title }}</h1> | ||
|
||
<label for="exampleCheckbox">Example Checkbox</label> | ||
<input type="checkbox" id="exampleCheckbox" name="exampleCheckbox" {% if checked %}checked{% endif %}> | ||
|
||
<label for="exampleInput">Example Input</label> | ||
<input type="text" id="exampleInput" name="exampleInput" value="{{ inputValue }}"> | ||
|
||
<p class="info">This is a test paragraph with some text.</p> | ||
|
||
<form id="testForm" action="{{ path('app_form_test') }}" method="post"> | ||
<div> | ||
<label for="username">Username</label> | ||
<input type="text" id="username" name="username" value="{{ usernameValue }}"> | ||
</div> | ||
<button type="submit">Submit</button> | ||
</form> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Controller; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\HttpFoundation\Cookie; | ||
use Symfony\Component\HttpFoundation\RedirectResponse; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
final class BrowserController extends AbstractController | ||
{ | ||
public function requestWithAttribute(Request $request): Response | ||
{ | ||
$request->attributes->set('page', 'register'); | ||
|
||
return $this->render('blog/home.html.twig'); | ||
} | ||
|
||
public function responseWithCookie(): Response | ||
{ | ||
$response = new Response('TESTCOOKIE has been set.'); | ||
$response->headers->setCookie(new Cookie('TESTCOOKIE', 'codecept')); | ||
|
||
return $response; | ||
} | ||
|
||
public function responseJsonFormat(): Response | ||
{ | ||
return $this->json([ | ||
'status' => 'success', | ||
'message' => "Expected format: 'json'.", | ||
]); | ||
} | ||
|
||
public function unprocessableEntity(): Response | ||
{ | ||
return $this->json([ | ||
'status' => 'error', | ||
'message' => 'The request was well-formed but could not be processed.', | ||
], Response::HTTP_UNPROCESSABLE_ENTITY); | ||
} | ||
|
||
public function redirectToHome(): RedirectResponse | ||
{ | ||
return $this->redirectToRoute('index'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Controller; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
final class DomCrawlerController extends AbstractController | ||
{ | ||
public function __invoke(): Response | ||
{ | ||
return $this->render('dom_crawler/test_page.html.twig', [ | ||
'page_title' => 'Test Page', | ||
'title' => 'Test Page', | ||
'checked' => true, | ||
'inputValue' => 'Expected Value', | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Controller; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
final class FormController extends AbstractController | ||
{ | ||
public function __invoke(Request $request): Response | ||
{ | ||
$data = [ | ||
'page_title' => 'Test Page', | ||
'checked' => false, | ||
'inputValue' => '', | ||
]; | ||
if ($request->isMethod('POST')) { | ||
$data['usernameValue'] = $request->request->get('username', ''); | ||
$data['title'] = 'Form Sent'; | ||
} else { | ||
$data['usernameValue'] = 'codeceptUser'; | ||
$data['title'] = 'Test Page'; | ||
} | ||
|
||
return $this->render('dom_crawler/test_page.html.twig', $data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Controller; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | ||
use Symfony\Contracts\HttpClient\HttpClientInterface; | ||
|
||
final class HttpClientController extends AbstractController | ||
{ | ||
private HttpClientInterface $httpClient; | ||
|
||
public function __construct(HttpClientInterface $httpClient) | ||
{ | ||
$this->httpClient = $httpClient; | ||
} | ||
|
||
public function routeUsingHttpClient(): Response | ||
{ | ||
$internalUrl = $this->generateUrl('internal_endpoint', [], UrlGeneratorInterface::ABSOLUTE_URL); | ||
|
||
$response = $this->httpClient->request('GET', $internalUrl, [ | ||
'headers' => ['Accept' => 'application/json'], | ||
]); | ||
|
||
return new Response("Internal request completed successfully: {$response->getStatusCode()}"); | ||
} | ||
|
||
public function internalEndpoint(): Response | ||
{ | ||
return $this->json(['message' => 'Response from internal endpoint.']); | ||
} | ||
|
||
public function routeMakingMultipleRequests(): Response | ||
{ | ||
$internalUrl = $this->generateUrl('internal_endpoint', [], UrlGeneratorInterface::ABSOLUTE_URL); | ||
$internalUrlPost = $this->generateUrl('internal_endpoint_post', [], UrlGeneratorInterface::ABSOLUTE_URL); | ||
|
||
$response1 = $this->httpClient->request('GET', $internalUrl, [ | ||
'headers' => ['Accept' => 'application/json'], | ||
]); | ||
|
||
$response2 = $this->httpClient->request('POST', $internalUrlPost, [ | ||
'headers' => ['Content-Type' => 'application/json'], | ||
'json' => ['key' => 'value'], | ||
]); | ||
|
||
$response3 = $this->httpClient->request('GET', $internalUrl, [ | ||
'headers' => ['Accept' => 'application/json'], | ||
]); | ||
|
||
$message = sprintf( | ||
"Request 1: %d\nRequest 2: %d\nRequest 3: %d", | ||
$response1->getStatusCode(), | ||
$response2->getStatusCode(), | ||
$response3->getStatusCode() | ||
); | ||
|
||
return new Response($message); | ||
} | ||
|
||
public function internalEndpointPost(Request $request): Response | ||
{ | ||
$data = json_decode($request->getContent(), true); | ||
|
||
return $this->json(['received' => $data]); | ||
} | ||
|
||
public function routeShouldNotMakeSpecificRequest(): Response | ||
{ | ||
return new Response('No specific internal requests were made.'); | ||
} | ||
|
||
public function internalEndpointNotDesired(): Response | ||
{ | ||
return $this->json(['message' => 'This endpoint should not be called.']); | ||
} | ||
} |
Oops, something went wrong.