Skip to content

Commit

Permalink
Update to Atk4/Ui 2.4
Browse files Browse the repository at this point in the history
Update/2.4
  • Loading branch information
abbadon1334 authored Aug 1, 2021
2 parents b041f06 + bb0e537 commit 95e5846
Show file tree
Hide file tree
Showing 15 changed files with 1,195 additions and 117 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.min.css -text -filter
*.min.js -text -filter
89 changes: 54 additions & 35 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,65 @@
name: Unit Testing
# This is a basic workflow to help you get started with Actions

name: UnitTest

# Controls when the workflow will run
on:
pull_request
# Triggers the workflow on push or pull request events but only for the master branch
push:
pull_request:

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
unit-test:
name: Unit Testing
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
container:
image: atk4/image:latest # https://github.com/atk4/image
strategy:
fail-fast: false
matrix:
php: ['7.2', '7.3']
services:
mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: password
DB_DATABASE: db
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
php: ['7.3', '7.4']

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: MilesChou/composer-action@master
- name: Workaround composer failed opening composer.lock
run: |
sudo chown -R runner .
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
args: install
php-version: ${{ matrix.php }}
extensions: intl
tools: composer:v2 behat
coverage: xdebug

- name: Install dependencies and SQL
run: |
mkdir -p coverage
#mysql -uroot -ppassword -h mysql -e 'CREATE DATABASE atk4;'
#mysql -uroot -ppassword -h mysql atk4 < demos/atk4.sql
#mv demos/db.github.php demos/db.php
- name: Unit Testing
run: vendor/bin/phpunit --coverage-text --coverage-clover=coverage.xml

- name: Behat Testing
run: vendor/bin/behat

- name: Merge coverage logs
run: vendor/bin/phpcov merge build/logs/ --clover build/logs/cc.xml;

- uses: codecov/codecov-action@v1
- name: Install dependencies
run: composer install --prefer-dist

- name: PhpStan
run: vendor/bin/phpstan

- name: PHP-CS-Fixer
run: vendor/bin/php-cs-fixer fix

- name: PHPUnit (php-actions)
run: vendor/bin/phpunit

- uses: nanasess/setup-chromedriver@master
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: build/logs/cc.xml
chromedriver-version: '2.44'
- run: export DISPLAY=:99

- name: Behat
run: |
wget https://selenium-release.storage.googleapis.com/2.43/selenium-server-standalone-2.43.1.jar
java -jar selenium-server-standalone-2.43.1.jar > /dev/null 2>/dev/null &
php -S 0.0.0.0:8888 &
sleep 10
vendor/bin/behat
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/behat.yml
/config.codekit
/phpunit.xml
*.bak
Expand Down
72 changes: 72 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

$finder = PhpCsFixer\Finder::create()
->exclude([
'cache',
'build',
'vendor',
])
->in(__DIR__)
;

$config = new PhpCsFixer\Config();
$config->setRiskyAllowed(true)
->setRules([
'@PhpCsFixer' => true,
'@PhpCsFixer:risky' =>true,
'@PHP71Migration:risky' => true,
'@PHP73Migration' => true,

// required by PSR-12
'concat_space' => [
'spacing' => 'one',
],

// disable some too strict rules
'phpdoc_types' => [
// keep enabled, but without "alias" group to not fix
// "Callback" to "callback" in phpdoc
'groups' => ['simple', 'meta']
],
'phpdoc_types_order' => [
'null_adjustment' => 'always_last',
'sort_algorithm' => 'none',
],
'single_line_throw' => false,
'yoda_style' => [
'equal' => false,
'identical' => false,
],
'native_function_invocation' => false,
'non_printable_character' => [
'use_escape_sequences_in_strings' => true,
],
'void_return' => false,
'blank_line_before_statement' => [
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'exit'],
],
'combine_consecutive_issets' => false,
'combine_consecutive_unsets' => false,
'multiline_whitespace_before_semicolons' => false,
'no_superfluous_elseif' => false,
'ordered_class_elements' => false,
'php_unit_internal_class' => false,
'php_unit_test_case_static_method_calls' => [
'call_type' => 'this',
],
'php_unit_test_class_requires_covers' => false,
'phpdoc_add_missing_param_annotation' => false,
'return_assignment' => false,
'comment_to_phpdoc' => false,
'list_syntax' => ['syntax' => 'short'],
'general_phpdoc_annotation_remove' => [
'annotations' => ['author', 'copyright', 'throws'],
],
'nullable_type_declaration_for_default_null_value' => [
'use_nullable_type_declaration' => false,
],
])
->setFinder($finder)
->setCacheFile(__DIR__ . '/.php_cs.cache');

