Skip to content

Commit

Permalink
editor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Nov 23, 2023
1 parent 07d82d9 commit fda485b
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tests/Fields/EditorTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

namespace Cone\Root\Tests\Fields;

use Cone\Root\Fields\Editor;
use Cone\Root\Tests\TestCase;

class EditorTest extends TestCase
{
protected Editor $field;

public function setUp(): void
{
parent::setUp();

$this->field = new Editor('Content');
}

public function test_an_editor_field_has_configuration(): void
{
$this->field->withConfig(function () {
return ['key' => 'value'];
});

$this->assertSame(['key' => 'value'], $this->field->getConfig());
}

public function test_an_editor_field_resolves_media_field(): void
{
$this->field->withMedia(function ($media) {
$media->label('Attachments');
});

$this->assertSame('content-media', $this->field->getMedia()->getModelAttribute());
}

public function test_an_editor_field_register_routes(): void
{
$this->field->withMedia();

$this->app['router']->prefix('posts/fields')->group(function ($router) {
$this->field->registerRoutes($this->app['request'], $router);
});

$this->assertSame('/posts/fields/content', $this->field->getUri());

$this->assertArrayHasKey(
trim($this->field->getMedia()->getUri(), '/'),
$this->app['router']->getRoutes()->get('GET')
);
}
}

0 comments on commit fda485b

Please sign in to comment.