From 590981a20d53c3fa455134782a24ade809986778 Mon Sep 17 00:00:00 2001 From: Adrian Pemsel Date: Tue, 1 Mar 2016 17:19:56 +0100 Subject: [PATCH] tests for TokenizedAttributedString->setTokenDictionaryAttribute() and ->lowercaseTokens() --- test/unit/TokenizedAttributedStringTest.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/unit/TokenizedAttributedStringTest.php b/test/unit/TokenizedAttributedStringTest.php index 9fa1e49..a7fa891 100644 --- a/test/unit/TokenizedAttributedStringTest.php +++ b/test/unit/TokenizedAttributedStringTest.php @@ -49,6 +49,14 @@ public function testSetTokenRangeAttribute() { $this->assertEquals(true, $as->is("bold", 10)); } + public function testSetTokenDictionaryAttribute() { + $as = new TokenizedAttributedString("foo bar baz"); + $as->setTokenDictionaryAttribute(["baz", "bar"], "bold"); + $this->assertEquals(true, $as->is("bold", 4)); + $this->assertEquals(false, $as->is("bold", 3)); + $this->assertEquals(true, $as->is("bold", 10)); + } + public function testAttributesAtToken() { $as = new TokenizedAttributedString("foo bar baz"); $as->setTokenAttribute(1, "bold"); @@ -57,4 +65,10 @@ public function testAttributesAtToken() { $this->assertEquals(["bold", "underlined"], $as->attributesAtToken(1)); $this->assertEquals([], $as->attributesAtToken(0)); } + + public function testLowercaseTokens() { + $as = new TokenizedAttributedString("FOO bar bAz"); + $as->lowercaseTokens(); + $this->assertEquals(["foo", "bar", "baz"], $as->getTokens()); + } }