1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Bobbyshaw\WatsonVisualRecognition\Tests; |
4
|
|
|
|
5
|
|
|
use Bobbyshaw\WatsonVisualRecognition\Client; |
6
|
|
|
use Bobbyshaw\WatsonVisualRecognition\Message\ClassifyRequest; |
7
|
|
|
use Bobbyshaw\WatsonVisualRecognition\Message\GetClassifiersRequest; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class ClientTest |
11
|
|
|
* @package Bobbyshaw\WatsonVisualRecognition\Tests |
12
|
|
|
*/ |
13
|
|
|
class ClientTest extends Base |
14
|
|
|
{ |
15
|
|
|
/** @var Client */ |
16
|
|
|
private $client; |
17
|
|
|
private $username = 'username'; |
18
|
|
|
private $password = 'password'; |
19
|
|
|
|
20
|
|
|
public function setUp() |
21
|
|
|
{ |
22
|
|
|
$config = array( |
23
|
|
|
'username' => $this->username, |
24
|
|
|
'password' => $this->password, |
25
|
|
|
); |
26
|
|
|
|
27
|
|
|
$this->client = new Client(); |
28
|
|
|
$this->client->initialize($config); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function testGetClassifiers() |
32
|
|
|
{ |
33
|
|
|
$request = $this->client->getClassifiers(); |
34
|
|
|
$this->assertInstanceOf(GetClassifiersRequest::class, $request); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function testClassify() |
38
|
|
|
{ |
39
|
|
|
$request = $this->client->classify(); |
40
|
|
|
$this->assertInstanceOf(ClassifyRequest::class, $request); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function testVersion() |
44
|
|
|
{ |
45
|
|
|
$version = 'test'; |
46
|
|
|
$this->client->setVersion($version); |
47
|
|
|
$this->assertEquals($version, $this->client->getVersion()); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function testUsername() |
51
|
|
|
{ |
52
|
|
|
$username = 'test'; |
53
|
|
|
$this->client->setUsername($username); |
54
|
|
|
$this->assertEquals($username, $this->client->getUsername()); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function testPassword() |
58
|
|
|
{ |
59
|
|
|
$password = 'test'; |
60
|
|
|
$this->client->setPassword($password); |
61
|
|
|
$this->assertEquals($password, $this->client->getPassword()); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function testInitialize() |
65
|
|
|
{ |
66
|
|
|
$config = array( |
67
|
|
|
'username' => $this->username, |
68
|
|
|
'password' => $this->password, |
69
|
|
|
); |
70
|
|
|
|
71
|
|
|
$this->client = new Client(); |
72
|
|
|
$this->client->initialize($config); |
73
|
|
|
|
74
|
|
|
$this->assertEquals($this->username, $this->client->getUsername()); |
75
|
|
|
$this->assertEquals($this->password, $this->client->getPassword()); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|