/** * Testing .torrent file creation. */ public function testCreateTorrentFile() { $bencoded_torrent = $this->object->createTorrentFile(array('http://announce')) . ''; $parser = new PHPTracker_Bencode_Parser($bencoded_torrent); $decoded_torrent = $parser->parse()->represent(); $this->assertEquals($decoded_torrent['info']['piece length'], $this->object->size_piece); $this->assertEquals($decoded_torrent['info']['name'], $this->object->name); $this->assertEquals($decoded_torrent['info']['length'], $this->object->length); $this->assertEquals($decoded_torrent['info']['pieces'], $this->object->pieces); $this->assertEquals($decoded_torrent['announce'], 'http://announce'); $this->assertContains(array('http://announce'), $decoded_torrent['announce-list']); }
/** * @expectedException PHPTracker_Bencode_Error_Parse */ public function testParseErrorUnendedContainer() { $object = new PHPTracker_Bencode_Parser('ld2:AB2:CDe'); $object->parse(); }