forked from brycied00d/PHP-Transmission-Class
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.php
executable file
·77 lines (51 loc) · 1.93 KB
/
tests.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
75
76
77
#!/usr/bin/php
<?php
require_once( dirname( __FILE__ ) . '/class/TransmissionRPC.class.php' );
$test_torrent = "http://www.slackware.com/torrents/slackware64-13.1-install-dvd.torrent";
$rpc = new TransmissionRPC();
//$rpc->username = 'test';
//$rpc->password = 'test';
//$rpc->debug = true;
try
{
$result = $rpc->sstats( );
print "GET SESSION STATS... [{$result->result}]\n";
sleep( 2 );
$result = $rpc->add( $test_torrent, '/tmp' );
$id = $result->arguments->torrent_added->id;
print "ADD TORRENT TEST... [{$result->result}] (id=$id)\n";
sleep( 2 );
$result = $rpc->set( $id, array('uploadLimit' => 10) );
print "SET TORRENT INFO TEST... [{$result->result}]\n";
sleep( 2 );
$rpc->return_as_array = true;
$result = $rpc->get( $id, array( 'uploadLimit' ) );
print "GET TORRENT INFO AS ARRAY TEST... [{$result['result']}]\n";
$rpc->return_as_array = false;
sleep( 2 );
$result = $rpc->get( $id, array( 'uploadLimit' ) );
print "GET TORRENT INFO AS OBJECT TEST... [{$result->result}]\n";
sleep( 2 );
$result2 = $result->arguments->torrents[0]->uploadLimit == 10 ? 'success' : 'failed';
print "VERIFY TORRENT INFO SET/GET... [{$result2}] (".$result->arguments->torrents[0]->uploadLimit.")\n";
$result = $rpc->stop( $id );
print "STOP TORRENT TEST... [{$result->result}]\n";
sleep( 2 );
$result = $rpc->verify( $id );
print "VERIFY TORRENT TEST... [{$result->result}]\n";
sleep( 10 );
$result = $rpc->start( $id );
print "START TORRENT TEST... [{$result->result}]\n";
sleep( 2 );
$result = $rpc->reannounce( $id );
print "REANNOUNCE TORRENT TEST... [{$result->result}]\n";
sleep( 2 );
$result = $rpc->move( $id, '/tmp/torrent-test', true );
print "MOVE TORRENT TEST... [{$result->result}]\n";
sleep( 2 );
$result = $rpc->remove( $id, false );
print "REMOVE TORRENT TEST... [{$result->result}]\n";
} catch (Exception $e) {
die('[ERROR] ' . $e->getMessage() . PHP_EOL);
}
?>