assertStringContainsString('missing required field, field', $e); } Functions::assertFieldRequired('field', 'hello world'); } public function testAssertXmlRoot() { try { Functions::assertXmlRoot('', ''); } catch (Exception\DeserializationExecption $e) { $this->assertStringContainsString('Not found tag', $e); } try { Functions::assertXmlRoot('', ''); } catch (Exception\DeserializationExecption $e) { $this->assertStringContainsString('Not found tag', $e); } try { Functions::assertXmlRoot('', '123'); } catch (Exception\DeserializationExecption $e) { $this->assertStringContainsString('Not found tag', $e); } Functions::assertXmlRoot('', 'Root'); Functions::assertXmlRoot('', 'Root'); Functions::assertXmlRoot('', 'Root'); $str = ' str1 str2 str-sub 1234 '; try { Functions::assertXmlRoot($str, 'Configuration'); $this->assertTrue(false, 'should not here'); } catch (Exception\DeserializationExecption $e) { $this->assertStringContainsString('Not found tag', $e); } } public function testtryToDatetime() { $elem = new \SimpleXMLElement('2023-12-17T03:30:09Zinvalid value'); $this->assertNull(Functions::tryToDatetime($elem->NoNode)); $this->assertNull(Functions::tryToDatetime($elem->Data1)); $datetimeUtc = new \DateTime(); $datetimeUtc->setTimestamp(1702783809); $this->assertEquals($datetimeUtc, Functions::tryToDatetime($elem->Data)); } public function testtryToBool() { $elem = new \SimpleXMLElement('Truetruefalse'); $this->assertNull(Functions::tryToBool($elem->NoNode)); $this->assertEquals(true, Functions::tryToBool($elem->Data)); $this->assertEquals(true, Functions::tryToBool($elem->Data1)); $this->assertEquals(false, Functions::tryToBool($elem->Data2)); $this->assertNotNull(Functions::tryToBool($elem->DataEmpty)); $this->assertEquals(false, Functions::tryToBool($elem->DataEmpty)); } public function testtryToInt() { $elem = new \SimpleXMLElement('1230invalid value'); $this->assertNull(Functions::tryToInt($elem->NoNode)); $this->assertEquals(123, Functions::tryToInt($elem->Data)); $this->assertEquals(0, Functions::tryToInt($elem->Data1)); $this->assertEquals(0, Functions::tryToInt($elem->Data2)); $this->assertNotNull(Functions::tryToInt($elem->DataEmpty)); $this->assertEquals(0, Functions::tryToInt($elem->DataEmpty)); } public function testtryToString() { $elem = new \SimpleXMLElement('1230'); $this->assertNull(Functions::tryToString($elem->NoNode)); $this->assertEquals('123', Functions::tryToString($elem->Data)); $this->assertEquals('0', Functions::tryToString($elem->Data1)); $this->assertNotNull(Functions::tryToString($elem->Data2)); $this->assertEquals('', Functions::tryToString($elem->Data2)); } }