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
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ indent_style = tab
indent_size = tab
tab_width = 4

[{*.json, *.yaml, *.yml, *.md}]
[*.{json,yaml,yml,md}]
indent_style = space
indent_size = 2
6 changes: 3 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Not archived
.docs export-ignore
tests export-ignore
.github export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.travis.yml export-ignore
Makefile export-ignore
phpstan.neon export-ignore
README.md export-ignore
phpstan.neon export-ignore
ruleset.xml export-ignore
tests export-ignore
10 changes: 0 additions & 10 deletions .github/.kodiak.toml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/codesniffer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
name: "Codesniffer"
uses: contributte/.github/.github/workflows/codesniffer.yml@master
with:
php: "8.3"
php: "8.2"
4 changes: 2 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ on:
branches: ["*"]

schedule:
- cron: "0 8 * * 1"
- cron: "0 9 * * 1"

jobs:
coverage:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester-coverage-v2.yml@master
with:
php: "8.3"
php: "8.2"
4 changes: 2 additions & 2 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ on:
branches: ["*"]

schedule:
- cron: "0 8 * * 1"
- cron: "0 10 * * 1"

jobs:
phpstan:
name: "Phpstan"
uses: contributte/.github/.github/workflows/phpstan.yml@master
with:
php: "8.3"
php: "8.2"
18 changes: 9 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@ on:
workflow_dispatch:

push:
branches: [ "*" ]
branches: ["*"]

schedule:
- cron: "0 8 * * 1"
- cron: "0 10 * * 1"

jobs:
test85:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester.yml@master
with:
php: "8.5"

test84:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester.yml@master
Expand All @@ -29,15 +35,9 @@ jobs:
with:
php: "8.2"

test81:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester.yml@master
with:
php: "8.1"

testlower:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester.yml@master
with:
php: "8.1"
php: "8.2"
composer: "composer update --no-interaction --no-progress --prefer-dist --prefer-stable --prefer-lowest"
9 changes: 6 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
/composer.lock

# Tests
/tests/_output
/tests/Support/_generated
/coverage.xml
/tests/tmp
/coverage.*
/tests/**/*.log
/tests/**/*.html
/tests/**/*.expected
/tests/**/*.actual
20 changes: 11 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
.PHONY: install qa cs csf phpstan tests coverage

.PHONY: install
install:
composer update

.PHONY: qa
qa: phpstan cs

.PHONY: cs
cs:
ifdef GITHUB_ACTION
vendor/bin/phpcs --standard=ruleset.xml --encoding=utf-8 --extensions="php,phpt" --colors -nsp -q --report=checkstyle src tests | cs2pr
else
vendor/bin/phpcs --standard=ruleset.xml --encoding=utf-8 --extensions="php,phpt" --colors -nsp src tests
endif

.PHONY: csf
csf:
vendor/bin/phpcbf --standard=ruleset.xml --encoding=utf-8 --colors -nsp src tests
vendor/bin/phpcbf --standard=ruleset.xml --encoding=utf-8 --extensions="php,phpt" --colors -nsp src tests

.PHONY: phpstan
phpstan:
vendor/bin/phpstan analyse -c phpstan.neon

.PHONY: tests
tests:
vendor/bin/codecept build
vendor/bin/codecept run
vendor/bin/tester -s -p php --colors 1 -C tests/Cases

.PHONY: coverage
coverage:
ifdef GITHUB_ACTION
vendor/bin/codecept build
XDEBUG_MODE=coverage vendor/bin/codecept run --coverage --coverage-xml
vendor/bin/tester -s -p phpdbg --colors 1 -C --coverage coverage.xml --coverage-src src tests/Cases
else
vendor/bin/codecept build
XDEBUG_MODE=coverage vendor/bin/codecept run --coverage --coverage-html
vendor/bin/tester -s -p phpdbg --colors 1 -C --coverage coverage.html --coverage-src src tests/Cases
endif
22 changes: 0 additions & 22 deletions codeception.yml

This file was deleted.

