Skip to content

Commit

Permalink
improved specs for EditorService
Browse files Browse the repository at this point in the history
  • Loading branch information
takeit committed Jan 30, 2015
1 parent 14e57fb commit 215f688
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions spec/Newscoop/Services/EditorServiceSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function it_is_initializable()
$this->shouldImplement('Newscoop\EditorInterface');
}

public function let(TraceableEventDispatcher $dispatcher, EntityManager $em, Article $article)
public function let(TraceableEventDispatcher $dispatcher, EntityManager $em, Article $article, Language $language)
{
$article->getNumber()->willReturn(10);
$article->getName()->willReturn("test article");
Expand All @@ -27,33 +27,49 @@ public function let(TraceableEventDispatcher $dispatcher, EntityManager $em, Art
$article->getIssueId()->willReturn(20);
$article->getSectionId()->willReturn(30);

$em
->getReference('Newscoop\Entity\Language', 1)
->willReturn($language);

$language->getCode()->willReturn('en');

$this->beConstructedWith($dispatcher, $em);
}

public function it_should_get_editor_link(
Article $article,
Language $language,
EntityManager $em,
TraceableEventDispatcher $dispatcher,
GenericEvent $event)
{

$em
->getReference('Newscoop\Entity\Language', 1)
->willReturn($language);

$language->getCode()->willReturn('en');
$dispatcher->dispatch(
'newscoop_admin.editor',
Argument::type('Newscoop\EventDispatcher\Events\GenericEvent')
)->shouldBeCalled()->willReturn($event);

$event->hasArgument('link')->willReturn(true);
$event->getArgument('link')->willReturn(null);
$params = "f_publication_id=2&f_issue_number=20&f_section_number=30&f_article_number=10&f_language_id=1&f_language_selected=1";

$this->getLink($article)->shouldReturn('/admin/articles/edit.php?'. $params);
}

public function it_should_get_3rd_party_editor_link(
Article $article,
TraceableEventDispatcher $dispatcher,
GenericEvent $event)
{
$dispatcher->dispatch(
'newscoop_admin.editor',
Argument::type('Newscoop\EventDispatcher\Events\GenericEvent')
)->shouldBeCalled()->willReturn($event);

$link = '/admin/some/3rd/party/editor/link/10/1';
$event->hasArgument('link')->willReturn(true);
$event->getArgument('link')->willReturn($link);

$this->getLink($article)->shouldReturn($link);
}

public function it_should_return_default_editor_parameters(Article $article)
{
$params = "?f_publication_id=2&f_issue_number=20&f_section_number=30&f_article_number=10&f_language_id=1&f_language_selected=1";
Expand Down

0 comments on commit 215f688

Please sign in to comment.