Exemplo n.º 1
0
<?php

use Codeception\Util\Fixtures;
/** @type \Codeception\Scenario $scenario */
$scenario->groups('api', 'ajax');
\Yii::app()->fixtureManager->prepare();
$I = new ApiGuy($scenario);
$I->wantTo('Ensure ajax comment update works fine');
$I->amOnPage(\BlogFeedPage::$url);
$I->click(\BlogFeedPage::$postTitleSelector);
$postUrl = $I->grabFromCurrentUrl();
$ajaxUrl = $I->grabAttributeFrom(\PostPage::$commentForm, 'data-action-ajax');
$I->sendPOST($ajaxUrl, array(\PostPage::$commentTextArea => 'Sample comment', \PostPage::$commentUsernameField => 'Fuy Gox'));
$I->assertTrue($I->grabDataFromJsonResponse('success'));
$I->assertNotEmpty($I->grabDataFromJsonResponse('data'));
$I->sendPOST($ajaxUrl, array(\PostPage::$commentTextArea => 'Sample comment'));
$I->assertFalse($I->grabDataFromJsonResponse('success'));
$I->assertNotEmpty($I->grabDataFromJsonResponse('errors'));
$I->sendPOST($ajaxUrl, array(\PostPage::$commentUsernameField => 'Fuy Gox'));
$I->assertFalse($I->grabDataFromJsonResponse('success'));
$I->assertNotEmpty($I->grabDataFromJsonResponse('errors'));
$I->amOnPage(\LoginPage::$url);
$I->submitForm(\LoginPage::$formSelector, array(\LoginPage::$loginField => Fixtures::get('data:users[0]:login'), \LoginPage::$passwordField => Fixtures::get('data:users[0]:password')));
$I->sendPost($ajaxUrl, array(\PostPage::$commentTextArea => 'Sample comment'));
$I->assertTrue($I->grabDataFromJsonResponse('success'));
$I->assertNotEmpty($I->grabDataFromJsonResponse('data'));
<?php

use Codeception\Module\ApiHelper;
$I = new ApiGuy($scenario);
$I->wantTo('TEST Orders');
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
$data = array();
//get token
$I->sendGET('Tokens?email=' . ApiHelper::$testUser['email'] . '&hash=' . md5(ApiHelper::$testUser['pass']), array());
$I->seeResponseIsJson();
$I->seeResponseContains('{"result":1,"data":{"signature":"');
$token = json_decode($I->grabResponse(), true);
$days2 = strtotime('next tuesday');
//'collection_local_date' => date("Y-m-d",$days2),
for ($i = 0; $i < 100; $i++) {
    foreach (ApiHelper::$testOrdersData as $providerID => $providerDataset) {
        codecept_debug('[_Debug data] ' . $providerID . ' test');
        foreach ($providerDataset as $datasetName => $datasetData) {
            codecept_debug('[_Debug data] ' . $datasetName . ' test');
            $datasetData['client_ID'] = $token['data']['client_ID'];
            $datasetData['signature'] = $token['data']['signature'];
            $I->sendGET('Prices/' . $providerID, $datasetData);
            $I->seeResponseIsJson();
            //echo '!NULL';
            $I->seeResponseContains('{"result":1,"data":');
            $priceData = json_decode($I->grabResponse(), true);
        }
    }
}
Exemplo n.º 3
0
<?php

$I = new ApiGuy($scenario);
$I->wantTo('create a user via API');
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
$I->sendPOST('users', array('username' => '*****@*****.**', 'Password' => ''));
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContains('{"message":"Password","success":0}');
?>

?>

<?php

/*
 * Copyright (c) 2014 Ebizu Sdn. Bhd.
 */
/**
 * List Bid API Test
 *
 * @author Budi Irawan <*****@*****.**>
 */
$I = new ApiGuy($scenario);
$I->wantTo('get all bids');
$I->sendGET('bids');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
Exemplo n.º 5
0
<?php

