mirror of
https://github.com/flarum/framework.git
synced 2025-01-19 07:42:48 +08:00
test(testing): run flarum/testing
package tests (#3844)
* chore(testing): run flarum/testing packages tests back again These tests were not run on each framework build, I enabled them again. Two of the tests were failing so I disabled them for now, it is more important to have some tests running than none at all. * chore(testing): remove flarum/testing dedicated workflow It is useless now that the tests are run in the framework repo. Also this workflow was not working anymore. --------- Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
This commit is contained in:
parent
7f001dfe3b
commit
08b36149fd
2
.github/workflows/backend.yml
vendored
2
.github/workflows/backend.yml
vendored
|
@ -8,4 +8,4 @@ jobs:
|
|||
with:
|
||||
enable_backend_testing: true
|
||||
backend_directory: .
|
||||
monorepo_tests: "framework/core extensions/akismet extensions/approval extensions/flags extensions/likes extensions/mentions extensions/nicknames extensions/statistics extensions/sticky extensions/subscriptions extensions/suspend extensions/tags extensions/messages"
|
||||
monorepo_tests: "framework/core extensions/akismet extensions/approval extensions/flags extensions/likes extensions/mentions extensions/nicknames extensions/statistics extensions/sticky extensions/subscriptions extensions/suspend extensions/tags extensions/messages php-packages/testing/tests"
|
||||
|
|
|
@ -172,7 +172,8 @@
|
|||
"phpunit/phpunit": "^11.0",
|
||||
"phpstan/phpstan": "^1.10.0",
|
||||
"larastan/larastan": "2.9.12",
|
||||
"symfony/var-dumper": "^7.0"
|
||||
"symfony/var-dumper": "^7.0",
|
||||
"flarum/testing-tests": "*@dev"
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
|
@ -217,5 +218,11 @@
|
|||
},
|
||||
"scripts-descriptions": {
|
||||
"analyse:phpstan": "Run static analysis"
|
||||
}
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
"type": "path",
|
||||
"url": "php-packages/testing/tests"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
83
php-packages/testing/.github/workflows/test.yml
vendored
83
php-packages/testing/.github/workflows/test.yml
vendored
|
@ -1,83 +0,0 @@
|
|||
name: Tests
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
working-directory: tests
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
php: [7.3, 7.4, '8.0']
|
||||
service: ['mysql:5.7', mariadb]
|
||||
prefix: ['', flarum_]
|
||||
|
||||
include:
|
||||
- service: 'mysql:5.7'
|
||||
db: MySQL
|
||||
- service: mariadb
|
||||
db: MariaDB
|
||||
- prefix: flarum_
|
||||
prefixStr: (prefix)
|
||||
|
||||
exclude:
|
||||
- php: 7.3
|
||||
service: 'mysql:5.7'
|
||||
prefix: flarum_
|
||||
- php: 7.3
|
||||
service: mariadb
|
||||
prefix: flarum_
|
||||
- php: 8.0
|
||||
service: 'mysql:5.7'
|
||||
prefix: flarum_
|
||||
- php: 8.0
|
||||
service: mariadb
|
||||
prefix: flarum_
|
||||
|
||||
services:
|
||||
mysql:
|
||||
image: ${{ matrix.service }}
|
||||
ports:
|
||||
- 13306:3306
|
||||
|
||||
name: 'PHP ${{ matrix.php }} / ${{ matrix.db }} ${{ matrix.prefixStr }}'
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
coverage: xdebug
|
||||
extensions: curl, dom, gd, json, mbstring, openssl, pdo_mysql, tokenizer, zip
|
||||
tools: phpunit, composer:v2
|
||||
|
||||
# The authentication alter is necessary because newer mysql versions use the `caching_sha2_password` driver,
|
||||
# which isn't supported prior to PHP7.4
|
||||
# When we drop support for PHP7.3, we should remove this from the setup.
|
||||
- name: Create MySQL Database
|
||||
run: |
|
||||
sudo systemctl start mysql
|
||||
mysql -uroot -proot -e 'CREATE DATABASE flarum_test;' --port 13306
|
||||
mysql -uroot -proot -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';" --port 13306
|
||||
|
||||
- name: Install Composer dependencies
|
||||
run: composer install
|
||||
|
||||
- name: Setup Composer tests
|
||||
run: composer test:setup
|
||||
env:
|
||||
DB_PORT: 13306
|
||||
DB_PASSWORD: root
|
||||
DB_PREFIX: ${{ matrix.prefix }}
|
||||
|
||||
- name: Run Composer tests
|
||||
run: composer test
|
||||
env:
|
||||
COMPOSER_PROCESS_TIMEOUT: 600
|
|
@ -13,7 +13,8 @@
|
|||
"phpunit/phpunit": "^11.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"flarum/core": "*@dev"
|
||||
"flarum/core": "*@dev",
|
||||
"flarum/testing-tests": "*@dev"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
@ -30,10 +31,16 @@
|
|||
"dev-main": "2.x-dev"
|
||||
}
|
||||
},
|
||||
"repositories": [{
|
||||
"repositories": [
|
||||
{
|
||||
"type": "path",
|
||||
"url": "../../*/*"
|
||||
}],
|
||||
},
|
||||
{
|
||||
"type": "path",
|
||||
"url": "tests"
|
||||
}
|
||||
],
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace Flarum\Testing\integration\Extension;
|
|||
use Flarum\Database\Migrator;
|
||||
use Flarum\Extension\Extension;
|
||||
use Flarum\Extension\ExtensionManager;
|
||||
use Flarum\Foundation\Config;
|
||||
use Flarum\Foundation\MaintenanceMode;
|
||||
use Flarum\Foundation\Paths;
|
||||
use Flarum\Settings\SettingsRepositoryInterface;
|
||||
|
@ -99,9 +100,13 @@ class ExtensionManagerIncludeCurrent extends ExtensionManager
|
|||
*/
|
||||
protected function getAssetsFilesystem(): Cloud
|
||||
{
|
||||
/** @var Config $config */
|
||||
$config = $this->container->make(Config::class);
|
||||
$adapter = new LocalFilesystemAdapter($this->paths->public.'/assets');
|
||||
|
||||
return new FilesystemAdapter(new \League\Flysystem\Filesystem($adapter), $adapter);
|
||||
return new FilesystemAdapter(new \League\Flysystem\Filesystem($adapter), $adapter, [
|
||||
'url' => $config->url().'/assets',
|
||||
]);
|
||||
}
|
||||
|
||||
protected function includeCurrentExtension(Collection $extensions, $package, string $packagePath): Collection
|
||||
|
|
3
php-packages/testing/tests/.gitignore
vendored
3
php-packages/testing/tests/.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
vendor/*
|
||||
vendor/*
|
||||
tests/.*.cache
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"description": "Minimal extension to test the flarum/testing package",
|
||||
"type": "flarum-extension",
|
||||
"require": {
|
||||
"flarum/core": "^0.1.0@dev"
|
||||
"flarum/core": "^2.0@dev"
|
||||
},
|
||||
"require-dev": {
|
||||
"flarum/testing": "*@dev"
|
||||
|
@ -13,6 +13,17 @@
|
|||
"Flarum\\Testing\\Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"flarum-extension": {
|
||||
"title": "Testing",
|
||||
"category": "feature",
|
||||
"icon": {
|
||||
"name": "fas fa-vial",
|
||||
"backgroundColor": "#ABDC88",
|
||||
"color": "#3F8A32"
|
||||
}
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"test": [
|
||||
"@test:unit",
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
C:37:"PHPUnit\Runner\DefaultTestResultCache":219:{a:2:{s:7:"defects";a:1:{s:74:"Flarum\Testing\Tests\integration\TestCaseTest::can_add_settings_via_method";i:4;}s:5:"times";a:1:{s:74:"Flarum\Testing\Tests\integration\TestCaseTest::can_add_settings_via_method";d:0.09;}}}
|
|
@ -10,17 +10,18 @@
|
|||
namespace Flarum\Testing\Tests\integration;
|
||||
|
||||
use Flarum\Extend;
|
||||
use Flarum\Extension\ExtensionManager;
|
||||
use Flarum\Foundation\Config;
|
||||
use Flarum\Settings\DefaultSettingsRepository;
|
||||
use Flarum\Settings\SettingsRepositoryInterface;
|
||||
use Flarum\Testing\integration\TestCase;
|
||||
use Flarum\User\User;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
class TestCaseTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function admin_user_created_as_part_of_default_state()
|
||||
{
|
||||
$this->app();
|
||||
|
@ -34,9 +35,7 @@ class TestCaseTest extends TestCase
|
|||
$this->assertTrue($user->isAdmin());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function can_add_settings_via_method()
|
||||
{
|
||||
$this->setting('hello', 'world');
|
||||
|
@ -48,20 +47,17 @@ class TestCaseTest extends TestCase
|
|||
$this->assertEquals('something_other_than_username', $settings->get('display_name_driver'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function settings_cleaned_up_from_previous_method()
|
||||
{
|
||||
$settings = $this->app()->getContainer()->make(SettingsRepositoryInterface::class);
|
||||
$defaults = $this->app()->getContainer()->make(DefaultSettingsRepository::class);
|
||||
|
||||
$this->assertEquals(null, $settings->get('hello'));
|
||||
$this->assertEquals(null, $settings->get('display_name_driver'));
|
||||
$this->assertEquals($defaults->get('display_name_driver'), $settings->get('display_name_driver'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function can_add_config_via_method()
|
||||
{
|
||||
$this->config('hello', 'world');
|
||||
|
@ -75,9 +71,7 @@ class TestCaseTest extends TestCase
|
|||
$this->assertEquals('value', $config['level1']['level2']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function config_cleaned_up_from_previous_method()
|
||||
{
|
||||
$config = $this->app()->getContainer()->make(Config::class);
|
||||
|
@ -87,9 +81,7 @@ class TestCaseTest extends TestCase
|
|||
$this->assertFalse(isset($config['level1']['level2']));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function current_extension_not_applied_by_default()
|
||||
{
|
||||
$response = $this->send(
|
||||
|
@ -99,9 +91,7 @@ class TestCaseTest extends TestCase
|
|||
$this->assertStringNotContainsString('notARealSetting', $response->getBody()->getContents());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function current_extension_applied_if_specified()
|
||||
{
|
||||
$this->extension('flarum-testing-tests');
|
||||
|
@ -113,9 +103,7 @@ class TestCaseTest extends TestCase
|
|||
$this->assertStringContainsString('notARealSetting', $response->getBody()->getContents());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function current_extension_migrations_applied_if_specified()
|
||||
{
|
||||
$this->extension('flarum-testing-tests');
|
||||
|
@ -124,9 +112,7 @@ class TestCaseTest extends TestCase
|
|||
$this->assertTrue($tableExists);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function current_extension_considered_enabled_after_boot()
|
||||
{
|
||||
$this->extension('flarum-testing-tests');
|
||||
|
@ -135,9 +121,7 @@ class TestCaseTest extends TestCase
|
|||
$this->assertTrue($enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function can_apply_extenders()
|
||||
{
|
||||
$this->extend(
|
||||
|
@ -151,9 +135,7 @@ class TestCaseTest extends TestCase
|
|||
$this->assertStringContainsString('notARealSetting', $response->getBody()->getContents());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function can_apply_route_extenders()
|
||||
{
|
||||
$this->extend(
|
||||
|
@ -167,9 +149,7 @@ class TestCaseTest extends TestCase
|
|||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function routes_added_by_current_extension_not_accessible_by_default()
|
||||
{
|
||||
$response = $this->send(
|
||||
|
@ -179,9 +159,7 @@ class TestCaseTest extends TestCase
|
|||
$this->assertEquals(404, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function routes_added_by_current_extension_accessible()
|
||||
{
|
||||
$this->extension('flarum-testing-tests');
|
||||
|
@ -193,14 +171,13 @@ class TestCaseTest extends TestCase
|
|||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
#[Test]
|
||||
public function extension_url_correct()
|
||||
{
|
||||
$this->extension('flarum-testing-tests');
|
||||
$expected = $this->app()->getContainer()->make('filesystem')->disk('flarum-assets')->url('/flarum-testing-tests/');
|
||||
// We need to test this since we override it.
|
||||
/** @var ExtensionManager $extensions */
|
||||
$extensions = $this->app()->getContainer()->make('flarum.extensions');
|
||||
$currExtension = $extensions->getExtension('flarum-testing-tests');
|
||||
$baseAssetsUrl = $extensions->getAsset($currExtension, '');
|
||||
|
|
|
@ -7,6 +7,6 @@
|
|||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
$setup = require __DIR__.'/../../../../php-packages/testing/bootstrap/monorepo.php';
|
||||
$setup = require __DIR__.'/../../../bootstrap/monorepo.php';
|
||||
|
||||
$setup->run();
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
colors="true"
|
||||
processIsolation="true"
|
||||
stopOnFailure="false"
|
||||
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
|
||||
bootstrap="../../bootstrap/monorepo.php"
|
||||
>
|
||||
<source>
|
||||
<include>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
colors="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
|
||||
bootstrap="../../bootstrap/monorepo.php"
|
||||
>
|
||||
<source>
|
||||
<include>
|
||||
|
|
Loading…
Reference in New Issue
Block a user