ILIAS  release_7 Revision v7.30-3-g800a261c036
StringTransformationTest.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 2020 Luka K. A. Stocker, Extended GPL, see docs/LICENSE */
3 
5 
6 require_once('./libs/composer/vendor/autoload.php');
7 
10 
15 {
16  private $transformation;
17 
18  public function setUp() : void
19  {
20  $this->transformation = new StringTransformation();
21  }
22 
28  public function testStringTransformation($originVal, $expectedVal)
29  {
30  $transformedValue = $this->transformation->transform($originVal);
31  $this->assertIsString($transformedValue);
32  $this->assertEquals($expectedVal, $transformedValue);
33  }
34 
35  public function StringTestDataProvider()
36  {
37  $obj = new class extends \StdClass {
38  public function __toString()
39  {
40  return 'an object';
41  }
42  };
43  return [
44  'string_val' => ['hello', 'hello'],
45  'int_val' => [300, '300'],
46  'neg_int_val' => [-300, '-300'],
47  'zero_int_val' => [0, '0'],
48  'pos_bool' => [true, 'true'],
49  'neg_bool' => [false, 'false'],
50  'float_val' => [20.5, '20.5'],
51  'object_val' => [$obj, 'an object']
52  ];
53  }
54 }
testStringTransformation($originVal, $expectedVal)
StringTestDataProvider