PHP 8.4 library and CLI tools to read, modify, and generate ProPresenter 7 files: songs (.pro), playlists (.proplaylist), bundles (.probundle), themes, and the global library files (Macros, Labels, Groups, ClearGroups, CCLI, Messages, Timers, Stage, Workspace, Props, TestPatterns, Calendar, KeyMappings, CommunicationDevices). Built on the MIT-licensed ProPresenter7-Proto schema by greyshirtguy (v7.16.2). Includes 18 CLI parsers, comprehensive API docs in doc/, binary-format specs, and a synthetic 369-test PHPUnit suite covering RTF extraction, translation slides, ZIP64 repair, round-trip fidelity, and end-to-end generation.
94 lines
3 KiB
PHP
94 lines
3 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\CCLIFileReader;
|
|
use ProPresenter\Parser\CCLIFileWriter;
|
|
use ProPresenter\Parser\CCLILibrary;
|
|
|
|
class CCLIFileReaderTest extends TestCase
|
|
{
|
|
private const REFERENCE_PATH = __DIR__ . '/../doc/reference_samples/CCLI';
|
|
|
|
#[Test]
|
|
public function readThrowsOnMissingFile(): void
|
|
{
|
|
$this->expectException(InvalidArgumentException::class);
|
|
CCLIFileReader::read(__DIR__ . '/../doc/reference_samples/does-not-exist-ccli');
|
|
}
|
|
|
|
#[Test]
|
|
public function readReturnsLibraryWithExpectedCount(): void
|
|
{
|
|
$library = CCLIFileReader::read(self::REFERENCE_PATH);
|
|
|
|
$this->assertInstanceOf(CCLILibrary::class, $library);
|
|
$this->assertSame(1, $library->count());
|
|
}
|
|
|
|
#[Test]
|
|
public function documentExposesLicenseAndDisplaySettings(): void
|
|
{
|
|
$library = CCLIFileReader::read(self::REFERENCE_PATH);
|
|
|
|
$this->assertTrue($library->isCCLIDisplayEnabled());
|
|
$this->assertSame('', $library->getCCLILicense());
|
|
$this->assertSame(0, $library->getDisplayType());
|
|
$this->assertNotNull($library->getTemplate());
|
|
}
|
|
|
|
#[Test]
|
|
public function settersUpdateDocument(): void
|
|
{
|
|
$library = CCLIFileReader::read(self::REFERENCE_PATH);
|
|
|
|
$library->setCCLILicense('1234567');
|
|
$library->setDisplayType(3);
|
|
$library->setCCLIDisplayEnabled(false);
|
|
|
|
$this->assertSame('1234567', $library->getCCLILicense());
|
|
$this->assertSame(3, $library->getDisplayType());
|
|
$this->assertFalse($library->isCCLIDisplayEnabled());
|
|
}
|
|
|
|
#[Test]
|
|
public function addAndRemoveRoundTrip(): void
|
|
{
|
|
$library = CCLIFileReader::read(self::REFERENCE_PATH);
|
|
|
|
$template = $library->getTemplate();
|
|
$this->assertNotNull($template);
|
|
|
|
$library->setTemplate(null);
|
|
$this->assertNull($library->getTemplate());
|
|
|
|
$library->setTemplate($template);
|
|
$this->assertNotNull($library->getTemplate());
|
|
}
|
|
|
|
#[Test]
|
|
public function writerProducesByteIdenticalRoundTrip(): void
|
|
{
|
|
$original = file_get_contents(self::REFERENCE_PATH);
|
|
$library = CCLIFileReader::read(self::REFERENCE_PATH);
|
|
|
|
$tmp = tempnam(sys_get_temp_dir(), 'ccli_');
|
|
try {
|
|
CCLIFileWriter::write($library, $tmp);
|
|
$roundTrip = CCLIFileReader::read($tmp);
|
|
$this->assertSame(strlen((string) $original), strlen((string) file_get_contents($tmp)));
|
|
$this->assertSame($library->isCCLIDisplayEnabled(), $roundTrip->isCCLIDisplayEnabled());
|
|
$this->assertSame($library->getCCLILicense(), $roundTrip->getCCLILicense());
|
|
$this->assertSame($library->getDisplayType(), $roundTrip->getDisplayType());
|
|
$this->assertSame($library->getTemplate() !== null, $roundTrip->getTemplate() !== null);
|
|
} finally {
|
|
@unlink($tmp);
|
|
}
|
|
}
|
|
}
|