-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: users cannot enable block pd option (#192)
* chore: create test for toggle block pds * Apply fixes from StyleCI * chore: enable tests * fix: toggling blockpd fails to save * fix: test disable setting * Apply fixes from StyleCI --------- Co-authored-by: StyleCI Bot <[email protected]>
- Loading branch information
1 parent
10770e1
commit 725636c
Showing
10 changed files
with
187 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 | ||
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 |
---|---|---|
|
@@ -2,3 +2,4 @@ js/dist | |
js/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
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,92 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of fof/byobu. | ||
* | ||
* Copyright (c) FriendsOfFlarum. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace FoF\Byobu\Tests\integration\api; | ||
|
||
use Flarum\Testing\integration\RetrievesAuthorizedUsers; | ||
use Flarum\Testing\integration\TestCase; | ||
|
||
class UserPrivacyTest extends TestCase | ||
{ | ||
use RetrievesAuthorizedUsers; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->extension('fof-byobu'); | ||
|
||
$this->prepareDatabase([ | ||
'users' => [ | ||
$this->normalUser(), | ||
['id' => 3, 'username' => 'normal2', 'email' => '[email protected]', 'password' => 'too-obscure', 'blocks_byobu_pd' => true], | ||
], | ||
]); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function user_can_set_block_pd_setting() | ||
{ | ||
$response = $this->send( | ||
$this->request( | ||
'PATCH', | ||
'/api/users/2', | ||
[ | ||
'authenticatedAs' => 2, | ||
'json' => [ | ||
'data' => [ | ||
'attributes' => [ | ||
'blocksPd' => true, | ||
], | ||
], | ||
], | ||
] | ||
) | ||
); | ||
|
||
$this->assertEquals(200, $response->getStatusCode()); | ||
|
||
$json = json_decode($response->getBody()->getContents(), true); | ||
|
||
$this->assertTrue($json['data']['attributes']['blocksPd']); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function user_can_disable_block_pd_setting() | ||
{ | ||
$response = $this->send( | ||
$this->request( | ||
'PATCH', | ||
'/api/users/3', | ||
[ | ||
'authenticatedAs' => 3, | ||
'json' => [ | ||
'data' => [ | ||
'attributes' => [ | ||
'blocksPd' => false, | ||
], | ||
], | ||
], | ||
] | ||
) | ||
); | ||
|
||
$this->assertEquals(200, $response->getStatusCode()); | ||
|
||
$json = json_decode($response->getBody()->getContents(), true); | ||
|
||
$this->assertFalse($json['data']['attributes']['blocksPd']); | ||
} | ||
} |
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,18 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of fof/byobu. | ||
* | ||
* Copyright (c) FriendsOfFlarum. | ||
* | ||
* For the full 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.