29 changes: 17 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
{
"name": "contributte/forms-multiplier",
"type": "library",
"license": "MIT",
"description": "Multiplier for nette forms",
"keywords": [
"nette",
"contributte",
"forms",
"multiplier"
],
"type": "library",
"license": "MIT",
"homepage": "https://github.com/contributte/forms-multiplier",
"authors": [
{
"name": "Milan Felix Sulc",
"homepage": "https://f3l1x.io"
}
],
"require": {
"php": ">=8.1",
"nette/forms": "^3.1.12"
"php": ">=8.2",
"nette/forms": "^3.2.0"
},
"require-dev": {
"codeception/codeception": "^5.0",
"codeception/module-asserts": "^3.0",
"codeception/module-phpbrowser": "^3.0",
"nette/application": "^3.1.11",
"nette/di": "^3.1.0",
"contributte/phpstan": "~0.2.0",
"contributte/qa": "~0.4.0",
"contributte/tester": "~0.4.0",
"latte/latte": "^3.0.0",
"contributte/qa": "^0.3",
"contributte/phpstan": "^0.2",
"nette/application": "^3.2.0",
"nette/di": "^3.2.0",
"webchemistry/testing-helpers": "^4.0.0"
},
"conflict": {
Expand All @@ -38,8 +43,8 @@
"Tests\\": "tests"
}
},
"prefer-stable": true,
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"sort-packages": true,
"allow-plugins": {
Expand Down
43 changes: 39 additions & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
includes:
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
- vendor/phpstan/phpstan-nette/extension.neon
- vendor/phpstan/phpstan-nette/rules.neon
- vendor/contributte/phpstan/phpstan.neon

parameters:
level: 8
phpVersion: 80100
phpVersion: 80200

scanDirectories:
- src
Expand All @@ -24,3 +22,40 @@ parameters:
identifier: argument.type
count: 4
path: src/Multiplier.php

# Strict rules - boolean conditions
-
identifier: if.condNotBoolean
path: src/ComponentResolver.php
-
identifier: if.condNotBoolean
path: src/Multiplier.php
-
identifier: booleanAnd.leftNotBoolean
path: src/Latte/Extension/Node/MultiplierAddNode.php
-
identifier: booleanAnd.leftNotBoolean
path: src/Multiplier.php
-
identifier: booleanAnd.rightNotBoolean
path: src/Multiplier.php
-
identifier: booleanNot.exprNotBoolean
path: src/Latte/Extension/Node/MultiplierRemoveNode.php
-
identifier: booleanNot.exprNotBoolean
path: src/Multiplier.php
-
identifier: ternary.condNotBoolean
path: src/Latte/Extension/Node/MultiplierAddNode.php
-
identifier: ternary.condNotBoolean
path: src/Latte/Extension/Node/MultiplierRemoveNode.php

# Strict rules - covariance/contravariance
-
identifier: method.childReturnType
path: src/Latte/Extension/MultiplierExtension.php
-
identifier: method.childParameterType
path: src/Multiplier.php
15 changes: 8 additions & 7 deletions ruleset.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
<?xml version="1.0"?>
<ruleset>
<rule ref="./vendor/contributte/qa/ruleset.xml">
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="Contributte" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
<!-- Rulesets -->
<rule ref="./vendor/contributte/qa/ruleset-8.2.xml">
<exclude name="SlevomatCodingStandard.PHP.DisallowReference.DisallowedAssigningByReference"/>
<exclude name="SlevomatCodingStandard.PHP.DisallowReference.DisallowedReturningReference"/>
<exclude name="SlevomatCodingStandard.PHP.DisallowReference.DisallowedInheritingVariableByReference"/>
</rule>

<!-- Package specific rules -->
<!-- Rules -->
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
<properties>
<property name="rootNamespaces" type="array">
<element key="src" value="Contributte\FormMultiplier"/>
<element key="tests" value="Tests"/>
</property>
<property name="extensions" type="array" value="php,phpt"/>
</properties>
</rule>

<!-- Exclude folders -->
<exclude-pattern>/tests</exclude-pattern>
<!-- Excludes -->
<exclude-pattern>/tests/tmp</exclude-pattern>
</ruleset>
4 changes: 0 additions & 4 deletions tests/.coveralls.yml

This file was deleted.

68 changes: 68 additions & 0 deletions tests/Cases/Functional/MultiplierExtensionTest.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php declare(strict_types = 1);

namespace Tests\Cases\Functional;

use Contributte\FormMultiplier\DI\MultiplierExtension;
use Contributte\FormMultiplier\Multiplier;
use Contributte\Tester\Environment;
use Contributte\Tester\Toolkit;
use Nette\Bridges\ApplicationLatte\ILatteFactory;
use Nette\DI\Compiler;
use Nette\DI\ContainerLoader;
use Nette\DI\InvalidConfigurationException;
use Nette\Forms\Container;
use Nette\Forms\Form;
use Tester\Assert;

require __DIR__ . '/../../bootstrap.php';

/**
* @param array<string, mixed>|null $multiplierConfig
*/
function initializeContainer(?array $multiplierConfig = null): void
{
$config = [
'services' => [
'latte.latteFactory' => ILatteFactory::class,
],
];

if ($multiplierConfig !== null) {
$config['multiplier'] = $multiplierConfig;
}

$loader = new ContainerLoader(Environment::getTestDir());
$class = $loader->load(function (Compiler $compiler) use ($config): void {
$compiler->addExtension('multiplier', new MultiplierExtension());
$compiler->addConfig($config);
}, md5(serialize($multiplierConfig)) . time());
$container = new $class();
$container->initialize();
}

// testDefaultConfiguration
Toolkit::test(function (): void {
initializeContainer();

$form = new Form();
$multiplier = $form->addMultiplier('multiplier', function (Container $container, Form $form): void {
});
Assert::type(Multiplier::class, $multiplier);
});

// testAlternativeConfiguration
Toolkit::test(function (): void {
initializeContainer(['name' => 'addMultiplierAlternative']);

$form = new Form();
$multiplier = $form->addMultiplierAlternative('multiplier', function (Container $container, Form $form): void {
});
Assert::type(Multiplier::class, $multiplier);
});

// testInvalidConfiguration
Toolkit::test(function (): void {
Assert::exception(function (): void {
initializeContainer(['name' => 0]);
}, InvalidConfigurationException::class);
});
Loading