instaclick/base-test-bundle
Instaclick BaseTestBundle provides reusable base test cases and helpers for Symfony applications, streamlining functional testing, fixture loading, mocking, and common test setup so teams can write consistent, maintainable tests with less boilerplate.
This bundle is test infrastructure, not a feature bundle. It ships base test-case classes so you can boot a Symfony2 kernel, grab the container, and drive the test client without inheriting Symfony's own WebTestCase constraints.
dev-master:
composer require --dev instaclick/base-test-bundle:dev-master#<commit-sha>
test environment inside app/AppKernel.php:
if (in_array($this->getEnvironment(), array('test'))) {
$bundles[] = new IC\Bundle\BaseTestBundle\ICBaseTestBundle();
}
Test/ directory. That is where the base classes live (a WebTestCase for functional tests and typically a unit-oriented base case). Read getKernelClass(), createKernel(), and createClient() before writing anything else — those are the hooks you will override.use IC\Bundle\BaseTestBundle\Test\WebTestCase;
class HomepageTest extends WebTestCase
{
public function testHomepageIsReachable()
{
$client = $this->createClient();
$client->request('GET', '/');
$this->assertTrue($client->getResponse()->isSuccessful());
}
}
If the class namespaces differ in your checkout, trust the source over the README — the docs are from the Symfony 2.1–2.3 era.
createClient() per test, call $client->request(...), then assert on getResponse(), getCrawler(), and redirects. This mirrors Symfony's WebTestCase but lets the bundle control how the kernel is booted and reused.$kernel = $this->createKernel();
$kernel->boot();
$service = $kernel->getContainer()->get('acme.mailer');
This is the "lower level" value prop — you are not forced through HTTP to test wiring.getKernelClass() or createKernel() in your own abstract base test case so every test in a bundle boots the same environment (e.g., test, debug=false) and the same cache path:
protected function getKernelClass()
{
return 'Acme\TestBundle\Test\AppKernel';
}
Acme\TestBundle\Test\FunctionalTestCase extends WebTestCase in your project and centralize: kernel boot, DB truncation, mailer reset, and authentication helpers. Every bundle test then extends that.@dataProvider methods free of container access; boot the kernel in setUp() only, so data providers (which run before setUp) never touch services.@group functional and run them separately from unit tests in CI; kernel boots dominate runtime.setUp/tearDown behavior). Rebooting per test is correct but slow; only share when your tests don't mutate container state.composer require instaclick/base-test-bundle may resolve oddly; pin a SHA or a dev-master alias with a commit hash to keep builds reproducible.test only. Registering in prod/dev wastes autoload and can surprise you if the bundle's compiler passes assume test-only context.app/cache/test. If a config or container change isn't reflected, clear that cache manually — bin/phpunit won't always do it for you.setUp truncation. Treat the bundle as kernel/client plumbing only.createKernel(), createClient(), and getKernelClass() are your seams. Everything else (mailer assertions, DB reset, auth) belongs in your project-level base class, not in this dependency.--debug and inspect app/logs/test.log; a missing bundle registration or bad parameters_test.yml is the usual culprit.composer.json autoload mapping and confirm app/autoload.php registers the namespace before debugging your own test code.setUp() signatures yourself — budget for that if you're keeping it around.How can I help you explore Laravel packages today?