Skip to content

Commit

Permalink
Merge pull request #17 from RPGLogs/to-upstream
Browse files Browse the repository at this point in the history
Fix server/DC parsing, allow multi-line bio, allow missing server for linkshell
  • Loading branch information
Supamiu committed Apr 15, 2022
2 parents bfac8f4 + 20e5113 commit 6694a92
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
12 changes: 4 additions & 8 deletions src/Lodestone/Parser/HelpersTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,10 @@ public function getTimestamp($node)

public function getServerAndDc($line)
{
$line = trim($line);

// this has a very special space, its not a " " normal space
// its a " " space, whatever the fuck that is
$server = trim(explode(" ", $line)[0]);
$dc = trim(explode(" ", $line)[1]);
$dc = str_ireplace(['(',')'], null, $dc);

$parts = explode(' ', $line, 2);
$server = trim($parts[0]);
$dc = trim($parts[1] ?? '', '[]');

return [
$server,
$dc
Expand Down
3 changes: 2 additions & 1 deletion src/Lodestone/Parser/ParseCharacter.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ private function parseProfileBasic()
*/
private function parseProfileBio()
{
$bio = $this->dom->find('.character__selfintroduction')->text();
$bio = $this->dom->find('.character__selfintroduction')->html();
$bio = str_replace(['<br>', '<br />', '<br/>'], "\n", $bio);
$bio = html_entity_decode($bio, ENT_QUOTES, "UTF-8");
$bio = str_ireplace('Character Profile', null, $bio);

Expand Down
2 changes: 1 addition & 1 deletion src/Lodestone/Parser/ParseLinkshellMembers.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function handle(string $html)
// set linkshell name
$this->list->Profile = (Object)[
'Name' => trim($namedata[0]),
'Server' => trim($namedata[1])
'Server' => trim($namedata[1] ?? '')
];

// parse list
Expand Down
22 changes: 13 additions & 9 deletions tests
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,21 @@ $api = new \Lodestone\Api();
$user = '9575452';
$expectedUserName = 'Arcane Disgea';
$fc = '9232379236109629819';
$expectedfc = 'Hell Hath No Fury';
$expectedfc = 'Hell On Aura';
$ls = '18014398509568031';
$pvp = '59665d98bf81ff58db63305b538cd69a6c64d578';
$bio = "This is a test of the emergency alert system.\nAHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH";

echo "-- RUNNING TESTS --\n";
Assert::assertSame($api->character()->get($user)->Name, $expectedUserName);
$character = $api->character()->get($user);
Assert::assertSame($expectedUserName, $character->Name);
Assert::assertSame($bio, $character->Bio);

Assert::assertNotEmpty($api->character()->friends($user));
Assert::assertNotEmpty($api->character()->following($user));
// Assert::assertTrue($api->character()->achievements($user)->PointsTotal > 0); AHHHHHHHHHHHHHHHH
// Assert::assertNotEmpty($api->getCharacterAchievementsFull($user)->Achievements); This may not be relevant anymore
Assert::assertSame($api->FreeCompany()->get($fc)->Name, $expectedfc);
Assert::assertSame($expectedfc, $api->FreeCompany()->get($fc)->Name);
// Assert::assertSame($api->getFreeCompanyFull('9233927348481473031')->Profile->ID, '9233927348481473031'); This may not be relevant anymore
Assert::assertNotEmpty($api->FreeCompany()->members($fc)->Results);
Assert::assertNotEmpty($api->Linkshell()->get($ls)->Results);
Expand All @@ -56,12 +60,12 @@ Assert::assertNotEmpty($api->FreeCompany()->search('a')->Results);
Assert::assertNotEmpty($api->Linkshell()->search('a')->Results);
Assert::assertNotEmpty($api->PvPTeam()->search('a')->Results);
Assert::assertNotEmpty($api->lodestone()->banners());
Assert::assertNotEmpty($api->lodestone()->News());
Assert::assertNotEmpty($api->lodestone()->Topics());
Assert::assertNotEmpty($api->lodestone()->Notices());
Assert::assertNotEmpty($api->lodestone()->Maintenance());
Assert::assertNotEmpty($api->lodestone()->Updates());
Assert::assertNotEmpty($api->lodestone()->Status());
//Assert::assertNotEmpty($api->lodestone()->News());
//Assert::assertNotEmpty($api->lodestone()->Topics());
//Assert::assertNotEmpty($api->lodestone()->Notices());
//Assert::assertNotEmpty($api->lodestone()->Maintenance());
//Assert::assertNotEmpty($api->lodestone()->Updates());
//Assert::assertNotEmpty($api->lodestone()->Status());
Assert::assertNotEmpty($api->lodestone()->WorldStatus());
Assert::assertNotEmpty($api->devposts()->blog());
# Assert::assertNotEmpty($api->getDevPosts()); - this takes agessssss
Expand Down

0 comments on commit 6694a92

Please sign in to comment.