public function setUp() { // Mock the post request. $session = SessionFactory::init(new MockArraySessionStorage()); $this->char = TestAccountCreateAndDestroy::char(); $session->set('player_id', $this->char->id()); }
/** * Create a mock login, with real created account and character */ public function login() { SessionFactory::init(new MockArraySessionStorage()); $this->char = TestAccountCreateAndDestroy::char(); SessionFactory::getSession()->set('authenticated', true); $this->account = Account::findByChar($this->char); SessionFactory::getSession()->set('account_id', $this->account->id()); }
function setUp() { $this->char = TestAccountCreateAndDestroy::char(); $request = new Request([], []); RequestWrapper::inject($request); SessionFactory::init(new MockArraySessionStorage()); $sess = SessionFactory::getSession(); $sess->set('player_id', $this->char->id()); }
function setUp() { $this->controller = new InventoryController(); $this->char = TestAccountCreateAndDestroy::char(); $request = new Request([], []); RequestWrapper::inject($request); SessionFactory::init(new MockArraySessionStorage()); $sess = SessionFactory::getSession(); $sess->set('player_id', $this->char->id()); add_item($this->char->id(), self::ITEM); }
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); }
protected function setUp() { $this->char = TestAccountCreateAndDestroy::char(); SessionFactory::init(new MockArraySessionStorage()); }
protected function setUp() { $this->char = TestAccountCreateAndDestroy::char(); $this->data = ['title' => 'Some QuEst TiTle HeRe', 'description' => 'What I want you to do, X, Y, and Z', '_player_id' => $this->char->id(), 'tags' => 'shadow_quest,epic,ninjamaster_level', 'karma' => rand(5, 888), 'proof' => 'For proof, provide screenshots', 'difficulty' => 20]; $this->quest = new Quest($this->data); }
public function testPostEmailCanGetAnAccountUsingANinjaName() { $req = Request::create('/password/post_email/'); $req->setMethod('POST'); $char = TestAccountCreateAndDestroy::char(); $ninja_name = $char->name(); $req->request->set('ninja_name', $ninja_name); RequestWrapper::inject($req); $account = Account::findByNinjaName($ninja_name); $this->assertNotEmpty($account->id(), 'Unable to find id for newly created account.'); $controller = new PasswordController(); $controller->postEmail($this->m_dependencies); // Check for a matching request for the appropriate account. $pwrr = PasswordResetRequest::where('_account_id', '=', $account->id())->first(); $this->assertNotEmpty($pwrr, 'Fail: Unable to find a matching password reset request for account_id: [' . $this->account->id() . '].'); $this->nonce = $pwrr->nonce; }