public function RulesTest::testGet in Auth0 Single Sign On 8.2
Test that get methods work as expected.
Return value
void
Throws
CoreException Thrown when there is a problem with parameters passed to the method.
\Exception Thrown by the HTTP client when there is a problem with the API call.
File
- vendor/
auth0/ auth0-php/ tests/ API/ Management/ RulesTest.php, line 53
Class
- RulesTest
- Class RulesTest.
Namespace
Auth0\Tests\API\ManagementCode
public function testGet() {
$api = new Management(self::$env['API_TOKEN'], self::$env['DOMAIN']);
$results = $api
->rules()
->getAll();
usleep(AUTH0_PHP_TEST_INTEGRATION_SLEEP);
$this
->assertNotEmpty($results);
// Check getting a single rule by a known ID.
$get_rule_id = $results[0]['id'];
$result = $api
->rules()
->get($get_rule_id);
usleep(AUTH0_PHP_TEST_INTEGRATION_SLEEP);
$this
->assertNotEmpty($result);
$this
->assertEquals($results[0]['id'], $get_rule_id);
// Iterate through the results to see if we have enabled and disabled Rules.
$has_enabled = false;
$has_disabled = false;
foreach ($results as $result) {
if ($result['enabled']) {
$has_enabled = true;
}
else {
$has_disabled = true;
}
}
// Check enabled rules.
$enabled_results = $api
->rules()
->getAll(true);
usleep(AUTH0_PHP_TEST_INTEGRATION_SLEEP);
if ($has_enabled) {
$this
->assertNotEmpty($enabled_results);
}
else {
$this
->assertEmpty($enabled_results);
}
// Check disabled rules.
$disabled_results = $api
->rules()
->getAll(false);
usleep(AUTH0_PHP_TEST_INTEGRATION_SLEEP);
if ($has_disabled) {
$this
->assertNotEmpty($disabled_results);
}
else {
$this
->assertEmpty($disabled_results);
}
}