Skip to content

Commit

Permalink
Adjust to atk4 3.0 (#76)
Browse files Browse the repository at this point in the history
Release sponsored by @mkrecek234, thanks!

Co-authored-by: DarkSide <[email protected]>
Co-authored-by: Michael Voříšek <[email protected]>
  • Loading branch information
3 people authored Oct 16, 2021
1 parent 2cc0910 commit 149b209
Show file tree
Hide file tree
Showing 48 changed files with 557 additions and 1,098 deletions.
1 change: 1 addition & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ categories:
- "Documentation :books:"
template: |
## What’s Changed
$CHANGES
2 changes: 1 addition & 1 deletion .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
name: Build Release
runs-on: ubuntu-latest
container:
image: atk4/image:latest
image: ghcr.io/mvorisek/image-php:latest
steps:
- uses: actions/checkout@v2
with:
Expand Down
297 changes: 242 additions & 55 deletions .github/workflows/test-unit.yml

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
docs/build
/build
/docs/build
/coverage
/vendor
/composer.lock
.idea
nbproject
.vscode
.DS_Store

local
*.local
*.local.*
cache
*.cache
*.cache.*

/demos/db.php
/demos/_demo-data/db.sqlite
/demos/_demo-data/db.sqlite-journal
/phpunit.xml
/phpunit-*.xml
/behat.yml

*.bak
/demos/data/db.sqlite
28 changes: 13 additions & 15 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
<?php

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

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

// required by PSR-12
'concat_space' => [
Expand All @@ -37,10 +36,8 @@
'equal' => false,
'identical' => false,
],
'native_constant_invocation' => true,
'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'],
Expand All @@ -58,15 +55,16 @@
'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,
],

// fn => without curly brackets is less readable,
// also prevent bounding of unwanted variables for GC
'use_arrow_functions' => false,
])
->setFinder($finder)
->setCacheFile(__DIR__ . '/.php_cs.cache');

