Overview

Classes

  • Sentence
  • SentenceTest

Functions

  • Sentence_autoloader
  • Overview
  • Class
  1: <?php
  2: 
  3: /**
  4:  * Generated by PHPUnit_SkeletonGenerator on 2015-02-16 at 20:05:00.
  5:  */
  6: class SentenceTest extends PHPUnit_Framework_TestCase {
  7: 
  8:     /**
  9:      * @var Sentence
 10:      */
 11:     protected $object;
 12: 
 13:     /**
 14:      * Sets up the fixture, for example, opens a network connection.
 15:      * This method is called before a test is executed.
 16:      */
 17:     protected function setUp() {
 18:         $this->object = new Sentence;
 19:     }
 20: 
 21:     /**
 22:      * @covers Sentence::count
 23:      */
 24:     public function testCountEmpty() {
 25:         $this->assertSame(0, $this->object->count(''));
 26:         $this->assertSame(0, $this->object->count(' '));
 27:         $this->assertSame(0, $this->object->count("\n"));
 28:     }
 29: 
 30:     /**
 31:      * @covers Sentence::count
 32:      */
 33:     public function testCountWord() {
 34:         $this->assertSame(1, $this->object->count('Hello'));
 35:         $this->assertSame(1, $this->object->count('Hello.'));
 36:         $this->assertSame(1, $this->object->count('Hello...'));
 37:         $this->assertSame(1, $this->object->count('Hello!'));
 38:         $this->assertSame(1, $this->object->count('Hello?'));
 39:         $this->assertSame(1, $this->object->count('Hello?!'));
 40:     }
 41: 
 42:     /**
 43:      * @covers Sentence::count
 44:      */
 45:     public function testCountTwoWords() {
 46:         $this->assertSame(1, $this->object->count('Hello world'));
 47:         $this->assertSame(1, $this->object->count('Hello world.'));
 48:         $this->assertSame(1, $this->object->count('Hello world...'));
 49:         $this->assertSame(1, $this->object->count('Hello world!'));
 50:         $this->assertSame(1, $this->object->count('Hello world?'));
 51:         $this->assertSame(1, $this->object->count('Hello world?!'));
 52:     }
 53: 
 54:     /**
 55:      * @covers Sentence::count
 56:      */
 57:     public function testCountMultipleWords() {      
 58:         $this->assertSame(2, $this->object->count('Hello world. Are you there'));
 59:         $this->assertSame(2, $this->object->count('Hello world. Are you there?'));
 60:         $this->assertSame(1, $this->object->count('Hello world, Are you there?'));
 61:         $this->assertSame(1, $this->object->count('Hello world: Are you there?'));
 62:         $this->assertSame(1, $this->object->count('Hello world... Are you there?'));
 63:     }
 64: 
 65:     /**
 66:      * @covers Sentence::count
 67:      */
 68:     public function testCountLinebreaks() {
 69:         $this->assertSame(2, $this->object->count("Hello world...\rAre you there?"));
 70:         $this->assertSame(2, $this->object->count("Hello world...\nAre you there?"));
 71:         $this->assertSame(2, $this->object->count("Hello world...\r\nAre you there?"));
 72:         $this->assertSame(2, $this->object->count("Hello world...\r\n\rAre you there?"));
 73:         $this->assertSame(2, $this->object->count("Hello world...\n\r\nAre you there?"));
 74:         $this->assertSame(2, $this->object->count("Hello world...\n\nAre you there?"));
 75:         $this->assertSame(2, $this->object->count("Hello world...\r\rAre you there?"));
 76:     }
 77: 
 78:     /**
 79:      * @covers Sentence::count
 80:      */
 81:     public function testCountAbreviations() {
 82:         $this->assertSame(1, $this->object->count("Hello mr. Smith."));
 83:         $this->assertSame(1, $this->object->count("Hello, OMG Kittens!"));
 84:         $this->assertSame(1, $this->object->count("Hello, abbrev. Kittens!"));
 85:         $this->assertSame(1, $this->object->count("Hello, O.M.G. Kittens!"));
 86:     }
 87:     
 88:     /**
 89:      * @covers Sentence::count
 90:      */
 91:     public function testCountMultiplePunctuation() {
 92:         $this->assertSame(2, $this->object->count("Hello there. Brave new world."));
 93:         $this->assertSame(1, $this->object->count("Hello there... Brave new world."));
 94:         $this->assertSame(2, $this->object->count("Hello there?... Brave new world."));
 95:         $this->assertSame(2, $this->object->count("Hello there!... Brave new world."));
 96:         $this->assertSame(2, $this->object->count("Hello there!!! Brave new world."));
 97:         $this->assertSame(2, $this->object->count("Hello there??? Brave new world."));
 98:     }
 99:     
100:     /**
101:      * @covers Sentence::count
102:      */
103:     public function testCountOneWordSentences() {   
104:         $this->assertSame(2, $this->object->count("You? Smith?"));
105:         $this->assertSame(2, $this->object->count("You there? Smith?"));
106:         $this->assertSame(1, $this->object->count("You mr. Smith?"));
107:         //$this->assertSame(2, $this->object->count("Are you there. Smith?");   // Confuses "there." for an abbreviation.
108:         $this->assertSame(2, $this->object->count("Are you there. Smith, sir?"));
109:         $this->assertSame(2, $this->object->count("Are you there. Mr. Smith?"));
110:     }
111:     
112:     /**
113:      * @covers Sentence::split
114:      */
115:     public function testSplitEmpty() {
116:         $this->assertSame(array(), $this->object->split(''));
117:         $this->assertSame(array(), $this->object->split(' '));
118:         $this->assertSame(array(), $this->object->split("\n"));
119:     }   
120:     
121:     /**
122:      * @covers Sentence::split
123:      */
124:     public function testSplitWord() {
125:         $this->assertSame(array('Hello'), $this->object->split('Hello'));
126:         $this->assertSame(array('Hello.'), $this->object->split('Hello.'));
127:         $this->assertSame(array('Hello...'), $this->object->split('Hello...'));
128:         $this->assertSame(array('Hello!'), $this->object->split('Hello!'));
129:         $this->assertSame(array('Hello?'), $this->object->split('Hello?'));
130:         $this->assertSame(array('Hello?!'), $this->object->split('Hello?!'));
131:     }   
132: 
133:     /**
134:      * @covers Sentence::split
135:      */
136:     public function testSplitMultipleWords() {      
137:         $this->assertSame(array('Hello world.', ' Are you there'), $this->object->split('Hello world. Are you there'));
138:         $this->assertSame(array('Hello world.', ' Are you there?'), $this->object->split('Hello world. Are you there?'));
139:         $this->assertSame(array('Hello world.', 'Are you there'), $this->object->split('Hello world. Are you there', Sentence::SPLIT_TRIM));
140:         $this->assertSame(array('Hello world.', 'Are you there?'), $this->object->split('Hello world. Are you there?', Sentence::SPLIT_TRIM));
141:         $this->assertSame(array('Hello world, Are you there?'), $this->object->split('Hello world, Are you there?'));
142:         $this->assertSame(array('Hello world: Are you there?'), $this->object->split('Hello world: Are you there?'));
143:         $this->assertSame(array('Hello world... Are you there?'), $this->object->split('Hello world... Are you there?'));
144:     }
145: 
146:     /**
147:      * @covers Sentence::split
148:      */
149:     public function testSplitLinebreaks() {
150:         $this->assertSame(array("Hello world...\r", "Are you there?"), $this->object->split("Hello world...\rAre you there?"));
151:         $this->assertSame(array("Hello world...\n", " Are you there?"), $this->object->split("Hello world...\n Are you there?"));
152:         $this->assertSame(array("Hello world...\n", "Are you there?"), $this->object->split("Hello world...\nAre you there?"));
153:         $this->assertSame(array("Hello world...\r\n", "Are you there?"), $this->object->split("Hello world...\r\nAre you there?"));
154:         $this->assertSame(array("Hello world...\r\n\r", "Are you there?"), $this->object->split("Hello world...\r\n\rAre you there?"));
155:         $this->assertSame(array("Hello world...\n\r\n", "Are you there?"), $this->object->split("Hello world...\n\r\nAre you there?"));
156:         $this->assertSame(array("Hello world...\n\n", "Are you there?"), $this->object->split("Hello world...\n\nAre you there?"));
157:         $this->assertSame(array("Hello world...\r\r", "Are you there?"), $this->object->split("Hello world...\r\rAre you there?"));
158:     }
159: 
160:     /**
161:      * @covers Sentence::split
162:      */
163:     public function testSplitAbreviations() {
164:         $this->markTestIncomplete('This test has not been implemented yet.');               
165:         $this->assertSame(array('Hello mr. Smith.'), $this->object->split("Hello mr. Smith."));
166:         $this->assertSame(array('Hello, OMG Kittens!'), $this->object->split("Hello, OMG Kittens!"));
167:         $this->assertSame(array('Hello, abbrev. Kittens!'), $this->object->split("Hello, abbrev. Kittens!"));
168:         $this->assertSame(array('Hello, O.M.G. Kittens!'), $this->object->split("Hello, O.M.G. Kittens!"));
169:     }
170:     
171:     /**
172:      * @covers Sentence::split
173:      */
174:     public function testSplitOneWordSentences() {   
175:         $this->assertSame(array("You?", " Smith?"), $this->object->split("You? Smith?"));
176:         $this->assertSame(array("You there?", " Smith?"), $this->object->split("You there? Smith?"));
177:         $this->assertSame(array("You mr. Smith?"), $this->object->split("You mr. Smith?"));
178:         //$this->assertSame(2, $this->object->count("Are you there. Smith?");   // Confuses "there." for an abbreviation.
179:         $this->assertSame(array("Are you there.", " Smith, sir?"), $this->object->split("Are you there. Smith, sir?"));
180:         $this->assertSame(array("Are you there.", " Mr. Smith?"), $this->object->split("Are you there. Mr. Smith?"));
181:     }
182: }
183: 
phpSentence API documentation generated by ApiGen