/** * @dataProvider providerTestFbMeta */ public function testFbMeta($parseString, $expected) { $ma = new MockApplication(); $parser = new RingsideSocialDslParser($ma); $results = $parser->parseString($parseString); $this->assertEquals(stripNewlines($expected), stripNewlines(trim($results)), "{$expected} != {$results}"); }
/** * @dataProvider providerTestFbShareButton */ public function testFbShareButton($parseString, $expected) { $ma = new MockApplication(); $parser = new RingsideSocialDslParser($ma); $results = $parser->parseString($parseString); $this->assertEquals($expected, trim($results), "{$expected} != {$results}"); }
/** * @dataProvider providerTestUserHasAddedApp */ public function testFbUserHasAddedApp($mockUid, $mockMethodResults, $parseString, $expected) { $ma = new MockApplication(); $ma->uid = $mockUid; $ma->client = new MockClient(); $ma->client->method = $mockMethodResults; $parser = new RingsideSocialDslParser($ma); $results = $parser->parseString($parseString); $this->assertEquals($expected, trim($results), "{$expected} != {$results}"); }
/** * @dataProvider providerTestFbUser */ public function testFbUser($mockUid, $mockMethodResults, $parseString, $expected) { $ma = new MockApplication(); $ma->uid = $mockUid; $ma->client = new MockClient(); $ma->client->method = $mockMethodResults; $parser = new RingsideSocialDslParser($ma); $results = $parser->parseString($parseString); // error_log("Results: '$results'"); $this->assertEquals($expected, trim($results)); }
/** * @dataProvider providerTestFbTabs */ public function testFbTabs($parseString, $expected) { $ma = new MockApplication(); $ma->client = new MockClient(); $parser = new RingsideSocialDslParser($ma); $results = $parser->parseString($parseString); $length1 = sizeof($expected); $length2 = sizeof($results); $length = $length1 > $length2 ? $length2 : $length1; $newExpected = substr($expected, 0, $length); $newActual = substr($results, 0, $length); $this->assertEquals($newExpected, $newActual, "{$expected} != {$results}"); }
public function renderFbml($fbmlText, $network_session, $apiClient, $app_id) { if (!empty($fbmlText)) { try { $flavor_context = new RingsideSocialDslFlavorContext(); $context = new RingsideSocialDslContext($apiClient, $network_session, $flavor_context, $app_id); $parser = new RingsideSocialDslParser($context); $flavor_context->startFlavor('canvas'); $text = $parser->parseString($fbmlText); $flavor_context->endFlavor('canvas'); $this->redirect = $parser->getRedirect(); return $text; } catch (Exception $exception) { $this->error = $exception->getMessage(); error_log("Exception thrown during parsing page ({$exception})"); } } return null; }
/** * @dataProvider providerTestFbError */ public function testFbError($parseString, $expected) { $parser = new RingsideSocialDslParser(new MockApplication()); $results = $parser->parseString($parseString); $this->assertEquals($expected, trim($results)); }
/** * @dataProvider providerFeeds */ public function testFeeds($mockUid, $mockMethodResults, $parseString, $expectedSubstrings, $notExpectedSubstrings) { $ma = new MockApplication(); $ma->uid = $mockUid; $ma->client = new MockClient(); $ma->client->method = $mockMethodResults; $parser = new RingsideSocialDslParser($ma); $results = $parser->parseString($parseString); // error_log( 'results: ' . var_export( $results, true ) ); if ($expectedSubstrings != null) { foreach ($expectedSubstrings as $substring) { $this->assertContains($substring, $results, "[{$substring}] not found in [{$results}] but should have been"); $index = strpos($results, $substring); $this->assertTrue(isset($index)); $secondHalf = substr($results, $index + strlen($substring)); // error_log( 'secondHalf: ' . var_export( $secondHalf, true ) ); $index = strpos($secondHalf, $substring); $this->assertFalse($index, "Found [{$substring}] a second time in [{$results}]"); } } if ($notExpectedSubstrings != null) { foreach ($notExpectedSubstrings as $notsubstring) { $this->assertNotContains($notsubstring, $results, "[{$notsubstring}] found in [{$results}] but should not have been"); } } }
public function testFbEditorCustomHrule() { $ma = new MockApplication(); $ma->client = new MockClient(); $parser = new RingsideSocialDslParser($ma); $parseString = '<fb:editor action="edit_app.php" labelwidth="150"> <fb:editor-custom><br /><hr /><br /></fb:editor-custom> </fb:editor>'; $results = $parser->parseString($parseString); $expected = '<form action="edit_app.php" method="post"> <table class="editorkit" border="0" cellspacing="0" style="width:425px"> <tr><td colspan="2" /></tr> <tr><th style="width:150px"></th><td><br /> <hr /> <br /></td></tr> <tr><th style="width:150px"></th><td> </td></tr> </table> </form>'; // For whatever reason, spacing and formatting matters; and introducing newlines makes the results of a failure readable. $this->assertXmlStringEqualsXmlString($expected, preg_replace(array(',</tr>,', ',<table([^>]*)>,'), array("</tr>\n", "<table\$1>\n"), str_replace(' ', ' ', $results))); }
/** * @dataProvider providerTestFbGoogleAnalytics */ public function testFbGoogleAnalytics($parseString, $expected) { $parser = new RingsideSocialDslParser(new MockApplication()); $results = $parser->parseString($parseString); $this->assertEquals($expected, trim($results), "results do not match"); }
public function testFbCommentsNumposts() { $numposts = 2; $inputs = array('xid', 'true', 'true', $numposts, null, null, null, null, null); $comments = array(array('uid' => 44, 'cid' => 4400, 'text' => 'msg 1', 'created' => time()), array('uid' => 44, 'cid' => 4401, 'text' => 'msg 2', 'created' => time()), array('uid' => 44, 'cid' => 4402, 'text' => 'msg 3', 'created' => time())); $mockResults = array('ringside.comments.get' => $comments); $ma = new MockApplication(); $ma->client = new MockClient(); $ma->client->method = $mockResults; $ma->applicationId = '12345'; $parser = new RingsideSocialDslParser($ma); $results = $parser->parseString(self::buildCase($inputs)); $count = substr_count($results, '<div class="comment">'); $this->assertTrue($count == 2); }
/** * @dataProvider providerTestPlansBasic */ public function testPlansBasic($mockMethodResults, $parseString, $expectedSubstrings, $notExpectedSubstrings) { $ma = new MockApplication(); $ma->client = new MockClient(); $ma->client->method = $mockMethodResults; $ma->applicationId = '100101'; $parser = new RingsideSocialDslParser($ma); $results = $parser->parseString($parseString); if ($expectedSubstrings != null) { foreach ($expectedSubstrings as $substring) { $this->assertContains($substring, $results); } } if ($notExpectedSubstrings != null) { foreach ($notExpectedSubstrings as $notsubstring) { $this->assertNotContains($notsubstring, $results); } } }
public function testVoomaxerStyle() { $a = new MockApplication(); $p = new RingsideSocialDslParser($a); $result = $p->parseString(<<<EOF <link href="http://dev.fastlightbeautiful.com:4012/stylesheets/fb_style.css?1207684280" media="screen" rel="stylesheet" type="text/css" /> <style> /* =LOGO */ .logo { width: 646px; height: 70px; display: block; background: url("http://dev.fastlightbeautiful.com:4012/images/facebook/logo.png") 0 0 no-repeat; text-indent: -5000px; margin-bottom: 10px; clear: both; } </style> <script> function submit_message_ajax(form_obj) { // set spinner document.getElementById('spinner').setStyle('display', 'block'); var ajax = new Ajax(); ajax.responseType = Ajax.FBML; var post_data = form_obj.serialize(); ajax.post("http://dev.fastlightbeautiful.com:4012/messages?_method=post", post_data); ajax.ondone = function(data) { \$('discussion_pane').setInnerFBML(data); document.getElementById('spinner').setStyle('display', 'none'); } ajax.onerror = function(data) { element_for_error = form_obj.getPreviousSibling(); // the error div needs to be the previous sibling element_for_error.setInnerXHTML("<p>Must enter some text</p>"); Animation(element_for_error).to('background', '#ffffff').from('background', '#ffff99').go(); document.getElementById('spinner').setStyle('display', 'none'); } } </script> EOF ); $this->assertEquals(<<<EOF <link href="http://dev.fastlightbeautiful.com:4012/stylesheets/fb_style.css?1207684280" media="screen" rel="stylesheet" type="text/css"/><style> /* =LOGO */ .logo { width: 646px; height: 70px; display: block; background: url("http://dev.fastlightbeautiful.com:4012/images/facebook/logo.png") 0 0 no-repeat; text-indent: -5000px; margin-bottom: 10px; clear: both; } </style><script> function submit_message_ajax(form_obj) { // set spinner document.getElementById('spinner').setStyle('display', 'block'); var ajax = new Ajax(); ajax.responseType = Ajax.FBML; var post_data = form_obj.serialize(); ajax.post("http://dev.fastlightbeautiful.com:4012/messages?_method=post", post_data); ajax.ondone = function(data) { \$('discussion_pane').setInnerFBML(data); document.getElementById('spinner').setStyle('display', 'none'); } ajax.onerror = function(data) { element_for_error = form_obj.getPreviousSibling(); // the error div needs to be the previous sibling element_for_error.setInnerXHTML("<p>Must enter some text</p>"); Animation(element_for_error).to('background', '#ffffff').from('background', '#ffff99').go(); document.getElementById('spinner').setStyle('display', 'none'); } } </script> EOF , $result); }