ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ByTryingTransformTest Class Reference
+ Inheritance diagram for ByTryingTransformTest:
+ Collaboration diagram for ByTryingTransformTest:

Public Member Functions

 testNullOrNumeric ($value, $expected)
 NullOrNumericDataProvider More...
 
 testNullOrNumericOrString ($value, $expected)
 NullOrNumericOrStringDataProvider More...
 
 testStringOrNull ($value, $expected)
 StringOrNullDataProvider More...
 
- Public Member Functions inherited from ILIAS\Tests\Refinery\TestCase
 getLanguage ()
 

Static Public Member Functions

static NullOrNumericDataProvider ()
 
static NullOrNumericOrStringDataProvider ()
 
static StringOrNullDataProvider ()
 

Protected Member Functions

 setUp ()
 

Private Attributes

const ERROR = 'error_expected'
 
Refinery $refinery
 

Detailed Description

Definition at line 28 of file ByTryingTransformTest.php.

Member Function Documentation

◆ NullOrNumericDataProvider()

static ByTryingTransformTest::NullOrNumericDataProvider ( )
static

Definition at line 41 of file ByTryingTransformTest.php.

References null.

41  : array
42  {
43  return [
44  'empty string' => ['', null],
45  'empty string - one space' => [' ', null],
46  'empty string - more spaces' => [' ', null],
47  'null' => [null, null],
48  'string' => ['str', self::ERROR],
49  'int' => [1, 1],
50  'negative int' => [-1, -1],
51  'zero' => [0, 0],
52  'array' => [[], self::ERROR],
53  'bool (false)' => [false, self::ERROR],
54  'bool (true)' => [true, self::ERROR]
55  ];
56  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ NullOrNumericOrStringDataProvider()

static ByTryingTransformTest::NullOrNumericOrStringDataProvider ( )
static

Definition at line 78 of file ByTryingTransformTest.php.

References null.

78  : array
79  {
80  return [
81  'string' => ['str', 'str'],
82  'null' => [null, null],
83  'empty string' => ['', null],
84  'int' => [1, 1],
85  'bool (true)' => [true, self::ERROR],
86  'array' => [[], self::ERROR]
87  ];
88  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ setUp()

ByTryingTransformTest::setUp ( )
protected

Definition at line 34 of file ByTryingTransformTest.php.

References $lang, ILIAS\Tests\Refinery\TestCase\getLanguage(), and ILIAS\Repository\refinery().

34  : void
35  {
36  $df = new DataFactory();
37  $lang = $this->getLanguage();
38  $this->refinery = new Refinery($df, $lang);
39  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$lang
Definition: xapiexit.php:25
+ Here is the call graph for this function:

◆ StringOrNullDataProvider()

static ByTryingTransformTest::StringOrNullDataProvider ( )
static

Definition at line 110 of file ByTryingTransformTest.php.

References null.

110  : array
111  {
112  return [
113  'string' => ['str', 'str'],
114  'null' => [null, null],
115  'empty string' => ['', ''],
116  'int' => [1, self::ERROR],
117  'array' => [[], self::ERROR]
118  ];
119  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ testNullOrNumeric()

ByTryingTransformTest::testNullOrNumeric (   $value,
  $expected 
)

NullOrNumericDataProvider

Parameters
mixed$value
mixed$expected

Definition at line 63 of file ByTryingTransformTest.php.

References ILIAS\Repository\refinery().

63  : void
64  {
65  $transformation = $this->refinery->byTrying([
66  $this->refinery->numeric()->isNumeric(),
67  $this->refinery->kindlyTo()->null()
68  ]);
69 
70  if ($expected === self::ERROR) {
71  $this->expectException(ConstraintViolationException::class);
72  }
73  $transformed = $transformation->transform($value);
74  $this->assertEquals($expected, $transformed);
75  }
+ Here is the call graph for this function:

◆ testNullOrNumericOrString()

ByTryingTransformTest::testNullOrNumericOrString (   $value,
  $expected 
)

NullOrNumericOrStringDataProvider

Parameters
mixed$value
mixed$expected

Definition at line 95 of file ByTryingTransformTest.php.

References ILIAS\Repository\refinery().

95  : void
96  {
97  $transformation = $this->refinery->byTrying([
98  $this->refinery->kindlyTo()->null(),
99  $this->refinery->numeric()->isNumeric(),
100  $this->refinery->to()->string()
101  ]);
102 
103  if ($expected === self::ERROR) {
104  $this->expectException(ConstraintViolationException::class);
105  }
106  $transformed = $transformation->transform($value);
107  $this->assertEquals($expected, $transformed);
108  }
+ Here is the call graph for this function:

◆ testStringOrNull()

ByTryingTransformTest::testStringOrNull (   $value,
  $expected 
)

StringOrNullDataProvider

Parameters
mixed$value
mixed$expected

Definition at line 126 of file ByTryingTransformTest.php.

References ILIAS\Repository\refinery().

126  : void
127  {
128  $transformation = $this->refinery->byTrying([
129  $this->refinery->to()->string(),
130  $this->refinery->kindlyTo()->null()
131  ]);
132 
133  if ($expected === self::ERROR) {
134  $this->expectException(ConstraintViolationException::class);
135  }
136  $transformed = $transformation->transform($value);
137  $this->assertEquals($expected, $transformed);
138  }
+ Here is the call graph for this function:

Field Documentation

◆ $refinery

Refinery ByTryingTransformTest::$refinery
private

Definition at line 32 of file ByTryingTransformTest.php.

◆ ERROR

const ByTryingTransformTest::ERROR = 'error_expected'
private

Definition at line 30 of file ByTryingTransformTest.php.


The documentation for this class was generated from the following file: