Skip to content

Commit

Permalink
Tweak tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dvlpp committed Nov 22, 2015
1 parent 6aa4c81 commit b7fed5f
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions tests/ListValuatorTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

use Dvlpp\Sharp\Config\FormFields\ListField\SharpListFormFieldConfig;
use Dvlpp\Sharp\Config\FormFields\ListField\SharpListItemFormTemplateConfig;
use Dvlpp\Sharp\Config\FormFields\SharpTextareaFormFieldConfig;
use Dvlpp\Sharp\Repositories\AutoUpdater\SharpEloquentAutoUpdaterService;
use Dvlpp\Sharp\Repositories\AutoUpdater\Valuators\ListValuator;
Expand Down Expand Up @@ -80,7 +79,7 @@ public function new_item_is_added()
public function missing_item_is_removed()
{
$post = factory(TestListPostModel::class)->create();
$comment = factory(TestListCommentModel::class)->create([
factory(TestListCommentModel::class)->create([
"post_id" => $post->id
]);

Expand Down Expand Up @@ -124,6 +123,29 @@ public function list_items_order_is_managed()
$this->seeInDatabase('comments', ['post_id'=>$post->id, 'id'=>$commentTwo->id, 'order'=>1]);
}

/** @test */
function specific_create_item_method_is_called()
{
$post = factory(TestListPostModel::class)->create();

$sharpRepo = Mockery::mock(SharpCmsRepository::class)->makePartial();
$sharpRepo->shouldReceive("createCommentsListItem")->once();
$listConfig = SharpListFormFieldConfig::create("comments")
->setAddable(true)
->addItemFormField(
SharpTextareaFormFieldConfig::create("body")
);
$autoUpdater = new SharpEloquentAutoUpdaterService();

(new ListValuator($post, "comments", [
"N_1" => [
"id" => "N_1",
"body" => "some test body"
]
], $listConfig, $sharpRepo, $autoUpdater))
->valuate();
}

private function migrateDatabase()
{
\Schema::create('posts', function (Blueprint $table) {
Expand Down

0 comments on commit b7fed5f

Please sign in to comment.