test: project name should be a string

This commit is contained in:
Oliver Davies 2023-03-11 01:01:52 +00:00
parent de6dc1851c
commit f25395d877
3 changed files with 24 additions and 5 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
/.phpunit.result.cache
/build/
/vendor/

View file

@ -1,5 +0,0 @@
<?php
test('example', function () {
expect(true)->toBeTrue();
});

View file

@ -0,0 +1,23 @@
<?php
use OliverDaviesLtd\BuildConfigs\Validator\ConfigurationValidator;
beforeEach(function (): void {
$this->validator = new ConfigurationValidator();
});
test('The project name should be a string', function (mixed $projectName, int $expectedViolationCount) {
$configuration = [
'name' => $projectName,
];
expect($this->validator->validate($configuration))
->toHaveCount($expectedViolationCount);
})->with(function () {
yield 'Non-empty string' => ['test', 0];
yield 'Empty string' => ['', 1];
yield 'Integer' => [1, 1];
yield 'Null' => [null, 1];
yield 'True' => [true, 1];
yield 'False' => [false, 2];
});