public function testPerPageSort()
 {
     $this->_mockIncomingEvent->shouldReceive('getSubject')->once()->andReturn(array('foo' => 'bar'));
     $this->_mockIncomingEvent->shouldReceive('setSubject')->once()->with(array('foo' => 'bar', tubepress_api_options_AcceptableValues::PER_PAGE_SORT_NONE => 'none', tubepress_api_options_AcceptableValues::PER_PAGE_SORT_COMMENT_COUNT => 'comment count', tubepress_api_options_AcceptableValues::PER_PAGE_SORT_NEWEST => 'date published (newest first)', tubepress_api_options_AcceptableValues::PER_PAGE_SORT_OLDEST => 'date published (oldest first)', tubepress_api_options_AcceptableValues::PER_PAGE_SORT_DURATION => 'length', tubepress_api_options_AcceptableValues::PER_PAGE_SORT_RANDOM => 'random', tubepress_api_options_AcceptableValues::PER_PAGE_SORT_TITLE => 'title', tubepress_api_options_AcceptableValues::PER_PAGE_SORT_VIEW_COUNT => 'view count'));
     $this->_sut->onPerPageSort($this->_mockIncomingEvent);
     $this->assertTrue(true);
 }
 public function testInUpdateMessageNoKey()
 {
     $this->expectOutputString('foobar');
     $this->_mockContext->shouldReceive('get')->once()->with(tubepress_api_options_Names::TUBEPRESS_API_KEY)->andReturnNull();
     $this->_mockTemplating->shouldReceive('renderTemplate')->once()->with('wordpress/in-update-message')->andReturn('foobar');
     $this->_sut->onAction_in_plugin_update_message($this->_mockIncomingEvent);
 }
 public function testGetEngineNoEngineSupports()
 {
     $this->setExpectedException('RuntimeException', 'Template <code>foobar</code> not found.');
     $this->_mockEngine1->shouldReceive('supports')->once()->with('foobar')->andReturn(false);
     $this->_mockEngine2->shouldReceive('supports')->once()->with('foobar')->andReturn(false);
     $this->_sut->getEngine('foobar');
 }
 public function testBuildCache()
 {
     $this->_mockContext->shouldReceive('get')->once()->with(tubepress_api_options_Names::CACHE_DIRECTORY)->andReturn('/abc');
     $this->_mockBootSettings->shouldReceive('getPathToSystemCacheDirectory')->once()->andReturn(sys_get_temp_dir());
     $result = $this->_sut->buildFilesystemDriver();
     $this->assertInstanceOf('Stash\\Interfaces\\DriverInterface', $result);
 }
 private function _prepareEvent($feed, $index)
 {
     $item = new tubepress_api_media_MediaItem('id');
     $mockProvider = $this->mock(tubepress_spi_media_MediaProviderInterface::_);
     $mockProvider->shouldReceive('getName')->andReturn('vimeo');
     $item->setAttribute(tubepress_api_media_MediaItem::ATTRIBUTE_PROVIDER, $mockProvider);
     $unserialized = json_decode($feed, true);
     $videoArray = array();
     /*
      * Is this just a single video?
      */
     if (!isset($unserialized['data'])) {
         $videoArray = (array) $unserialized->video;
     } else {
         $videoArray = (array) $unserialized['data'];
     }
     $event = new tubepress_event_impl_tickertape_EventBase($item);
     $event->setArgument('decodedJson', $unserialized);
     $event->setArgument('videoArray', $videoArray);
     $event->setArgument('zeroBasedIndex', $index);
     $this->_mockAttributeFormatter->shouldReceive('formatNumberAttribute')->once()->with($item, tubepress_api_media_MediaItem::ATTRIBUTE_LIKES_COUNT, tubepress_api_media_MediaItem::ATTRIBUTE_LIKES_COUNT, 0);
     $this->_mockAttributeFormatter->shouldReceive('formatNumberAttribute')->once()->with($item, tubepress_api_media_MediaItem::ATTRIBUTE_VIEW_COUNT, tubepress_api_media_MediaItem::ATTRIBUTE_VIEW_COUNT, 0);
     $this->_mockAttributeFormatter->shouldReceive('truncateStringAttribute')->once()->with($item, tubepress_api_media_MediaItem::ATTRIBUTE_DESCRIPTION, tubepress_api_media_MediaItem::ATTRIBUTE_DESCRIPTION, tubepress_api_options_Names::META_DESC_LIMIT);
     $this->_mockAttributeFormatter->shouldReceive('formatDurationAttribute')->once()->with($item, tubepress_api_media_MediaItem::ATTRIBUTE_DURATION_SECONDS, tubepress_api_media_MediaItem::ATTRIBUTE_DURATION_FORMATTED);
     $this->_mockAttributeFormatter->shouldReceive('formatDateAttribute')->once()->with($item, tubepress_api_media_MediaItem::ATTRIBUTE_TIME_PUBLISHED_UNIXTIME, tubepress_api_media_MediaItem::ATTRIBUTE_TIME_PUBLISHED_FORMATTED);
     $this->_mockAttributeFormatter->shouldReceive('implodeArrayAttribute')->once()->with($item, tubepress_api_media_MediaItem::ATTRIBUTE_KEYWORD_ARRAY, tubepress_api_media_MediaItem::ATTRIBUTE_KEYWORDS_FORMATTED, ', ');
     return $event;
 }
