Skip to content

Commit

Permalink
Added tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Robert committed Feb 9, 2022
1 parent 6e3a1ff commit 5818813
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 1 deletion.
60 changes: 60 additions & 0 deletions Tests/BuilderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

use Chase\Safari\Element;
use Chase\Safari\ElementBuilder;
use PHPUnit\Framework\TestCase;

class BuilderTest extends TestCase
{

protected function setUp(): void
{
$this->builder = new ElementBuilder([
'name' => 'Safari',
'value' => 'Forms'
]);
}

protected function tearDown(): void
{
$this->builder = null;
}

public function testInput(){
$input = $this->builder->input([]);
$this->assertInstanceOf(Element::class, $input);
$this->assertMatchesRegularExpression("#^<input#", $input->html);
}

public function testTextarea(){
$textarea = $this->builder->textarea([]);
$this->assertInstanceOf(Element::class, $textarea);
$this->assertMatchesRegularExpression("#^<textarea#", $textarea->html);
}

public function testSelect(){
$select = $this->builder->select([], []);
$this->assertInstanceOf(Element::class, $select);
$this->assertMatchesRegularExpression("#^<select#", $select->html);
}

public function testCheckbox(){
$input = $this->builder->checkbox([]);
$this->assertInstanceOf(Element::class, $input);
$this->assertMatchesRegularExpression("#^<input#", $input->html);
$this->assertMatchesRegularExpression("#type='checkbox'#", $input->html);
}

public function testRadio(){
$input = $this->builder->radio([]);
$this->assertInstanceOf(Element::class, $input);
$this->assertMatchesRegularExpression("#^<input#", $input->html);
$this->assertMatchesRegularExpression("#type='radio'#", $input->html);
}

public function testRaw(){
$input = $this->builder->raw('safari');
$this->assertInstanceOf(Element::class, $input);
$this->assertMatchesRegularExpression("#^safari$#", $input->html);
}
}
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@
},
"require": {
"php": ">=7.0.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5"
}
}
}
8 changes: 8 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit colors="true" bootstrap="vendor/autoload.php" cacheResult="false">
<testsuites>
<testsuite name="tests">
<directory>Tests</directory>
</testsuite>
</testsuites>
</phpunit>

0 comments on commit 5818813

Please sign in to comment.