Last active
November 5, 2019 21:50
-
-
Save coclav/b0dd9f7eee2d887cfd4566720fce5d6e to your computer and use it in GitHub Desktop.
Skore test block
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* works with laravel route() | |
* if you want to force a HTTP verb, append it to the route e.g. v1.processes.update.post to force using post instead of the default patch on update | |
*/ | |
public function getResponse($endpoint, $queryParams = [], $bodyParams = []) | |
{ | |
// first -- get the right method | |
$points = explode(".", $endpoint); | |
$action = $points[sizeof($points) - 1]; | |
switch ($action) { | |
case "post": | |
array_pop($points); | |
/* falls through */ | |
case "store": | |
$endpoint = implode(".", $points); | |
return $this->postJson(route($endpoint, $queryParams), $bodyParams); | |
case "patch": | |
array_pop($endpoint); | |
/* falls through */ | |
case "update": | |
$endpoint = implode(".", $points); | |
return $this->patchJson(route($endpoint, $queryParams), $bodyParams); | |
case "delete": | |
array_pop($endpoint); | |
/* falls through */ | |
case "destroy": | |
$endpoint = implode(".", $points); | |
return $this->deleteJson(route($endpoint, $queryParams)); | |
case "get": | |
array_pop($endpoint); | |
/* falls through */ | |
case "index": | |
case "show": | |
$endpoint = implode(".", $points); | |
return $this->getJson(route($endpoint, $queryParams), $bodyParams); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$block = [ | |
"v1.processes.update" => [ | |
"admin-canEdit-can-changeStatusOfAProcess-200" [ | |
// generic : "userType-accessType-Can-Description-code => [ | |
"user" => "[email protected]", | |
"queryParams" => [ | |
"process" => 1, | |
], | |
"bodyParams" => [ | |
"status" => "Archived", | |
], | |
"tests" => [ | |
"data.attributes.status" => "Archived", ], | |
"recursive" => "/* reuse test object */ | |
], | |
// other scenarios for the same endpoint... | |
], | |
"another.endpoint" => [ /* ...*/ ], | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment