We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -1,10 +1,10 @@ |
||
1 | -<?php if(isset($Preview)) { ?><table class="standard"><tr><td><?php echo bbifyMessage($Preview); ?></td></tr></table><?php } ?> |
|
1 | +<?php if (isset($Preview)) { ?><table class="standard"><tr><td><?php echo bbifyMessage($Preview); ?></td></tr></table><?php } ?> |
|
2 | 2 | <form name="MessageSendForm" method="POST" action="<?php echo $MessageSendFormHref; ?>"> |
3 | 3 | <p> |
4 | 4 | <b>From: </b><?php echo $ThisPlayer->getDisplayName(); ?><br /> |
5 | - <b>To: </b><?php if(isset($Receiver) && is_object($Receiver)) { echo $Receiver->getDisplayName(); } else { echo $Receiver; } ?> |
|
5 | + <b>To: </b><?php if (isset($Receiver) && is_object($Receiver)) { echo $Receiver->getDisplayName(); } else { echo $Receiver; } ?> |
|
6 | 6 | </p> |
7 | - <textarea spellcheck="true" name="message" required><?php if(isset($Preview)) { echo $Preview; } ?></textarea><br /> |
|
7 | + <textarea spellcheck="true" name="message" required><?php if (isset($Preview)) { echo $Preview; } ?></textarea><br /> |
|
8 | 8 | <br /> |
9 | 9 | <input type="submit" name="action" value="Send message" /> <input type="submit" name="action" value="Preview message" /> |
10 | 10 | </form> |
@@ -44,7 +44,10 @@ |
||
44 | 44 | <td> |
45 | 45 | <select name="game_type"><?php |
46 | 46 | foreach (SmrGame::GAME_TYPES as $GameTypeID => $GameType) { |
47 | - ?><option value="<?php echo $GameTypeID; ?>" <?php if ($GameType == $Game['gameType']) echo 'selected'; ?>><?php echo $GameType; ?></option><?php |
|
47 | + ?><option value="<?php echo $GameTypeID; ?>" <?php if ($GameType == $Game['gameType']) { |
|
48 | + echo 'selected'; |
|
49 | + } |
|
50 | + ?>><?php echo $GameType; ?></option><?php |
|
48 | 51 | } ?> |
49 | 52 | </select> |
50 | 53 | </td> |
@@ -337,8 +337,8 @@ |
||
337 | 337 | foreach (Globals::getAvailableTemplates() as $Template) { |
338 | 338 | foreach (Globals::getAvailableColourSchemes($Template) as $ColourScheme) { |
339 | 339 | $selected = ($ThisAccount->getTemplate() == $Template && |
340 | - $ThisAccount->getColourScheme() == $ColourScheme && |
|
341 | - $ThisAccount->isDefaultCSSEnabled()) ? 'selected' : ''; |
|
340 | + $ThisAccount->getColourScheme() == $ColourScheme && |
|
341 | + $ThisAccount->isDefaultCSSEnabled()) ? 'selected' : ''; |
|
342 | 342 | $name = $Template . ' - ' . $ColourScheme; |
343 | 343 | ?><option value="<?php echo $name; ?>" <?php echo $selected; ?>><?php echo $name; ?></option><?php |
344 | 344 | } |
@@ -150,7 +150,7 @@ |
||
150 | 150 | $account->increaseSmrRewardCredits(2 * CREDITS_PER_DOLLAR); // Give $2 worth of "reward" credits for joining. |
151 | 151 | if ($socialLogin) { |
152 | 152 | $account->addAuthMethod($_SESSION['socialLogin']->getLoginType(), |
153 | - $_SESSION['socialLogin']->getUserID()); |
|
153 | + $_SESSION['socialLogin']->getUserID()); |
|
154 | 154 | if ($validatedBySocial) { |
155 | 155 | $account->setValidated(true); |
156 | 156 | $account->update(); |
@@ -96,7 +96,7 @@ |
||
96 | 96 | //heres the AIs cards |
97 | 97 | $i = 1; |
98 | 98 | if ($dealerHand->hasBlackjack() || |
99 | - ($playerHand->getValue() > 21 && $dealerHand->getValue() <= 21)) { |
|
99 | + ($playerHand->getValue() > 21 && $dealerHand->getValue() <= 21)) { |
|
100 | 100 | $message .= ('<h1 class="red center">Bank Wins</h1>'); |
101 | 101 | } |
102 | 102 | $message .= ('<div class="center">Bank\'s Cards are</div><br /><table class="center"><tr>'); |
@@ -44,8 +44,8 @@ |
||
44 | 44 | */ |
45 | 45 | public function getValue() : int { |
46 | 46 | if ($this->rank == self::RANK_JACK || |
47 | - $this->rank == self::RANK_QUEEN || |
|
48 | - $this->rank == self::RANK_KING) { |
|
47 | + $this->rank == self::RANK_QUEEN || |
|
48 | + $this->rank == self::RANK_KING) { |
|
49 | 49 | return 10; |
50 | 50 | } elseif ($this->isAce()) { |
51 | 51 | return 11; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | foreach (\Globals::getGoods() as $goodId => $value) { |
94 | 94 | if ($goods[$goodId] === true) { |
95 | 95 | if ($sectors[$currentSectorId]->getPort()->getGoodTransaction($goodId) === self::GOOD_SELLS && |
96 | - $sectors[$targetSectorId]->getPort()->getGoodTransaction($goodId) === self::GOOD_BUYS) { |
|
96 | + $sectors[$targetSectorId]->getPort()->getGoodTransaction($goodId) === self::GOOD_BUYS) { |
|
97 | 97 | $rl[] = new OneWayRoute($currentSectorId, $targetSectorId, $raceID, $sectors[$targetSectorId]->getPort()->getRaceID(), $sectors[$currentSectorId]->getPort()->getGoodDistance($goodId), $sectors[$targetSectorId]->getPort()->getGoodDistance($goodId), $distance, $goodId); |
98 | 98 | } |
99 | 99 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | foreach (\Globals::getGoods() as $goodId => $value) { |
122 | 122 | if ($goods[$goodId] === true) { |
123 | 123 | if ($sectors[$currentSectorId]->getPort()->getGoodTransaction($goodId) === self::GOOD_SELLS && |
124 | - $sectors[$targetSectorId]->getPort()->getGoodTransaction($goodId) === self::GOOD_BUYS) { |
|
124 | + $sectors[$targetSectorId]->getPort()->getGoodTransaction($goodId) === self::GOOD_BUYS) { |
|
125 | 125 | $owr = new OneWayRoute($currentSectorId, $targetSectorId, $sectors[$currentSectorId]->getPort()->getRaceID(), $sectors[$targetSectorId]->getPort()->getRaceID(), $sectors[$currentSectorId]->getPort()->getGoodDistance($goodId), $sectors[$targetSectorId]->getPort()->getGoodDistance($goodId), $distance, $goodId); |
126 | 126 | $fakeReturn = new OneWayRoute($targetSectorId, $currentSectorId, $sectors[$targetSectorId]->getPort()->getRaceID(), $sectors[$currentSectorId]->getPort()->getRaceID(), 0, 0, $distance, GOODS_NOTHING); |
127 | 127 | $mpr = new MultiplePortRoute($owr, $fakeReturn); |
@@ -3,10 +3,10 @@ |
||
3 | 3 | // Holds information linking the received message and the game data |
4 | 4 | class GameLink |
5 | 5 | { |
6 | - public $valid = false; // identifies if the message is linked to game data |
|
7 | - public $account; // SmrAccount instance |
|
8 | - public $alliance; // SmrAlliance instance |
|
9 | - public $player; // SmrPlayer instance |
|
6 | + public $valid = false; // identifies if the message is linked to game data |
|
7 | + public $account; // SmrAccount instance |
|
8 | + public $alliance; // SmrAlliance instance |
|
9 | + public $player; // SmrPlayer instance |
|
10 | 10 | |
11 | 11 | // $author can be either Discord\Parts\User\{User,Member} |
12 | 12 | function __construct(Discord\Parts\Channel\Channel $channel, $author) { |
@@ -6,30 +6,30 @@ discard block |
||
6 | 6 | |
7 | 7 | class Record |
8 | 8 | { |
9 | - public int $account_id = 1; |
|
10 | - public string $login = "login"; |
|
11 | - public string $password = "password"; |
|
12 | - public string $email = "email"; |
|
13 | - public string $last_login = "last login"; |
|
14 | - public string $validation_code = "validation code"; |
|
15 | - public string $offset = "offset"; |
|
16 | - public string $images = "Yes"; |
|
17 | - public string $fontsize = "font size"; |
|
18 | - public string $password_reset = "password reset"; |
|
19 | - public int $mail_banned = 0; |
|
20 | - public string $friendly_colour = "colour"; |
|
21 | - public string $neutral_colour = "colour"; |
|
22 | - public string $enemy_colour = "colour"; |
|
23 | - public string $css_link = "css link"; |
|
24 | - public string $referral_id = 'referral_id'; |
|
25 | - public string $max_rank_achieved = 'max_rank_achieved'; |
|
26 | - public string $hof_name = 'hof_name'; |
|
27 | - public string $discord_id = 'discord_id'; |
|
28 | - public string $irc_nick = 'irc_nick'; |
|
29 | - public string $date_short = 'date_short'; |
|
30 | - public string $time_short = 'time_short'; |
|
31 | - public string $template = 'template'; |
|
32 | - public string $colour_scheme = 'colour_scheme'; |
|
9 | + public int $account_id = 1; |
|
10 | + public string $login = "login"; |
|
11 | + public string $password = "password"; |
|
12 | + public string $email = "email"; |
|
13 | + public string $last_login = "last login"; |
|
14 | + public string $validation_code = "validation code"; |
|
15 | + public string $offset = "offset"; |
|
16 | + public string $images = "Yes"; |
|
17 | + public string $fontsize = "font size"; |
|
18 | + public string $password_reset = "password reset"; |
|
19 | + public int $mail_banned = 0; |
|
20 | + public string $friendly_colour = "colour"; |
|
21 | + public string $neutral_colour = "colour"; |
|
22 | + public string $enemy_colour = "colour"; |
|
23 | + public string $css_link = "css link"; |
|
24 | + public string $referral_id = 'referral_id'; |
|
25 | + public string $max_rank_achieved = 'max_rank_achieved'; |
|
26 | + public string $hof_name = 'hof_name'; |
|
27 | + public string $discord_id = 'discord_id'; |
|
28 | + public string $irc_nick = 'irc_nick'; |
|
29 | + public string $date_short = 'date_short'; |
|
30 | + public string $time_short = 'time_short'; |
|
31 | + public string $template = 'template'; |
|
32 | + public string $colour_scheme = 'colour_scheme'; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
@@ -40,287 +40,287 @@ discard block |
||
40 | 40 | */ |
41 | 41 | class AbstractSmrAccountTest extends TestCase |
42 | 42 | { |
43 | - private AbstractSmrAccount $abstractSmrAccount; |
|
43 | + private AbstractSmrAccount $abstractSmrAccount; |
|
44 | 44 | |
45 | - public function test_get_account_by_account_id() |
|
46 | - { |
|
47 | - //# Given the database has been set up with a user |
|
48 | - $record = new Record(); |
|
49 | - self::setupMockMysqlDatabase($record); |
|
50 | - //# And there is no force update |
|
51 | - $forceUpdate = false; |
|
52 | - //# When the account is retrieved by its ID |
|
53 | - $this->abstractSmrAccount = AbstractSmrAccount::getAccount($record->account_id, $forceUpdate); |
|
54 | - //# Then the integrity of the user is correct |
|
55 | - $this->assertEquals($record->account_id, $this->abstractSmrAccount->getAccountID()); |
|
56 | - $this->assertEquals($record->login, $this->abstractSmrAccount->getLogin()); |
|
57 | - $this->assertEquals($record->email, $this->abstractSmrAccount->getEmail()); |
|
58 | - $this->assertEquals($record->last_login, $this->abstractSmrAccount->getLastLogin()); |
|
59 | - $this->assertEquals($record->validation_code, $this->abstractSmrAccount->getValidationCode()); |
|
60 | - $this->assertEquals($record->offset, $this->abstractSmrAccount->getOffset()); |
|
61 | - $this->assertEquals(true, $this->abstractSmrAccount->isDisplayShipImages()); |
|
62 | - $this->assertEquals($record->fontsize, $this->abstractSmrAccount->getFontSize()); |
|
63 | - $this->assertEquals($record->password_reset, $this->abstractSmrAccount->getPasswordReset()); |
|
64 | - $this->assertEquals($record->mail_banned, $this->abstractSmrAccount->getMailBanned()); |
|
65 | - $this->assertEquals($record->friendly_colour, $this->abstractSmrAccount->getFriendlyColour()); |
|
66 | - $this->assertEquals($record->neutral_colour, $this->abstractSmrAccount->getNeutralColour()); |
|
67 | - $this->assertEquals($record->enemy_colour, $this->abstractSmrAccount->getEnemyColour()); |
|
68 | - $this->assertEquals($record->css_link, $this->abstractSmrAccount->getCssLink()); |
|
69 | - $this->assertEquals($record->referral_id, $this->abstractSmrAccount->getReferrerID()); |
|
70 | - $this->assertEquals($record->hof_name, $this->abstractSmrAccount->getHofName()); |
|
71 | - $this->assertEquals($record->discord_id, $this->abstractSmrAccount->getDiscordId()); |
|
72 | - $this->assertEquals($record->irc_nick, $this->abstractSmrAccount->getIrcNick()); |
|
73 | - $this->assertEquals($record->date_short, $this->abstractSmrAccount->getShortDateFormat()); |
|
74 | - $this->assertEquals($record->time_short, $this->abstractSmrAccount->getShortTimeFormat()); |
|
75 | - $this->assertEquals($record->template, $this->abstractSmrAccount->getTemplate()); |
|
76 | - } |
|
45 | + public function test_get_account_by_account_id() |
|
46 | + { |
|
47 | + //# Given the database has been set up with a user |
|
48 | + $record = new Record(); |
|
49 | + self::setupMockMysqlDatabase($record); |
|
50 | + //# And there is no force update |
|
51 | + $forceUpdate = false; |
|
52 | + //# When the account is retrieved by its ID |
|
53 | + $this->abstractSmrAccount = AbstractSmrAccount::getAccount($record->account_id, $forceUpdate); |
|
54 | + //# Then the integrity of the user is correct |
|
55 | + $this->assertEquals($record->account_id, $this->abstractSmrAccount->getAccountID()); |
|
56 | + $this->assertEquals($record->login, $this->abstractSmrAccount->getLogin()); |
|
57 | + $this->assertEquals($record->email, $this->abstractSmrAccount->getEmail()); |
|
58 | + $this->assertEquals($record->last_login, $this->abstractSmrAccount->getLastLogin()); |
|
59 | + $this->assertEquals($record->validation_code, $this->abstractSmrAccount->getValidationCode()); |
|
60 | + $this->assertEquals($record->offset, $this->abstractSmrAccount->getOffset()); |
|
61 | + $this->assertEquals(true, $this->abstractSmrAccount->isDisplayShipImages()); |
|
62 | + $this->assertEquals($record->fontsize, $this->abstractSmrAccount->getFontSize()); |
|
63 | + $this->assertEquals($record->password_reset, $this->abstractSmrAccount->getPasswordReset()); |
|
64 | + $this->assertEquals($record->mail_banned, $this->abstractSmrAccount->getMailBanned()); |
|
65 | + $this->assertEquals($record->friendly_colour, $this->abstractSmrAccount->getFriendlyColour()); |
|
66 | + $this->assertEquals($record->neutral_colour, $this->abstractSmrAccount->getNeutralColour()); |
|
67 | + $this->assertEquals($record->enemy_colour, $this->abstractSmrAccount->getEnemyColour()); |
|
68 | + $this->assertEquals($record->css_link, $this->abstractSmrAccount->getCssLink()); |
|
69 | + $this->assertEquals($record->referral_id, $this->abstractSmrAccount->getReferrerID()); |
|
70 | + $this->assertEquals($record->hof_name, $this->abstractSmrAccount->getHofName()); |
|
71 | + $this->assertEquals($record->discord_id, $this->abstractSmrAccount->getDiscordId()); |
|
72 | + $this->assertEquals($record->irc_nick, $this->abstractSmrAccount->getIrcNick()); |
|
73 | + $this->assertEquals($record->date_short, $this->abstractSmrAccount->getShortDateFormat()); |
|
74 | + $this->assertEquals($record->time_short, $this->abstractSmrAccount->getShortTimeFormat()); |
|
75 | + $this->assertEquals($record->template, $this->abstractSmrAccount->getTemplate()); |
|
76 | + } |
|
77 | 77 | |
78 | - public function test_get_account_by_account_id_no_account_found_throws_exception() |
|
79 | - { |
|
80 | - $this->expectException(AccountNotFoundException::class); |
|
81 | - //# Given there is no account record |
|
82 | - $mysqlDatabase = m::mock("overload:" . SmrMySqlDatabase::class)->shouldIgnoreMissing(); |
|
83 | - $mysqlDatabase |
|
84 | - ->shouldReceive("nextRecord") |
|
85 | - ->andReturnNull(); |
|
86 | - //# When performing an account lookup by id |
|
87 | - AbstractSmrAccount::getAccount("bad account id"); |
|
88 | - } |
|
78 | + public function test_get_account_by_account_id_no_account_found_throws_exception() |
|
79 | + { |
|
80 | + $this->expectException(AccountNotFoundException::class); |
|
81 | + //# Given there is no account record |
|
82 | + $mysqlDatabase = m::mock("overload:" . SmrMySqlDatabase::class)->shouldIgnoreMissing(); |
|
83 | + $mysqlDatabase |
|
84 | + ->shouldReceive("nextRecord") |
|
85 | + ->andReturnNull(); |
|
86 | + //# When performing an account lookup by id |
|
87 | + AbstractSmrAccount::getAccount("bad account id"); |
|
88 | + } |
|
89 | 89 | |
90 | - public function test_get_account_by_account_id_force_update_from_database() |
|
91 | - { |
|
92 | - //# Given the database has been set up with a user |
|
93 | - $record = new Record(); |
|
94 | - self::setupMockMysqlDatabase($record); |
|
95 | - //# And the force update flag is true |
|
96 | - $forceUpdate = true; |
|
97 | - //# And the account has been retrieved once |
|
98 | - AbstractSmrAccount::getAccount($record->account_id, $forceUpdate); |
|
99 | - //# When retrieving the account a second time |
|
100 | - AbstractSmrAccount::getAccount($record->account_id, $forceUpdate); |
|
101 | - //# Then verify multiple interactions with the database |
|
102 | - //# There are a total of three mocks in the container: |
|
103 | - //# One constructed here in this test, and one for each time getAccount was called. |
|
104 | - $this->assertCount(3, m::getContainer()->getMocks()); |
|
105 | - } |
|
90 | + public function test_get_account_by_account_id_force_update_from_database() |
|
91 | + { |
|
92 | + //# Given the database has been set up with a user |
|
93 | + $record = new Record(); |
|
94 | + self::setupMockMysqlDatabase($record); |
|
95 | + //# And the force update flag is true |
|
96 | + $forceUpdate = true; |
|
97 | + //# And the account has been retrieved once |
|
98 | + AbstractSmrAccount::getAccount($record->account_id, $forceUpdate); |
|
99 | + //# When retrieving the account a second time |
|
100 | + AbstractSmrAccount::getAccount($record->account_id, $forceUpdate); |
|
101 | + //# Then verify multiple interactions with the database |
|
102 | + //# There are a total of three mocks in the container: |
|
103 | + //# One constructed here in this test, and one for each time getAccount was called. |
|
104 | + $this->assertCount(3, m::getContainer()->getMocks()); |
|
105 | + } |
|
106 | 106 | |
107 | - public function test_get_account_by_id_multiple_times_without_force_refresh_calls_database_once() |
|
108 | - { |
|
109 | - //# Given the database has been set up with a user |
|
110 | - $record = new Record(); |
|
111 | - self::setupMockMysqlDatabase($record); |
|
112 | - //# And the force update flag is true |
|
113 | - $forceUpdate = false; |
|
114 | - //# And the account has been retrieved once |
|
115 | - AbstractSmrAccount::getAccount($record->account_id, $forceUpdate); |
|
116 | - //# When retrieving the account a second time |
|
117 | - AbstractSmrAccount::getAccount($record->account_id, $forceUpdate); |
|
118 | - //# Then verify multiple interactions with the database |
|
119 | - //# There are a total of two mocks in the container: |
|
120 | - //# One constructed here in this test, and one for the only time a database connection was spawned. |
|
121 | - $this->assertCount(2, m::getContainer()->getMocks()); |
|
122 | - } |
|
107 | + public function test_get_account_by_id_multiple_times_without_force_refresh_calls_database_once() |
|
108 | + { |
|
109 | + //# Given the database has been set up with a user |
|
110 | + $record = new Record(); |
|
111 | + self::setupMockMysqlDatabase($record); |
|
112 | + //# And the force update flag is true |
|
113 | + $forceUpdate = false; |
|
114 | + //# And the account has been retrieved once |
|
115 | + AbstractSmrAccount::getAccount($record->account_id, $forceUpdate); |
|
116 | + //# When retrieving the account a second time |
|
117 | + AbstractSmrAccount::getAccount($record->account_id, $forceUpdate); |
|
118 | + //# Then verify multiple interactions with the database |
|
119 | + //# There are a total of two mocks in the container: |
|
120 | + //# One constructed here in this test, and one for the only time a database connection was spawned. |
|
121 | + $this->assertCount(2, m::getContainer()->getMocks()); |
|
122 | + } |
|
123 | 123 | |
124 | - public function test_get_account_by_name_happy_path() |
|
125 | - { |
|
126 | - //# Given a record exists |
|
127 | - $record = new Record(); |
|
128 | - self::setupMockMysqlDatabase($record); |
|
129 | - //# When retrieving account by name |
|
130 | - $account = AbstractSmrAccount::getAccountByName($record->login); |
|
131 | - //# Then the record is found |
|
132 | - $this->assertEquals($record->account_id, $account->getAccountID()); |
|
133 | - } |
|
124 | + public function test_get_account_by_name_happy_path() |
|
125 | + { |
|
126 | + //# Given a record exists |
|
127 | + $record = new Record(); |
|
128 | + self::setupMockMysqlDatabase($record); |
|
129 | + //# When retrieving account by name |
|
130 | + $account = AbstractSmrAccount::getAccountByName($record->login); |
|
131 | + //# Then the record is found |
|
132 | + $this->assertEquals($record->account_id, $account->getAccountID()); |
|
133 | + } |
|
134 | 134 | |
135 | - public function test_get_account_by_name_returns_null_when_no_account_name_provided() |
|
136 | - { |
|
137 | - //# Given a record exists |
|
138 | - $record = new Record(); |
|
139 | - self::setupMockMysqlDatabase($record); |
|
140 | - //# When retrieving account by null name |
|
141 | - $account = AbstractSmrAccount::getAccountByName(null); |
|
142 | - //# Then the record is null |
|
143 | - $this->assertNull($account); |
|
144 | - } |
|
135 | + public function test_get_account_by_name_returns_null_when_no_account_name_provided() |
|
136 | + { |
|
137 | + //# Given a record exists |
|
138 | + $record = new Record(); |
|
139 | + self::setupMockMysqlDatabase($record); |
|
140 | + //# When retrieving account by null name |
|
141 | + $account = AbstractSmrAccount::getAccountByName(null); |
|
142 | + //# Then the record is null |
|
143 | + $this->assertNull($account); |
|
144 | + } |
|
145 | 145 | |
146 | - public function test_get_account_by_name_returns_null_when_no_record_found() |
|
147 | - { |
|
148 | - //# Given no record exists |
|
149 | - self::setupMockMysqlDatabase(null); |
|
150 | - //# When retrieving account by name |
|
151 | - $account = AbstractSmrAccount::getAccountByName("any"); |
|
152 | - //# Then the record is null |
|
153 | - $this->assertNull($account); |
|
154 | - } |
|
146 | + public function test_get_account_by_name_returns_null_when_no_record_found() |
|
147 | + { |
|
148 | + //# Given no record exists |
|
149 | + self::setupMockMysqlDatabase(null); |
|
150 | + //# When retrieving account by name |
|
151 | + $account = AbstractSmrAccount::getAccountByName("any"); |
|
152 | + //# Then the record is null |
|
153 | + $this->assertNull($account); |
|
154 | + } |
|
155 | 155 | |
156 | - public function test_get_account_by_email_happy_path() |
|
157 | - { |
|
158 | - //# Given a record exists |
|
159 | - $record = new Record(); |
|
160 | - self::setupMockMysqlDatabase($record); |
|
161 | - //# When retrieving account by email |
|
162 | - $account = AbstractSmrAccount::getAccountByEmail($record->email); |
|
163 | - //# Then the record is found |
|
164 | - $this->assertEquals($record->account_id, $account->getAccountID()); |
|
165 | - } |
|
156 | + public function test_get_account_by_email_happy_path() |
|
157 | + { |
|
158 | + //# Given a record exists |
|
159 | + $record = new Record(); |
|
160 | + self::setupMockMysqlDatabase($record); |
|
161 | + //# When retrieving account by email |
|
162 | + $account = AbstractSmrAccount::getAccountByEmail($record->email); |
|
163 | + //# Then the record is found |
|
164 | + $this->assertEquals($record->account_id, $account->getAccountID()); |
|
165 | + } |
|
166 | 166 | |
167 | - public function test_get_account_by_email_returns_null_when_no_email_provided() |
|
168 | - { |
|
169 | - //# Given a record exists |
|
170 | - $record = new Record(); |
|
171 | - self::setupMockMysqlDatabase($record); |
|
172 | - //# When retrieving account by null email |
|
173 | - $account = AbstractSmrAccount::getAccountByEmail(null); |
|
174 | - //# Then the record is null |
|
175 | - $this->assertNull($account); |
|
176 | - } |
|
167 | + public function test_get_account_by_email_returns_null_when_no_email_provided() |
|
168 | + { |
|
169 | + //# Given a record exists |
|
170 | + $record = new Record(); |
|
171 | + self::setupMockMysqlDatabase($record); |
|
172 | + //# When retrieving account by null email |
|
173 | + $account = AbstractSmrAccount::getAccountByEmail(null); |
|
174 | + //# Then the record is null |
|
175 | + $this->assertNull($account); |
|
176 | + } |
|
177 | 177 | |
178 | - public function test_get_account_by_email_returns_null_when_no_record_found() |
|
179 | - { |
|
180 | - //# Given no record exists |
|
181 | - self::setupMockMysqlDatabase(null); |
|
182 | - //# When retrieving account by email |
|
183 | - $account = AbstractSmrAccount::getAccountByEmail("any"); |
|
184 | - //# Then the record is null |
|
185 | - $this->assertNull($account); |
|
186 | - } |
|
178 | + public function test_get_account_by_email_returns_null_when_no_record_found() |
|
179 | + { |
|
180 | + //# Given no record exists |
|
181 | + self::setupMockMysqlDatabase(null); |
|
182 | + //# When retrieving account by email |
|
183 | + $account = AbstractSmrAccount::getAccountByEmail("any"); |
|
184 | + //# Then the record is null |
|
185 | + $this->assertNull($account); |
|
186 | + } |
|
187 | 187 | |
188 | - public function test_get_account_by_discord_happy_path() |
|
189 | - { |
|
190 | - //# Given a record exists |
|
191 | - $record = new Record(); |
|
192 | - self::setupMockMysqlDatabase($record); |
|
193 | - //# When retrieving account by discord |
|
194 | - $account = AbstractSmrAccount::getAccountByDiscordId($record->login); |
|
195 | - //# Then the record is found |
|
196 | - $this->assertEquals($record->account_id, $account->getAccountID()); |
|
197 | - } |
|
188 | + public function test_get_account_by_discord_happy_path() |
|
189 | + { |
|
190 | + //# Given a record exists |
|
191 | + $record = new Record(); |
|
192 | + self::setupMockMysqlDatabase($record); |
|
193 | + //# When retrieving account by discord |
|
194 | + $account = AbstractSmrAccount::getAccountByDiscordId($record->login); |
|
195 | + //# Then the record is found |
|
196 | + $this->assertEquals($record->account_id, $account->getAccountID()); |
|
197 | + } |
|
198 | 198 | |
199 | - public function test_get_account_by_discord_returns_null_when_no_discord_provided() |
|
200 | - { |
|
201 | - //# Given a record exists |
|
202 | - $record = new Record(); |
|
203 | - self::setupMockMysqlDatabase($record); |
|
204 | - //# When retrieving account by null discord |
|
205 | - $account = AbstractSmrAccount::getAccountByDiscordId(null); |
|
206 | - //# Then the record is null |
|
207 | - $this->assertNull($account); |
|
208 | - } |
|
199 | + public function test_get_account_by_discord_returns_null_when_no_discord_provided() |
|
200 | + { |
|
201 | + //# Given a record exists |
|
202 | + $record = new Record(); |
|
203 | + self::setupMockMysqlDatabase($record); |
|
204 | + //# When retrieving account by null discord |
|
205 | + $account = AbstractSmrAccount::getAccountByDiscordId(null); |
|
206 | + //# Then the record is null |
|
207 | + $this->assertNull($account); |
|
208 | + } |
|
209 | 209 | |
210 | - public function test_get_account_by_discord_returns_null_when_no_record_found() |
|
211 | - { |
|
212 | - //# Given no record exists |
|
213 | - self::setupMockMysqlDatabase(null); |
|
214 | - //# When retrieving account by discord |
|
215 | - $account = AbstractSmrAccount::getAccountByDiscordId("any"); |
|
216 | - //# Then the record is null |
|
217 | - $this->assertNull($account); |
|
218 | - } |
|
210 | + public function test_get_account_by_discord_returns_null_when_no_record_found() |
|
211 | + { |
|
212 | + //# Given no record exists |
|
213 | + self::setupMockMysqlDatabase(null); |
|
214 | + //# When retrieving account by discord |
|
215 | + $account = AbstractSmrAccount::getAccountByDiscordId("any"); |
|
216 | + //# Then the record is null |
|
217 | + $this->assertNull($account); |
|
218 | + } |
|
219 | 219 | |
220 | - public function test_get_account_by_irc_happy_path() |
|
221 | - { |
|
222 | - //# Given a record exists |
|
223 | - $record = new Record(); |
|
224 | - self::setupMockMysqlDatabase($record); |
|
225 | - //# When retrieving account by irc |
|
226 | - $account = AbstractSmrAccount::getAccountByIrcNick($record->login); |
|
227 | - //# Then the record is found |
|
228 | - $this->assertEquals($record->account_id, $account->getAccountID()); |
|
229 | - } |
|
220 | + public function test_get_account_by_irc_happy_path() |
|
221 | + { |
|
222 | + //# Given a record exists |
|
223 | + $record = new Record(); |
|
224 | + self::setupMockMysqlDatabase($record); |
|
225 | + //# When retrieving account by irc |
|
226 | + $account = AbstractSmrAccount::getAccountByIrcNick($record->login); |
|
227 | + //# Then the record is found |
|
228 | + $this->assertEquals($record->account_id, $account->getAccountID()); |
|
229 | + } |
|
230 | 230 | |
231 | - public function test_get_account_by_irc_returns_null_when_no_irc_provided() |
|
232 | - { |
|
233 | - //# Given a record exists |
|
234 | - $record = new Record(); |
|
235 | - self::setupMockMysqlDatabase($record); |
|
236 | - //# When retrieving account by null irc |
|
237 | - $account = AbstractSmrAccount::getAccountByIrcNick(null); |
|
238 | - //# Then the record is null |
|
239 | - $this->assertNull($account); |
|
240 | - } |
|
231 | + public function test_get_account_by_irc_returns_null_when_no_irc_provided() |
|
232 | + { |
|
233 | + //# Given a record exists |
|
234 | + $record = new Record(); |
|
235 | + self::setupMockMysqlDatabase($record); |
|
236 | + //# When retrieving account by null irc |
|
237 | + $account = AbstractSmrAccount::getAccountByIrcNick(null); |
|
238 | + //# Then the record is null |
|
239 | + $this->assertNull($account); |
|
240 | + } |
|
241 | 241 | |
242 | - public function test_get_account_by_irc_returns_null_when_no_record_found() |
|
243 | - { |
|
244 | - //# Given no record exists |
|
245 | - self::setupMockMysqlDatabase(null); |
|
246 | - //# When retrieving account by irc |
|
247 | - $account = AbstractSmrAccount::getAccountByIrcNick("any"); |
|
248 | - //# Then the record is null |
|
249 | - $this->assertNull($account); |
|
250 | - } |
|
242 | + public function test_get_account_by_irc_returns_null_when_no_record_found() |
|
243 | + { |
|
244 | + //# Given no record exists |
|
245 | + self::setupMockMysqlDatabase(null); |
|
246 | + //# When retrieving account by irc |
|
247 | + $account = AbstractSmrAccount::getAccountByIrcNick("any"); |
|
248 | + //# Then the record is null |
|
249 | + $this->assertNull($account); |
|
250 | + } |
|
251 | 251 | |
252 | - ///// |
|
253 | - public function test_get_account_by_social_happy_path() |
|
254 | - { |
|
255 | - //# Given a record exists |
|
256 | - $record = new Record(); |
|
257 | - self::setupMockMysqlDatabase($record); |
|
258 | - //# And a valid social login |
|
259 | - $socialLogin = m::mock(SocialLogin::class)->shouldIgnoreMissing(); |
|
260 | - $socialLogin |
|
261 | - ->expects() |
|
262 | - ->isValid() |
|
263 | - ->andReturns(true); |
|
264 | - //# When retrieving account by social |
|
265 | - $account = AbstractSmrAccount::getAccountBySocialLogin($socialLogin); |
|
266 | - //# Then the record is found |
|
267 | - $this->assertEquals($record->account_id, $account->getAccountID()); |
|
268 | - } |
|
252 | + ///// |
|
253 | + public function test_get_account_by_social_happy_path() |
|
254 | + { |
|
255 | + //# Given a record exists |
|
256 | + $record = new Record(); |
|
257 | + self::setupMockMysqlDatabase($record); |
|
258 | + //# And a valid social login |
|
259 | + $socialLogin = m::mock(SocialLogin::class)->shouldIgnoreMissing(); |
|
260 | + $socialLogin |
|
261 | + ->expects() |
|
262 | + ->isValid() |
|
263 | + ->andReturns(true); |
|
264 | + //# When retrieving account by social |
|
265 | + $account = AbstractSmrAccount::getAccountBySocialLogin($socialLogin); |
|
266 | + //# Then the record is found |
|
267 | + $this->assertEquals($record->account_id, $account->getAccountID()); |
|
268 | + } |
|
269 | 269 | |
270 | - public function test_get_account_by_social_returns_null_when_social_invalid() |
|
271 | - { |
|
272 | - //# Given a record exists |
|
273 | - $record = new Record(); |
|
274 | - self::setupMockMysqlDatabase($record); |
|
275 | - //# And an invalid social login |
|
276 | - $socialLogin = m::mock(SocialLogin::class)->shouldIgnoreMissing(); |
|
277 | - $socialLogin |
|
278 | - ->expects() |
|
279 | - ->isValid() |
|
280 | - ->andReturns(false); |
|
281 | - //# When retrieving account by null social |
|
282 | - $account = AbstractSmrAccount::getAccountBySocialLogin($socialLogin); |
|
283 | - //# Then the record is null |
|
284 | - $this->assertNull($account); |
|
285 | - } |
|
270 | + public function test_get_account_by_social_returns_null_when_social_invalid() |
|
271 | + { |
|
272 | + //# Given a record exists |
|
273 | + $record = new Record(); |
|
274 | + self::setupMockMysqlDatabase($record); |
|
275 | + //# And an invalid social login |
|
276 | + $socialLogin = m::mock(SocialLogin::class)->shouldIgnoreMissing(); |
|
277 | + $socialLogin |
|
278 | + ->expects() |
|
279 | + ->isValid() |
|
280 | + ->andReturns(false); |
|
281 | + //# When retrieving account by null social |
|
282 | + $account = AbstractSmrAccount::getAccountBySocialLogin($socialLogin); |
|
283 | + //# Then the record is null |
|
284 | + $this->assertNull($account); |
|
285 | + } |
|
286 | 286 | |
287 | - public function test_get_account_by_social_returns_null_when_no_record_found() |
|
288 | - { |
|
289 | - //# Given no record exists |
|
290 | - self::setupMockMysqlDatabase(null); |
|
291 | - //# And a valid social login |
|
292 | - $socialLogin = m::mock(SocialLogin::class)->shouldIgnoreMissing(); |
|
293 | - $socialLogin |
|
294 | - ->expects() |
|
295 | - ->isValid() |
|
296 | - ->andReturns(true); |
|
297 | - //# When retrieving account by social |
|
298 | - $account = AbstractSmrAccount::getAccountBySocialLogin($socialLogin); |
|
299 | - //# Then the record is null |
|
300 | - $this->assertNull($account); |
|
301 | - } |
|
287 | + public function test_get_account_by_social_returns_null_when_no_record_found() |
|
288 | + { |
|
289 | + //# Given no record exists |
|
290 | + self::setupMockMysqlDatabase(null); |
|
291 | + //# And a valid social login |
|
292 | + $socialLogin = m::mock(SocialLogin::class)->shouldIgnoreMissing(); |
|
293 | + $socialLogin |
|
294 | + ->expects() |
|
295 | + ->isValid() |
|
296 | + ->andReturns(true); |
|
297 | + //# When retrieving account by social |
|
298 | + $account = AbstractSmrAccount::getAccountBySocialLogin($socialLogin); |
|
299 | + //# Then the record is null |
|
300 | + $this->assertNull($account); |
|
301 | + } |
|
302 | 302 | |
303 | - public function tearDown(): void |
|
304 | - { |
|
305 | - m::close(); |
|
306 | - } |
|
303 | + public function tearDown(): void |
|
304 | + { |
|
305 | + m::close(); |
|
306 | + } |
|
307 | 307 | |
308 | - private static function setupMockMysqlDatabase(?Record $record): MockInterface |
|
309 | - { |
|
310 | - //# Force the mock to be used in the autoloader |
|
311 | - $mysqlDatabase = m::mock("overload:" . SmrMySqlDatabase::class)->shouldIgnoreMissing(); |
|
312 | - if (isset($record)) { |
|
313 | - $mysqlDatabase |
|
314 | - ->shouldReceive("escapeNumber") |
|
315 | - ->with($record->account_id) |
|
316 | - ->andReturn($record->account_id); |
|
317 | - $mysqlDatabase |
|
318 | - ->shouldReceive("nextRecord") |
|
319 | - ->andReturn($record); |
|
320 | - $mysqlDatabase |
|
321 | - ->shouldReceive("getRow") |
|
322 | - ->andReturn((array)$record); |
|
323 | - } |
|
324 | - return $mysqlDatabase; |
|
325 | - } |
|
308 | + private static function setupMockMysqlDatabase(?Record $record): MockInterface |
|
309 | + { |
|
310 | + //# Force the mock to be used in the autoloader |
|
311 | + $mysqlDatabase = m::mock("overload:" . SmrMySqlDatabase::class)->shouldIgnoreMissing(); |
|
312 | + if (isset($record)) { |
|
313 | + $mysqlDatabase |
|
314 | + ->shouldReceive("escapeNumber") |
|
315 | + ->with($record->account_id) |
|
316 | + ->andReturn($record->account_id); |
|
317 | + $mysqlDatabase |
|
318 | + ->shouldReceive("nextRecord") |
|
319 | + ->andReturn($record); |
|
320 | + $mysqlDatabase |
|
321 | + ->shouldReceive("getRow") |
|
322 | + ->andReturn((array)$record); |
|
323 | + } |
|
324 | + return $mysqlDatabase; |
|
325 | + } |
|
326 | 326 | } |