function setUp() { $this->char_id = TestAccountCreateAndDestroy::char_id(true); $this->char_id_2 = TestAccountCreateAndDestroy::char_id_2(true); $this->messageData = ['message' => 'Random phpunit Test Message', 'send_from' => $this->char_id, 'send_to' => $this->char_id_2, 'unread' => 1, 'type' => 0]; $this->message_id = null; }
function setUp() { $this->char_id = TestAccountCreateAndDestroy::char_id($confirm = true); $this->char_id_2 = TestAccountCreateAndDestroy::char_id_2($confirm = true); $this->message = Message::create(['message' => 'Random phpunit Test Message', 'send_to' => $this->char_id, 'send_from' => $this->char_id_2, 'unread' => 1, 'type' => null]); $this->delete_this_message = null; }
function setUp() { $this->char_id = TestAccountCreateAndDestroy::char_id(); $this->char_id_2 = TestAccountCreateAndDestroy::char_id_2(); $this->clan = Clan::create(Player::find($this->char_id_2), $this->clan_identity); $this->clan_id = $this->clan->id; }
public function testViewOtherPlayerProfile() { $viewing_char_id = TestAccountCreateAndDestroy::char_id_2(); $request = new Request(['player_id' => $viewing_char_id]); RequestWrapper::inject($request); $sess = SessionFactory::getSession(); $sess->set('player_id', $this->char->id()); $player = new PlayerController(); $player_outcome = $player->index(); $this->assertNotEmpty($player_outcome); }
function setUp() { $clan_identity = 'randomNewTestClan'; $id_already_exists = query_item('select clan_id from clan where clan_name = :name', [':name' => $clan_identity]); if ($id_already_exists) { $this->deleteClan($id_already_exists); } $this->clan = ClanFactory::create($clan_identity, ['founder' => 'phpunittest', 'description' => 'Some clan description']); $this->clan_id = $this->clan->getId(); $this->char_id = TestAccountCreateAndDestroy::char_id(); $this->char_id_2 = TestAccountCreateAndDestroy::char_id_2(); }
public function testAttackWhenDead() { $attacker = Player::find(SessionFactory::getSession()->get('player_id')); $attacker->death(); $attacker->save(); $char_id_2 = TestAccountCreateAndDestroy::char_id_2(); $params = ['target' => $char_id_2]; $request = Request::create('/attack', 'GET', $params); RequestWrapper::inject($request); $response = $this->controller->index($this->m_dependencies); $this->assertInstanceOf(StreamedViewResponse::class, $response); $reflection = new \ReflectionProperty(get_class($response), 'data'); $reflection->setAccessible(true); $response_data = $reflection->getValue($response); $this->assertNotEmpty($response_data['error']); }
public function testBribeDownABounty() { $char_id = $this->char->id(); $target_id = TestAccountCreateAndDestroy::char_id_2(); $this->char->setGold(434343); $this->char->save(); $this->char->setBounty(400); $this->char->save(); $this->char = Player::find($char_id); $this->assertEquals(400, $this->char->bounty); $request = new Request(['bribe' => 300]); RequestWrapper::inject($request); $doshin = new DoshinController(); $doshin->bribe($this->m_dependencies); $pulled_char = Player::find($char_id); $current_bounty = $pulled_char->bounty; // Bounty should be less now $this->assertLessThan(400, $current_bounty); $this->assertGreaterThan(0, $current_bounty); }
public function testCloneKillKillingWipesHealthAndTurns() { $char_id = TestAccountCreateAndDestroy::char_id(); $charObj = Player::find($char_id); $char_id_2 = TestAccountCreateAndDestroy::char_id_2(); $charObj_2 = Player::find($char_id_2); // Will create characters with 127.0.0.1 ip, but that shouldn't be clone kill able. $this->assertFalse(CloneKill::canKill($char_id, $char_id_2)); $this->syncIps('555.66.77.88', $char_id, $char_id_2); $this->assertTrue(CloneKill::canKill($char_id, $char_id_2), 'Should be able to clone kill similar and same ip characters!'); CloneKill::kill($charObj, $charObj, $charObj_2); // Obliterate them. $pc1 = Player::find($char_id); $pc2 = Player::find($char_id_2); $this->assertEquals(0, $pc1->health); $this->assertEquals(0, $pc2->health); $this->assertEquals(0, $pc1->turns); $this->assertEquals(0, $pc2->turns); }
public function testKickAsMember() { $this->setExpectedException(\RuntimeException::class); $char_id_1 = $this->m_dependencies['session']->get('player_id'); // create new character $char_id_2 = TestAccountCreateAndDestroy::char_id_2(); // add new character to clan $this->clan->addMember(Player::find($char_id_2), Player::find($char_id_1)); // switch session to new character $this->m_dependencies['session']->set('player_id', $char_id_2); // try to kick $request = Request::create('/clan/kick', 'GET', ['kicked' => $char_id_1]); RequestWrapper::inject($request); $response = $this->controller->kick($this->m_dependencies); }