Joby Elliott
4bff7f2f87
Brought phpstan and phpunit versions up, and fixed phpunit deprecations. I just deleted a bunch of tests of abstract classes, because phpunit has deprecated it and that stuff should all be getting tested every which way downstream anyway.
46 lines
1.5 KiB
PHP
46 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace ByJoby\HTML\Helpers;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class ClassesTest extends TestCase
|
|
{
|
|
public function testConstruction(): Classes
|
|
{
|
|
$classes = new Classes();
|
|
$this->assertEquals([], $classes->getArray());
|
|
$classes = new Classes(['a', 'c', ' a ', 'b', '!']);
|
|
$this->assertEquals(['a', 'b', 'c'], $classes->getArray());
|
|
return $classes;
|
|
}
|
|
|
|
public function testInvalidConstruction()
|
|
{
|
|
$this->expectExceptionMessage('Invalid class name');
|
|
$classes = new Classes(['a', 'c', ' a ', 'b', '!'], false);
|
|
}
|
|
|
|
public function testAddRemove(): void
|
|
{
|
|
$classes = new Classes(['a', 'c', ' a ', 'b', '!']);
|
|
$classes->add('d');
|
|
$this->assertEquals(['a', 'b', 'c', 'd'], $classes->getArray());
|
|
$classes->add('-d');
|
|
$this->assertEquals(['-d', 'a', 'b', 'c', 'd'], $classes->getArray());
|
|
$classes->add('_A');
|
|
$this->assertEquals(['-d', '_A', 'a', 'b', 'c', 'd'], $classes->getArray());
|
|
$classes->remove('b');
|
|
$this->assertEquals(['-d', '_A', 'a', 'c', 'd'], $classes->getArray());
|
|
$this->expectExceptionMessage('Invalid class name');
|
|
$classes->add('0a');
|
|
}
|
|
|
|
public function testContains(): void
|
|
{
|
|
$classes = new Classes(['a', 'c', ' a ', 'b', '!']);
|
|
$this->assertFalse($classes->contains('d'));
|
|
$classes->add('d');
|
|
$this->assertTrue($classes->contains('d'));
|
|
}
|
|
}
|