PHP code example of webnazakazku / mango-tester-infrastructure

1. Go to this page and download the library: Download webnazakazku/mango-tester-infrastructure library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

webnazakazku / mango-tester-infrastructure example snippets




igurator = new Nette\Configurator();

// we need to override defaultExtensions because Nette\Configurator registers
// butch of extensions we don't need and that clash with the Mango Tester
$configurator->defaultExtensions = [
	'php' => Nette\DI\Extensions\PhpExtension::class,
	'constants' => Nette\DI\Extensions\ConstantsExtension::class,
	'extensions' => Nette\DI\Extensions\ExtensionsExtension::class,
	'decorator' => Nette\DI\Extensions\DecoratorExtension::class,
	'cache' => [Nette\Bridges\CacheDI\CacheExtension::class, ['%tempDir%']],
	'di' => [Nette\DI\Extensions\DIExtension::class, ['%debugMode%']],
	'database' => [Nette\Bridges\DatabaseDI\DatabaseExtension::class, ['%debugMode%']],
	'tracy' => [Tracy\Bridges\Nette\TracyExtension::class, ['%debugMode%', '%consoleMode%']],
	'inject' => Nette\DI\Extensions\InjectExtension::class,
];

$configurator->setDebugMode(true);
$logDir = __DIR__ . '/../temp/tests/log';
@mkdir($logDir, 0777, true);
$configurator->enableTracy($logDir);
$configurator->setTempDirectory(__DIR__ . '/../temp/tests');

$appDir = __DIR__ . '/../app';

$rb = $configurator->createRobotLoader()
	->addDirectory($appDir)
	->addDirectory(__DIR__)
	->register();

$configurator->addParameters(
	[
		'appDir' => $appDir,
		'wwwDir' => __DIR__ . '/../www',
	]
);

$configurator->addConfig(__DIR__ . '/config/tests.neon');
$configurator->addConfig(__DIR__ . '/../app/config/tests.local.neon');

Tester\Environment::setup();
Tester\Dumper::$maxPathSegments = 32;

return [$configurator, 'createContainer'];

 declare(strict_types = 1);

namespace AppTests;

use Nette\Configurator;
use Nette\DI\Container as DIContainer;
use Nette\DI\Definitions\Statement as DIStatement;
use Nette\Neon\Neon;
use Nette\Utils\Finder;
use Throwable;
use Webnazakazku\MangoTester\Infrastructure\Container\IAppConfiguratorFactory;

class AppConfiguratorFactory implements IAppConfiguratorFactory
{

	public function create(DIContainer $testContainer): Configurator
	{
		$testContainerParameters = $testContainer->getParameters();

		$configurator = new Configurator();
		$configurator->setDebugMode(true);
		$configurator->setTempDirectory($testContainerParameters['tempDir']);

		$appDir = __DIR__ . '/../../app';
		$wwwDir = __DIR__ . '/../../temp/tests/www';

		$configurator->addParameters(
			[
				'appDir' => $appDir,
				'wwwDir' => $wwwDir,
			]
		);

		$configurator->addConfig(__DIR__ . '/../config/app.neon');

		$configurator->createRobotLoader()
			->addDirectory($appDir)
			->register();

		$configurator->addConfig($appDir . '/config/config.neon');
		$configurator->addConfig($appDir . '/config/tests.local.neon');

		$configurator->addConfig(
			[
				'console' => [
					'url' => null,
				],
			]
		);

		return $configurator;
	}

}