From 020281d932c566476222e6c825ada3affff239a6 Mon Sep 17 00:00:00 2001
From: Andy Staudacher
world
", + $safe_string->unescaped()); + } + + public function toString_escapes_for_html_test() { + $safe_string = new SafeString("helloworld
"); + $this->assert_equal("hello <p>world</p>", + $safe_string); + } + + public function toString_for_safe_string_test() { + $safe_string = new SafeString("helloworld
"); + $safe_string->mark_html_safe(); + $this->assert_equal("helloworld
", + $safe_string); + } + + public function for_html_test() { + $safe_string = new SafeString("helloworld
"); + $this->assert_equal("hello <p>world</p>", + $safe_string->for_html()); + } + + public function safestring_of_safestring_test() { + $safe_string = new SafeString("helloworld
"); + $safe_string_2 = new SafeString($safe_string); + $this->assert_true($safe_string_2 instanceof SafeString); + $raw_string = $safe_string_2->unescaped(); + $this->assert_false(is_object($raw_string)); + $this->assert_equal("helloworld
", $raw_string); + $this->assert_equal("hello <p>world</p>", $safe_string_2); + } + + public function for_js_test() { + $safe_string = new SafeString('"Foo\'s bar"'); + $js_string = $safe_string->for_js(); + $this->assert_equal('\\"Foo<\\/em>\\\'s bar\\"', + $js_string); + } + + public function string_safestring_equality_test() { + $safe_string = new SafeString("helloworld
"); + $this->assert_equal("helloworld
", + $safe_string->unescaped()); + $escaped_string = "hello <p>world</p>"; + $this->assert_equal($escaped_string, $safe_string); + + $this->assert_true($escaped_string == $safe_string); + $this->assert_false($escaped_string === $safe_string); + $this->assert_false("meow" == $safe_string); + } + + public function of_test() { + $safe_string = SafeString::of("helloworld
"); + $this->assert_equal("helloworld
", $safe_string->unescaped()); + } + + public function of_safe_html_test() { + $safe_string = SafeString::of("helloworld
")->mark_html_safe(); + $this->assert_equal("helloworld
", $safe_string->for_html()); + } + + public function of_fluid_api_test() { + $escaped_string = SafeString::of("Foo's bar")->for_js(); + $this->assert_equal("Foo\\'s bar", $escaped_string); + } + + public function safestring_of_safestring_preserves_safe_status_test() { + $safe_string = SafeString::of("hello'sworld
")->mark_html_safe(); + $safe_string_2 = new SafeString($safe_string); + $this->assert_equal("hello'sworld
", $safe_string_2); + $this->assert_equal("hello\\'sworld<\\/p>", $safe_string_2->for_js()); + } + + public function safestring_of_safestring_preserves_html_safe_status_test() { + $safe_string = SafeString::of("hello's
world
") + ->mark_html_safe(); + $safe_string_2 = new SafeString($safe_string); + $this->assert_equal("hello'sworld
", $safe_string_2); + $this->assert_equal("hello\\'sworld<\\/p>", $safe_string_2->for_js()); + } + + public function safestring_of_safestring_safe_status_override_test() { + $safe_string = new SafeString("hello
world
"); + $safe_string_2 = SafeString::of($safe_string)->mark_html_safe(); + $this->assert_equal("helloworld
", $safe_string_2); + } +} -- cgit v1.2.3