mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-02-06 19:41:13 -05:00
* Complete PHPStan Level 6 Fix https://github.com/FreshRSS/FreshRSS/issues/4112 And initiate PHPStan Level 7 * PHPStan Level 6 for tests * Use phpstan/phpstan-phpunit * Update to PHPStan version 1.10 * Fix mixed bug * Fix mixed return bug * Fix paginator bug * Fix FreshRSS_UserConfiguration * A couple more Minz_Configuration bug fixes * A few trivial PHPStan Level 7 fixes * A few more simple PHPStan Level 7 * More files passing PHPStan Level 7 Add interface to replace removed class from https://github.com/FreshRSS/FreshRSS/pull/5251 * A few more PHPStan Level 7 preparations * A few last details
84 lines
2.9 KiB
PHP
84 lines
2.9 KiB
PHP
<?php
|
|
|
|
require_once __DIR__ . '/../../../cli/i18n/I18nValue.php';
|
|
|
|
class I18nValueTest extends PHPUnit\Framework\TestCase {
|
|
public function testConstructorWithoutState(): void {
|
|
$value = new I18nValue('some value');
|
|
$this->assertEquals('some value', $value->getValue());
|
|
$this->assertFalse($value->isIgnore());
|
|
$this->assertFalse($value->isTodo());
|
|
}
|
|
|
|
public function testConstructorWithUnknownState(): void {
|
|
$value = new I18nValue('some value -> unknown');
|
|
$this->assertEquals('some value', $value->getValue());
|
|
$this->assertFalse($value->isIgnore());
|
|
$this->assertFalse($value->isTodo());
|
|
}
|
|
|
|
public function testConstructorWithTodoState(): void {
|
|
$value = new I18nValue('some value -> todo');
|
|
$this->assertEquals('some value', $value->getValue());
|
|
$this->assertFalse($value->isIgnore());
|
|
$this->assertTrue($value->isTodo());
|
|
}
|
|
|
|
public function testConstructorWithIgnoreState(): void {
|
|
$value = new I18nValue('some value -> ignore');
|
|
$this->assertEquals('some value', $value->getValue());
|
|
$this->assertTrue($value->isIgnore());
|
|
$this->assertFalse($value->isTodo());
|
|
}
|
|
|
|
public function testClone(): void {
|
|
$value = new I18nValue('some value');
|
|
$clonedValue = clone $value;
|
|
$this->assertEquals('some value', $value->getValue());
|
|
$this->assertEquals('some value', $clonedValue->getValue());
|
|
$this->assertFalse($value->isIgnore());
|
|
$this->assertFalse($clonedValue->isIgnore());
|
|
$this->assertFalse($value->isTodo());
|
|
$this->assertTrue($clonedValue->isTodo());
|
|
}
|
|
|
|
public function testEqualWhenValueIsIdentical(): void {
|
|
$value = new I18nValue('some value');
|
|
$clonedValue = clone $value;
|
|
$this->assertTrue($value->equal($clonedValue));
|
|
$this->assertTrue($clonedValue->equal($value));
|
|
}
|
|
|
|
public function testEqualWhenValueIsDifferent(): void {
|
|
$value = new I18nValue('some value');
|
|
$otherValue = new I18nValue('some other value');
|
|
$this->assertFalse($value->equal($otherValue));
|
|
$this->assertFalse($otherValue->equal($value));
|
|
}
|
|
|
|
public function testStates(): void {
|
|
$reflectionProperty = new ReflectionProperty(I18nValue::class, 'state');
|
|
$reflectionProperty->setAccessible(true);
|
|
|
|
$value = new I18nValue('some value');
|
|
$this->assertNull($reflectionProperty->getValue($value));
|
|
$value->markAsDirty();
|
|
$this->assertEquals('dirty', $reflectionProperty->getValue($value));
|
|
$value->unmarkAsIgnore();
|
|
$this->assertEquals('dirty', $reflectionProperty->getValue($value));
|
|
$value->markAsIgnore();
|
|
$this->assertEquals('ignore', $reflectionProperty->getValue($value));
|
|
$value->unmarkAsIgnore();
|
|
$this->assertNull($reflectionProperty->getValue($value));
|
|
$value->markAsTodo();
|
|
$this->assertEquals('todo', $reflectionProperty->getValue($value));
|
|
}
|
|
|
|
public function testToString(): void {
|
|
$value = new I18nValue('some value');
|
|
$this->assertEquals('some value', $value->__toString());
|
|
$value->markAsTodo();
|
|
$this->assertEquals('some value -> todo', $value->__toString());
|
|
}
|
|
}
|