Skip to content

Commit

Permalink
Rename NQMCollection into QueryCollection
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Eckerstorfer committed Feb 16, 2015
1 parent 1b0488c commit 15386c1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
19 changes: 13 additions & 6 deletions src/NQMCollection.php → src/QueryCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,33 @@
namespace Cocur\NQM;

/**
* NQMCollection
* QueryCollection
*
* @package cocur/nqm
* @author Florian Eckerstorfer <florian@eckerstorfer.co>
* @copyright 2013-2015 Florian Eckerstorfer
* @license http://opensource.org/licenses/MIT The MIT License
*/
class NQMCollection
class QueryCollection
{
/**
* @var NQM
*/
private $nqm;

/**
* @param NQM $nqm
* @var string
*/
public function __construct(NQM $nqm)
private $separator;

/**
* @param NQM $nqm
* @param string $separator
*/
public function __construct(NQM $nqm, $separator = "\n#;\n")
{
$this->nqm = $nqm;
$this->nqm = $nqm;
$this->separator = $separator;
}

/**
Expand All @@ -41,7 +48,7 @@ public function __construct(NQM $nqm)
*/
public function getQueries($name)
{
return array_map('trim', preg_split("/\n#;\n/", $this->nqm->getQuery($name)));
return array_map('trim', preg_split('/'.$this->separator.'/', $this->nqm->getQuery($name)));
}

/**
Expand Down
24 changes: 15 additions & 9 deletions tests/NQMCollectionTest.php → tests/QueryCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Pseudo\Pdo;

/**
* NQMCollectionTest
* QueryCollectionTest
*
* @category test
* @package cocur/nqm
Expand All @@ -24,10 +24,10 @@
* @license http://opensource.org/licenses/MIT The MIT License
* @group unit
*/
class NQMCollectionTest extends \PHPUnit_Framework_TestCase
class QueryCollectionTest extends \PHPUnit_Framework_TestCase
{
/**
* @var NQMCollection
* @var QueryCollection
*/
private $collection;

Expand All @@ -39,12 +39,13 @@ class NQMCollectionTest extends \PHPUnit_Framework_TestCase
public function setUp()
{
$this->nqm = $this->getMockNQM();
$this->collection = new NQMCollection($this->nqm);
$this->collection = new QueryCollection($this->nqm);
}

/**
* @test
* @covers Cocur\NQM\NQMCollection::getQueries()
* @covers Cocur\NQM\QueryCollection::__construct()
* @covers Cocur\NQM\QueryCollection::getQueries()
*/
public function getQueriesReturnsListOfQueries()
{
Expand All @@ -63,7 +64,8 @@ public function getQueriesReturnsListOfQueries()

/**
* @test
* @covers Cocur\NQM\NQMCollection::getQueries()
* @covers Cocur\NQM\QueryCollection::__construct()
* @covers Cocur\NQM\QueryCollection::getQueries()
*/
public function getQueriesDoesNotSplitSeparatorInQuery()
{
Expand All @@ -77,7 +79,7 @@ public function getQueriesDoesNotSplitSeparatorInQuery()

/**
* @test
* @covers Cocur\NQM\NQMCollection::prepare()
* @covers Cocur\NQM\QueryCollection::prepare()
*/
public function preparePreparesMultipleStatements()
{
Expand All @@ -100,7 +102,9 @@ public function preparePreparesMultipleStatements()

/**
* @test
* @covers Cocur\NQM\NQMCollection::execute()
* @covers Cocur\NQM\QueryCollection::__construct()
* @covers Cocur\NQM\QueryCollection::execute()
* @covers Cocur\NQM\QueryCollection::getQueryParameters()
*/
public function executeExecutesMultipleStatements()
{
Expand All @@ -123,7 +127,9 @@ public function executeExecutesMultipleStatements()

/**
* @test
* @covers Cocur\NQM\NQMCollection::execute()
* @covers Cocur\NQM\QueryCollection::__construct()
* @covers Cocur\NQM\QueryCollection::execute()
* @covers Cocur\NQM\QueryCollection::getQueryParameters()
*/
public function executeExecutesMultipleStatementsWithDifferentParameters()
{
Expand Down

0 comments on commit 15386c1

Please sign in to comment.