-
-
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
4 changed files
with
79 additions
and
17 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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
<div class="card"> | ||
<h2 class="card__title">{{ __('Welcome') }}</h2> | ||
<div class="card__inner"> | ||
<div class="app-card"> | ||
<div class="app-card__header"> | ||
<h2 class="app-card__title">{{ __('Welcome') }}</h2> | ||
</div> | ||
<div class="app-card__body"> | ||
<p>{{ __('This is the Root Dashboard.') }}</p> | ||
</div> | ||
</div> |
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,50 @@ | ||
<?php | ||
|
||
namespace Cone\Root\Tests\Fields; | ||
|
||
use Cone\Root\Fields\Slug; | ||
use Cone\Root\Tests\TestCase; | ||
use Cone\Root\Tests\User; | ||
|
||
class SlugTest extends TestCase | ||
{ | ||
protected Slug $field; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->field = new Slug('Slug', 'name'); | ||
} | ||
|
||
public function test_a_slug_field_has_slug_template(): void | ||
{ | ||
$this->assertSame('root::fields.slug', $this->field->getTemplate()); | ||
} | ||
|
||
public function test_a_slug_field_can_be_nullable(): void | ||
{ | ||
$this->assertFalse($this->field->isNullable()); | ||
$this->field->nullable(); | ||
$this->assertTrue($this->field->isNullable()); | ||
} | ||
|
||
public function test_a_slug_field_generates_value_from_model_attributes(): void | ||
{ | ||
$user = new User([ | ||
'email' => '[email protected]', | ||
'name' => 'Test', | ||
'password' => 'secret', | ||
]); | ||
|
||
$this->field->from('email')->unique()->separator('_'); | ||
|
||
$this->field->persist( | ||
$this->app['request'], $user, $this->field->getValueForHydrate($this->app['request']) | ||
); | ||
|
||
$user->save(); | ||
|
||
$this->assertSame('test_at_foocom', $user->name); | ||
} | ||
} |