Commit 81402ace authored by Dainis Abols's avatar Dainis Abols
Browse files

General Routes test

Redme update
Version 3.0.2
parent 80360d79
<?php
declare(strict_types=1);
namespace Lu\LuApi\Functional;
use Lu\LuApi\Helpers\DataHelper;
use Vendor\MyExtension\Service\AbstractSomethingService;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
/**
* Test for type class `Table`
*
* @author Dainis Abols <dainis.abols@lu.lv>
* @owner University of Latvia
* @since 21.02.2022
*/
class RoutesTest extends UnitTestCase
{
protected $resetSingletonInstances = true;
/**
* Public API URL
*
* @var string
*/
private string $url = 'https://www.lu.lv/api/';
/**
* Main API Test
*
* @test
*/
public function apiTest()
{
$url = $this->url;
$this->assertEquals(200, (new DataHelper())->fetchUrl($url, true), 'Url read failed ['.$url.']');
}
/**
* Download route test
*
* @test
* @depends apiTest
*/
public function downloadTest()
{
$url = $this->url.'?r=download/purchase/0';
$this->assertEquals(200, (new DataHelper())->fetchUrl($url, true), 'Url read failed ['.$url.']');
}
/**
* QRCOde route test
*
* @test
* @depends apiTest
*/
public function qrcodeTest()
{
// $url = $this->url.'?r=qrcode/generate/'.urlencode($this->url); // @TODO UNCOMMENT THIS
$url = 'https://typo3-dev2.lu.lv/api/?r=qrcode/generate/'.urlencode($this->url);
$this->assertEquals(200, (new DataHelper())->fetchUrl($url, true), 'Url read failed ['.$url.']');
}
/**
* Course route test
*
* @test
* @depends apiTest
*/
public function courseTest()
{
$url = $this->url.'?r=course/search/aaa';
$this->assertEquals(200, (new DataHelper())->fetchUrl($url, true), 'Url read failed ['.$url.']');
}
/**
* Course continue route test
*
* @test
* @depends apiTest
*/
public function courseContinueTest()
{
$url = $this->url.'?r=course-continue/search/aaa';
$this->assertEquals(200, (new DataHelper())->fetchUrl($url, true), 'Url read failed ['.$url.']');
}
/**
* Programme route test
*
* @test
* @depends apiTest
*/
public function programTest()
{
$url = $this->url.'?r=program/search/aaa';
$this->assertEquals(200, (new DataHelper())->fetchUrl($url, true), 'Url read failed ['.$url.']');
}
/**
* Programme continue route test
*
* @test
* @depends apiTest
*/
public function programContinueTest()
{
$url = $this->url.'?r=program-continue/search/aaa';
$this->assertEquals(200, (new DataHelper())->fetchUrl($url, true), 'Url read failed ['.$url.']');
}
/**
* Purchse route test
*
* @test
* @depends apiTest
*/
public function purchaseRouteTest()
{
$url = $this->url.'?r=purchase';
$this->assertEquals(200, (new DataHelper())->fetchUrl($url, true), 'Url read failed ['.$url.']');
}
/**
* Namedays route test
*
* @test
* @depends apiTest
*/
public function namedaysTest()
{
$url = $this->url.'?r=namedays/search/';
$this->assertEquals(200, (new DataHelper())->fetchUrl($url, true), 'Url read failed ['.$url.']');
}
/**
* Naba Live route test
*
* @test
* @depends apiTest
*/
public function nabaLiveTest()
{
$url = $this->url.'?r=naba-live/search/';
$this->assertEquals(200, (new DataHelper())->fetchUrl($url, true), 'Url read failed ['.$url.']');
}
/**
* Naba Store route test
*
* @test
* @depends apiTest
*/
public function nabaStoreTest()
{
$url = $this->url.'?r=naba-store';
$this->assertEquals(200, (new DataHelper())->fetchUrl($url, true), 'Url read failed ['.$url.']');
}
/**
* Dabas Maja Lessons route test
*
* @test
* @depends apiTest
*/
public function dabasMajaTest()
{
$url = $this->url.'?r=dabas-maja/search/1';
$this->assertEquals(200, (new DataHelper())->fetchUrl($url, true), 'Url read failed ['.$url.']');
}
/**
* Zinatnu Maja Lessons route test
*
* @test
* @depends apiTest
*/
public function zinatnuMajaTest()
{
$url = $this->url.'?r=zinatnu-maja/search/1';
$this->assertEquals(200, (new DataHelper())->fetchUrl($url, true), 'Url read failed ['.$url.']');
}
/**
* Email route test
*
* @test
* @depends apiTest
*/
public function emailTest()
{
$url = $this->url.'?r=email/search';
$this->assertEquals(200, (new DataHelper())->fetchUrl($url, true), 'Url read failed ['.$url.']');
}
}
{
"name": "luitd/lu-api",
"version": "3.0.1",
"version": "3.0.2",
"description": "REST API Integration for TYPO3",
"type": "typo3-cms-extension",
"keywords": [
......@@ -26,6 +26,11 @@
"Lu\\LuApi\\": "Classes"
}
},
"autoload-dev": {
"psr-4": {
"Lu\\LuApi\\Tests\\": "Tests"
}
},
"replace": {
"typo3-ter/lu_api": "self.version"
},
......
......@@ -14,7 +14,7 @@ $EM_CONF[$_EXTKEY] = [
'title' => 'LU API',
'description' => 'REST API Integration for TYPO3',
'category' => 'plugin',
'version' => 'v3.0.1',
'version' => '3.0.2',
'dependencies' => 'typo3',
'state' => 'stable',
'clearCacheOnLoad' => true,
......
......@@ -16,19 +16,21 @@ 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=tornkalns-lessons/{search-params} | JSON DT / HTML | Results for datatables or as html |
| ?r=namedays/search/{search-params} | JSON | Name days by name or date |
| ?r=email/search/ | JSON / HTML | Get email client type or as html |
| ?r=naba-live/search/ | JSON | Get Radio NABA Live stream songs |
| 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 |
## Configuration
......@@ -53,14 +55,14 @@ return [
### Plugin Configuration
| Tab | Var name | Meaning |
| ------- | ----------------------------------------- | ----------------------------------- |
| General | configFile | Configuration file location | |
|---------|-------------------------------------------|-------------------------------------|
| General | configFile | Configuration file location |
| General | extraImages | Use LUIS Images |
| General | imagesTempFolder | Image temp folder |
| General | extraImagesStorage | Image storage ID |
| | | |
| -- | -- | -- |
| cTypes | endPoints.ContractsList | Contracts List Url |
| | | |
| -- | -- | -- |
| SOLR | solrDatabase.search | Main search DB |
| SOLR | solrDatabase.programmeCatalogue | Programme catalogue DB |
| SOLR | solrDatabase.programmeCatalogueContinuing | Programme catalogue (continuing) DB |
......@@ -70,6 +72,30 @@ return [
| SOLR | solrDatabase.regulations | Regulations (NAS) DB |
## Testing
```shell
./vendor/bin/phpunit public/typo3conf/ext/lu_api/Tests/<test-file>
```
| Test File | Assertions |
|------------------------------------|------------|
| Functional/RoutesTest.php | 42 |
| Functional/DownloadTest.php | 6 |
| Functional/QRCodeTest.php | 5 |
| Functional/CourseTest.php | 5 |
| Functional/CourseContinueTest.php | 5 |
| Functional/ProgramTest.php | 5 |
| Functional/ProgramContinueTest.php | 5 |
| Functional/PurchaseTest.php | 8 |
| Functional/NamedaysTest.php | 10 |
| Functional/NabaLiveTest.php | 6 |
| Functional/NabaStoreTest.php | 5 |
| Functional/LessonsTest.php | 26 |
| Functional/EmailTest.php | 8 |
| Type/RequestTypeTest.php | 25 |
| Type/TableTest.php | 25 |
| Type/UsernameTest.php | 26 |
## Notes
_When listing catalogues, it is sorted by `nosaukums_{lang}`, if search term is provided (or filter elements) then it is sorted by returned SOLR relation!_
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