class DecimalValidatorTest in Form API Validation 8.2
Tests generation of ice cream.
@group fapi_validation @group fapi_validation_validators
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\fapi_validation\Unit\Validators\BaseValidator
- class \Drupal\Tests\fapi_validation\Unit\Validators\DecimalValidatorTest
- class \Drupal\Tests\fapi_validation\Unit\Validators\BaseValidator
Expanded class hierarchy of DecimalValidatorTest
File
- tests/
src/ Unit/ Validators/ DecimalValidatorTest.php, line 14
Namespace
Drupal\Tests\fapi_validation\Unit\ValidatorsView source
class DecimalValidatorTest extends BaseValidator {
protected $plugin;
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
$this->plugin = new DecimalValidator();
}
/**
* Testing decimal and negative decimal without params.
*/
public function testNegativeDecimalNoParams() {
$validator = new Validator('decimal', '123.23');
$this
->assertTrue($this->plugin
->validate($validator, [], $this->decoratedFormState));
$validator = new Validator('decimal', '-123.23');
$this
->assertTrue($this->plugin
->validate($validator, [], $this->decoratedFormState));
}
/**
* Testing integer.
*/
public function testIntegerNoParams() {
$validator = new Validator('decimal', '1525');
$this
->assertTrue($this->plugin
->validate($validator, [], $this->decoratedFormState));
$validator = new Validator('decimal', '-1525');
$this
->assertTrue($this->plugin
->validate($validator, [], $this->decoratedFormState));
}
/**
* Testing negative decimal value.
*/
public function testNegativeDecimal() {
$validator = new Validator('decimal', '-123.23');
$this
->assertTrue($this->plugin
->validate($validator, [], $this->decoratedFormState));
}
/**
* Testing decimal and negative decimal without params.
*/
public function testNegativeDecimalWithParams() {
$validator = new Validator('decimal[3,2]', '123.23');
$this
->assertTrue($this->plugin
->validate($validator, [], $this->decoratedFormState));
$validator = new Validator('decimal[3,2] ', '-123.23');
$this
->assertTrue($this->plugin
->validate($validator, [], $this->decoratedFormState));
$validator = new Validator('decimal[5,2]', '123.23');
$this
->assertFalse($this->plugin
->validate($validator, [], $this->decoratedFormState));
$validator = new Validator('decimal[3,3]', '123.23');
$this
->assertFalse($this->plugin
->validate($validator, [], $this->decoratedFormState));
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BaseValidator:: |
protected | property | The decorated form state. | |
DecimalValidatorTest:: |
protected | property | ||
DecimalValidatorTest:: |
public | function |
Overrides BaseValidator:: |
|
DecimalValidatorTest:: |
public | function | Testing integer. | |
DecimalValidatorTest:: |
public | function | Testing negative decimal value. | |
DecimalValidatorTest:: |
public | function | Testing decimal and negative decimal without params. | |
DecimalValidatorTest:: |
public | function | Testing decimal and negative decimal without params. | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. |