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
7 changes: 2 additions & 5 deletions .github/workflows/published.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,9 @@ jobs:
run: vendor/bin/psalm --stats --shepherd

- name: Generate Coverage
run: vendor/bin/phpunit --configuration phpunit.xml.dist \
--coverage-xml=build/coverage-xml \
--coverage-clover=build/clover.xml \
--log-junit=build/phpunit.junit.xml
run: vendor/bin/testo --coverage --log-junit=runtime/coverage/phpunit.junit.xml

- name: Infection Mutation Testing
env:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
run: vendor/bin/infection --coverage=build --threads=max --logger-github --no-progress --skip-initial-tests
run: vendor/bin/infection --coverage=runtime/coverage --threads=max --logger-github --no-progress --skip-initial-tests
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ jobs:
composer-options: "--optimize-autoloader"

- name: PHPUnit
run: vendor/bin/phpunit --configuration phpunit.xml.dist --coverage-clover ./coverage.xml
run: vendor/bin/testo
env:
XDEBUG_MODE: coverage
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# phpstorm project files
.idea
.zed
.claude

# Mac DS_Store Files
.DS_Store
Expand All @@ -18,4 +19,5 @@ phpunit.phar

# local
*.local.php
*.env
.auth.json
26 changes: 15 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ phpstan: ## phpstan
ghcr.io/kuaukutsu/php:${PHP_VERSION}-cli \
./vendor/bin/phpstan analyse -c phpstan.neon

phpunit: ## phpunit
testo: ## testo
$(DOCKER_RUN) \
ghcr.io/kuaukutsu/php:${PHP_VERSION}-cli \
./vendor/bin/phpunit
./vendor/bin/testo

phpcs: ## php code snifferphp: detect violations of a defined coding standard
$(DOCKER_RUN) \
Expand Down Expand Up @@ -78,11 +78,13 @@ infection:
--target tests \
-t app_cli .docker/php/cli
- docker run --init -it --rm \
--add-host=host.docker.internal:host-gateway \
-u $(USER) \
-v "$$(pwd):/app" \
-w /app \
app_cli ./vendor/bin/infection
app_cli ./vendor/bin/infection \
--coverage=/app/runtime/coverage \
--threads=max \
--skip-initial-tests
docker image rm -f app_cli

tests:
Expand All @@ -93,17 +95,12 @@ tests:
--target tests \
-t app_cli .docker/php/cli
- docker run --init -it --rm \
--add-host=host.docker.internal:host-gateway \
-u $(USER) \
-v "$$(pwd):/app" \
-w /app \
app_cli ./vendor/bin/phpunit \
--configuration phpunit.xml.dist \
--coverage-xml=/app/runtime/coverage/coverage-xml \
--coverage-clover=/app/runtime/coverage/clover.xml \
--log-junit=/app/runtime/coverage/phpunit.junit.xml
app_cli ./vendor/bin/testo \
--coverage --log-junit=/app/runtime/coverage/junit.xml
- docker run --init -it --rm \
--add-host=host.docker.internal:host-gateway \
-u $(USER) \
-v "$$(pwd):/app" \
-w /app \
Expand All @@ -119,3 +116,10 @@ app:
$(DOCKER_RUN) -w /app/example \
ghcr.io/kuaukutsu/php:${PHP_VERSION}-cli \
sh -l

## AI
-include .claude/Makefile

