mirror of
https://codeberg.org/demostf/api.git
synced 2026-06-03 09:54:17 +02:00
cleanup
This commit is contained in:
parent
5986d8552d
commit
73469d2aa1
29 changed files with 140 additions and 149 deletions
|
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Demostf\API\Test\Providers;
|
||||
|
||||
use DateTime;
|
||||
use Demostf\API\Data\ParsedDemo;
|
||||
use Demostf\API\Demo\Demo;
|
||||
use Demostf\API\Demo\DemoSaver;
|
||||
|
|
@ -21,6 +22,10 @@ use Demostf\API\Providers\UserProvider;
|
|||
use Demostf\API\Test\TestCase;
|
||||
use Doctrine\DBAL\Connection;
|
||||
use InvalidArgumentException;
|
||||
use RecursiveDirectoryIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
use ReflectionException;
|
||||
use function strlen;
|
||||
|
||||
class UploadProviderTest extends TestCase {
|
||||
/** @var RawParser */
|
||||
|
|
@ -42,6 +47,9 @@ class UploadProviderTest extends TestCase {
|
|||
/** @var string */
|
||||
private $tmpDir;
|
||||
|
||||
/**
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
|
|
@ -90,10 +98,10 @@ class UploadProviderTest extends TestCase {
|
|||
}
|
||||
|
||||
private function rmdirr($dir) {
|
||||
$it = new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS);
|
||||
$files = new \RecursiveIteratorIterator(
|
||||
$it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS);
|
||||
$files = new RecursiveIteratorIterator(
|
||||
$it,
|
||||
\RecursiveIteratorIterator::CHILD_FIRST
|
||||
RecursiveIteratorIterator::CHILD_FIRST
|
||||
);
|
||||
foreach ($files as $file) {
|
||||
if ($file->isDir()) {
|
||||
|
|
@ -209,7 +217,7 @@ class UploadProviderTest extends TestCase {
|
|||
public function testUploadInvalidKey() {
|
||||
$this->assertEquals(
|
||||
'Invalid key',
|
||||
$this->uploadProvider->upload('asdasd', 'RED', 'BLU', 'asdasd', 'asdas')
|
||||
$this->uploadProvider->upload('dummy', 'RED', 'BLU', 'dummy', 'dummy')
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -222,7 +230,7 @@ class UploadProviderTest extends TestCase {
|
|||
$steamId = $this->getSteamId('123', 'a');
|
||||
$token = $this->userProvider->store($steamId);
|
||||
|
||||
$this->uploadProvider->upload($token, 'RED', 'BLU', 'asdasd', $this->tmpDir . '/foo.dem');
|
||||
$this->uploadProvider->upload($token, 'RED', 'BLU', 'dummy', $this->tmpDir . '/foo.dem');
|
||||
}
|
||||
|
||||
public function testUploadExisting() {
|
||||
|
|
@ -240,7 +248,7 @@ class UploadProviderTest extends TestCase {
|
|||
12,
|
||||
'n',
|
||||
'm',
|
||||
new \DateTime(),
|
||||
new DateTime(),
|
||||
'r',
|
||||
'b',
|
||||
1,
|
||||
|
|
@ -260,7 +268,7 @@ class UploadProviderTest extends TestCase {
|
|||
|
||||
$this->assertEquals(
|
||||
'STV available at: http://example.com/' . $id,
|
||||
$this->uploadProvider->upload($token, 'RED', 'BLU', 'asdasd', $this->tmpDir . '/foo.dem')
|
||||
$this->uploadProvider->upload($token, 'RED', 'BLU', 'dummy', $this->tmpDir . '/foo.dem')
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -299,7 +307,7 @@ class UploadProviderTest extends TestCase {
|
|||
$result = $this->uploadProvider->upload($token, 'RED', 'BLU', 'foodemo', $this->tmpDir . '/foo.dem');
|
||||
$this->assertStringStartsWith('STV available at: http://example.com/', $result);
|
||||
|
||||
$demoId = (int) substr($result, \strlen('STV available at: http://example.com/'));
|
||||
$demoId = (int) substr($result, strlen('STV available at: http://example.com/'));
|
||||
|
||||
$demo = $this->demoProvider->get($demoId, true);
|
||||
|
||||
|
|
@ -331,7 +339,7 @@ class UploadProviderTest extends TestCase {
|
|||
|
||||
$this->assertEquals(
|
||||
'Invalid key',
|
||||
$uploadProvider->upload($token, 'RED', 'BLU', 'asdasd', 'asdas')
|
||||
$uploadProvider->upload($token, 'RED', 'BLU', 'dummy', 'dummy')
|
||||
);
|
||||
|
||||
$uploadProvider = new UploadProvider(
|
||||
|
|
@ -348,6 +356,6 @@ class UploadProviderTest extends TestCase {
|
|||
|
||||
file_put_contents($this->tmpDir . '/foo.dem', 'asd');
|
||||
|
||||
$uploadProvider->upload($token, 'RED', 'BLU', 'asdasd', $this->tmpDir . '/foo.dem');
|
||||
$uploadProvider->upload($token, 'RED', 'BLU', 'dummy', $this->tmpDir . '/foo.dem');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue