Skip to content

Commit

Permalink
Add Wildfire::setQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
rougin committed Mar 24, 2016
1 parent a8fd1bd commit a81c04a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/Wildfire.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Wildfire
protected $describe;

/**
* @var CI_DB
* @var CI_DB_result
*/
protected $query;

Expand All @@ -42,8 +42,8 @@ class Wildfire
protected $tables = [];

/**
* @param CI_DB|null $database
* @param CI_DB|null $query
* @param CI_DB|null $database
* @param CI_DB_result|null $query
*/
public function __construct($database = null, $query = null)
{
Expand Down Expand Up @@ -186,6 +186,19 @@ public function setDatabase($database)
return $this;
}

/**
* Sets the query result.
*
* @param CI_DB_result $query
* @return self
*/
public function setQuery($query)
{
$this->query = $query;

return $this;
}

/**
* Create an object from the specified data
*
Expand Down
17 changes: 17 additions & 0 deletions tests/WildfireTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,21 @@ public function testWildfireWithoutConstructor()

$this->assertCount(5, $posts);
}

/**
* Tests Wildfire::set_query.
*
* @return void
*/
public function testSetQueryMethod()
{
$query = $this->ci->db->query('SELECT * FROM ' . $this->table);

$wildfire = new Wildfire($this->ci->db);
$wildfire->set_query($query);

$posts = $wildfire->result();

$this->assertCount($this->expectedRows, $posts);
}
}

0 comments on commit a81c04a

Please sign in to comment.