Skip to content

vs0uz4/bypassforphp-snippets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bypass for PHP Snippets

Code snippets for writing tests for PHP using Bypass for PHP in Visual Studio Code.

Screenshot

Usage

Writing Tests

To write a test, you first need to open the Bypass Server.

Opening Server

Bypass provides two fuctions for opening server open() and serve().

Type :bopen + [TAB] for:

Bypass::open();

Type :bserv + [TAB] for:

Bypass::serve(
    //Route::
);

Get Base URL and/or Port

Type :bburl + [TAB] for:

->getBaseUrl();

Type :bport + [TAB] for:

->getPort();

Stop and Shut down

Type :bstop + [TAB] for:

->stop();

Type :bdown + [TAB] for:

->down();

Adding Routes (Standard and File)

Bypass Server provides two types of routes: Standard Routes and File Routes.

For standard routes the bypass provides the addRoute() method. This method has an alias, called expect().

Type :baro + [TAB] for:

->addRoute(method: '', uri: '', status: , body: );

Type :bexp + [TAB] for:

->expect(method: '', uri: '', status: , body: );

For File routes:

Type :bafr + [TAB] for:

->addFileRoute(method: '', uri: '', status: , file: );

Asserting Routes

Type :bass + [TAB] for:

->assertRoutes();

Route Helpers

When we use the serve() method to open a bypass server, it expects us to pass it routes. And for this, Bypass offers us the route helpers.

After opening the Bypass server by typing :bserv, finish adding the desired route.

Example: Type :brok + [TAB] produces:

Bypass::serve(
    Route::ok(method: '', uri: '', body: '', times: )
    ..
);

Available Route:: methods:

Trigger Snippet
:brok Route::ok(method: '', uri: '', body: '', times: )
:brbadrequest Route::badRequest(method: '', uri: '', body: '', times: )
:brunauthorized Route::unauthorized(method: '', uri: '', body: '$', times: )
:brforbidden Route::forbidden(method: '', uri: '', body: '', times: )
:brcreated Route::created(uri: '', body: '', times: )
:brnotfound Route::notFound(method: '', uri: '', body: '', times: )
:brnotallowed Route::notAllowed(method: '', uri: '', body: '', times: )
:brtoomany Route::tooMany(method: '', uri: '', body: '', times: )
:brservererror Route::serverError(method: '', uri: '', body: '', times: )
:brvalidationfailed Route::validationFailed(method: '', uri: '', body: '', times: )
:brfile Route::file(method: '', uri: '', file: '', status: , times: )
:brget Route::get(uri: '', body: '', status: , times: )
:brgetfile Route::getFile(uri: '', file: '', status: , times: )
:brpost Route::post(uri: '', body: '', status: , times: )
:brput Route::put(uri: '', body: '', status: , times: )
:brdelete Route::delete(uri: '', body: '', status: , times: )
:brpatch Route::patch(uri: '', body: '', status: , times: )

About

VS-Code Snippets for Bypass in Pest Tests

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published