/** * Test create torrent * * @return string */ protected function createTorrent() { $core = new Core($this->persistence); $core->setIp('127.0.0.1')->setInterval(60); $file = new File\File(dirname(__FILE__) . '/../Fixtures/' . self::FILE_TO_DOWNLOAD); $torrent = new Torrent($file, self::PIECE_LENGTH); $torrent->setAnnounceList(array(self::ANNOUNCE_URL)); return $core->addTorrent($torrent); }
/** * Test create torrent * * @return Torrent */ protected function getTorrent() { $file = new File\File(dirname(__FILE__) . '/../Fixtures/' . self::FILE_TO_DOWNLOAD); $torrent = new Torrent($file, self::PIECE_LENGTH); $torrent->setAnnounceList(array(self::ANNOUNCE_URL)); $torrent->setInfoHash(self::INFO_HASH); return $torrent; }
/** * Create torrent file * * @return string */ protected function createTorrentFile() { $persistence = new Persistence\Pdo('sqlite:' . $this->db_path); $core = new Core($persistence); $file = new File\File(dirname(__FILE__) . '/../Fixtures/' . self::FILE_TO_DOWNLOAD); $torrent = new Torrent($file, self::PIECE_LENGTH); $torrent->setAnnounceList(array('http://' . self::ANNOUNCE_SERVER_IP . ':' . self::ANNOUNCE_SERVER_PORT . '/announce.php')); $contents = $core->addTorrent($torrent); $file_name = sys_get_temp_dir() . "/phptracker_torrent" . uniqid() . '.torrent'; file_put_contents($file_name, $contents); return $file_name; }
/** * @covers PHP\BitTorrent\Torrent::setAnnounceList * @covers PHP\BitTorrent\Torrent::getAnnounceList */ public function testSetGetAnnounceList() { $announceList = array('http://tracker1/', 'http://tracker2/'); $this->assertSame($this->torrent, $this->torrent->setAnnounceList($announceList)); $this->assertSame($announceList, $this->torrent->getAnnounceList()); }