- Move src/, tests/, bin/, generated/, proto/, composer.json, composer.lock, phpunit.xml from php/ to repo root - Move ref/ to doc/reference_samples/ for better organization - Remove vendor/ from git tracking (now properly gitignored) - Update all test file paths (dirname adjustments and ref/ -> doc/reference_samples/) - Update all documentation paths (AGENTS.md, doc/*.md) - Remove php.bak/ directory - All 252 tests pass
80 lines
2.6 KiB
PHP
80 lines
2.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace ProPresenter\Parser\Tests;
|
|
|
|
use InvalidArgumentException;
|
|
use PHPUnit\Framework\Attributes\Test;
|
|
use PHPUnit\Framework\TestCase;
|
|
use ProPresenter\Parser\ProFileReader;
|
|
use RuntimeException;
|
|
|
|
class ProFileReaderTest extends TestCase
|
|
{
|
|
#[Test]
|
|
public function readThrowsOnMissingFile(): void
|
|
{
|
|
$this->expectException(InvalidArgumentException::class);
|
|
ProFileReader::read(dirname(__DIR__) . '/doc/reference_samples/does-not-exist.pro');
|
|
}
|
|
|
|
#[Test]
|
|
public function readThrowsOnEmptyFile(): void
|
|
{
|
|
$this->expectException(RuntimeException::class);
|
|
ProFileReader::read(dirname(__DIR__) . '/doc/reference_samples/all-songs/Du machst alles neu_ver2025-05-11-4.pro');
|
|
}
|
|
|
|
#[Test]
|
|
public function readLoadsTestProAndReturnsSong(): void
|
|
{
|
|
$song = ProFileReader::read(dirname(__DIR__) . '/doc/reference_samples/Test.pro');
|
|
|
|
$this->assertSame('Test', $song->getName());
|
|
$this->assertCount(4, $song->getGroups());
|
|
$this->assertCount(2, $song->getArrangements());
|
|
}
|
|
|
|
#[Test]
|
|
public function readHandlesUtf8Filename(): void
|
|
{
|
|
$matches = glob(dirname(__DIR__) . '/doc/reference_samples/all-songs/-- ANK*DIGUNGEN --.pro');
|
|
$this->assertNotFalse($matches);
|
|
$this->assertNotEmpty($matches);
|
|
|
|
$song = ProFileReader::read($matches[0]);
|
|
|
|
$this->assertNotSame('', $song->getName());
|
|
$this->assertGreaterThanOrEqual(0, count($song->getGroups()));
|
|
}
|
|
|
|
#[Test]
|
|
public function readLoadsDiverseReferenceFilesSuccessfully(): void
|
|
{
|
|
$repoRoot = dirname(__DIR__);
|
|
$files = [
|
|
$repoRoot . '/doc/reference_samples/Test.pro',
|
|
$repoRoot . '/doc/reference_samples/all-songs/Cornerstone.pro',
|
|
$repoRoot . '/doc/reference_samples/all-songs/Du machst alles neu.pro',
|
|
$repoRoot . '/doc/reference_samples/all-songs/-- MODERATION --.pro',
|
|
];
|
|
|
|
$oceans = glob($repoRoot . '/doc/reference_samples/all-songs/Oceans*TRANS*.pro');
|
|
$announcements = glob($repoRoot . '/doc/reference_samples/all-songs/-- ANK*DIGUNGEN --.pro');
|
|
|
|
$this->assertNotFalse($oceans);
|
|
$this->assertNotFalse($announcements);
|
|
$this->assertNotEmpty($oceans);
|
|
$this->assertNotEmpty($announcements);
|
|
|
|
$files[] = $oceans[0];
|
|
$files[] = $announcements[0];
|
|
|
|
foreach ($files as $file) {
|
|
$song = ProFileReader::read($file);
|
|
$this->assertNotSame('', $song->getUuid(), sprintf('Song UUID should not be empty for %s', basename($file)));
|
|
}
|
|
}
|
|
}
|