return $config;
24 changes: 24 additions & 0 deletions behat.yml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
default:
suites:
atk4_login:
paths:
features: '%paths.base%/tests-behat'
contexts:
- TextEditor\Behat\Context
- Behat\MinkExtension\Context\MinkContext
extensions:
Behat\MinkExtension:
show_cmd: 'open %s'
base_url: 'http://127.0.0.1:8888/demos/'
sessions:
default:
selenium2:
browser: chrome
wd_host: http://127.0.0.1:4444/wd/hub
capabilities:
chrome:
switches:
- "--headless"
- "--disable-gpu"
- "--window-size=1920,1080"
- "--no-sandbox"
67 changes: 35 additions & 32 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,37 @@
{
"name": "abbadon1334/atk4-trumbowyg",
"description": "ATK4 WYSIWYG editor using javascript library trumbowyg",
"minimum-stability": "dev",
"license": "MIT",
"authors": [
{
"name": "Francesco Danti",
"email": "fdanti@gmail.com"
}
],
"require": {
"atk4/ui": "^1.7.1"
},
"require-dev": {
"phpunit/phpunit": "<6",
"phpunit/phpcov": "^3.0",
"codeclimate/php-test-reporter": "*",
"behat/behat": "^3.4",
"behat/mink-selenium2-driver": "^1.3",
"behat/mink-extension": "^2.2",
"fzaninotto/faker": "*",
"guzzlehttp/guzzle": "^6.3",
"symfony/process": "^4.3"
},
"autoload": {
"psr-4": {"atk4\\ui\\FormField\\":"src/"}
},
"autoload-dev": {
"psr-4": {
"atk4\\ui\\tests\\":"tests/"
}
}
"name": "abbadon1334/atk4-trumbowyg",
"description": "ATK4 WYSIWYG editor using javascript library trumbowyg",
"license": "MIT",
"authors": [
{
"name": "Francesco Danti",
"email": "fdanti@gmail.com"
}
],
"require": {
"php": ">=7.3",
"atk4/ui": "2.4"
},
"require-dev": {
"behat/behat": "^3.8",
"behat/mink": "^1.8",
"behat/mink-extension": "^2.3.1",
"behat/mink-selenium2-driver": "^1.4",
"friendsofphp/php-cs-fixer": "^2.17",
"phpstan/phpstan": "^0.12.82",
"phpunit/phpunit": ">=9.3"
},
"autoload": {
"psr-4": {
"Atk4\\Ui\\Form\\Control\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"TextEditor\\Tests\\": "tests/",
"TextEditor\\Behat\\": "tests-behat/Bootstrap/"
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
36 changes: 36 additions & 0 deletions demos/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

namespace Atk4\Ui\Demos;

date_default_timezone_set('UTC');

require_once __DIR__ . '/../vendor/autoload.php';

use Atk4\Ui\App;
use Atk4\Ui\Layout\Centered;

$app = new App([
'title' => 'Agile toolkit WYSIWYG',
'call_exit' => false,
]);
$app->initLayout([Centered::class]);

$form = \Atk4\Ui\Form::addTo($app);
$form->addControl('subject');
$form->addControl('editor', [
\Atk4\Ui\Form\Control\TextEditor::class,
'placeholder' => 'test placeholder',
]);

$form->onSubmit(function ($f) {
$view = new \Atk4\Ui\Message();
$view->invokeInit();
$view->text->addParagraph('subject : ' . $f->model->get('subject'));
$view->text->addParagraph('editor : ' . $f->model->get('editor'));

return $view;
});

$app->run();
13 changes: 0 additions & 13 deletions demos/simple.php

This file was deleted.

14 changes: 14 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
includes:
- vendor/mahalux/atk4-hintable/phpstan-ext.neon

parameters:
level: 4
paths:
- ./
excludes_analyse:
- cache/
- build/
- vendor/

# TODO review once we drop PHP 7.x support
treatPhpDocTypesAsCertain: false
23 changes: 23 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" bootstrap="vendor/autoload.php" printerClass="Atk4\Core\AtkPhpunit\ResultPrinter" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
<report>
<php outputFile="build/logs/clover.cov"/>
</report>
</coverage>
<php>
<var name="DB_DSN" value="sqlite::memory:"/>
<var name="DB_USER" value=""/>
<var name="DB_PASSWD" value=""/>
<var name="DB_DBNAME" value=""/>
</php>
<testsuites>
<testsuite name="editor">
<directory>tests</directory>
</testsuite>
</testsuites>
<logging/>
</phpunit>
Loading

0 comments on commit 95e5846

Please sign in to comment.