1. Go to this page and download the library: Download rector/swiss-knife 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/ */
declare(strict_types=1);
namespace App\Tests\Unit\Smoke;
use Throwable;
final class ServiceContainerTest extends AbstractContainerTestCase
{
public function testServiceConstruction(): void
{
$serviceIds = self::$container->getServiceIds();
$checkedServiceCount = 0;
foreach ($serviceIds as $serviceId) {
if ($this->isDynamicService($serviceId)) {
continue;
}
try {
self::$container->get($serviceId);
} catch (Throwable $throwable) {
$this->fail(sprintf('Service "%s" could not be created because:%s%s', $serviceId, PHP_EOL, $throwable->getMessage()));
}
++$checkedServiceCount;
}
// @todo update this number to match your service count
$this->assertSame(100000, $checkedServiceCount);
}
private function isDynamicService(string $serviceId): bool
{
if (str_contains($serviceId, 'session')) {
return true;
}
if (str_starts_with($serviceId, 'doctrine.')) {
return true;
}
return in_array(
$serviceId,
['kernel', 'database_connection', 'event_dispatcher'],
true
);
}
}