| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | include '../vendor/autoload.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | use Guzzle\Http; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | class BundleTest extends PHPUnit_Framework_TestCase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |     protected $bundle = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |     protected $client = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |     protected $media  = 'http://media.clarify.io/audio/samples/harvard-sentences-1.wav'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |     public function setUp() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |         global $apikey; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |         $this->client = new \Clarify\Client($apikey); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |         $this->bundle = new \Clarify\Bundle($apikey, $this->client); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |         parent::setUp(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     public function testCreate() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |         $name = 'name - testCreate' . rand(0, 500); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |         $this->bundle->create($name, $this->media); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |         $this->assertEquals(201, $this->bundle->getStatusCode()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |         $location = $this->bundle->location; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |         $this->assertEquals(44, strlen($location)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         $this->assertTrue($this->bundle->delete($location)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |         $this->assertEquals(204, $this->bundle->getStatusCode()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |      * @expectedException \Clarify\Exceptions\InvalidJSONException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     public function testCreateWithJSONException() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         $name = 'name - testCreate'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         $this->bundle->create($name, $this->media, 'not a json string'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |      * @expectedException \Clarify\Exceptions\InvalidEnumTypeException | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 46 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |     public function testCreateWithChannelException() | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  |         $name = 'name - testCreate'; | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |         $this->bundle->create($name, $this->media, '', '', 'neither channel!'); | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     public function testUpdate() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |         $name = 'name - testUpdate'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         $this->bundle->create($name, $this->media); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         $this->assertEquals(201, $this->bundle->getStatusCode()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         $location = $this->bundle->location; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         $this->assertTrue($this->bundle->update($location, array())); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         $this->assertEquals(202, $this->bundle->getStatusCode()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |      * @expectedException \Clarify\Exceptions\InvalidIntegerArgumentException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     public function testUpdateWithException() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |         $this->bundle->update('id', 'name', 'http://google.com', 'not a version string'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |     public function testDelete() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |         $name = 'name - testUpdate'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |         $this->bundle->create($name, $this->media); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |         $this->assertEquals(201, $this->bundle->getStatusCode()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |         $location = $this->bundle->location; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |         $this->assertTrue($this->bundle->delete($location)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |         $this->assertEquals(204, $this->bundle->getStatusCode()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |         $this->bundle->load($location); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |         $this->assertEquals(404, $this->bundle->getStatusCode()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |     public function testIndex() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |         $data = $this->bundle->index(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |         $items = $data['_links']['items']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |         $this->assertEquals(10, $data['limit']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |         $this->assertLessThanOrEqual(10, count($items)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |         $data = $this->bundle->index(2); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |         $items = $data['_links']['items']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |         $this->assertEquals(2, $data['limit']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |         $this->assertLessThanOrEqual(2, count($items)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |     public function test__get() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |         $object = $this->bundle->tracks; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         $this->assertInstanceOf('\Clarify\Tracks', $object); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |         $object = $this->bundle->metadata; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |         $this->assertInstanceOf('\Clarify\Metadata', $object); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |      * @expectedException \Clarify\Exceptions\InvalidResourceException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |     public function test__getWithException() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |         $object = $this->bundle->monkey; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 116 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 117 |  |  | } | 
            
                        
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: