PHP code example of cst / leantesting
1. Go to this page and download the library: Download cst/leantesting library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cst / leantesting example snippets
$client = new LeanTesting\API\Client\Client();
$client->attachToken('<your token>');
// Listing projects
$projects = $client->projects->all();
// Fetching project bugs
$bugs = $client->projects->find(123)->bugs->all();
$client->getCurrentToken()
$client->attachToken('<token>');
$generated_URL = $client->auth->generateAuthLink(
'DHxaSvtpl91Xos4vb7d0GKkXRu0GJxd5Rdha2HHx', // client id
'https://www.example.com/appurl/',
'write', // scope
'a3ahdh2iqhdasdasfdjahf26' // random string
);
print_r( $generated_URL );
$token = $client->auth->exchangeAuthCode(
'DHxaSvtpl91Xos4vb7d0GKkXRu0GJxd5Rdha2asdasdx', // client id
'DpOZxNbeL1arVbjUINoA9pOhgS8FNQsOkpE4CtXU', // client secret
'authorization_code',
'JKHanMA897A7KA9ajqmxly', // auth code
'https://www.example.com/appurl/'
);
print_r( $token );
$client->user->getInformation()
$client->user->organizations->all()->toArray()
$client->user->organizations->find(31)->data
$client->projects->all()->toArray()
$new_project = $client->projects->create([
'name' => 'Project135',
'organization_id' => 5779
]);
print_r( $new_project->data );
$client->projects->find(3515)->data
$client->projects->find(3515)->sections->all()->toArray()
$new_section = $client->projects->find(3515)->sections->create([
'name' => 'SectionName'
]);
print_r( $new_section->data );
$client->projects->find(3515)->versions->all()->toArray()
$new_version = $client->projects->find(3515)->versions->create([
'number' => 'v0.3.1104'
]);
print_r( $new_version->data );
$client->projects->find(3515)->testCases->all()->toArray();
$client->projects->find(3515)->testRuns->all()->toArray();
$client->projects->find(3515)->testRuns->find(123)->data;
$client->projects->find(3515)->users->all()->toArray();
$client->projects->find(3515)->users->delete(123);
$client->projects->find(3515)->bugTypeScheme->all()->toArray()
$client->projects->find(3515)->bugStatusScheme->all()->toArray()
$client->projects->find(3515)->bugSeverityScheme->all()->toArray()
$client->projects->find(3515)->bugReproducibilityScheme->all()->toArray()
$client->projects->find(3515)->bugs->all()->toArray()
$new_bug = $client->projects->find(3515)->bugs->create([
'title' => 'Something bad happened...',
'status_id' => 1,
'severity_id' => 2,
'project_version_id' => 123
]);
print_r( $new_bug->data );
$client->bugs->find(123)->data
$updated_bug = $client->bugs->update(123, [
'title' => 'Updated title',
'status_id' => 1,
'severity_id' => 2,
'project_version_id' => 123
]);
print_r( $updated_bug->data );
$client->bugs->delete(123)
$client->bugs->find(123)->comments->all()->toArray()
$client->bugs->find(123)->attachments->all()->toArray()
$file_path = '/place/Downloads/Images/1370240743_2294218.jpg';
$new_attachment = $client->bugs->find(123)->attachments->upload($file_path);
print_r( $new_attachment->data )
$client->attachments->find(21515)->data
$client->attachments->delete(75198)
$client->platform->types->all()->toArray()
$client->platform->types->find(1)->data
$client->platform->types->find(1)->devices->all()->toArray()
$client->platform->devices->find(11)->data
$client->platform->os->all()->toArray()
$client->platform->os->find(1)->data
$client->platform->os->find(1)->versions->all()->toArray()
$client->platform->browsers->all()->toArray()
$client->platform->browsers->find(1)->data
$client->platform->browsers->find(1)->versions->all()->toArray()
$client->projects->find(3515)->bugs->all(['limit' => 2, 'page' => 5]).toArray();
$browsers = $client->platform->browsers->all()
echo $browsers->total()
echo $browsers->totalPages()
echo $browsers->count()
echo $browsers->toArray()
$comments = $client->bugs->find(123)->comments->all(['limit' => 1]);
foreach ($comments as $page) {
print_r( $page );
}
$comments = $client->bugs->find(123)->comments->all(['limit' => 1]);
echo $comments->toArray();
// Will return false if unable to move forwards
$comments->next(); echo $comments->toArray();
// Will return false if already on last page
$comments->last(); echo $comments->toArray();
// Will return false if unable to move backwards
$comments->previous(); echo $comments->toArray();
// Will return false if already on first page
$comments->first(); echo $comments->toArray();