public function testFacebookStat() { $stats = URLStatistics::get()->filter(array('Service' => 'Facebook')); $facebookService = new FacebookCount(); $statistics = $facebookService->getStatistics(); foreach ($stats as $stat) { $this->assertEquals($stat->Service, 'Facebook'); $this->assertArrayHasKey($stat->Action, array_flip($statistics)); $this->assertEquals($stat->Count, 50); $this->assertEquals($stat->URL, $this->testURL); } }
public function testFacebookServiceAPI() { $request = $this->get('api/countsfor/service/facebook?urls=' . $this->testURL); $this->assertEquals($request->getStatusCode(), 200); $body = $request->getBody(); $socialQueue = SocialQueue::get()->first(); $this->assertEquals($socialQueue->Active, 1); $jsonArray = json_decode($body, true); $results = $jsonArray['results']; $www = $results[$this->testURL]; $facebookService = new FacebookCount(); $expectedCount = count($facebookService->getStatistics()) * 2 + 1; $this->assertEquals(count($www, true), $expectedCount); foreach ($www['Facebook'] as $facebook) { foreach ($facebook as $key => $value) { $this->assertEquals($facebook[$key], 50); } } // confirm the URL has been requeued $socialQueue = SocialQueue::get()->first(); $this->assertEquals($socialQueue->Active, 1); $urls = json_decode($socialQueue->URLs, true); $this->assertEquals($urls[0], $this->testURL); }