2 declare(strict_types = 1);
20 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
37 protected function setUp()
39 $this->taskExecutor = $this->getMockBuilder(TaskExecutor::class)
40 ->setMethods([
'execute'])
41 ->disableOriginalConstructor()
43 $this->task = $this->getAccessibleMock(Task::class, [
'logException',
'__wakeup'], [],
'',
false);
51 $this->expectException(\Exception::class);
53 $this->taskExecutor->expects($this->once())->method(
'execute')->will($this->throwException(
new \
Exception(
'testing', 1476107518)));
54 $this->task->_set(
'taskExecutor', $this->taskExecutor);
55 $this->task->expects($this->once())->method(
'logException');
56 $this->task->execute();
64 $this->task->_set(
'taskExecutor', $this->taskExecutor);
65 $this->assertTrue($this->task->execute());
73 $this->task->setCommandIdentifier(
'Foo');
74 $this->assertSame(
'Foo', $this->task->_get(
'commandIdentifier'));
82 $this->task->_set(
'commandIdentifier',
'Foo');
83 $this->assertSame(
'Foo', $this->task->getCommandIdentifier());
91 $this->task->setArguments([
'Foo']);
92 $this->assertSame([
'Foo'], $this->task->_get(
'arguments'));
100 $this->task->_set(
'arguments', [
'Foo']);
101 $this->assertSame([
'Foo'], $this->task->getArguments());
109 $this->task->setDefaults([
'Foo']);
110 $this->assertSame([
'Foo'], $this->task->_get(
'defaults'));
118 $this->task->_set(
'defaults', [
'Foo']);
119 $this->assertSame([
'Foo'], $this->task->getDefaults());
127 $defaults = [
'foo' =>
'bar'];
128 $this->task->_set(
'defaults', $defaults);
130 $defaults[
'baz'] =
'qux';
131 $this->task->addDefaultValue(
'baz',
'qux');
133 $this->assertSame($defaults, $this->task->getDefaults());
141 $defaults = [
'foo' =>
'bar'];
142 $this->task->_set(
'defaults', $defaults);
144 $defaults[
'baz'] = 1;
145 $this->task->addDefaultValue(
'baz',
true);
147 $this->assertSame($defaults, $this->task->getDefaults());
155 $this->task->_set(
'commandIdentifier',
'foo');
156 $this->task->_set(
'defaults', [
'bar' =>
'baz']);
157 $this->task->_set(
'arguments', [
'qux' =>
'quux']);
159 $this->assertSame(
'foo qux=quux', $this->task->getAdditionalInformation());