-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Showing
5 changed files
with
78 additions
and
52 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
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,48 @@ | ||
<?php | ||
|
||
namespace Src\Controllers; | ||
|
||
use Psr\Container\ContainerInterface; | ||
use Psr\Http\Message\RequestInterface; | ||
use Psr\Http\Message\ResponseInterface; | ||
|
||
/** | ||
* Class CSSGeneratorController | ||
* | ||
* The controller for generating webfonts CSS files. | ||
* | ||
* @author Finesse | ||
* @package Src\Controllers | ||
*/ | ||
class CSSGeneratorController | ||
{ | ||
/** | ||
* @var ContainerInterface Dependencies container | ||
*/ | ||
protected $container; | ||
|
||
/** | ||
* @param ContainerInterface $container Dependencies container | ||
*/ | ||
public function __construct(ContainerInterface $container) | ||
{ | ||
$this->container = $container; | ||
} | ||
|
||
/** | ||
* Runs the controller action. | ||
* | ||
* @param RequestInterface $request | ||
* @param ResponseInterface $response | ||
* @return ResponseInterface | ||
*/ | ||
public function __invoke(RequestInterface $request, ResponseInterface $response): ResponseInterface | ||
{ | ||
$response = $response->withHeader('Content-Type', 'text/css; charset=UTF-8'); | ||
|
||
$body = $response->getBody(); | ||
$body->write('body {color: #555;}'); | ||
|
||
return $response; | ||
} | ||
} |
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,17 @@ | ||
<?php | ||
|
||
namespace Tests\Functional; | ||
|
||
class CssGeneratorTest extends BaseTestCase | ||
{ | ||
/** | ||
* Test that the route returns a CSS file response | ||
*/ | ||
public function testStatusAndContentType() | ||
{ | ||
$response = $this->runApp('GET', '/css'); | ||
|
||
$this->assertEquals(200, $response->getStatusCode()); | ||
$this->assertTrue((bool)preg_match('~^text/css(;|$)~', $response->getHeaderLine('Content-Type'))); | ||
} | ||
} |
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