Skip to content

Commit

Permalink
Version 0.1.3 Release
Browse files Browse the repository at this point in the history
- Don't register command when playground file is empty
- Removed playground.php file from tests

Signed-off-by: RJ Garcia <[email protected]>
  • Loading branch information
ragboyjr committed Jun 4, 2020
1 parent a4a7fce commit b8cba15
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 0.1.3 - 2020-06-03

- Only register the playground command if playground file exists

## 0.1.2 - 2020-06-03

- Added test coverage
Expand Down
1 change: 1 addition & 0 deletions src/DependencyInjection/PlaygroundCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public function process(ContainerBuilder $container) {
$projectDir = $container->getParameter("kernel.project_dir");
$reflectionFn = self::loadPlaygroundCallableReflection($projectDir . '/playground.php');
if (!$reflectionFn) {
$container->removeDefinition("krak.symfony_playground.playground_command");
return;
}

Expand Down
2 changes: 0 additions & 2 deletions tests/Feature/Fixtures/playground.php

This file was deleted.

12 changes: 12 additions & 0 deletions tests/Feature/PlaygroundTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ protected function tearDown(): void {
$this->kernel->shutdown();
shell_exec("rm -rf {$this->kernel->getCacheDir()}");
}
$this->given_the_playground_php_file_is_removed();
}

protected function createKernel() {
Expand All @@ -46,6 +47,7 @@ public function test_does_nothing_if_no_playground_file_exists() {
$this->when_the_kernel_is_booted();
$this->then_no_exceptions_should_be_thrown();
$this->then_the_container_should_be_built(1);
$this->then_the_service_does_not_exist('krak.symfony_playground.playground_command');
}

public function test_rebuilds_sf_di_cache_on_first_invoke() {
Expand Down Expand Up @@ -77,6 +79,12 @@ public function test_rebuilds_sf_di_cache_if_playground_params_change() {
$this->then_the_container_should_be_built(2);
}

public function test_allows_playground_files_with_no_args() {
$this->given_the_playground_php_file_is_set_with('');
$this->when_the_kernel_is_booted();
$this->then_no_exceptions_should_be_thrown();
}

private function given_the_kernel_is_booted_and_waits(?int $seconds = 1) {
$this->when_the_kernel_is_booted();
if ($seconds) {
Expand Down Expand Up @@ -125,4 +133,8 @@ private function then_no_exceptions_should_be_thrown() {
private function then_the_container_should_be_built(int $times) {
$this->assertEquals($times, $this->kernel->containerBuildCount);
}

private function then_the_service_does_not_exist(string $id) {
$this->assertFalse($this->kernel->getContainer()->has($id));
}
}

0 comments on commit b8cba15

Please sign in to comment.