/** * @dataProvider trim_message_data */ public function test_trim_message($message, $bbcode_uid, $length, $expected, $trimmed, $incomplete) { if ($incomplete) { $this->markTestIncomplete($incomplete); } $TrimMessage = new \Nickvergessen\TrimMessage\TrimMessage($message, $bbcode_uid, $length, ' [...]', 0); $this->assertEquals($expected, $TrimMessage->message()); $this->assertEquals($trimmed, $TrimMessage->is_trimmed()); }
/** * Trim message to specified length * * @param string $message Post text * @param string $bbcode_uid BBCode UID * @param int $length Length the text should have after shortening * * @return string trimmed messsage */ private function trim_message($message, $bbcode_uid, $length) { if (class_exists('\\Nickvergessen\\TrimMessage\\TrimMessage')) { $trim = new \Nickvergessen\TrimMessage\TrimMessage($message, $bbcode_uid, $length); $message = $trim->message(); $message = str_replace(' [...]', $this->user->lang('SFPO_APPEND_MESSAGE'), $message); unset($trim); } return $message; }
/** * Shorten message to specified length * * @param string $message Post text * @param string $bbcode_uid BBCode UID * @param int $length Length the text should have after shortening * * @return string Shortened messsage */ public function shorten_message($message, $bbcode_uid, $length) { if (class_exists('\\Nickvergessen\\TrimMessage\\TrimMessage')) { $trim = new \Nickvergessen\TrimMessage\TrimMessage($message, $bbcode_uid, $length); $message = $trim->message(); unset($trim); } return $message; }