6use PHPUnit\Framework\TestCase;
27 protected function setUp() : void
29 $language = $this->createMock(\ilLanguage::class);
32 $this->custom = $this->f->custom()->transformation(
34 if (!is_string($value)) {
35 throw new InvalidArgumentException(
"'" . gettype($value) .
"' is not a string.");
50 $result = $this->custom->transform(self::TEST_STRING);
51 $this->assertEquals(self::TEST_STRING,
$result);
58 $lower_string = $this->custom->transform(array());
59 }
catch (InvalidArgumentException
$e) {
60 $this->assertEquals(
"'array' is not a string.",
$e->getMessage());
63 $this->assertTrue($raised);
67 $lower_string = $this->custom->transform(12345);
68 }
catch (InvalidArgumentException
$e) {
69 $this->assertEquals(
"'integer' is not a string.",
$e->getMessage());
72 $this->assertTrue($raised);
76 $std_class =
new stdClass();
77 $lower_string = $this->custom->transform($std_class);
78 }
catch (InvalidArgumentException
$e) {
79 $this->assertEquals(
"'object' is not a string.",
$e->getMessage());
82 $this->assertTrue($raised);
87 $custom = $this->f->custom()->transformation(
89 if (!is_string($value)) {
90 throw new InvalidArgumentException(
"'" . gettype($value) .
"' is not a string.");
97 $this->assertEquals(self::TEST_STRING,
$result);
102 $custom = $this->f->custom()->transformation(
104 if (!is_string($value)) {
105 throw new InvalidArgumentException(
"'" . gettype($value) .
"' is not a string.");
113 $lower_string =
$custom(array());
114 }
catch (InvalidArgumentException
$e) {
115 $this->assertEquals(
"'array' is not a string.",
$e->getMessage());
118 $this->assertTrue($raised);
122 $lower_string =
$custom(12345);
123 }
catch (InvalidArgumentException
$e) {
124 $this->assertEquals(
"'integer' is not a string.",
$e->getMessage());
127 $this->assertTrue($raised);
131 $std_class =
new stdClass();
132 $lower_string =
$custom($std_class);
133 }
catch (InvalidArgumentException
$e) {
134 $this->assertEquals(
"'object' is not a string.",
$e->getMessage());
137 $this->assertTrue($raised);
142 $factory = new \ILIAS\Data\Factory();
143 $valueObject =
$factory->ok(self::TEST_STRING);
145 $resultObject = $this->custom->applyTo($valueObject);
147 $this->assertEquals(self::TEST_STRING, $resultObject->value());
148 $this->assertFalse($resultObject->isError());
An exception for terminatinating execution or to throw for unit testing.
Class ChatMainBarProvider \MainMenu\Provider.