|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Utopia PHP Framework |
| 4 | + * |
| 5 | + * @package Abuse |
| 6 | + * @subpackage Tests |
| 7 | + * |
| 8 | + * @link https://github.com/utopia-php/framework |
| 9 | + * @author Eldad Fux <[email protected]> |
| 10 | + * @version 1.0 RC4 |
| 11 | + * @license The MIT License (MIT) <http://www.opensource.org/licenses/mit-license.php> |
| 12 | + */ |
| 13 | + |
| 14 | +namespace Utopia\Tests; |
| 15 | + |
| 16 | +use Utopia\CLI\Task; |
| 17 | +use PHPUnit\Framework\TestCase; |
| 18 | +use Utopia\Validator\Email; |
| 19 | + |
| 20 | +class TaskTest extends TestCase |
| 21 | +{ |
| 22 | + /** |
| 23 | + * @var Task |
| 24 | + */ |
| 25 | + protected $task; |
| 26 | + |
| 27 | + public function setUp() |
| 28 | + { |
| 29 | + $this->task = new Task('test'); |
| 30 | + } |
| 31 | + |
| 32 | + public function tearDown() |
| 33 | + { |
| 34 | + $this->task = null; |
| 35 | + } |
| 36 | + |
| 37 | + public function testDescription() |
| 38 | + { |
| 39 | + $this->task->desc('test task'); |
| 40 | + |
| 41 | + $this->assertEquals('test task', $this->task->getDesc()); |
| 42 | + } |
| 43 | + |
| 44 | + public function testAction() |
| 45 | + { |
| 46 | + $this->task->action(function () { |
| 47 | + return 'result'; |
| 48 | + }); |
| 49 | + |
| 50 | + $this->assertEquals('result', $this->task->getAction()()); |
| 51 | + } |
| 52 | + |
| 53 | + public function testLabel() |
| 54 | + { |
| 55 | + $this->task->label('key', 'value'); |
| 56 | + |
| 57 | + $this->assertEquals('value', $this->task->getLabel('key', 'default')); |
| 58 | + $this->assertEquals('default', $this->task->getLabel('unknown', 'default')); |
| 59 | + } |
| 60 | + |
| 61 | + public function testParam() |
| 62 | + { |
| 63 | + $this-> task-> param( 'email', '[email protected]', new Email(), 'Param with valid email address', false); |
| 64 | + |
| 65 | + $this->assertCount(1, $this->task->getParams()); |
| 66 | + } |
| 67 | +} |
0 commit comments