custom-d / unleash-helpers
helpers for Unleash
Requires
- php: ^7.4|^8.0
- illuminate/support: ^8.0|^9.0|^10.0
Requires (Dev)
- mikefrancis/laravel-unleash: ^0.6
- mockery/mockery: ^1.4
- orchestra/testbench: ^6.0|^7.0|^8.0
- phpunit/phpunit: ^8.0|^9.0
This package is auto-updated.
Last update: 2024-10-25 06:10:30 UTC
README
Installation
You can install the package via composer:
composer require custom-d/unleash-helpers
Usage
Unit Tests
to make your unit test where feature flags are within the testing object add the UsesFeatureFlag trait
example
use CustomD\UnleashHelpers\Traits\Testing\UsesFeatureFlags;
class MyFeatureTest extends TestCase
{
use UsesFeatureFlags;
public function testFlagsEnabled()
{
$this->setFeatureEnabled('test');
$this->setFeatureDisabled('test2');
$this->assertTrue(Unleash::isFeatureEnabled('test'));
$this->assertTrue(Unleash::isFeatureDisabled('test2'));
}
public function testHasFeatureFlags()
{
//optional array of features
$this->setUpFeatures([
'flag' => true,
'off' => false
]);
}
...
Scheduler
you can tell the scheduler to trigger events based on the feature flag status: this will perform a check and only allow the scheduled event / job etc to run if the feature flag test passes. examples:
$schedule->job('xxx')->ifFeatureEnabled('feature');
$schedule->job('xxx')->ifFeatureDisabled('feature');
Validation
We have a validation rule set that can be called as follows
function rules() {
'field' => 'requiredWithFeatureEnabled:my-feature', // field should be required if the feature flag is set on
'field' => 'requiredWithFeatureDisabled:my-feature', // field should be required if the feature flag is set off or not set.
}
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email craig.smith@customd.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.