Initial commit
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Condition\Context;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
|
||||
|
||||
/**
|
||||
* @protection off
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
*/
|
||||
class IsBackendViewHelperTest extends AbstractViewHelperTest {
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function testIsBackendContext() {
|
||||
$instance = $this->createInstance();
|
||||
$result = $this->callInaccessibleMethod($instance, 'evaluateCondition');
|
||||
$this->assertThat($result, new \PHPUnit_Framework_Constraint_IsType(\PHPUnit_Framework_Constraint_IsType::TYPE_BOOL));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function testRender() {
|
||||
$arguments = array('then' => TRUE, 'else' => FALSE);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals(TRUE, $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Condition\Context;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
|
||||
|
||||
/**
|
||||
* @protection off
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
*/
|
||||
class IsCliViewHelperTest extends AbstractViewHelperTest {
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function testIsCliContext() {
|
||||
$instance = $this->createInstance();
|
||||
$result = $this->callInaccessibleMethod($instance, 'evaluateCondition');
|
||||
$this->assertThat($result, new \PHPUnit_Framework_Constraint_IsType(\PHPUnit_Framework_Constraint_IsType::TYPE_BOOL));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function testRender() {
|
||||
$arguments = array('then' => TRUE, 'else' => FALSE);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals(FALSE, $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Condition\Context;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
|
||||
|
||||
/**
|
||||
* @protection off
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
*/
|
||||
class IsDevelopmentViewHelperTest extends AbstractViewHelperTest {
|
||||
|
||||
public function testRender() {
|
||||
$arguments = array('then' => 'then', 'else' => 'else');
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('else', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Condition\Context;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
|
||||
|
||||
/**
|
||||
* @protection off
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
*/
|
||||
class IsFrontendViewHelperTest extends AbstractViewHelperTest {
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function testIsFrontendContext() {
|
||||
$instance = $this->createInstance();
|
||||
$result = $this->callInaccessibleMethod($instance, 'evaluateCondition');
|
||||
$this->assertThat($result, new \PHPUnit_Framework_Constraint_IsType(\PHPUnit_Framework_Constraint_IsType::TYPE_BOOL));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function testRender() {
|
||||
$arguments = array('then' => TRUE, 'else' => FALSE);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals(FALSE, $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Condition\Context;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
|
||||
|
||||
/**
|
||||
* @protection off
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
*/
|
||||
class IsProductionViewHelperTest extends AbstractViewHelperTest {
|
||||
|
||||
public function testRender() {
|
||||
$arguments = array('then' => 'then', 'else' => 'else');
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('else', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Condition\Context;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
|
||||
|
||||
/**
|
||||
* @protection off
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
*/
|
||||
class IsTestingViewHelperTest extends AbstractViewHelperTest {
|
||||
|
||||
public function testRender() {
|
||||
$arguments = array('then' => 'then', 'else' => 'else');
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('then', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Condition\Form;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use FluidTYPO3\Vhs\Tests\Fixtures\Domain\Model\Bar;
|
||||
use FluidTYPO3\Vhs\Tests\Fixtures\Domain\Model\Foo;
|
||||
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
|
||||
|
||||
/**
|
||||
* @protection off
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
*/
|
||||
class HasValidatorViewHelperTest extends AbstractViewHelperTest {
|
||||
|
||||
public function testRenderThenWithSingleProperty() {
|
||||
$domainObject = new Foo();
|
||||
$arguments = array(
|
||||
'validatorName' => 'NotEmpty',
|
||||
'property' => 'bar',
|
||||
'object' => $domainObject,
|
||||
'then' => 'then'
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('then', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
public function testRenderElseWithSingleProperty() {
|
||||
$domainObject = new Foo();
|
||||
$arguments = array(
|
||||
'validatorName' => 'NotEmpty',
|
||||
'property' => 'foo',
|
||||
'object' => $domainObject,
|
||||
'else' => 'else'
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('else', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
public function testRenderThenWithNestedSingleProperty() {
|
||||
$domainObject = new Bar();
|
||||
$arguments = array(
|
||||
'validatorName' => 'NotEmpty',
|
||||
'property' => 'foo.bar',
|
||||
'object' => $domainObject,
|
||||
'then' => 'then'
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('then', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
public function testRenderElseWithNestedSingleProperty() {
|
||||
$domainObject = new Bar();
|
||||
$arguments = array(
|
||||
'validatorName' => 'NotEmpty',
|
||||
'property' => 'foo.foo',
|
||||
'object' => $domainObject,
|
||||
'else' => 'else'
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('else', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
public function testRenderThenWithNestedMultiProperty() {
|
||||
$domainObject = new Bar();
|
||||
$arguments = array(
|
||||
'validatorName' => 'NotEmpty',
|
||||
'property' => 'bars.bar.foo.bar',
|
||||
'object' => $domainObject,
|
||||
'then' => 'then'
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('then', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
public function testRenderElseWithNestedMultiProperty() {
|
||||
$domainObject = new Bar();
|
||||
$arguments = array(
|
||||
'validatorName' => 'NotEmpty',
|
||||
'property' => 'bars.foo.foo',
|
||||
'object' => $domainObject,
|
||||
'else' => 'else'
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('else', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Condition\Form;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use FluidTYPO3\Vhs\Tests\Fixtures\Domain\Model\Bar;
|
||||
use FluidTYPO3\Vhs\Tests\Fixtures\Domain\Model\Foo;
|
||||
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
|
||||
|
||||
/**
|
||||
* @protection off
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
*/
|
||||
class IsRequiredViewHelperTest extends AbstractViewHelperTest {
|
||||
|
||||
public function testRenderThenWithSingleProperty() {
|
||||
$domainObject = new Foo();
|
||||
$arguments = array(
|
||||
'property' => 'bar',
|
||||
'object' => $domainObject,
|
||||
'then' => 'then'
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('then', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
public function testRenderElseWithSingleProperty() {
|
||||
$domainObject = new Foo();
|
||||
$arguments = array(
|
||||
'property' => 'foo',
|
||||
'object' => $domainObject,
|
||||
'else' => 'else'
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('else', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
public function testRenderThenWithNestedSingleProperty() {
|
||||
$domainObject = new Bar();
|
||||
$arguments = array(
|
||||
'property' => 'foo.bar',
|
||||
'object' => $domainObject,
|
||||
'then' => 'then'
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('then', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
public function testRenderElseWithNestedSingleProperty() {
|
||||
$domainObject = new Bar();
|
||||
$arguments = array(
|
||||
'property' => 'foo.foo',
|
||||
'object' => $domainObject,
|
||||
'else' => 'else'
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('else', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
public function testRenderThenWithNestedMultiProperty() {
|
||||
$domainObject = new Bar();
|
||||
$arguments = array(
|
||||
'property' => 'bars.bar.foo.bar',
|
||||
'object' => $domainObject,
|
||||
'then' => 'then'
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('then', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
public function testRenderElseWithNestedMultiProperty() {
|
||||
$domainObject = new Bar();
|
||||
$arguments = array(
|
||||
'property' => 'bars.foo.foo',
|
||||
'object' => $domainObject,
|
||||
'else' => 'else'
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('else', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Condition\Iterator;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use FluidTYPO3\Vhs\Tests\Fixtures\Domain\Model\Bar;
|
||||
use FluidTYPO3\Vhs\Tests\Fixtures\Domain\Model\Foo;
|
||||
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage;
|
||||
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
|
||||
use TYPO3\CMS\Extbase\Reflection\ObjectAccess;
|
||||
|
||||
/**
|
||||
* @protection off
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
*/
|
||||
class ContainsViewHelperTest extends AbstractViewHelperTest {
|
||||
|
||||
/**
|
||||
* @dataProvider getPositiveTestValues
|
||||
* @param mixed $haystack
|
||||
* @param mixed $needle
|
||||
*/
|
||||
public function testRendersThen($haystack, $needle) {
|
||||
$arguments = array(
|
||||
'haystack' => $haystack,
|
||||
'needle' => $needle,
|
||||
'then' => 'then'
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('then', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getPositiveTestValues() {
|
||||
$bar = new Bar();
|
||||
ObjectAccess::setProperty($bar, 'uid', 1, TRUE);
|
||||
$foo = new Foo();
|
||||
ObjectAccess::setProperty($foo, 'uid', 2, TRUE);
|
||||
$objectStorage = new ObjectStorage();
|
||||
$objectStorage->attach($bar);
|
||||
/** @var LazyObjectStorage $lazyObjectStorage */
|
||||
$lazyObjectStorage = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager')
|
||||
->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\LazyObjectStorage', $bar, 'foo', 0);
|
||||
ObjectAccess::setProperty($lazyObjectStorage, 'isInitialized', TRUE, TRUE);
|
||||
$lazyObjectStorage->attach($foo);
|
||||
return array(
|
||||
array(array('foo'), 'foo'),
|
||||
array('foo,bar', 'foo'),
|
||||
array(array($foo), $foo),
|
||||
array($objectStorage, $bar),
|
||||
array($lazyObjectStorage, $foo)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getNegativeTestValues
|
||||
* @param mixed $haystack
|
||||
* @param mixed $needle
|
||||
*/
|
||||
public function testRendersElse($haystack, $needle) {
|
||||
$arguments = array(
|
||||
'haystack' => $haystack,
|
||||
'needle' => $needle,
|
||||
'else' => 'else'
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('else', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getNegativeTestValues() {
|
||||
$bar = new Bar();
|
||||
ObjectAccess::setProperty($bar, 'uid', 1, TRUE);
|
||||
$foo = new Foo();
|
||||
ObjectAccess::setProperty($foo, 'uid', 2, TRUE);
|
||||
$objectStorage = new ObjectStorage();
|
||||
$objectStorage->attach($bar);
|
||||
/** @var LazyObjectStorage $lazyObjectStorage */
|
||||
$lazyObjectStorage = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager')
|
||||
->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\LazyObjectStorage', $bar, 'foo', 0);
|
||||
ObjectAccess::setProperty($lazyObjectStorage, 'isInitialized', TRUE, TRUE);
|
||||
$lazyObjectStorage->attach($foo);
|
||||
return array(
|
||||
array(array('foo'), 'bar'),
|
||||
array('foo,baz', 'bar'),
|
||||
array($objectStorage, $foo),
|
||||
array($lazyObjectStorage, $bar)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Condition\Page;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
|
||||
|
||||
/**
|
||||
* @protection off
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
*/
|
||||
class HasSubpagesViewHelperTest extends AbstractViewHelperTest {
|
||||
|
||||
public function testRenderWithAPageThatHasSubpages() {
|
||||
$pageSelect = $this->getMock('FluidTYPO3\Vhs\Service\PageSelectService', array('getMenu'), array(), '', FALSE);
|
||||
$pageSelect->expects($this->any())->method('getMenu')->will($this->returnValue(array('childpage')));
|
||||
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'pageUid' => 1
|
||||
);
|
||||
$instance = $this->buildViewHelperInstance($arguments);
|
||||
$instance::setPageSelectService($pageSelect);
|
||||
$result = $instance->initializeArgumentsAndRender();
|
||||
$this->assertEquals('then', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
public function testRenderWithAPageWithoutSubpages() {
|
||||
$pageSelect = $this->getMock('FluidTYPO3\Vhs\Service\PageSelectService', array('getMenu'), array(), '', FALSE);
|
||||
$pageSelect->expects($this->any())->method('getMenu')->will($this->returnValue(array()));
|
||||
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'pageUid' => 1
|
||||
);
|
||||
$instance = $this->buildViewHelperInstance($arguments);
|
||||
$instance::setPageSelectService($pageSelect);
|
||||
$result = $instance->initializeArgumentsAndRender();
|
||||
$this->assertEquals('else', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Condition\Page;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
|
||||
|
||||
/**
|
||||
* @protection off
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
*/
|
||||
class IsChildPageViewHelperTest extends AbstractViewHelperTest {
|
||||
|
||||
public function testRender() {
|
||||
$GLOBALS['TYPO3_DB'] = $this->getMock('TYPO3\\CMS\\Core\\Database\\DatabaseConnection', array('exec_SELECTquery'), array(), '', FALSE);
|
||||
$GLOBALS['TYPO3_DB']->expects($this->any())->method('exec_SELECTquery')->will($this->returnValue(FALSE));
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'pageUid' => 0
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('else', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Condition\Page;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
|
||||
|
||||
/**
|
||||
* @protection off
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
*/
|
||||
class IsLanguageViewHelperTest extends AbstractViewHelperTest {
|
||||
|
||||
public function testRender() {
|
||||
$GLOBALS['TYPO3_DB'] = $this->getMock('TYPO3\\CMS\\Core\\Database\\DatabaseConnection', array('exec_SELECTgetSingleRow'), array(), '', FALSE);
|
||||
$GLOBALS['TYPO3_DB']->expects($this->any())->method('exec_SELECTgetSingleRow')->will($this->returnValue(FALSE));
|
||||
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'language' => 0
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('else', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Condition\String;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
|
||||
|
||||
/**
|
||||
* @protection off
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
*/
|
||||
class ContainsViewHelperTest extends AbstractViewHelperTest {
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersThenChildIfConditionMatched() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'haystack' => 'foobar',
|
||||
'needle' => 'bar'
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('then', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersElseChildIfConditionNotMatched() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'haystack' => 'foobar',
|
||||
'needle' => 'baz'
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('else', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Condition\String;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
|
||||
|
||||
/**
|
||||
* @protection off
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
*/
|
||||
class IsLowercaseViewHelperTest extends AbstractViewHelperTest {
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersThenChildIfFirstCharacterIsLowercase() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'string' => 'foobar',
|
||||
'fullString' => FALSE
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('then', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersThenChildIfAllCharactersAreLowercase() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'string' => 'foobar',
|
||||
'fullString' => TRUE
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('then', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersElseChildIfFirstCharacterIsNotLowercase() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'string' => 'FooBar',
|
||||
'fullString' => FALSE
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('else', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersElseChildIfAllCharactersAreNotLowercase() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'string' => 'fooBar',
|
||||
'fullString' => TRUE
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('else', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Condition\String;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
|
||||
|
||||
/**
|
||||
* @protection off
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
*/
|
||||
class IsNumericViewHelperTest extends AbstractViewHelperTest {
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersThenChildIfConditionMatched() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'value' => '123'
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('then', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersElseChildIfConditionNotMatched() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'value' => 'z123'
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('else', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Condition\String;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
|
||||
|
||||
/**
|
||||
* @protection off
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
*/
|
||||
class IsUppercaseViewHelperTest extends AbstractViewHelperTest {
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersThenChildIfFirstCharacterIsUppercase() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'string' => 'Foobar',
|
||||
'fullString' => FALSE
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('then', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersThenChildIfAllCharactersAreUppercase() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'string' => 'FOOBAR',
|
||||
'fullString' => TRUE
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('then', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersElseChildIfFirstCharacterIsNotUppercase() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'string' => 'fooBar',
|
||||
'fullString' => FALSE
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('else', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersElseChildIfAllCharactersAreNotUppercase() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'string' => 'FooBar',
|
||||
'fullString' => TRUE
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('else', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Condition\String;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
|
||||
|
||||
/**
|
||||
* @protection off
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
*/
|
||||
class PregViewHelperTest extends AbstractViewHelperTest {
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersThenChildIfConditionMatched() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'string' => 'foo123bar',
|
||||
'pattern' => '/([0-9]+)/i'
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('then', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersElseChildIfConditionNotMatched() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'string' => 'foobar',
|
||||
'pattern' => '/[0-9]+/i'
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('else', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersThenChildIfConditionMatchedAndGlobalEnabled() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'string' => 'foo123bar',
|
||||
'pattern' => '/([0-9]+)/i'
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('then', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersElseChildIfConditionNotMatchedAndGlobalEnabled() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'string' => 'foobar',
|
||||
'pattern' => '/[0-9]+/i',
|
||||
'global' => TRUE
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('else', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersTagContentWhenConditionMatchedAndAsArgumentUsed() {
|
||||
$arguments = array(
|
||||
'string' => 'foo123bar',
|
||||
'pattern' => '/[0-9]+/',
|
||||
'global' => TRUE, 'as' => 'dummy'
|
||||
);
|
||||
$variables = array('dummy' => 'test');
|
||||
$result = $this->executeViewHelperUsingTagContent('Text', 'test', $arguments, $variables);
|
||||
$this->assertEquals('test', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperUsingTagContentStatic('Text', 'test', $arguments, $variables);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Condition\Type;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
|
||||
|
||||
/**
|
||||
* @protection off
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
*/
|
||||
class IsArrayViewHelperTest extends AbstractViewHelperTest {
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersThenChildIfConditionMatched() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'value' => array()
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('then', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersElseChildIfConditionNotMatched() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'value' => new \stdClass()
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('else', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Condition\Type;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
|
||||
|
||||
/**
|
||||
* @protection off
|
||||
* @package Vhs
|
||||
*/
|
||||
class IsBooleanViewHelperTest extends AbstractViewHelperTest {
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersThenChildIfConditionMatched() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'value' => TRUE
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('then', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersElseChildIfConditionNotMatched() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'value' => new \stdClass()
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('else', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Condition\Type;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
|
||||
use TYPO3\CMS\Extbase\Domain\Model\FrontendUser;
|
||||
|
||||
/**
|
||||
* @protection off
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
*/
|
||||
class IsDomainObjectViewHelperTest extends AbstractViewHelperTest {
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersThenChildIfConditionMatched() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'value' => new FrontendUser()
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('then', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersElseChildIfConditionNotMatched() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'value' => new \stdClass()
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('else', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Condition\Type;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
|
||||
|
||||
/**
|
||||
* @protection off
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
*/
|
||||
class IsFloatViewHelperTest extends AbstractViewHelperTest {
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersThenChildIfConditionMatched() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'value' => 0.5
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('then', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersElseChildIfConditionNotMatched() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'value' => 1
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('else', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Condition\Type;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
|
||||
|
||||
/**
|
||||
* @protection off
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
*/
|
||||
class IsInstanceOfViewHelperTest extends AbstractViewHelperTest {
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersThenChildIfConditionMatched() {
|
||||
$dateTime = new \DateTime('now');
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'value' => $dateTime,
|
||||
'class' => 'DateTime'
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('then', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersElseChildIfConditionNotMatched() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'value' => 1,
|
||||
'class' => 'DateTime'
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('else', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Condition\Type;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
|
||||
|
||||
/**
|
||||
* @protection off
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
*/
|
||||
class IsIntegerViewHelperTest extends AbstractViewHelperTest {
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersThenChildIfConditionMatched() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'value' => 1
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('then', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersElseChildIfConditionNotMatched() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'value' => 0.5
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('else', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Condition\Type;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
|
||||
|
||||
/**
|
||||
* @protection off
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
*/
|
||||
class IsObjectViewHelperTest extends AbstractViewHelperTest {
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersThenChildIfConditionMatched() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'value' => new \DateTime('now')
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('then', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersElseChildIfConditionNotMatched() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'value' => 1
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('else', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Condition\Type;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
|
||||
|
||||
/**
|
||||
* @protection off
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
*/
|
||||
class IsQueryResultViewHelperTest extends AbstractViewHelperTest {
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersThenChildIfConditionMatched() {
|
||||
$queryResult = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QueryResult',
|
||||
array('toArray', 'initialize', 'rewind', 'valid', 'count'), array(), '', FALSE);
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'value' => $queryResult
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('then', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersElseChildIfConditionNotMatched() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'value' => 1
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('else', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Condition\Type;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
|
||||
|
||||
/**
|
||||
* @protection off
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
*/
|
||||
class IsStringViewHelperTest extends AbstractViewHelperTest {
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersThenChildIfConditionMatched() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'value' => 'test'
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('then', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersElseChildIfConditionNotMatched() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'value' => 1
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('else', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Condition\Type;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
|
||||
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
|
||||
|
||||
/**
|
||||
* @protection off
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
*/
|
||||
class IsTraversableViewHelperTest extends AbstractViewHelperTest {
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersThenChildIfConditionMatched() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'value' => new ObjectStorage()
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('then', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersElseChildIfConditionNotMatched() {
|
||||
$arguments = array(
|
||||
'then' => 'then',
|
||||
'else' => 'else',
|
||||
'value' => 1
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals('else', $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Condition\Variable;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
|
||||
|
||||
/**
|
||||
* @protection off
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
*/
|
||||
class IsNullViewHelperTest extends AbstractViewHelperTest {
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersThenChildIfVariableIsNull() {
|
||||
$arguments = array(
|
||||
'value' => NULL,
|
||||
'then' => 'then',
|
||||
'else' => 'else'
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals($arguments['then'], $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersElseChildIfVariableIsNotNull() {
|
||||
$arguments = array(
|
||||
'value' => TRUE,
|
||||
'then' => 'then',
|
||||
'else' => 'else'
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments);
|
||||
$this->assertEquals($arguments['else'], $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Condition\Variable;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\AbstractViewHelperTest;
|
||||
|
||||
/**
|
||||
* @protection off
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
*/
|
||||
class IssetViewHelperTest extends AbstractViewHelperTest {
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersThenChildIfVariableIsSet() {
|
||||
$arguments = array(
|
||||
'name' => 'test',
|
||||
'then' => 'then',
|
||||
'else' => 'else'
|
||||
);
|
||||
$variables = array(
|
||||
'test' => TRUE
|
||||
);
|
||||
$result = $this->executeViewHelper($arguments, $variables);
|
||||
$this->assertEquals($arguments['then'], $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments, $variables);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function rendersElseChildIfVariableIsNotSet() {
|
||||
$arguments = array(
|
||||
'name' => 'test',
|
||||
'then' => 'then',
|
||||
'else' => 'else'
|
||||
);
|
||||
$variables = array();
|
||||
$result = $this->executeViewHelper($arguments, $variables);
|
||||
$this->assertEquals($arguments['else'], $result);
|
||||
|
||||
$staticResult = $this->executeViewHelperStatic($arguments, $variables);
|
||||
$this->assertEquals($result, $staticResult, 'The regular viewHelper output doesn\'t match the static output!');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user