MetadataTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 40
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 10 1
A testUpdateWithJSONException() 0 5 1
A testUpdate() 0 14 1
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
}