start using PHPUnit and test all this
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -12,3 +12,4 @@ Thumbs.db
|
|||||||
example/
|
example/
|
||||||
vendor/
|
vendor/
|
||||||
.env
|
.env
|
||||||
|
/.phpunit.result.cache
|
||||||
|
|||||||
1
bin/.gitignore
vendored
1
bin/.gitignore
vendored
@@ -3,3 +3,4 @@ lessc
|
|||||||
pscss
|
pscss
|
||||||
.directory
|
.directory
|
||||||
/phpca
|
/phpca
|
||||||
|
/phpunit
|
||||||
|
|||||||
@@ -27,19 +27,10 @@
|
|||||||
* @package magdev/dossier
|
* @package magdev/dossier
|
||||||
* @license http://opensource.org/licenses/MIT MIT License
|
* @license http://opensource.org/licenses/MIT MIT License
|
||||||
*/
|
*/
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
define('DOSSIER_ROOT', dirname(__DIR__));
|
require(dirname(__DIR__).'/src/bootstrap.php');
|
||||||
define('DOSSIER_CACHE', getenv('HOME').'/.dossier/cache');
|
|
||||||
define('PROJECT_ROOT', getcwd());
|
|
||||||
define('DOSSIER_LOGO', 'DQogX19fX19fX18gICAgICAgICAgICAgICAgICAgICAgLl9fICAgICAgICAgICAgICANCiBcX19fX19fIFwgICBfX19fICBfX19fX18gX19fX198X198IF9fX19fX19fX19fIA0KICB8ICAgIHwgIFwgLyAgXyBcLyAgX19fLy8gIF9fXy8gIHwvIF9fIFxfICBfXyBcDQogIHwgICAgYCAgICggIDxfPiApX19fIFwgXF9fXyBcfCAgXCAgX19fL3wgIHwgXC8NCiAvX19fX19fXyAgL1xfX19fL19fX18gID5fX19fICA+X198XF9fXyAgPl9ffCAgIA0KICAgICAgICAgXC8gICAgICAgICAgIFwvICAgICBcLyAgICAgICAgXC8gICAgICAgDQo=');
|
define('DOSSIER_LOGO', 'DQogX19fX19fX18gICAgICAgICAgICAgICAgICAgICAgLl9fICAgICAgICAgICAgICANCiBcX19fX19fIFwgICBfX19fICBfX19fX18gX19fX198X198IF9fX19fX19fX19fIA0KICB8ICAgIHwgIFwgLyAgXyBcLyAgX19fLy8gIF9fXy8gIHwvIF9fIFxfICBfXyBcDQogIHwgICAgYCAgICggIDxfPiApX19fIFwgXF9fXyBcfCAgXCAgX19fL3wgIHwgXC8NCiAvX19fX19fXyAgL1xfX19fL19fX18gID5fX19fICA+X198XF9fXyAgPl9ffCAgIA0KICAgICAgICAgXC8gICAgICAgICAgIFwvICAgICBcLyAgICAgICAgXC8gICAgICAgDQo=');
|
||||||
|
|
||||||
if (!is_dir(DOSSIER_CACHE)) {
|
|
||||||
mkdir(DOSSIER_CACHE, 0700, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
require DOSSIER_ROOT.'/vendor/autoload.php';
|
|
||||||
|
|
||||||
use Magdev\Dossier\Application;
|
use Magdev\Dossier\Application;
|
||||||
use Magdev\Dossier\Command;
|
use Magdev\Dossier\Command;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name" : "magdev/dossier",
|
"name" : "magdev/dossier",
|
||||||
"type" : "project",
|
"type" : "project",
|
||||||
"description" : "Create your dossier from Markdown files",
|
"description" : "Create a personal dossier from Markdown files",
|
||||||
"license" : "MIT",
|
"license" : "MIT",
|
||||||
"authors" : [{
|
"authors" : [{
|
||||||
"name" : "Marco Grätsch",
|
"name" : "Marco Grätsch",
|
||||||
@@ -13,6 +13,11 @@
|
|||||||
"Magdev\\Dossier\\" : "src"
|
"Magdev\\Dossier\\" : "src"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"autoload-dev" : {
|
||||||
|
"psr-4" : {
|
||||||
|
"Magdev\\DossierTests\\" : "tests"
|
||||||
|
}
|
||||||
|
},
|
||||||
"require" : {
|
"require" : {
|
||||||
"php" : "~7.2",
|
"php" : "~7.2",
|
||||||
"ext-phar" : "*",
|
"ext-phar" : "*",
|
||||||
@@ -39,6 +44,10 @@
|
|||||||
"pdfshift/pdfshift-php" : "~1.0.2",
|
"pdfshift/pdfshift-php" : "~1.0.2",
|
||||||
"raivisdejus/html-minifier" : "~0.5"
|
"raivisdejus/html-minifier" : "~0.5"
|
||||||
},
|
},
|
||||||
|
"require-dev" : {
|
||||||
|
"wapmorgan/php-code-analyzer" : "^1.0",
|
||||||
|
"phpunit/phpunit" : "~8.1"
|
||||||
|
},
|
||||||
"config" : {
|
"config" : {
|
||||||
"bin-dir" : "bin"
|
"bin-dir" : "bin"
|
||||||
},
|
},
|
||||||
@@ -64,8 +73,5 @@
|
|||||||
"url" : "git@github.com:magdev/console-form.git",
|
"url" : "git@github.com:magdev/console-form.git",
|
||||||
"name" : "magdev/console-form"
|
"name" : "magdev/console-form"
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"require-dev" : {
|
|
||||||
"wapmorgan/php-code-analyzer" : "^1.0"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
1904
composer.lock
generated
1904
composer.lock
generated
File diff suppressed because it is too large
Load Diff
17
phpunit.xml
Normal file
17
phpunit.xml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<phpunit
|
||||||
|
backupGlobals="false"
|
||||||
|
backupStaticAttributes="false"
|
||||||
|
bootstrap="src/bootstrap.php"
|
||||||
|
colors="true"
|
||||||
|
convertErrorsToExceptions="true"
|
||||||
|
convertNoticesToExceptions="true"
|
||||||
|
convertWarningsToExceptions="true"
|
||||||
|
processIsolation="false"
|
||||||
|
stopOnFailure="false">
|
||||||
|
|
||||||
|
<testsuites>
|
||||||
|
<testsuite name="dossier">
|
||||||
|
<directory>tests</directory>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
|
</phpunit>
|
||||||
41
src/bootstrap.php
Normal file
41
src/bootstrap.php
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019 magdev
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @author magdev
|
||||||
|
* @copyright 2019 Marco Grätsch
|
||||||
|
* @package magdev/dossier
|
||||||
|
* @license http://opensource.org/licenses/MIT MIT License
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
define('DOSSIER_ROOT', dirname(__DIR__));
|
||||||
|
define('DOSSIER_CACHE', getenv('HOME').'/.dossier/cache');
|
||||||
|
define('PROJECT_ROOT', getcwd());
|
||||||
|
|
||||||
|
if (!is_dir(DOSSIER_CACHE)) {
|
||||||
|
mkdir(DOSSIER_CACHE, 0700, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
require DOSSIER_ROOT.'/vendor/autoload.php';
|
||||||
56
tests/ApplicationTest.php
Normal file
56
tests/ApplicationTest.php
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019 magdev
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @author magdev
|
||||||
|
* @copyright 2019 Marco Grätsch
|
||||||
|
* @package magdev/dossier
|
||||||
|
* @license http://opensource.org/licenses/MIT MIT License
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Magdev\DossierTests;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
use Magdev\Dossier\Application;
|
||||||
|
use Magdev\Dossier\Service\GitService;
|
||||||
|
|
||||||
|
class ApplicationTest extends TestCase
|
||||||
|
{
|
||||||
|
private $app = null;
|
||||||
|
|
||||||
|
public function setup(): void
|
||||||
|
{
|
||||||
|
$this->app = new Application();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetContainer()
|
||||||
|
{
|
||||||
|
$this->assertInstanceOf(ContainerBuilder::class, $this->app->getContainer());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetValidService()
|
||||||
|
{
|
||||||
|
$this->assertInstanceOf(GitService::class, $this->app->getService('git'));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user