-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enable testing, test forum actor relation
- Loading branch information
Showing
5 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ jobs: | |
run: | ||
uses: flarum/framework/.github/workflows/[email protected] | ||
with: | ||
enable_backend_testing: false | ||
enable_backend_testing: true | ||
enable_phpstan: true | ||
php_versions: '["8.0", "8.1", "8.2", "8.3"]' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules | ||
vendor | ||
composer.lock | ||
.phpunit.result.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace IanM\FollowUsers\Tests\integration\api; | ||
|
||
use Flarum\Testing\integration\RetrievesAuthorizedUsers; | ||
use Flarum\Testing\integration\TestCase; | ||
|
||
class ForumRelationTest extends TestCase | ||
{ | ||
use RetrievesAuthorizedUsers; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->extension('ianm-follow-users'); | ||
|
||
$this->prepareDatabase([ | ||
'users' => [ | ||
$this->normalUser(), | ||
], | ||
]); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function forum_actor_contains_followed_user_relations() | ||
{ | ||
$response = $this->send( | ||
$this->request( | ||
'GET', | ||
'/api', | ||
[ | ||
'authenticatedAs' => 2, | ||
] | ||
) | ||
); | ||
|
||
$this->assertEquals(200, $response->getStatusCode()); | ||
|
||
$json = json_decode($response->getBody()->getContents(), true); | ||
|
||
$this->assertArrayHasKey('actor', $json['data']['relationships']); | ||
|
||
$included = $json['included']; | ||
|
||
$actorIndex = array_search('users', array_column($included, 'type')); | ||
$actor = $included[$actorIndex]; | ||
|
||
$this->assertEquals(2, $actor['id']); | ||
$this->assertArrayHasKey('followedUsers', $actor['relationships']); | ||
$this->assertArrayHasKey('data', $actor['relationships']['followedUsers']); | ||
} | ||
} |