function tearDown() { TestAccountCreateAndDestroy::destroy(); RequestWrapper::inject(new Request([])); $session = SessionFactory::getSession(); $session->invalidate(); }
public function tearDown() { RequestWrapper::inject(new Request([])); TestAccountCreateAndDestroy::purge_test_accounts(); $session = SessionFactory::getSession(); $session->invalidate(); }
public function setUp() { parent::setUp(); SessionFactory::init(new MockArraySessionStorage()); $char_id = TestAccountCreateAndDestroy::create_testing_account(); SessionFactory::getSession()->set('player_id', $char_id); }
protected function tearDown() { TestAccountCreateAndDestroy::destroy(); if ($this->quest) { query('delete from quests where quest_id = :id and quest_id > 1', [':id' => $this->quest->id()]); } }
function tearDown() { TestAccountCreateAndDestroy::destroy(); if ($this->message_id !== null) { query('delete from messages where message_id = :id', [':id' => $this->message_id]); } }
/** * group char **/ function tearDown() { // Delete test user. TestAccountCreateAndDestroy::purge_test_accounts($this->test_ninja_name); $_SERVER['REMOTE_ADDR'] = $this->previous_server_ip; // Reset remote addr to whatever it was before, just in case. }
protected function setUp() { $this->markTestIncomplete('Casino index relies on DB to get player'); SessionFactory::init(new MockArraySessionStorage()); $char_id = TestAccountCreateAndDestroy::create_testing_account(); SessionFactory::getSession()->set('player_id', $char_id); }
function tearDown() { removeItem($this->char->id(), self::ITEM); TestAccountCreateAndDestroy::destroy(); RequestWrapper::inject(new Request([])); $session = SessionFactory::getSession(); $session->invalidate(); }
public function setUp() { parent::setUp(); SessionFactory::init(new MockArraySessionStorage()); $char_id = TestAccountCreateAndDestroy::create_testing_account(); SessionFactory::getSession()->set('player_id', $char_id); $request = new Request([], []); RequestWrapper::inject($request); }
public function tearDown() { $this->inventory->remove(self::ITEM); TestAccountCreateAndDestroy::destroy(); RequestWrapper::inject(new Request([])); $session = SessionFactory::getSession(); $session->invalidate(); parent::tearDown(); }
/** */ protected function setUp() { // Mock the post request. $request = new Request([], []); RequestWrapper::inject($request); $this->char_id = TestAccountCreateAndDestroy::create_testing_account(); $session = SessionFactory::init(new MockArraySessionStorage()); $session->set('player_id', $this->char_id); $session->set('account_id', $this->char_id); }
public function testCantAttackIfExcessiveAmountOfTurnsIsRequired() { $confirm = true; $char_id = TestAccountCreateAndDestroy::create_testing_account($confirm); $this->oldify_character_last_attack($char_id); $char_2_id = TestAccountCreateAndDestroy::create_alternate_testing_account($confirm); $this->oldify_character_last_attack($char_2_id); $char = new Player($char_2_id); $legal = new AttackLegal($char_id, $char->name(), ['required_turns' => 4000000000.0, 'ignores_stealth' => true]); $this->assertFalse($legal->check($update_timer = false)); }
public function setUp() { SessionFactory::init(new MockArraySessionStorage()); $char_id = TestAccountCreateAndDestroy::char_id(); $char = Player::find($char_id); $account = Account::findByChar($char); $account_id = $account->id(); SessionFactory::getSession()->set('authenticated', true); SessionFactory::getSession()->set('player_id', $char_id); SessionFactory::getSession()->set('account_id', $account_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); }
public function testWorkDoesNothingWithNegativeWorkRequest() { // Note that this had to have an active logged in character to not just get an ignored result of "0" gold. $this->char = TestAccountCreateAndDestroy::char(); SessionFactory::getSession()->set('player_id', $this->char->id()); $request = new Request([], ['worked' => -999]); RequestWrapper::inject($request); $work = new WorkController(); $work_response = $work->requestWork(); $earned_gold = $work_response['parts']['earned_gold']; $this->assertEquals("0", $earned_gold); }
public function testPostEmailCanGetAnAccountUsingANinjaName() { $req = Request::create('/resetpassword.php'); $req->setMethod('POST'); $char = TestAccountCreateAndDestroy::char(); $ninja_name = $char->name(); $req->query->set('ninja_name', $ninja_name); $account = AccountFactory::findByNinjaName($ninja_name); $controller = new PasswordController(); $controller->postEmail($req); // Check for a matching request for the appropriate account. $req = PasswordResetRequest::where('_account_id', '=', $account->id())->first(); $this->assertNotEmpty($req, 'Fail: Unable to find a matching password reset request.'); }
public function testWorkDoesNothingWithNegativeWorkRequest() { // Note that this had to have an active logged in character to not just get an ignored result of "0" gold. $this->char = TestAccountCreateAndDestroy::char(); SessionFactory::getSession()->set('player_id', $this->char->id()); $request = new Request([], ['worked' => -999]); RequestWrapper::inject($request); $work = new WorkController(); $response = $work->requestWork($this->m_dependencies); $reflection = new \ReflectionProperty(get_class($response), 'data'); $reflection->setAccessible(true); $response_data = $reflection->getValue($response); $earned_gold = $response_data['earned_gold']; $this->assertEquals("0", $earned_gold); }
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 static function account_id() { return TestAccountCreateAndDestroy::create_complete_test_account_and_return_id(); }
function testAttemptLoginOfUnconfirmedAccountShouldFail() { $email = '*****@*****.**'; // Create a non-autoconfirmed user TestAccountCreateAndDestroy::create_testing_account(false, $email); RequestWrapper::inject(new Request([])); $controller = new LoginController(); $res = $controller->performLogin($email, $this->test_password); $this->assertNotEmpty($res, 'No error returned'); }
public function testLoginShouldFailOnBlanks() { $account = Account::findById(TestAccountCreateAndDestroy::account_id()); $this->assertInstanceOf(Account::class, $account); $account->confirmed = 0; $account->save(); $request = new Request([], ['user' => '', 'pass' => '']); // TestAccountCreateAndDestroy::$test_password RequestWrapper::inject($request); $controller = new LoginController(); $res = $controller->requestLogin($this->m_dependencies); $this->assertInstanceOf(RedirectResponse::class, $res); $this->assertTrue(stripos($res->getTargetUrl(), 'error') !== false); }
public function tearDown() { // Delete test users created in body of test functions TestAccountCreateAndDestroy::purge_test_accounts(); }
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); }
function tearDown() { $this->deleteClan($this->clan_id); $this->deleteClanByIdentity('someTestClan'); TestAccountCreateAndDestroy::purge_test_accounts(); }
function tearDown() { TestAccountCreateAndDestroy::destroy(); $this->message->delete(); }
public function testPerformingAResetInvalidatesUsedRequest() { $account_id = TestAccountCreateAndDestroy::account_id(); $account = AccountFactory::findById($account_id); PasswordResetRequest::generate($account, $this->nonce = '77warkwark', false); PasswordResetRequest::reset($account, 'new_pass34532'); $req = PasswordResetRequest::match($this->nonce); $this->assertEmpty($req); // Request shouldn't match because it should already be used. }
/** * group accountconf **/ function testAttemptLoginOfUnconfirmedAccountShouldFail() { $email = '*****@*****.**'; // Create a non-autoconfirmed user $char_id = TestAccountCreateAndDestroy::create_testing_account($confirm = false, $email); $res = @login_user($email, $this->test_password); $this->assertFalse($res['success']); $this->assertTrue(is_string($res['login_error'])); $this->assertTrue((bool) $res['login_error'], 'No error returned: ' . $res['login_error']); }
public function tearDown() { TestAccountCreateAndDestroy::purge_test_accounts(); }
function tearDown() { query('delete from clan where clan_id = :id', [':id' => $this->clan->id]); query('delete from clan_player where _clan_id = :id', [':id' => $this->clan->id]); TestAccountCreateAndDestroy::purge_test_accounts(); }