Codebird library added
[friendica-addons.git/.git] / twitter / vendor / jublonet / codebird-php / test / returnformat_tests.php
1 <?php
2
3 namespace Codebird;
4 require_once ('test/codebirdm.php');
5
6 /**
7  * A Twitter library in PHP.
8  *
9  * @package   codebird-test
10  * @author    Jublo Solutions <support@jublo.net>
11  * @copyright 2010-2016 Jublo Solutions <support@jublo.net>
12  * @license   https://opensource.org/licenses/GPL-3.0 GNU General Public License 3.0
13  * @link      https://github.com/jublonet/codebird-php
14  */
15
16 /**
17  * Return format tests
18  *
19  * @package codebird-test
20  */
21 class Returnformat_Test extends \PHPUnit_Framework_TestCase
22 {
23   /**
24    * Initialise Codebird class
25    *
26    * @return \Codebird\Codebird The Codebird class
27    */
28   protected function getCB()
29   {
30     Codebird::setConsumerKey('123', '456');
31     $cb = new CodebirdM();
32     $cb->setToken('234', '567');
33
34     return $cb;
35   }
36
37   /**
38    * Tests array return format
39    */
40   public function testArrayFormat()
41   {
42     $cb = $this->getCB();
43     $cb->setReturnFormat(CODEBIRD_RETURNFORMAT_ARRAY);
44     $reply = $cb->users_show(['screen_name' => 'TwitterAPI']);
45     $this->assertTrue(is_array($reply));
46   }
47
48   /**
49    * Tests object return format
50    */
51   public function testObjectFormat()
52   {
53     $cb = $this->getCB();
54     $cb->setReturnFormat(CODEBIRD_RETURNFORMAT_OBJECT);
55     $reply = $cb->users_show(['screen_name' => 'TwitterAPI']);
56     $this->assertInstanceOf('stdClass', $reply);
57   }
58
59   /**
60    * Tests JSON return format
61    */
62   public function testJsonFormat()
63   {
64     $cb = $this->getCB();
65     $cb->setReturnFormat(CODEBIRD_RETURNFORMAT_JSON);
66     $reply = $cb->users_show(['screen_name' => 'TwitterAPI']);
67     $data = json_decode($reply);
68     $this->assertNotFalse($data);
69   }
70 }