Fix how tags are created. Fixes #3004
This commit is contained in:
54
tests/Bus/Commands/Tag/ApplyTagCommandTest.php
Normal file
54
tests/Bus/Commands/Tag/ApplyTagCommandTest.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Bus\Commands\Tag;
|
||||
|
||||
use AltThree\TestBench\CommandTrait;
|
||||
use CachetHQ\Cachet\Bus\Commands\Tag\ApplyTagCommand;
|
||||
use CachetHQ\Cachet\Bus\Handlers\Commands\Tag\ApplyTagCommandHandler;
|
||||
use CachetHQ\Cachet\Models\Component;
|
||||
use CachetHQ\Cachet\Models\Tag;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the apply tag command test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class ApplyTagCommandTest extends AbstractTestCase
|
||||
{
|
||||
use CommandTrait;
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = [
|
||||
'model' => new Component(),
|
||||
'tag' => new Tag(),
|
||||
];
|
||||
|
||||
$object = new ApplyTagCommand(
|
||||
$params['model'],
|
||||
$params['tag']
|
||||
);
|
||||
|
||||
return compact('params', 'object');
|
||||
}
|
||||
|
||||
protected function objectHasRules()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getHandlerClass()
|
||||
{
|
||||
return ApplyTagCommandHandler::class;
|
||||
}
|
||||
}
|
||||
52
tests/Bus/Commands/Tag/CreateTagCommandTest.php
Normal file
52
tests/Bus/Commands/Tag/CreateTagCommandTest.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Bus\Commands\Tag;
|
||||
|
||||
use AltThree\TestBench\CommandTrait;
|
||||
use CachetHQ\Cachet\Bus\Commands\Tag\CreateTagCommand;
|
||||
use CachetHQ\Cachet\Bus\Handlers\Commands\Tag\CreateTagCommandHandler;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the create tag command test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class CreateTagCommandTest extends AbstractTestCase
|
||||
{
|
||||
use CommandTrait;
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = [
|
||||
'name' => 'Test',
|
||||
'slug' => 'test',
|
||||
];
|
||||
|
||||
$object = new CreateTagCommand(
|
||||
$params['name'],
|
||||
$params['slug']
|
||||
);
|
||||
|
||||
return compact('params', 'object');
|
||||
}
|
||||
|
||||
protected function objectHasRules()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getHandlerClass()
|
||||
{
|
||||
return CreateTagCommandHandler::class;
|
||||
}
|
||||
}
|
||||
51
tests/Bus/Commands/Tag/DeleteTagCommandTest.php
Normal file
51
tests/Bus/Commands/Tag/DeleteTagCommandTest.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Bus\Commands\Tag;
|
||||
|
||||
use AltThree\TestBench\CommandTrait;
|
||||
use CachetHQ\Cachet\Bus\Commands\Tag\DeleteTagCommand;
|
||||
use CachetHQ\Cachet\Bus\Handlers\Commands\Tag\DeleteTagCommandHandler;
|
||||
use CachetHQ\Cachet\Models\Tag;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the delete tag command test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class DeleteTagCommandTest extends AbstractTestCase
|
||||
{
|
||||
use CommandTrait;
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = [
|
||||
'tag' => new Tag(),
|
||||
];
|
||||
|
||||
$object = new DeleteTagCommand(
|
||||
$params['tag']
|
||||
);
|
||||
|
||||
return compact('params', 'object');
|
||||
}
|
||||
|
||||
protected function objectHasRules()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getHandlerClass()
|
||||
{
|
||||
return DeleteTagCommandHandler::class;
|
||||
}
|
||||
}
|
||||
55
tests/Bus/Commands/Tag/UpdateTagCommandTest.php
Normal file
55
tests/Bus/Commands/Tag/UpdateTagCommandTest.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Bus\Commands\Tag;
|
||||
|
||||
use AltThree\TestBench\CommandTrait;
|
||||
use CachetHQ\Cachet\Bus\Commands\Tag\UpdateTagCommand;
|
||||
use CachetHQ\Cachet\Bus\Handlers\Commands\Tag\UpdateTagCommandHandler;
|
||||
use CachetHQ\Cachet\Models\Tag;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the update tag command test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class UpdateTagCommandTest extends AbstractTestCase
|
||||
{
|
||||
use CommandTrait;
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = [
|
||||
'tag' => new Tag(),
|
||||
'name' => 'Test',
|
||||
'slug' => 'test',
|
||||
];
|
||||
|
||||
$object = new UpdateTagCommand(
|
||||
$params['tag'],
|
||||
$params['name'],
|
||||
$params['slug']
|
||||
);
|
||||
|
||||
return compact('params', 'object');
|
||||
}
|
||||
|
||||
protected function objectHasRules()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getHandlerClass()
|
||||
{
|
||||
return UpdateTagCommandHandler::class;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user