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:----LkhOE/adIAo1dQRlICKgCgFfdoU5kswx03BeUgJS4rdGs206nSQ/t3B43/Pwd3q2kOs56eVzK+14zbDCAPTPMZvgG+wcykIc4rcudf+pReUvh76JJkU4Dx9Y/QPhRs5c6wO1OkYJj/H6CZqBR5VZANf37jrvwEX4MIAR9tCLcyQXN2n+mTbdqq2DrYgjEDeiiswWWhFeyFIbOC3+OhV601mU4LefBQbz2HGyB7UMoCO7AZVE5gytpq6HWece3kIfpX4WQDc0VveK+Z9awyGz34VIdUMlx0Ifacb5M7dLyOEFaiA/kEVL8ypEV90hANAtWhqbar3el9u9PyQSGssiBF+oC2tp4bhRLvC1qgVUtj9+QtYUQw54Sk0Svz2pEThsB/V0aqF6vdgUtx28OxHX/Bbm7sso66AEFrAWSVyhltBTZgx4o9e8naNY3jWJQ5H5EnZStGyl6Va+US6tPC0w2mZrz63zM1YUL5ExheIKV01+r9koKyCPoZyyRwXC7qUM6oJ6LCUpdQJQz/oowcgYVNZSKGW5KC5e8TxGhP/YycscFISchXKWwNTHBuIsN1ya6cSuNiMq+9e3PSecu3PsXXbJlriRiA6BFmqRZJ4Skp6D3uPLSOAx0YR5hgrZFg0cONCgvvlHTuSWh1w+Qjgwn/QnwyBvnxH5DG8MEmCPSI8=----ATTACHMENT:----NjM4NDYwMDgxNTU5NDE1NCAyMTQxMzk5ODE2MDAxNTk1IDIyNzkwNDUwMzM3MTA2Mzg=