1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Bobbyshaw\WatsonVisualRecognition\Tests\Commands; |
4
|
|
|
|
5
|
|
|
use Bobbyshaw\WatsonVisualRecognition\Client; |
6
|
|
|
use Bobbyshaw\WatsonVisualRecognition\Commands\ClassifyCommand; |
7
|
|
|
use Bobbyshaw\WatsonVisualRecognition\Tests\Base; |
8
|
|
|
use Symfony\Component\Console\Input\ArrayInput; |
9
|
|
|
use Symfony\Component\Console\Output\BufferedOutput; |
10
|
|
|
|
11
|
|
|
class ClassifyCommandTest extends Base |
12
|
|
|
{ |
13
|
|
|
public function testCommand() |
14
|
|
|
{ |
15
|
|
|
$container = []; |
16
|
|
|
$response = $this->getMockHttpResponse('ClassifySuccess.txt'); |
17
|
|
|
$httpClient = $this->getMockHttpClientWithHistoryAndResponses($container, [$response]); |
18
|
|
|
|
19
|
|
|
$classifiers = 'photo_1572731175,Flower_Scene,Butterfly,Picket_Fence,Flower,bright_496607388,Insect,' . |
20
|
|
|
'Florist_Shop,living_room_1007650764,Violet,watermarked_2070418028,inside_402842804,Aquarium,Ballooning,' . |
21
|
|
|
'Arthropod,swimmingpool_109438771,Invertebrate,blurry_786219730,Shoes,sea_524758387,Graduation,' . |
22
|
|
|
'blue_sky_2056231781,Popcorn,Hummingbird,Cormorant,blurry_786219730,blue_sky_2056231781,Blue,' . |
23
|
|
|
'Military_Plane,Statue_of_Liberty,Fish,Rainbow,White,watermarked_2070418028,Red,Hang_Gliding,Crevasse,' . |
24
|
|
|
'Frost,Air_Sport,Bird,Vertebrate,Animal,Capitol,Ice_Scene,Ski_Jumping,photo_1114291327'; |
25
|
|
|
|
26
|
|
|
$arguments = [ |
27
|
|
|
'username' => 'test', |
28
|
|
|
'password' => 'test', |
29
|
|
|
'images' => 'Tests/images/Cosmos-Flower-And-Hummingbird.zip', |
30
|
|
|
'--classifiers' => $classifiers, |
31
|
|
|
'--version-date' => '2016-01-01' |
32
|
|
|
]; |
33
|
|
|
$input = new ArrayInput($arguments); |
34
|
|
|
|
35
|
|
|
$output = new BufferedOutput(); |
36
|
|
|
|
37
|
|
|
$command = new ClassifyCommand(null, new Client($httpClient)); |
38
|
|
|
$command->run($input, $output); |
39
|
|
|
|
40
|
|
|
$this->assertEquals('classifiers:classify', $command->getName()); |
41
|
|
|
|
42
|
|
|
$correctOutput = file_get_contents('Tests/Mock/Commands/ClassifySuccess.txt'); |
43
|
|
|
|
44
|
|
|
$this->assertEquals($correctOutput, $output->fetch()); |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|