示例#6
0
 public function testGet()
 {
     $bla = new stdClass();
     $this->_mockContainer->shouldReceive('get')->once()->with('foo', \Symfony\Component\DependencyInjection\ContainerInterface::NULL_ON_INVALID_REFERENCE)->andReturn($bla);
     $result = $this->_sut->get('foo');
     $this->assertSame($bla, $result);
 }
 public function testGetDataUrl()
 {
     $this->_mockContext->shouldReceive('get')->once()->with(tubepress_api_options_Names::EMBEDDED_AUTOPLAY)->andReturn(true);
     $this->_mockContext->shouldReceive('get')->once()->with(tubepress_api_options_Names::EMBEDDED_LOOP)->andReturn(false);
     $this->_mockContext->shouldReceive('get')->once()->with(tubepress_api_options_Names::EMBEDDED_SHOW_INFO)->andReturn(true);
     $this->_mockContext->shouldReceive('get')->once()->with(tubepress_youtube3_api_Constants::OPTION_AUTOHIDE)->andReturn(tubepress_youtube3_api_Constants::AUTOHIDE_HIDE_BOTH);
     $this->_mockContext->shouldReceive('get')->once()->with(tubepress_youtube3_api_Constants::OPTION_FULLSCREEN)->andReturn(false);
     $this->_mockContext->shouldReceive('get')->once()->with(tubepress_youtube3_api_Constants::OPTION_MODEST_BRANDING)->andReturn(true);
     $this->_mockContext->shouldReceive('get')->once()->with(tubepress_youtube3_api_Constants::OPTION_SHOW_RELATED)->andReturn(false);
     $mockFullUrl = $this->mock('tubepress_api_url_UrlInterface');
     $mockUrl2 = $this->mock('tubepress_api_url_UrlInterface');
     $mockQuery = $this->mock('tubepress_api_url_QueryInterface');
     $mockUrl2->shouldReceive('getQuery')->once()->andReturn($mockQuery);
     $mockFullUrl->shouldReceive('getScheme')->once()->andReturn('sdy');
     $mockFullUrl->shouldReceive('getHost')->once()->andReturn('too.net');
     $mockQuery->shouldReceive('set')->once()->with('autohide', '1');
     $mockQuery->shouldReceive('set')->once()->with('autoplay', 'troo');
     $mockQuery->shouldReceive('set')->once()->with('enablejsapi', '1');
     $mockQuery->shouldReceive('set')->once()->with('fs', 'fawlse');
     $mockQuery->shouldReceive('set')->once()->with('modestbranding', 'troo');
     $mockQuery->shouldReceive('set')->once()->with('origin', 'sdy://too.net');
     $mockQuery->shouldReceive('set')->once()->with('rel', 'fawlse');
     $mockQuery->shouldReceive('set')->once()->with('showinfo', 'troo');
     $mockQuery->shouldReceive('set')->once()->with('wmode', 'opaque');
     $this->_mockUrlFactory->shouldReceive('fromCurrent')->once()->andReturn($mockFullUrl);
     $this->_mockUrlFactory->shouldReceive('fromString')->once()->with('https://www.youtube.com/embed/xx')->andReturn($mockUrl2);
     $this->_mockLangUtils->shouldReceive('booleanToStringOneOrZero')->times(3)->with(true)->andReturn('troo');
     $this->_mockLangUtils->shouldReceive('booleanToStringOneOrZero')->times(2)->with(false)->andReturn('fawlse');
     $this->_mockMediaItem->shouldReceive('getId')->once()->andReturn('xx');
     $expected = array(tubepress_api_template_VariableNames::EMBEDDED_DATA_URL => $mockUrl2);
     $actual = $this->_sut->getTemplateVariables($this->_mockMediaItem);
     $this->assertEquals($expected, $actual);
 }
 /**
  * @dataProvider getDataScriptsStyles
  */
 public function testScripts($setter, $getter, $isAbsolute)
 {
     /**
      * @var $theme tubepress_internal_theme_FilesystemTheme
      */
     $theme = $this->buildContributable();
     $mockUrl = $this->mock('tubepress_api_url_UrlInterface');
     $mockUrl->shouldReceive('isAbsolute')->once()->andReturn($isAbsolute);
     $theme->{$setter}(array($mockUrl));
     if ($isAbsolute) {
         $actual = $theme->{$getter}($this->_mockBaseUrl, $this->_mockUserContentUrl);
         $this->assertTrue(is_array($actual));
         $this->assertCount(1, $actual);
         $this->assertSame($mockUrl, $actual[0]);
     } else {
         list($handle, $manifestPath) = $this->getTemporaryFile();
         $theme->setManifestPath($manifestPath);
         $this->_mockUserContentUrl->shouldReceive('getClone')->once()->andReturn($this->_mockUserContentUrl);
         $this->_mockUserContentUrl->shouldReceive('addPath')->once()->with('/themes/' . basename(dirname($manifestPath)) . '/url as string');
         $mockUrl->shouldReceive('__toString')->twice()->andReturn('url as string');
         $actual = $theme->{$getter}($this->_mockBaseUrl, $this->_mockUserContentUrl);
         $this->assertTrue(is_array($actual));
         $this->assertCount(1, $actual);
         $this->assertSame($this->_mockUserContentUrl, $actual[0]);
     }
 }
 public function testTubePressLegacyTheme()
 {
     $this->_mockEvent->shouldReceive('getArgument')->once()->with('optionValue')->andReturn('vimeo');
     $this->_mockEvent->shouldReceive('setArgument')->once()->with('optionValue', 'tubepress/legacy-vimeo');
     $this->_sut->onPreValidationSet($this->_mockEvent);
     $this->assertTrue(true);
 }
 public function testQuickSend()
 {
     $mockResponse = $this->mock('tubepress_api_http_message_ResponseInterface');
     $mockRequest = $this->mock('tubepress_api_http_message_RequestInterface');
     $mockUrl = $this->mock(tubepress_api_url_UrlInterface::_);
     $mockAfterEvent = $this->mock('tubepress_api_event_EventInterface');
     $mockBeforeEvent = $this->mock('tubepress_api_event_EventInterface');
     $mockBodyStream = $this->mock('tubepress_api_streams_StreamInterface');
     $client = new tubepress_test_lib_http_impl_AbstractHttpClientTest__noErrorClient($this->_mockEventDispatcher, $this->_mockLogger, $mockResponse);
     $mockRequest->shouldReceive('getMethod')->atLeast(1)->andReturn('SOME METHOD');
     $mockRequest->shouldReceive('getUrl')->atLeast(1)->andReturn($mockUrl);
     $mockUrl->shouldReceive('__toString')->atLeast(1)->andReturn('url as string');
     $this->_mockEventDispatcher->shouldReceive('newEventInstance')->once()->with($mockRequest, array('response' => null))->andReturn($mockBeforeEvent);
     $this->_mockEventDispatcher->shouldReceive('dispatch')->once()->with(tubepress_api_http_Events::EVENT_HTTP_REQUEST, $mockBeforeEvent);
     $mockBeforeEvent->shouldReceive('hasArgument')->once()->with('response')->andReturn(true);
     $mockBeforeEvent->shouldReceive('getArgument')->twice()->with('response')->andReturn($mockResponse);
     $this->_mockEventDispatcher->shouldReceive('newEventInstance')->once()->with($mockResponse, array('request' => $mockRequest))->andReturn($mockAfterEvent);
     $this->_mockEventDispatcher->shouldReceive('dispatch')->once()->with(tubepress_api_http_Events::EVENT_HTTP_RESPONSE, $mockAfterEvent);
     $mockResponse->shouldReceive('getHeaders')->once()->andReturn(array('bar' => array('xx')));
     $mockResponse->shouldReceive('getBody')->once()->andReturn($mockBodyStream);
     $mockBodyStream->shouldReceive('toString')->once()->andReturn('bla bla bl');
     $mockAfterEvent->shouldReceive('getSubject')->once()->andReturn($mockResponse);
     $result = $client->send($mockRequest);
     $this->assertSame($mockResponse, $result);
 }
 public function testSaveAll()
 {
     $this->_existingStoredOptions = array('a' => 'b');
     $this->_mockWordPressFunctionWrapper->shouldReceive('update_option')->once()->with('tubepress-foo', 'bar');
     $result = $this->_sut->saveAll(array('foo' => 'bar'));
     $this->assertNull($result);
 }
