Phpspec没有匹配的电话

时间:2017-01-11 20:46:26

标签: php bdd phpspec

在实际通话时我与phpspecNo calls have been made that match挣扎。这是迄今为止的代码:

    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();

    }

并实现了类方法:

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);
            }

        }
    }
}

我是测试的初学者,而且phpspec的在线资源几乎不存在,对于我在这里缺少什么概念以及我做错了什么,我们非常感激。

0 个答案:

没有答案