ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
StringTransformationTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
22 
25 use stdClass;
26 
28 {
30 
31  protected function setUp(): void
32  {
33  $this->transformation = new StringTransformation();
34  }
35 
41  public function testStringTransformation($originVal, string $expectedVal): void
42  {
43  $transformedValue = $this->transformation->transform($originVal);
44  $this->assertIsString($transformedValue);
45  $this->assertEquals($expectedVal, $transformedValue);
46  }
47 
48  public function StringTestDataProvider(): array
49  {
50  $obj = new class () extends stdClass {
51  public function __toString()
52  {
53  return 'an object';
54  }
55  };
56  return [
57  'string_val' => ['hello', 'hello'],
58  'int_val' => [300, '300'],
59  'neg_int_val' => [-300, '-300'],
60  'zero_int_val' => [0, '0'],
61  'pos_bool' => [true, 'true'],
62  'neg_bool' => [false, 'false'],
63  'float_val' => [20.5, '20.5'],
64  'object_val' => [$obj, 'an object']
65  ];
66  }
67 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
testStringTransformation($originVal, string $expectedVal)
StringTestDataProvider