示例#12
0
 public function testMissingBootLogger()
 {
     $this->_mockContainerBuilder->shouldReceive('hasDefinition')->with(tubepress_api_event_EventDispatcherInterface::_)->andReturn(true);
     $this->_mockContainerBuilder->shouldReceive('has')->with('tubepress_internal_logger_BootLogger')->andReturn(false);
     $this->_sut->process($this->_mockContainerBuilder);
     $this->assertTrue(true);
 }
示例#13
0
 public function testDeleteMessage()
 {
     $body = ['job' => 'job-1', 'queue' => 'test', 'attempts' => 1];
     $message = new FuseSource\Stomp\Frame(null, null, json_encode($body));
     $this->stomp->shouldReceive('ack')->once()->with($message);
     $this->queue->deleteMessage('test', $message);
 }
 public function testAccessTokenEndpoint()
 {
     $mockUrl = $this->mock(tubepress_api_url_UrlInterface::_);
     $this->_mockUrlFactory->shouldReceive('fromString')->once()->with('https://api.vimeo.com/oauth/authorize/client')->andReturn($mockUrl);
     $actual = $this->_sut->getTokenEndpoint();
     $this->assertSame($mockUrl, $actual);
 }
示例#15
0
 public function testSingle()
 {
     $mockMediaItem = $this->mock('tubepress_api_media_MediaItem');
     $this->_mockHttpCollector->shouldReceive('collectSingle')->once()->with('abc', $this->_mockFeedHandler)->andReturn($mockMediaItem);
     $actual = $this->_sut->collectSingle('abc');
     $this->assertSame($mockMediaItem, $actual);
 }
 /**
  * @dataProvider nonIE8Data
  */
 public function testNonIe8($serverVars)
 {
     $this->_mockIncomingEvent->shouldReceive('getSubject')->once()->andReturn(array());
     $this->_sut->__setServerVars($serverVars);
     $this->_sut->onAdminScripts($this->_mockIncomingEvent);
     $this->assertTrue(true);
 }
 public function testGetWidgetHtmlWithTemplate()
 {
     $expectedVars = $this->getExpectedTemplateVariables();
     $this->_mockTemplating->shouldReceive('renderTemplate')->once()->with($this->getExpectedTemplateName(), $expectedVars)->andReturn('foo');
     $html = $this->getSut()->getWidgetHTML();
     $this->assertEquals('foo', $html);
 }
 public function testUnserializeNonArray()
 {
     $this->setExpectedException('InvalidArgumentException', 'Expected to deserialize an array');
     $this->_mockSerializer->shouldReceive('unserialize')->once()->with('hello')->andReturn('yo');
     $bootArtifacts = array('add-ons' => 'hello');
     $this->_buildSut($bootArtifacts);
 }
