Initial commit

This commit is contained in:
2018-04-02 08:07:38 +02:00
commit 7330c1ed3e
2054 changed files with 405203 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
<?php
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Math;
/*
* 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
*/
abstract class AbstractMathViewHelperTest extends AbstractViewHelperTest {
/**
* @param mixed $a
* @param mixed $expected
* @return void
*/
protected function executeSingleArgumentTest($a, $expected) {
$result = $this->executeViewHelper(array('a' => $a));
$this->assertEquals($expected, $result);
}
/**
* @param mixed $a
* @param mixed $b
* @param mixed $expected
* @return void
*/
protected function executeDualArgumentTest($a, $b, $expected) {
$result = $this->executeViewHelper(array('a' => $a, 'b' => $b));
$this->assertEquals($expected, $result);
}
}

View File

@@ -0,0 +1,61 @@
<?php
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Math;
/*
* 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.
*/
/**
* @protection off
* @author Claus Due <claus@namelesscoder.net>
* @package Vhs
*/
class AverageViewHelperTest extends AbstractMathViewHelperTest {
/**
* @test
*/
public function testSingleArgument() {
$this->executeSingleArgumentTest(1, 1);
}
/**
* @test
*/
public function testSingleArgumentIteratorFirst() {
$this->executeSingleArgumentTest(array(1, 3), 2);
}
/**
* @test
*/
public function testDualArgument() {
$this->executeDualArgumentTest(1, 3, 2);
}
/**
* @test
*/
public function testDualArgumentWithIteratorFirst() {
$this->executeDualArgumentTest(array(1, 5), 3, array(2, 4));
}
/**
* @test
*/
public function testDualArgumentBothIterators() {
$this->executeDualArgumentTest(array(1, 5), array(3, 3), array(2, 4));
}
/**
* @test
*/
public function executeMissingArgumentTest() {
$this->setExpectedException('TYPO3\CMS\Fluid\Core\ViewHelper\Exception', 'Required argument "b" was not supplied');
$this->executeViewHelper(array());
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Math;
/*
* 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.
*/
/**
* @protection off
* @author Claus Due <claus@namelesscoder.net>
* @package Vhs
*/
class CeilViewHelperTest extends AbstractMathViewHelperTest {
/**
* @test
*/
public function testSingleArgument() {
$this->executeSingleArgumentTest(0.5, 1);
}
/**
* @test
*/
public function testSingleArgumentIteratorFirst() {
$this->executeSingleArgumentTest(array(0.5, 0.8), array(1, 1));
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Math;
/*
* 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.
*/
/**
* @protection off
* @author Claus Due <claus@namelesscoder.net>
* @package Vhs
*/
class CubeViewHelperTest extends AbstractMathViewHelperTest {
/**
* @test
*/
public function testSingleArgument() {
$this->executeSingleArgumentTest(2, 8);
}
/**
* @test
*/
public function testSingleArgumentIteratorFirst() {
$this->executeSingleArgumentTest(array(2, 3), array(8, 27));
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Math;
/*
* 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.
*/
/**
* @protection off
* @author Claus Due <claus@namelesscoder.net>
* @package Vhs
*/
class CubicRootViewHelperTest extends AbstractMathViewHelperTest {
/**
* @test
*/
public function testSingleArgument() {
$this->executeSingleArgumentTest(8, 2);
}
/**
* @test
*/
public function testSingleArgumentIteratorFirst() {
$this->executeSingleArgumentTest(array(8, 27), array(2, 3));
}
}

View File

@@ -0,0 +1,56 @@
<?php
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Math;
/*
* 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.
*/
/**
* @protection off
* @author Claus Due <claus@namelesscoder.net>
* @package Vhs
*/
class DivisionViewHelperTest extends AbstractMathViewHelperTest {
/**
* @test
*/
public function testDualArgument() {
$this->executeDualArgumentTest(4, 2, 2);
}
/**
* @test
*/
public function testDualArgumentIteratorFirst() {
$this->executeDualArgumentTest(array(4, 8), 2, array(2, 4));
}
/**
* @test
*/
public function executeMissingArgumentTest() {
$this->setExpectedException('TYPO3\CMS\Fluid\Core\ViewHelper\Exception', 'Required argument "b" was not supplied');
$this->executeViewHelper(array());
}
/**
* @test
*/
public function executeInvalidFirstArgumentTypeTest() {
$this->setExpectedException('TYPO3\CMS\Fluid\Core\ViewHelper\Exception', 'Required argument "a" was not supplied');
$this->executeViewHelper(array('b' => 1, 'fail' => TRUE));
}
/**
* @test
*/
public function executeInvalidSecondArgumentTypeTest() {
$this->setExpectedException('TYPO3\CMS\Fluid\Core\ViewHelper\Exception', 'Math operation attempted using an iterator $b against a numeric value $a. Either both $a and $b, or only $a, must be array/Iterator');
$this->executeViewHelper(array('a' => 1, 'b' => array(1), 'fail' => TRUE));
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Math;
/*
* 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.
*/
/**
* @protection off
* @author Claus Due <claus@namelesscoder.net>
* @package Vhs
*/
class FloorViewHelperTest extends AbstractMathViewHelperTest {
/**
* @test
*/
public function testSingleArgument() {
$this->executeSingleArgumentTest(1.5, 1);
}
/**
* @test
*/
public function testSingleArgumentIteratorFirst() {
$this->executeSingleArgumentTest(array(1.5, 2.5), array(1, 2));
}
}

View File

@@ -0,0 +1,55 @@
<?php
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Math;
/*
* 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.
*/
/**
* @protection off
* @author Claus Due <claus@namelesscoder.net>
* @package Vhs
*/
class MaximumViewHelperTest extends AbstractMathViewHelperTest {
/**
* @test
*/
public function testSingleArgument() {
$this->executeSingleArgumentTest(array(1, 3), 3);
}
/**
* @test
*/
public function testDualArgument() {
$this->executeDualArgumentTest(4, 2, 4);
}
/**
* @test
*/
public function testDualArgumentBothIterators() {
$this->executeDualArgumentTest(array(4, 8), array(8, 8), array(8, 8));
}
/**
* @test
*/
public function executeMissingArgumentTest() {
$this->setExpectedException('TYPO3\CMS\Fluid\Core\ViewHelper\Exception', 'Required argument "b" was not supplied');
$result = $this->executeViewHelper(array());
}
/**
* @test
*/
public function executeInvalidArgumentTypeTest() {
$this->setExpectedException('TYPO3\CMS\Fluid\Core\ViewHelper\Exception', 'Required argument "a" was not supplied');
$this->executeViewHelper(array('b' => 1, 'fail' => TRUE));
}
}

View File

@@ -0,0 +1,39 @@
<?php
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Math;
/*
* 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.
*/
/**
* @protection off
* @author Claus Due <claus@namelesscoder.net>
* @package Vhs
*/
class MedianViewHelperTest extends AbstractMathViewHelperTest {
/**
* @test
*/
public function testSingleArgumentNotIteratorPassesThrough() {
$this->executeSingleArgumentTest(1, 1);
}
/**
* @test
*/
public function testSingleArgumentThreeMembers() {
$this->executeSingleArgumentTest(array(1, 2, 3), 2);
}
/**
* @test
*/
public function testSingleArgumentFourMembers() {
$this->executeSingleArgumentTest(array(1, 2, 3, 4), 2.5);
}
}

View File

@@ -0,0 +1,55 @@
<?php
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Math;
/*
* 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.
*/
/**
* @protection off
* @author Claus Due <claus@namelesscoder.net>
* @package Vhs
*/
class MinimumViewHelperTest extends AbstractMathViewHelperTest {
/**
* @test
*/
public function testSingleArgument() {
$this->executeSingleArgumentTest(array(1, 3), 1);
}
/**
* @test
*/
public function testDualArgument() {
$this->executeDualArgumentTest(4, 2, 2);
}
/**
* @test
*/
public function testDualArgumentBothIterators() {
$this->executeDualArgumentTest(array(4, 8), array(8, 8), array(4, 8));
}
/**
* @test
*/
public function executeMissingArgumentTest() {
$this->setExpectedException('TYPO3\CMS\Fluid\Core\ViewHelper\Exception', 'Required argument "b" was not supplied');
$this->executeViewHelper(array());
}
/**
* @test
*/
public function executeInvalidArgumentTypeTest() {
$this->setExpectedException('TYPO3\CMS\Fluid\Core\ViewHelper\Exception', 'Required argument "a" was not supplied');
$this->executeViewHelper(array('b' => 1, 'fail' => TRUE));
}
}

View File

@@ -0,0 +1,25 @@
<?php
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Math;
/*
* 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.
*/
/**
* @protection off
* @author Claus Due <claus@namelesscoder.net>
* @package Vhs
*/
class ModuloViewHelperTest extends AbstractMathViewHelperTest {
/**
* @test
*/
public function testDualArguments() {
$this->executeDualArgumentTest(3, 2, 1);
}
}

View File

@@ -0,0 +1,25 @@
<?php
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Math;
/*
* 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.
*/
/**
* @protection off
* @author Claus Due <claus@namelesscoder.net>
* @package Vhs
*/
class PowerViewHelperTest extends AbstractMathViewHelperTest {
/**
* @test
*/
public function testDualArguments() {
$this->executeDualArgumentTest(8, 2, 64);
}
}

View File

@@ -0,0 +1,48 @@
<?php
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Math;
/*
* 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.
*/
/**
* @protection off
* @author Claus Due <claus@namelesscoder.net>
* @package Vhs
*/
class ProductViewHelperTest extends AbstractMathViewHelperTest {
/**
* @test
*/
public function testSingleArgumentIterator() {
$this->executeSingleArgumentTest(array(2, 8), 16);
}
/**
* @test
*/
public function testDualArguments() {
$this->executeDualArgumentTest(8, 2, 16);
}
/**
* @test
*/
public function executeMissingArgumentTest() {
$this->setExpectedException('TYPO3\CMS\Fluid\Core\ViewHelper\Exception', 'Required argument "b" was not supplied');
$this->executeViewHelper(array());
}
/**
* @test
*/
public function executeInvalidArgumentTypeTest() {
$this->setExpectedException('TYPO3\CMS\Fluid\Core\ViewHelper\Exception', 'Required argument "a" was not supplied');
$this->executeViewHelper(array('b' => 1, 'fail' => TRUE));
}
}

View File

@@ -0,0 +1,39 @@
<?php
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Math;
/*
* 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.
*/
/**
* @protection off
* @author Claus Due <claus@namelesscoder.net>
* @package Vhs
*/
class RangeViewHelperTest extends AbstractMathViewHelperTest {
/**
* @test
*/
public function testSingleArgumentNotIteratorPassesThrough() {
$this->executeSingleArgumentTest(1, 1);
}
/**
* @test
*/
public function testSingleArgumentIteratorSingleValue() {
$this->executeSingleArgumentTest(array(2), array(2, 2));
}
/**
* @test
*/
public function testSingleArgumentIteratorMultipleValues() {
$this->executeSingleArgumentTest(array(2, 4, 6, 3, 8), array(2, 8));
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Math;
/*
* 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.
*/
/**
* @protection off
* @author Claus Due <claus@namelesscoder.net>
* @package Vhs
*/
class RoundViewHelperTest extends AbstractMathViewHelperTest {
/**
* @test
*/
public function testSingleArgument() {
$this->executeSingleArgumentTest(0.5, 1);
}
/**
* @test
*/
public function testSingleArgumentIteratorFirst() {
$this->executeSingleArgumentTest(array(0.5, 2.3), array(1, 2));
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Math;
/*
* 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.
*/
/**
* @protection off
* @author Claus Due <claus@namelesscoder.net>
* @package Vhs
*/
class SquareRootViewHelperTest extends AbstractMathViewHelperTest {
/**
* @test
*/
public function testSingleArgument() {
$this->executeSingleArgumentTest(9, 3);
}
/**
* @test
*/
public function testSingleArgumentIteratorFirst() {
$this->executeSingleArgumentTest(array(4, 16), array(2, 4));
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Math;
/*
* 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.
*/
/**
* @protection off
* @author Claus Due <claus@namelesscoder.net>
* @package Vhs
*/
class SquareViewHelperTest extends AbstractMathViewHelperTest {
/**
* @test
*/
public function testSingleArgument() {
$this->executeSingleArgumentTest(3, 9);
}
/**
* @test
*/
public function testSingleArgumentIteratorFirst() {
$this->executeSingleArgumentTest(array(2, 4), array(4, 16));
}
}

View File

@@ -0,0 +1,48 @@
<?php
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Math;
/*
* 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.
*/
/**
* @protection off
* @author Claus Due <claus@namelesscoder.net>
* @package Vhs
*/
class SubtractViewHelperTest extends AbstractMathViewHelperTest {
/**
* @test
*/
public function testSingleArgumentIterator() {
$this->executeSingleArgumentTest(array(8, 2), -10);
}
/**
* @test
*/
public function testDualArguments() {
$this->executeDualArgumentTest(8, 2, 6);
}
/**
* @test
*/
public function executeMissingArgumentTest() {
$this->setExpectedException('TYPO3\CMS\Fluid\Core\ViewHelper\Exception', 'Required argument "b" was not supplied');
$result = $this->executeViewHelper(array());
}
/**
* @test
*/
public function executeInvalidArgumentTypeTest() {
$this->setExpectedException('TYPO3\CMS\Fluid\Core\ViewHelper\Exception', 'Required argument "a" was not supplied');
$result = $this->executeViewHelper(array('b' => 1, 'fail' => TRUE));
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Math;
/*
* 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.
*/
/**
* @protection off
* @author Claus Due <claus@namelesscoder.net>
* @package Vhs
*/
class SumViewHelperTest extends AbstractMathViewHelperTest {
/**
* @test
*/
public function testSingleArgumentIterator() {
$this->executeSingleArgumentTest(array(8, 2), 10);
}
/**
* @test
*/
public function testDualArguments() {
$this->executeDualArgumentTest(8, 2, 10);
}
}