return $config;
->setCacheFile(sys_get_temp_dir() . '/php-cs-fixer.' . md5(__DIR__) . '.cache');
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Here are all the classes implemented:
- Populates user menu with name of current user
- Adds log-out link
- Adds Preferences page
- [Flexible ACL support](docs/acl.md)
- Flexible ACL support
- Field\Password - password hashing, safety, generation and validation
- Model\User - basic user entity that can be extended
- LoginForm - username/password login form
Expand Down
7 changes: 3 additions & 4 deletions behat.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ default:
paths:
features: '%paths.base%/tests-behat'
contexts:
- Atk4\Login\Behat\Context
- Behat\MinkExtension\Context\MinkContext
- Atk4\Ui\Behat\Context
extensions:
Behat\MinkExtension:
show_cmd: 'open %s'
base_url: 'http://172.18.0.2:8888/demos'
base_url: 'http://172.18.0.2:8888/demos'
sessions:
default:
selenium2:
Expand All @@ -20,4 +19,4 @@ default:
chrome:
args:
- '--headless'
- '--window-size=1930,1200'
- '--window-size=1920,1200'
6 changes: 2 additions & 4 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
ignore:
- src/Behat
- demos
- docs
- template
- tests
- tests-behat
comment: false
coverage:
status:
project:
default:
target: auto
threshold: 0.1
threshold: 0.025
patch: false
changes: false
124 changes: 61 additions & 63 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,65 +1,63 @@
{
"name": "atk4/login",
"type": "library",
"description": "Login and User module for Agile UI",
"keywords": [
"user",
"acl",
"auth",
"login",
"atk4",
"agile",
"agile ui",
"data",
"framework"
],
"homepage": "https://github.com/atk4/login",
"license": "MIT",
"authors": [
{
"name": "Romans Malinovskis",
"email": "[email protected]",
"homepage": "https://nearly.guru/"
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"sort-packages": true
},
"require": {
"php": ">=7.3.0",
"atk4/ui": "2.4.*",
"atk4/data": "2.4.*"
},
"require-release": {
"php": ">=7.3.0",
"atk4/ui": "~2.4.0"
},
"require-dev": {
"behat/behat": "^3.8",
"behat/mink": "^1.8",
"behat/mink-extension": "^2.3.1",
"behat/mink-selenium2-driver": "^1.4",
"ergebnis/composer-normalize": "^2.13",
"friendsofphp/php-cs-fixer": "^2.17",
"johnkary/phpunit-speedtrap": "^3.2",
"instaclick/php-webdriver": "^1.4.7",
"phpstan/phpstan": "^0.12.82",
"phpunit/phpcov": "*",
"phpunit/phpunit": ">=9.3",
"symfony/contracts": ">=1.1"
},
"autoload": {
"psr-4": {
"Atk4\\Login\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Atk4\\Login\\Behat\\": "tests-behat/Bootstrap/",
"Atk4\\Login\\Demo\\": "demos/src/",
"Atk4\\Login\\Tests\\": "tests/"
}
}
"name": "atk4/login",
"type": "library",
"description": "Login and User module for Agile UI",
"keywords": [
"user",
"acl",
"auth",
"login",
"atk4",
"agile",
"agile ui",
"data",
"framework"
],
"homepage": "https://github.com/atk4/login",
"license": "MIT",
"authors": [
{
"name": "Romans Malinovskis",
"email": "[email protected]",
"homepage": "https://nearly.guru/"
},
{
"name": "Michael Voříšek",
"homepage": "https://mvorisek.cz/"
}
],
"require": {
"php": ">=7.4 <8.2",
"atk4/ui": "~3.0.0"
},
"require-dev": {
"behat/behat": "^3.8.2 || dev-master#6f38d11",
"behat/gherkin": "^4.8.1 || dev-master#5fbf806",
"behat/mink": "^1.8.2 || dev-master#1ab79d6",
"behat/mink-extension": "^2.3.1",
"behat/mink-selenium2-driver": "^1.4",
"ergebnis/composer-normalize": "^2.13",
"friendsofphp/php-cs-fixer": "^3.0",
"instaclick/php-webdriver": "^1.4.7",
"johnkary/phpunit-speedtrap": "^3.3",
"phpstan/phpstan": "^0.12.82",
"phpunit/phpcov": "*",
"phpunit/phpunit": "^9.5.5",
"symfony/contracts": ">=1.1"
},
"config": {
"sort-packages": true
},
"autoload": {
"psr-4": {
"Atk4\\Login\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Atk4\\Login\\Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,40 @@

namespace Atk4\Login\Demos;

include __DIR__ . '/../../vendor/autoload.php';
use Atk4\Data\Model;
use Atk4\Schema\Migration;

$sqliteFile = __DIR__ . '/../data/db.sqlite';
if (file_exists($sqliteFile)) {
unlink($sqliteFile);
require_once __DIR__ . '/../init-autoloader.php';

$sqliteFile = __DIR__ . '/db.sqlite';
if (!file_exists($sqliteFile)) {
new \Atk4\Data\Persistence\Sql('sqlite:' . $sqliteFile);
}
unset($sqliteFile);

/** @var \Atk4\Data\Persistence\Sql $db */
require_once __DIR__ . '/../init-db.php';

$persistence = new \Atk4\Data\Persistence\Sql('sqlite:' . $sqliteFile);
$model = new \Atk4\Data\Model($persistence, ['table' => 'login_user']);
$model = new Model($db, ['table' => 'login_user']);
$model->addField('name', ['type' => 'string']);
$model->addField('email', ['type' => 'string']);
$model->addField('password', ['type' => 'string']);
$model->addField('role_id', ['type' => 'integer']);
(new \Atk4\Schema\Migration($model))->dropIfExists()->create();
(new Migration($model))->create();
$model->import([
1 => ['id' => 1, 'name' => 'Standard User', 'email' => 'user', 'password' => '$2y$10$BwEhcP8f15yOexf077VTHOnySn/mit49ZhpfeBkORQhrsmHr4U6Qy', 'role_id' => 1], // user/user
2 => ['id' => 2, 'name' => 'Administrator', 'email' => 'admin', 'password' => '$2y$10$p34ciRcg9GZyxukkLIaEnenGBao79fTFa4tFSrl7FvqrxnmEGlD4O', 'role_id' => 2], // admin/admin
]);

$model = new \Atk4\Data\Model($persistence, ['table' => 'login_role']);
$model = new Model($db, ['table' => 'login_role']);
$model->addField('name', ['type' => 'string']);
(new \Atk4\Schema\Migration($model))->dropIfExists()->create();
(new Migration($model))->create();
$model->import([
1 => ['id' => 1, 'name' => 'User Role'],
2 => ['id' => 2, 'name' => 'Admin Role'],
]);

$model = new \Atk4\Data\Model($persistence, ['table' => 'login_access_role']);
$model = new Model($db, ['table' => 'login_access_role']);
$model->addField('role_id', ['type' => 'integer']);
$model->addField('model', ['type' => 'string']);
$model->addField('all_visible', ['type' => 'boolean']);
Expand All @@ -42,11 +48,11 @@
$model->addField('actions', ['type' => 'boolean']);
$model->addField('conditions', ['type' => 'boolean']);

(new \Atk4\Schema\Migration($model))->dropIfExists()->create();
(new Migration($model))->create();
$model->import([
1 => ['id' => 1, 'role_id' => 1, 'model' => '\\Atk4\Login\\Model\\User', 'all_visible' => 1, 'visible_fields' => null, 'all_editable' => 0, 'editable_fields' => null, 'all_actions' => 1, 'actions' => null, 'conditions' => null],
2 => ['id' => 2, 'role_id' => 2, 'model' => '\\Atk4\Login\\Model\\User', 'all_visible' => 1, 'visible_fields' => null, 'all_editable' => 1, 'editable_fields' => null, 'all_actions' => 1, 'actions' => null, 'conditions' => null],
3 => ['id' => 3, 'role_id' => 2, 'model' => '\\Atk4\Login\\Model\\Role', 'all_visible' => 1, 'visible_fields' => null, 'all_editable' => 1, 'editable_fields' => null, 'all_actions' => 1, 'actions' => null, 'conditions' => null],
]);

echo 'import complete!' . "\n";
echo 'import complete!' . "\n\n";
4 changes: 2 additions & 2 deletions demos/src/App.php → demos/_includes/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Atk4\Login\Demo;
namespace Atk4\Login\Demos;

use Atk4\Login\Acl;
use Atk4\Login\Auth;
Expand All @@ -11,7 +11,7 @@
/**
* Example implementation of your Authenticated application.
*/
class App extends AbstractApp
class App extends \Atk4\Ui\App
{
public $auth;
public $title = 'Demo App';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Atk4\Login\Demo;
namespace Atk4\Login\Demos;

use Atk4\Core\AppScopeTrait;
use Atk4\Core\DynamicMethodTrait;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Atk4\Login\Demo\Model;
namespace Atk4\Login\Demos\Model;

use Atk4\Data\Model;

Expand Down
2 changes: 1 addition & 1 deletion demos/acl-clients.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Atk4\Login\Demo;
namespace Atk4\Login\Demos;

use Atk4\Ui\Crud;
use Atk4\Ui\Header;
Expand Down
Loading

0 comments on commit 149b209

Please sign in to comment.