diff --git a/composer.json b/composer.json index c948b4e..918385d 100644 --- a/composer.json +++ b/composer.json @@ -39,19 +39,28 @@ "team-reflex/discord-php": "^10.3" }, "require-dev": { - "laravel/pint": "^1.15" + "laravel/pint": "^1.15", + "orchestra/testbench": "^9.11", + "pestphp/pest": "^3.7", + "pestphp/pest-plugin-arch": "^3.0", + "pestphp/pest-plugin-laravel": "^3.1" }, "autoload": { "psr-4": { - "Laracord\\": "src/" + "Laracord\\": "src/", + "Tests\\": "tests/" }, "files": [ "src/helpers.php" ] }, + "scripts": { + "test": "./vendor/bin/pest" + }, "config": { "sort-packages": true, "allow-plugins": { + "pestphp/pest-plugin": true, "php-http/discovery": true } } diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..7d0904f --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,18 @@ + + + + + ./tests + + + + + ./app + ./src + + + diff --git a/tests/Feature/CommandsTest.php b/tests/Feature/CommandsTest.php new file mode 100644 index 0000000..95bd907 --- /dev/null +++ b/tests/Feature/CommandsTest.php @@ -0,0 +1,22 @@ +registerCommand(ValidCommand::class); + + expect(ValidCommand::class)->toBeRegistered(); + }); +}); diff --git a/tests/Pest.php b/tests/Pest.php new file mode 100644 index 0000000..bad4ebb --- /dev/null +++ b/tests/Pest.php @@ -0,0 +1,48 @@ +extend(Tests\TestCase::class)->in('Feature'); + +/* +|-------------------------------------------------------------------------- +| Expectations +|-------------------------------------------------------------------------- +| +| When you're writing tests, you often need to check that values meet certain conditions. The +| "expect()" function gives you access to a set of "expectations" methods that you can use +| to assert different things. Of course, you may extend the Expectation API at any time. +| +*/ + +expect()->extend('toBeRegistered', function () { + $laracord = app(\Laracord\Laracord::class); + if (str_contains($this->value, 'Command')) { + return $this->toBeIn(array_keys($laracord->getCommands())); + } +}); + +/* +|-------------------------------------------------------------------------- +| Functions +|-------------------------------------------------------------------------- +| +| While Pest is very powerful out-of-the-box, you may have some testing code specific to your +| project that you don't want to repeat in every file. Here you can also expose helpers as +| global functions to help you to reduce the number of lines of code in your test files. +| +*/ + +function something() +{ + // .. +} diff --git a/tests/TestCase.php b/tests/TestCase.php new file mode 100644 index 0000000..313482f --- /dev/null +++ b/tests/TestCase.php @@ -0,0 +1,15 @@ +toBeTrue(); +});