Working on the API

This commit is contained in:
Hillel Coren 2015-11-27 14:55:28 +02:00
parent 1497b99b36
commit cf458c52a2
29 changed files with 832 additions and 1061 deletions

View File

@ -51,26 +51,21 @@ class AccountApiController extends BaseAPIController
$this->accountRepo->createTokens($user, $request->token_name);
$users = $this->accountRepo->findUsers($user, 'account.account_tokens');
$data = $this->createCollection($users, new UserAccountTransformer($user->account, $request->token_name));
$transformer = new UserAccountTransformer($user->account, $request->serializer, $request->token_name);
$data = $this->createCollection($users, $transformer, 'user_account');
$response = [
'user_accounts' => $data
];
return $this->response($response);
return $this->response($data);
}
public function show()
public function show(Request $request)
{
$account = Auth::user()->account;
$account->loadAllData();
$account = $this->createItem($account, new AccountTransformer);
$response = [
'account' => $account
];
$transformer = new AccountTransformer(null, $request->serializer);
$account = $this->createItem($account, $transformer, 'account');
return $this->response($response);
return $this->response($account);
}
public function getStaticData()

View File

@ -1,12 +1,16 @@
<?php namespace App\Http\Controllers;
use Session;
use Utils;
use Response;
use Request;
use League\Fractal;
use League\Fractal\Manager;
use League\Fractal\Resource\Item;
use League\Fractal\Resource\Collection;
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
use App\Ninja\Serializers\ArraySerializer;
use League\Fractal\Serializer\JsonApiSerializer;
/**
* @SWG\Swagger(
@ -41,31 +45,88 @@ use App\Ninja\Serializers\ArraySerializer;
class BaseAPIController extends Controller
{
protected $manager;
protected $serializer;
public function __construct()
{
$this->manager = new Manager();
$this->manager->setSerializer(new ArraySerializer());
if ($include = Request::get('include')) {
$this->manager->parseIncludes($include);
}
$this->serializer = Request::get('serializer') ?: API_SERIALIZER_ARRAY;
if ($this->serializer === API_SERIALIZER_JSON) {
$this->manager->setSerializer(new JsonApiSerializer());
} else {
$this->manager->setSerializer(new ArraySerializer());
}
}
protected function createItem($data, $transformer)
protected function createItem($data, $transformer, $entityType)
{
$resource = new Item($data, $transformer);
if ($this->serializer && $this->serializer != API_SERIALIZER_JSON) {
$entityType = null;
}
$resource = new Item($data, $transformer, $entityType);
return $this->manager->createData($resource)->toArray();
}
protected function createCollection($data, $transformer)
protected function createCollection($data, $transformer, $entityType, $paginator = false)
{
$resource = new Collection($data, $transformer);
if ($this->serializer && $this->serializer != API_SERIALIZER_JSON) {
$entityType = null;
}
$resource = new Collection($data, $transformer, $entityType);
if ($paginator) {
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
}
return $this->manager->createData($resource)->toArray();
}
protected function response($response)
{
$index = Request::get('index') ?: 'data';
$meta = isset($response['meta']) ? $response['meta'] : null;
$response = [
$index => $response
];
if ($meta) {
$response['meta'] = $meta;
unset($response[$index]['meta']);
}
$response = json_encode($response, JSON_PRETTY_PRINT);
$headers = Utils::getApiHeaders();
return Response::make($response, 200, $headers);
}
protected function getIncluded()
{
$data = ['user'];
$included = Request::get('include');
$included = explode(',', $included);
foreach ($included as $include) {
if ($include == 'invoices') {
$data[] = 'invoices.invoice_items';
$data[] = 'invoices.user';
} elseif ($include == 'clients') {
$data[] = 'clients.contacts';
$data[] = 'clients.user';
} elseif ($include) {
$data[] = $include;
}
}
return $data;
}
}

View File

@ -3,10 +3,11 @@
use Utils;
use Response;
use Input;
use Auth;
use App\Models\Client;
use App\Http\Controllers\BaseAPIController;
use App\Ninja\Repositories\ClientRepository;
use App\Http\Requests\CreateClientRequest;
use App\Http\Controllers\BaseAPIController;
use App\Ninja\Transformers\ClientTransformer;
class ClientApiController extends BaseAPIController
@ -46,17 +47,16 @@ class ClientApiController extends BaseAPIController
public function index()
{
$clients = Client::scope()
->with('country', 'contacts', 'industry', 'size', 'currency')
->with($this->getIncluded())
->orderBy('created_at', 'desc')
->get();
->paginate();
$data = $this->createCollection($clients, new ClientTransformer(\Auth::user()->account));
$transformer = new ClientTransformer(Auth::user()->account, Input::get('serializer'));
$paginator = Client::scope()->paginate();
$response = [
'clients' => $data
];
$data = $this->createCollection($clients, $transformer, ENTITY_CLIENT, $paginator);
return $this->response($response);
return $this->response($data);
}
/**
@ -83,15 +83,14 @@ class ClientApiController extends BaseAPIController
public function store(CreateClientRequest $request)
{
$client = $this->clientRepo->save($request->input());
$client = Client::scope($client->public_id)
->with('country', 'contacts', 'industry', 'size', 'currency')
->first();
$client = Client::scope($client->public_id)->with('country', 'contacts', 'industry', 'size', 'currency')->first();
$transformer = new ClientTransformer(Auth::user()->account, Input::get('serializer'));
$data = $this->createItem($client, $transformer, ENTITY_CLIENT);
$data = $this->createItem($client, new ClientTransformer(\Auth::user()->account));
$response = [
'client' => $data
];
return $this->response($response);
return $this->response($data);
}
}

View File

@ -13,13 +13,17 @@ use App\Models\Invitation;
use App\Ninja\Repositories\ClientRepository;
use App\Ninja\Repositories\InvoiceRepository;
use App\Ninja\Mailers\ContactMailer as Mailer;
use App\Http\Controllers\BaseAPIController;
use App\Ninja\Transformers\InvoiceTransformer;
class InvoiceApiController extends Controller
class InvoiceApiController extends BaseAPIController
{
protected $invoiceRepo;
public function __construct(InvoiceRepository $invoiceRepo, ClientRepository $clientRepo, Mailer $mailer)
{
parent::__construct();
$this->invoiceRepo = $invoiceRepo;
$this->clientRepo = $clientRepo;
$this->mailer = $mailer;
@ -41,20 +45,24 @@ class InvoiceApiController extends Controller
* )
* )
*/
public function index($clientPublicId = false)
public function index()
{
$paginator = Invoice::scope();
$invoices = Invoice::scope()
->with('client', 'invitations.account')
->with(array_merge(['invoice_items'], $this->getIncluded()))
->where('invoices.is_quote', '=', false);
if ($clientPublicId) {
$invoices->whereHas('client', function($query) use ($clientPublicId) {
if ($clientPublicId = Input::get('client_id')) {
$filter = function($query) use ($clientPublicId) {
$query->where('public_id', '=', $clientPublicId);
});
};
$invoices->whereHas('client', $filter);
$paginator->whereHas('client', $filter);
}
$invoices = $invoices->orderBy('created_at', 'desc')->get();
$invoices = $invoices->orderBy('created_at', 'desc')->paginate();
/*
// Add the first invitation link to the data
foreach ($invoices as $key => $invoice) {
foreach ($invoice->invitations as $subKey => $invitation) {
@ -62,13 +70,14 @@ class InvoiceApiController extends Controller
}
unset($invoice['invitations']);
}
*/
$invoices = Utils::remapPublicIds($invoices);
$response = json_encode($invoices, JSON_PRETTY_PRINT);
$headers = Utils::getApiHeaders(count($invoices));
$transformer = new InvoiceTransformer(Auth::user()->account, Input::get('serializer'));
$paginator = $paginator->paginate();
return Response::make($response, 200, $headers);
$data = $this->createCollection($invoices, $transformer, 'invoices', $paginator);
return $this->response($data);
}
@ -145,14 +154,14 @@ class InvoiceApiController extends Controller
if (!$error) {
if (!isset($data['client_id']) && !isset($data['email'])) {
$error = trans('validation.', ['attribute' => 'client_id or email']);
$error = trans('validation.required_without', ['attribute' => 'client_id', 'values' => 'email']);
} else if (!$client) {
$error = trans('validation.not_in', ['attribute' => 'client_id']);
}
}
if ($error) {
$response = json_encode($error, JSON_PRETTY_PRINT);
return $error;
} else {
$data = self::prepareData($data, $client);
$data['client_id'] = $client->id;
@ -170,16 +179,12 @@ class InvoiceApiController extends Controller
$this->mailer->sendInvoice($invoice);
}
// prepare the return data
$invoice = Invoice::scope($invoice->public_id)->with('client', 'invoice_items', 'invitations')->first();
$invoice = Utils::remapPublicIds([$invoice]);
$transformer = new InvoiceTransformer(\Auth::user()->account, Input::get('serializer'));
$data = $this->createItem($invoice, $transformer, 'invoice');
$response = json_encode($invoice, JSON_PRETTY_PRINT);
return $this->response($data);
}
$headers = Utils::getApiHeaders();
return Response::make($response, $error ? 400 : 200, $headers);
}
private function prepareData($data, $client)

View File

