2020-03-01 02:39:06 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Engelsystem\Test\Unit\Http\Validation\Rules;
|
|
|
|
|
|
|
|
use Engelsystem\Http\Validation\Rules\Checked;
|
|
|
|
use Engelsystem\Test\Unit\TestCase;
|
|
|
|
|
|
|
|
class CheckedTest extends TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @covers \Engelsystem\Http\Validation\Rules\Checked::validate
|
|
|
|
*/
|
2022-12-14 19:15:20 +01:00
|
|
|
public function testValidate(): void
|
2020-03-01 02:39:06 +01:00
|
|
|
{
|
|
|
|
$rule = new Checked();
|
|
|
|
|
|
|
|
$this->assertTrue($rule->validate('yes'));
|
|
|
|
$this->assertTrue($rule->validate('on'));
|
|
|
|
$this->assertTrue($rule->validate(1));
|
|
|
|
$this->assertTrue($rule->validate('1'));
|
|
|
|
$this->assertTrue($rule->validate('true'));
|
|
|
|
$this->assertTrue($rule->validate(true));
|
|
|
|
|
|
|
|
$this->assertFalse($rule->validate('no'));
|
|
|
|
$this->assertFalse($rule->validate('off'));
|
|
|
|
$this->assertFalse($rule->validate(0));
|
|
|
|
$this->assertFalse($rule->validate('0'));
|
|
|
|
$this->assertFalse($rule->validate('false'));
|
|
|
|
$this->assertFalse($rule->validate(false));
|
|
|
|
$this->assertFalse($rule->validate(null));
|
|
|
|
}
|
|
|
|
}
|