Skip to content

Commit

Permalink
Test coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseleite committed Dec 5, 2024
1 parent b6032a4 commit 0411923
Showing 1 changed file with 75 additions and 5 deletions.
80 changes: 75 additions & 5 deletions tests/StarterKits/InitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,11 @@ public function it_can_init_updatable_kit()
->expectsOutputToContain('Your starter kit config was successfully created in your project\'s [package] folder.')
->assertOk();

$this->assertCount(2, $this->files->allFiles($this->packagePath()));
$this->assertCount(3, $this->files->allFiles($this->packagePath()));

$this->assertFileExists($configPath = $this->packagePath('starter-kit.yaml'));
$this->assertFileExists($composerJsonPath = $this->packagePath('composer.json'));
$this->assertFileExists($serviceProviderPath = $this->packagePath('src/ServiceProvider.php'));

$this->assertEquals(<<<'YAML'
updatable: true
Expand Down Expand Up @@ -264,6 +265,22 @@ public function it_can_init_updatable_kit()
}
}
JSON, trim($this->files->get($composerJsonPath)));

$this->assertEquals(<<<'PHP'
<?php
namespace Example\StarterKitNamespace;
use Statamic\Providers\AddonServiceProvider;
class ServiceProvider extends AddonServiceProvider
{
public function bootAddon()
{
//
}
}
PHP, trim($this->files->get($serviceProviderPath)));
}

#[Test]
Expand All @@ -280,10 +297,11 @@ public function it_can_interactively_init_updatable_kit()
->expectsOutputToContain('Your starter kit config was successfully created in your project\'s [package] folder.')
->assertOk();

$this->assertCount(2, $this->files->allFiles($this->packagePath()));
$this->assertCount(3, $this->files->allFiles($this->packagePath()));

$this->assertFileExists($configPath = $this->packagePath('starter-kit.yaml'));
$this->assertFileExists($composerJsonPath = $this->packagePath('composer.json'));
$this->assertFileExists($serviceProviderPath = $this->packagePath('src/ServiceProvider.php'));

$this->assertEquals(<<<'YAML'
updatable: true
Expand Down Expand Up @@ -326,6 +344,22 @@ public function it_can_interactively_init_updatable_kit()
}
}
JSON, trim($this->files->get($composerJsonPath)));

$this->assertEquals(<<<'PHP'
<?php
namespace Example\StarterKitNamespace;
use Statamic\Providers\AddonServiceProvider;
class ServiceProvider extends AddonServiceProvider
{
public function bootAddon()
{
//
}
}
PHP, trim($this->files->get($serviceProviderPath)));
}

#[Test]
Expand All @@ -343,10 +377,11 @@ public function it_can_init_updatable_kit_with_custom_package_info()
->expectsOutputToContain('Your starter kit config was successfully created in your project\'s [package] folder.')
->assertOk();

$this->assertCount(2, $this->files->allFiles($this->packagePath()));
$this->assertCount(3, $this->files->allFiles($this->packagePath()));

$this->assertFileExists($configPath = $this->packagePath('starter-kit.yaml'));
$this->assertFileExists($composerJsonPath = $this->packagePath('composer.json'));
$this->assertFileExists($serviceProviderPath = $this->packagePath('src/ServiceProvider.php'));

$this->assertEquals(<<<'JSON'
{
Expand Down Expand Up @@ -374,6 +409,22 @@ public function it_can_init_updatable_kit_with_custom_package_info()
}
}
JSON, trim($this->files->get($composerJsonPath)));

$this->assertEquals(<<<'PHP'
<?php
namespace StatamicRadPack\CoolWritings;
use Statamic\Providers\AddonServiceProvider;
class ServiceProvider extends AddonServiceProvider
{
public function bootAddon()
{
//
}
}
PHP, trim($this->files->get($serviceProviderPath)));
}

#[Test]
Expand All @@ -390,10 +441,11 @@ public function it_can_interactively_init_updatable_kit_with_custom_package_info
->expectsOutputToContain('Your starter kit config was successfully created in your project\'s [package] folder.')
->assertOk();

$this->assertCount(2, $this->files->allFiles($this->packagePath()));
$this->assertCount(3, $this->files->allFiles($this->packagePath()));

$this->assertFileExists($configPath = $this->packagePath('starter-kit.yaml'));
$this->assertFileExists($composerJsonPath = $this->packagePath('composer.json'));
$this->assertFileExists($serviceProviderPath = $this->packagePath('src/ServiceProvider.php'));

$this->assertEquals(<<<'JSON'
{
Expand Down Expand Up @@ -421,6 +473,22 @@ public function it_can_interactively_init_updatable_kit_with_custom_package_info
}
}
JSON, trim($this->files->get($composerJsonPath)));

$this->assertEquals(<<<'PHP'
<?php
namespace StatamicRadPack\CoolWritings;
use Statamic\Providers\AddonServiceProvider;
class ServiceProvider extends AddonServiceProvider
{
public function bootAddon()
{
//
}
}
PHP, trim($this->files->get($serviceProviderPath)));
}

#[Test]
Expand All @@ -436,12 +504,14 @@ public function it_properly_camel_cases_namespace()
->expectsOutputToContain('Your starter kit config was successfully created in your project\'s [package] folder.')
->assertOk();

$this->assertCount(2, $this->files->allFiles($this->packagePath()));
$this->assertCount(3, $this->files->allFiles($this->packagePath()));

$this->assertFileExists($composerJsonPath = $this->packagePath('composer.json'));
$this->assertFileExists($serviceProviderPath = $this->packagePath('src/ServiceProvider.php'));

$this->assertStringContainsString('"Example\\\\CoolWritingsKitABC\\\\": "src"', $this->files->get($composerJsonPath));
$this->assertStringContainsString('"Example\\\\CoolWritingsKitABC\\\\ServiceProvider"', $this->files->get($composerJsonPath));
$this->assertStringContainsString('namespace Example\\CoolWritingsKitABC;', $this->files->get($serviceProviderPath));
}

#[Test]
Expand Down

0 comments on commit 0411923

Please sign in to comment.