Files
Testing/tus-php/tests/Tus/AbstractTusTest.php
sean 0e8a8b3028
Some checks are pending
deploy-testing / deploy (push) Waiting to run
Initial testing snapshot
2026-11-17 16:15:01 -05:00

80 lines
1.9 KiB
PHP

<?php
namespace TusPhp\Test\Tus;
use TusPhp\Cache\FileStore;
use TusPhp\Cache\RedisStore;
use PHPUnit\Framework\TestCase;
use TusPhp\Tus\Server as TusServer;
use Symfony\Component\EventDispatcher\EventDispatcher;
/**
* @coversDefaultClass \TusPhp\Tus\AbstractTus
*/
class AbstractTusTest extends TestCase
{
/** @var TusServer */
protected $tus;
/**
* Prepare vars.
*
* @return void
*/
public function setUp() : void
{
$this->tus = new TusServer;
parent::setUp();
}
/**
* @test
*
* @covers ::getCache
* @covers ::setCache
*/
public function it_sets_and_gets_cache() : void
{
$this->assertInstanceOf(FileStore::class, $this->tus->getCache());
$this->tus->setCache('redis');
$this->assertInstanceOf(RedisStore::class, $this->tus->getCache());
$fileStore = new FileStore;
$this->assertInstanceOf(TusServer::class, $this->tus->setCache($fileStore));
$this->assertInstanceOf(FileStore::class, $this->tus->getCache());
}
/**
* @test
*
* @covers ::getApiPath
* @covers ::setApiPath
*/
public function it_sets_and_gets_api_path() : void
{
$this->assertEquals('/files', $this->tus->getApiPath());
$this->assertInstanceOf(TusServer::class, $this->tus->setApiPath('/api'));
$this->assertEquals('/api', $this->tus->getApiPath());
}
/**
* @test
*
* @covers ::event
* @covers ::setDispatcher
*/
public function it_sets_and_gets_event_dispatcher() : void
{
$this->assertInstanceOf(EventDispatcher::class, $this->tus->event());
$eventDispatcher = new EventDispatcher();
$this->assertInstanceOf(TusServer::class, $this->tus->setDispatcher($eventDispatcher));
$this->assertEquals($eventDispatcher, $this->tus->event());
}
}