My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes  
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
75
76
77
78
79
80
81
82
83
84
85
86
<?php
if (! defined('SIMPLE_TEST')) {
define('SIMPLE_TEST', '../../../simpletest/');
}
require_once(SIMPLE_TEST . 'unit_tester.php');
require_once(SIMPLE_TEST . 'reporter.php');
require_once('../blip-php.php');

class TestOfBlipUpload extends UnitTestCase {
function setUp() {

}

function TestOfBlipUpload() {
$this->UnitTestCase();
}

function test_the_truth() {
$this->assertTrue(true);
}

function test_blip_create() {
$blip = new BlipPHP();
$this->assertNotNull($blip);
}

function test_upload_standard () {
$blip = new BlipPHP();
$response = $blip->upload($username = "api_test_user", $password = "bliptastic", $file = '../videos/blip_test_footage.mp4', $title='Test Title', $description = 'Test Description');
$this->assertNotNull($response);
$this->assertTrue($response instanceof SimpleXMLElement);
$this->assertEqual($response->status, "OK");

$this->assertTrue($response->timestamp > 0);

// Moving on to testing the payload
$this->assertNotNull($response->payload);
$this->assertNotNull($response->payload->asset);

$this->assertTrue($response->payload->asset->id > 0);
$this->assertEqual("file", $response->payload->asset->item_type[0]);

$this->assertNotNull($response->payload->asset->links);
$this->assertEqual(5, count($response->payload->asset->links->link));
}

function test_upload_wrong_password() {
$blip = new BlipPHP();

$this->expectException('Exception');
$response = $blip->upload($username = "api_test_user", $password = "wrongpassword", $file = '../videos/blip_test_footage.mp4', $title='Test Title', $description = 'Test Description');
}

function test_upload_no_username() {
$blip = new BlipPHP();

$this->expectException('BlipAuthenticationException');
$response = $blip->upload($password = "wrongpassword", $file = '../videos/blip_test_footage.mp4', $title='Test Title', $description = 'Test Description');
}

function test_upload_blank_username() {
$blip = new BlipPHP();

$this->expectException('BlipAuthenticationException');
$response = $blip->upload($username = "", $password = "wrongpassword", $file = '../videos/blip_test_footage.mp4', $title='Test Title', $description = 'Test Description');
}

// function test_upload_no_title() {
// $blip = new BlipPHP();
//
// $this->expectException('BlipDataException');
// $response = $blip->upload($username = "api_test_user", $password = "bliptastic", $file = '../videos/blip_test_footage.mp4', $description = 'Test Description');
// }

function test_upload_blanke_title() {
$blip = new BlipPHP();

$this->expectException('BlipDataException');
$response = $blip->upload($username = "something", $password = "wrongpassword", $file = '../videos/blip_test_footage.mp4', $title='', $description = 'Test Description');
}

}

$test = &new TestOfBlipUpload();
$test->run(new HtmlReporter());
?>

Change log

r9 by michael.k.sutton on Jun 26, 2009   Diff
renamed blip_upload to upload
Go to: 
Sign in to write a code review

Older revisions

r7 by michael.k.sutton on Jun 26, 2009   Diff
adding the test files

All revisions of this file

File info

Size: 3226 bytes, 86 lines
Powered by Google Project Hosting