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
20 changes: 17 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
php-version: ['8.4', '8.5']
php-version: ['8.5']
dependency-versions: ['lowest', 'highest']
name: 'BlackBox'
services:
Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
php-version: ['8.4', '8.5']
php-version: ['8.5']
dependency-versions: ['lowest', 'highest']
name: 'Coverage'
services:
Expand Down Expand Up @@ -92,6 +92,20 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
psalm:
uses: innmind/github-workflows/.github/workflows/psalm-matrix.yml@main
uses: innmind/github-workflows/.github/workflows/psalm.yml@main
name: 'Psalm'
strategy:
matrix:
php-version: ['8.5']
run-php-version: ['8.5']
with:
php-version: ${{ matrix.php-version }}
run-php-version: ${{ matrix.run-php-version }}
cs:
uses: innmind/github-workflows/.github/workflows/cs.yml@main
name: 'CS'
strategy:
matrix:
php-version: ['8.5']
with:
php-version: ${{ matrix.php-version }}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [Unreleased]

### Changed

- Requires PHP `8.5`
- Requires `innmind/black-box:~7.0`

## 5.1.0 - 2026-03-21

### Added
Expand Down
25 changes: 13 additions & 12 deletions blackbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,20 @@

Application::new($argv)
->disableMemoryLimit()
->codeCoverage(
CodeCoverage::of(
__DIR__.'/src/',
__DIR__.'/proofs/',
__DIR__.'/fixtures/',
)
->dumpTo('coverage.clover')
->enableWhen(\getenv('ENABLE_COVERAGE') !== false),
->scenariiPerProof(10)
->when(
\getenv('ENABLE_COVERAGE') !== false,
static fn($app) => $app
->codeCoverage(
CodeCoverage::of(
__DIR__.'/src/',
__DIR__.'/proofs/',
__DIR__.'/fixtures/',
)
->dumpTo('coverage.clover'),
)
->scenariiPerProof(1),
)
->scenariiPerProof(match (\getenv('ENABLE_COVERAGE')) {
false => 100,
default => 1,
})
->when(
\getenv('BLACKBOX_SET_SIZE') !== false,
static fn(Application $app) => $app->scenariiPerProof((int) \getenv('BLACKBOX_SET_SIZE')),
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"issues": "http://github.com/formal-php/access-layer/issues"
},
"require": {
"php": "~8.4",
"php": "~8.5",
"innmind/immutable": "~6.0",
"innmind/url": "~5.0",
"innmind/specification": "~4.1",
Expand All @@ -35,16 +35,16 @@
},
"require-dev": {
"innmind/static-analysis": "~1.3",
"innmind/black-box": "~6.5",
"innmind/black-box": "~7.0",
"innmind/coding-standard": "~2.0"
},
"conflict": {
"innmind/black-box": "<6.0|~7.0"
"innmind/black-box": "<7.0|~8.0"
},
"suggest": {
"innmind/black-box": "For property based testing"
},
"provide": {
"innmind/black-box-sets": "6.0"
"innmind/black-box-sets": "7.0"
}
}
2 changes: 1 addition & 1 deletion fixtures/Table/Column/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,6 @@ private static function comment(): Set
Set::strings()
->madeOf(Set::strings()->chars()->alphanumerical())
->atLeast(1),
)->toSet();
);
}
}
2 changes: 1 addition & 1 deletion fixtures/Table/Name.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static function any(): Set
Set::of('é', 'è', 'ê', 'ë', '_'),
)
->between(0, 63),
)->toSet();
);
}

