CastToIntTest.php in Tamper 8
File
tests/src/Unit/Plugin/Tamper/CastToIntTest.php
View source
<?php
namespace Drupal\Tests\tamper\Unit\Plugin\Tamper;
use Drupal\tamper\Plugin\Tamper\CastToInt;
class CastToIntTest extends TamperPluginTestBase {
protected function instantiatePlugin() {
return new CastToInt([], 'cast_to_int', [], $this
->getMockSourceDefinition());
}
public function testStringOneToInt() {
$this
->assertEquals(1, $this->plugin
->tamper('1'));
}
public function testAlphabeticStringToInt() {
$this
->assertEquals(0, $this->plugin
->tamper('asdfsdf'));
}
public function testDecimalStringToInt() {
$this
->assertEquals(1, $this->plugin
->tamper('1.2324'));
}
public function testDecimalToInt() {
$this
->assertEquals(1, $this->plugin
->tamper(1.2324));
}
public function testTrueToInt() {
$this
->assertEquals(1, $this->plugin
->tamper(TRUE));
}
public function testFalseToInt() {
$this
->assertEquals(0, $this->plugin
->tamper(FALSE));
}
public function testStringIntToInt() {
$this
->assertEquals(23456, $this->plugin
->tamper('23456'));
}
}