Example #1
0
 /**
  * @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']);
 }
Example #2
0
 /**
  * @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();
 }
Example #3
0
 /**
  * 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);
 }