Skip to content

Commit

Permalink
Merge pull request #1602 from aryala7/DisableCommandTest
Browse files Browse the repository at this point in the history
[feat] implement test for disabling commands
  • Loading branch information
dcblogdev authored Aug 16, 2023
2 parents 354d91d + f27d030 commit 103ec42
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions tests/Commands/DisableCommandTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

namespace Nwidart\Modules\Tests\Commands;

use Nwidart\Modules\Contracts\RepositoryInterface;
use Nwidart\Modules\Module;
use Nwidart\Modules\Tests\BaseTestCase;

class DisableCommandTest extends BaseTestCase
{
public function setUp(): void
{
parent::setUp();
$this->artisan('module:make', ['name' => ['Blog']]);
$this->artisan('module:make', ['name' => ['Taxonomy']]);
}

public function tearDown(): void
{
$this->app[RepositoryInterface::class]->delete('Blog');
$this->app[RepositoryInterface::class]->delete('Taxonomy');
parent::tearDown();
}

/** @test */
public function it_disables_a_module()
{
/** @var Module $blogModule */
$blogModule = $this->app[RepositoryInterface::class]->find('Blog');
$blogModule->disable();

$code = $this->artisan('module:disable', ['module' => ['Blog']]);

$this->assertTrue($blogModule->isDisabled());
$this->assertSame(0, $code);
}

/** @test */
public function it_disables_array_of_modules()
{
/** @var Module $blogModule */
$blogModule = $this->app[RepositoryInterface::class]->find('Blog');
$blogModule->enable();

/** @var Module $taxonomyModule */
$taxonomyModule = $this->app[RepositoryInterface::class]->find('Taxonomy');
$taxonomyModule->enable();

$code = $this->artisan('module:disable',['module' => ['Blog','Taxonomy']]);

$this->assertTrue($blogModule->isDisabled() && $taxonomyModule->isDisabled());
$this->assertSame(0, $code);
}

/** @test */
public function it_disables_all_modules()
{
/** @var Module $blogModule */
$blogModule = $this->app[RepositoryInterface::class]->find('Blog');
$blogModule->enable();

/** @var Module $taxonomyModule */
$taxonomyModule = $this->app[RepositoryInterface::class]->find('Taxonomy');
$taxonomyModule->enable();

$code = $this->artisan('module:disable');

$this->assertTrue($blogModule->isDisabled() && $taxonomyModule->isDisabled());
$this->assertSame(0, $code);
}
}

0 comments on commit 103ec42

Please sign in to comment.