-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
168 additions
and
6 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 | ||
|
||
backend_directory: . |
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 @@ | ||
{"version":1,"defects":{"FoF\\OAuth\\Tests\\integration\\api\\ForumSerializerTest::it_includes_providers_in_forum_attributes_for_guests":3,"FoF\\OAuth\\Tests\\integration\\api\\ForumSerializerTest::it_does_not_include_providers_in_forum_attributes_for_logged_in_users":4,"FoF\\OAuth\\Tests\\integration\\api\\ForumSerializerTest::admin_panel_is_available":3},"times":{"FoF\\OAuth\\Tests\\integration\\api\\ForumSerializerTest::it_includes_providers_in_forum_attributes_for_guests":0.045,"FoF\\OAuth\\Tests\\integration\\api\\ForumSerializerTest::it_does_not_include_providers_in_forum_attributes_for_logged_in_users":0.059,"FoF\\OAuth\\Tests\\integration\\api\\ForumSerializerTest::admin_panel_is_available":0.351}} |
Empty file.
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,73 @@ | ||
<?php | ||
|
||
namespace FoF\OAuth\Tests\integration\api; | ||
|
||
use Flarum\Extend; | ||
use Flarum\Testing\integration\TestCase; | ||
|
||
class ForumSerializerTest extends TestCase | ||
{ | ||
public function setUp(): void | ||
{ | ||
$this->extension('fof-oauth'); | ||
|
||
$this->extend( | ||
(new Extend\Csrf)->exemptRoute('login') | ||
); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_includes_providers_in_forum_attributes_for_guests() | ||
{ | ||
$response = $this->send( | ||
$this->request('GET', '/api') | ||
); | ||
|
||
$this->assertEquals(200, $response->getStatusCode()); | ||
|
||
$body = json_decode($response->getBody(), true); | ||
|
||
$this->assertArrayHasKey('fof-oauth', $body['data']['attributes']); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_does_not_include_providers_in_forum_attributes_for_logged_in_users() | ||
{ | ||
$response = $this->send( | ||
$this->request('GET', '/api', ['authenticatedAs' => 1]) | ||
); | ||
|
||
$this->assertEquals(200, $response->getStatusCode()); | ||
|
||
$body = json_decode($response->getBody()->getContents(), true); | ||
|
||
$this->assertArrayNotHasKey('fof-oauth', $body['data']['attributes']); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function admin_panel_is_available() | ||
{ | ||
$login = $this->send( | ||
$this->request('POST', '/login', [ | ||
'json' => [ | ||
'identification' => 'admin', | ||
'password' => 'password' | ||
] | ||
]) | ||
); | ||
|
||
$this->assertEquals(200, $login->getStatusCode()); | ||
|
||
$response = $this->send( | ||
$this->request('GET', '/admin', ['cookiesFrom' => $login]) | ||
); | ||
|
||
$this->assertEquals(200, $response->getStatusCode()); | ||
} | ||
} |
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,16 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Flarum. | ||
* | ||
* For detailed copyright and license information, please view the | ||
* LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
use Flarum\Testing\integration\Setup\SetupScript; | ||
|
||
require __DIR__.'/../../vendor/autoload.php'; | ||
|
||
$setup = new SetupScript(); | ||
|
||
$setup->run(); |
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,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="true" | ||
stopOnFailure="false" | ||
> | ||
<coverage processUncoveredFiles="true"> | ||
<include> | ||
<directory suffix=".php">../src/</directory> | ||
</include> | ||
</coverage> | ||
<testsuites> | ||
<testsuite name="Flarum Integration Tests"> | ||
<directory suffix="Test.php">./integration</directory> | ||
<exclude>./integration/tmp</exclude> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
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,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
> | ||
<coverage processUncoveredFiles="true"> | ||
<include> | ||
<directory suffix=".php">../src/</directory> | ||
</include> | ||
</coverage> | ||
<testsuites> | ||
<testsuite name="Flarum Unit Tests"> | ||
<directory suffix="Test.php">./unit</directory> | ||
</testsuite> | ||
</testsuites> | ||
<listeners> | ||
<listener class="\Mockery\Adapter\Phpunit\TestListener" /> | ||
</listeners> | ||
</phpunit> |
Empty file.