MetadataTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 10
rs 9.4285
1
<?php
2
include '../vendor/autoload.php';
3
4
use Guzzle\Http;
5
6
class MetadataTest extends PHPUnit_Framework_TestCase
7
{
8
    protected $bundle = null;
9
    protected $media  = 'http://media.clarify.io/audio/samples/harvard-sentences-1.wav';
10
11
    public function setUp()
12
    {
13
        global $apikey;
14
15
        $this->client = new \Clarify\Client($apikey);
0 ignored issues
show
Bug introduced by
The property client does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
16
        $this->bundle = new \Clarify\Bundle($apikey, $this->client);
17
        $this->metadata = new \Clarify\Metadata($this->client);
0 ignored issues
show
Bug introduced by
The property metadata does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
18
19
        parent::setUp();
20
    }
21
22
    /**
23
     * @expectedException \Clarify\Exceptions\InvalidJSONException
24
     */
25
    public function testUpdateWithJSONException()
26
    {
27
        $params = array('data' => 'not a json string');
28
        $this->metadata->update($params);
29
    }
30
31
    public function testUpdate()
32
    {
33
        $name = 'name - testMetadataUpdate';
34
        $this->bundle->create($name, $this->media);
35
        $this->assertEquals(201, $this->bundle->getStatusCode());
36
        $location = $this->bundle->location;
37
38
        $params = array('data' => '{"name" : "value"}', 'id' => $location);
39
        $result = $this->bundle->metadata->update($params);
40
        $this->assertTrue($result);
41
42
        $this->assertTrue($this->bundle->delete($location));
43
        $this->assertEquals(204, $this->bundle->getStatusCode());
44
    }
45
}