TYPO3 CMS  TYPO3_6-2
TaskTest.php
Go to the documentation of this file.
1 <?php
3 
21 
25  protected $task;
26 
30  protected $taskExecutor;
31 
32  public function setUp() {
33  $this->taskExecutor = $this->getMock('TYPO3\\CMS\\Extbase\\Scheduler\\TaskExecutor', array('execute'), array(), '', FALSE);
34  $this->task = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Scheduler\\Task', array('logException', '__wakeup'), array(), '', FALSE);
35  }
36 
43  $this->taskExecutor->expects($this->once())->method('execute')->will($this->throwException(new \Exception()));
44  $this->task->_set('taskExecutor', $this->taskExecutor);
45  $this->task->expects($this->once())->method('logException');
46  $this->task->execute();
47  }
48 
54  $this->task->_set('taskExecutor', $this->taskExecutor);
55  $this->assertTrue($this->task->execute());
56  }
57 
63  $this->task->setCommandIdentifier('Foo');
64  $this->assertSame('Foo', $this->task->_get('commandIdentifier'));
65  }
66 
72  $this->task->_set('commandIdentifier', 'Foo');
73  $this->assertSame('Foo', $this->task->getCommandIdentifier());
74  }
75 
81  $this->task->setArguments(array('Foo'));
82  $this->assertSame(array('Foo'), $this->task->_get('arguments'));
83  }
84 
90  $this->task->_set('arguments', array('Foo'));
91  $this->assertSame(array('Foo'), $this->task->getArguments());
92  }
93 
99  $this->task->setDefaults(array('Foo'));
100  $this->assertSame(array('Foo'), $this->task->_get('defaults'));
101  }
102 
108  $this->task->_set('defaults', array('Foo'));
109  $this->assertSame(array('Foo'), $this->task->getDefaults());
110  }
111 
117  $defaults = array('foo' => 'bar');
118  $this->task->_set('defaults', $defaults);
119 
120  $defaults['baz'] = 'qux';
121  $this->task->addDefaultValue('baz', 'qux');
122 
123  $this->assertSame($defaults, $this->task->getDefaults());
124  }
125 
131  $defaults = array('foo' => 'bar');
132  $this->task->_set('defaults', $defaults);
133 
134  $defaults['baz'] = 1;
135  $this->task->addDefaultValue('baz', TRUE);
136 
137  $this->assertSame($defaults, $this->task->getDefaults());
138  }
139 
145  $this->task->_set('commandIdentifier', 'foo');
146  $this->task->_set('defaults', array('bar' => 'baz'));
147  $this->task->_set('arguments', array('qux' => 'quux'));
148 
149  $this->assertSame('foo qux=quux', $this->task->getAdditionalInformation());
150  }
151 }
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)