/** * @depends testStoreMessage * @covers \jones\wschat\components\DbStorage::getHistory */ public function testGetHistory() { $data = AbstractStorage::factory('pgsql')->getHistory($this->params['chat_id']); $this->assertNotEmpty($data); $this->assertEquals(1, sizeof($data), 'Only one message should be in history table'); $this->assertEquals($this->params['message'], $data[0]['message']); }
/** * @depends testStoreMessage * @covers \jones\wschat\collections\History::getHistory */ public function testGetHistory() { $data = AbstractStorage::factory('mongodb')->getHistory($this->params['chat_id']); $this->assertNotEmpty($data); $this->assertEquals(1, sizeof($data), 'Only one message should be in history collection'); $this->assertEquals($this->params['message'], $data[0]['message']); $this->clearCollection(); }
/** * Load user chat history * * @access public * @param mixed $chatId * @param integer $limit * @return array */ public function getHistory($chatId, $limit = 10) { $data = AbstractStorage::factory()->getHistory($chatId, $limit); return array_reverse($data); }
/** * @covers \jones\wschat\components\AbstractStorage::factory */ public function testMysqlStorage() { $storage = AbstractStorage::factory('mysql'); $this->assertInstanceOf('\\jones\\wschat\\components\\DbStorage', $storage); }