-
Notifications
You must be signed in to change notification settings - Fork 3
Add CI workflow with automated testing and code coverage #169
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
Merged
+107
−1
Merged
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
489c667
Initial plan
Copilot de5c380
Initial exploration and understanding of the repository
Copilot fd05614
Add CI workflow for automated testing and code coverage
Copilot fb27c29
Add CI and coverage badges to README, update gitignore
Copilot e136d50
Add explicit permissions to CI workflow for security
Copilot 12f5cc8
Remove vendor test directory pattern from gitignore
Copilot 90cc4f2
Remove Dependencies directory from repo and add to gitignore
Copilot 620f0f0
Restore Dependencies directory and remove from gitignore
Copilot 658c6c2
Remove test files that were accidentally added to Dependencies
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| - develop | ||
| pull_request: | ||
| branches: | ||
| - master | ||
| - develop | ||
|
|
||
| jobs: | ||
| test: | ||
| name: Test (PHP ${{ matrix.php }}) | ||
| runs-on: ubuntu-latest | ||
|
|
||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| php: ['7.4', '8.0', '8.1', '8.2'] | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up PHP | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: ${{ matrix.php }} | ||
| coverage: xdebug | ||
| tools: composer | ||
|
|
||
| - name: Get Composer cache directory | ||
| id: composer-cache | ||
| run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Cache Composer dependencies | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ${{ steps.composer-cache.outputs.dir }} | ||
| key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
| restore-keys: ${{ runner.os }}-composer- | ||
|
|
||
| - name: Install PHP dependencies | ||
| run: composer install --no-interaction --prefer-dist | ||
|
|
||
| - name: Run PHPUnit tests | ||
| run: vendor/bin/phpunit --colors=always | ||
|
|
||
| - name: Run PHPUnit tests with coverage | ||
| if: matrix.php == '8.1' | ||
| run: vendor/bin/phpunit --coverage-clover=coverage.xml --colors=always | ||
|
|
||
| - name: Upload coverage to Codecov | ||
| if: matrix.php == '8.1' | ||
| uses: codecov/codecov-action@v4 | ||
| with: | ||
| files: ./coverage.xml | ||
| flags: unittests | ||
| name: codecov-php-${{ matrix.php }} | ||
| fail_ci_if_error: false | ||
| token: ${{ secrets.CODECOV_TOKEN }} | ||
|
|
||
| lint: | ||
| name: Lint (PHP ${{ matrix.php }}) | ||
| runs-on: ubuntu-latest | ||
|
|
||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| php: ['7.4', '8.0', '8.1', '8.2'] | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up PHP | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: ${{ matrix.php }} | ||
| tools: composer, cs2pr | ||
|
|
||
| - name: Get Composer cache directory | ||
| id: composer-cache | ||
| run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Cache Composer dependencies | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ${{ steps.composer-cache.outputs.dir }} | ||
| key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
| restore-keys: ${{ runner.os }}-composer- | ||
|
|
||
| - name: Install PHP dependencies | ||
| run: composer install --no-interaction --prefer-dist | ||
|
|
||
| - name: Run PHPCS | ||
| run: composer run-script lint |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
...des/classes/Dependencies/Symfony/Component/CssSelector/Tests/CssSelectorConverterTest.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| <?php | ||
|
|
||
| /* | ||
| * This file is part of the Symfony package. | ||
| * | ||
| * (c) Fabien Potencier <[email protected]> | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests; | ||
|
|
||
| use PHPUnit\Framework\TestCase; | ||
| use PoweredCache\Dependencies\Symfony\Component\CssSelector\CssSelectorConverter; | ||
| use PoweredCache\Dependencies\Symfony\Component\CssSelector\Exception\ParseException; | ||
|
|
||
| class CssSelectorConverterTest extends TestCase | ||
| { | ||
| public function testCssToXPath() | ||
| { | ||
| $converter = new CssSelectorConverter(); | ||
|
|
||
| $this->assertEquals('descendant-or-self::*', $converter->toXPath('')); | ||
| $this->assertEquals('descendant-or-self::h1', $converter->toXPath('h1')); | ||
| $this->assertEquals("descendant-or-self::h1[@id = 'foo']", $converter->toXPath('h1#foo')); | ||
| $this->assertEquals("descendant-or-self::h1[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]", $converter->toXPath('h1.foo')); | ||
| $this->assertEquals('descendant-or-self::foo:h1', $converter->toXPath('foo|h1')); | ||
| $this->assertEquals('descendant-or-self::h1', $converter->toXPath('H1')); | ||
|
|
||
| // Test the cache layer | ||
| $converter = new CssSelectorConverter(); | ||
| $this->assertEquals('descendant-or-self::h1', $converter->toXPath('H1')); | ||
| } | ||
|
|
||
| public function testCssToXPathXml() | ||
| { | ||
| $converter = new CssSelectorConverter(false); | ||
|
|
||
| $this->assertEquals('descendant-or-self::H1', $converter->toXPath('H1')); | ||
|
|
||
| $converter = new CssSelectorConverter(false); | ||
| // Test the cache layer | ||
| $this->assertEquals('descendant-or-self::H1', $converter->toXPath('H1')); | ||
| } | ||
|
|
||
| public function testParseExceptions() | ||
| { | ||
| $this->expectException(ParseException::class); | ||
| $this->expectExceptionMessage('Expected identifier, but <eof at 3> found.'); | ||
| $converter = new CssSelectorConverter(); | ||
| $converter->toXPath('h1:'); | ||
| } | ||
|
|
||
| /** @dataProvider getCssToXPathWithoutPrefixTestData */ | ||
| public function testCssToXPathWithoutPrefix($css, $xpath) | ||
| { | ||
| $converter = new CssSelectorConverter(); | ||
|
|
||
| $this->assertEquals($xpath, $converter->toXPath($css, ''), '->parse() parses an input string and returns a node'); | ||
| } | ||
|
|
||
| public static function getCssToXPathWithoutPrefixTestData() | ||
| { | ||
| return [ | ||
| ['h1', 'h1'], | ||
| ['foo|h1', 'foo:h1'], | ||
| ['h1, h2, h3', 'h1 | h2 | h3'], | ||
| ['h1:nth-child(3n+1)', "*/*[(name() = 'h1') and (position() - 1 >= 0 and (position() - 1) mod 3 = 0)]"], | ||
| ['h1 > p', 'h1/p'], | ||
| ['h1#foo', "h1[@id = 'foo']"], | ||
| ['h1.foo', "h1[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"], | ||
| ['h1[class*="foo bar"]', "h1[@class and contains(@class, 'foo bar')]"], | ||
| ['h1[foo|class*="foo bar"]', "h1[@foo:class and contains(@foo:class, 'foo bar')]"], | ||
| ['h1[class]', 'h1[@class]'], | ||
| ['h1 .foo', "h1/descendant-or-self::*/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"], | ||
| ['h1 #foo', "h1/descendant-or-self::*/*[@id = 'foo']"], | ||
| ['h1 [class*=foo]', "h1/descendant-or-self::*/*[@class and contains(@class, 'foo')]"], | ||
| ['div>.foo', "div/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"], | ||
| ['div > .foo', "div/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"], | ||
| ]; | ||
| } | ||
| } |
34 changes: 34 additions & 0 deletions
34
...es/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/AbstractNodeTestCase.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| <?php | ||
|
|
||
| /* | ||
| * This file is part of the Symfony package. | ||
| * | ||
| * (c) Fabien Potencier <[email protected]> | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Node; | ||
|
|
||
| use PHPUnit\Framework\TestCase; | ||
| use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\NodeInterface; | ||
|
|
||
| abstract class AbstractNodeTestCase extends TestCase | ||
| { | ||
| /** @dataProvider getToStringConversionTestData */ | ||
| public function testToStringConversion(NodeInterface $node, $representation) | ||
| { | ||
| $this->assertEquals($representation, (string) $node); | ||
| } | ||
|
|
||
| /** @dataProvider getSpecificityValueTestData */ | ||
| public function testSpecificityValue(NodeInterface $node, $value) | ||
| { | ||
| $this->assertEquals($value, $node->getSpecificity()->getValue()); | ||
| } | ||
|
|
||
| abstract public static function getToStringConversionTestData(); | ||
|
|
||
| abstract public static function getSpecificityValueTestData(); | ||
| } |
37 changes: 37 additions & 0 deletions
37
includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/AttributeNodeTest.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| <?php | ||
|
|
||
| /* | ||
| * This file is part of the Symfony package. | ||
| * | ||
| * (c) Fabien Potencier <[email protected]> | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Node; | ||
|
|
||
| use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\AttributeNode; | ||
| use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\ElementNode; | ||
|
|
||
| class AttributeNodeTest extends AbstractNodeTestCase | ||
| { | ||
| public static function getToStringConversionTestData() | ||
| { | ||
| return [ | ||
| [new AttributeNode(new ElementNode(), null, 'attribute', 'exists', null), 'Powered_Cache_Attribute[Element[*][attribute]]'], | ||
| [new AttributeNode(new ElementNode(), null, 'attribute', '$=', 'value'), "Powered_Cache_Attribute[Element[*][attribute $= 'value']]"], | ||
| [new AttributeNode(new ElementNode(), 'namespace', 'attribute', '$=', 'value'), "Powered_Cache_Attribute[Element[*][namespace|attribute $= 'value']]"], | ||
| ]; | ||
| } | ||
|
|
||
| public static function getSpecificityValueTestData() | ||
| { | ||
| return [ | ||
| [new AttributeNode(new ElementNode(), null, 'attribute', 'exists', null), 10], | ||
| [new AttributeNode(new ElementNode(null, 'element'), null, 'attribute', 'exists', null), 11], | ||
| [new AttributeNode(new ElementNode(), null, 'attribute', '$=', 'value'), 10], | ||
| [new AttributeNode(new ElementNode(), 'namespace', 'attribute', '$=', 'value'), 10], | ||
| ]; | ||
| } | ||
| } |
33 changes: 33 additions & 0 deletions
33
includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/ClassNodeTest.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| <?php | ||
|
|
||
| /* | ||
| * This file is part of the Symfony package. | ||
| * | ||
| * (c) Fabien Potencier <[email protected]> | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Node; | ||
|
|
||
| use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\ClassNode; | ||
| use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\ElementNode; | ||
|
|
||
| class ClassNodeTest extends AbstractNodeTestCase | ||
| { | ||
| public static function getToStringConversionTestData() | ||
| { | ||
| return [ | ||
| [new ClassNode(new ElementNode(), 'class'), 'Class[Element[*].class]'], | ||
| ]; | ||
| } | ||
|
|
||
| public static function getSpecificityValueTestData() | ||
| { | ||
| return [ | ||
| [new ClassNode(new ElementNode(), 'class'), 10], | ||
| [new ClassNode(new ElementNode(null, 'element'), 'class'), 11], | ||
| ]; | ||
| } | ||
| } |
35 changes: 35 additions & 0 deletions
35
...lasses/Dependencies/Symfony/Component/CssSelector/Tests/Node/CombinedSelectorNodeTest.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| <?php | ||
|
|
||
| /* | ||
| * This file is part of the Symfony package. | ||
| * | ||
| * (c) Fabien Potencier <[email protected]> | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Node; | ||
|
|
||
| use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\CombinedSelectorNode; | ||
| use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\ElementNode; | ||
|
|
||
| class CombinedSelectorNodeTest extends AbstractNodeTestCase | ||
| { | ||
| public static function getToStringConversionTestData() | ||
| { | ||
| return [ | ||
| [new CombinedSelectorNode(new ElementNode(), '>', new ElementNode()), 'CombinedSelector[Element[*] > Element[*]]'], | ||
| [new CombinedSelectorNode(new ElementNode(), ' ', new ElementNode()), 'CombinedSelector[Element[*] <followed> Element[*]]'], | ||
| ]; | ||
| } | ||
|
|
||
| public static function getSpecificityValueTestData() | ||
| { | ||
| return [ | ||
| [new CombinedSelectorNode(new ElementNode(), '>', new ElementNode()), 0], | ||
| [new CombinedSelectorNode(new ElementNode(null, 'element'), '>', new ElementNode()), 1], | ||
| [new CombinedSelectorNode(new ElementNode(null, 'element'), '>', new ElementNode(null, 'element')), 2], | ||
| ]; | ||
| } | ||
| } |
35 changes: 35 additions & 0 deletions
35
includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/ElementNodeTest.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| <?php | ||
|
|
||
| /* | ||
| * This file is part of the Symfony package. | ||
| * | ||
| * (c) Fabien Potencier <[email protected]> | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Node; | ||
|
|
||
| use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\ElementNode; | ||
|
|
||
| class ElementNodeTest extends AbstractNodeTestCase | ||
| { | ||
| public static function getToStringConversionTestData() | ||
| { | ||
| return [ | ||
| [new ElementNode(), 'Element[*]'], | ||
| [new ElementNode(null, 'element'), 'Element[element]'], | ||
| [new ElementNode('namespace', 'element'), 'Element[namespace|element]'], | ||
| ]; | ||
| } | ||
|
|
||
| public static function getSpecificityValueTestData() | ||
| { | ||
| return [ | ||
| [new ElementNode(), 0], | ||
| [new ElementNode(null, 'element'), 1], | ||
| [new ElementNode('namespace', 'element'), 1], | ||
| ]; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot undo this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Removed the
includes/classes/Dependencies/**/Testspattern from.gitignorein commit 12f5cc8.