Commit 214d3b46 authored by Dainis Abols's avatar Dainis Abols
Browse files

Added `LU Tools` section and Logo generation endpoint

v3.1.0
parent 63cdba43
This diff is collapsed.
<?php
declare(strict_types=1);
namespace Lu\LuApi\Functional;
use Lu\LuApi\Helpers\DataHelper;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
/**
* Test for route `?r=logo`
*
* @author Dainis Abols <dainis.abols@lu.lv>
* @owner University of Latvia
* @since 22.02.2022
*/
class LogoTest extends UnitTestCase
{
protected $resetSingletonInstances = true;
/**
* LocalConfiguration file name and relative location
*
* @var string
*/
private string $LocalConfiguration = 'public/typo3conf/LocalConfiguration.php';
/**
* Program test
*
* @test
*/
public function logoSVGTest()
{
// Read settings
$conf = @include $this->LocalConfiguration;
$testUrl = @$conf['EXTENSIONS']['lu_api']['testAPIUrl'];
// Read SVG
$url = $testUrl.'?r=logo/.svg';
$result = (new DataHelper())->fetchUrl($url);
// Assert url read
$code = !empty($result) ? $result->getStatusCode() : 500;
$this->assertEquals(200, $code, 'Logo svg url read failed ['.$url.']');
// Assert svg file
$this->assertTrue($result->getHeader('Content-Type')[0] === 'image/svg+xml', 'Logo response is not an image');
}
/**
* Program test
*
* @test
*/
public function logoPNGTest()
{
// Read settings
$conf = @include $this->LocalConfiguration;
$testUrl = @$conf['EXTENSIONS']['lu_api']['testAPIUrl'];
// Read SVG
$url = $testUrl.'?r=logo/w40.png';
$result = (new DataHelper())->fetchUrl($url);
// Assert url read
$code = !empty($result) ? $result->getStatusCode() : 500;
$this->assertEquals(200, $code, 'Logo png url read failed ['.$url.']');
// Assert svg file
$this->assertTrue($result->getHeader('Content-Type')[0] === 'image/png', 'Logo response is not an image');
// Asset correct size
$this->assertEquals(40, getimagesizefromstring($result->getBody()->getContents())[0], 'Logo response size is incorrect');
}
}
\ No newline at end of file
{
"name": "luitd/lu-api",
"version": "3.0.7",
"version": "3.1.0",
"description": "REST API Integration for TYPO3",
"type": "typo3-cms-extension",
"keywords": [
......
......@@ -14,7 +14,7 @@ $EM_CONF[$_EXTKEY] = [
'title' => 'LU API',
'description' => 'REST API Integration for TYPO3',
'category' => 'plugin',
'version' => '3.0.7',
'version' => '3.1.0',
'dependencies' => 'typo3',
'state' => 'stable',
'clearCacheOnLoad' => true,
......
<?php
defined('TYPO3_MODE') or die ('Access denied.');
/*
* Suggested new aproach does not work yet:
* https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/11.0/Deprecation-92947-DeprecateTYPO3_MODEAndTYPO3_REQUESTTYPEConstants.html
*/
if (TYPO3_MODE === 'BE') {
call_user_func(
function () {
// Main Blog
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModule(
'lutools',
'',
'after:web',
null,
[
'labels' => 'LLL:EXT:lu_api/Resources/Private/Language/locallang.xlf',
'name' => 'lutools',
'icon' => 'EXT:lu_api/Resources/Public/Icons/LUTools.svg',
]
);
}
);
}
......@@ -4,7 +4,7 @@
## Version
3.0.7
3.1.0
## Dependencies
......@@ -16,21 +16,22 @@ Dainis Abols <dainis.abols@lu.lv>
## Frontend routes
| Route | Response | Purpose |
|------------------------------------------|----------------|-------------------------------------|
| ?r=download/purchase/{file-id} | BIN FILE | Returns file as download |
| ?r=qrcode/generate/{encoded-full-url} | PNG IMAGE | Returns visual PNG image |
| ?r=course/search/{search-term} | JSON | Input auto complete |
| ?r=course-continue/search/{search-term} | JSON | Input auto complete |
| ?r=program/search/{search-term} | JSON | Input auto complete |
| ?r=program-continue/search/{search-term} | JSON | Input auto complete |
| ?r=purchase/{search-params} | JSON | Results for datatables |
| ?r=namedays/search/{search-params} | JSON | Name days by name or date |
| ?r=naba-live/search/ | JSON | Get Radio NABA Live stream songs |
| ?r=naba-store | JSON | Save Radio NABA songs from playlist |
| ?r=dabas-maja/{search-params} | JSON DT / HTML | Results for datatables or as html |
| ?r=zinatnu-maja/{search-params} | JSON DT / HTML | Results for datatables or as html |
| ?r=email/search/ | JSON / HTML | Get email client type or as html |
| Route | Response | Purpose |
|------------------------------------------------------|----------------|-------------------------------------|
| ?r=download/purchase/{file-id} | BIN FILE | Returns file as download |
| ?r=qrcode/generate/{encoded-full-url} | PNG IMAGE | Returns visual PNG image |
| ?r=course/search/{search-term} | JSON | Input auto complete |
| ?r=course-continue/search/{search-term} | JSON | Input auto complete |
| ?r=program/search/{search-term} | JSON | Input auto complete |
| ?r=program-continue/search/{search-term} | JSON | Input auto complete |
| ?r=purchase/{search-params} | JSON | Results for datatables |
| ?r=namedays/search/{search-params} | JSON | Name days by name or date |
| ?r=naba-live/search/ | JSON | Get Radio NABA Live stream songs |
| ?r=naba-store | JSON | Save Radio NABA songs from playlist |
| ?r=dabas-maja/{search-params} | JSON DT / HTML | Results for datatables or as html |
| ?r=zinatnu-maja/{search-params} | JSON DT / HTML | Results for datatables or as html |
| ?r=email/search/ | JSON / HTML | Get email client type or as html |
| ?r=logo/{type}_{weight}_{width}_{height}.{extension} | JSON / HTML | Get email client type or as html |
## Configuration
......@@ -81,6 +82,7 @@ return [
| Functional/RoutesTest.php | 42 |
| Functional/DownloadTest.php | 6 |
| Functional/QRCodeTest.php | 5 |
| Functional/LogoTest.php | 9 |
| Functional/CourseTest.php | 5 |
| Functional/CourseContinueTest.php | 5 |
| Functional/ProgramTest.php | 5 |
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment