Skip to content

Commit

Permalink
tests for TokenizedAttributedString->setTokenDictionaryAttribute() an…
Browse files Browse the repository at this point in the history
…d ->lowercaseTokens()
  • Loading branch information
apemsel committed Mar 1, 2016
1 parent 8d3d73a commit 590981a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/unit/TokenizedAttributedStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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());
}
}

0 comments on commit 590981a

Please sign in to comment.