Initial commit
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user