Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CI #220

Merged
merged 1 commit into from
May 7, 2024
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
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ on: [push]

jobs:
tests:
name: PHP ${{ matrix.php }}
name: 'PHP ${{ matrix.php }} (Composer Flags: ${{ matrix.composer }})'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [8.1]
php: [8.1, 8.2, 8.3]
composer: ['--prefer-stable', '--prefer-lowest']
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -22,7 +23,7 @@ jobs:
uses: actions/checkout@v3

- name: Install the dependencies
run: composer install --no-interaction --no-progress
run: composer update --no-interaction --no-suggest ${{ matrix.composer }}

- name: Run the unit tests
run: vendor/bin/phpunit --colors=always
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"autoload-dev": {
"psr-4": {
"Codefog\\Hastebundle\\Tests\\": "tests/"
"Codefog\\HasteBundle\\Tests\\": "tests/"
}
},
"extra": {
Expand All @@ -49,7 +49,8 @@
"allow-plugins": {
"contao-components/installer": true,
"contao/manager-plugin": true,
"php-http/discovery": false
"php-http/discovery": false,
"terminal42/contao-build-tools": true
}
},
"scripts": {
Expand Down
15 changes: 7 additions & 8 deletions src/DcaRelationsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ class DcaRelationsManager
private array $searchableFields = [];

/**
* This cache stores the table and record ID that has been already purged.
* It allows you to have multiple fields with the same relation in one DCA
* and prevents the earlier field values to be removed by the last one
* (the helper table is purged only once in this case, for the first field).
* This cache stores the table and record ID that has been already purged. It
* allows you to have multiple fields with the same relation in one DCA and
* prevents the earlier field values to be removed by the last one (the helper
* table is purged only once in this case, for the first field).
*/
private array $purgeCache = [];

/**
* This cache is in fact a hotfix for the "override all" mode. It simply
* does not allow the last record to be double-saved.
* This cache is in fact a hotfix for the "override all" mode. It simply does not
* allow the last record to be double-saved.
*/
private array $overrideAllCache = [];

Expand Down Expand Up @@ -848,8 +848,7 @@ public function getRelation(string $table, string $fieldName): array|null

/**
* Get the relations table name in the following format (sorted alphabetically):
* Parameters: tl_table_one, tl_table_two
* Returned value: tl_table_one_table_two.
* Parameters: tl_table_one, tl_table_two Returned value: tl_table_one_table_two.
*/
public function getTableName(string $tableOne, string $tableTwo): string
{
Expand Down
3 changes: 2 additions & 1 deletion src/EventListener/DcaDateRangeFilterListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ public function onPanelCallback(DataContainer $dc): string
}

/**
* On data container load callback. Filters the records by setting sorting->root if filters are set.
* On data container load callback. Filters the records by setting sorting->root
* if filters are set.
*/
public function onLoadCallback(DataContainer $dc): void
{
Expand Down
19 changes: 11 additions & 8 deletions src/EventListener/InsertTagsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public function __invoke(string $tag): mixed
*
* Description:
*
* The source_format and target_format can be any format from php date()
* or "date", "datim" or "time" to take the the format from the root page settings
* The source_format and target_format can be any format from php date() or
* "date", "datim" or "time" to take the the format from the root page settings
* (or system settings, in case not defined).
*
* Possible use cases:
Expand Down Expand Up @@ -84,11 +84,14 @@ private function replaceConvertedDateFormat(array $chunks): string|false
*
* {{formatted_datetime::timestamp}}
* or
* {{formatted_datetime::timestamp::datim}} - formats a given timestamp with the global date and time (datim) format
* {{formatted_datetime::timestamp::date}} - formats a given timestamp with the global date format
* {{formatted_datetime::timestamp::time}} - formats a given timestamp with the global time format
* {{formatted_datetime::timestamp::Y-m-d H:i}} - formats a given timestamp with the specified format
* {{formatted_datetime::+1 day::Y-m-d H:i}} - formats a given php date/time format (see http://php.net/manual/en/function.strtotime.php) with the specified format
* {{formatted_datetime::timestamp::datim}} - formats a given timestamp with the
* global date and time (datim) format {{formatted_datetime::timestamp::date}} -
* formats a given timestamp with the global date format
* {{formatted_datetime::timestamp::time}} - formats a given timestamp with the
* global time format {{formatted_datetime::timestamp::Y-m-d H:i}} - formats a
* given timestamp with the specified format {{formatted_datetime::+1 day::Y-m-d
* H:i}} - formats a given php date/time format (see
* http://php.net/manual/en/function.strtotime.php) with the specified format
*/
private function replaceFormattedDateTime(array $chunks): string
{
Expand Down Expand Up @@ -149,7 +152,7 @@ private function replaceOptionsLabel(array $chunks): string
{
$value = $chunks[2];

if (null === ($field = FormFieldModel::findByPk($chunks[1]))) {
if (null === ($field = FormFieldModel::findById($chunks[1]))) {
return $value;
}

Expand Down
16 changes: 10 additions & 6 deletions src/Form/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ public function getBoundEntity(): object|null
}

/**
* Binds a Doctrine entity to the form. If there is data, haste form will add the present values as default values.
* Binds a Doctrine entity to the form. If there is data, haste form will add the
* present values as default values.
*/
public function setBoundEntity(object $boundEntity, PropertyAccessor|null $propertyAccessor = null): self
{
Expand All @@ -176,7 +177,8 @@ public function getBoundModel(): Model|null
}

/**
* Binds a model instance to the form. If there is data, haste form will add the present values as default values.
* Binds a model instance to the form. If there is data, haste form will add the
* present values as default values.
*/
public function setBoundModel(Model $boundModel): self
{
Expand Down Expand Up @@ -585,9 +587,10 @@ public function addFieldsFromDca(string $table, callable|null $callback = null):
/**
* Return true if the field has "inputType" set, false otherwise.
*
* This is a default callback that can be used with addFieldsFromDca() method. It prevents from adding fields
* that do not have inputType specified which would result in an exception. The fields you typically would
* like to skip are: id, tstamp, pid, sorting.
* This is a default callback that can be used with addFieldsFromDca() method. It
* prevents from adding fields that do not have inputType specified which would
* result in an exception. The fields you typically would like to skip are: id,
* tstamp, pid, sorting.
*/
public function skipFieldsWithoutInputType(string $fieldName, array $fieldConfig): bool
{
Expand Down Expand Up @@ -630,7 +633,8 @@ public function addFieldsFromFormGenerator(int $formId, callable|null $callback
}

/**
* Adds a form field from the form generator without trying to convert a DCA configuration.
* Adds a form field from the form generator without trying to convert a DCA
* configuration.
*/
public function addFieldFromFormGenerator(string $fieldName, array $fieldConfig, ArrayPosition|null $position = null): self
{
Expand Down
2 changes: 1 addition & 1 deletion tests/CodefogHasteBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Codefog\Hastebundle\Tests;
namespace Codefog\HasteBundle\Tests;

use Codefog\HasteBundle\CodefogHasteBundle;
use PHPUnit\Framework\TestCase;
Expand Down
15 changes: 15 additions & 0 deletions tests/Fixtures/DataContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,19 @@

class DataContainer
{
private array $keys = [];

public function __construct()
{
}

public function __set($strKey, $varValue): void
{
$this->keys[$strKey] = $varValue;
}

public function __get($strKey): mixed
{
return $this->keys[$strKey] ?? null;
}
}
2 changes: 1 addition & 1 deletion tests/Fixtures/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Codefog\Hastebundle\Tests\Fixtures;
namespace Codefog\HasteBundle\Tests\Fixtures;

class Entity
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/Input.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Codefog\Hastebundle\Tests\Fixtures;
namespace Codefog\HasteBundle\Tests\Fixtures;

class Input
{
Expand Down
4 changes: 2 additions & 2 deletions tests/Fixtures/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Codefog\Hastebundle\Tests\Fixtures;
namespace Codefog\HasteBundle\Tests\Fixtures;

class Model
{
Expand All @@ -18,7 +18,7 @@ public function __set(string $key, mixed $value): void
$this->data[$key] = $value;
}

public static function findByPk(int $id): static
public static function findById(int $id): static
{
$model = new static();
$model->id = $id;
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/PageModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Codefog\Hastebundle\Tests\Fixtures;
namespace Codefog\HasteBundle\Tests\Fixtures;

use Contao\Model;

Expand Down
13 changes: 0 additions & 13 deletions tests/Fixtures/System.php

This file was deleted.

2 changes: 1 addition & 1 deletion tests/Fixtures/Widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Codefog\Hastebundle\Tests\Fixtures;
namespace Codefog\HasteBundle\Tests\Fixtures;

class Widget
{
Expand Down
15 changes: 11 additions & 4 deletions tests/Form/FormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

declare(strict_types=1);

namespace Codefog\Hastebundle\Tests\Form;
namespace Codefog\HasteBundle\Tests\Form;

use Codefog\HasteBundle\Form\Form;
use Codefog\Hastebundle\Tests\Fixtures\Entity;
use Codefog\Hastebundle\Tests\Fixtures\FormTextField;
use Codefog\HasteBundle\Tests\Fixtures\Entity;
use Codefog\HasteBundle\Tests\Fixtures\FormTextField;
use Contao\Input;
use Contao\PageModel;
use Contao\System;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\HttpFoundation\RequestStack;

class FormTest extends TestCase
{
Expand Down Expand Up @@ -119,7 +122,7 @@ public function testBoundModelDefaultValues(): void
{
$form = $this->createForm(false);

$pageModel = PageModel::findByPk(13);
$pageModel = PageModel::findById(13);
$pageModel->pageTitle = 'My page';
$pageModel->jumpTo = 11;
$form->setBoundModel($pageModel);
Expand Down Expand Up @@ -148,6 +151,10 @@ private function createForm(bool $isSubmitted = true): Form
$GLOBALS['TL_MODELS']['tl_page'] = PageModel::class;
$GLOBALS['TL_FFL']['text'] = FormTextField::class;

$container = new Container();
$container->set('request_stack', new RequestStack());
System::setContainer($container);

return new Form('my-form-id', 'POST', static fn () => $isSubmitted);
}
}
6 changes: 3 additions & 3 deletions tests/StringParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Codefog\Hastebundle\Tests;
namespace Codefog\HasteBundle\Tests;

use Codefog\HasteBundle\StringParser;
use PHPUnit\Framework\TestCase;
Expand All @@ -20,7 +20,7 @@ public function testFlatten(mixed $value, string $key, array $data, array $expec
$this->assertSame($expected, $data);
}

public function flattenDataProvider()
public static function flattenDataProvider(): iterable
{
return [
// String input will set key and value
Expand Down Expand Up @@ -83,8 +83,8 @@ public function flattenDataProvider()
'foo',
[],
[
'foo_bar' => 'baz',
'foo_bar_baz' => '1',
'foo_bar' => 'baz',
'foo' => '',
],
],
Expand Down
6 changes: 3 additions & 3 deletions tests/UrlParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Codefog\Hastebundle\Tests;
namespace Codefog\HasteBundle\Tests;

use Codefog\HasteBundle\UrlParser;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -44,7 +44,7 @@ public function testRemoveQueryStringCallback($request, $paramsToRemove, $expect
$this->assertSame($expectedResult, $actualResult);
}

public function addQueryStringProvider()
public static function addQueryStringProvider(): iterable
{
// current request -> query to add -> expected result
return [
Expand Down Expand Up @@ -121,7 +121,7 @@ public function addQueryStringProvider()
];
}

public function removeQueryStringProvider()
public static function removeQueryStringProvider(): iterable
{
// current request -> query to remove -> expected result
return [
Expand Down
2 changes: 1 addition & 1 deletion tests/Util/ArrayPositionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Codefog\Hastebundle\Tests\Util;
namespace Codefog\HasteBundle\Tests\Util;

use Codefog\HasteBundle\Util\ArrayPosition;
use PHPUnit\Framework\TestCase;
Expand Down
Loading