Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
funivan committed Dec 9, 2024
1 parent 4ebf7b4 commit 6ed2bc3
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
phpunit.xml.dist export-ignore
tests export-ignore
docs export-ignore

.phpunit.result.cache
35 changes: 13 additions & 22 deletions .idea/ElementFinder.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
"autoload-dev": {
"psr-4": {
"Test\\Xparse\\ElementFinder\\": "tests"
"Test\\Xparse\\ElementFinder\\": "./tests"
}
},
"config": {
Expand Down
7 changes: 6 additions & 1 deletion ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use PhpCsFixer\Fixer\FunctionNotation\VoidReturnFixer;
use PhpCsFixer\Fixer\Import\NoUnusedImportsFixer;
use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;

Expand All @@ -14,7 +15,11 @@
__FILE__,
]);

$ecsConfig->rules([NoUnusedImportsFixer::class, VoidReturnFixer::class]);
$ecsConfig->rules([
NoUnusedImportsFixer::class,
VoidReturnFixer::class,
DeclareStrictTypesFixer::class,
]);

// this way you can add sets - group of rules
$ecsConfig->sets([SetList::SPACES, SetList::ARRAY, SetList::DOCBLOCK, SetList::NAMESPACES, SetList::COMMENTS, SetList::PSR_12]);
Expand Down
16 changes: 11 additions & 5 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,25 @@
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php"
colors="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.0/phpunit.xsd"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true"
>
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
<report>
<clover outputFile=".tmp/clover.xml"/>
</report>
</coverage>
<testsuites>
<testsuite name="Test Suite">
<directory>tests</directory>
<directory>./tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>./src</directory>
</include>
</source>
</phpunit>
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php

namespace Tests\Xparse\ElementFinder\Collection\Filters\StringFilter;
declare(strict_types=1);

namespace Test\Xparse\ElementFinder\Collection\Filters\StringFilter;

use PHPUnit\Framework\TestCase;
use Xparse\ElementFinder\Collection\Filters\StringFilter\RegexStringFilter;

class RegexStringFilterTest extends TestCase
final class RegexStringFilterTest extends TestCase
{
public function testRegexSuccess(): void
{
Expand Down
6 changes: 4 additions & 2 deletions tests/Collection/Modify/StringModify/RegexReplaceTest.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<?php

namespace Tests\Xparse\ElementFinder\Collection\Modify\StringModify;
declare(strict_types=1);

namespace Test\Xparse\ElementFinder\Collection\Modify\StringModify;

use PHPUnit\Framework\TestCase;
use Xparse\ElementFinder\Collection\Modify\StringModify\RegexReplace;
use Xparse\ElementFinder\Collection\StringCollection;

class RegexReplaceTest extends TestCase
final class RegexReplaceTest extends TestCase
{
public function testReplace(): void
{
Expand Down
20 changes: 11 additions & 9 deletions tests/Collection/StringCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Test\Xparse\ElementFinder\Collection;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Test\Xparse\ElementFinder\Collection\Dummy\JoinedBy;
use Test\Xparse\ElementFinder\Collection\Dummy\WithLetterFilter;
Expand All @@ -12,7 +13,7 @@
/**
* @author Ivan Shcherbak <alotofall@gmail.com>
*/
class StringCollectionTest extends TestCase
final class StringCollectionTest extends TestCase
{
public function testInvalidObjectIndex(): void
{
Expand Down Expand Up @@ -87,10 +88,12 @@ public function testMergeWithPartialItems(): void
{
$collection = (new StringCollection([
1 => 'a',
]))->merge(new StringCollection([
1 => 'b',
'c',
]));
]))->merge(
new StringCollection([
1 => 'b',
'c',
])
);
self::assertSame(['a', 'b', 'c'], $collection->all());
}

Expand Down Expand Up @@ -128,7 +131,8 @@ public function testFilter(): void

self::assertSame(
[
'bar', 'baz',
'bar',
'baz',
],
$collection->all()
);
Expand All @@ -148,9 +152,7 @@ public function testMap(): void
);
}

/**
* @dataProvider lastDataProvider
*/
#[DataProvider('lastDataProvider')]
public function testLast(array $items, mixed $expected): void
{
$collection = new StringCollection($items);
Expand Down
9 changes: 4 additions & 5 deletions tests/CssExpressionTranslator/CssExpressionTranslatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

declare(strict_types=1);

namespace Xparse\ElementFinder\CssExpressionTranslator\Test;
namespace Test\Xparse\ElementFinder\CssExpressionTranslator;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Xparse\ElementFinder\CssExpressionTranslator\CssExpressionTranslator;

Expand All @@ -15,7 +16,7 @@ class CssExpressionTranslatorTest extends TestCase
/**
* @return string[][]
*/
final public function getConvertWithAttributesDataProvider(): array
final public static function getConvertWithAttributesDataProvider(): array
{
return [
['a', 'descendant-or-self::a'],
Expand All @@ -26,9 +27,7 @@ final public function getConvertWithAttributesDataProvider(): array
];
}

/**
* @dataProvider getConvertWithAttributesDataProvider
*/
#[DataProvider('getConvertWithAttributesDataProvider')]
final public function testConvertWithAttributes(string $input, string $expect): void
{
self::assertSame(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Test\Xparse\ElementFinder\CssExpressionTranslator;

use InvalidArgumentException;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Xparse\ElementFinder\CssExpressionTranslator\CssOrXpathExpressionTranslator;

Expand All @@ -16,7 +17,7 @@ final class CssOrXpathExpressionTranslatorTest extends TestCase
/**
* @return string[][]
*/
public function getQueriesDataProvider(): array
public static function getQueriesDataProvider(): array
{
return [
[
Expand Down Expand Up @@ -90,9 +91,7 @@ public function getQueriesDataProvider(): array
];
}

/**
* @dataProvider getQueriesDataProvider
*/
#[DataProvider('getQueriesDataProvider')]
public function testQueries(string $input, string $expect): void
{
$output = (new CssOrXpathExpressionTranslator())
Expand Down
2 changes: 2 additions & 0 deletions tests/Dummy/ItemsByClassExpressionTranslator.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Test\Xparse\ElementFinder\Dummy;

use Xparse\ElementFinder\ExpressionTranslator\ExpressionTranslatorInterface;
Expand Down
2 changes: 1 addition & 1 deletion tests/Helper/FormHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Tests\Xparse\ElementFinder\Helper;
namespace Test\Xparse\ElementFinder\Helper;

use Exception;
use PHPUnit\Framework\TestCase;
Expand Down
2 changes: 1 addition & 1 deletion tests/Helper/NodeHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Tests\Xparse\ElementFinder\Helper;
namespace Test\Xparse\ElementFinder\Helper;

use DOMDocument;
use PHPUnit\Framework\TestCase;
Expand Down
4 changes: 2 additions & 2 deletions tests/Helper/StringHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

declare(strict_types=1);

namespace Tests\Xparse\ElementFinder\Helper;
namespace Test\Xparse\ElementFinder\Helper;

use PHPUnit\Framework\TestCase;
use Xparse\ElementFinder\Helper\StringHelper;

/**
* @author Ivan Shcherbak <alotofall@gmail.com>
*/
class StringHelperTest extends TestCase
final class StringHelperTest extends TestCase
{
public function testEncode(): void
{
Expand Down

0 comments on commit 6ed2bc3

Please sign in to comment.