assertEquals( false, Util::isType('hello', 'type') ); } /** * Pass an object which is not a subclass * without strict mode. */ public function testIsNotASubclass() { $obj = new \StdClass; $this->assertEquals( false, Util::subclassOf($obj, 'Class') ); } /** * Pass an object which is not a subclass * with strict mode. */ public function testIsStrictlyNotASubclass() { $this->expectException(Exception::class); $obj = new \StdClass; $this->assertEquals( false, Util::subclassOf($obj, 'Class', true) ); } /** * Pass an malformed XML ISO 8601 duration * without strict mode. */ public function testIsNotAValidDuration() { $this->assertEquals( false, Util::isDuration('MALFORMED') ); } /** * Test between() method. */ public function testBetween() { // tests true $this->assertEquals(true, Util::between(0, 0, 20)); $this->assertEquals(true, Util::between(10.5, 10, null)); $this->assertEquals(true, Util::between(10, null, 10)); $this->assertEquals(true, Util::between(15, 15, null)); $this->assertEquals(true, Util::between(-9.6, -10, 10)); // tests false $this->assertEquals(false, Util::between(0, 10, 20)); $this->assertEquals(false, Util::between(0, 10, null)); $this->assertEquals(false, Util::between(15, null, 10)); $this->assertEquals(false, Util::between(15, null, null)); $this->assertEquals(false, Util::between("Hello", -10, 10)); } /** * Pass an illegal type for validateBcp47 string */ public function testIsNotAValidBcp47Type() { $this->assertEquals( false, Util::validateBcp47([]) ); } /** * Pass an illegal type for validateCollection */ public function testValidateCollectionNotAnObject() { $this->assertEquals( false, Util::validateCollection('MyStringCollection') ); } /** * Pass an illegal type for validateCollectionPage */ public function testValidateCollectionPageInvalidObject() { $this->expectException(Exception::class); Util::validateCollectionPage(new ObjectType()); } /** * Pass a malformed JSON string */ public function testDecodeJsonFailing() { $this->expectException(Exception::class); Util::decodeJson('hello'); } /** * Pass JSON string and get an array */ public function testDecodeJson() { $this->assertEquals( ['name' => 'hello'], Util::decodeJson('{"name":"hello"}') ); } /** * An object must have a property. * In non strict mode, it must return false */ public function testHasPropertiesFailingNonStrictMode() { $item = new \StdClass; $this->assertEquals( false, Util::hasProperties($item, ['type']) ); } /** * Pass a malformed magnet string */ public function testValidateMagnetFailing() { $this->assertEquals( false, Util::validateMagnet("magnet:?xx=false") ); } /** * Pass a valid magnet link */ public function testValidateMagnet() { $this->assertEquals( true, Util::validateMagnet("magnet:?xs=https%3A%2F%2Fexample.com%2Fstatic%2Ftorrents%2F3a1234-azerty.torrent&xt=urn:btih:e12f01fb316895&dn=A+dname%5D&tr=wss%3A%2F%2Fexample.com%3A443%2Ftracker%2Fsocket&tr=https%3A%2F%2Fexample.com%2Ftracker%2Fannounce&ws=https%3A%2F%2Fexample.com%2Fstatic%2Fwebseed%2F3af1234-azerty.mp4") ); } /** * Pass a valid media type */ public function testValidateMediaType() { $this->assertEquals( true, Util::validateMediaType("application/json") ); } /** * Pass a valid multiple media type */ public function testValidateMultiMediaType() { $this->assertEquals( true, Util::validateMediaType("application/x-bittorrent;x-scheme-handler/magnet") ); } } __halt_compiler();----SIGNATURE:----tex8WAHPQtM8KhRvJ3I1UMxq2O78TXr16rRWB21qEZMbTtmdBQJn98rp00XXsjQ995QWnncwcX7SrH0e3WbBS1xaKwrI5iO9wchqyNp/2KZ2hPgnH5tkilhFNks9M3aFM6O4NtNC9mCkCn2i/DY5KqmTlKftUmUBXHdENn0LSoiFnfvlb+ceX0X008CfQOInuMTpeFFv7FLHo8Dk+ENkDUkEC4ylpnonPx8BjMkOr+pSAnt6kSzdUP0heXaRMJAVSMokvZx2ZCIWkAw2ejqC9i8K8J2ti5fhlYpotHDG/gV68uTAEjORwgltLlbbAqSwBxpMbPpohXozz4csWDCYYJ/JwcloNxVaDnXBw2hvrZGX08ITWL39kzj9fPh3P/SYza1JoBGfPIUJ8Nm6z9ajJfytLTSo4E5fHKkrn4AUI/2gn6Ih1H5KbzgnWnrpGmP9w1+Fpun56l3EvssE8fo+V8wzq2RsVMa4s/m8MvoOw9nMbhYcmEV+s9DwkOyGR6OBtD48cSGSgkj8i1LGoo9XRqMra5W4EwAK7NgVQhUAK2AFw10fUaSORzl+61NXAn1+bZ3xcCbyV5vjPcaQx7Dt14Dqfx9SgEJHGXiYN2f06OdBRPU56FKZB3i4AgUGso1mPm6J+1sWkNSHanyj/2G5IH8p5EuNXLobHc9guOU7EyM=----ATTACHMENT:----NDU1NjY1NTYzODA0MjY3IDEwOTcwNjQzNDAxOTk3MzEgNDg4MjU1MzQxODExMzI3MQ==