/** * Test to make sure a zero fails validation * * @return void **/ public function testGetDetectors() { $d = new Detector(); $k = get_class($d); $data = []; $data[$k] = $d; $service = new Checker(); $service->registerDetector($data[$k]); $detectors = $service->getDetectors(); $this->assertTrue(is_array($detectors), 'Getting all detectors should return an array'); $this->assertCount(1, $detectors, 'Get detectors should have returned one detector'); $this->assertEquals($detectors, $data); }
/** * Test the check() method * * @covers \Hubzero\Spam\Checker::check * @return void **/ public function testCheck() { $service = new Checker(); $service->registerDetector(new Detector()); $result = $service->check('Maecenas sed diam eget risus varius blandit sit amet non magna.'); $this->assertInstanceOf('Hubzero\\Spam\\Result', $result); $this->assertFalse($result->isSpam()); $result = $service->check('Maecenas sed diam eget risus varius spam blandit sit amet non magna.'); $this->assertInstanceOf('Hubzero\\Spam\\Result', $result); $this->assertTrue($result->isSpam()); $messages = $result->getMessages(); $this->assertTrue(is_array($messages)); $this->assertTrue(in_array('Text contained the word "spam".', $messages)); }