New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Helper To Mock Result Sets In Testing #720
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Fenikkusu Could you please take a look at my comments
* User: Charles.Martin | ||
* Date: 12/13/2016 | ||
* Time: 12:41 PM | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please use proper DocBlock or remove this at all
* Time: 12:41 PM | ||
*/ | ||
|
||
namespace unit\Test\Traits; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unit\Test\Traits
=> Unit\Test\Traits
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After double checking this (comparing other files), I believe this should actually be 'Phalcon\Test\Test\Traits'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
use ResultSet; | ||
|
||
/** @var \Phalcon\Test\Traits\ResultSet */ | ||
protected $testSubject = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NULL
=> null
} | ||
|
||
public function testCanMockResultSet() { | ||
$mockModel = $this->getMockBuilder('\Phalcon\Mvc\Model') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use Phalcon\Mvc\Model
$mockModel = $this->getMockBuilder(Model:class)
} | ||
|
||
public function testCanUseOtherResultSetClasses() { | ||
$mockResultset = $this->mockResultset([], '\Phalcon\Mvc\Model\Resultset\Simple'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Phalcon\Mvc\Model\Resultset\Simple;
$mockResultset = $this->mockResultset([], Simple::class);
$this->assertSame($mockData, $mockResultSet->toArray()); | ||
} | ||
|
||
public function testCanMockEmptyResultSet() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public function testCanMockEmptyResultSet() {
=>
public function testCanMockEmptyResultSet()
{
@@ -57,7 +57,9 @@ protected function _before() | |||
*/ | |||
protected function _after() | |||
{ | |||
$this->cleanup(); | |||
if (extension_loaded('aerospike')) { | |||
$this->cleanup(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
* | ||
* @return \PHPUnit_Framework_MockObject_MockObject|\Phalcon\Mvc\Model\Resultset|\Phalcon\Mvc\Model\ResultsetInterface | ||
*/ | ||
public function mockResultSet(array $dataSet, $className = '\Phalcon\Mvc\Model\Resultset') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use Phalcon\Mvc\Model\Resultset;
public function mockResultSet(array $dataSet, $className = Resultset::class)
{
…sion was already skipped in _before.
...Apparently I made the changes but never finished them or pushed them up...go figure...oops. |
@Fenikkusu Could you please rebase on 3.1.x branch |
The |
Updated, though it looks like the dump.sql may be out of date. Running Codeception locally is resulting in errors from EagerLoading and Prefixing. |
Ignore my previous comment regarding the dump.sql - DB wasn't populated. |
Hello!
This pull request affects the following components: (please check boxes)
In raising this pull request, I confirm the following (please check boxes):
Small description of change:
I've added a trait for mocking a basic Result set. This comes in handy when doing unit tests and I don't want to have to actually connect to the DB to do so.
Thanks