/**
 * Copyright (c) 2014 Ebizu Sdn. Bhd.
 * 
 * @author Budi Irawan <*****@*****.**>
 */
$I = new ApiGuy($scenario);
$I->wantTo('login as user');
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
$I->sendPOST('users/login', ['email' => '*****@*****.**', 'password' => 'halimi']);
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->amGoingTo('login using wrong username or password');
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
$I->sendPOST('users/login', ['email' => '*****@*****.**', 'password' => 'halimi']);
$I->seeResponseIsJson();
$I->seeResponseContains('404');
Exemplo n.º 6
0
<?php

$I = new ApiGuy($scenario);
$I->wantTo('Logout');
$I->haveHttpHeader('Content-Type', 'application/json');
include 'loginCept.php';
$I->amBearerAuthenticated($token);
$I->sendPOST('/auth/logout');
$I->seeResponseIsJson();
$I->seeResponseCodeIs(200);
Exemplo n.º 7
0
<?php

$I = new ApiGuy($scenario);
$I->wantTo('GET banners');
$I->haveHttpHeader('Content-Type', 'application/json');
$I->sendGET('/banner', array('offset' => '50', 'limit' => '15'));
$I->seeResponseCodeIs(200);
Exemplo n.º 8
0
<?php

$I = new ApiGuy($scenario);
$I->wantTo('Search song in iTunes');
include 'getCurrentTrackCept.php';
$I->sendGET('/itunes/search/' . $song_url);
$I->seeResponseCodeIs(200);
Exemplo n.º 9
0
<?php

$I = new ApiGuy($scenario);
$I->wantTo('Add current track to Favorite');
$I->haveHttpHeader('Content-Type', 'application/json');
include 'loginCept.php';
$I->amBearerAuthenticated($token);
include 'getCurrentTrackCept.php';
$I->sendPOST('/favorite/track', array('track_name' => $current_track));
$I->seeResponseCodeIs(200);
?>

Exemplo n.º 10
0
<?php

$I = new ApiGuy($scenario);
$I->wantTo('perform actions and see result');
$I->haveHttpHeader('Content-Type', 'application/json');
include 'loginCept.php';
$I->amBearerAuthenticated($token);
include 'constant.php';
$I->sendPUT('/user/profile', array('username' => $new_username));
Exemplo n.º 11
0
<?php

$I = new ApiGuy($scenario);
$I->wantTo('GET Favorite Stations');
$I->haveHttpHeader('Content-Type', 'application/json');
require_once 'loginCept.php';
$I->amBearerAuthenticated($token);
$I->sendGET('/favorite/station');
$st1 = $I->grabDataFromResponseByJsonPath('$..data[0].station_id');
#[] выбор массива
$stat1 = serialize($st1);
$favorite_station = substr("{$stat1}", 14, -3);
$st2 = $I->grabDataFromResponseByJsonPath('$..data[2].name');
#[] выбор массива
$stat2 = serialize($st2);
$search_station = substr($stat2, 14, strpos($stat2, ' '));
$I->seeResponseCodeIs(200);
Exemplo n.º 12
0
<?php

$I = new ApiGuy($scenario);
$I->wantTo('Resend activation code');
$I->sendPUT('/auth/activate', array('email' => '*****@*****.**'));
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
Exemplo n.º 13
0
<?php

$I = new ApiGuy($scenario);
$I->wantTo('Delete favorite track');
$I->haveHttpHeader('Content-Type', 'application/json');
include 'loginCept.php';
$I->amBearerAuthenticated($token);
include 'getFavoriteTracksCept.php';
$I->sendDELETE('/favorite/track', array('id' => $favorite_track));
$I->seeResponseCodeIs(200);
<?php

$I = new ApiGuy($scenario);
$I->wantTo('Get Station by Genre');
include 'constant.php';
$I->sendGET('/station/' . $genreSlug);
$I->seeResponseCodeIs(200);
Exemplo n.º 15
0
<?php

