ILIAS  trunk Revision v11.0_alpha-2645-g16283d3b3f8
ILIAS\LegalDocuments\test\ConsumerToolbox\MarshalTest Class Reference
+ Inheritance diagram for ILIAS\LegalDocuments\test\ConsumerToolbox\MarshalTest:
+ Collaboration diagram for ILIAS\LegalDocuments\test\ConsumerToolbox\MarshalTest:

Public Member Functions

 testConstruct ()
 
 testDateTime ()
 
 testBoolean ()
 
 testNullable ()
 
 testString ()
 

Detailed Description

Definition at line 35 of file MarshalTest.php.

Member Function Documentation

◆ testBoolean()

ILIAS\LegalDocuments\test\ConsumerToolbox\MarshalTest::testBoolean ( )

Definition at line 61 of file MarshalTest.php.

References ILIAS\UI\examples\Layout\Page\Standard\$refinery.

61  : void
62  {
63  $from = $this->mock(ByTrying::class);
64  $custom = $this->mock(Transformation::class);
65  $bool = $this->mock(Transformation::class);
66  $to = $this->mock(Transformation::class);
67 
68  $refinery = $this->mockTree(Refinery::class, [
69  'custom' => ['transformation' => $custom],
70  'kindlyTo' => ['string' => $to, 'bool' => $bool],
71  ]);
72  $refinery->expects(self::once())->method('byTrying')->with([$bool, $custom])->willReturn($from);
73 
74  $convert = (new Marshal($refinery))->boolean();
75  $this->assertSame($from, $convert->fromString());
76  $this->assertSame($to, $convert->toString());
77  }

◆ testConstruct()

ILIAS\LegalDocuments\test\ConsumerToolbox\MarshalTest::testConstruct ( )

Definition at line 39 of file MarshalTest.php.

39  : void
40  {
41  $this->assertInstanceOf(Marshal::class, new Marshal($this->mock(Refinery::class)));
42  }

◆ testDateTime()

ILIAS\LegalDocuments\test\ConsumerToolbox\MarshalTest::testDateTime ( )

Definition at line 44 of file MarshalTest.php.

References ILIAS\UI\examples\Layout\Page\Standard\$refinery.

44  : void
45  {
46  $from = $this->mock(Transformation::class);
47  $custom = $this->mock(Transformation::class);
48  $date = $this->mock(Transformation::class);
49 
50  $refinery = $this->mockTree(Refinery::class, [
51  'in' => $this->mockMethod(In::class, 'series', [[$custom, $date]], $from),
52  'custom' => ['transformation' => $custom],
53  'to' => ['dateTime' => $date],
54  ]);
55 
56  $convert = (new Marshal($refinery))->dateTime();
57  $this->assertSame($from, $convert->fromString());
58  $this->assertSame($custom, $convert->toString());
59  }

◆ testNullable()

ILIAS\LegalDocuments\test\ConsumerToolbox\MarshalTest::testNullable ( )

Definition at line 79 of file MarshalTest.php.

References ILIAS\UI\examples\Layout\Page\Standard\$refinery.

79  : void
80  {
81  $decorate = $this->mockTree(Convert::class, [
82  'fromString' => $this->mock(Transformation::class),
83  'toString' => $this->mock(Transformation::class),
84  ]);
85 
86  $by_trying = $this->mock(ByTrying::class);
87  $nice_null = $this->mock(Transformation::class);
88  $null = $this->mock(Constraint::class);
89  $always = $this->mock(Transformation::class);
90  $series = $this->mock(Transformation::class);
91 
92  $refinery = $this->mockTree(Refinery::class, [
93  'kindlyTo' => ['null' => $nice_null],
94  'in' => $this->mockMethod(In::class, 'series', [[$null, $always]], $series),
95  'always' => $always,
96  'null' => $null,
97  ]);
98  $consecutive = [[$nice_null, $decorate->fromString()], [$series, $decorate->toString()]];
99  $refinery->expects(self::exactly(2))->method('byTrying')->with(
100  $this->callback(function ($value) use (&$consecutive) {
101  $this->assertSame(array_shift($consecutive), $value);
102  return true;
103  })
104  )->willReturn($by_trying);
105 
106  $convert = (new Marshal($refinery))->nullable($decorate);
107  $this->assertSame($by_trying, $convert->fromString());
108  $this->assertSame($by_trying, $convert->toString());
109  }

◆ testString()

ILIAS\LegalDocuments\test\ConsumerToolbox\MarshalTest::testString ( )

Definition at line 111 of file MarshalTest.php.

References $id.

111  : void
112  {
113  $id = $this->mock(Transformation::class);
114 
115  $convert = (new Marshal($this->mockTree(Refinery::class, ['identity' => $id])))->string();
116  $this->assertSame($id, $convert->fromString());
117  $this->assertSame($id, $convert->toString());
118  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

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