/**
Expand Down
20 changes: 11 additions & 9 deletions proofs/connection/lazy.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,41 @@
use Innmind\Url\Url;
use Innmind\BlackBox\Set;

return static function() {
return static function($prove) {
$port = \getenv('DB_PORT') ?: '3306';
$connection = Connection::new(Url::of("mysql://root:root@127.0.0.1:$port/example"))->unwrap();
Properties::seed($connection);
$connections = Set::call(static function() use ($connection) {
$connections = Set::of(static function() use ($connection) {
Properties::seed($connection);

return $connection;
});

yield test(
yield $prove->test(
'Lazy interface',
static fn($assert) => $assert
->object($connection)
->instance(Connection::class),
);

yield test(
yield $prove->test(
'Lazy connection must not be established at instanciation',
static fn($assert) => $assert
->object(Connection::new(Url::of('mysql://unknown:unknown@127.0.0.1:3306/unknown'))),
);

yield properties(
yield $prove->properties(
'Lazy properties',
Properties::any(),
$connections,
);

foreach (Properties::list() as $property) {
yield property(
$property,
$connections,
)->named('Lazy');
yield $prove
->property(
$property,
$connections,
)
->named('Lazy');
}
};
18 changes: 10 additions & 8 deletions proofs/connection/logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,38 @@
use Innmind\BlackBox\Set;
use Psr\Log\NullLogger;

return static function() {
return static function($prove) {
$port = \getenv('DB_PORT') ?: '3306';
$connection = Connection::logger(
Connection::new(Url::of("mysql://root:root@127.0.0.1:$port/example"))->unwrap(),
new NullLogger,
);
Properties::seed($connection);
$connections = Set::call(static function() use ($connection) {
$connections = Set::of(static function() use ($connection) {
Properties::seed($connection);

return $connection;
});

yield test(
yield $prove->test(
'Logger interface',
static fn($assert) => $assert
->object($connection)
->instance(Connection::class),
);

yield properties(
yield $prove->properties(
'Logger properties',
Properties::any(),
$connections,
);

foreach (Properties::list() as $property) {
yield property(
$property,
$connections,
)->named('Logger');
yield $prove
->property(
$property,
$connections,
)
->named('Logger');
}
};
47 changes: 25 additions & 22 deletions proofs/connection/pdo.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,23 @@
use Innmind\Immutable\Sequence;
use Innmind\BlackBox\Set;

$proofs = static function(Url $dsn, Driver $driver) {
$proofs = static function($prove, Url $dsn, Driver $driver) {
$connection = Connection::new($dsn)->unwrap();
Properties::seed($connection);
$connections = Set::call(static function() use ($connection) {
$connections = Set::of(static function() use ($connection) {
Properties::seed($connection);

return $connection;
});

yield test(
yield $prove->test(
"PDO interface({$driver->name})",
static fn($assert) => $assert
->object($connection)
->instance(Connection::class),
);

yield test(
yield $prove->test(
"PDO lazy select doesnt load everything in memory({$driver->name})",
static function($assert) use ($connection) {
$table = Table\Name::of('test_lazy_load');
Expand Down Expand Up @@ -91,7 +91,7 @@ static function($assert) use ($connection) {
);

if ($driver === Driver::mysql) {
yield test(
yield $prove->test(
"PDO charset({$driver->name})",
static function($assert) use ($connection, $dsn) {
$table = Table\Name::of('test_charset');
Expand Down Expand Up @@ -144,7 +144,7 @@ static function($assert) use ($connection, $dsn) {
);
}

yield test(
yield $prove->test(
"Select join({$driver->name})",
static function($assert) use ($connection) {
$table = Table\Name::of('test_left_join');
Expand Down Expand Up @@ -250,7 +250,7 @@ public function value(): int
},
);

yield test(
yield $prove->test(
"Delete cascade({$driver->name})",
static function($assert) use ($connection) {
$parent = Table\Name::of('test_cascade_delete_parent');
Expand Down Expand Up @@ -309,7 +309,7 @@ static function($assert) use ($connection) {
},
);

yield test(
yield $prove->test(
"Delete set null({$driver->name})",
static function($assert) use ($connection) {
$parent = Table\Name::of('test_set_null_delete_parent');
Expand Down Expand Up @@ -375,7 +375,7 @@ static function($assert) use ($connection) {
},
);

yield test(
yield $prove->test(
"Foreign key name({$driver->name})",
static function($assert) use ($driver) {
$parent = Table\Name::of('parent_table');
Expand All @@ -392,7 +392,7 @@ static function($assert) use ($driver) {
},
);

yield test(
yield $prove->test(
"Delete join({$driver->name})",
static function($assert) use ($connection) {
$parent = Table\Name::of('test_join_delete_parent')->as('parent');
Expand Down Expand Up @@ -465,10 +465,10 @@ static function($assert) use ($connection) {
},
);

yield proof(
"Unique constraint({$driver->name})",
given(Set::integers()->between(0, 1_000_000)),
static function($assert, $int) use ($connection) {
yield $prove
->proof("Unique constraint({$driver->name})")
->given(Set::integers()->between(0, 1_000_000))
->test(static function($assert, $int) use ($connection) {
$table = Table\Name::of('test_unique');
$_ = $connection(CreateTable::ifNotExists(
$table,
Expand Down Expand Up @@ -506,34 +506,37 @@ static function($assert, $int) use ($connection) {
)));

$_ = $connection(DropTable::named($table));
},
);
});

yield properties(
yield $prove->properties(
"PDO properties({$driver->name})",
Properties::any(),
$connections,
);

foreach (Properties::list() as $property) {
yield property(
$property,
$connections,
)->named("PDO({$driver->name})");
yield $prove
->property(
$property,
$connections,
)
->named("PDO({$driver->name})");
}
};

return static function() use ($proofs) {
return static function($prove) use ($proofs) {
$port = \getenv('DB_PORT') ?: '3306';

yield from $proofs(
$prove,
Url::of("mysql://root:root@127.0.0.1:$port/example"),
Driver::mysql,
);

$port = \getenv('POSTGRES_DB_PORT') ?: '5432';

yield from $proofs(
$prove,
Url::of("pgsql://root:root@127.0.0.1:$port/example"),
Driver::postgres,
);
Expand Down
Loading
Loading