@ -1,18 +1,23 @@
<?php namespace App\Http\Controllers;
use Auth;
use Input;
use Utils;
use Response;
use App\Models\Payment;
use App\Models\Invoice;
use App\Ninja\Repositories\PaymentRepository;
use App\Http\Controllers\BaseAPIController;
use App\Ninja\Transformers\PaymentTransformer;
class PaymentApiController extends Controller
class PaymentApiController extends BaseAPIController
{
protected $paymentRepo;
public function __construct(PaymentRepository $paymentRepo)
{
parent::__construct();
$this->paymentRepo = $paymentRepo;
}
@ -32,27 +37,29 @@ class PaymentApiController extends Controller
* )
* )
*/
public function index($clientPublicId = false)
public function index()
{
$paginator = Payment::scope();
$payments = Payment::scope()
->with('client', 'contact', 'invitation', 'user', 'invoice');
->with('client.contacts', 'invitation', 'user', 'invoice');
if ($clientPublicId) {
$payments->whereHas('client', function($query) use ($clientPublicId) {
if ($clientPublicId = Input::get('client_id')) {
$filter = function($query) use ($clientPublicId) {
$query->where('public_id', '=', $clientPublicId);
});
};
$payments->whereHas('client', $filter);
$paginator->whereHas('client', $filter);
}
$payments = $payments->orderBy('created_at', 'desc')->get();
$payments = Utils::remapPublicIds($payments);
$payments = $payments->orderBy('created_at', 'desc')->paginate();
$paginator = $paginator->paginate();
$transformer = new PaymentTransformer(Auth::user()->account, Input::get('serializer'));
$response = json_encode($payments, JSON_PRETTY_PRINT);
$headers = Utils::getApiHeaders(count($payments));
$data = $this->createCollection($payments, $transformer, 'payments', $paginator);
return Response::make($response, 200, $headers);
return $this->response($data);
}
/**
* @SWG\Post(
* path="/payments",
@ -96,15 +103,17 @@ class PaymentApiController extends Controller
$data['transaction_reference'] = '';
}
if (!$error) {
$payment = $this->paymentRepo->save($data);
$payment = Payment::scope($payment->public_id)->with('client', 'contact', 'user', 'invoice')->first();
$payment = Utils::remapPublicIds([$payment]);
if ($error) {
return $error;
}
$response = json_encode($error ?: $payment, JSON_PRETTY_PRINT);
$headers = Utils::getApiHeaders();
return Response::make($response, 200, $headers);
$payment = $this->paymentRepo->save($data);
$payment = Payment::scope($payment->public_id)->with('client', 'contact', 'user', 'invoice')->first();
$transformer = new PaymentTransformer(Auth::user()->account, Input::get('serializer'));
$data = $this->createItem($payment, $transformer, 'payment');
return $this->response($data);
}
}

View File

@ -391,11 +391,11 @@ class PaymentController extends BaseController
// check if we're creating/using a billing token
if ($accountGateway->gateway_id == GATEWAY_STRIPE) {
if ($useToken) {
$details['cardReference'] = $client->getGatewayToken();
$details['customerReference'] = $client->getGatewayToken();
} elseif ($account->token_billing_type_id == TOKEN_BILLING_ALWAYS || Input::get('token_billing')) {
$token = $this->paymentService->createToken($gateway, $details, $accountGateway, $client, $invitation->contact_id);
if ($token) {
$details['cardReference'] = $token;
$details['customerReference'] = $token;
} else {
$this->error('Token-No-Ref', $this->paymentService->lastError, $accountGateway);
return Redirect::to('payment/'.$invitationKey)->withInput();

View File

@ -1,16 +1,22 @@
<?php namespace App\Http\Controllers;
use Auth;
use Input;
use Utils;
use Response;
use App\Models\Invoice;
use App\Ninja\Repositories\InvoiceRepository;
use App\Http\Controllers\BaseAPIController;
use App\Ninja\Transformers\QuoteTransformer;
class QuoteApiController extends Controller
class QuoteApiController extends BaseAPIController
{
protected $invoiceRepo;
public function __construct(InvoiceRepository $invoiceRepo)
{
parent::__construct();
$this->invoiceRepo = $invoiceRepo;
}
@ -30,25 +36,29 @@ class QuoteApiController extends Controller
* )
* )
*/
public function index($clientPublicId = false)
public function index()
{
$paginator = Invoice::scope();
$invoices = Invoice::scope()
->with('client', 'user')
->with('client', 'invitations', 'user', 'invoice_items')
->where('invoices.is_quote', '=', true);
if ($clientPublicId) {
$invoices->whereHas('client', function($query) use ($clientPublicId) {
if ($clientPublicId = Input::get('client_id')) {
$filter = function($query) use ($clientPublicId) {
$query->where('public_id', '=', $clientPublicId);
});
};
$invoices->whereHas('client', $filter);
$paginator->whereHas('client', $filter);
}
$invoices = $invoices->orderBy('created_at', 'desc')->get();
$invoices = Utils::remapPublicIds($invoices);
$invoices = $invoices->orderBy('created_at', 'desc')->paginate();
$transformer = new QuoteTransformer(\Auth::user()->account, Input::get('serializer'));
$paginator = $paginator->paginate();
$response = json_encode($invoices, JSON_PRETTY_PRINT);
$headers = Utils::getApiHeaders(count($invoices));
$data = $this->createCollection($invoices, $transformer, 'quotes', $paginator);
return Response::make($response, 200, $headers);
return $this->response($data);
}
/*

View File

@ -1,17 +1,22 @@
<?php namespace App\Http\Controllers;
use Auth;
use Utils;
use Response;
use Input;
use App\Models\Task;
use App\Ninja\Repositories\TaskRepository;
use App\Http\Controllers\BaseAPIController;
use App\Ninja\Transformers\TaskTransformer;
class TaskApiController extends Controller
class TaskApiController extends BaseAPIController
{
protected $taskRepo;
public function __construct(TaskRepository $taskRepo)
{
parent::__construct();
$this->taskRepo = $taskRepo;
}
@ -31,23 +36,27 @@ class TaskApiController extends Controller
* )
* )
*/
public function index($clientPublicId = false)
public function index()
{
$tasks = Task::scope()->with('client');
$paginator = Task::scope();
$tasks = Task::scope()
->with($this->getIncluded());
if ($clientPublicId) {
$tasks->whereHas('client', function($query) use ($clientPublicId) {
if ($clientPublicId = Input::get('client_id')) {
$filter = function($query) use ($clientPublicId) {
$query->where('public_id', '=', $clientPublicId);
});
};
$tasks->whereHas('client', $filter);
$paginator->whereHas('client', $filter);
}
$tasks = $tasks->orderBy('created_at', 'desc')->get();
$tasks = Utils::remapPublicIds($tasks);
$tasks = $tasks->orderBy('created_at', 'desc')->paginate();
$paginator = $paginator->paginate();
$transformer = new TaskTransformer(\Auth::user()->account, Input::get('serializer'));
$response = json_encode($tasks, JSON_PRETTY_PRINT);
$headers = Utils::getApiHeaders(count($tasks));
$data = $this->createCollection($tasks, $transformer, 'tasks', $paginator);
return Response::make($response, 200, $headers);
return $this->response($data);
}
/**
@ -82,12 +91,11 @@ class TaskApiController extends Controller
$task = $this->taskRepo->save($taskId, $data);
$task = Task::scope($task->public_id)->with('client')->first();
$task = Utils::remapPublicIds([$task]);
$response = json_encode($task, JSON_PRETTY_PRINT);
$headers = Utils::getApiHeaders();
$transformer = new TaskTransformer(Auth::user()->account, Input::get('serializer'));
$data = $this->createItem($task, $transformer, 'task');
return Response::make($response, 200, $headers);
return $this->response($data);
}
}

View File

@ -199,13 +199,13 @@ Route::group(['middleware' => 'api', 'prefix' => 'api/v1'], function()
Route::get('static', 'AccountApiController@getStaticData');
Route::get('accounts', 'AccountApiController@show');
Route::resource('clients', 'ClientApiController');
Route::get('quotes/{client_id?}', 'QuoteApiController@index');
Route::get('quotes', 'QuoteApiController@index');
Route::resource('quotes', 'QuoteApiController');
Route::get('invoices/{client_id?}', 'InvoiceApiController@index');
Route::get('invoices', 'InvoiceApiController@index');
Route::resource('invoices', 'InvoiceApiController');
Route::get('payments/{client_id?}', 'PaymentApiController@index');
Route::get('payments', 'PaymentApiController@index');
Route::resource('payments', 'PaymentApiController');
Route::get('tasks/{client_id?}', 'TaskApiController@index');
Route::get('tasks', 'TaskApiController@index');
Route::resource('tasks', 'TaskApiController');
Route::post('hooks', 'IntegrationController@subscribe');
Route::post('email_invoice', 'InvoiceApiController@emailInvoice');
@ -250,7 +250,9 @@ if (!defined('CONTACT_EMAIL')) {
define('RECENTLY_VIEWED', 'RECENTLY_VIEWED');
define('ENTITY_CLIENT', 'client');
define('ENTITY_CONTACT', 'contact');
define('ENTITY_INVOICE', 'invoice');
define('ENTITY_INVOICE_ITEMS', 'invoice_items');
define('ENTITY_RECURRING_INVOICE', 'recurring_invoice');
define('ENTITY_PAYMENT', 'payment');
define('ENTITY_CREDIT', 'credit');
@ -442,6 +444,7 @@ if (!defined('CONTACT_EMAIL')) {
define('OUTDATE_BROWSER_URL', 'http://browsehappy.com/');
define('PDFMAKE_DOCS', 'http://pdfmake.org/playground.html');
define('PHANTOMJS_CLOUD', 'http://api.phantomjscloud.com/single/browser/v1/');
//define('PHANTOMJS_CLOUD', 'http://api.phantomjscloud.com/api/browser/v2/');
define('PHP_DATE_FORMATS', 'http://php.net/manual/en/function.date.php');
define('REFERRAL_PROGRAM_URL', 'https://www.invoiceninja.com/referral-program/');
@ -492,7 +495,9 @@ if (!defined('CONTACT_EMAIL')) {
define('USER_STATE_PENDING', 'pending');
define('USER_STATE_DISABLED', 'disabled');
define('USER_STATE_ADMIN', 'admin');
define('API_SERIALIZER_ARRAY', 'array');
define('API_SERIALIZER_JSON', 'json');
$creditCards = [
1 => ['card' => 'images/credit_cards/Test-Visa-Icon.png', 'text' => 'Visa'],
@ -542,7 +547,6 @@ if (!defined('CONTACT_EMAIL')) {
}
}
/*
// Log all SQL queries to laravel.log
if (Utils::isNinjaDev()) {
Event::listen('illuminate.query', function($query, $bindings, $time, $name) {
@ -564,11 +568,10 @@ if (Utils::isNinjaDev()) {
Log::info($query, $data);
});
}
*/
/*
if (Auth::check() && Auth::user()->id === 1)
{
Auth::loginUsingId(1);
}
*/
*/

View File

@ -590,18 +590,6 @@ class Utils
}
}
public static function remapPublicIds($items)
{
$return = [];
foreach ($items as $item) {
$return[] = $item->toPublicArray();
}
return $return;
}
public static function hideIds($data, $mapped = false)
{
$publicId = null;

View File

@ -612,7 +612,6 @@ class Invoice extends EntityModel implements BalanceAffecting
$invitation = $this->invitations[0];
$link = $invitation->getLink();
$curl = curl_init();
$jsonEncodedData = json_encode([
'targetUrl' => "{$link}?phantomjs=true",

View File

@ -7,7 +7,7 @@ use App\Models\Product;
use League\Fractal;
use League\Fractal\TransformerAbstract;
class AccountTransformer extends TransformerAbstract
class AccountTransformer extends EntityTransformer
{
protected $defaultIncludes = [
'users',
@ -19,27 +19,32 @@ class AccountTransformer extends TransformerAbstract
public function includeUsers(Account $account)
{
return $this->collection($account->users, new UserTransformer($account));
$transformer = new UserTransformer($account, $this->serializer);
return $this->includeCollection($account->users, $transformer, 'users');
}
public function includeClients(Account $account)
{
return $this->collection($account->clients, new ClientTransformer($account));
$transformer = new ClientTransformer($account, $this->serializer);
return $this->includeCollection($account->clients, $transformer, 'clients');
}
public function includeInvoices(Account $account)
{
return $this->collection($account->invoices, new InvoiceTransformer($account));
$transformer = new InvoiceTransformer($account, $this->serializer);
return $this->includeCollection($account->invoices, $transformer, 'invoices');
}
public function includeContacts(Account $account)
{
return $this->collection($account->contacts, new ContactTransformer($account));
$transformer = new ContactTransformer($account, $this->serializer);
return $this->includeCollection($account->contacts, $transformer, 'contacts');
}
public function includeProducts(Account $account)
{
return $this->collection($account->products, new ProductTransformer($account));
$transformer = new ProductTransformer($account, $this->serializer);
return $this->includeCollection($account->products, $transformer, 'products');
}
public function transform(Account $account)

View File

@ -40,25 +40,28 @@ class ClientTransformer extends EntityTransformer
* @SWG\Property(property="language_id", type="integer", example=1)
*/
protected $defaultIncludes = [
// 'contacts',
// 'invoices',
// 'quotes',
protected $availableIncludes = [
'contacts',
'invoices',
'quotes',
];
public function includeContacts(Client $client)
{
return $this->collection($client->contacts, new ContactTransformer($this->account));
$transformer = new ContactTransformer($this->account, $this->serializer);
return $this->includeCollection($client->contacts, $transformer, ENTITY_CONTACT);
}
public function includeInvoices(Client $client)
{
return $this->collection($client->getInvoices, new InvoiceTransformer($this->account, $client));
$transformer = new InvoiceTransformer($this->account, $this->serializer);
return $this->includeCollection($client->getInvoices, $transformer, ENTITY_INVOICE);
}
public function includeQuotes(Client $client)
{
return $this->collection($client->getQuotes, new QuoteTransformer($this->account, $client));
$transformer = new QuoteTransformer($this->account, $this->serializer);
return $this->includeCollection($client->getQuotes, $transformer, ENTITY_QUOTE);
}
public function transform(Client $client)
@ -68,7 +71,7 @@ class ClientTransformer extends EntityTransformer
'name' => $client->name,
'balance' => (float) $client->balance,
'paid_to_date' => (float) $client->paid_to_date,
'user_id' => (int) $client->user->public_id+1,
'user_id' => (int) $client->user->public_id + 1,
'account_key' => $this->account->account_key,
'updated_at' => $client->updated_at,
'deleted_at' => $client->deleted_at,

View File

@ -20,7 +20,6 @@ class ContactTransformer extends EntityTransformer
'phone' => $contact->phone,
'last_login' => $contact->last_login,
'account_key' => $this->account->account_key,
'client_id' => $contact->client->public_id
];
}
}

View File

@ -1,14 +1,35 @@
<?php namespace App\Ninja\Transformers;
use App\Models\Account;
use App\Models\Client;
use League\Fractal\TransformerAbstract;
class EntityTransformer extends TransformerAbstract
{
protected $account;
protected $serializer;
public function __construct(Account $account)
public function __construct(Account $account = null, $serializer = null)
{
$this->account = $account;
$this->serializer = $serializer;
}
protected function includeCollection($data, $transformer, $entityType)
{
if ($this->serializer && $this->serializer != API_SERIALIZER_JSON) {
$entityType = null;
}
return $this->collection($data, $transformer, $entityType);
}
protected function includeItem($data, $transformer, $entityType)
{
if ($this->serializer && $this->serializer != API_SERIALIZER_JSON) {
$entityType = null;
}
return $this->item($data, $transformer, $entityType);
}
}

View File

@ -20,20 +20,14 @@ class InvoiceTransformer extends EntityTransformer
* @SWG\Property(property="invoice_status_id", type="integer", example=1)
*/
public function __construct(Account $account)
{
parent::__construct($account);
}
protected $defaultIncludes = [
'invoice_items',
];
public function includeInvoiceItems(Invoice $invoice)
{
return $this->collection($invoice->invoice_items, new InvoiceItemTransformer($this->account));
$transformer = new InvoiceItemTransformer($this->account, $this->serializer);
return $this->includeCollection($invoice->invoice_items, $transformer, ENTITY_INVOICE_ITEMS);
}
public function transform(Invoice $invoice)
@ -70,7 +64,7 @@ class InvoiceTransformer extends EntityTransformer
'has_tasks' => (bool) $invoice->has_tasks,
'auto_bill' => (bool) $invoice->auto_bill,
'account_key' => $this->account->account_key,
'user_id' => (int) $invoice->user->public_id+1
'user_id' => (int) $invoice->user->public_id + 1
];
}
}

View File

@ -0,0 +1,55 @@
<?php namespace App\Ninja\Transformers;
use App\Models\Account;
use App\Models\Payment;
use App\Models\Invoice;
use App\Models\Client;
use League\Fractal;
use App\Ninja\Transformers\InvoiceTransformer;
/**
* @SWG\Definition(definition="Payment", required={"invoice_id"}, @SWG\Xml(name="Payment"))
*/
class PaymentTransformer extends EntityTransformer
{
/**
* @SWG\Property(property="id", type="integer", example=1, readOnly=true)
* @SWG\Property(property="amount", type="float", example=10, readOnly=true)
* @SWG\Property(property="invoice_id", type="integer", example=1)
*/
protected $defaultIncludes = [
'invoice',
'client',
];
public function __construct(Account $account)
{
parent::__construct($account);
}
public function includeInvoice(Payment $payment)
{
$transformer = new InvoiceTransformer($this->account, $this->serializer);
return $this->includeItem($payment->invoice, $transformer, 'invoice');
}
public function includeClient(Payment $payment)
{
$transformer = new ClientTransformer($this->account, $this->serializer);
return $this->includeItem($payment->client, $transformer, 'client');
}
public function transform(Payment $payment)
{
return [
'id' => (int) $payment->public_id,
'amount' => (float) $payment->amount,
'account_key' => $this->account->account_key,
'user_id' => (int) $payment->user->public_id + 1,
'transaction_reference' => $payment->transaction_reference,
];
}
}

View File

@ -11,7 +11,8 @@ class QuoteTransformer extends EntityTransformer
public function includeInvoiceItems($invoice)
{
return $this->collection($invoice->invoice_items, new InvoiceItemTransformer($this->account));
$transformer = new InvoiceItemTransformer($this->account, $this->serializer);
return $this->includeCollection($invoice->invoice_items, $transformer, 'invoice_items');
}
public function transform(Invoice $invoice)

View File

@ -0,0 +1,50 @@
<?php namespace App\Ninja\Transformers;
use App\Models\Account;
use App\Models\Task;
use App\Models\Client;
use League\Fractal;
/**
* @SWG\Definition(definition="Task", @SWG\Xml(name="Task"))
*/
class TaskTransformer extends EntityTransformer
{
/**
* @SWG\Property(property="id", type="integer", example=1, readOnly=true)
* @SWG\Property(property="amount", type="float", example=10, readOnly=true)
* @SWG\Property(property="invoice_id", type="integer", example=1)
*/
protected $availableIncludes = [
'client',
];
public function __construct(Account $account)
{
parent::__construct($account);
}
public function includeClient(Task $task)
{
if ($task->client) {
$transformer = new ClientTransformer($this->account, $this->serializer);
return $this->includeItem($task->client, $transformer, 'client');
} else {
return null;
}
}
public function transform(Task $task)
{
return [
'id' => (int) $task->public_id,
'account_key' => $this->account->account_key,
'user_id' => (int) $task->user->public_id + 1,
'description' => $task->description,
'duration' => $task->getDuration()
];
}
}

View File

@ -14,16 +14,17 @@ class UserAccountTransformer extends EntityTransformer
protected $tokenName;
public function __construct(Account $account, $tokenName)
public function __construct(Account $account, $serializer, $tokenName)
{
parent::__construct($account);
parent::__construct($account, $serializer);
$this->tokenName = $tokenName;
}
public function includeUser(User $user)
{
return $this->item($user, new UserTransformer($this->account));
$transformer = new UserTransformer($this->account, $this->serializer);
return $this->includeItem($user, $transformer, 'user');
}
public function transform(User $user)

View File

@ -159,7 +159,7 @@ class PaymentService extends BaseService
public function createToken($gateway, $details, $accountGateway, $client, $contactId)
{
$tokenResponse = $gateway->createCard($details)->send();
$cardReference = $tokenResponse->getCardReference();
$cardReference = $tokenResponse->getCustomerReference();
if ($cardReference) {
$token = AccountGatewayToken::where('client_id', '=', $client->id)
@ -237,7 +237,7 @@ class PaymentService extends BaseService
// setup the gateway/payment info
$gateway = $this->createGateway($accountGateway);
$details = $this->getPaymentDetails($invitation, $accountGateway);
$details['cardReference'] = $token;
$details['customerReference'] = $token;
// submit purchase/get response
$response = $gateway->purchase($details)->send();

30
c3.php
View File

@ -33,7 +33,14 @@ if (!array_key_exists('HTTP_X_CODECEPTION_CODECOVERAGE', $_SERVER)) {
if (!function_exists('__c3_error')) {
function __c3_error($message)
{
file_put_contents(C3_CODECOVERAGE_MEDIATE_STORAGE . DIRECTORY_SEPARATOR . 'error.txt', $message);
$errorLogFile = defined('C3_CODECOVERAGE_ERROR_LOG_FILE') ?
C3_CODECOVERAGE_ERROR_LOG_FILE :
C3_CODECOVERAGE_MEDIATE_STORAGE . DIRECTORY_SEPARATOR . 'error.txt';
if (is_writable($errorLogFile)) {
file_put_contents($errorLogFile, $message);
}else{
$message = "Could not write error to log file ($errorLogFile), original message: $message";
}
if (!headers_sent()) {
header('X-Codeception-CodeCoverage-Error: ' . str_replace("\n", ' ', $message), true, 500);
}
@ -43,10 +50,14 @@ if (!function_exists('__c3_error')) {
// Autoload Codeception classes
if (!class_exists('\\Codeception\\Codecept')) {
if (stream_resolve_include_path(__DIR__ . '/vendor/autoload.php')) {
require_once __DIR__ . '/vendor/autoload.php';
} elseif (file_exists(__DIR__ . '/codecept.phar')) {
if (file_exists(__DIR__ . '/codecept.phar')) {
require_once 'phar://'.__DIR__ . '/codecept.phar/autoload.php';
} elseif (stream_resolve_include_path(__DIR__ . '/vendor/autoload.php')) {
require_once __DIR__ . '/vendor/autoload.php';
// Required to load some methods only available at codeception/autoload.php
if (stream_resolve_include_path(__DIR__ . '/vendor/codeception/codeception/autoload.php')) {
require_once __DIR__ . '/vendor/codeception/codeception/autoload.php';
}
} elseif (stream_resolve_include_path('Codeception/autoload.php')) {
require_once 'Codeception/autoload.php';
} else {
@ -55,11 +66,18 @@ if (!class_exists('\\Codeception\\Codecept')) {
}
// Load Codeception Config
$config_dist_file = realpath(__DIR__) . DIRECTORY_SEPARATOR . 'codeception.dist.yml';
$config_file = realpath(__DIR__) . DIRECTORY_SEPARATOR . 'codeception.yml';
if (isset($_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_CONFIG'])) {
$config_file = realpath(__DIR__) . DIRECTORY_SEPARATOR . $_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_CONFIG'];
}
if (!file_exists($config_file)) {
if (file_exists($config_file)) {
// Use codeception.yml for configuration.
} elseif (file_exists($config_dist_file)) {
// Use codeception.dist.yml for configuration.
$config_file = $config_dist_file;
} else {
__c3_error(sprintf("Codeception config file '%s' not found", $config_file));
}
try {
@ -237,4 +255,4 @@ if ($requested_c3_report) {
}
}
// @codeCoverageIgnoreEnd
// @codeCoverageIgnoreEnd

View File

@ -66,7 +66,7 @@
"require-dev": {
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1",
"codeception/codeception": "~2.0",
"codeception/codeception": "2.1.2",
"codeception/c3": "~2.0",
"fzaninotto/faker": "^1.5"
},

253
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "b6c2660a613f4e94f13f226ec19c66eb",
"hash": "6966ff410ab9fb5745347a70ab9d85ca",
"packages": [
{
"name": "agmscode/omnipay-agms",
@ -779,16 +779,16 @@
},
{
"name": "collizo4sky/omnipay-wepay",
"version": "1.0",
"version": "1.1",
"source": {
"type": "git",
"url": "https://github.com/Collizo4sky/omnipay-wepay.git",
"reference": "360abf8c4bb4a926c39846abde970ab7dad93cb2"
"url": "https://github.com/collizo4sky/omnipay-wepay.git",
"reference": "bcc235113915c1547f62b8f02019f6289869c95c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Collizo4sky/omnipay-wepay/zipball/360abf8c4bb4a926c39846abde970ab7dad93cb2",
"reference": "360abf8c4bb4a926c39846abde970ab7dad93cb2",
"url": "https://api.github.com/repos/collizo4sky/omnipay-wepay/zipball/bcc235113915c1547f62b8f02019f6289869c95c",
"reference": "bcc235113915c1547f62b8f02019f6289869c95c",
"shasum": ""
},
"require": {
@ -800,7 +800,7 @@
},
"type": "library",
"autoload": {
"psr-0": {
"psr-4": {
"Omnipay\\WePay\\": "src/"
}
},
@ -809,7 +809,7 @@
"MIT"
],
"description": "WePay driver for the Omnipay payment processing library",
"homepage": "https://github.com/Collizo4sky/omnipay-wepay",
"homepage": "https://github.com/collizo4sky/omnipay-wepay",
"keywords": [
"gateway",
"merchant",
@ -818,7 +818,7 @@
"payment",
"wepay"
],
"time": "2015-10-08 14:12:18"
"time": "2015-11-13 13:19:25"
},
{
"name": "danielstjules/stringy",
@ -2610,12 +2610,12 @@
"source": {
"type": "git",
"url": "https://github.com/labs7in0/omnipay-wechat.git",
"reference": "d4c46d37f438c48510840aa3e5b806d4280c6b40"
"reference": "4e279ff4535dfa0636a3d6af5c92b8e9dcc4311a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/labs7in0/omnipay-wechat/zipball/d4c46d37f438c48510840aa3e5b806d4280c6b40",
"reference": "d4c46d37f438c48510840aa3e5b806d4280c6b40",
"url": "https://api.github.com/repos/labs7in0/omnipay-wechat/zipball/4e279ff4535dfa0636a3d6af5c92b8e9dcc4311a",
"reference": "4e279ff4535dfa0636a3d6af5c92b8e9dcc4311a",
"shasum": ""
},
"require": {
@ -2651,7 +2651,7 @@
"purchase",
"wechat"
],
"time": "2015-10-27 05:12:08"
"time": "2015-11-16 11:04:21"
},
{
"name": "laracasts/presenter",
@ -5309,16 +5309,16 @@
},
{
"name": "omnipay/stripe",
"version": "v2.2.1",
"version": "v2.3.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/omnipay-stripe.git",
"reference": "906377e50045dc2ba9c612aa1f6924157e1f750e"
"reference": "54b816a5e95e34c988d71fb805b0232cfd7c1ce5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/omnipay-stripe/zipball/906377e50045dc2ba9c612aa1f6924157e1f750e",
"reference": "906377e50045dc2ba9c612aa1f6924157e1f750e",
"url": "https://api.github.com/repos/thephpleague/omnipay-stripe/zipball/54b816a5e95e34c988d71fb805b0232cfd7c1ce5",
"reference": "54b816a5e95e34c988d71fb805b0232cfd7c1ce5",
"shasum": ""
},
"require": {
@ -5362,7 +5362,7 @@
"payment",
"stripe"
],
"time": "2015-04-14 18:55:56"
"time": "2015-11-10 16:17:35"
},
{
"name": "omnipay/targetpay",
@ -6068,16 +6068,16 @@
},
{
"name": "symfony/class-loader",
"version": "v2.7.6",
"version": "v2.7.7",
"source": {
"type": "git",
"url": "https://github.com/symfony/class-loader.git",
"reference": "320f8d2a9cdbcbeb24be602c124aae9d998474a4"
"reference": "9d8359ca865621ba7f43ac6a3455d064d064bed7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/class-loader/zipball/320f8d2a9cdbcbeb24be602c124aae9d998474a4",
"reference": "320f8d2a9cdbcbeb24be602c124aae9d998474a4",
"url": "https://api.github.com/repos/symfony/class-loader/zipball/9d8359ca865621ba7f43ac6a3455d064d064bed7",
"reference": "9d8359ca865621ba7f43ac6a3455d064d064bed7",
"shasum": ""
},
"require": {
@ -6095,7 +6095,10 @@
"autoload": {
"psr-4": {
"Symfony\\Component\\ClassLoader\\": ""
}
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@ -6113,20 +6116,20 @@
],
"description": "Symfony ClassLoader Component",
"homepage": "https://symfony.com",
"time": "2015-10-23 14:47:27"
"time": "2015-10-30 20:10:21"
},
{
"name": "symfony/console",
"version": "v2.6.11",
"version": "v2.6.12",
"target-dir": "Symfony/Component/Console",
"source": {
"type": "git",
"url": "https://github.com/symfony/Console.git",
"url": "https://github.com/symfony/console.git",
"reference": "0e5e18ae09d3f5c06367759be940e9ed3f568359"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Console/zipball/0e5e18ae09d3f5c06367759be940e9ed3f568359",
"url": "https://api.github.com/repos/symfony/console/zipball/0e5e18ae09d3f5c06367759be940e9ed3f568359",
"reference": "0e5e18ae09d3f5c06367759be940e9ed3f568359",
"shasum": ""
},
@ -6175,16 +6178,16 @@
},
{
"name": "symfony/css-selector",
"version": "v2.7.6",
"version": "v2.7.7",
"source": {
"type": "git",
"url": "https://github.com/symfony/css-selector.git",
"reference": "e1b865b26be4a56d22a8dee398375044a80c865b"
"reference": "abb47717fb88aebd9437da2fc8bb01a50a36679f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/css-selector/zipball/e1b865b26be4a56d22a8dee398375044a80c865b",
"reference": "e1b865b26be4a56d22a8dee398375044a80c865b",
"url": "https://api.github.com/repos/symfony/css-selector/zipball/abb47717fb88aebd9437da2fc8bb01a50a36679f",
"reference": "abb47717fb88aebd9437da2fc8bb01a50a36679f",
"shasum": ""
},
"require": {
@ -6199,7 +6202,10 @@
"autoload": {
"psr-4": {
"Symfony\\Component\\CssSelector\\": ""
}
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@ -6221,20 +6227,20 @@
],
"description": "Symfony CssSelector Component",
"homepage": "https://symfony.com",
"time": "2015-10-11 09:39:48"
"time": "2015-10-30 20:10:21"
},
{
"name": "symfony/debug",
"version": "v2.6.11",
"version": "v2.6.12",
"target-dir": "Symfony/Component/Debug",
"source": {
"type": "git",
"url": "https://github.com/symfony/Debug.git",
"url": "https://github.com/symfony/debug.git",
"reference": "fca5696e0c9787722baa8f2ad6940dfd7a6a6941"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Debug/zipball/fca5696e0c9787722baa8f2ad6940dfd7a6a6941",
"url": "https://api.github.com/repos/symfony/debug/zipball/fca5696e0c9787722baa8f2ad6940dfd7a6a6941",
"reference": "fca5696e0c9787722baa8f2ad6940dfd7a6a6941",
"shasum": ""
},
@ -6286,16 +6292,16 @@
},
{
"name": "symfony/event-dispatcher",
"version": "v2.7.6",
"version": "v2.7.7",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
"reference": "87a5db5ea887763fa3a31a5471b512ff1596d9b8"
"reference": "7e2f9c31645680026c2372edf66f863fc7757af5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/87a5db5ea887763fa3a31a5471b512ff1596d9b8",
"reference": "87a5db5ea887763fa3a31a5471b512ff1596d9b8",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/7e2f9c31645680026c2372edf66f863fc7757af5",
"reference": "7e2f9c31645680026c2372edf66f863fc7757af5",
"shasum": ""
},
"require": {
@ -6321,7 +6327,10 @@
"autoload": {
"psr-4": {
"Symfony\\Component\\EventDispatcher\\": ""
}
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@ -6339,20 +6348,20 @@
],
"description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com",
"time": "2015-10-11 09:39:48"
"time": "2015-10-30 20:10:21"
},
{
"name": "symfony/filesystem",
"version": "v2.7.6",
"version": "v2.7.7",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
"reference": "56fd6df73be859323ff97418d97edc1d756df6df"
"reference": "8e173509d7fdbbba3cf34d6d072f2073c0210c1d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/56fd6df73be859323ff97418d97edc1d756df6df",
"reference": "56fd6df73be859323ff97418d97edc1d756df6df",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/8e173509d7fdbbba3cf34d6d072f2073c0210c1d",
"reference": "8e173509d7fdbbba3cf34d6d072f2073c0210c1d",
"shasum": ""
},
"require": {
@ -6367,7 +6376,10 @@
"autoload": {
"psr-4": {
"Symfony\\Component\\Filesystem\\": ""
}
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@ -6385,20 +6397,20 @@
],
"description": "Symfony Filesystem Component",
"homepage": "https://symfony.com",
"time": "2015-10-18 20:23:18"
"time": "2015-11-18 13:41:01"
},
{
"name": "symfony/finder",
"version": "v2.6.11",
"version": "v2.6.12",
"target-dir": "Symfony/Component/Finder",
"source": {
"type": "git",
"url": "https://github.com/symfony/Finder.git",
"url": "https://github.com/symfony/finder.git",
"reference": "203a10f928ae30176deeba33512999233181dd28"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Finder/zipball/203a10f928ae30176deeba33512999233181dd28",
"url": "https://api.github.com/repos/symfony/finder/zipball/203a10f928ae30176deeba33512999233181dd28",
"reference": "203a10f928ae30176deeba33512999233181dd28",
"shasum": ""
},
@ -6439,16 +6451,16 @@
},
{
"name": "symfony/http-foundation",
"version": "v2.6.11",
"version": "v2.6.12",
"target-dir": "Symfony/Component/HttpFoundation",
"source": {
"type": "git",
"url": "https://github.com/symfony/HttpFoundation.git",
"url": "https://github.com/symfony/http-foundation.git",
"reference": "e8fd1b73ac1c3de1f76c73801ddf1a8ecb1c1c9c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/e8fd1b73ac1c3de1f76c73801ddf1a8ecb1c1c9c",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/e8fd1b73ac1c3de1f76c73801ddf1a8ecb1c1c9c",
"reference": "e8fd1b73ac1c3de1f76c73801ddf1a8ecb1c1c9c",
"shasum": ""
},
@ -6493,17 +6505,17 @@
},
{
"name": "symfony/http-kernel",
"version": "v2.6.11",
"version": "v2.6.12",
"target-dir": "Symfony/Component/HttpKernel",
"source": {
"type": "git",
"url": "https://github.com/symfony/HttpKernel.git",
"reference": "a3f0ed713255c0400a2db38b3ed01989ef4b7322"
"url": "https://github.com/symfony/http-kernel.git",
"reference": "498866a8ca0bcbcd3f3824b1520fa568ff7ca3b6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/HttpKernel/zipball/a3f0ed713255c0400a2db38b3ed01989ef4b7322",
"reference": "a3f0ed713255c0400a2db38b3ed01989ef4b7322",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/498866a8ca0bcbcd3f3824b1520fa568ff7ca3b6",
"reference": "498866a8ca0bcbcd3f3824b1520fa568ff7ca3b6",
"shasum": ""
},
"require": {
@ -6567,20 +6579,20 @@
],
"description": "Symfony HttpKernel Component",
"homepage": "https://symfony.com",
"time": "2015-07-26 10:44:22"
"time": "2015-11-23 11:37:53"
},
{
"name": "symfony/process",
"version": "v2.6.11",
"version": "v2.6.12",
"target-dir": "Symfony/Component/Process",
"source": {
"type": "git",
"url": "https://github.com/symfony/Process.git",
"url": "https://github.com/symfony/process.git",
"reference": "57f1e88bb5dafa449b83f9f265b11d52d517b3e9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Process/zipball/57f1e88bb5dafa449b83f9f265b11d52d517b3e9",
"url": "https://api.github.com/repos/symfony/process/zipball/57f1e88bb5dafa449b83f9f265b11d52d517b3e9",
"reference": "57f1e88bb5dafa449b83f9f265b11d52d517b3e9",
"shasum": ""
},
@ -6621,16 +6633,16 @@
},
{
"name": "symfony/routing",
"version": "v2.6.11",
"version": "v2.6.12",
"target-dir": "Symfony/Component/Routing",
"source": {
"type": "git",
"url": "https://github.com/symfony/Routing.git",
"url": "https://github.com/symfony/routing.git",
"reference": "0a1764d41bbb54f3864808c50569ac382b44d128"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Routing/zipball/0a1764d41bbb54f3864808c50569ac382b44d128",
"url": "https://api.github.com/repos/symfony/routing/zipball/0a1764d41bbb54f3864808c50569ac382b44d128",
"reference": "0a1764d41bbb54f3864808c50569ac382b44d128",
"shasum": ""
},
@ -6690,7 +6702,7 @@
},
{
"name": "symfony/security-core",
"version": "v2.6.11",
"version": "v2.6.12",
"target-dir": "Symfony/Component/Security/Core",
"source": {
"type": "git",
@ -6754,16 +6766,16 @@
},
{
"name": "symfony/translation",
"version": "v2.6.11",
"version": "v2.6.12",
"target-dir": "Symfony/Component/Translation",
"source": {
"type": "git",
"url": "https://github.com/symfony/Translation.git",
"url": "https://github.com/symfony/translation.git",
"reference": "d84291215b5892834dd8ca8ee52f9cbdb8274904"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Translation/zipball/d84291215b5892834dd8ca8ee52f9cbdb8274904",
"url": "https://api.github.com/repos/symfony/translation/zipball/d84291215b5892834dd8ca8ee52f9cbdb8274904",
"reference": "d84291215b5892834dd8ca8ee52f9cbdb8274904",
"shasum": ""
},
@ -6813,7 +6825,7 @@
},
{
"name": "symfony/var-dumper",
"version": "v2.6.11",
"version": "v2.6.12",
"target-dir": "Symfony/Component/VarDumper",
"source": {
"type": "git",
@ -6966,16 +6978,16 @@
},
{
"name": "twbs/bootstrap",
"version": "v3.3.5",
"version": "v3.3.6",
"source": {
"type": "git",
"url": "https://github.com/twbs/bootstrap.git",
"reference": "16b48259a62f576e52c903c476bd42b90ab22482"
"reference": "81df608a40bf0629a1dc08e584849bb1e43e0b7a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twbs/bootstrap/zipball/16b48259a62f576e52c903c476bd42b90ab22482",
"reference": "16b48259a62f576e52c903c476bd42b90ab22482",
"url": "https://api.github.com/repos/twbs/bootstrap/zipball/81df608a40bf0629a1dc08e584849bb1e43e0b7a",
"reference": "81df608a40bf0629a1dc08e584849bb1e43e0b7a",
"shasum": ""
},
"replace": {
@ -7013,7 +7025,7 @@
"responsive",
"web"
],
"time": "2015-06-16 16:13:22"
"time": "2015-11-24 19:37:05"
},
{
"name": "vink/omnipay-komoju",
@ -7236,16 +7248,16 @@
},
{
"name": "zircote/swagger-php",
"version": "2.0.3",
"version": "2.0.4",
"source": {
"type": "git",
"url": "https://github.com/zircote/swagger-php.git",
"reference": "f6624cc067d7894ec32943f5b94cf282c683f7c7"
"reference": "be5d96e56c23cbe52c5bc5e267851323d95c57cd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zircote/swagger-php/zipball/f6624cc067d7894ec32943f5b94cf282c683f7c7",
"reference": "f6624cc067d7894ec32943f5b94cf282c683f7c7",
"url": "https://api.github.com/repos/zircote/swagger-php/zipball/be5d96e56c23cbe52c5bc5e267851323d95c57cd",
"reference": "be5d96e56c23cbe52c5bc5e267851323d95c57cd",
"shasum": ""
},
"require": {
@ -7292,28 +7304,32 @@
"rest",
"service discovery"
],
"time": "2015-10-18 13:05:54"
"time": "2015-11-13 13:50:11"
}
],
"packages-dev": [
{
"name": "codeception/c3",
"version": "2.0.3",
"version": "2.0.4",
"source": {
"type": "git",
"url": "https://github.com/Codeception/c3.git",
"reference": "30321efb2421c5d201d02e2cb8da1a1ca96e4a38"
"reference": "bc22b4f6cd1a7e74a98dbff541c055dbf0f6f7c8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Codeception/c3/zipball/30321efb2421c5d201d02e2cb8da1a1ca96e4a38",
"reference": "30321efb2421c5d201d02e2cb8da1a1ca96e4a38",
"url": "https://api.github.com/repos/Codeception/c3/zipball/bc22b4f6cd1a7e74a98dbff541c055dbf0f6f7c8",
"reference": "bc22b4f6cd1a7e74a98dbff541c055dbf0f6f7c8",
"shasum": ""
},
"require": {
"composer-plugin-api": "1.0.0",
"php": ">=5.4.0"
},
"type": "library",
"type": "composer-plugin",
"extra": {
"class": "Codeception\\c3\\Installer"
},
"autoload": {
"psr-4": {
"Codeception\\c3\\": "."
@ -7324,9 +7340,13 @@
"MIT"
],
"authors": [
{
"name": "Tiger Seo",
"email": "tiger.seo@gmail.com"
},
{
"name": "Michael Bodnarchuk",
"email": "davert.php@resend.cc",
"email": "davert.php@codegyre.com",
"homepage": "http://codegyre.com"
}
],
@ -7336,27 +7356,27 @@
"code coverage",
"codecoverage"
],
"time": "2014-11-18 22:06:45"
"time": "2015-11-25 04:03:09"
},
{
"name": "codeception/codeception",
"version": "2.1.4",
"version": "2.1.2",
"source": {
"type": "git",
"url": "https://github.com/Codeception/Codeception.git",
"reference": "6a812e8a0d1b1db939a29b4dc14cb398b21b6112"
"reference": "521adbb2ee34e9debdd8508a2c41ab2b5c2f042b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Codeception/Codeception/zipball/6a812e8a0d1b1db939a29b4dc14cb398b21b6112",
"reference": "6a812e8a0d1b1db939a29b4dc14cb398b21b6112",
"url": "https://api.github.com/repos/Codeception/Codeception/zipball/521adbb2ee34e9debdd8508a2c41ab2b5c2f042b",
"reference": "521adbb2ee34e9debdd8508a2c41ab2b5c2f042b",
"shasum": ""
},
"require": {
"ext-json": "*",
"ext-mbstring": "*",
"facebook/webdriver": ">=1.0.1",
"guzzlehttp/guzzle": ">=4.1.4 <7.0",
"guzzlehttp/guzzle": ">=4.0|<7.0",
"guzzlehttp/psr7": "~1.0",
"php": ">=5.4.0",
"phpunit/phpunit": "~4.8.0",
@ -7416,7 +7436,7 @@
"functional testing",
"unit testing"
],
"time": "2015-11-12 03:57:06"
"time": "2015-08-09 13:48:55"
},
{
"name": "doctrine/instantiator",
@ -8479,16 +8499,16 @@
},
{
"name": "symfony/browser-kit",
"version": "v2.7.6",
"version": "v2.7.7",
"source": {
"type": "git",
"url": "https://github.com/symfony/browser-kit.git",
"reference": "07d664a052572ccc28eb2ab7dbbe82155b1ad367"
"reference": "bd28847ea2193916074c7b11d4fdd78570049694"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/browser-kit/zipball/07d664a052572ccc28eb2ab7dbbe82155b1ad367",
"reference": "07d664a052572ccc28eb2ab7dbbe82155b1ad367",
"url": "https://api.github.com/repos/symfony/browser-kit/zipball/bd28847ea2193916074c7b11d4fdd78570049694",
"reference": "bd28847ea2193916074c7b11d4fdd78570049694",
"shasum": ""
},
"require": {
@ -8511,7 +8531,10 @@
"autoload": {
"psr-4": {
"Symfony\\Component\\BrowserKit\\": ""
}
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@ -8529,20 +8552,20 @@
],
"description": "Symfony BrowserKit Component",
"homepage": "https://symfony.com",
"time": "2015-10-23 14:47:27"
"time": "2015-11-02 20:20:53"
},
{
"name": "symfony/dom-crawler",
"version": "v2.7.6",
"version": "v2.7.7",
"source": {
"type": "git",
"url": "https://github.com/symfony/dom-crawler.git",
"reference": "5fef7d8b80d8f9992df99d8ee283f420484c9612"
"reference": "b33593cbfe1d81b50d48353f338aca76a08658d8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/dom-crawler/zipball/5fef7d8b80d8f9992df99d8ee283f420484c9612",
"reference": "5fef7d8b80d8f9992df99d8ee283f420484c9612",
"url": "https://api.github.com/repos/symfony/dom-crawler/zipball/b33593cbfe1d81b50d48353f338aca76a08658d8",
"reference": "b33593cbfe1d81b50d48353f338aca76a08658d8",
"shasum": ""
},
"require": {
@ -8563,7 +8586,10 @@
"autoload": {
"psr-4": {
"Symfony\\Component\\DomCrawler\\": ""
}
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@ -8581,20 +8607,20 @@
],
"description": "Symfony DomCrawler Component",
"homepage": "https://symfony.com",
"time": "2015-10-11 09:39:48"
"time": "2015-11-02 20:20:53"
},
{
"name": "symfony/yaml",
"version": "v2.7.6",
"version": "v2.7.7",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "eca9019c88fbe250164affd107bc8057771f3f4d"
"reference": "4cfcd7a9fceba662b3c036b7d9a91f6197af046c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/eca9019c88fbe250164affd107bc8057771f3f4d",
"reference": "eca9019c88fbe250164affd107bc8057771f3f4d",
"url": "https://api.github.com/repos/symfony/yaml/zipball/4cfcd7a9fceba662b3c036b7d9a91f6197af046c",
"reference": "4cfcd7a9fceba662b3c036b7d9a91f6197af046c",
"shasum": ""
},
"require": {
@ -8609,7 +8635,10 @@
"autoload": {
"psr-4": {
"Symfony\\Component\\Yaml\\": ""
}
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
@ -8627,7 +8656,7 @@
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
"time": "2015-10-11 09:39:48"
"time": "2015-11-18 13:41:01"
}
],
"aliases": [],

View File

@ -1,4 +1,4 @@
<?php //[STAMP] f6d69edc5937bdfc3f7eeb6538ccd9ba
<?php //[STAMP] fd572cb1f679911978b9f48a842ed64b
namespace _generated;
// This class was automatically generated by build task
@ -17,17 +17,6 @@ trait AcceptanceTesterActions
abstract protected function getScenario();
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Print out latest Selenium Logs in debug mode
* @see \Codeception\Module\WebDriver::debugWebDriverLogs()
*/
public function debugWebDriverLogs() {
return $this->getScenario()->runStep(new \Codeception\Step\Action('debugWebDriverLogs', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
@ -260,6 +249,7 @@ trait AcceptanceTesterActions
* $I->amOnPage('/');
* // opens /register page
* $I->amOnPage('/register');
* ?>
* ```
*
* @param $page
@ -273,31 +263,16 @@ trait AcceptanceTesterActions
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the current page contains the given string (case insensitive).
*
* You can specify a specific HTML element (via CSS or XPath) as the second
* parameter to only search within that element.
* Checks that the current page contains the given string.
* Specify a locator as the second parameter to match a specific region.
*
* ``` php
* <?php
* $I->see('Logout'); // I can suppose user is logged in
* $I->see('Sign Up', 'h1'); // I can suppose it's a signup page
* $I->see('Sign Up', '//body/h1'); // with XPath
* $I->see('Logout'); // I can suppose user is logged in
* $I->see('Sign Up','h1'); // I can suppose it's a signup page
* $I->see('Sign Up','//body/h1'); // with XPath
* ?>
* ```
*
* Note that the search is done after stripping all HTML tags from the body,
* so `$I->see('strong')` will return true for strings like:
*
* - `<p>I am Stronger than thou</p>`
* - `<script>document.createElement('strong');</script>`
*
* But will *not* be true for strings like:
*
* - `<strong>Home</strong>`
* - `<div class="strong">Home</strong>`
* - `<!-- strong -->`
*
* For checking the raw source code, use `seeInSource()`.
*
* @param $text
* @param null $selector
@ -310,31 +285,16 @@ trait AcceptanceTesterActions
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the current page contains the given string (case insensitive).
*
* You can specify a specific HTML element (via CSS or XPath) as the second
* parameter to only search within that element.
* Checks that the current page contains the given string.
* Specify a locator as the second parameter to match a specific region.
*
* ``` php
* <?php
* $I->see('Logout'); // I can suppose user is logged in
* $I->see('Sign Up', 'h1'); // I can suppose it's a signup page
* $I->see('Sign Up', '//body/h1'); // with XPath
* $I->see('Logout'); // I can suppose user is logged in
* $I->see('Sign Up','h1'); // I can suppose it's a signup page
* $I->see('Sign Up','//body/h1'); // with XPath
* ?>
* ```
*
* Note that the search is done after stripping all HTML tags from the body,
* so `$I->see('strong')` will return true for strings like:
*
* - `<p>I am Stronger than thou</p>`
* - `<script>document.createElement('strong');</script>`
*
* But will *not* be true for strings like:
*
* - `<strong>Home</strong>`
* - `<div class="strong">Home</strong>`
* - `<!-- strong -->`
*
* For checking the raw source code, use `seeInSource()`.
*
* @param $text
* @param null $selector
@ -348,29 +308,16 @@ trait AcceptanceTesterActions
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the current page doesn't contain the text specified (case insensitive).
* Checks that the current page doesn't contain the text specified.
* Give a locator as the second parameter to match a specific region.
*
* ```php
* <?php
* $I->dontSee('Login'); // I can suppose user is already logged in
* $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page
* $I->dontSee('Sign Up','//body/h1'); // with XPath
* $I->dontSee('Login'); // I can suppose user is already logged in
* $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page
* $I->dontSee('Sign Up','//body/h1'); // with XPath
* ?>
* ```
*
* Note that the search is done after stripping all HTML tags from the body,
* so `$I->dontSee('strong')` will fail on strings like:
*
* - `<p>I am Stronger than thou</p>`
* - `<script>document.createElement('strong');</script>`
*
* But will ignore strings like:
*
* - `<strong>Home</strong>`
* - `<div class="strong">Home</strong>`
* - `<!-- strong -->`
*
* For checking the raw source code, use `seeInSource()`.
*
* @param $text
* @param null $selector
@ -383,29 +330,16 @@ trait AcceptanceTesterActions
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the current page doesn't contain the text specified (case insensitive).
* Checks that the current page doesn't contain the text specified.
* Give a locator as the second parameter to match a specific region.
*
* ```php
* <?php
* $I->dontSee('Login'); // I can suppose user is already logged in
* $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page
* $I->dontSee('Sign Up','//body/h1'); // with XPath
* $I->dontSee('Login'); // I can suppose user is already logged in
* $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page
* $I->dontSee('Sign Up','//body/h1'); // with XPath
* ?>
* ```
*
* Note that the search is done after stripping all HTML tags from the body,
* so `$I->dontSee('strong')` will fail on strings like:
*
* - `<p>I am Stronger than thou</p>`
* - `<script>document.createElement('strong');</script>`
*
* But will ignore strings like:
*
* - `<strong>Home</strong>`
* - `<div class="strong">Home</strong>`
* - `<!-- strong -->`
*
* For checking the raw source code, use `seeInSource()`.
*
* @param $text
* @param null $selector
@ -416,80 +350,6 @@ trait AcceptanceTesterActions
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the current page contains the given string in its
* raw source code.
*
* ``` php
* <?php
* $I->seeInSource('<h1>Green eggs &amp; ham</h1>');
* ```
*
* @param $raw
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Module\WebDriver::seeInSource()
*/
public function canSeeInSource($raw) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInSource', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the current page contains the given string in its
* raw source code.
*
* ``` php
* <?php
* $I->seeInSource('<h1>Green eggs &amp; ham</h1>');
* ```
*
* @param $raw
* @see \Codeception\Module\WebDriver::seeInSource()
*/
public function seeInSource($raw) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInSource', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the current page contains the given string in its
* raw source code.
*
* ```php
* <?php
* $I->dontSeeInSource('<h1>Green eggs &amp; ham</h1>');
* ```
*
* @param $raw
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Module\WebDriver::dontSeeInSource()
*/
public function cantSeeInSource($raw) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInSource', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the current page contains the given string in its
* raw source code.
*
* ```php
* <?php
* $I->dontSeeInSource('<h1>Green eggs &amp; ham</h1>');
* ```
*
* @param $raw
* @see \Codeception\Module\WebDriver::dontSeeInSource()
*/
public function dontSeeInSource($raw) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInSource', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
@ -1565,28 +1425,7 @@ trait AcceptanceTesterActions
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Grabs either the text content, or attribute values, of nodes
* matched by $cssOrXpath and returns them as an array.
*
* ```html
* <a href="#first">First</a>
* <a href="#second">Second</a>
* <a href="#third">Third</a>
* ```
*
* ```php
* <?php
* // would return ['First', 'Second', 'Third']
* $aLinkText = $I->grabMultiple('a');
*
* // would return ['#first', '#second', '#third']
* $aLinks = $I->grabMultiple('a', 'href');
* ?>
* ```
*
* @param $cssOrXpath
* @param $attribute
* @return string[]
*
* @see \Codeception\Module\WebDriver::grabMultiple()
*/
public function grabMultiple($cssOrXpath, $attribute = null) {
@ -1801,27 +1640,6 @@ trait AcceptanceTesterActions
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
*
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Module\WebDriver::seeNumberOfElementsInDOM()
*/
public function canSeeNumberOfElementsInDOM($selector, $expected) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeNumberOfElementsInDOM', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
*
* @see \Codeception\Module\WebDriver::seeNumberOfElementsInDOM()
*/
public function seeNumberOfElementsInDOM($selector, $expected) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeNumberOfElementsInDOM', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
@ -2139,13 +1957,13 @@ trait AcceptanceTesterActions
* ```
* Note that "2" will be the submitted value for the "plan" field, as it is
* the selected option.
*
*
* Also note that this differs from PhpBrowser, in that
* ```'user' => [ 'login' => 'Davert' ]``` is not supported at the moment.
* Named array keys *must* be included in the name as above.
*
*
* Pair this with seeInFormFields for quick testing magic.
*
*
* ``` php
* <?php
* $form = [
@ -2188,20 +2006,20 @@ trait AcceptanceTesterActions
*
* Mixing string and boolean values for a checkbox's value is not supported
* and may produce unexpected results.
*
* Field names ending in "[]" must be passed without the trailing square
*
* Field names ending in "[]" must be passed without the trailing square
* bracket characters, and must contain an array for its value. This allows
* submitting multiple values with the same name, consider:
*
*
* ```php
* $I->submitForm('#my-form', [
* 'field[]' => 'value',
* 'field[]' => 'another value', // 'field[]' is already a defined key
* ]);
* ```
*
*
* The solution is to pass an array value:
*
*
* ```php
* // this way both values are submitted
* $I->submitForm('#my-form', [
@ -2645,7 +2463,34 @@ trait AcceptanceTesterActions
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param string $name
* Saves current cookies into named snapshot in order to restore them in other tests
* This is useful to save session state between tests.
* For example, if user needs log in to site for each test this scenario can be executed once
* while other tests can just restore saved cookies.
*
* ``` php
* <?php
* // inside AcceptanceTester class:
*
* public function login()
* {
* // if snapshot exists - skipping login
* if ($I->loadSessionSnapshot('login')) return;
*
* // logging in
* $I->amOnPage('/login');
* $I->fillField('name', 'jon');
* $I->fillField('password', '123345');
* $I->click('Login');
*
* // saving snapshot
* $I->saveSessionSnapshot('login');
* }
* ?>
* ```
*
* @param $name
* @return mixed
* @see \Codeception\Module\WebDriver::saveSessionSnapshot()
*/
public function saveSessionSnapshot($name) {
@ -2656,8 +2501,11 @@ trait AcceptanceTesterActions
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* @param string $name
* @return bool
* Loads cookies from saved snapshot.
*
* @param $name
* @see saveSessionSnapshot
* @return mixed
* @see \Codeception\Module\WebDriver::loadSessionSnapshot()
*/
public function loadSessionSnapshot($name) {
@ -2668,7 +2516,7 @@ trait AcceptanceTesterActions
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Inserts an SQL record into a database. This record will be erased after the test.
* Inserts SQL record into database. This record will be erased after the test.
*
* ``` php
* <?php
@ -2690,7 +2538,7 @@ trait AcceptanceTesterActions
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a row with the given column values exists.
* Checks if a row with given column values exists.
* Provide table name and column values.
*
* Example:
@ -2718,7 +2566,7 @@ trait AcceptanceTesterActions
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that a row with the given column values exists.
* Checks if a row with given column values exists.
* Provide table name and column values.
*
* Example:
@ -2747,7 +2595,7 @@ trait AcceptanceTesterActions
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that the given number of records were found in the database.
* Asserts that found number of records in database
*
* ``` php
* <?php
@ -2755,19 +2603,19 @@ trait AcceptanceTesterActions
* ?>
* ```
*
* @param int $expectedNumber Expected number
* @param int $num Expected number
* @param string $table Table name
* @param array $criteria Search criteria [Optional]
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Module\Db::seeNumRecords()
*/
public function canSeeNumRecords($expectedNumber, $table, $criteria = null) {
public function canSeeNumRecords($num, $table, $criteria = null) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeNumRecords', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Asserts that the given number of records were found in the database.
* Asserts that found number of records in database
*
* ``` php
* <?php
@ -2775,12 +2623,12 @@ trait AcceptanceTesterActions
* ?>
* ```
*
* @param int $expectedNumber Expected number
* @param int $num Expected number
* @param string $table Table name
* @param array $criteria Search criteria [Optional]
* @see \Codeception\Module\Db::seeNumRecords()
*/
public function seeNumRecords($expectedNumber, $table, $criteria = null) {
public function seeNumRecords($num, $table, $criteria = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeNumRecords', func_get_args()));
}
@ -2790,7 +2638,7 @@ trait AcceptanceTesterActions
*
* Effect is opposite to ->seeInDatabase
*
* Asserts that there is no record with the given column values in a database.
* Checks if there is no record with such column values in database.
* Provide table name and column values.
*
* Example:
@ -2820,7 +2668,7 @@ trait AcceptanceTesterActions
*
* Effect is opposite to ->seeInDatabase
*
* Asserts that there is no record with the given column values in a database.
* Checks if there is no record with such column values in database.
* Provide table name and column values.
*
* Example:

View File

@ -1,4 +1,4 @@
<?php //[STAMP] a0d5cd84d7074a41bde1bd3fc123f1cf
<?php //[STAMP] 3a5564865956327f909936a09aa15a20
namespace _generated;
// This class was automatically generated by build task
@ -164,6 +164,7 @@ trait FunctionalTesterActions
* $I->amOnPage('/');
* // opens /register page
* $I->amOnPage('/register');
* ?>
* ```
*
* @param $page
@ -216,31 +217,16 @@ trait FunctionalTesterActions
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the current page contains the given string (case insensitive).
*
* You can specify a specific HTML element (via CSS or XPath) as the second
* parameter to only search within that element.
* Checks that the current page contains the given string.
* Specify a locator as the second parameter to match a specific region.
*
* ``` php
* <?php
* $I->see('Logout'); // I can suppose user is logged in
* $I->see('Sign Up', 'h1'); // I can suppose it's a signup page
* $I->see('Sign Up', '//body/h1'); // with XPath
* $I->see('Logout'); // I can suppose user is logged in
* $I->see('Sign Up','h1'); // I can suppose it's a signup page
* $I->see('Sign Up','//body/h1'); // with XPath
* ?>
* ```
*
* Note that the search is done after stripping all HTML tags from the body,
* so `$I->see('strong')` will return true for strings like:
*
* - `<p>I am Stronger than thou</p>`
* - `<script>document.createElement('strong');</script>`
*
* But will *not* be true for strings like:
*
* - `<strong>Home</strong>`
* - `<div class="strong">Home</strong>`
* - `<!-- strong -->`
*
* For checking the raw source code, use `seeInSource()`.
*
* @param $text
* @param null $selector
@ -253,31 +239,16 @@ trait FunctionalTesterActions
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the current page contains the given string (case insensitive).
*
* You can specify a specific HTML element (via CSS or XPath) as the second
* parameter to only search within that element.
* Checks that the current page contains the given string.
* Specify a locator as the second parameter to match a specific region.
*
* ``` php
* <?php
* $I->see('Logout'); // I can suppose user is logged in
* $I->see('Sign Up', 'h1'); // I can suppose it's a signup page
* $I->see('Sign Up', '//body/h1'); // with XPath
* $I->see('Logout'); // I can suppose user is logged in
* $I->see('Sign Up','h1'); // I can suppose it's a signup page
* $I->see('Sign Up','//body/h1'); // with XPath
* ?>
* ```
*
* Note that the search is done after stripping all HTML tags from the body,
* so `$I->see('strong')` will return true for strings like:
*
* - `<p>I am Stronger than thou</p>`
* - `<script>document.createElement('strong');</script>`
*
* But will *not* be true for strings like:
*
* - `<strong>Home</strong>`
* - `<div class="strong">Home</strong>`
* - `<!-- strong -->`
*
* For checking the raw source code, use `seeInSource()`.
*
* @param $text
* @param null $selector
@ -291,29 +262,16 @@ trait FunctionalTesterActions
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the current page doesn't contain the text specified (case insensitive).
* Checks that the current page doesn't contain the text specified.
* Give a locator as the second parameter to match a specific region.
*
* ```php
* <?php
* $I->dontSee('Login'); // I can suppose user is already logged in
* $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page
* $I->dontSee('Sign Up','//body/h1'); // with XPath
* $I->dontSee('Login'); // I can suppose user is already logged in
* $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page
* $I->dontSee('Sign Up','//body/h1'); // with XPath
* ?>
* ```
*
* Note that the search is done after stripping all HTML tags from the body,
* so `$I->dontSee('strong')` will fail on strings like:
*
* - `<p>I am Stronger than thou</p>`
* - `<script>document.createElement('strong');</script>`
*
* But will ignore strings like:
*
* - `<strong>Home</strong>`
* - `<div class="strong">Home</strong>`
* - `<!-- strong -->`
*
* For checking the raw source code, use `seeInSource()`.
*
* @param $text
* @param null $selector
@ -326,29 +284,16 @@ trait FunctionalTesterActions
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the current page doesn't contain the text specified (case insensitive).
* Checks that the current page doesn't contain the text specified.
* Give a locator as the second parameter to match a specific region.
*
* ```php
* <?php
* $I->dontSee('Login'); // I can suppose user is already logged in
* $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page
* $I->dontSee('Sign Up','//body/h1'); // with XPath
* $I->dontSee('Login'); // I can suppose user is already logged in
* $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page
* $I->dontSee('Sign Up','//body/h1'); // with XPath
* ?>
* ```
*
* Note that the search is done after stripping all HTML tags from the body,
* so `$I->dontSee('strong')` will fail on strings like:
*
* - `<p>I am Stronger than thou</p>`
* - `<script>document.createElement('strong');</script>`
*
* But will ignore strings like:
*
* - `<strong>Home</strong>`
* - `<div class="strong">Home</strong>`
* - `<!-- strong -->`
*
* For checking the raw source code, use `seeInSource()`.
*
* @param $text
* @param null $selector
@ -359,80 +304,6 @@ trait FunctionalTesterActions
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the current page contains the given string in its
* raw source code.
*
* ``` php
* <?php
* $I->seeInSource('<h1>Green eggs &amp; ham</h1>');
* ```
*
* @param $raw
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Lib\InnerBrowser::seeInSource()
*/
public function canSeeInSource($raw) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInSource', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the current page contains the given string in its
* raw source code.
*
* ``` php
* <?php
* $I->seeInSource('<h1>Green eggs &amp; ham</h1>');
* ```
*
* @param $raw
* @see \Codeception\Lib\InnerBrowser::seeInSource()
*/
public function seeInSource($raw) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInSource', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the current page contains the given string in its
* raw source code.
*
* ```php
* <?php
* $I->dontSeeInSource('<h1>Green eggs &amp; ham</h1>');
* ```
*
* @param $raw
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Lib\InnerBrowser::dontSeeInSource()
*/
public function cantSeeInSource($raw) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInSource', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the current page contains the given string in its
* raw source code.
*
* ```php
* <?php
* $I->dontSeeInSource('<h1>Green eggs &amp; ham</h1>');
* ```
*
* @param $raw
* @see \Codeception\Lib\InnerBrowser::dontSeeInSource()
*/
public function dontSeeInSource($raw) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInSource', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
@ -1205,25 +1076,13 @@ trait FunctionalTesterActions
* Submits the given form on the page, optionally with the given form
* values. Give the form fields values as an array.
*
* Although this function can be used as a short-hand version of
* `fillField()`, `selectOption()`, `click()` etc. it has some important
* differences:
*
* * Only field *names* may be used, not CSS/XPath selectors nor field labels
* * If a field is sent to this function that does *not* exist on the page,
* it will silently be added to the HTTP request. This is helpful for testing
* some types of forms, but be aware that you will *not* get an exception
* like you would if you called `fillField()` or `selectOption()` with
* a missing field.
*
* Fields that are not provided will be filled by their values from the page,
* or from any previous calls to `fillField()`, `selectOption()` etc.
* Skipped fields will be filled by their values from the page.
* You don't need to click the 'Submit' button afterwards.
* This command itself triggers the request to form's action.
*
* You can optionally specify which button's value to include
* in the request with the last parameter (as an alternative to
* explicitly setting its value in the second parameter), as
* You can optionally specify what button's value to include
* in the request with the last parameter as an alternative to
* explicitly setting its value in the second parameter, as
* button values are not otherwise included in the request.
*
* Examples:
@ -1297,8 +1156,7 @@ trait FunctionalTesterActions
* );
* ```
*
* This function works well when paired with `seeInFormFields()`
* for quickly testing CRUD interfaces and form validation logic.
* Pair this with seeInFormFields for quick testing magic.
*
* ``` php
* <?php
@ -1308,14 +1166,15 @@ trait FunctionalTesterActions
* 'checkbox1' => true,
* // ...
* ];
* $I->submitForm('#my-form', $form, 'submitButton');
* $I->submitForm('//form[@id=my-form]', $form, 'submitButton');
* // $I->amOnPage('/path/to/form-page') may be needed
* $I->seeInFormFields('#my-form', $form);
* $I->seeInFormFields('//form[@id=my-form]', $form);
* ?>
* ```
*
* Parameter values can be set to arrays for multiple input fields
* of the same name, or multi-select combo boxes. For checkboxes,
* you can use either the string value or boolean `true`/`false` which will
* either the string value can be used, or boolean values which will
* be replaced by the checkbox's value in the DOM.
*
* ``` php
@ -1324,7 +1183,7 @@ trait FunctionalTesterActions
* 'field1' => 'value',
* 'checkbox' => [
* 'value of first checkbox',
* 'value of second checkbox',
* 'value of second checkbox,
* ],
* 'otherCheckboxes' => [
* true,
@ -1336,29 +1195,27 @@ trait FunctionalTesterActions
* 'second option value'
* ]
* ]);
* ?>
* ```
*
* Mixing string and boolean values for a checkbox's value is not supported
* and may produce unexpected results.
*
* Field names ending in `[]` must be passed without the trailing square
* Field names ending in "[]" must be passed without the trailing square
* bracket characters, and must contain an array for its value. This allows
* submitting multiple values with the same name, consider:
*
* ```php
* <?php
* // This will NOT work correctly
* $I->submitForm('#my-form', [
* 'field[]' => 'value',
* 'field[]' => 'another value', // 'field[]' is already a defined key
* 'field[]' => 'another value', // 'field[]' is already a defined key
* ]);
* ```
*
* The solution is to pass an array value:
*
* ```php
* <?php
* // This way both values are submitted
* // this way both values are submitted
* $I->submitForm('#my-form', [
* 'field' => [
* 'value',
@ -1609,28 +1466,7 @@ trait FunctionalTesterActions
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Grabs either the text content, or attribute values, of nodes
* matched by $cssOrXpath and returns them as an array.
*
* ```html
* <a href="#first">First</a>
* <a href="#second">Second</a>
* <a href="#third">Third</a>
* ```
*
* ```php
* <?php
* // would return ['First', 'Second', 'Third']
* $aLinkText = $I->grabMultiple('a');
*
* // would return ['#first', '#second', '#third']
* $aLinks = $I->grabMultiple('a', 'href');
* ?>
* ```
*
* @param $cssOrXpath
* @param $attribute
* @return string[]
*
* @see \Codeception\Lib\InnerBrowser::grabMultiple()
*/
public function grabMultiple($cssOrXpath, $attribute = null) {
@ -2136,43 +1972,6 @@ trait FunctionalTesterActions
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Switch to iframe or frame on the page.
*
* Example:
* ``` html
* <iframe name="another_frame" src="http://example.com">
* ```
*
* ``` php
* <?php
* # switch to iframe
* $I->switchToIframe("another_frame");
* ```
*
* @param string $name
* @see \Codeception\Lib\InnerBrowser::switchToIframe()
*/
public function switchToIframe($name) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('switchToIframe', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Moves back in history.
*
* @param int $numberOfSteps (default value 1)
* @see \Codeception\Lib\InnerBrowser::moveBack()
*/
public function moveBack($numberOfSteps = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('moveBack', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
@ -2231,122 +2030,6 @@ trait FunctionalTesterActions
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Disable events for the next requests.
*
* ``` php
* <?php
* $I->disableEvents();
* ?>
* ```
* @see \Codeception\Module\Laravel5::disableEvents()
*/
public function disableEvents() {
return $this->getScenario()->runStep(new \Codeception\Step\Action('disableEvents', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Enable events for the next requests.
*
* ``` php
* <?php
* $I->enableEvents();
* ?>
* ```
* @see \Codeception\Module\Laravel5::enableEvents()
*/
public function enableEvents() {
return $this->getScenario()->runStep(new \Codeception\Step\Action('enableEvents', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Make sure events fired during the test.
*
* ``` php
* <?php
* $I->seeEventTriggered('App\MyEvent');
* $I->seeEventTriggered(new App\Events\MyEvent());
* $I->seeEventTriggered('App\MyEvent', 'App\MyOtherEvent');
* $I->seeEventTriggered(['App\MyEvent', 'App\MyOtherEvent']);
* ?>
* ```
* @param $events
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Module\Laravel5::seeEventTriggered()
*/
public function canSeeEventTriggered($events) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeEventTriggered', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Make sure events fired during the test.
*
* ``` php
* <?php
* $I->seeEventTriggered('App\MyEvent');
* $I->seeEventTriggered(new App\Events\MyEvent());
* $I->seeEventTriggered('App\MyEvent', 'App\MyOtherEvent');
* $I->seeEventTriggered(['App\MyEvent', 'App\MyOtherEvent']);
* ?>
* ```
* @param $events
* @see \Codeception\Module\Laravel5::seeEventTriggered()
*/
public function seeEventTriggered($events) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeEventTriggered', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Make sure events did not fire during the test.
*
* ``` php
* <?php
* $I->dontSeeEventTriggered('App\MyEvent');
* $I->dontSeeEventTriggered(new App\Events\MyEvent());
* $I->dontSeeEventTriggered('App\MyEvent', 'App\MyOtherEvent');
* $I->dontSeeEventTriggered(['App\MyEvent', 'App\MyOtherEvent']);
* ?>
* ```
* @param $events
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Module\Laravel5::dontSeeEventTriggered()
*/
public function cantSeeEventTriggered($events) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeEventTriggered', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Make sure events did not fire during the test.
*
* ``` php
* <?php
* $I->dontSeeEventTriggered('App\MyEvent');
* $I->dontSeeEventTriggered(new App\Events\MyEvent());
* $I->dontSeeEventTriggered('App\MyEvent', 'App\MyOtherEvent');
* $I->dontSeeEventTriggered(['App\MyEvent', 'App\MyOtherEvent']);
* ?>
* ```
* @param $events
* @see \Codeception\Module\Laravel5::dontSeeEventTriggered()
*/
public function dontSeeEventTriggered($events) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeEventTriggered', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
@ -2367,41 +2050,6 @@ trait FunctionalTesterActions
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that current url matches route
*
* ``` php
* <?php
* $I->seeCurrentRouteIs('posts.index');
* ?>
* ```
* @param $routeName
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Module\Laravel5::seeCurrentRouteIs()
*/
public function canSeeCurrentRouteIs($routeName) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentRouteIs', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that current url matches route
*
* ``` php
* <?php
* $I->seeCurrentRouteIs('posts.index');
* ?>
* ```
* @param $routeName
* @see \Codeception\Module\Laravel5::seeCurrentRouteIs()
*/
public function seeCurrentRouteIs($routeName) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCurrentRouteIs', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
@ -2422,6 +2070,43 @@ trait FunctionalTesterActions
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that current url matches route
*
* ``` php
* <?php
* $I->seeCurrentRouteIs('posts.index');
* ?>
* ```
* @param $route
* @param array $params
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Module\Laravel5::seeCurrentRouteIs()
*/
public function canSeeCurrentRouteIs($route, $params = null) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentRouteIs', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that current url matches route
*
* ``` php
* <?php
* $I->seeCurrentRouteIs('posts.index');
* ?>
* ```
* @param $route
* @param array $params
* @see \Codeception\Module\Laravel5::seeCurrentRouteIs()
*/
public function seeCurrentRouteIs($route, $params = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCurrentRouteIs', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
@ -2434,10 +2119,11 @@ trait FunctionalTesterActions
* ```
*
* @param $action
* @param array $params
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Module\Laravel5::seeCurrentActionIs()
*/
public function canSeeCurrentActionIs($action) {
public function canSeeCurrentActionIs($action, $params = null) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentActionIs', func_get_args()));
}
/**
@ -2452,9 +2138,10 @@ trait FunctionalTesterActions
* ```
*
* @param $action
* @param array $params
* @see \Codeception\Module\Laravel5::seeCurrentActionIs()
*/
public function seeCurrentActionIs($action) {
public function seeCurrentActionIs($action, $params = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCurrentActionIs', func_get_args()));
}
@ -2472,7 +2159,7 @@ trait FunctionalTesterActions
* ```
*
* @param string|array $key
* @param mixed|null $value
* @param mixed $value
* @return void
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Module\Laravel5::seeInSession()
@ -2493,7 +2180,7 @@ trait FunctionalTesterActions
* ```
*
* @param string|array $key
* @param mixed|null $value
* @param mixed $value
* @return void
* @see \Codeception\Module\Laravel5::seeInSession()
*/
@ -2580,56 +2267,19 @@ trait FunctionalTesterActions
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Assert that there are no form errors bound to the View.
*
* ``` php
* <?php
* $I->dontSeeFormErrors();
* ?>
* ```
*
* @return bool
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Module\Laravel5::dontSeeFormErrors()
*/
public function cantSeeFormErrors() {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeFormErrors', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Assert that there are no form errors bound to the View.
*
* ``` php
* <?php
* $I->dontSeeFormErrors();
* ?>
* ```
*
* @return bool
* @see \Codeception\Module\Laravel5::dontSeeFormErrors()
*/
public function dontSeeFormErrors() {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeFormErrors', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Assert that specific form error messages are set in the view.
*
* This method calls `seeFormErrorMessage` for each entry in the `$bindings` array.
* Useful for validation messages e.g.
* return `Redirect::to('register')->withErrors($validator);`
*
* Example of Usage
*
* ``` php
* <?php
* $I->seeFormErrorMessages([
* 'username' => 'Invalid Username',
* 'password' => null,
* ]);
* $I->seeFormErrorMessages(array('username'=>'Invalid Username'));
* ?>
* ```
* @param array $bindings
@ -2644,14 +2294,14 @@ trait FunctionalTesterActions
*
* Assert that specific form error messages are set in the view.
*
* This method calls `seeFormErrorMessage` for each entry in the `$bindings` array.
* Useful for validation messages e.g.
* return `Redirect::to('register')->withErrors($validator);`
*
* Example of Usage
*
* ``` php
* <?php
* $I->seeFormErrorMessages([
* 'username' => 'Invalid Username',
* 'password' => null,
* ]);
* $I->seeFormErrorMessages(array('username'=>'Invalid Username'));
* ?>
* ```
* @param array $bindings
@ -2665,50 +2315,48 @@ trait FunctionalTesterActions
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Assert that a specific form error message is set in the view.
* Assert that specific form error message is set in the view.
*
* If you want to assert that there is a form error message for a specific key
* but don't care about the actual error message you can omit `$expectedErrorMessage`.
* Useful for validation messages and generally messages array
* e.g.
* return `Redirect::to('register')->withErrors($validator);`
*
* If you do pass `$expectedErrorMessage`, this method checks if the actual error message for a key
* contains `$expectedErrorMessage`.
* Example of Usage
*
* ``` php
* <?php
* $I->seeFormErrorMessage('username');
* $I->seeFormErrorMessage('username', 'Invalid Username');
* ?>
* ```
* @param string $key
* @param string|null $expectedErrorMessage
* @param string $errorMessage
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Module\Laravel5::seeFormErrorMessage()
*/
public function canSeeFormErrorMessage($key, $expectedErrorMessage = null) {
public function canSeeFormErrorMessage($key, $errorMessage) {
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeFormErrorMessage', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Assert that a specific form error message is set in the view.
* Assert that specific form error message is set in the view.
*
* If you want to assert that there is a form error message for a specific key
* but don't care about the actual error message you can omit `$expectedErrorMessage`.
* Useful for validation messages and generally messages array
* e.g.
* return `Redirect::to('register')->withErrors($validator);`
*
* If you do pass `$expectedErrorMessage`, this method checks if the actual error message for a key
* contains `$expectedErrorMessage`.
* Example of Usage
*
* ``` php
* <?php
* $I->seeFormErrorMessage('username');
* $I->seeFormErrorMessage('username', 'Invalid Username');
* ?>
* ```
* @param string $key
* @param string|null $expectedErrorMessage
* @param string $errorMessage
* @see \Codeception\Module\Laravel5::seeFormErrorMessage()
*/
public function seeFormErrorMessage($key, $expectedErrorMessage = null) {
public function seeFormErrorMessage($key, $errorMessage) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeFormErrorMessage', func_get_args()));
}
@ -2720,19 +2368,8 @@ trait FunctionalTesterActions
* Takes either an object that implements the User interface or
* an array of credentials.
*
* ``` php
* <?php
* // provide array of credentials
* $I->amLoggedAs(['username' => 'jane@example.com', 'password' => 'password']);
*
* // provide User object
* $I->amLoggesAs( new User );
*
* // can be verified with $I->seeAuthentication();
* ?>
* ```
* @param \Illuminate\Contracts\Auth\User|array $user
* @param string|null $driver 'eloquent', 'database', or custom driver
* @param string $driver
* @return void
* @see \Codeception\Module\Laravel5::amLoggedAs()
*/
@ -2744,7 +2381,7 @@ trait FunctionalTesterActions
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Logout user.
* Logs user out
* @see \Codeception\Module\Laravel5::logout()
*/
public function logout() {
@ -2755,7 +2392,7 @@ trait FunctionalTesterActions
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that a user is authenticated
* Checks that user is authenticated
* Conditional Assertion: Test won't be stopped on fail
* @see \Codeception\Module\Laravel5::seeAuthentication()
*/
@ -2765,7 +2402,7 @@ trait FunctionalTesterActions
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that a user is authenticated
* Checks that user is authenticated
* @see \Codeception\Module\Laravel5::seeAuthentication()
*/
public function seeAuthentication() {
@ -2800,6 +2437,7 @@ trait FunctionalTesterActions
* Return an instance of a class from the IoC Container.
* (http://laravel.com/docs/ioc)
*
* Example
* ``` php
* <?php
* // In Laravel
@ -2948,88 +2586,4 @@ trait FunctionalTesterActions
public function grabRecord($tableName, $attributes = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('grabRecord', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Use Laravel's model factory to create a model.
* Can only be used with Laravel 5.1 and later.
*
* ``` php
* <?php
* $I->haveModel('App\User');
* $I->haveModel('App\User', ['name' => 'John Doe']);
* $I->haveModel('App\User', [], 'admin');
* $I->haveModel('App\User', [], 'admin', 3);
* ?>
* ```
*
* @see http://laravel.com/docs/5.1/testing#model-factories
* @param string $model
* @param array $attributes
* @param string $name
* @param int $times
* @return mixed
* @see \Codeception\Module\Laravel5::haveModel()
*/
public function haveModel($model, $attributes = null, $name = null, $times = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('haveModel', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Use Laravel's model factory to create a model.
* Can only be used with Laravel 5.1 and later.
*
* ``` php
* <?php
* $I->createModel('App\User');
* $I->createModel('App\User', ['name' => 'John Doe']);
* $I->createModel('App\User', [], 'admin');
* $I->createModel('App\User', [], 'admin', 3);
* ?>
* ```
*
* @see http://laravel.com/docs/5.1/testing#model-factories
* @param string $model
* @param array $attributes
* @param string $name
* @param int $times
* @return mixed
* @see \Codeception\Module\Laravel5::createModel()
*/
public function createModel($model, $attributes = null, $name = null, $times = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('createModel', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Use Laravel's model factory to make a model.
* Can only be used with Laravel 5.1 and later.
*
* ``` php
* <?php
* $I->makeModel('App\User');
* $I->makeModel('App\User', ['name' => 'John Doe']);
* $I->makeModel('App\User', [], 'admin');
* $I->makeModel('App\User', [], 'admin', 3);
* ?>
* ```
*
* @see http://laravel.com/docs/5.1/testing#model-factories
* @param string $model
* @param array $attributes
* @param string $name
* @param int $times
* @return mixed
* @see \Codeception\Module\Laravel5::makeModel()
*/
public function makeModel($model, $attributes = null, $name = null, $times = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('makeModel', func_get_args()));
}
}

View File

@ -1,4 +1,4 @@
<?php //[STAMP] 9d680d4d116f13b46f4a15d3ff55e20a
<?php //[STAMP] 411f8e49789d4aff7d24b72665b5df9f
namespace _generated;
// This class was automatically generated by build task

View File

@ -0,0 +1,114 @@
<?php
use Codeception\Util\Fixtures;
use Faker\Factory;
use Codeception\Util\Debug;
class OnlinePaymentCest
{
private $faker;
private $token;
public function _before(AcceptanceTester $I)
{
$this->faker = Factory::create();
Debug::debug('Create/get token');
$data = new stdClass;
$data->email = Fixtures::get('username');
$data->password = Fixtures::get('password');
$data->api_secret = Fixtures::get('api_secret');
$data->token_name = 'iOS Token';
$response = $this->sendRequest('login', $data);
$userAccounts = $response->data;
PHPUnit_Framework_Assert::assertGreaterThan(0, count($userAccounts));
$userAccount = $userAccounts[0];
$this->token = $userAccount->token;
}
public function testAPI(AcceptanceTester $I)
{
$I->wantTo('test the API');
$data = new stdClass;
$data->contact = new stdClass;
$data->contact->email = $this->faker->safeEmail;
$clientId = $this->createEntity('client', $data);
$this->listEntities('client');
$data = new stdClass;
$data->client_id = $clientId;
$data->description = $this->faker->realText(100);
$this->createEntity('task', $data);
$this->listEntities('task');
$lineItem = new stdClass;
$lineItem->qty = $this->faker->numberBetween(1, 10);
$lineItem->cost = $this->faker->numberBetween(1, 10);
$data = new stdClass;
$data->client_id = $clientId;
$data->invoice_items = [
$lineItem
];
$invoiceId = $this->createEntity('invoice', $data);
$this->listEntities('invoice');
$data = new stdClass;
$data->invoice_id = $invoiceId;
$data->amount = 1;
$this->createEntity('payment', $data);
$this->listEntities('payment');
$this->listEntities('account');
}
private function createEntity($entityType, $data)
{
Debug::debug("Create {$entityType}");
$response = $this->sendRequest("{$entityType}s", $data);
$entityId = $response->data->id;
PHPUnit_Framework_Assert::assertGreaterThan(0, $entityId);
return $entityId;
}
private function listEntities($entityType)
{
Debug::debug("List {$entityType}s");
$response = $this->sendRequest("{$entityType}s", null, 'GET');
PHPUnit_Framework_Assert::assertGreaterThan(0, count($response->data));
return $response;
}
private function sendRequest($url, $data, $type = 'POST')
{
$url = Fixtures::get('url') . '/api/v1/' . $url;
$data = json_encode($data);
$curl = curl_init();
$opts = [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => $type,
CURLOPT_POST => $type === 'POST' ? 1 : 0,
CURLOPT_POSTFIELDS => $data,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'Content-Length: ' . strlen($data),
'X-Ninja-Token: '. $this->token,
],
];
curl_setopt_array($curl, $opts);
$response = curl_exec($curl);
curl_close($curl);
return json_decode($response);
}
}

View File

@ -81,6 +81,8 @@ class OnlinePaymentCest
$I->see('Successfully applied payment');
});
$I->wait(1);
// create recurring invoice and auto-bill
$I->amOnPage('/recurring_invoices/create');
$I->selectDropdown($I, $clientEmail, '.client_select .dropdown-toggle');