-
Notifications
You must be signed in to change notification settings - Fork 0
/
FactoryTest.php
74 lines (65 loc) · 2.25 KB
/
FactoryTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
namespace Gloubster\Tests\Message;
use Gloubster\Message\Factory;
use Gloubster\Message\Job\ImageJob;
use Gloubster\Message\Job\VideoJob;
use Gloubster\Message\Presence\WorkerPresence;
use Gloubster\Delivery\Filesystem as FilesystemDelivery;
class FactoryTests extends \PHPUnit_Framework_TestCase
{
/**
* @dataProvider getData
* @covers Gloubster\Message\Factory::fromJson
*/
public function testFromJson($expected, $json)
{
$this->assertEquals($expected, Factory::fromJson($json));
}
public function getData()
{
$delivery = new FilesystemDelivery();
$delivery->setTarget('/path/to/Target');
/**
* @todo add receipts
*/
$receipts = array();
$image = new ImageJob();
$image->setEnd(microtime(true))
->setDeliveryDuration(25.4)
->setDelivery($delivery)
->setError(true)
->setErrorMessage('An error ploped')
->setParameters(array('param1'=>'val1', 'param2'=>'val2'))
->setProcessDuration(23.42)
->setWorkerId('a worker-id')
->setSource('/path/to/source')
->setReceipts($receipts);
$video = new VideoJob();
$image->setEnd(microtime(true))
->setDeliveryDuration(25.4)
->setDelivery($delivery)
->setError(true)
->setErrorMessage('An error ploped')
->setParameters(array('param1'=>'val1', 'param2'=>'val2'))
->setProcessDuration(23.42)
->setWorkerId('a worker-id')
->setSource('/path/to/source')
->setReceipts($receipts);
$presence = new WorkerPresence();
$presence->setWorkerType('worker-type')
->setFailureJobs(mt_rand())
->setId(mt_rand())
->setMemory(123456789)
->setStartedTime(223456789.987654322)
->setLastJobTime(333456789.987654333)
->setTotalJobs(mt_rand())
->setSuccessJobs(mt_rand())
->setReportTime(444456789.987654444)
->setIdle(true);
return array(
array($image, $image->toJson()),
array($video, $video->toJson()),
array($presence, $presence->toJson()),
);
}
}