PHP code example of builtbyberry / laravel-swarm-installer-testkit
1. Go to this page and download the library: Download builtbyberry/laravel-swarm-installer-testkit 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/ */
builtbyberry / laravel-swarm-installer-testkit example snippets
namespace App\Tests\Installer;
use BuiltByBerry\LaravelSwarmInstallerTestkit\InstallerTestCase;
class MyPackageInstallerTestCase extends InstallerTestCase
{
protected function getPackageProviders($app): array
{
return [
\My\Package\MyPackageServiceProvider::class,
];
}
}
use App\Tests\Installer\MyPackageInstallerTestCase;
uses(MyPackageInstallerTestCase::class);
use App\Tests\Installer\MyPackageInstallerTestCase;
uses(MyPackageInstallerTestCase::class);
test('my:install wires up the runtime', function () {
$this->runInstaller('my:install')
->assertSucceeded()
->assertOutputContains('Installed.');
$this->assertFileContains('config/my-package.php', "'driver' => 'database'");
$this->assertEnvKey('MY_PACKAGE_DRIVER', 'database');
$this->assertScheduleEntry('my:prune');
});
test('my:install is idempotent', function () {
$this->runInstaller('my:install')
->assertSucceeded()
->twice()
->assertSecondRunIsNoOp();
});
test('my:install refuses on an unsupported driver', function () {
$this->writeSkeletonFile('config/my-package.php', " return ['driver' => 'unsupported'];");
$this->assertInstallerFailsWith(
'my:install',
[],
'Unsupported driver',
);
});
$this->writeSkeletonFile('config/my-package.php', file_get_contents(__DIR__.'/fixtures/old-config.php'));
beforeEach(function () {
$this->registerInstallerCommand(\App\Console\Commands\MyInstallerCommand::class);
});