root/trunk/Tests/Bug7406.php
| Revision 72, 3.2 KB (checked in by m, 22 months ago) | |
|---|---|
|
|
| Line | |
|---|---|
| 1 | <?php |
| 2 | |
| 3 | // +----------------------------------------------------------------------+ |
| 4 | // | MakeTorrent and Encode data in Bittorrent format | |
| 5 | // +----------------------------------------------------------------------+ |
| 6 | // | Copyright (C) 2004-2005 Markus Tacker <m@tacker.org> | |
| 7 | // +----------------------------------------------------------------------+ |
| 8 | // | This library is free software; you can redistribute it and/or | |
| 9 | // | modify it under the terms of the GNU Lesser General Public | |
| 10 | // | License as published by the Free Software Foundation; either | |
| 11 | // | version 2.1 of the License, or (at your option) any later version. | |
| 12 | // | | |
| 13 | // | This library is distributed in the hope that it will be useful, | |
| 14 | // | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 16 | // | Lesser General Public License for more details. | |
| 17 | // | | |
| 18 | // | You should have received a copy of the GNU Lesser General Public | |
| 19 | // | License along with this library; if not, write to the | |
| 20 | // | Free Software Foundation, Inc. | |
| 21 | // | 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
| 22 | // +----------------------------------------------------------------------+ |
| 23 | |
| 24 | /** |
| 25 | * Test for Bug #7406 |
| 26 | * |
| 27 | * @link http://pear.php.net/bugs/bug.php?id=7406 |
| 28 | * @package File_Bittorrent |
| 29 | * @subpackage Test |
| 30 | * @category File |
| 31 | * @author Markus Tacker <m@tacker.org> |
| 32 | * @version $Id$ |
| 33 | */ |
| 34 | |
| 35 | require_once 'PHPUnit/Framework/TestCase.php'; |
| 36 | require_once 'File/Bittorrent/MakeTorrent.php'; |
| 37 | require_once 'File/Bittorrent/Decode.php'; |
| 38 | |
| 39 | /** |
| 40 | * Test for Bug #7406 |
| 41 | * |
| 42 | * @link http://pear.php.net/bugs/bug.php?id=7406 |
| 43 | * @package File_Bittorrent |
| 44 | * @subpackage Test |
| 45 | * @category File |
| 46 | * @author Markus Tacker <m@tacker.org> |
| 47 | * @version $Id$ |
| 48 | */ |
| 49 | class Tests_Bug7406 extends PHPUnit_Framework_TestCase |
| 50 | { |
| 51 | public static $torrent = './bugs/bug-7406/TestDir'; |
| 52 | |
| 53 | public function testAnnounceList() |
| 54 | { |
| 55 | $MakeTorrent = new File_Bittorrent_MakeTorrent(self::$torrent); |
| 56 | // Set the announce URL |
| 57 | $MakeTorrent->setAnnounce('http://www.example.org'); |
| 58 | // Set the comment |
| 59 | $MakeTorrent->setComment('Hello World!'); |
| 60 | // Set the piece length (in KB) |
| 61 | $MakeTorrent->setPieceLength(256); |
| 62 | // Build the torrent |
| 63 | $metainfo = $MakeTorrent->buildTorrent(); |
| 64 | |
| 65 | $Decode = new File_Bittorrent_Decode(); |
| 66 | $info = $Decode->decode($metainfo); |
| 67 | $this->assertEquals(count($info['info']['files']), 3); |
| 68 | $files = array(); |
| 69 | foreach ($info['info']['files'] as $k => $v) { |
| 70 | $files[] = $v['path'][0]; |
| 71 | } |
| 72 | sort($files); |
| 73 | $expected = array ( |
| 74 | '1.txt', |
| 75 | '2.txt', |
| 76 | '3.txt', |
| 77 | ); |
| 78 | $this->assertEquals($expected, $files); |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | ?> |
Note: See TracBrowser
for help on using the browser.