mirror of
https://github.com/flarum/core.git
synced 2025-08-02 14:37:49 +02:00
Add automated tests for flarum/testing
This commit is contained in:
committed by
SychO9
parent
1fbf5fd029
commit
9ed29cd35e
83
php-packages/testing/.github/workflows/test.yml
vendored
Normal file
83
php-packages/testing/.github/workflows/test.yml
vendored
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
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
|
@@ -20,6 +20,11 @@
|
|||||||
"Flarum\\Testing\\": "src/"
|
"Flarum\\Testing\\": "src/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"autoload-dev": {
|
||||||
|
"psr-4": {
|
||||||
|
"Flarum\\Testing\\Tests\\": "src/tests/"
|
||||||
|
}
|
||||||
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "0.1.x-dev"
|
"dev-master": "0.1.x-dev"
|
||||||
|
1
php-packages/testing/tests/.gitignore
vendored
Normal file
1
php-packages/testing/tests/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
vendor/*
|
1
php-packages/testing/tests/README.md
Normal file
1
php-packages/testing/tests/README.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
A minimal extension skeleton to test the flarum/testing package.
|
35
php-packages/testing/tests/composer.json
Normal file
35
php-packages/testing/tests/composer.json
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"name": "flarum/testing-tests",
|
||||||
|
"description": "Minimal extension to test the flarum/testing package",
|
||||||
|
"type": "flarum-extension",
|
||||||
|
"require": {
|
||||||
|
"flarum/core": "^0.1.0-beta.16"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"flarum/testing": "*@dev"
|
||||||
|
},
|
||||||
|
"autoload-dev": {
|
||||||
|
"psr-4": {
|
||||||
|
"Flarum\\Testing\\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"
|
||||||
|
},
|
||||||
|
"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."
|
||||||
|
},
|
||||||
|
"repositories": [{
|
||||||
|
"type": "path",
|
||||||
|
"url": "../"
|
||||||
|
}]
|
||||||
|
}
|
20
php-packages/testing/tests/extend.php
Normal file
20
php-packages/testing/tests/extend.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of flarum/testing-tests.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2021 .
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE.md
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Flarum\Testing;
|
||||||
|
|
||||||
|
use Flarum\Extend;
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
];
|
1
php-packages/testing/tests/tests/.phpunit.result.cache
Normal file
1
php-packages/testing/tests/tests/.phpunit.result.cache
Normal file
@@ -0,0 +1 @@
|
|||||||
|
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;}}}
|
0
php-packages/testing/tests/tests/fixtures/.gitkeep
vendored
Normal file
0
php-packages/testing/tests/tests/fixtures/.gitkeep
vendored
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Flarum\Testing\Tests\integration;
|
||||||
|
|
||||||
|
use Flarum\Settings\SettingsRepositoryInterface;
|
||||||
|
use Flarum\Testing\integration\TestCase;
|
||||||
|
|
||||||
|
class TestCaseTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function can_add_settings_via_method()
|
||||||
|
{
|
||||||
|
$this->setting('hello', 'world');
|
||||||
|
$this->setting('display_name_driver', 'something_other_than_username');
|
||||||
|
|
||||||
|
$settings = $this->app()->getContainer()->make(SettingsRepositoryInterface::class);
|
||||||
|
|
||||||
|
$this->assertEquals('world', $settings->get('hello'));
|
||||||
|
$this->assertEquals('something_other_than_username', $settings->get('display_name_driver'));
|
||||||
|
}
|
||||||
|
}
|
16
php-packages/testing/tests/tests/integration/setup.php
Normal file
16
php-packages/testing/tests/tests/integration/setup.php
Normal file
@@ -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();
|
24
php-packages/testing/tests/tests/phpunit.integration.xml
Normal file
24
php-packages/testing/tests/tests/phpunit.integration.xml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?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>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
|
</phpunit>
|
27
php-packages/testing/tests/tests/phpunit.unit.xml
Normal file
27
php-packages/testing/tests/tests/phpunit.unit.xml
Normal file
@@ -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>
|
0
php-packages/testing/tests/tests/unit/.gitkeep
Normal file
0
php-packages/testing/tests/tests/unit/.gitkeep
Normal file
Reference in New Issue
Block a user