/** * @test */ public function processReturnsEmptyStringIfSpecifiedPostProcessorDoesNotImplementTheInterface() { $typoScript = array(10 => $this->getUniqueId('postprocess'), 20 => \TYPO3\CMS\Form\Tests\Unit\Fixtures\PostProcessorWithoutInterfaceFixture::class); $this->subject->typoScript = $typoScript; $this->subject->expects($this->once())->method('sortTypoScriptKeyList')->will($this->returnValue(array(10, 20))); $returnValue = $this->subject->process(); $this->assertEquals('', $returnValue); }
/** * @test */ public function processReturnsEmptyStringIfSpecifiedPostProcessorDoesNotImplementTheInterface() { $classNameWithoutInterface = uniqid('postprocess'); eval('namespace TYPO3\\CMS\\Form\\PostProcess;' . 'class ' . $classNameWithoutInterface . 'PostProcessor {' . ' public function __construct(\\TYPO3\\CMS\\Form\\Domain\\Model\\Form $form, array $typoScript) {' . ' }' . ' public function process() {' . ' return \'withoutInterface\';' . ' }' . '}'); $typoScript = array(10 => uniqid('postprocess'), 20 => $classNameWithoutInterface); $this->fixture->typoScript = $typoScript; $this->fixture->expects($this->once())->method('sortTypoScriptKeyList')->will($this->returnValue(array(10, 20))); $returnValue = $this->fixture->process(); $this->assertEquals('', $returnValue); }
/** * @test */ public function processWrapsCurrentViewHelperInEscapeNode() { $interceptorPosition = InterceptorInterface::INTERCEPT_OBJECTACCESSOR; $mockNode = $this->getMock(ObjectAccessorNode::class, [], [], '', false); $actualResult = $this->escapeInterceptor->process($mockNode, $interceptorPosition, $this->mockParsingState); $this->assertInstanceOf(EscapingNode::class, $actualResult); }
/** * @covers ::process * @covers ::processCallback */ public function testProcess() { $cache_contexts = Cache::mergeContexts(['baz', 'qux']); $cache_tags = Cache::mergeTags(['foo', 'bar']); $currency_code_from = 'EUR'; $currency_code_to = 'NLG'; $rate = '2.20371'; $exchange_rate_provider_id = 'foo_bar'; $exchange_rate = new ExchangeRate($currency_code_from, $currency_code_to, $rate, $exchange_rate_provider_id); $exchange_rate->addCacheContexts($cache_contexts); $exchange_rate->addCacheTags($cache_tags); $this->input->expects($this->any())->method('parseAmount')->will($this->returnArgument(0)); $this->exchangeRateProvider->expects($this->any())->method('load')->with($currency_code_from, $currency_code_to)->willReturn($exchange_rate); $langcode = $this->randomMachineName(2); $tokens_valid = ['[currency:EUR:NLG]' => '2.20371', '[currency:EUR:NLG:1]' => '2.20371', '[currency:EUR:NLG:2]' => '4.40742']; $tokens_invalid = ['[currency]', '[currency:]', '[currency::]', '[currency:EUR]', '[currency:EUR:123]', '[currency:123:EUR]', '[currency:123]']; foreach ($tokens_valid as $token => $replacement) { $result = $this->sut->process($token, $langcode); $this->assertInstanceOf(FilterProcessResult::class, $result); $this->assertSame($replacement, $result->getProcessedText()); $this->assertSame($cache_contexts, $result->getCacheContexts()); $this->assertSame($cache_tags, $result->getCacheTags()); } foreach ($tokens_invalid as $token) { $result = $this->sut->process($token, $langcode); $this->assertInstanceOf(FilterProcessResult::class, $result); $this->assertSame($token, $result->getProcessedText()); $this->assertEmpty($result->getCacheContexts()); $this->assertEmpty($result->getCacheTags()); } }
/** * @test */ public function processReturnsEmptyStringIfSpecifiedPostProcessorDoesNotImplementTheInterface() { $typoScript = array(10 => uniqid('postprocess'), 20 => $this->classNameWithoutInterface); $this->postprocessor->typoScript = $typoScript; $this->postprocessor->expects($this->once())->method('sortTypoScriptKeyList')->will($this->returnValue(array(10, 20))); $returnValue = $this->postprocessor->process(); $this->assertEquals('', $returnValue); }
/** * @test */ public function processWrapsCurrentViewHelperInHtmlspecialcharsViewHelperOnObjectAccessor() { $interceptorPosition = InterceptorInterface::INTERCEPT_OBJECTACCESSOR; $mockNode = $this->getMock('NamelessCoder\\Fluid\\Core\\Parser\\SyntaxTree\\ObjectAccessorNode', array(), array(), '', FALSE); $mockEscapeViewHelper = $this->getMock('NamelessCoder\\Fluid\\ViewHelpers\\Format\\HtmlspecialcharsViewHelper'); $actualResult = $this->escapeInterceptor->process($mockNode, $interceptorPosition, $this->mockParsingState); $this->assertInstanceOf('NamelessCoder\\Fluid\\Core\\Parser\\SyntaxTree\\ViewHelperNode', $actualResult); }
public function testProcess() { $item = $this->getMock('Mage_Sales_Model_Quote_Item', array('getAddress'), array(), '', false); $item->expects($this->once())->method('getAddress')->will($this->returnValue(true)); $item->setDiscountCalculationPrice(-1); $item->setCalculationPrice(1); $quote = $this->getMock('Mage_Sales_Model_Quote', null, array(), '', false); $item->setQuote($quote); $this->assertInstanceOf('Mage_SalesRule_Model_Validator', $this->_model->process($item)); return true; }
/** * @test */ public function processWrapsCurrentViewHelperInHtmlspecialcharsViewHelperOnObjectAccessor() { $interceptorPosition = InterceptorInterface::INTERCEPT_OBJECTACCESSOR; $mockNode = $this->getMock(\TYPO3\Fluid\Core\Parser\SyntaxTree\ObjectAccessorNode::class, array(), array(), '', false); $mockEscapeViewHelper = $this->getMock(\TYPO3\Fluid\ViewHelpers\Format\HtmlspecialcharsViewHelper::class); $mockObjectManager = $this->getMock(\TYPO3\Flow\Object\ObjectManagerInterface::class); $mockObjectManager->expects($this->at(0))->method('get')->with(\TYPO3\Fluid\ViewHelpers\Format\HtmlspecialcharsViewHelper::class)->will($this->returnValue($mockEscapeViewHelper)); $mockObjectManager->expects($this->at(1))->method('get')->with(\TYPO3\Fluid\Core\Parser\SyntaxTree\ViewHelperNode::class, $mockEscapeViewHelper, array('value' => $mockNode))->will($this->returnValue($this->mockNode)); $this->escapeInterceptor->injectObjectManager($mockObjectManager); $actualResult = $this->escapeInterceptor->process($mockNode, $interceptorPosition, $this->mockParsingState); $this->assertSame($this->mockNode, $actualResult); }
/** * Verifies that we can skip processing. * * @covers ::dispatchSkippedProcessing * @covers ::process * * @depends testVerifyFileContentsProcessedAndEventsDispatched */ public function testVerifyProcessingSkipped() { // register an event dispatcher $dispatcher = new EventDispatcher(); $this->processor->setDispatcher($dispatcher); // require that processing be skipped $dispatcher->addListener(Events::PRE_PROCESSING, function (PreProcessingEvent $event) { $event->skip(); }); // verify that the skip event is dispatched $skipped = false; $dispatcher->addListener(Events::SKIPPED_PROCESSING, function (SkippedProcessingEvent $event) use(&$skipped) { $skipped = true; }); // make sure the processing method is never called $this->processor->expects(self::never())->method('doProcessing'); // make sure the contents were are returned unchanged self::assertEquals('<?php echo "Hello, world!\\n";', $this->processor->process('test.php', '<?php echo "Hello, world!\\n";')); // make sure the skip event was dispatched self::assertTrue($skipped); }
/** * @expectedException \Exception * @expectedExceptionMessage Missing write permissions to the following paths: */ public function testWritePermissionErrors() { $this->filePermissions->expects($this->once())->method('getMissingWritablePathsForInstallation')->willReturn(['/a/ro/dir', '/media']); $this->configModel->process([]); }
/** * @param array $structureElements * * @dataProvider processWithExceptionDataProvider * @expectedException \Magento\Framework\Exception\LocalizedException */ public function testProcessWithException($structureElements) { $this->scheduledStructureMock->expects($this->once())->method('getElements')->willReturn($structureElements); $this->structureMock->expects($this->once())->method('setAttribute')->willReturnSelf(); $this->container->process($this->readerContextMock, $this->generatorContextMock); }
/** * @param FieldConfigModel $field * @param bool $isExist * @param FieldConfigModel|null $expected * * @dataProvider processProvider */ public function testProcess($field, $isExist, $expected) { $this->databaseHelper->expects(static::any())->method('findOneBy')->willReturn($isExist ? $field : null); static::assertEquals($expected, $this->strategy->process($field)); }
/** * @covers ::process * * @expectedException \InvalidArgumentException * * @dataProvider providerTestProcess */ public function testProcessWithInvalidElementConfiguration(array $element) { $form_state = $this->getMock(FormStateInterface::class); $form = []; $this->sut->process($element, $form_state, $form); }