ExceptionTest::testBadMethodCallException()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Stichoza\GoogleTranslate\Tests;
4
5
use Stichoza\GoogleTranslate\TranslateClient;
6
7
class ExceptionTest extends \PHPUnit_Framework_TestCase
0 ignored issues
show
Bug introduced by
The type PHPUnit_Framework_TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
{
9
    public function setUp()
10
    {
11
        $this->tr = new TranslateClient();
0 ignored issues
show
Bug Best Practice introduced by
The property tr does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
12
    }
13
14
    /**
15
     * @expectedException BadMethodCallException
16
     */
17
    public function testBadMethodCallException()
18
    {
19
        $this->tr->fooBar('baz');
20
    }
21
22
    /**
23
     * @expectedException InvalidArgumentException
24
     */
25
    public function testInvalidArgumentException()
26
    {
27
        $this->tr->translate();
28
    }
29
30
    /**
31
     * @expectedException InvalidArgumentException
32
     */
33
    public function testInvalidArgumentException2()
34
    {
35
        $this->tr->translate(1);
36
    }
37
38
    /**
39
     * @expectedException BadMethodCallException
40
     */
41
    public function testStaticBadMethodCallException()
42
    {
43
        TranslateClient::fooBar('baz');
0 ignored issues
show
Bug introduced by
The method fooBar() does not exist on Stichoza\GoogleTranslate\TranslateClient. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

43
        TranslateClient::/** @scrutinizer ignore-call */ 
44
                         fooBar('baz');
Loading history...
44
    }
45
46
    /**
47
     * @expectedException InvalidArgumentException
48
     */
49
    public function testStaticInvalidArgumentException()
50
    {
51
        TranslateClient::translate();
0 ignored issues
show
Bug Best Practice introduced by
The method Stichoza\GoogleTranslate...lateClient::translate() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

51
        TranslateClient::/** @scrutinizer ignore-call */ 
52
                         translate();
Loading history...
Bug introduced by
The call to Stichoza\GoogleTranslate...lateClient::translate() has too few arguments starting with text. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

51
        TranslateClient::/** @scrutinizer ignore-call */ 
52
                         translate();

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
52
    }
53
54
    /**
55
     * @expectedException InvalidArgumentException
56
     */
57
    public function testStaticInvalidArgumentException2()
58
    {
59
        TranslateClient::translate(1);
0 ignored issues
show
Bug Best Practice introduced by
The method Stichoza\GoogleTranslate...lateClient::translate() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

59
        TranslateClient::/** @scrutinizer ignore-call */ 
60
                         translate(1);
Loading history...
60
    }
61
}
62