/**
  * @depends WebserviceIsAvailable
  */
 public function create(ApiTester $I)
 {
     $I->wantTo('POST a new Contact in com_contacts');
     $I->amHttpAuthenticated('admin', 'admin');
     $I->sendPOST('index.php' . '?option=contact' . '&api=Hal' . '&webserviceClient=administrator' . '&webserviceVersion=1.0.0' . "&name={$this->name}" . '&catid=4');
     $I->seeResponseCodeIs(201);
     $I->seeResponseIsJson();
     $contactIDs = $I->grabDataFromResponseByJsonPath('$.id');
     $this->id = $contactIDs[0];
     $I->comment("The id of the new created user is: {$this->id}");
 }
예제 #2
0
<?php

$I = new ApiTester($scenario);
$I->wantTo('Check for hot tips');
//$I->amHttpAuthenticated('service_user', '123456');
////$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
$I->sendGet('http://api.invendium-dev.com/?source=');
//$I->seeResponseCodeIs(200);
//$I->seeResponseIsJson();
//$I->seeResponseContains('odds_rounded');
//$I->seeResponseContains('popularity');
//$I->seeResponseContainsJson(array('sport' => 'Football'));
$tips = $I->grabDataFromResponseByJsonPath('$.tips');
$array = array();
foreach ($tips[0] as $tip) {
    $array[] = $tip['sportname'];
}
$array = array_count_values($array);
foreach ($array as $sportname => $tipsCount) {
    $I->assertGreaterThanOrEqual('10', $tipsCount, "{$sportname} has only {$tipsCount} tips.");
}
예제 #3
0
<?php

$scenario->group('rels');
$I = new ApiTester($scenario);
$I->wantTo('load the initial rels');
$I->sendGET('/rels');
$I->grabDataFromResponseByJsonPath('$');
$I->seeResponseContainsJson(['loadList' => '/list/elements', 'addToList' => '/list/elements', 'removeFromList' => '/list/elements']);
예제 #4
0
파일: GamesCept.php 프로젝트: AndriyK/team
<?php

$I = new ApiTester($scenario);
$I->wantTo('check games resource');
$I->sendGET('/teams/26?expand=games');
$I->seeResponseCodeIs(401);
$token = $I->login('q@q.q', 'q');
// show list of games for team
$I->haveHttpHeader('Authorization', "Bearer {$token}");
$I->sendGET('/teams/26?expand=games');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContains('games');
$games = $I->grabDataFromResponseByJsonPath('$.games')[0];
\PHPUnit_Framework_Assert::assertEquals(2, count($games));
$I->seeResponseContains('training');
$I->seeResponseContains('evening game');
// check for empty list for team with no games
$I->sendGET('/teams/27?expand=games');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContains('games');
$games = $I->grabDataFromResponseByJsonPath('$.games')[0];
\PHPUnit_Framework_Assert::assertEquals(0, count($games));
// create game
$I->sendPOST('/games', ['team_id' => 26, 'datetime' => date("Y-m-d H:i:s"), 'location' => "home", 'title' => "important game"]);
$I->seeResponseCodeIs(201);
$I->seeResponseIsJson();
$I->seeResponseContains('important game');
$I->seeResponseContains('home');
$gameId = $I->grabDataFromResponseByJsonPath('$.id')[0];
예제 #5
0
 public function silksImageNotNullIfHorseracing(ApiTester $I)
 {
     $I->sendGET($this->endpoint . SOURCE);
     $tips = $I->grabDataFromResponseByJsonPath('$.tips');
     foreach ($tips[0] as $tip) {
         if ($tip['sportname'] == 'Horse Racing') {
             $I->assertNotNull($tip['silks_image'], 'silks_image is NULL at HorseRacing');
         }
     }
 }
예제 #6
0
<?php

$I = new ApiTester($scenario);
$I->wantTo('check player dashboard');
$I->sendGET('/dashboard/33');
$I->seeResponseCodeIs(401);
$token = $I->login('q@q.q', 'q');
$I->haveHttpHeader('Authorization', "Bearer {$token}");
$I->sendGET('/dashboard/33');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$games = $I->grabDataFromResponseByJsonPath('$')[0];
\PHPUnit_Framework_Assert::assertEquals(2, count($games));
$game1 = $games[0];
\PHPUnit_Framework_Assert::assertEquals('joined', $game1['current_player_status']);
\PHPUnit_Framework_Assert::assertEquals('FridayPlay', $game1['team']['name']);
\PHPUnit_Framework_Assert::assertEquals('training', $game1['game']['title']);
\PHPUnit_Framework_Assert::assertEquals(2, $game1['players_summary']['total']['amount']);
\PHPUnit_Framework_Assert::assertEquals(1, $game1['players_summary']['joined']['amount']);
\PHPUnit_Framework_Assert::assertEquals('q', $game1['players_summary']['joined']['players'][0]);
\PHPUnit_Framework_Assert::assertEquals(0, $game1['players_summary']['rejected']['amount']);
\PHPUnit_Framework_Assert::assertEquals(1, $game1['players_summary']['unknown']['amount']);
\PHPUnit_Framework_Assert::assertEquals('Super Player', $game1['players_summary']['unknown']['players'][0]);
$game2 = $games[1];
\PHPUnit_Framework_Assert::assertEquals('rejected', $game2['current_player_status']);
\PHPUnit_Framework_Assert::assertEquals('FridayPlay', $game2['team']['name']);
\PHPUnit_Framework_Assert::assertEquals('evening game', $game2['game']['title']);
\PHPUnit_Framework_Assert::assertEquals(2, $game2['players_summary']['total']['amount']);
\PHPUnit_Framework_Assert::assertEquals(0, $game2['players_summary']['joined']['amount']);
\PHPUnit_Framework_Assert::assertEquals('q', $game2['players_summary']['rejected']['players'][0]);
\PHPUnit_Framework_Assert::assertEquals(1, $game2['players_summary']['rejected']['amount']);
예제 #7
0
<?php