示例#19
0
 /**
  * @expectedException FrontControllerException
  */
 public function testHandleRequest_unhandledException()
 {
     $this->mockRouter->shouldReceive('decode')->andReturn(new ControllerActionParams('FrontController_Controller', 'throwException'));
     $controller = new FrontController();
     $controller->setupContainer($this->provider);
     $controller->handle('/');
 }
示例#20
0
 public function testLoadNotExist()
 {
     $this->_mockTemplateReference->shouldReceive('getLogicalName')->once()->andReturn('abc');
     $this->_mockThemeTemplateLocator->shouldReceive('exists')->once()->with('abc')->andReturn(false);
     $actual = $this->_sut->load($this->_mockTemplateReference);
     $this->assertFalse($actual);
 }
 /**
  * @dataProvider getDataAlbum
  */
 public function testAlbum($incoming, $expected)
 {
     $this->_mockEvent->shouldReceive('getArgument')->once()->with('optionValue')->andReturn($incoming);
     $this->_mockEvent->shouldReceive('setArgument')->once()->with('optionValue', $expected);
     $this->_sut->onAlbumValue($this->_mockEvent);
     $this->assertTrue(true);
 }
 public function testGetAllMessages()
 {
     $this->createMocks();
     $this->message->shouldReceive("orderBy")->once()->with('messages.created_at', 'DESC')->andReturnSelf();
     $this->message->shouldReceive("get")->once()->with([EloquentMessageRepository::ID, EloquentMessageRepository::USER_ID, EloquentMessageRepository::CURRENCY_FROM, EloquentMessageRepository::CURRENCY_TO, EloquentMessageRepository::AMOUNT_SELL, EloquentMessageRepository::AMOUNT_BUY, EloquentMessageRepository::RATE, EloquentMessageRepository::TIME_PLACED, EloquentMessageRepository::ORIGINATING_COUNTRY])->andReturn($this->getMessageDummy());
     $data = $this->messageRepository->getAllMessages();
     $this->assertEquals($this->getMessageDummy(), $data);
 }
