File_Bittorrent
[ class tree: File_Bittorrent ] [ index: File_Bittorrent ] [ all elements ]

Source for file Bug7406.php

Documentation is available at Bug7406.php

  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.     /**
  26.     * Test for Bug #7406
  27.     *
  28.     * @link http://pear.php.net/bugs/bug.php?id=7406
  29.     * @package File_Bittorrent
  30.     * @subpackage Test
  31.     * @category File
  32.     * @author Markus Tacker <m@tacker.org>
  33.     * @version $Id: Bug7406.php 72 2007-03-13 14:53:28Z m $
  34.     */
  35.  
  36.     require_once 'PHPUnit/Framework/TestCase.php';
  37.     require_once 'File/Bittorrent/MakeTorrent.php';
  38.     require_once 'File/Bittorrent/Decode.php';
  39.  
  40.     /**
  41.     * Test for Bug #7406
  42.     *
  43.     * @link http://pear.php.net/bugs/bug.php?id=7406
  44.     * @package File_Bittorrent
  45.     * @subpackage Test
  46.     * @category File
  47.     * @author Markus Tacker <m@tacker.org>
  48.     * @version $Id: Bug7406.php 72 2007-03-13 14:53:28Z m $
  49.     */
  50.     class Tests_Bug7406 extends PHPUnit_Framework_TestCase
  51.     {
  52.         public static $torrent './bugs/bug-7406/TestDir';
  53.  
  54.         public function testAnnounceList()
  55.         {
  56.             $MakeTorrent = new File_Bittorrent_MakeTorrent(self::$torrent);
  57.             // Set the announce URL
  58.             $MakeTorrent->setAnnounce('http://www.example.org');
  59.             // Set the comment
  60.             $MakeTorrent->setComment('Hello World!');
  61.             // Set the piece length (in KB)
  62.             $MakeTorrent->setPieceLength(256);
  63.             // Build the torrent
  64.             $metainfo $MakeTorrent->buildTorrent();
  65.  
  66.             $Decode = new File_Bittorrent_Decode();
  67.             $info $Decode->decode($metainfo);
  68.             $this->assertEquals(count($info['info']['files'])3);
  69.             $files = array();
  70.             foreach ($info['info']['files'as $k => $v{
  71.                 $files[$v['path'][0];
  72.             }
  73.             sort($files);
  74.             $expected = array (
  75.                 '1.txt',
  76.                 '2.txt',
  77.                 '3.txt',
  78.             );
  79.             $this->assertEquals($expected$files);
  80.         }
  81.     }
  82.  
  83. ?>

Documentation generated on Tue, 13 Mar 2007 10:00:09 -0500 by phpDocumentor 1.3.0. PEAR Logo Copyright © PHP Group 2004.