-
-
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
8 changed files
with
142 additions
and
21 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
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
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\Checkbox; | ||
use Cone\Root\Tests\TestCase; | ||
|
||
class CheckboxTest extends TestCase | ||
{ | ||
protected Checkbox $field; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->field = new Checkbox('Permissions'); | ||
} | ||
|
||
public function test_a_checkbox_field_makes_new_option(): void | ||
{ | ||
$option = $this->field->newOption('test', 'Test'); | ||
|
||
$this->assertTrue( | ||
empty(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\Color; | ||
use Cone\Root\Tests\TestCase; | ||
|
||
class ColorTest extends TestCase | ||
{ | ||
protected Color $field; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->field = new Color('Primary'); | ||
} | ||
|
||
public function test_a_color_field_has_color_type(): void | ||
{ | ||
$this->assertSame('color', $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,54 @@ | ||
<?php | ||
|
||
namespace Cone\Root\Tests\Fields; | ||
|
||
use Cone\Root\Fields\Date; | ||
use Cone\Root\Tests\TestCase; | ||
use Cone\Root\Tests\User; | ||
use Illuminate\Support\Facades\Date as DateFactory; | ||
|
||
class DateTest extends TestCase | ||
{ | ||
protected Date $field; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->field = new Date('Created At'); | ||
} | ||
|
||
public function test_a_date_field_has_date_type(): void | ||
{ | ||
$this->assertSame('date', $this->field->getAttribute('type')); | ||
$this->assertSame(1, $this->field->getAttribute('step')); | ||
} | ||
|
||
public function test_date_has_min_max_attributes(): void | ||
{ | ||
$this->assertNull($this->field->getAttribute('min')); | ||
|
||
$date = DateFactory::now(); | ||
|
||
$this->field->min($date); | ||
$this->assertSame($date->format('Y-m-d'), $this->field->getAttribute('min')); | ||
|
||
$this->field->max($date); | ||
$this->assertSame($date->format('Y-m-d'), $this->field->getAttribute('max')); | ||
} | ||
|
||
public function test_a_date_field_has_time(): void | ||
{ | ||
$model = new User(); | ||
|
||
$now = DateFactory::now(); | ||
|
||
$model->setAttribute('created_at', $now); | ||
|
||
$this->assertSame($now->format('Y-m-d'), $this->field->resolveFormat($this->app['request'], $model)); | ||
|
||
$this->field->withTime(); | ||
$this->assertSame('datetime-local', $this->field->getAttribute('type')); | ||
$this->assertSame($now->format('Y-m-d H:i:s'), $this->field->resolveFormat($this->app['request'], $model)); | ||
} | ||
} |