-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Starting some tests (tests/Console/Utils/ParamsValidatorTest.phpt), ref
- Loading branch information
1 parent
5357c6a
commit 163293e
Showing
6 changed files
with
86 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<!DOCTYPE html> <html> <head> <title>Awesome cookbook JSON-RPC API doc</title> <style>html,body{margin:0;padding:0;height:100%;width:100%}h1,h2,h3,h4,h5,h6,p{margin:0}body{background-color:#2980b9;background-color:#34495e;font-size:12px;font-family:Arial,Helvetica,sans-serif;color:#2c3e50;overflow:auto;box-sizing:border-box;width:100vw;max-width:100vw;height:100vh;max-height:100vh;display:grid;grid-template-columns:auto 300px 900px auto;grid-template-rows:80px auto 80px;grid-template-areas:"header header header header" "empty-left nav main empty-right" "footer footer footer footer";grid-column-gap:2em}header{grid-area:header}nav{grid-area:nav;align-self:start}.empty-left{grid-area:empty-left}.empty-right{grid-area:empty-right}main{grid-area:main}footer{grid-area:footer}button.section-method,a.section-site{font-size:12px;display:block;width:100%;border:0;margin:0;line-height:30px;vertical-align:middle;padding:0 1em;background-color:#fff;color:#505050;box-sizing:border-box;text-align:left;border-radius:0;cursor:pointer}button.section-method:hover,a.section-site:hover,button.section-method:active,a.section-site:active,button.section-method:focus,a.section-site:focus,button.section-method:target,a.section-site:target{background-color:#eee;cursor:pointer;outline:none}.section-site:first-of-type{font-weight:700}.section-method:first-of-type,.section-site:first-of-type{border-top-right-radius:2px;border-top-left-radius:2px}.section-method:last-of-type,.section-site:last-of-type{border-bottom-right-radius:2px;border-bottom-left-radius:2px}.section-method:first-of-type{margin-top:1em}iframe{width:100%;height:0;border:0;padding:0;margin:0}</style> <link rel="shortcut icon" type="image/x-icon" href="favicon.ico"/> </head> <body> <header>Awesome cookbook JSON-RPC API doc</header> <div class="empty-left"></div> <nav> <p><a data-section-href="home.html" class="section-site" data-target="home">Home</a> <a data-section-href="about.html" class="section-site" data-target="about-project">About project</a> <button data-section-href="methods/user.login.html" class="section-method" data-target="user-login">user.login</button> <button data-section-href="methods/user.logout.html" class="section-method" data-target="user-logout">user.logout</button></p></nav> <div class="empty-right"></div> <main> <iframe src="" scrolling="no"></iframe> </main> <footer></footer> <script type="text/javascript">document.addEventListener("DOMContentLoaded",function(event){var buttons=document.querySelectorAll('[data-section-href]');for(var i=0;i<buttons.length;i++){buttons[i].addEventListener("click",function(event){event.stopPropagation();event.preventDefault();window.location.hash=this.getAttribute("data-target")})} if(buttons.length){if(window.location.hash){onHashChangeRouter()}else{var sectionLink=buttons[0].getAttribute("data-section-href");document.getElementsByTagName('iframe')[0].setAttribute("src",sectionLink)}}});document.getElementsByTagName("iframe")[0].addEventListener("load",function(){this.style.height=this.contentWindow.document.body.scrollHeight+'px'});document.getElementsByTagName("iframe")[0].addEventListener("load",function(){var jsonAreas=this.contentWindow.document.getElementsByClassName('language-json');for(var i=0;i<jsonAreas.length;i++){var content=jsonAreas[i].innerHTML;content=content.replace(/"([^"]+)":/g,"<span class=language-json-key>"$1":</span>");content=content.replace(/"([^"]+)"([^:])/g,"<span class=language-json-string>"$1"</span>$2");content=content.replace(/([ ,:{\n])(\d+)/g,"$1<span class=language-json-number>$2</span>");jsonAreas[i].innerHTML=content}});var onHashChangeRouter=function(){if(window.location.hash){var hash=window.location.hash.replace(/#/,'');var sectionLink=document.querySelectorAll('[data-target="'+hash+'"]');if(sectionLink.length){var sectionSrc=sectionLink[0].getAttribute("data-section-href");document.getElementsByTagName('iframe')[0].setAttribute("src",sectionSrc)}}};window.onhashchange=function(){onHashChangeRouter()}</script> </body> </html> | ||
<!DOCTYPE html> <html> <head> <title>Awesome cookbook JSON-RPC API doc</title> <style>html,body{margin:0;padding:0;height:100%;width:100%}h1,h2,h3,h4,h5,h6,p{margin:0}body{background-color:#2980b9;background-color:#34495e;font-size:12px;font-family:Arial,Helvetica,sans-serif;color:#2c3e50;overflow:auto;box-sizing:border-box;width:100vw;max-width:100vw;height:100vh;max-height:100vh;display:grid;grid-template-columns:auto 300px 900px auto;grid-template-rows:80px auto 80px;grid-template-areas:"header header header header" "empty-left nav main empty-right" "footer footer footer footer";grid-column-gap:2em}header{grid-area:header}nav{grid-area:nav;align-self:start}.empty-left{grid-area:empty-left}.empty-right{grid-area:empty-right}main{grid-area:main}footer{grid-area:footer}button.section-method,a.section-site{font-size:12px;display:block;width:100%;border:0;margin:0;line-height:30px;vertical-align:middle;padding:0 1em;background-color:#fff;color:#505050;box-sizing:border-box;text-align:left;border-radius:0;cursor:pointer}button.section-method:hover,a.section-site:hover,button.section-method:active,a.section-site:active,button.section-method:focus,a.section-site:focus,button.section-method:target,a.section-site:target{background-color:#eee;cursor:pointer;outline:none}.section-site:first-of-type{font-weight:700}.section-method:first-of-type,.section-site:first-of-type{border-top-right-radius:2px;border-top-left-radius:2px}.section-method:last-of-type,.section-site:last-of-type{border-bottom-right-radius:2px;border-bottom-left-radius:2px}.section-method:first-of-type{margin-top:1em}iframe{width:100%;height:0;border:0;padding:0;margin:0}</style> <link rel="shortcut icon" type="image/x-icon" href="favicon.ico"/> </head> <body> <header>Awesome cookbook JSON-RPC API doc</header> <div class="empty-left"></div> <nav> <p><a data-section-href="home.html" class="section-site" data-target="home">Home</a> <a data-section-href="about.html" class="section-site" data-target="about-project">About project</a> <button data-section-href="methods/user.login.html" class="section-method" data-target="user-login">user.login</button> <button data-section-href="methods/user.logout.html" class="section-method" data-target="user-logout">user.logout</button></p></nav> <div class="empty-right"></div> <main> <iframe src="" scrolling="no"></iframe> </main> <footer></footer> <script type="text/javascript">document.addEventListener("DOMContentLoaded",function(event){var buttons=document.querySelectorAll('[data-section-href]');for(var i=0;i<buttons.length;i++){buttons[i].addEventListener("click",function(event){event.stopPropagation();event.preventDefault();window.location.hash=this.getAttribute("data-target")})} if(buttons.length){if(window.location.hash){onHashChangeRouter()}else{var sectionLink=buttons[0].getAttribute("data-section-href");document.getElementsByTagName('iframe')[0].setAttribute("src",sectionLink)}}});document.getElementsByTagName("iframe")[0].addEventListener("load",function(){this.style.height=this.contentWindow.document.body.scrollHeight+'px'});document.getElementsByTagName("iframe")[0].addEventListener("load",function(){var jsonAreas=this.contentWindow.document.getElementsByClassName('language-json');for(var i=0;i<jsonAreas.length;i++){var content=jsonAreas[i].innerHTML;content=content.replace(/"([^"]+)":/g,"<span class=language-json-key>"$1":</span>");content=content.replace(/"([^"]+)"([^:])/g,"<span class=language-json-string>"$1"</span>$2");content=content.replace(/([ ,:{\n])(\d+)/g,"$1<span class=language-json-number>$2</span>");jsonAreas[i].innerHTML=content}});var onHashChangeRouter=function(){if(window.location.hash){var hash=window.location.hash.replace(/#/,'');var sectionLink=document.querySelectorAll('[data-target="'+hash+'"]');if(sectionLink.length){var sectionSrc=sectionLink[0].getAttribute("data-section-href");document.getElementsByTagName('iframe')[0].setAttribute("src",sectionSrc)}}};window.addEventListener('hashchange',onHashChangeRouter)</script> </body> </html> |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Ublaboo\Anabelle\Tests\Console\Utils; | ||
|
||
require_once __DIR__ . '/../../bootstrap.php'; | ||
|
||
use Tester\Assert; | ||
use Tester\TestCase; | ||
use Ublaboo\Anabelle\Console\Utils\Exception\ParamsValidatorException; | ||
use Ublaboo\Anabelle\Console\Utils\ParamsValidator; | ||
use Ublaboo\Anabelle\Http\AuthCredentials; | ||
|
||
class ParamsValidatorTest extends TestCase | ||
{ | ||
|
||
public function testDirectories(): void | ||
{ | ||
$auth = new AuthCredentials(null, null); | ||
$paramsValidator = new ParamsValidator(''); | ||
|
||
Assert::exception(function() use ($paramsValidator, $auth): void { | ||
$paramsValidator->validateInputParams( | ||
'nonExistingDir', | ||
'', | ||
$auth, | ||
false | ||
); | ||
}, ParamsValidatorException::class, 'Input documentation directory does not exist'); | ||
|
||
Assert::exception(function() use ($paramsValidator, $auth): void { | ||
$paramsValidator->validateInputParams( | ||
__FILE__, | ||
'', | ||
$auth, | ||
false | ||
); | ||
}, ParamsValidatorException::class, 'Given path is not a directory'); | ||
|
||
Assert::exception(function() use ($paramsValidator, $auth): void { | ||
$paramsValidator->validateInputParams( | ||
__DIR__, | ||
'', | ||
$auth, | ||
false | ||
); | ||
}, ParamsValidatorException::class, 'Missing file ' . __DIR__ . '/index.md'); | ||
|
||
$m = "Output directory path already exists." | ||
. " Delete it or use option [-o] as for \"overwrite\" output directory"; | ||
|
||
Assert::exception(function() use ($paramsValidator, $auth, $m): void { | ||
$paramsValidator->validateInputParams( | ||
TEST_DOCU_DIR, | ||
TEST_DOCU_DIR, | ||
$auth, | ||
false | ||
); | ||
}, ParamsValidatorException::class, $m); | ||
} | ||
} | ||
|
||
(new ParamsValidatorTest())->run(); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Api\Tests; | ||
|
||
use Tester\Environment; | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
define('TEST_DOCU_DIR', __DIR__ . '/testDir'); | ||
|
||
Environment::setup(); | ||
|
||
date_default_timezone_set('Europe/Prague'); |
Empty file.