Skip to content

Commit

Permalink
Merge pull request #1 from tugmaks/test-codecov
Browse files Browse the repository at this point in the history
Test codecov
  • Loading branch information
tugmaks authored Nov 9, 2023
2 parents cfc0af6 + 3124bd7 commit fc07b2d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
23 changes: 19 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

steps:
- name: "Checkout"
uses: "actions/checkout@v2"
uses: "actions/checkout@v4"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
Expand All @@ -26,7 +26,22 @@ jobs:
php-version: "${{ matrix.php-version }}"

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1"
uses: "php-actions/composer@v6"

- name: PHPUnit Tests
uses: php-actions/phpunit@v3
env:
XDEBUG_MODE: coverage
with:
bootstrap: vendor/autoload.php
configuration: phpunit.xml
php_extensions: xdebug
args: tests --coverage-clover ./coverage.xml

- name: Upload to Codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODE_COV_TOKEN }}
files: ./coverage.xml
verbose: true

- name: "Phpunit"
run: "vendor/bin/phpunit"
20 changes: 17 additions & 3 deletions tests/Locking/LockingWalkerWalkerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping\Driver\AttributeDriver;
use Doctrine\ORM\Query;
use Generator;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -59,7 +58,12 @@ protected function setUp(): void
$this->entityManager = new EntityManager($connectionMock, $config);
}

#[DataProvider('lockingClauseAndSql')]
/**
* @covers \Tugmaks\DoctrineWalkers\Locking\LockingClause
* @covers \Tugmaks\DoctrineWalkers\Locking\LockingWalker::walkSelectStatement
*
* @dataProvider lockingClauseAndSql
*/
public function testHints(LockingClause $lockingClause, string $producedSql): void
{
$dql = \sprintf('SELECT d FROM %s d WHERE d.id = 1', DummyEntity::class);
Expand All @@ -72,7 +76,10 @@ public function testHints(LockingClause $lockingClause, string $producedSql): vo
self::assertSame($producedSql, $query->getSQL());
}

public static function lockingClauseAndSql(): Generator
/**
* @return iterable<array{0:LockingClause,1:string}>
*/
public static function lockingClauseAndSql(): iterable
{
yield [
new LockingClause(LockStrength::UPDATE),
Expand All @@ -85,6 +92,9 @@ public static function lockingClauseAndSql(): Generator
];
}

/**
* @covers \Tugmaks\DoctrineWalkers\Locking\LockingWalker::walkSelectStatement
*/
public function testItThrowsExceptionIfLockingClauseNotProvided(): void
{
self::expectException(LockingWalkerException::class);
Expand All @@ -99,6 +109,10 @@ public function testItThrowsExceptionIfLockingClauseNotProvided(): void
$query->getSQL();
}

/**
* @covers \Tugmaks\DoctrineWalkers\Locking\LockingClause
* @covers \Tugmaks\DoctrineWalkers\Locking\LockingWalker::walkSelectStatement
*/
public function testItThrowsExceptionIfAnotherLockSet(): void
{
self::expectException(LockingWalkerException::class);
Expand Down

0 comments on commit fc07b2d

Please sign in to comment.