$I = new ApiGuy($scenario);
$I->wantTo('test login function');
//$I->haveHttpHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
$I->sendPOST(array('username' => '*****@*****.**', 'Password' => ''));
//$I->seeResponseCodeIs(200);
//$I->seeResponseIsJson();
//$I->seeResponseContainsJson('{"message":"Password","success":0}');
Exemplo n.º 16
0
<?php

$I = new ApiGuy($scenario);
$I->wantTo('Change my password');
$I->haveHttpHeader('Content-Type', 'application/json');
include 'loginCept.php';
$I->amBearerAuthenticated($token);
include 'constant.php';
#$I->sendPUT('/user/password', array('old_password' => $old_pass, 'new_password' => $new_pass, 'new_password_confirm' => $confirm_pass));
#$I->seeResponseCodeIs(200);
#$I->seeResponseIsJson();
Exemplo n.º 17
0
<?php

use Codeception\Module\ApiHelper;
$I = new ApiGuy($scenario);
$I->wantTo('TEST Orders');
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
//get token
$data = array();
$I->sendGET('Tokens?email=' . ApiHelper::$testUser['email'] . '&hash=' . md5(ApiHelper::$testUser['pass']), $data);
$I->seeResponseIsJson();
$I->seeResponseContains('{"result":1,"data":{"signature":"');
$response = json_decode($I->grabResponse(), true);
$responseToken = $response;
//get prices
$data = array('client_ID' => $response['data']['client_ID'], 'signature' => $response['data']['signature'], 'type' => 'd', 'quantity' => 3, 'sender_locality' => 'Kazan', 'sender_country_code' => 'RU', 'sender_locality_translated' => 'Казань', 'sender_postal_code' => '420001', 'receiver_locality' => 'Moscow', 'receiver_country_code' => 'RU', 'receiver_locality_translated' => 'Москва', 'receiver_postal_code' => '101000');
$I->sendGET('Prices/2', $data);
$I->seeResponseIsJson();
//echo '!NULL';
$I->seeResponseContains('{"result":1,"data":');
$days2 = mktime(date("H"), date("i"), date("s"), date("m"), date("d") + 2, date("Y"));
$requiredParams = array('client_ID' => $response['data']['client_ID'], 'signature' => $response['data']['signature'], 'type' => 'd', 'quantity' => 3, 'sender_locality' => 'Kazan', 'sender_country_code' => 'RU', 'sender_locality_translated' => 'Казань', 'sender_postal_code' => '420001', 'receiver_locality' => 'Moscow', 'receiver_country_code' => 'RU', 'receiver_locality_translated' => 'Москва', 'receiver_postal_code' => '101000', 'receiver_phone' => '+79510665133', 'sender_full_name' => 'Aydar Akhmeyzyanov', 'sender_type' => 'c', 'sender_company' => 'creativestripe', 'receiver_full_name' => 'Vadim Perov', 'receiver_type' => 'p', 'collection_local_date' => date("Y-m-d", $days2), 'delivery_timezone' => '4', 'sender_street' => 'Четаева', 'sender_housenumber' => '1', 'sender_roomnumber' => '2', 'receiver_street' => 'Тверская', 'receiver_housenumber' => '3', 'receiver_roomnumber' => '5', 'sender_significantinformation' => 'wtf???', 'invoice_contents' => 'wtf???', 'invoice_price' => '200', 'extra_insurance' => '100');
$response2 = json_decode($I->grabResponse(), true);
$requiredParams['provider_price_data'] = json_encode($response2['data']['1']);
$data = $requiredParams;
$I->sendPOST('Ship?action=create', $data);
$I->seeResponseIsJson();
$I->seeResponseContains('{"result":1');
$I->seeResponseContains('paymentRequired":0');
$requiredParams = array('client_ID' => $response['data']['client_ID'], 'signature' => $response['data']['signature']);
$data = $requiredParams;
$response = json_decode($I->grabResponse(), true);
Exemplo n.º 18
0
<?php

/*
 * Copyright (c) 2014 Ebizu Sdn. Bhd.
 */
/**
 * List Device API Test
 *
 * @author Budi Irawan <*****@*****.**>
 */
