-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
159 additions
and
2 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
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,4 @@ | ||
# for php-coveralls | ||
service_name: github-actions | ||
coverage_clover: coverage.xml | ||
json_path: coverage.json |
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,10 @@ | ||
# Folders - recursive | ||
*.expected | ||
*.actual | ||
|
||
# Folders | ||
/tmp | ||
|
||
# Files | ||
/*.log | ||
/*.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Tests\Cases\E2E\Container; | ||
|
||
use App\Bootstrap; | ||
use Contributte\Utils\FileSystem; | ||
use Nette\Application\Application as WebApplication; | ||
use Nette\DI\Container; | ||
use Symfony\Component\Console\Application as ConsoleApplication; | ||
use Tester\Assert; | ||
use Tester\TestCase; | ||
use Tests\Toolkit\Tests; | ||
|
||
require_once __DIR__ . '/../../../bootstrap.php'; | ||
|
||
final class EntrypointTest extends TestCase | ||
{ | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
if (!file_exists(Tests::ROOT_PATH . '/config/local.neon')) { | ||
FileSystem::copy( | ||
Tests::ROOT_PATH . '/config/local.neon.example', | ||
Tests::ROOT_PATH . '/config/local.neon' | ||
); | ||
} | ||
} | ||
|
||
public function testWeb(): void | ||
{ | ||
$container = Bootstrap::boot()->createContainer(); | ||
$container->getByType(WebApplication::class); | ||
|
||
Assert::type(Container::class, $container); | ||
} | ||
|
||
public function testCli(): void | ||
{ | ||
$container = Bootstrap::boot()->createContainer(); | ||
$container->getByType(ConsoleApplication::class); | ||
|
||
Assert::type(Container::class, $container); | ||
} | ||
|
||
public function testTest(): void | ||
{ | ||
$container = Bootstrap::boot()->createContainer(); | ||
$container->getByType(Container::class); | ||
|
||
Assert::type(Container::class, $container); | ||
} | ||
|
||
} | ||
|
||
(new EntrypointTest())->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,36 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Tests\Cases\E2E\Latte; | ||
|
||
use App\Bootstrap; | ||
use Contributte\Tester\Toolkit; | ||
use Nette\Bridges\ApplicationLatte\Template; | ||
use Nette\Bridges\ApplicationLatte\TemplateFactory; | ||
use Nette\Utils\Finder; | ||
use SplFileInfo; | ||
use Tester\Assert; | ||
use Tests\Toolkit\Tests; | ||
use Throwable; | ||
|
||
require_once __DIR__ . '/../../../bootstrap.php'; | ||
|
||
Toolkit::test(function (): void { | ||
$container = Bootstrap::boot()->createContainer(); | ||
|
||
/** @var TemplateFactory $templateFactory */ | ||
$templateFactory = $container->getByType(TemplateFactory::class); | ||
Assert::type(TemplateFactory::class, $templateFactory); | ||
|
||
/** @var Template $template */ | ||
$template = $templateFactory->createTemplate(); | ||
$finder = Finder::findFiles('*.latte')->from(Tests::APP_PATH); | ||
|
||
try { | ||
/** @var SplFileInfo $file */ | ||
foreach ($finder as $file) { | ||
$template->getLatte()->warmupCache($file->getRealPath()); | ||
} | ||
} catch (Throwable $e) { | ||
Assert::fail(sprintf('Template compilation failed ([%s] %s)', $e::class, $e->getMessage())); | ||
} | ||
}); |
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,19 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Tests\Cases\Unit\Model; | ||
|
||
use App\Model\LoggerService; | ||
use Contributte\Tester\Environment; | ||
use Contributte\Tester\Toolkit; | ||
use Nette\Utils\Json; | ||
use Tester\Assert; | ||
|
||
require_once __DIR__ . '/../../../bootstrap.php'; | ||
|
||
Toolkit::test(function (): void { | ||
$logfile = Environment::getTestDir() . '/log.txt'; | ||
$logger = new LoggerService($logfile); | ||
$logger->write('test'); | ||
|
||
Assert::match('[{"date":%A%,"message":"test"}]', Json::encode($logger->list())); | ||
}); |
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,11 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Tests\Toolkit; | ||
|
||
final class Tests | ||
{ | ||
|
||
public const ROOT_PATH = __DIR__ . '/../..'; | ||
public const APP_PATH = __DIR__ . '/../../app'; | ||
|
||
} |
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,10 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
use Contributte\Tester\Environment; | ||
|
||
if (@!include __DIR__ . '/../vendor/autoload.php') { | ||
echo 'Install Nette Tester using `composer update --dev`'; | ||
exit(1); | ||
} | ||
|
||
Environment::setup(__DIR__); |