public function onSetup()
 {
     $this->_mockLogger = $this->mock(tubepress_api_log_LoggerInterface::_);
     $this->_mockLangUtils = $this->mock(tubepress_api_util_LangUtilsInterface::_);
     $this->_mockUrlFactory = $this->mock(tubepress_api_url_UrlFactoryInterface::_);
     $this->_mockStringUtils = $this->mock(tubepress_api_util_StringUtilsInterface::_);
     $this->_mockLangUtils->shouldReceive('isAssociativeArray')->andReturnUsing(function ($candidate) {
         $util = new tubepress_util_impl_LangUtils();
         return $util->isAssociativeArray($candidate);
     });
     $this->_mockLangUtils->shouldReceive('isSimpleArrayOfStrings')->andReturnUsing(function ($candidate) {
         $util = new tubepress_util_impl_LangUtils();
         return $util->isSimpleArrayOfStrings($candidate);
     });
     $this->_mockUrlFactory->shouldReceive('fromString')->andReturnUsing(function ($candidate) {
         $factory = new tubepress_url_impl_puzzle_UrlFactory();
         return $factory->fromString($candidate);
     });
     $this->_mockStringUtils->shouldReceive('endsWith')->andReturnUsing(function ($haystack, $needle) {
         $utils = new tubepress_util_impl_StringUtils();
         return $utils->endsWith($haystack, $needle);
     });
     $this->_mockLogger->shouldReceive('isEnabled')->atLeast(1)->andReturn(true);
     $this->_mockLogger->shouldReceive('debug');
     $this->_sut = $this->buildSut($this->_mockLogger, $this->_mockUrlFactory, $this->_mockLangUtils, $this->_mockStringUtils);
 }
 /**
  * @dataProvider getDataGetDataUrl
  */
 public function testGetDataUrl(array $context, array $query)
 {
     $mockUrl = $this->mock('tubepress_api_url_UrlInterface');
     $mockQuery = $this->mock('tubepress_api_url_QueryInterface');
     foreach ($context as $key => $value) {
         $this->_mockContext->shouldReceive('get')->once()->with($key)->andReturn($value);
     }
     $mockUrl->shouldReceive('getQuery')->once()->andReturn($mockQuery);
     $this->_mockUrlFactory->shouldReceive('fromString')->once()->with('https://www.dailymotion.com/embed/video/xx')->andReturn($mockUrl);
     $this->_mockLangUtils->shouldReceive('booleanToStringOneOrZero')->atLeast(1)->andReturnUsing(function ($incoming) {
         $langutils = new tubepress_util_impl_LangUtils();
         return $langutils->booleanToStringOneOrZero($incoming);
     });
     $this->_mockMediaItem->shouldReceive('getId')->once()->andReturn('xx');
     $expected = array(tubepress_api_template_VariableNames::EMBEDDED_DATA_URL => $mockUrl, 'player_id' => 'player-id');
     foreach ($query as $key => $value) {
         $mockQuery->shouldReceive('set')->once()->with($key, $value);
     }
     $actual = $this->_sut->getTemplateVariables($this->_mockMediaItem);
     $this->assertEquals($expected, $actual);
 }
Esempio n. 3
0
 /**
  * @dataProvider getDataArrayUnshiftAssociative
  */
 public function testArrayUnshiftAssociative(array $incoming, $key, $value, array $expected)
 {
     $actual = $this->_sut->arrayUnshiftAssociative($incoming, $key, $value);
     $this->assertTrue(is_array($actual));
     $this->assertEquals($expected, $actual);
 }