Skip to content

Commit

Permalink
Releasing refs/heads/release/2.0.1 into master (#494)
Browse files Browse the repository at this point in the history
* wip

* wip

* fixes

* Feature/test1 (#483)

* fixes

* testtisg

* wip

* test

* backmerge master

* normalize everything

* added locale test (#485)

* added locale test

* Apply fixes from StyleCI

* wip

* wip

* Apply fixes from StyleCI

* Update CHANGELOG.md

* Implement #386 (#477)

* Implement #386

* Apply fixes from StyleCI

* Update Field.php

* Update Model.php

* Update Helper.php

* Apply fixes from StyleCI

* move functionality to atk4/core

* Apply fixes from StyleCI

* fix traits

* Apply fixes from StyleCI

* fix typo

* Feature/pgsql test (#486)

* fix one test

* Setting current dependencies

* wip

* wip

* Add matrix testing (#492)

* Test using matrix

* wip

* wip

* wip

* clean up bundler

* clean up bundler (#493)

* wip

* Setting current dependencies
  • Loading branch information
github-actions[bot] authored and romaninsh committed Dec 2, 2019
1 parent b1e941d commit 20e4eaf
Show file tree
Hide file tree
Showing 15 changed files with 144 additions and 135 deletions.
5 changes: 5 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# See https://github.com/release-drafter/release-drafter#configuration
categories:
- title: 'Enhancements'
labels:
- enhancement
template: |
## What’s Changed
Expand Down
39 changes: 28 additions & 11 deletions .github/workflows/bundler.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
name: Bundler

on:
create:
branches:
- 'release/*'
on: create

jobs:
autocommit:
name: Update to stable dependencies
if: startsWith(github.ref, 'refs/heads/release/')
runs-on: ubuntu-latest
container:
image: atk4/image:latest # https://github.com/atk4/image
steps:
- uses: actions/checkout@master
- run: |
sed -i -e '/atk4\/schema/s/dev-develop/\*/' composer.json
sed -i -e '/atk4\/dsql/d' composer.json
sed -i -e '/atk4\/core/d' composer.json
cat composer.json
composer require atk4/core atk4/dsql
composer update
- run: echo ${{ github.ref }}
- name: Update to stable dependencies
run: |
jq 'del(.require["atk4/core"]) | del(.require["atk4/dsql"]) | del(.["require-dev"]["atk4/schema"])' < composer.json > tmp && mv tmp composer.json
composer require --no-progress --no-suggest --prefer-dist --optimize-autoloader atk4/core atk4/dsql
composer require --no-progress --no-suggest --prefer-dist --optimize-autoloader --dev atk4/schema
composer update --no-progress --no-suggest --prefer-dist --optimize-autoloader
- uses: teaminkling/autocommit@master
with:
Expand All @@ -27,3 +26,21 @@ jobs:
with:
branch: ${{ github.ref }}
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: pull-request
uses: repo-sync/pull-request@v2
with:
source_branch: "" # If blank, default: triggered branch
destination_branch: "master" # If blank, default: master
pr_title: "Releasing ${{ github.ref }} into master"
pr_body: |
- [ ] Review changes (must include stable dependencies)
- [ ] Merge this PR into master (will delete ${{ github.ref }})
- [ ] Go to Releases and create TAG from master
----------
Do not merge master into develop
pr_reviewer: "romaninsh"
pr_assignee: "romaninsh"
github_token: ${{ secrets.GITHUB_TOKEN }}
69 changes: 7 additions & 62 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@ name: Unit Testing

on:
pull_request:
branches: '*'
push:
branches:
- 'feature/*'
- master
- develop

jobs:
unit-test:
name: Unit Testing
runs-on: ubuntu-latest
container:
image: atk4/image:latest # https://github.com/atk4/image
image: atk4/image:${{ matrix.php }} # https://github.com/atk4/image
strategy:
matrix:
php: ['7.3']
php: ['7.2', '7.3', 'latest']
services:
mysql:
image: mysql:5.7
Expand All @@ -29,6 +32,7 @@ jobs:
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v1
- run: php --version
- name: Get Composer Cache Directory
id: composer-cache
run: |
Expand Down Expand Up @@ -62,62 +66,3 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: build/logs/cc.xml


#
# build:
# runs-on: ubuntu-linux
# container:
# image: php:${{ matrix.php }}-alpine
# strategy:
# #max-parallel: 6
# matrix:
# #operating-system: [ubuntu-latest]
# #operating-system: [ubuntu-latest, windows-latest, macOS-latest]
# php: ['7.3']
#
# env:
# DB_DATABASE: db
# DB_USERNAME: root
# DB_PASSWORD: password
#
# services:
# mysql:
# image: mysql:5.7
# env:
# MYSQL_ALLOW_EMPTY_PASSWORD: false
# MYSQL_ROOT_PASSWORD: password
# MYSQL_DATABASE: db
# options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
# postgres:
# image: postgres:10-alpine
# env:
# POSTGRES_PASSWORD: password
# POSTGRES_USER: root
# options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
#
#
# steps:
# - uses: actions/checkout@v1
# - run: |
# apk add \
# unzip
# echo 'memory_limit=-1' >> /usr/local/etc/php/php.ini
# wget -qO - https://raw.githubusercontent.com/composer/getcomposer.org/fb22b78362d31c0d2bf516d1f8cdfd2745caa431/web/installer | php -- --install-dir=/usr/local/bin --filename=composer --quiet
#
# - name: Install dependencies
# run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
#
# - name: Test with phpunit and SQLite
# run: vendor/bin/phpunit --configuration phpunit.xml --coverage-text
#
# - name: Test with phpunit and MySQL
# run: vendor/bin/phpunit --configuration phpunit-mysql-workflow.xml --coverage-text
#
# - name: Merge logs
# run: vendor/bin/phpcov merge build/logs/ --clover build/logs/cc.xml;
#
# - name: Upload coverage to CodeCov
# uses: codecov/codecov-action@v1
# with:
# token: ${{ secrets.CODECOV_TOKEN }} #required
File renamed without changes.
4 changes: 1 addition & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

# 2.0

First major version update of ATK Data now includes support for "User Actions".

- TBC
see https://github.com/atk4/data/releases for further releases.


# 1.4
Expand Down
84 changes: 50 additions & 34 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,53 @@
{
"name": "atk4/data",
"type": "library",
"description": "Agile Data - Database access abstraction framework",
"keywords": ["framework", "orm", "query", "active record", "sql", "builder", "nosql", "mongodb", "mysql", "postgresql"],
"homepage": "https://github.com/atk4/data",
"license": "MIT",
"authors": [
{
"name": "Romans Malinovskis",
"email": "romans@agiletoolkit.org",
"homepage": "https://nearly.guru/"
}
],
"require": {
"php": ">=7.2.0",
"ext-intl": "*",
"atk4/core": "^1.3",
"atk4/dsql": "^1.2"
},
"require-dev": {
"atk4/schema": "*",
"phpunit/phpunit": "<6",
"phpunit/dbunit": ">=1.2",
"phpunit/phpcov": "*",
"codeclimate/php-test-reporter": "*"
},
"autoload": {
"psr-4": {"atk4\\data\\":"src/"}
},
"autoload-dev": {
"psr-4": {
"atk4\\data\\tests\\":"tests/",
"atk4\\data\\tests\\smbo\\":["tests/smbo","tests/smbo/lib"]
}
"name": "atk4/data",
"type": "library",
"description": "Agile Data - Database access abstraction framework",
"keywords": [
"framework",
"orm",
"query",
"active record",
"sql",
"builder",
"nosql",
"mongodb",
"mysql",
"postgresql"
],
"homepage": "https://github.com/atk4/data",
"license": "MIT",
"authors": [
{
"name": "Romans Malinovskis",
"email": "romans@agiletoolkit.org",
"homepage": "https://nearly.guru/"
}
],
"require": {
"php": ">=7.2.0",
"ext-intl": "*",
"atk4/core": "^2.0",
"atk4/dsql": "^2.0"
},
"require-dev": {
"phpunit/phpunit": "<6",
"phpunit/dbunit": ">=1.2",
"phpunit/phpcov": "*",
"codeclimate/php-test-reporter": "*",
"atk4/schema": "^2.0"
},
"autoload": {
"psr-4": {
"atk4\\data\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"atk4\\data\\tests\\": "tests/",
"atk4\\data\\tests\\smbo\\": [
"tests/smbo",
"tests/smbo/lib"
]
}
}
}
1 change: 1 addition & 0 deletions locale/en/atk.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
'Unable to serialize field value on save' => 'Unable to serialize field value on save ({{field}})',
'Unable to typecast field value on load' => 'Unable to typecast field value on load ({{field}})',
'Unable to typecast field value on save' => 'Unable to typecast field value on save ({{field}})',
'Record with specified ID was not found' => 'Record with specified ID was not found',
];
1 change: 1 addition & 0 deletions locale/ru/atk.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
'Unable to serialize field value on save' => 'Невозможно сериализовать значение поля при сохранении ({{field}})',
'Unable to typecast field value on load' => 'Невозможно установить тип поля при загрузке ({{field}})',
'Unable to typecast field value on save' => 'Невозможно сериализовать значение поля при сохранении ({{field}})',
'Record with specified ID was not found' => 'Запись с данным ID не найдена',
];
5 changes: 3 additions & 2 deletions src/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace atk4\data;

use atk4\core\DIContainerTrait;
use atk4\core\ReadableCaptionTrait;
use atk4\core\TrackableTrait;
use atk4\dsql\Expression;
use atk4\dsql\Expressionable;
Expand All @@ -16,6 +17,7 @@ class Field implements Expressionable
{
use TrackableTrait;
use DIContainerTrait;
use ReadableCaptionTrait;

// {{{ Properties

Expand Down Expand Up @@ -516,8 +518,7 @@ public function isHidden()
*/
public function getCaption()
{
return $this->caption ?: (isset($this->ui['caption']) ? $this->ui['caption'] :
ucwords(str_replace('_', ' ', $this->short_name)));
return $this->caption ?? $this->ui['caption'] ?? $this->readableCaption($this->short_name);
}

// }}}
Expand Down
24 changes: 5 additions & 19 deletions src/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use atk4\core\HookTrait;
use atk4\core\InitializerTrait;
use atk4\core\NameTrait;
use atk4\core\ReadableCaptionTrait;
use atk4\data\UserAction\Generic;
use atk4\dsql\Query;
use IteratorAggregate;
Expand All @@ -36,6 +37,7 @@ class Model implements ArrayAccess, IteratorAggregate
use FactoryTrait;
use AppScopeTrait;
use CollectionTrait;
use ReadableCaptionTrait;

// {{{ Properties of the class

Expand Down Expand Up @@ -898,23 +900,13 @@ public function get($field = null)

/**
* Return (possibly localized) $model->caption.
* If caption is not set, then generate it from model class name.
*
* @return string
*/
public function getModelCaption()
{
if ($this->caption) {
return $this->caption;
}

// if caption is not set, then generate it from model class name
$s = strtolower(get_class($this));
//$s = str_replace('model', '', $s);
$s = preg_split('/[\\\\_]/', $s, -1, PREG_SPLIT_NO_EMPTY);
$s = array_map('trim', $s);
$s = ucwords(implode(' ', $s));

return $s;
return $this->caption ?: $this->readableCaption(get_class($this));
}

/**
Expand Down Expand Up @@ -1040,13 +1032,7 @@ public function addAction($name, $defaults = []) : UserAction\Generic
}

if (!isset($defaults['caption'])) {
$s = $name;

$s = preg_split('/[\\\\_]/', $s, -1, PREG_SPLIT_NO_EMPTY);
$s = array_map('trim', $s);
$s = ucwords(implode(' ', $s));

$defaults['caption'] = $s;
$defaults['caption'] = $this->readableCaption($name);
}

/** @var UserAction\Generic $action */
Expand Down
2 changes: 1 addition & 1 deletion src/UserAction/Generic.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function execute(...$args)
}
} elseif ($this->fields !== false) {
throw new Exception([
'Arguments fields for the action must be either array or `false`.',
'Argument `fields` for the action must be either array or `false`.',
'fields'=> $this->fields,
]);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/DeepCopyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function init()
$this->addField('vat', ['type'=>'numeric', 'default'=>0.21]);

// total is calculated with VAT
$this->addExpression('total', '[qty]*[price]*(1+vat)');
$this->addExpression('total', '[qty]*[price]*(1+[vat])');
}
}

Expand Down
9 changes: 9 additions & 0 deletions tests/FieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,15 @@ public function testCaption()

$f = $m->addField('foo3', ['ui'=>['caption'=>'My Foo']]);
$this->assertEquals('My Foo', $f->getCaption());

$f = $m->addField('userDefinedEntity');
$this->assertEquals('User Defined Entity', $f->getCaption());

$f = $m->addField('newNASA_module');
$this->assertEquals('New NASA Module', $f->getCaption());

$f = $m->addField('this\\ _isNASA_MyBigBull shit_123\Foo');
$this->assertEquals('This Is NASA My Big Bull Shit 123 Foo', $f->getCaption());
}

/**
Expand Down

0 comments on commit 20e4eaf

Please sign in to comment.