Skip to content

Commit

Permalink
ci: write test for the boolean rule
Browse files Browse the repository at this point in the history
  • Loading branch information
devhammed committed Aug 24, 2020
1 parent d61090c commit f147c66
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/Rules/BooleanTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace Rakit\Validation\Tests;

use PHPUnit\Framework\TestCase;
use Rakit\Validation\Rules\Boolean;

class BooleanTest extends TestCase
{
public function setUp()
{
$this->rule = new Boolean;
}

public function testValids()
{
$this->assertTrue($this->rule->check(\true));
$this->assertTrue($this->rule->check(\false));
$this->assertTrue($this->rule->check(1));
$this->assertTrue($this->rule->check(0));
$this->assertTrue($this->rule->check('1'));
$this->assertTrue($this->rule->check('0'));
$this->assertTrue($this->rule->check('y'));
$this->assertTrue($this->rule->check('n'));
}

public function testInvalids()
{
$this->assertFalse($this->rule->check(11));
$this->assertFalse($this->rule->check([]));
$this->assertFalse($this->rule->check('foo123'));
$this->assertFalse($this->rule->check('123foo'));
$this->assertFalse($this->rule->check([123]));
$this->assertFalse($this->rule->check('123.456'));
$this->assertFalse($this->rule->check('-123.456'));
}
}

0 comments on commit f147c66

Please sign in to comment.