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

Update php version, merge expression-translator #290

Merged
merged 3 commits into from
Jan 10, 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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
All Notable changes to `ElementFinder` will be documented in this file

## Planned changes
- Add `ExpressionTranslator` (merged from the [xparse/expression-translator](https://github.com/xparse/ExpressionTranslator) repository)
- Move to php 8.1

## 1.0.1 [2021-06-01]
Move xparse/expression-translator to 1.0.0
- Move xparse/expression-translator to 1.0.0

## 1.0.0 [2021-05-31]
- No breaking changes.
Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@
],
"require": {
"php": "^8.0",
"xparse/expression-translator": "0.0.* || ^1.0.0",
"ext-libxml": "*",
"ext-dom": "*"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.16",
"phpunit/phpunit": "^9.5.2",
"rector/rector": "^0.18.13"
"rector/rector": "^0.19.0"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 2 additions & 2 deletions src/ElementFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
use Xparse\ElementFinder\ElementFinder\Element;
use Xparse\ElementFinder\Helper\NodeHelper;
use Xparse\ElementFinder\Helper\StringHelper;
use Xparse\ExpressionTranslator\ExpressionTranslatorInterface;
use Xparse\ExpressionTranslator\XpathExpression;
use Xparse\ElementFinder\ExpressionTranslator\ExpressionTranslatorInterface;
use Xparse\ElementFinder\ExpressionTranslator\XpathExpression;

/**
* @author Ivan Shcherbak <alotofall@gmail.com>
Expand Down
18 changes: 18 additions & 0 deletions src/ExpressionTranslator/ExpressionTranslatorInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace Xparse\ElementFinder\ExpressionTranslator;

/**
* @author Ivan Shcherbak <alotofall@gmail.com>
*/
interface ExpressionTranslatorInterface {

/**
* Translate expression to xpath
* For example you can use css
*/
public function convertToXpath(string $expression) : string;

}
18 changes: 18 additions & 0 deletions src/ExpressionTranslator/XpathExpression.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace Xparse\ElementFinder\ExpressionTranslator;

/**
* @author Ivan Shcherbak <alotofall@gmail.com>
*/
class XpathExpression implements ExpressionTranslatorInterface
{

final public function convertToXpath(string $expression): string
{
return $expression;
}

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

namespace Test\Xparse\ElementFinder\Dummy;

use Xparse\ExpressionTranslator\ExpressionTranslatorInterface;
use Xparse\ElementFinder\ExpressionTranslator\ExpressionTranslatorInterface;

/**
* @author Ivan Shcherbak <alotofall@gmail.com>
Expand Down
1 change: 0 additions & 1 deletion tests/ElementFinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use RuntimeException;
use PHPUnit\Framework\TestCase;
use Test\Xparse\ElementFinder\Dummy\ItemsByClassExpressionTranslator;
use Xparse\ElementFinder\Collection\StringCollection;
use Xparse\ElementFinder\DomNodeListAction\RemoveNodes;
use Xparse\ElementFinder\ElementFinder;
use Xparse\ElementFinder\ElementFinderInterface;
Expand Down
24 changes: 24 additions & 0 deletions tests/ExpressionTranslator/XpathExpressionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace Test\Xparse\ElementFinder\ExpressionTranslator;
SergeiMV marked this conversation as resolved.
Show resolved Hide resolved


use PHPUnit\Framework\TestCase;
use Xparse\ElementFinder\ExpressionTranslator\XpathExpression;

/**
* @author Ivan Shcherbak <alotofall@gmail.com>
*/
class XpathExpressionTest extends TestCase
{

final public function testAssertSameIO(): void
{
self::assertSame(
'custom-expression',
(new XpathExpression())->convertToXpath('custom-expression')
);
}
}
Loading