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,56 @@
<?php
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Random;
/*
* 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 NumberViewHelperTest extends AbstractViewHelperTest {
/**
* @test
*/
public function generatesRandomNumberWithoutDecimalsAsDefault() {
$arguments = array('minimum' => 0, 'maximum' => 999999);
$result1 = $this->executeViewHelper($arguments);
$result2 = $this->executeViewHelper($arguments);
$this->assertThat($result1, new \PHPUnit_Framework_Constraint_IsType(\PHPUnit_Framework_Constraint_IsType::TYPE_INT));
$this->assertThat($result2, new \PHPUnit_Framework_Constraint_IsType(\PHPUnit_Framework_Constraint_IsType::TYPE_INT));
$this->assertNotEquals($result1, $result2);
}
/**
* @test
*/
public function generatesRandomNumberWithoutDecimalsGivenArguments() {
$arguments = array('minimum' => 0, 'maximum' => 999999, 'minimumDecimals' => 0, 'maximumDecimals' => 0);
$result1 = $this->executeViewHelper($arguments);
$result2 = $this->executeViewHelper($arguments);
$this->assertThat($result1, new \PHPUnit_Framework_Constraint_IsType(\PHPUnit_Framework_Constraint_IsType::TYPE_INT));
$this->assertThat($result2, new \PHPUnit_Framework_Constraint_IsType(\PHPUnit_Framework_Constraint_IsType::TYPE_INT));
$this->assertNotEquals($result1, $result2);
}
/**
* @test
*/
public function generatesRandomNumberWithDecimalsGivenArguments() {
$arguments = array('minimum' => 0, 'maximum' => 999999, 'minimumDecimals' => 2, 'maximumDecimals' => 8);
$result1 = $this->executeViewHelper($arguments);
$result2 = $this->executeViewHelper($arguments);
$this->assertThat($result1, new \PHPUnit_Framework_Constraint_IsType(\PHPUnit_Framework_Constraint_IsType::TYPE_FLOAT));
$this->assertThat($result2, new \PHPUnit_Framework_Constraint_IsType(\PHPUnit_Framework_Constraint_IsType::TYPE_FLOAT));
$this->assertNotEquals($result1, $result2);
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace FluidTYPO3\Vhs\Tests\Unit\ViewHelpers\Random;
/*
* 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 StringViewHelperTest extends AbstractViewHelperTest {
/**
* @test
*/
public function generatesRandomStringWithDesiredCharactersOnlyAndOfDesiredLength() {
$arguments = array('minimumLength' => 32, 'maximumLength' => 32, 'characters' => 'abcdef');
$result = $this->executeViewHelper($arguments);
$this->assertEquals(32, strlen($result));
$this->assertEquals(0, preg_match('/[^a-f]+/', $result), 'Random string contained unexpected characters');
}
}