LogsTest.php in Auth0 Single Sign On 8.2
File
vendor/auth0/auth0-php/tests/API/Management/LogsTest.php
View source
<?php
namespace Auth0\Tests\API;
use Auth0\SDK\API\Management;
class LogsTest extends ApiTests {
protected static $api;
public static function setUpBeforeClass() {
$env = self::getEnv();
$api = new Management($env['API_TOKEN'], $env['DOMAIN'], [
'timeout' => 30,
]);
self::$api = $api
->logs();
}
public function testThatMethodAndPropertyReturnSameClass() {
$api = new Management(uniqid(), uniqid());
$this
->assertInstanceOf(Management\Logs::class, $api->logs);
$this
->assertInstanceOf(Management\Logs::class, $api
->logs());
$api->logs = null;
$this
->assertInstanceOf(Management\Logs::class, $api
->logs());
}
public function testLogSearchAndGetById() {
$search_results = self::$api
->search([
'fields' => '_id,log_id,date',
'include_fields' => true,
]);
usleep(AUTH0_PHP_TEST_INTEGRATION_SLEEP);
$this
->assertNotEmpty($search_results);
$this
->assertNotEmpty($search_results[0]['_id']);
$this
->assertNotEmpty($search_results[0]['log_id']);
$this
->assertNotEmpty($search_results[0]['date']);
$this
->assertCount(3, $search_results[0]);
$one_log = self::$api
->get($search_results[0]['log_id']);
usleep(AUTH0_PHP_TEST_INTEGRATION_SLEEP);
$this
->assertNotEmpty($one_log);
$this
->assertEquals($search_results[0]['log_id'], $one_log['log_id']);
}
public function testLogSearchPagination() {
$expected_count = 5;
$search_results = self::$api
->search([
'fields' => '_id,log_id',
'include_fields' => true,
'page' => 1,
'per_page' => $expected_count,
'include_totals' => true,
]);
usleep(AUTH0_PHP_TEST_INTEGRATION_SLEEP);
$this
->assertCount($expected_count, $search_results['logs']);
$this
->assertEquals($expected_count, $search_results['length']);
$this
->assertEquals($expected_count, $search_results['start']);
}
}