requestContext()->setViewer($user); $tgroup = Helper::makeTGroupMusic( name: 'phpunit torman ' . randomString(6), artistName: [[ARTIST_MAIN], ['DJ Torman ' . randomString(12)]], tagName: ['hip.hop'], user: $user, ); $this->torrentList = array_map(fn($info) => Helper::makeTorrentMusic( tgroup: $tgroup, format: $info['format'], size: $info['size'], title: $info['title'], user: $user, ), [ ['format' => 'FLAC', 'size' => 10_000_000, 'title' => 'Regular Edition'], ['format' => 'FLAC', 'size' => 15_000_000, 'title' => 'Limited Edition'], ['format' => 'FLAC', 'size' => 20_000_000, 'title' => 'Deluxe Edition'], ['format' => 'FLAC', 'size' => 25_000_000, 'title' => 'Ultra Edition'], ['format' => 'MP3', 'size' => 2_000_000, 'title' => 'Ultra Edition'], ] ); } public function tearDown(): void { Helper::removeUser($this->torrentList[0]->uploader()); } public function testTorrentFreeleechThreshold(): void { $this->assertEquals( 4, $this->torrentList[0]->group()->setFreeleech( leechType: LeechType::Free, reason: LeechReason::StaffPick, threshold: 22_000_000, user: $this->torrentList[0]->uploader(), ), 'fl-free-staffpick-22M' ); $this->assertEquals(LeechType::Free, $this->torrentList[0]->flush()->leechType(), 'torman-0-is-free'); $this->assertEquals(LeechType::Free, $this->torrentList[1]->flush()->leechType(), 'torman-1-is-free'); $this->assertEquals(LeechType::Free, $this->torrentList[2]->flush()->leechType(), 'torman-2-is-free'); $this->assertEquals(LeechType::Neutral, $this->torrentList[3]->flush()->leechType(), 'torman-3-is-neutral'); $this->assertEquals(LeechType::Normal, $this->torrentList[4]->flush()->leechType(), 'torman-4-is-normal'); $this->assertEquals( 4, $this->torrentList[0]->group()->setFreeleech( leechType: LeechType::Normal, reason: LeechReason::Normal, user: $this->torrentList[0]->uploader(), ), 'fl-normal' ); $this->assertEquals(LeechType::Normal, $this->torrentList[0]->flush()->leechType(), 'torman-0-is-now-normal'); $this->assertEquals(LeechType::Normal, $this->torrentList[1]->flush()->leechType(), 'torman-1-is-now-normal'); $this->assertEquals(LeechType::Normal, $this->torrentList[2]->flush()->leechType(), 'torman-2-is-now-normal'); $this->assertEquals(LeechType::Normal, $this->torrentList[3]->flush()->leechType(), 'torman-3-is-now-normal'); $this->assertEquals(LeechType::Normal, $this->torrentList[4]->flush()->leechType(), 'torman-4-is-now-normal'); } public function testTorrentFreeleechAllFree(): void { $this->assertEquals( 5, $this->torrentList[0]->group()->setFreeleech( all: true, leechType: LeechType::Free, reason: LeechReason::StaffPick, user: $this->torrentList[0]->uploader(), ), 'fl-free-all' ); $this->assertEquals(LeechType::Free, $this->torrentList[3]->flush()->leechType(), 'torman-3-is-free'); $this->assertEquals(LeechType::Free, $this->torrentList[4]->flush()->leechType(), 'torman-4-is-free'); } }