/** * Test that initialize() copies the connection property over. * * @return void */ public function testInitializeCopyConnection() { $this->assertEquals('', $this->Task->connection); $this->Task->params = ['connection' => 'test']; $this->Task->initialize(); $this->assertEquals('test', $this->Task->connection); }
/** * @covers Zend\Db\ResultSet\AbstractResultSet::current */ public function testCurrentCallsDataSourceCurrentOnceWithBuffer() { $result = $this->getMock('Zend\\Db\\Adapter\\Driver\\ResultInterface'); $this->resultSet->buffer(); $this->resultSet->initialize($result); $result->expects($this->once())->method('current')->will($this->returnValue(array('foo' => 'bar'))); $value1 = $this->resultSet->current(); $value2 = $this->resultSet->current(); $this->resultSet->current(); $this->assertEquals($value1, $value2); }
/** * Setup Defaults * * @return void */ public function setUp() { parent::setUp(); $this->out = new ConsoleOutput(); $this->err = new ConsoleOutput(); $io = new ConsoleIo($this->out, $this->err); $this->QueueShell = $this->getMockBuilder(QueueShell::class)->setMethods(['in', 'err', '_stop'])->setConstructorArgs([$io])->getMock(); $this->QueueShell->initialize(); $this->QueueShell->loadTasks(); Configure::write('Queue', ['sleeptime' => 2, 'gcprob' => 10, 'defaultworkertimeout' => 3, 'defaultworkerretries' => 1, 'workermaxruntime' => 5, 'cleanuptimeout' => 10, 'exitwhennothingtodo' => false, 'pidfilepath' => TMP . 'queue' . DS, 'log' => false]); }
/** * Creates a fake extension with a given table definition. * * @param string $tableDefinition SQL script to create the extension's tables * @throws \RuntimeException * @return void */ protected function createFakeExtension($tableDefinition) { // Prepare a fake extension configuration $ext_tables = GeneralUtility::tempnam('ext_tables'); if (!GeneralUtility::writeFile($ext_tables, $tableDefinition)) { throw new \RuntimeException('Can\'t write temporary ext_tables file.'); } $this->temporaryFiles[] = $ext_tables; $GLOBALS['TYPO3_LOADED_EXT'] = array('test_dbal' => array('ext_tables.sql' => $ext_tables)); // Append our test table to the list of existing tables $this->subject->initialize(); }
public function testAddError() { $context = ['foo' => 'fooValue', 'bar' => 'barValue']; $options = ['left' => 'foo', 'right' => 'bar']; $this->condition->initialize($options); $message = 'Error message.'; $this->condition->setMessage($message); $this->condition->expects($this->once())->method('isConditionAllowed')->with($context)->will($this->returnValue(false)); $errors = new ArrayCollection(); $this->assertFalse($this->condition->evaluate($context, $errors)); $this->assertCount(1, $errors); $this->assertEquals(['message' => $message, 'parameters' => []], $errors->get(0)); }
/** * @test */ public function standardTagAttributesAreRegistered() { $mockTagBuilder = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\TagBuilder', array('addAttribute'), array(), '', FALSE); $mockTagBuilder->expects($this->at(0))->method('addAttribute')->with('class', 'classAttribute'); $mockTagBuilder->expects($this->at(1))->method('addAttribute')->with('dir', 'dirAttribute'); $mockTagBuilder->expects($this->at(2))->method('addAttribute')->with('id', 'idAttribute'); $mockTagBuilder->expects($this->at(3))->method('addAttribute')->with('lang', 'langAttribute'); $mockTagBuilder->expects($this->at(4))->method('addAttribute')->with('style', 'styleAttribute'); $mockTagBuilder->expects($this->at(5))->method('addAttribute')->with('title', 'titleAttribute'); $mockTagBuilder->expects($this->at(6))->method('addAttribute')->with('accesskey', 'accesskeyAttribute'); $mockTagBuilder->expects($this->at(7))->method('addAttribute')->with('tabindex', 'tabindexAttribute'); $this->viewHelper->_set('tag', $mockTagBuilder); $arguments = array('class' => 'classAttribute', 'dir' => 'dirAttribute', 'id' => 'idAttribute', 'lang' => 'langAttribute', 'style' => 'styleAttribute', 'title' => 'titleAttribute', 'accesskey' => 'accesskeyAttribute', 'tabindex' => 'tabindexAttribute'); $this->viewHelper->_call('registerUniversalTagAttributes'); $this->viewHelper->setArguments($arguments); $this->viewHelper->initializeArguments(); $this->viewHelper->initialize(); }
public function testAddError() { $context = array('foo' => 'fooValue', 'bar' => 'barValue'); $options = array('left' => 'foo', 'right' => 'bar'); $left = $options['left']; $right = $options['right']; $this->condition->initialize($options); $message = 'Compare {{ left }} with {{ right }}.'; $this->condition->setMessage($message); $this->contextAccessor->expects($this->at(0))->method('getValue')->with($context, $left)->will($this->returnValue($context[$left])); $this->contextAccessor->expects($this->at(1))->method('getValue')->with($context, $right)->will($this->returnValue($context[$right])); $this->condition->expects($this->once())->method('doCompare')->with($context[$left], $context[$right])->will($this->returnValue(false)); $this->contextAccessor->expects($this->at(2))->method('getValue')->with($context, $left)->will($this->returnValue($context[$left])); $this->contextAccessor->expects($this->at(3))->method('getValue')->with($context, $right)->will($this->returnValue($context[$right])); $errors = new ArrayCollection(); $this->assertFalse($this->condition->isAllowed($context, $errors)); $this->assertEquals(1, $errors->count()); $this->assertEquals(array('message' => $message, 'parameters' => array('{{ left }}' => $context[$left], '{{ right }}' => $context[$right])), $errors->get(0)); }
public function testAddError() { $context = ['foo' => 'fooValue', 'bar' => 'barValue']; $options = ['left' => new PropertyPath('foo'), 'right' => new PropertyPath('bar')]; $left = $options['left']; $right = $options['right']; $keys = array_keys($context); $rightKey = end($keys); $leftKey = reset($keys); $this->condition->initialize($options); $message = 'Compare {{ left }} with {{ right }}.'; $this->condition->setMessage($message); $this->contextAccessor->expects($this->at(0))->method('getValue')->with($context, $left)->will($this->returnValue($context[$leftKey])); $this->contextAccessor->expects($this->at(1))->method('getValue')->with($context, $right)->will($this->returnValue($context[$rightKey])); $this->condition->expects($this->once())->method('doCompare')->with($context[$leftKey], $context[$rightKey])->will($this->returnValue(false)); $this->contextAccessor->expects($this->at(2))->method('getValue')->with($context, $left)->will($this->returnValue($context[$leftKey])); $this->contextAccessor->expects($this->at(3))->method('getValue')->with($context, $right)->will($this->returnValue($context[$rightKey])); $errors = new ArrayCollection(); $this->assertFalse($this->condition->evaluate($context, $errors)); $this->assertCount(1, $errors); $this->assertEquals(['message' => $message, 'parameters' => ['{{ left }}' => $context[$leftKey], '{{ right }}' => $context[$rightKey]]], $errors->get(0)); }
/** * @test */ public function renderSetsCheckedAttributeForListOfObjects() { $mockTagBuilder = $this->getMock(TagBuilder::class, array('setTagName', 'addAttribute')); $mockTagBuilder->expects($this->at(1))->method('addAttribute')->with('type', 'checkbox'); $mockTagBuilder->expects($this->at(2))->method('addAttribute')->with('name', 'foo[]'); $mockTagBuilder->expects($this->at(3))->method('addAttribute')->with('value', 2); $mockTagBuilder->expects($this->at(4))->method('addAttribute')->with('checked', 'checked'); $object1 = new \stdClass(); $object2 = new \stdClass(); $object3 = new \stdClass(); $this->viewHelper->expects($this->any())->method('getName')->willReturn('foo'); $this->viewHelper->expects($this->any())->method('getValueAttribute')->willReturn(2); $this->viewHelper->expects($this->any())->method('isObjectAccessorMode')->willReturn(true); $this->viewHelper->expects($this->any())->method('getPropertyValue')->willReturn(array($object1, $object2, $object3)); $this->viewHelper->_set('tag', $mockTagBuilder); $mockPersistenceManager = $this->getMock(PersistenceManagerInterface::class); $mockPersistenceManager->expects($this->any())->method('getIdentifierByObject')->will($this->returnValueMap(array(array($object1, 1), array($object2, 2), array($object3, 3)))); $this->viewHelper->_set('persistenceManager', $mockPersistenceManager); $this->viewHelper->initialize(); $this->viewHelper->render(); }