use Codeception\Module\ApiHelper;
$testPostData = ['title' => 'This is a cool topic!', 'details' => 'Where is the seismic moon? Ships meet on mankind at atlantis tower! Transporter of a ' . 'sub-light energy, arrest the voyage! Why does the planet meet?  Planets die from ' . 'voyages like ship-wide space suits.', 'excerpt' => 'Yuck! Pieces o\' life are forever swashbuckling. Madness ho! scrape to be commanded.', 'owned_by_creator' => true];
$I = new ApiTester($scenario);
$I->wantTo('create a topic for me to talk about');
// Headers
$I->haveHttpHeader('Content-Type', 'application/json');
// Submit
$I->sendPOST(ApiHelper::ENDPOINT_TOPICS, $testPostData);
// Response
$I->seeResponseCodeIs(201);
$I->seeResponseIsJson();
$I->canSeeResponseJsonMatchesJsonPath('$.id');
$I->assertEquals($testPostData['details'], $I->grabDataFromResponseByJsonPath('$.details')[0]);
$I->assertEquals($testPostData['excerpt'], $I->grabDataFromResponseByJsonPath('$.excerpt')[0]);
$I->assertEquals($testPostData['owned_by_creator'], $I->grabDataFromResponseByJsonPath('$.owned_by_creator')[0]);
$I->canSeeResponseJsonMatchesJsonPath('$.created_at');
// Db record
$I->seeInDatabase('topic', $testPostData);
예제 #8
0
파일: TeamsCept.php 프로젝트: AndriyK/team
$I = new ApiTester($scenario);
$I->wantTo('check teams resource');
$I->sendGET('/players/33?expand=teams');
$I->seeResponseCodeIs(401);
$token = $I->login('q@q.q', 'q');
// show list of user's teams
$I->haveHttpHeader('Authorization', "Bearer {$token}");
$I->sendGET('/players/33?expand=teams');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContains('teams');
$I->seeResponseContains('"sport":"football"');
$I->seeResponseContains('"name":"FridayPlay"');
$I->seeResponseContains('"is_capitan":"1"');
$teams = $I->grabDataFromResponseByJsonPath('$.teams')[0];
\PHPUnit_Framework_Assert::assertEquals(1, count($teams));
\PHPUnit_Framework_Assert::assertEquals(2, count($teams[0]['players']));
// new team creation
$I->sendPOST('/teams', ['name' => "QA", 'sport' => "voleyball"]);
$I->seeResponseCodeIs(201);
$I->seeResponseIsJson();
$I->seeResponseContains('"sport":"voleyball"');
$I->seeResponseContains('"name":"QA"');
$I->seeResponseContains('"is_capitan":"1"');
$players = $I->grabDataFromResponseByJsonPath('$.players')[0];
\PHPUnit_Framework_Assert::assertEquals(1, count($players));
$teamId = $I->grabDataFromResponseByJsonPath('$.id')[0];
$I->sendGET('/players/33?expand=teams');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
예제 #9
0
<?php

$I = new ApiTester($scenario);
$I->wantTo('check teams search by name and player mail');
$I->sendGET('/teams/search?name=test&email=');
$I->seeResponseCodeIs(401);
$token = $I->login('q@q.q', 'q');
// search by team name
$I->haveHttpHeader('Authorization', "Bearer {$token}");
$I->sendGET('/teams/search?name=play&email=');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContains('"name":"FridayPlay"');
$I->seeResponseContains('"name":"MondayPlay"');
$teams = $I->grabDataFromResponseByJsonPath('$')[0];
\PHPUnit_Framework_Assert::assertEquals(2, count($teams));
// search by email
$I->sendGET('/teams/search?name=&email=w@w.w');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContains('"name":"FridayPlay"');
$teams = $I->grabDataFromResponseByJsonPath('$')[0];
\PHPUnit_Framework_Assert::assertEquals(1, count($teams));
// no team parameters
$I->sendGET('/teams/search?name=&email=wrong@mail.com');
$I->seeResponseCodeIs(404);
$I->seeResponseIsJson();
$I->seeResponseContains('"No teams found for passed name and mail"');
// bad request with empty parameters
$I->sendGET('/teams/search?name=&email=');
$I->seeResponseCodeIs(400);