testedClass; $label = $class::NAME; $e = new Encoder($label, $fatal); $input = (array) $input; if ($exp instanceof \Throwable) { $this->expectException(get_class($exp)); $this->expectExceptionCode($exp->getCode()); } else { $exp = strtolower(str_replace(" ", "", $exp)); } $out = $e->encode($input); $this->assertSame($exp, bin2hex($out)); $out = ""; foreach ($input as $c) { $out .= $e->encodeChar($c); } $out .= $e->finalize(); $this->assertSame($exp, bin2hex($out)); } public function testEncodeCodePointsStatically(bool $fatal, $input, $exp) { $class = $this->testedClass; if (!method_exists($class, "encode")) { $this->assertTrue(true); return; } if ($exp instanceof \Throwable) { $this->expectException(get_class($exp)); $this->expectExceptionCode($exp->getCode()); } else { $exp = strtolower(str_replace(" ", "", $exp)); } $out = $class::encode($input, $fatal); $this->assertSame($exp, bin2hex($out)); } }