testProjectsUpdateDetectInvalidAuthentication()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Onesky\Api\Tests;
4
5
use Onesky\Api\Client;
6
7
/**
8
 * Class to test the projects resource.
9
 *
10
 * See more about projects resource here:
11
 * https://github.com/onesky/api-documentation-platform/blob/master/resources/project.md
12
 *
13
 * @author Bernardo Silva <[email protected]>
14
 */
15
class ProjectsApiTest extends \PHPUnit_Framework_TestCase
16
{
17
    /** @var \Onesky\Api\Client $api */
18
    protected $api;
19
20
    public function setUp()
21
    {
22
        $this->api = new Client();
23
    }
24
25
    /**
26
     * @expectedException \InvalidArgumentException
27
     * @expectedExceptionMessage Invalid resource action
28
     */
29
    public function testProjectsDetectMissingResourceAction()
30
    {
31
        $this->api->projects();
0 ignored issues
show
Documentation Bug introduced by
The method projects does not exist on object<Onesky\Api\Client>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
32
    }
33
34
    /**
35
     * @expectedException \InvalidArgumentException
36
     * @expectedExceptionMessage Missing parameter: project_group_id
37
     */
38
    public function testProjectsListDetectMissingGroupIdParam()
39
    {
40
        $this->api->projects('list');
0 ignored issues
show
Documentation Bug introduced by
The method projects does not exist on object<Onesky\Api\Client>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
41
    }
42
43
    /**
44
     * @expectedException \UnexpectedValueException
45
     * @expectedExceptionMessage Invalid authenticate data of api key or secret
46
     */
47
    public function testProjectsListDetectInvalidAuthentication()
48
    {
49
        $this->api->projects('list', ['project_group_id' => 123]);
0 ignored issues
show
Documentation Bug introduced by
The method projects does not exist on object<Onesky\Api\Client>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
50
    }
51
52
53
    /**
54
     * @expectedException \InvalidArgumentException
55
     * @expectedExceptionMessage Missing parameter: project_id
56
     */
57
    public function testProjectsShowDetectMissingParam()
58
    {
59
        $this->api->projects('show');
0 ignored issues
show
Documentation Bug introduced by
The method projects does not exist on object<Onesky\Api\Client>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
60
    }
61
62
    /**
63
     * @expectedException \UnexpectedValueException
64
     * @expectedExceptionMessage Invalid authenticate data of api key or secret
65
     */
66
    public function testProjectsShowDetectInvalidAuthentication()
67
    {
68
        $this->api->projects('show', ['project_id' => 123]);
0 ignored issues
show
Documentation Bug introduced by
The method projects does not exist on object<Onesky\Api\Client>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
69
    }
70
71
    /**
72
     * @expectedException \InvalidArgumentException
73
     * @expectedExceptionMessage Missing parameter: project_group_id
74
     */
75
    public function testProjectsCreateDetectMissingGroupIdParam()
76
    {
77
        $this->api->projects('create');
0 ignored issues
show
Documentation Bug introduced by
The method projects does not exist on object<Onesky\Api\Client>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
78
    }
79
80
    /**
81
     * @expectedException \UnexpectedValueException
82
     * @expectedExceptionMessage Invalid authenticate data of api key or secret
83
     */
84
    public function testProjectsCreateDetectMissingParam()
85
    {
86
        $this->api->projects('create', ['project_group_id' => 123]);
0 ignored issues
show
Documentation Bug introduced by
The method projects does not exist on object<Onesky\Api\Client>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
87
    }
88
89
    /**
90
     * @expectedException \InvalidArgumentException
91
     * @expectedExceptionMessage Missing parameter: project_id
92
     */
93
    public function testProjectsUpdateDetectMissingParam()
94
    {
95
        $this->api->projects('update');
0 ignored issues
show
Documentation Bug introduced by
The method projects does not exist on object<Onesky\Api\Client>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
96
    }
97
98
    /**
99
     * @expectedException \UnexpectedValueException
100
     * @expectedExceptionMessage Invalid authenticate data of api key or secret
101
     */
102
    public function testProjectsUpdateDetectInvalidAuthentication()
103
    {
104
        $this->api->projects('update', ['project_id' => 123]);
0 ignored issues
show
Documentation Bug introduced by
The method projects does not exist on object<Onesky\Api\Client>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
105
    }
106
107
    /**
108
     * @expectedException \InvalidArgumentException
109
     * @expectedExceptionMessage Missing parameter: project_id
110
     */
111
    public function testProjectsDeleteDetectMissingParam()
112
    {
113
        $this->api->projects('delete');
0 ignored issues
show
Documentation Bug introduced by
The method projects does not exist on object<Onesky\Api\Client>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
114
    }
115
116
    /**
117
     * @expectedException \UnexpectedValueException
118
     * @expectedExceptionMessage Invalid authenticate data of api key or secret
119
     */
120
    public function testProjectsDeleteDetectInvalidAuthentication()
121
    {
122
        $this->api->projects('delete', ['project_id' => 123]);
0 ignored issues
show
Documentation Bug introduced by
The method projects does not exist on object<Onesky\Api\Client>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
123
    }
124
125
    /**
126
     * @expectedException \InvalidArgumentException
127
     * @expectedExceptionMessage Missing parameter: project_id
128
     */
129
    public function testProjectsLanguagesDetectMissingParam()
130
    {
131
        $this->api->projects('languages');
0 ignored issues
show
Documentation Bug introduced by
The method projects does not exist on object<Onesky\Api\Client>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
132
    }
133
134
    /**
135
     * @expectedException \UnexpectedValueException
136
     * @expectedExceptionMessage Invalid authenticate data of api key or secret
137
     */
138
    public function testProjectsLanguagesDetectInvalidAuthentication()
139
    {
140
        $this->api->projects('languages', ['project_id' => 123]);
0 ignored issues
show
Documentation Bug introduced by
The method projects does not exist on object<Onesky\Api\Client>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
141
    }
142
}
143