function testExecuteGenerateGalleryId() { $mockChainContext = new stdClass(); $ioc = org_tubepress_impl_ioc_IocContainer::getInstance(); $qss = $ioc->get(org_tubepress_api_http_HttpRequestParameterService::_); $qss->shouldReceive('getParamValueAsInt')->once()->with(org_tubepress_api_const_http_ParamName::PAGE, 1)->andReturn('page-num'); $mockTemplate = \Mockery::mock('org_tubepress_api_template_Template'); $mockTemplate->shouldReceive('toString')->once()->andReturn('template-string'); $themeHandler = $ioc->get(org_tubepress_api_theme_ThemeHandler::_); $themeHandler->shouldReceive('getTemplateInstance')->once()->with('gallery.tpl.php')->andReturn($mockTemplate); $pc = $ioc->get(org_tubepress_api_provider_ProviderCalculator::_); $pc->shouldReceive('calculateCurrentVideoProvider')->once()->andReturn('provider-name'); $execContext = $ioc->get(org_tubepress_api_exec_ExecutionContext::_); $execContext->shouldReceive('get')->once()->with(org_tubepress_api_const_options_names_Advanced::GALLERY_ID)->andReturn(''); $execContext->shouldReceive('set')->once()->with(org_tubepress_api_const_options_names_Advanced::GALLERY_ID, integerValue())->andReturn(true); $mockFeedResult = \Mockery::mock('org_tubepress_api_provider_ProviderResult'); $mockFeedResult->shouldReceive('getVideoArray')->once()->andReturn(array('x', 'y')); $provider = $ioc->get(org_tubepress_api_provider_Provider::_); $provider->shouldReceive('getMultipleVideos')->once()->andReturn($mockFeedResult); $pluginManager = $ioc->get(org_tubepress_api_plugin_PluginManager::_); $pluginManager->shouldReceive('runFilters')->once()->with(org_tubepress_api_const_plugin_FilterPoint::TEMPLATE_GALLERY, $mockTemplate, $mockFeedResult, 'page-num', 'provider-name')->andReturn($mockTemplate); $pluginManager->shouldReceive('runFilters')->once()->with(org_tubepress_api_const_plugin_FilterPoint::HTML_GALLERY, 'template-string', $mockFeedResult, 'page-num', 'provider-name')->andReturn('filtered-html'); $this->assertTrue($this->_sut->execute($mockChainContext)); $this->assertEquals('filtered-html', $mockChainContext->returnValue); }
function testPhockitoIntegration() { $mock = Phockito::mock('ViewableData'); Phockito::when($mock)->getField(stringValue())->return('Foo'); $this->assertEquals($mock->getField(1), null); $this->assertEquals($mock->getField('Bar'), 'Foo'); Phockito::verify($mock)->getField(integerValue()); }
public function testDecribesActualTypeInMismatchMessage() { $this->assertMismatchDescription('was null', integerValue(), null); $this->assertMismatchDescription('was a string "foo"', integerValue(), 'foo'); }