Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@ jobs:
cs:
uses: bedita/github-workflows/.github/workflows/php-cs.yml@v2
with:
php_versions: '["8.4"]'
php_versions: '["8.5"]'

psalm:
uses: bedita/github-workflows/.github/workflows/php-psalm.yml@v2
with:
php_versions: '["8.5"]'

stan:
uses: bedita/github-workflows/.github/workflows/php-stan.yml@v2
with:
php_versions: '["8.4"]'
php_versions: '["8.5"]'

unit:
name: 'Run unit tests'
Expand All @@ -38,7 +43,7 @@ jobs:

strategy:
matrix:
php-version: [8.3, 8.4]
php-version: [8.3, 8.4, 8.5]

steps:
- name: 'Checkout current revision'
Expand Down
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ build:
analysis:
environment:
php:
version: 8.3.3
version: 8.3.16
tests:
override:
- php-scrutinizer-run
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![Github Actions](https://github.com/bedita/import-tools/workflows/php/badge.svg)](https://github.com/bedita/import-tools/actions?query=workflow%3Aphp)
[![codecov](https://codecov.io/gh/bedita/import-tools/branch/main/graph/badge.svg)](https://codecov.io/gh/bedita/import-tools)
[![phpstan](https://img.shields.io/badge/PHPStan-level%205-brightgreen.svg)](https://phpstan.org)
[![psalm](https://img.shields.io/badge/psalm-level%208-brightgreen.svg)](https://psalm.dev)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/bedita/import-tools/badges/quality-score.png?b=main)](https://scrutinizer-ci.com/g/bedita/import-tools/?branch=main)
[![image](https://img.shields.io/packagist/v/bedita/import-tools.svg?label=stable)](https://packagist.org/packages/bedita/import-tools)
[![image](https://img.shields.io/github/license/bedita/import-tools.svg)](https://github.com/bedita/import-tools/blob/main/LICENSE.LGPL)
Expand Down
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^1.12",
"phpstan/phpstan-deprecation-rules": "^1.2",
"phpunit/phpunit": "^11.1.3"
"phpunit/phpunit": "^11.1.3",
"vimeo/psalm": "^6.8"
},
"autoload": {
"psr-4": {
Expand All @@ -53,8 +54,10 @@
],
"cs-check": "vendor/bin/phpcs --colors -p --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests",
"cs-fix": "vendor/bin/phpcbf --colors --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests",
"psalm": "vendor/bin/psalm",
"stan": "vendor/bin/phpstan analyse",
"test": "vendor/bin/phpunit --colors=always",
"stan": "vendor/bin/phpstan analyse"
"coverage": "vendor/bin/phpunit --colors=always --coverage-html coverage"
},
"prefer-stable": true,
"config": {
Expand Down
23 changes: 23 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0"?>
<psalm
errorLevel="8"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
findUnusedBaselineEntry="true"
findUnusedCode="false"
>
<issueHandlers>
<ClassMustBeFinal errorLevel="suppress" />
<MissingOverrideAttribute errorLevel="suppress" />
<ImplicitToStringCast errorLevel="suppress" />
<UndefinedConstant errorLevel="suppress" />
</issueHandlers>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>
2 changes: 1 addition & 1 deletion src/Command/AnonymizeUsersCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ protected function objectsGenerator(Query $query, Table $table, int $limit = 100
break;
}
foreach ($results as $entity) {
$lastId = $entity->id;
$lastId = $entity->get('id');

yield $entity;
}
Expand Down
6 changes: 4 additions & 2 deletions src/Command/TranslateObjectsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,9 @@ public function objectsIterator(array $conditions, string $lang, string $to): it
/** @var \BEdita\Core\Model\Table\ObjectsTable $table */
$table = $this->fetchTable('objects');
if ($this->type !== null) {
$conditions[$table->aliasField('object_type_id')] = $table->objectType($this->type)->id;
/** @var \BEdita\Core\Model\Behavior\ObjectTypeBehavior $objectTypeBehavior */
$objectTypeBehavior = $table->getBehavior('ObjectType');
$conditions[$table->aliasField('object_type_id')] = $objectTypeBehavior->objectType($this->type)->id;
}
$conditions = array_merge(
$conditions,
Expand All @@ -334,7 +336,7 @@ public function objectsIterator(array $conditions, string $lang, string $to): it
}

foreach ($results as $entity) {
$lastId = $entity->id;
$lastId = $entity->get('id');

yield $entity;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Utility/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public function saveObject(array $obj): ObjectEntity
),
);
}
$entity = $o->getTable()->find('type', [$this->type])->where($conditions)->firstOrFail();
$entity = $o->getTable()->find('type', value: [$this->type])->where($conditions)->firstOrFail();
}
}
/** @var \BEdita\Core\Model\Entity\ObjectEntity $entity */
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/Command/ImportCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ public function testBuildOptionParser(): void
$this->assertOutputContains('--parent, -p');
$this->assertOutputContains('destination folder uname');
$this->assertOutputContains('--quiet, -q');
$this->assertOutputContains('Enable quiet output.');
$this->assertOutputContains('Enable quiet output');
$this->assertOutputContains('--type, -t');
$this->assertOutputContains('entity type to import <comment>(required)</comment>');
$this->assertOutputContains('--verbose, -v');
$this->assertOutputContains('Enable verbose output.');
$this->assertOutputContains('Enable verbose output');
}

/**
Expand Down
14 changes: 13 additions & 1 deletion tests/TestCase/Command/TranslateObjectsCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,19 @@ public function translate(ObjectEntity $object, string $from, string $to): void
*/
public function testObjectsIterator(): void
{
$this->markTestIncomplete('Not implemented yet.');
$cmd = new class () extends TranslateObjectsCommand {
public function __construct()
{
parent::__construct();
$this->type = 'users';
}
};
$catch = false;
$conditions = [];
foreach ($cmd->objectsIterator($conditions, 'en', 'it') as $object) {
$catch = true;
}
static::assertFalse($catch, 'objectsIterator find no users');
}

/**
Expand Down
10 changes: 5 additions & 5 deletions tests/TestCase/Utility/CsvTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
namespace BEdita\ImportTools\Test\TestCase\Utility;

use BEdita\ImportTools\Utility\CsvTrait;
use BEdita\ImportTools\Utility\XmlTrait;
use BEdita\ImportTools\Utility\FileTrait;
use Cake\TestSuite\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\UsesClass;
use PHPUnit\Framework\Attributes\CoversTrait;
use PHPUnit\Framework\Attributes\UsesTrait;
use RuntimeException;

/**
* {@see \BEdita\ImportTools\Utility\CsvTrait} Test Case
*/
#[CoversClass(CsvTrait::class)]
#[UsesClass(XmlTrait::class)]
#[CoversTrait(CsvTrait::class)]
#[UsesTrait(FileTrait::class)]
class CsvTraitTest extends TestCase
{
use CsvTrait;
Expand Down
12 changes: 8 additions & 4 deletions tests/TestCase/Utility/ReadTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,23 @@
*/
namespace BEdita\ImportTools\Test\TestCase\Utility;

use BEdita\ImportTools\Utility\CsvTrait;
use BEdita\ImportTools\Utility\FileTrait;
use BEdita\ImportTools\Utility\ReadTrait;
use BEdita\ImportTools\Utility\XmlTrait;
use Cake\TestSuite\TestCase;
use InvalidArgumentException;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\UsesClass;
use PHPUnit\Framework\Attributes\CoversTrait;
use PHPUnit\Framework\Attributes\UsesTrait;
use RuntimeException;

/**
* {@see \BEdita\ImportTools\Utility\ReadTrait} Test Case
*/
#[CoversClass(ReadTrait::class)]
#[UsesClass(XmlTrait::class)]
#[CoversTrait(ReadTrait::class)]
#[UsesTrait(CsvTrait::class)]
#[UsesTrait(XmlTrait::class)]
#[UsesTrait(FileTrait::class)]
class ReadTraitTest extends TestCase
{
use ReadTrait;
Expand Down