Commit ddd2d679 authored by Dainis Abols's avatar Dainis Abols
Browse files

DownloadTEst

parent bcb79b5f
<?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 route `?r=download`
*
* @author Dainis Abols <dainis.abols@lu.lv>
* @owner University of Latvia
* @since 22.02.2022
*/
class DownloadTest extends UnitTestCase
{
protected $resetSingletonInstances = true;
/**
* Public API URL
*
* @var string
*/
private string $url = 'https://www.lu.lv/api/?r=download/purchase/';
/**
* Test file ID
*
* @var int
*/
private int $fileId = 15882;
/**
* Download test
*
* @test
*/
public function downloadTest()
{
// Read url
$url = $this->url.'0';
$result = (new DataHelper())->fetchUrl($url);
// Assert url read
$code = !empty($result) ? $result->getStatusCode() : 500;
$this->assertEquals(200, $code, 'Download Url read failed ['.$url.']');
// Check empty results
$url = $this->url.$this->fileId;
$result = (new DataHelper())->fetchUrl($url);
// Assert url read
$this->assertEquals(200, $result->getStatusCode(), 'Download Url read failed ['.$url.']');
$this->assertEquals('File Transfer', $result->getHeader('Content-Description')[0], 'Download is not a file transfer');
$this->assertNotEmpty($result->getHeader('Content-Length')[0], 'Download file has no size');
}
}
\ No newline at end of file
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