# Спец-правило, чтобы Makefile не ругался на неизвестные команды (аргументы)
%:
@:
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@
},
"require-dev": {
"buggregator/trap": "^1.15",
"infection/infection": "^0.32.4",
"infection/infection": "^0.32.7",
"php-di/php-di": "^7.1",
"phpstan/phpstan": "^2.0",
"phpunit/phpunit": "^12.5",
"rector/rector": "^2.0",
"roave/security-advisories": "dev-latest",
"slevomat/coding-standard": "^8.7",
"squizlabs/php_codesniffer": "^3.7",
"testo/bridge-infection": "^0.1.3",
"testo/testo": "^0.10.10",
"vimeo/psalm": "^6.13"
},
"autoload": {
Expand Down
10 changes: 4 additions & 6 deletions infection.json5.dist
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
{
"$schema": "vendor/infection/infection/resources/schema.json",
"source": {
"directories": [
"src"
]
"directories": ["src"]
},
"testFramework": "testo",
"threads": "max",
"tmpDir": "runtime",
"minCoveredMsi": 99,
"phpUnit": {
"configDir": "."
},
"mutators": {
"@default": true
},
Expand Down
26 changes: 0 additions & 26 deletions phpunit.xml.dist

This file was deleted.

12 changes: 12 additions & 0 deletions testo.dist.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Placeholder for Infection's TestFrameworkConfigLocator.

Infection (Factory.php) eagerly calls configLocator->locate('testo'),
which only accepts xml/yml/dist filenames and would otherwise throw
FileOrDirectoryNotFound because Testo's real config lives in testo.php.

testo/bridge-infection discards the located path entirely; the actual
Testo configuration is testo.php. This file only needs to exist.
-->
<testo/>
24 changes: 24 additions & 0 deletions testo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

use Testo\Application\Config\ApplicationConfig;
use Testo\Application\Config\SuiteConfig;
use Testo\Codecov\CodecovPlugin;
use Testo\Codecov\Report\PhpUnitXmlReport;

return new ApplicationConfig(
suites: [
new SuiteConfig(
name: 'integration',
location: ['tests'],
),
],
plugins: [
new CodecovPlugin(
reports: [
new PhpUnitXmlReport(__DIR__ . '/runtime/coverage/coverage-xml'),
],
),
],
);
41 changes: 22 additions & 19 deletions tests/DriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,66 +4,69 @@

namespace dbschemix\pdo\tests;

use PHPUnit\Framework\TestCase;
use Testo\Assert;
use Testo\Expect;
use Testo\Test;
use dbschemix\core\exception\ConfigurationException;
use dbschemix\pdo\Driver;

final class DriverTest extends TestCase
#[Test]
final class DriverTest
{
public function testTypeDriver(): void
public function typeDriver(): void
{
$driver = new Driver(
dsn: 'pgsql:host=postgres;port=5432;dbname=main',
);

self::assertEquals('pgsql', $driver->getName());
self::assertEquals('main', $driver->getSourceName());
Assert::same($driver->getName(), 'pgsql');
Assert::same($driver->getSourceName(), 'main');

$driver = new Driver(
dsn: 'MYSQL:host=mysql;dbname=copyDb',
);

self::assertEquals('mysql', $driver->getName());
self::assertEquals('copydb', $driver->getSourceName());
Assert::same($driver->getName(), 'mysql');
Assert::same($driver->getSourceName(), 'copydb');

$driver = new Driver(
dsn: 'sqlite::memory:',
);

self::assertEquals('sqlite', $driver->getName());
self::assertEquals('memory', $driver->getSourceName());
Assert::same($driver->getName(), 'sqlite');
Assert::same($driver->getSourceName(), 'memory');

$driver = new Driver(
dsn: 'sqlite:tests/data/sqlite/db.sqlite3',
);

self::assertEquals('sqlite', $driver->getName());
self::assertEquals('db', $driver->getSourceName());
Assert::same($driver->getName(), 'sqlite');
Assert::same($driver->getSourceName(), 'db');
}

public function testConfigurationException(): void
public function configurationException(): void
{
$this->expectException(ConfigurationException::class);
Expect::exception(ConfigurationException::class);

new Driver(
dsn: 'unknown:',
);
}

public function testDSNConfigurationException(): void
public function dsnConfigurationException(): void
{
$this->expectException(ConfigurationException::class);
$this->expectExceptionMessage('PDODriver: dsn is incorrect.');
Expect::exception(ConfigurationException::class)
->withMessage('PDODriver: dsn is incorrect.');

new Driver(
dsn: 'mysql::memory:',
);
}

public function testDSNEmptyConfigurationException(): void
public function dsnEmptyConfigurationException(): void
{
$this->expectException(ConfigurationException::class);
$this->expectExceptionMessage('PDODriver: dsn is incorrect.');
Expect::exception(ConfigurationException::class)
->withMessage('PDODriver: dsn is incorrect.');

new Driver(
dsn: 'sqlite:',
Expand Down
Loading
Loading