Skip to content
Browse files

* refactor testGetSections: mock mock

  • Loading branch information...
1 parent 12fef40 commit 21a50404877f9cbb8611781685ca65b458f3ba12 @till till committed
Showing with 15 additions and 1 deletion.
  1. +9 −1 tests/Services/NYTimes/NewswireTest.php
  2. +6 −0 tests/fixtures/newswire/v3/get-sections.php
View
10 tests/Services/NYTimes/NewswireTest.php
@@ -163,7 +163,15 @@ public function testGetItemByUrlInPHP()
*/
public function testGetSections()
{
- $sections = $this->nw->getSections();
+ $responseObject = $this->setUpResponseObject(
+ 'newswire',
+ 'v3',
+ 'get-sections.php'
+ );
+
+ $nwMock = $this->getApiMocked('newswire', $responseObject);
+
+ $sections = $nwMock->getSections();
$this->assertInternalType('array', $sections);
}
View
6 tests/fixtures/newswire/v3/get-sections.php
@@ -0,0 +1,6 @@
+<?php
+return array(
+ 'body' => 'a:4:{s:6:"status";s:2:"OK";s:9:"copyright";s:68:"Copyright (c) 2011 The New York Times Company. All Rights Reserved.";s:11:"num_results";i:47;s:7:"results";a:47:{i:0;a:2:{s:7:"section";s:0:"";s:12:"display_name";s:0:"";}i:1;a:2:{s:7:"section";s:4:"arts";s:12:"display_name";s:4:"Arts";}i:2;a:2:{s:7:"section";s:12:"business day";s:12:"display_name";s:12:"Business Day";}i:3;a:2:{s:7:"section";s:6:"health";s:12:"display_name";s:6:"Health";}i:4;a:2:{s:7:"section";s:13:"n.y. / region";s:12:"display_name";s:13:"N.Y. / Region";}i:5;a:2:{s:7:"section";s:7:"science";s:12:"display_name";s:7:"Science";}i:6;a:2:{s:7:"section";s:6:"sports";s:12:"display_name";s:6:"Sports";}i:7;a:2:{s:7:"section";s:10:"technology";s:12:"display_name";s:10:"Technology";}i:8;a:2:{s:7:"section";s:4:"u.s.";s:12:"display_name";s:4:"U.S.";}i:9;a:2:{s:7:"section";s:5:"world";s:12:"display_name";s:5:"World";}i:10;a:2:{s:7:"section";s:8:"business";s:12:"display_name";s:8:"Business";}i:11;a:2:{s:7:"section";s:11:"automobiles";s:12:"display_name";s:11:"Automobiles";}i:12;a:2:{s:7:"section";s:5:"books";s:12:"display_name";s:5:"Books";}i:13;a:2:{s:7:"section";s:9:"education";s:12:"display_name";s:9:"Education";}i:14;a:2:{s:7:"section";s:15:"fashion & style";s:12:"display_name";s:15:"Fashion & Style";}i:15;a:2:{s:7:"section";s:28:"great homes and destinations";s:12:"display_name";s:28:"Great Homes and Destinations";}i:16;a:2:{s:7:"section";s:6:"movies";s:12:"display_name";s:6:"Movies";}i:17;a:2:{s:7:"section";s:7:"opinion";s:12:"display_name";s:7:"Opinion";}i:18;a:2:{s:7:"section";s:5:"style";s:12:"display_name";s:5:"Style";}i:19;a:2:{s:7:"section";s:6:"travel";s:12:"display_name";s:6:"Travel";}i:20;a:2:{s:7:"section";s:10:"your money";s:12:"display_name";s:10:"Your Money";}i:21;a:2:{s:7:"section";s:4:"news";s:12:"display_name";s:4:"News";}i:22;a:2:{s:7:"section";s:5:"autos";s:12:"display_name";s:5:"Autos";}i:23;a:2:{s:7:"section";s:5:"blogs";s:12:"display_name";s:5:"Blogs";}i:24;a:2:{s:7:"section";s:11:"corrections";s:12:"display_name";s:11:"Corrections";}i:25;a:2:{s:7:"section";s:15:"crossword/games";s:12:"display_name";s:15:"Crossword/Games";}i:26;a:2:{s:7:"section";s:10:"crosswords";s:12:"display_name";s:10:"Crosswords";}i:27;a:2:{s:7:"section";s:18:"crosswords & games";s:12:"display_name";s:18:"Crosswords & Games";}i:28;a:2:{s:7:"section";s:16:"crosswords/games";s:12:"display_name";s:16:"Crosswords/Games";}i:29;a:2:{s:7:"section";s:13:"dining & wine";s:12:"display_name";s:13:"Dining & Wine";}i:30;a:2:{s:7:"section";s:6:"giving";s:12:"display_name";s:6:"Giving";}i:31;a:2:{s:7:"section";s:13:"home & garden";s:12:"display_name";s:13:"Home & Garden";}i:32;a:2:{s:7:"section";s:10:"job market";s:12:"display_name";s:10:"Job Market";}i:33;a:2:{s:7:"section";s:8:"magazine";s:12:"display_name";s:8:"Magazine";}i:34;a:2:{s:7:"section";s:10:"multimedia";s:12:"display_name";s:10:"Multimedia";}i:35;a:2:{s:7:"section";s:11:"n.y./region";s:12:"display_name";s:11:"N.Y./Region";}i:36;a:2:{s:7:"section";s:10:"obituaries";s:12:"display_name";s:10:"Obituaries";}i:37;a:2:{s:7:"section";s:4:"open";s:12:"display_name";s:4:"Open";}i:38;a:2:{s:7:"section";s:11:"real estate";s:12:"display_name";s:11:"Real Estate";}i:39;a:2:{s:7:"section";s:15:"sunday magazine";s:12:"display_name";s:15:"Sunday Magazine";}i:40;a:2:{s:7:"section";s:13:"sunday review";s:12:"display_name";s:13:"Sunday Review";}i:41;a:2:{s:7:"section";s:10:"t magazine";s:12:"display_name";s:10:"T Magazine";}i:42;a:2:{s:7:"section";s:7:"t:style";s:12:"display_name";s:7:"T:Style";}i:43;a:2:{s:7:"section";s:7:"theater";s:12:"display_name";s:7:"Theater";}i:44;a:2:{s:7:"section";s:12:"times topics";s:12:"display_name";s:12:"Times Topics";}i:45;a:2:{s:7:"section";s:10:"washington";s:12:"display_name";s:10:"Washington";}i:46;a:2:{s:7:"section";s:14:"week in review";s:12:"display_name";s:14:"Week in Review";}}}',
+ 'effectiveUrl' => 'http://api.nytimes.com/svc/news/v3/content/section-list.sphp?api-key=4f3033d37819c9b78747d6731e9a43bb%3A7%3A57657007',
+ 'statusLine' => 'HTTP/1.1 200 OK',
+);

0 comments on commit 21a5040

Please sign in to comment.
Something went wrong with that request. Please try again.