コード例 #1
0
 function tearDown()
 {
     TestAccountCreateAndDestroy::destroy();
     RequestWrapper::inject(new Request([]));
     $session = SessionFactory::getSession();
     $session->invalidate();
 }
コード例 #2
0
 public function tearDown()
 {
     RequestWrapper::inject(new Request([]));
     TestAccountCreateAndDestroy::purge_test_accounts();
     $session = SessionFactory::getSession();
     $session->invalidate();
 }
コード例 #3
0
 public function setUp()
 {
     parent::setUp();
     SessionFactory::init(new MockArraySessionStorage());
     $char_id = TestAccountCreateAndDestroy::create_testing_account();
     SessionFactory::getSession()->set('player_id', $char_id);
 }
コード例 #4
0
ファイル: QuestTest.php プロジェクト: BitLucid/ninjawars
 protected function tearDown()
 {
     TestAccountCreateAndDestroy::destroy();
     if ($this->quest) {
         query('delete from quests where quest_id = :id and quest_id > 1', [':id' => $this->quest->id()]);
     }
 }
コード例 #5
0
ファイル: MessageTest.php プロジェクト: BitLucid/ninjawars
 function tearDown()
 {
     TestAccountCreateAndDestroy::destroy();
     if ($this->message_id !== null) {
         query('delete from messages where message_id = :id', [':id' => $this->message_id]);
     }
 }
コード例 #6
0
ファイル: player_test.php プロジェクト: reillo/ninjawars
 /**
  * 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.
 }
コード例 #7
0
 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);
 }
コード例 #8
0
 function tearDown()
 {
     removeItem($this->char->id(), self::ITEM);
     TestAccountCreateAndDestroy::destroy();
     RequestWrapper::inject(new Request([]));
     $session = SessionFactory::getSession();
     $session->invalidate();
 }
コード例 #9
0
 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);
 }
コード例 #10
0
 public function tearDown()
 {
     $this->inventory->remove(self::ITEM);
     TestAccountCreateAndDestroy::destroy();
     RequestWrapper::inject(new Request([]));
     $session = SessionFactory::getSession();
     $session->invalidate();
     parent::tearDown();
 }
コード例 #11
0
 /**
  */
 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);
 }
コード例 #12
0
ファイル: combat_test.php プロジェクト: reillo/ninjawars
 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));
 }
コード例 #13
0
 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);
 }
コード例 #14
0
 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);
 }
コード例 #15
0
 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);
 }
コード例 #16
0
 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.');
 }
コード例 #17
0
 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);
 }
コード例 #18
0
 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']);
 }
コード例 #19
0
 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);
 }
コード例 #20
0
 public static function account_id()
 {
     return TestAccountCreateAndDestroy::create_complete_test_account_and_return_id();
 }
コード例 #21
0
 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');
 }
コード例 #22
0
 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);
 }
コード例 #23
0
ファイル: SkillTest.php プロジェクト: NinjaWars/ninjawars
 public function tearDown()
 {
     // Delete test users created in body of test functions
     TestAccountCreateAndDestroy::purge_test_accounts();
 }
コード例 #24
0
ファイル: CloneKillTest.php プロジェクト: BitLucid/ninjawars
 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);
 }
コード例 #25
0
ファイル: ClanTest.php プロジェクト: NinjaWars/ninjawars
 function tearDown()
 {
     $this->deleteClan($this->clan_id);
     $this->deleteClanByIdentity('someTestClan');
     TestAccountCreateAndDestroy::purge_test_accounts();
 }
コード例 #26
0
ファイル: MessageTest.php プロジェクト: reillo/ninjawars
 function tearDown()
 {
     TestAccountCreateAndDestroy::destroy();
     $this->message->delete();
 }
コード例 #27
0
 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.
 }
コード例 #28
0
ファイル: accountconf_test.php プロジェクト: reillo/ninjawars
 /**
  * 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']);
 }
コード例 #29
0
ファイル: account_test.php プロジェクト: reillo/ninjawars
 public function tearDown()
 {
     TestAccountCreateAndDestroy::purge_test_accounts();
 }
コード例 #30
0
ファイル: ClanTest.php プロジェクト: BitLucid/ninjawars
 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();
 }