Skip to content

Commit

Permalink
Test List specific_create_item_method_is_called
Browse files Browse the repository at this point in the history
  • Loading branch information
dvlpp committed Nov 30, 2015
1 parent b7fed5f commit ab13da7
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions tests/ListValuatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,25 +124,31 @@ public function list_items_order_is_managed()
}

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

$sharpRepo = Mockery::mock(SharpCmsRepository::class)->makePartial();
$sharpRepo->shouldReceive("createCommentsListItem")->once();
$sharpRepo = Mockery::mock(TestListRepository::class);
$sharpRepo->shouldReceive("createCommentsListItem")
->once()
->andReturn(
factory(TestListCommentModel::class)->create([
"post_id" => $post->id
])
);

$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))
], $listConfig, $sharpRepo, new SharpEloquentAutoUpdaterService))
->valuate();
}

Expand Down Expand Up @@ -195,4 +201,10 @@ public function post()
{
return $this->belongsTo(TestListPostModel::class, "post_id");
}
}

abstract class TestListRepository implements SharpCmsRepository {

function createCommentsListItem($item){}

}

0 comments on commit ab13da7

Please sign in to comment.