-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
147 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Cone\Root\Tests\Fields; | ||
|
||
use Cone\Root\Fields\Radio; | ||
use Cone\Root\Tests\TestCase; | ||
|
||
class RadioTest extends TestCase | ||
{ | ||
protected Radio $field; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->field = new Radio('Role'); | ||
} | ||
|
||
public function test_a_checkbox_field_makes_new_option(): void | ||
{ | ||
$option = $this->field->newOption('test', 'Test'); | ||
|
||
$this->assertEmpty( | ||
array_diff(['value' => 'test'], $option->jsonSerialize()) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Cone\Root\Tests\Fields; | ||
|
||
use Cone\Root\Fields\Range; | ||
use Cone\Root\Tests\TestCase; | ||
|
||
class RangeTest extends TestCase | ||
{ | ||
protected Range $field; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->field = new Range('Age'); | ||
} | ||
|
||
public function test_a_range_field_has_range_type(): void | ||
{ | ||
$this->assertSame('range', $this->field->getAttribute('type')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace Cone\Root\Tests\Fields; | ||
|
||
use Cone\Root\Fields\Text; | ||
use Cone\Root\Tests\TestCase; | ||
|
||
class TextTest extends TestCase | ||
{ | ||
protected Text $field; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->field = new Text('Name'); | ||
} | ||
|
||
public function test_a_text_field_has_text_type(): void | ||
{ | ||
$this->assertSame('text', $this->field->getAttribute('type')); | ||
} | ||
|
||
public function test_a_text_field_has_size_attribute(): void | ||
{ | ||
$this->assertNull($this->field->getAttribute('size')); | ||
|
||
$this->field->size(10); | ||
|
||
$this->assertSame(10, $this->field->getAttribute('size')); | ||
} | ||
|
||
public function test_a_text_field_has_minlength_attribute(): void | ||
{ | ||
$this->assertNull($this->field->getAttribute('minlength')); | ||
|
||
$this->field->minlength(10); | ||
|
||
$this->assertSame(10, $this->field->getAttribute('minlength')); | ||
} | ||
|
||
public function test_a_text_field_has_maxlength_attribute(): void | ||
{ | ||
$this->assertNull($this->field->getAttribute('maxlength')); | ||
|
||
$this->field->maxlength(10); | ||
|
||
$this->assertSame(10, $this->field->getAttribute('maxlength')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace Cone\Root\Tests\Fields; | ||
|
||
use Cone\Root\Fields\Textarea; | ||
use Cone\Root\Tests\TestCase; | ||
|
||
class TextareaTest extends TestCase | ||
{ | ||
protected Textarea $field; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->field = new Textarea('Content'); | ||
} | ||
|
||
public function test_a_textarea_field_has_textarea_template(): void | ||
{ | ||
$this->assertSame('root::fields.textarea', $this->field->getTemplate()); | ||
} | ||
|
||
public function test_a_textarea_field_has_rows_attribute(): void | ||
{ | ||
$this->assertNull($this->field->getAttribute('rows')); | ||
|
||
$this->field->rows(10); | ||
|
||
$this->assertSame(10, $this->field->getAttribute('rows')); | ||
} | ||
|
||
public function test_a_textarea_field_has_cols_attribute(): void | ||
{ | ||
$this->assertNull($this->field->getAttribute('cols')); | ||
|
||
$this->field->cols(10); | ||
|
||
$this->assertSame(10, $this->field->getAttribute('cols')); | ||
} | ||
} |