ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
SplitStringTest Class Reference

TestCase for SplitString transformations. More...

+ Inheritance diagram for SplitStringTest:
+ Collaboration diagram for SplitStringTest:

Public Member Functions

 testTransform ()
 
 testTransformFails ()
 
 testInvoke ()
 
 testInvokeFails ()
 

Data Fields

const STRING_TO_SPLIT = "I am#a test string#for split"
 

Protected Member Functions

 setUp ()
 
 tearDown ()
 

Static Protected Attributes

static $result = array("I am", "a test string", "for split")
 

Detailed Description

TestCase for SplitString transformations.

Author
Stefan Hecken stefa.nosp@m.n.he.nosp@m.cken@.nosp@m.conc.nosp@m.epts-.nosp@m.and-.nosp@m.train.nosp@m.ing..nosp@m.de

Definition at line 12 of file SplitStringTest.php.

Member Function Documentation

◆ setUp()

SplitStringTest::setUp ( )
protected

Definition at line 17 of file SplitStringTest.php.

18  {
19  $this->f = new Transformation\Factory();
20  $this->split_string = $this->f->splitString("#");
21  }

◆ tearDown()

SplitStringTest::tearDown ( )
protected

Definition at line 23 of file SplitStringTest.php.

24  {
25  $this->f = null;
26  $this->split_string = null;
27  }

◆ testInvoke()

SplitStringTest::testInvoke ( )

Definition at line 65 of file SplitStringTest.php.

References $result.

66  {
67  $split_string = $this->f->splitString("#");
68  $arr = $split_string(self::STRING_TO_SPLIT);
69  $this->assertEquals(static::$result, $arr);
70  }
$result

◆ testInvokeFails()

SplitStringTest::testInvokeFails ( )

Definition at line 72 of file SplitStringTest.php.

73  {
74  $split_string = $this->f->splitString("#");
75 
76  $raised = false;
77  try {
78  $arr = [];
79  $next_arr = $split_string($arr);
80  } catch (InvalidArgumentException $e) {
81  $raised = true;
82  }
83  $this->assertTrue($raised);
84 
85  $raised = false;
86  try {
87  $number = 1001;
88  $with = $split_string($number);
89  } catch (InvalidArgumentException $e) {
90  $raised = true;
91  }
92  $this->assertTrue($raised);
93 
94  $raised = false;
95  try {
96  $std_class = new stdClass();
97  $with = $split_string($std_class);
98  } catch (InvalidArgumentException $e) {
99  $raised = true;
100  }
101  $this->assertTrue($raised);
102  }

◆ testTransform()

SplitStringTest::testTransform ( )

Definition at line 29 of file SplitStringTest.php.

References $result.

30  {
31  $arr = $this->split_string->transform(self::STRING_TO_SPLIT);
32  $this->assertEquals(static::$result, $arr);
33  }
$result

◆ testTransformFails()

SplitStringTest::testTransformFails ( )

Definition at line 35 of file SplitStringTest.php.

36  {
37  $raised = false;
38  try {
39  $arr = [];
40  $next_arr = $this->split_string->transform($arr);
41  } catch (InvalidArgumentException $e) {
42  $raised = true;
43  }
44  $this->assertTrue($raised);
45 
46  $raised = false;
47  try {
48  $without = 1001;
49  $with = $this->split_string->transform($without);
50  } catch (InvalidArgumentException $e) {
51  $raised = true;
52  }
53  $this->assertTrue($raised);
54 
55  $raised = false;
56  try {
57  $std_class = new stdClass();
58  $with = $this->split_string->transform($std_class);
59  } catch (InvalidArgumentException $e) {
60  $raised = true;
61  }
62  $this->assertTrue($raised);
63  }

Field Documentation

◆ $result

SplitStringTest::$result = array("I am", "a test string", "for split")
staticprotected

Definition at line 15 of file SplitStringTest.php.

◆ STRING_TO_SPLIT

const SplitStringTest::STRING_TO_SPLIT = "I am#a test string#for split"

Definition at line 14 of file SplitStringTest.php.


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