$I = new ApiGuy($scenario);
$I->wantTo('get all devices');
$I->sendGET('devices');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
<?php

$I = new ApiGuy($scenario);
$I->wantTo('GET Station by slug');
$I->haveHttpHeader('Content-Type', 'application/json');
include 'getRandomStationCept.php';
$I->sendGET('/station/details', array('stationSlug' => $slug));
$I->seeResponseCodeIs(200);
Exemplo n.º 20
0
<?php

$I = new ApiGuy($scenario);
$I->wantTo('create a user via API');
$I->haveHttpHeader('Content-Type', 'application/json');
include "constant.php";
$I->sendPOST('/auth/registration', array('username' => $user_name, 'email' => $email, 'password' => $pass, 'password_confirmation' => $pass));
$I->seeResponseContains("data", "errors");
$I->seeResponseIsJson();
$I->seeResponseCodeIs(200);
Exemplo n.º 21
0
<?php

$I = new ApiGuy($scenario);
$I->wantTo('TEST TNT Provider');
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
$pass = '******';
$hash = md5($pass);
//get token
$data = array();
$I->sendGET('Tokens?email=aydar@creativestripe.ru&hash=' . $hash, $data);
$I->seeResponseIsJson();
$I->seeResponseContains('{"result":1,"data":{"signature":"');
$response = json_decode($I->grabResponse(), true);
$responseToken = $response;
//get prices
$data = array('client_ID' => $response['data']['client_ID'], 'signature' => $response['data']['signature'], 'type' => 'd', 'quantity' => 3, 'sender_locality' => 'Kazan', 'sender_country_code' => 'RU', 'sender_locality_translated' => 'Казань', 'sender_postal_code' => '420001', 'receiver_locality' => 'Moscow', 'receiver_country_code' => 'RU', 'receiver_locality_translated' => 'Москва', 'receiver_postal_code' => '101000');
$I->sendGET('Prices/1', $data);
$I->seeResponseIsJson();
$I->seeResponseContains('{"result":1,"data":');
$days2 = mktime(date("H"), date("i"), date("s"), date("m"), date("d") + 4, date("Y"));
$days10 = mktime(date("H"), date("i"), date("s"), date("m"), date("d") + 12, date("Y"));
$days2timefrom = mktime(date("H"), date("i"), date("s"), date("m"), date("d") + 4, date("Y"));
$days10timefrom = mktime(date("H"), date("i"), date("s"), date("m"), date("d") + 12, date("Y"));
$days2timeto = mktime(date("H") + 1, date("i"), date("s"), date("m"), date("d") + 4, date("Y"));
$days10timeto = mktime(date("H") + 1, date("i"), date("s"), date("m"), date("d") + 12, date("Y"));
$requiredParams = array('client_ID' => $response['data']['client_ID'], 'signature' => $response['data']['signature'], 'type' => 'd', 'quantity' => 3, 'sender_locality' => 'Kazan', 'sender_country_code' => 'RU', 'sender_locality_translated' => 'Казань', 'sender_postal_code' => '420001', 'receiver_locality' => 'Moscow', 'receiver_country_code' => 'RU', 'receiver_locality_translated' => 'Москва', 'receiver_postal_code' => '101000', 'receiver_phone' => '+79510665133', 'sender_full_name' => 'Aydar Akhmeyzyanov', 'sender_type' => 'c', 'sender_company' => 'creativestripe', 'receiver_full_name' => 'Vadim Perov', 'receiver_type' => 'p', 'collection_local_date' => date("Y-m-d", $days2), 'delivery_timezone' => '4', 'sender_street' => 'chetaeva', 'sender_housenumber' => '1', 'sender_roomnumber' => '2', 'receiver_street' => 'chetaeva', 'receiver_housenumber' => '3', 'receiver_roomnumber' => '5', 'sender_significantinformation' => 'wtf???', 'invoice_contents' => 'wtf???', 'invoice_price' => '200', 'extra_insurance' => '100');
$response2 = json_decode($I->grabResponse(), true);
$requiredParams['provider_price_data'] = json_encode($response2['data']['0']);
$data = $requiredParams;
$I->sendPOST('Ship?action=create', $data);
$I->seeResponseIsJson();
Exemplo n.º 22
0
<?php

/*
 * Copyright (c) 2014 Ebizu Sdn. Bhd.
 */
/**
 * Get a user by ID API Test
 *
 * @author Budi Irawan <*****@*****.**>
 */
$I = new ApiGuy($scenario);
$I->wantTo('get user by id');
$I->sendGET('users/1');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
Exemplo n.º 23
0
<?php

$I = new ApiGuy($scenario);
$I->wantTo('Add Station to Favorite');
$I->haveHttpHeader('Content-Type', 'application/json');
include 'loginCept.php';
$I->amBearerAuthenticated($token);
include 'getStationByNameCept.php';
$I->sendPOST('/favorite/station', array('station_id' => $station));
$I->seeResponseCodeIs(200);
Exemplo n.º 24
0
<?php

/**
 * Copyright (c) 2014 Ebizu Sdn. Bhd.
 */
/**
 * Create Bid 
 *
 * @author Budi Irawan <*****@*****.**>
 */
$I = new ApiGuy($scenario);
$I->wantTo('create bid');
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
$newBid = ["bid_usr_id" => 2, "bid_shp_id" => 1, "bid_amount" => 5000, "bid_description" => "mantap", "bid_starting" => 80, "bid_lowest" => 10];
$I->sendPOST('bids', $newBid);
$I->seeResponseIsJson();
Exemplo n.º 25
0
<?php

/*
 * Copyright (c) 2014 Ebizu Sdn. Bhd.
 */
/**
 * Get a category by ID API Test
 *
 * @author Budi Irawan <*****@*****.**>
 */
$I = new ApiGuy($scenario);
$I->wantTo('get category by id');
$I->sendGET('categories/495');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
<?php

$I = new ApiGuy($scenario);
$I->wantTo('TEST Terminals response');
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
$data = array();
$I->sendGET('Datasets/Terminals/Pickup/RU/Kazan?locality_translated=Казань&weight=10&length=100&width=100&height=100&provider_ID=2', $data);
$I->seeResponseIsJson();
$I->seeResponseContains('{"result":1,"data":[{"ID');
$PickupTerminal = json_decode($I->grabResponse(), true);
$datasetData['sender_terminal_ID'] = json_encode($PickupTerminal['data'][0]['ID']);
codecept_debug('[_Debug data] ' . $datasetData['sender_terminal_ID'] . ' test');
Exemplo n.º 27
0
<?php

/*
 * Copyright (c) 2014 Ebizu Sdn. Bhd.
 */
/**
 * List User API Test
 *
 * @author Budi Irawan <*****@*****.**>
 */
$I = new ApiGuy($scenario);
$I->wantTo('get all users');
$I->sendGET('users');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
Exemplo n.º 28
0
<?php

$I = new ApiGuy($scenario);
$I->wantTo('get Stations by Name');
$I->haveHttpHeader('Content-Type', 'application/json');
include 'constant.php';
$I->sendGET('/station/search/' . $station_name);
$st = $I->grabDataFromResponseByJsonPath('$..data[1].station_id');
$stat = serialize($st);
$station = substr("{$stat}", 14, -3);
$I->seeResponseCodeIs(200);
<?php

// broken
$I = new ApiGuy($scenario);
$I->wantTo('Get autocomplete for view via json request');
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
$I->sendPOST('/backend/view/autocomplete', array('q' => ''));
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
//$I->seeResponseContains('{ result: ok}');
Exemplo n.º 30
0
<?php

/*
 * Copyright (c) 2014 Ebizu Sdn. Bhd.
 */
/**
 * List Bid API Test
 *
 * @author Budi Irawan <*****@*****.**>
 */
$I = new ApiGuy($scenario);
$I->wantTo('get all bids');
$I->sendGET('pushes/android');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();