示例#23
0
 public function testGoodValue()
 {
     $event = $this->_getMockEvent('value', array());
     $this->_mockStringUtils->shouldReceive('redactSecrets')->once()->with('value')->andReturn('hi');
     $this->_mockLogger->shouldReceive('debug')->once()->with('(Option Logger) Accepted valid value: <code>name</code> = <code>hi</code>');
     $this->_sut->onOptionSet($event);
     $this->assertTrue(true);
 }
 public function testProcessNoTagSet()
 {
     $this->setExpectedException('LogicException', 'Service id must specify tag in its tag data');
     $mockDefinition = $this->mock('tubepress_api_ioc_DefinitionInterface');
     $this->_mockContainer->shouldReceive('findTaggedServiceIds')->once()->with(tubepress_api_ioc_ServiceTags::TAGGED_SERVICES_CONSUMER)->andReturn(array('id' => array(array())));
     $this->_mockContainer->shouldReceive('getDefinition')->once()->with('id')->andReturn($mockDefinition);
     $this->_sut->process($this->_mockContainer);
 }
 public function testPrintWidgetHtml()
 {
     $mockEvent = $this->mock('tubepress_api_event_EventInterface');
     $this->_mockEventDispatcher->shouldReceive('newEventInstance')->once()->with(array(1))->andReturn($mockEvent);
     $this->_mockEventDispatcher->shouldReceive('dispatch')->once()->with(tubepress_wordpress_api_Constants::EVENT_WIDGET_PUBLIC_HTML, $mockEvent);
     $this->_sut->__fireWidgetHtmlEvent(array(1));
     $this->assertTrue(true);
 }
示例#26
0
 public function testErrorReturnsErrorResponseInstance()
 {
     $data = array('foo' => 'bar');
     $this->formatterMock->shouldReceive('format')->once()->with($data)->andReturn('{"foo":"bar"}');
     $lapiResponse = $this->getPreparedLapiResponse();
     $errorInstance = $lapiResponse->error($data);
     $this->assertInstanceOf('\\Kyjan\\Lapi\\Http\\Response\\LapiErrorResponse', $errorInstance);
 }
 public function testRtrim()
 {
     $this->_mockEvent->shouldReceive('getArgument')->once()->with('optionValue')->andReturn('####5####');
     $this->_mockEvent->shouldReceive('setArgument')->once()->with('optionValue', '####5');
     $this->_sut->setModeToRtrim();
     $this->_sut->onOption($this->_mockEvent);
     $this->assertTrue(true);
 }
示例#28
0
 /**
  * @dataProvider getSerializeData
  */
 public function testSerialize($encoding, $nonSerialized, $serialized)
 {
     $this->_mockBootSettings->shouldReceive('getSerializationEncoding')->twice()->andReturn($encoding);
     $actualSerialized = $this->_sut->serialize($nonSerialized);
     $this->assertEquals($serialized, $actualSerialized);
     $actualDeserialized = $this->_sut->unserialize($serialized);
     $this->assertEquals($nonSerialized, $actualDeserialized);
 }
 private function _testVideoMetaStuff(array $mockTemplate)
 {
     $this->_mockMediaProvider->shouldReceive('getMapOfMetaOptionNamesToAttributeDisplayNames')->once()->andReturn(array('meta' => 'something'));
     $this->_mockExecutionContext->shouldReceive('get')->once()->with('meta')->andReturn('<<value of meta>>');
     $this->_mockOptionReference->shouldReceive('optionExists')->once()->with('meta')->andReturn(true);
     $this->_mockOptionReference->shouldReceive('getUntranslatedLabel')->once()->with('meta')->andReturn('meta label!');
     $this->_mockTranslator->shouldReceive('trans')->once()->with('meta label!')->andReturn('##video-meta##');
 }
示例#30
0
 public function testRequest()
 {
     $this->_mockIncomingEvent->shouldReceive('getSubject')->once()->andReturn(array('foo' => 'bar'));
     $this->_mockIncomingEvent->shouldReceive('setSubject')->once()->with(array('foo' => 'bar', 'key' => 'key1', 'pid' => 2));
     $this->_mockContext->shouldReceive('get')->once()->with(tubepress_api_options_Names::TUBEPRESS_API_KEY)->andReturn('key1');
     $this->_mockEnvironment->shouldReceive('isPro')->once()->andReturn(true);
     $this->_sut->onFilter_PucRequestInfoQueryArgsTubePress($this->_mockIncomingEvent);
 }