问题
I'm struggling with phpspec
and No calls have been made that match
while the call was actually made. Here is the code so far:
function it_imports_social_feeds(
ContainerInterface $container,
FacebookManagerFactory $managerFactory,
FacebookConnector $facebookConnector,
FacebookMapper $facebookMapper,
EzContent $ezContent,
Collection $feed,
Content $content
)
{
$chainProfiles = [];
$container->getParameter('someParam1')->willReturn($chainProfiles);
$container->get('someParam2')
->shouldBeCalled()->willReturn($managerFactory);
$managerFactory->createFacebookConnector(Argument::type('string'))->willReturn($facebookConnector);
$facebookConnector->getFeed()->shouldBeCalled();
$facebookMapper->getData()->willReturn($feed);
$container->getParameter('someParam3')->shouldBeCalled();
$container->getParameter('someParam4')->shouldBeCalled();
// these 2 call are issue
$ezContent->save(Argument::type('array'), Argument::any(), Argument::any())->willReturn($content)->shouldBeCalled();
$ezContent->updatePublishedDate(Argument::type('string'), $content)->shouldBeCalled();
$this->importFeeds();
}
And implemented class method:
public function importFeeds()
{
$socialChainsProfiles = $this->container->getParameter('mrkisha_social_feed_profiles');
foreach($socialChainsProfiles as $socialMedia => $chainsProfiles) {
foreach($chainsProfiles as $chain => $chainsProfile) {
$fbConnector = $this->container
->get("social.feed.facebook.factory")
->createFacebookConnector($chainsProfile);
$fbMapper = new FacebookMapper($fbConnector);
$fbData = $fbMapper->getData();
$contentTypeIdentifier = $this->container->getParameter('social_feed_content_type_identifier');
$folderId = $this->container->getParameter('social_feed_folder_ids')[$chain];
$sortedData = $fbData->sortByDesc('publishedAt')->values()->all();
foreach ($sortedData as $item) {
$item['socialFeed'] = $socialMedia;
$publishedDate = $item['publishedAt'];
unset($item['publishedAt']);
// These 2 calls withing loop phpspec does not see
$content = $this->ezContent->save($item, $contentTypeIdentifier, $folderId);
$this->ezContent->updatePublishedDate($publishedDate, $content);
}
}
}
}
I'm beginner in testing and the resources online for phpspec are almost non existent, any help is much appreciated regarding what concept am I missing here and what am I doing wrong.
来源:https://stackoverflow.com/questions/41600397/phpspec-no-calls-have-been-made-that-match