Skip to content
Open
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
39 changes: 36 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,46 @@ on: [push]

jobs:
blackbox:
uses: innmind/github-workflows/.github/workflows/black-box-matrix.yml@main
uses: innmind/github-workflows/.github/workflows/black-box.yml@main
name: 'BlackBox'
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
php-version: ['8.5']
dependency-versions: ['lowest', 'highest']
with:
scenarii: 20
os: ${{ matrix.os }}
php-version: ${{ matrix.php-version }}
dependency-versions: ${{ matrix.dependency-versions }}
coverage:
uses: innmind/github-workflows/.github/workflows/coverage-matrix.yml@main
uses: innmind/github-workflows/.github/workflows/coverage.yml@main
name: 'Coverage'
secrets: inherit
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
php-version: ['8.5']
dependency-versions: ['lowest', 'highest']
with:
os: ${{ matrix.os }}
php-version: ${{ matrix.php-version }}
dependency-versions: ${{ matrix.dependency-versions }}
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`

## 9.0.0 - 2026-01-25

### Added
Expand Down
3 changes: 1 addition & 2 deletions blackbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
__DIR__.'/proofs/',
__DIR__.'/fixtures/',
)
->dumpTo('coverage.clover')
->enableWhen(true),
->dumpTo('coverage.clover'),
)
->scenariiPerProof(1),
)
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/Innmind/filesystem/issues"
},
"require": {
"php": "~8.4",
"php": "~8.5",
"innmind/immutable": "~6.0",
"innmind/media-type": "~3.0",
"innmind/url": "~5.0",
Expand All @@ -37,18 +37,18 @@
},
"require-dev": {
"innmind/static-analysis": "~1.3",
"innmind/black-box": "~6.5",
"innmind/black-box": "~7.0",
"innmind/coding-standard": "~2.0",
"symfony/filesystem": "~6.0|~7.0|~8.0",
"ramsey/uuid": "^4.6"
},
"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/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ public static function any(): Set
Name::any(),
Set::strings(),
MediaType::any(),
)->toSet();
);
}
}
68 changes: 36 additions & 32 deletions proofs/adapter/filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
use Innmind\BlackBox\Set;
use Symfony\Component\Filesystem\Filesystem as FS;

return static function() {
return static function($prove) {
$path = \rtrim(\sys_get_temp_dir(), '/').'/innmind/filesystem/';

yield properties(
yield $prove->properties(
'Filesystem properties',
PAdapter::properties(),
Set::call(static function() use ($path) {
Set::of(static function() use ($path) {
(new FS)->remove($path);

return Adapter::mount(
Expand All @@ -40,25 +40,27 @@
);

foreach (PAdapter::alwaysApplicable() as $property) {
yield property(
$property,
Set::call(static function() use ($path) {
(new FS)->remove($path);
yield $prove
->property(
$property,
Set::of(static function() use ($path) {
(new FS)->remove($path);

return Adapter::mount(
Path::of($path),
match (\PHP_OS) {
'Darwin' => CaseSensitivity::insensitive,
default => CaseSensitivity::sensitive,
},
)
->recover(Recover::mount(...))
->unwrap();
}),
)->named('Filesystem');
return Adapter::mount(
Path::of($path),
match (\PHP_OS) {
'Darwin' => CaseSensitivity::insensitive,
default => CaseSensitivity::sensitive,
},
)
->recover(Recover::mount(...))
->unwrap();
}),
)
->named('Filesystem');
}

yield test(
yield $prove->test(
'Regression adding file in directory due to case sensitivity',
static function($assert) use ($path) {
$property = new PAdapter\AddRemoveAddModificationsStillAddTheFile(
Expand Down Expand Up @@ -86,10 +88,10 @@ static function($assert) use ($path) {
);

foreach (CaseSensitivity::cases() as $case) {
yield properties(
yield $prove->properties(
'Filesystem properties on simulated disk',
PAdapter::properties(),
Set::call(static fn() => Adapter::mount(
Set::of(static fn() => Adapter::mount(
Path::of('/'),
$case,
IO::simulation(
Expand All @@ -100,17 +102,19 @@ static function($assert) use ($path) {
);

foreach (PAdapter::alwaysApplicable() as $property) {
yield property(
$property,
Set::call(static fn() => Adapter::mount(
Path::of('/'),
$case,
IO::simulation(
IO::fromAmbientAuthority(),
Disk::new(),
),
)->unwrap()),
)->named('Filesystem on simulated disk');
yield $prove
->property(
$property,
Set::of(static fn() => Adapter::mount(
Path::of('/'),
$case,
IO::simulation(
IO::fromAmbientAuthority(),
Disk::new(),
),
)->unwrap()),
)
->named('Filesystem on simulated disk');
}
}
};
18 changes: 10 additions & 8 deletions proofs/adapter/inMemory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,23 @@
use Properties\Innmind\Filesystem\Adapter as PAdapter;
use Innmind\BlackBox\Set;

return static function() {
yield properties(
return static function($prove) {
yield $prove->properties(
'InMemory properties emulating filesystem',
PAdapter::properties(),
Set::call(Adapter::inMemory(...)),
Set::of(Adapter::inMemory(...)),
);

foreach (PAdapter::alwaysApplicable() as $property) {
yield property(
$property,
Set::call(Adapter::inMemory(...)),
)->named('InMemory emulating filesystem');
yield $prove
->property(
$property,
Set::of(Adapter::inMemory(...)),
)
->named('InMemory emulating filesystem');
}

yield test(
yield $prove->test(
'Adding a file in a directory should not remove other files starting with the same name',
static function($assert) {
$adapter = Adapter::inMemory();
Expand Down
62 changes: 36 additions & 26 deletions proofs/directory/directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@
use Properties\Innmind\Filesystem\Directory as PDirectory;
use Innmind\BlackBox\Set;

return static function() {
yield properties(
return static function($prove) {
yield $prove->properties(
'Empty Directory properties',
PDirectory::properties(),
Name::any()->map(Directory::of(...)),
Name::any()
->map(Directory::of(...))
->map(static fn($directory) => static fn() => $directory),
);
yield properties(

yield $prove->properties(
'Non empty Directory properties',
PDirectory::properties(),
Set::compose(
Expand All @@ -32,30 +35,37 @@
->groupBy(static fn($file) => $file->name()->toString())
->size() === $files->size(), // do not accept duplicated files
),
),
)->map(static fn($directory) => static fn() => $directory),
);

foreach (PDirectory::alwaysApplicable() as $property) {
yield property(
$property,
Name::any()->map(Directory::of(...)),
)->named('Empty Directory');
yield property(
$property,
Set::compose(
Directory::of(...),
Name::any(),
Sequence::of(
File::any()->randomize(),
Set::integers()
->between(1, 5) // only to speed up tests
->toSet(),
)->filter(
static fn($files) => $files
->groupBy(static fn($file) => $file->name()->toString())
->size() === $files->size(), // do not accept duplicated files
),
),
)->named('Non empty Directory');
yield $prove
->property(
$property,
Name::any()
->map(Directory::of(...))
->map(static fn($directory) => static fn() => $directory),
)
->named('Empty Directory');

yield $prove
->property(
$property,
Set::compose(
Directory::of(...),
Name::any(),
Sequence::of(
File::any()->randomize(),
Set::integers()
->between(1, 5) // only to speed up tests
->toSet(),
)->filter(
static fn($files) => $files
->groupBy(static fn($file) => $file->name()->toString())
->size() === $files->size(), // do not accept duplicated files
),
)->map(static fn($directory) => static fn() => $directory),
)
->named('Non empty Directory');
}
};
15 changes: 7 additions & 8 deletions proofs/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

use Fixtures\Innmind\Filesystem\File;

return static function() {
yield proof(
'File::mapContent()',
given(
return static function($prove) {
yield $prove
->proof('File::mapContent()')
->given(
File::any(),
File::any(),
),
static function($assert, $file, $replacement) {
)
->test(static function($assert, $file, $replacement) {
$new = $file->mapContent(static function($content) use ($assert, $file, $replacement) {
$assert->same($file->content(), $content);

Expand All @@ -24,6 +24,5 @@ static function($assert, $file, $replacement) {
$assert->same($file->name(), $new->name());
$assert->same($file->mediaType(), $new->mediaType());
$assert->same($replacement->content(), $new->content());
},
);
});
};
Loading
Loading