From 2c05323c5ff48ad46e3bd2c3a05956d259c3669d Mon Sep 17 00:00:00 2001 From: Louis Celier Date: Tue, 18 Jun 2024 00:53:01 +0200 Subject: [PATCH] feat: add data provider using class attributes --- .gitignore | 3 +++ composer.json | 3 ++- phpunit.xml | 6 ++++++ src/data-provider/ShouldBeGranted.php | 14 ++++++++++++++ src/data-provider/Tests/PatateTest.php | 19 +++++++++++++++++++ src/data-provider/Tests/TestCase.php | 18 ++++++++++++++++++ 6 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 src/data-provider/ShouldBeGranted.php create mode 100644 src/data-provider/Tests/PatateTest.php create mode 100644 src/data-provider/Tests/TestCase.php diff --git a/.gitignore b/.gitignore index c7eea7f..0c4e8bf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ ### MacOs ### .DS_Store +### PhpStorm ### +/.idea + ### Composer ### composer.lock composer.phar diff --git a/composer.json b/composer.json index 2a3bd38..9aca545 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,8 @@ "files": [ "src/classnames/function.php" ], "psr-4": { "ClassNames\\": "src/classnames", - "MergeCoverage\\": "src/merge-coverage" + "MergeCoverage\\": "src/merge-coverage", + "DataProvider\\": "src/data-provider" } }, "require-dev": { diff --git a/phpunit.xml b/phpunit.xml index 8e37f4a..42ddcf6 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -13,6 +13,12 @@ src/classnames/Tests + + src/time-of-day/Tests + + + src/data-provider/Tests + diff --git a/src/data-provider/ShouldBeGranted.php b/src/data-provider/ShouldBeGranted.php new file mode 100644 index 0000000..2427d7a --- /dev/null +++ b/src/data-provider/ShouldBeGranted.php @@ -0,0 +1,14 @@ +getAttributes(ShouldBeGranted::class); + foreach ($attributes as $attribute) { + yield [$attribute->newInstance()->role]; + } + } +} \ No newline at end of file