-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: migration assumes fof/follow-tags is installed (#49)
* fix: migration assumes fof/follow-tags is installed, add very basic initial test * remove phpunit cache * add phpunit.result.cache * Apply fixes from StyleCI * enable testing --------- Co-authored-by: StyleCI Bot <[email protected]>
- Loading branch information
1 parent
aaba93a
commit abf9b4c
Showing
12 changed files
with
280 additions
and
99 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name: FoF Discussion Language PHP | ||
|
||
on: [workflow_dispatch, push, pull_request] | ||
|
||
jobs: | ||
run: | ||
uses: flarum/framework/.github/workflows/REUSABLE_backend.yml@main | ||
with: | ||
enable_backend_testing: true | ||
|
||
backend_directory: . |
This file was deleted.
Oops, something went wrong.
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,19 @@ | ||
name: FoF Discussion Language JS | ||
|
||
on: [workflow_dispatch, push, pull_request] | ||
|
||
jobs: | ||
run: | ||
uses: flarum/framework/.github/workflows/REUSABLE_frontend.yml@main | ||
with: | ||
enable_bundlewatch: false | ||
enable_prettier: true | ||
enable_typescript: true | ||
|
||
frontend_directory: ./js | ||
backend_directory: . | ||
js_package_manager: npm | ||
main_git_branch: master | ||
|
||
secrets: | ||
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,94 @@ | ||
{ | ||
"name": "fof/discussion-language", | ||
"description": "Specify the language a discussion is written in & sort by language", | ||
"keywords": [ | ||
"flarum" | ||
], | ||
"type": "flarum-extension", | ||
"license": "MIT", | ||
"support": { | ||
"issues": "https://github.com/FriendsOfFlarum/discussion-language/issues", | ||
"source": "https://github.com/FriendsOfFlarum/discussion-language", | ||
"forum": "https://discuss.flarum.org/d/23702" | ||
}, | ||
"homepage": "https://friendsofflarum.org", | ||
"funding": [ | ||
{ | ||
"type": "website", | ||
"url": "https://opencollective.com/fof/donate" | ||
} | ||
], | ||
"require": { | ||
"flarum/core": "^1.8.1", | ||
"rinvex/countries": "^6.1.2 || ^7.0.1 || ^8.1.0", | ||
"league/csv": "^9.7", | ||
"ianm/iso-639": "^1.0", | ||
"flarum/tags": "*" | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "David Sevilla Martin", | ||
"email": "[email protected]", | ||
"role": "Developer" | ||
"name": "fof/discussion-language", | ||
"description": "Specify the language a discussion is written in & sort by language", | ||
"keywords": [ | ||
"flarum" | ||
], | ||
"type": "flarum-extension", | ||
"license": "MIT", | ||
"support": { | ||
"issues": "https://github.com/FriendsOfFlarum/discussion-language/issues", | ||
"source": "https://github.com/FriendsOfFlarum/discussion-language", | ||
"forum": "https://discuss.flarum.org/d/23702" | ||
}, | ||
{ | ||
"name": "IanM", | ||
"email": "[email protected]", | ||
"role": "Developer" | ||
} | ||
], | ||
"autoload": { | ||
"psr-4": { | ||
"FoF\\DiscussionLanguage\\": "src/" | ||
} | ||
}, | ||
"extra": { | ||
"flarum-extension": { | ||
"title": "FoF Discussion Language", | ||
"category": "feature", | ||
"icon": { | ||
"name": "fas fa-language", | ||
"backgroundColor": "#e74c3c", | ||
"color": "#fff" | ||
}, | ||
"optional-dependencies": [ | ||
"fof/byobu", | ||
"fof/follow-tags" | ||
] | ||
"homepage": "https://friendsofflarum.org", | ||
"funding": [ | ||
{ | ||
"type": "website", | ||
"url": "https://opencollective.com/fof/donate" | ||
} | ||
], | ||
"require": { | ||
"flarum/core": "^1.8.1", | ||
"rinvex/countries": "^6.1.2 || ^7.0.1 || ^8.1.0", | ||
"league/csv": "^9.7", | ||
"ianm/iso-639": "^1.0", | ||
"flarum/tags": "*" | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "David Sevilla Martin", | ||
"email": "[email protected]", | ||
"role": "Developer" | ||
}, | ||
{ | ||
"name": "IanM", | ||
"email": "[email protected]", | ||
"role": "Developer" | ||
} | ||
], | ||
"autoload": { | ||
"psr-4": { | ||
"FoF\\DiscussionLanguage\\": "src/" | ||
} | ||
}, | ||
"extra": { | ||
"flarum-extension": { | ||
"title": "FoF Discussion Language", | ||
"category": "feature", | ||
"icon": { | ||
"name": "fas fa-language", | ||
"backgroundColor": "#e74c3c", | ||
"color": "#fff" | ||
}, | ||
"optional-dependencies": [ | ||
"fof/byobu", | ||
"fof/follow-tags" | ||
] | ||
}, | ||
"flagrow": { | ||
"discuss": "https://discuss.flarum.org/d/23702" | ||
}, | ||
"flarum-cli": { | ||
"modules": { | ||
"githubActions": true, | ||
"backendTesting": true | ||
} | ||
} | ||
}, | ||
"require-dev": { | ||
"fof/byobu": "*", | ||
"fof/follow-tags": "*", | ||
"flarum/testing": "^1.0.0" | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"FoF\\DiscussionLanguage\\Tests\\": "tests/" | ||
} | ||
}, | ||
"scripts": { | ||
"test": [ | ||
"@test:unit", | ||
"@test:integration" | ||
], | ||
"test:unit": "phpunit -c tests/phpunit.unit.xml", | ||
"test:integration": "phpunit -c tests/phpunit.integration.xml", | ||
"test:setup": "@php tests/integration/setup.php" | ||
}, | ||
"flagrow": { | ||
"discuss": "https://discuss.flarum.org/d/23702" | ||
"scripts-descriptions": { | ||
"test": "Runs all tests.", | ||
"test:unit": "Runs all unit tests.", | ||
"test:integration": "Runs all integration tests.", | ||
"test:setup": "Sets up a database for use with integration tests. Execute this only once." | ||
} | ||
}, | ||
"require-dev": { | ||
"fof/byobu": "*", | ||
"fof/follow-tags": "*" | ||
} | ||
} |
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,83 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of fof/discussion-language. | ||
* | ||
* Copyright (c) FriendsOfFlarum. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace FoF\DiscussionLanguage\tests\integration\api; | ||
|
||
use Flarum\Testing\integration\RetrievesAuthorizedUsers; | ||
use Flarum\Testing\integration\TestCase; | ||
|
||
class CreateLanguageTest extends TestCase | ||
{ | ||
use RetrievesAuthorizedUsers; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->extension('flarum-tags'); | ||
$this->extension('fof-discussion-language'); | ||
|
||
$this->prepareDatabase([ | ||
'users' => [ | ||
$this->normalUser(), | ||
], | ||
]); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function non_admin_cannot_create_language() | ||
{ | ||
$response = $this->send( | ||
$this->request('POST', '/api/fof/discussion-language', [ | ||
'json' => [ | ||
'data' => [ | ||
'attributes' => [ | ||
'country' => 'Test Country', | ||
'code' => 'test', | ||
], | ||
], | ||
], | ||
'authenticatedAs' => 2, | ||
]) | ||
); | ||
|
||
$this->assertEquals(403, $response->getStatusCode()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function admin_can_create_language() | ||
{ | ||
$response = $this->send( | ||
$this->request('POST', '/api/fof/discussion-language', [ | ||
'json' => [ | ||
'data' => [ | ||
'attributes' => [ | ||
'country' => 'Test Country', | ||
'code' => 'test', | ||
], | ||
], | ||
], | ||
'authenticatedAs' => 1, | ||
]) | ||
); | ||
|
||
$this->assertEquals(201, $response->getStatusCode()); | ||
|
||
$data = json_decode($response->getBody()->getContents(), true); | ||
|
||
$this->assertEquals('Test Country', $data['data']['attributes']['country']); | ||
$this->assertEquals('test', $data['data']['attributes']['code']); | ||
} | ||
} |
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/discussion-language. | ||
* | ||
* 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> |
Oops, something went wrong.