/** * Tests the encode() method. * * @see \Jyxo\Mail\Encoding::encode() */ public function testEncode() { $data = file_get_contents($this->filePath . '/email.html'); foreach ($this->encodings as $encoding) { $encoded = Encoding::encode($data, $encoding, 75, "\n"); $this->assertStringEqualsFile($this->filePath . '/encoding-' . $encoding . '.txt', $encoded); } try { Encoding::encode('data', 'dummy-encoding', 75, "\n"); $this->fail(sprintf('Expected exception %s.', \InvalidArgumentException::class)); } catch (\PHPUnit_Framework_AssertionFailedError $e) { throw $e; } catch (\Exception $e) { // Correctly thrown exception $this->assertInstanceOf(\InvalidArgumentException::class, $e); } }
/** * Encodes a string using the given encoding. * * @param string $string Input string * @param string $encoding Encoding * @param integer $lineLength Line length * @return string */ private function encodeString(string $string, string $encoding, int $lineLength = self::LINE_LENGTH) : string { return Encoding::encode($string, $encoding, $lineLength, self::LINE_END); }