Last active
December 29, 2015 01:58
-
-
Save settermjd/7596618 to your computer and use it in GitHub Desktop.
I'm having trouble mocking "$select->where->greaterThanOrEqualTo" with Zend\Db\Sql. Hope someone can shed light on this.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Here's the function call. | |
* $searchCriteria is an instance of \Zend\InputFilter\InputFilter | |
*/ | |
$select->where->greaterThanOrEqualTo( | |
"EventDate", new \Zend\Db\Sql\Expression( | |
"STR_TO_DATE('" . $searchCriteria->getValue("startDate") ."','%m-%d-%Y')" | |
) | |
); | |
// Here's my attempt to mock | |
$mockWhere = \Mockery::mock('Zend\Db\Sql\Where'); | |
$mockWhere->shouldReceive('greaterThanOrEqualTo')->with( | |
"EventDate", | |
new \Zend\Db\Sql\Expression("STR_TO_DATE('" . $searchCriteria->getValue("startDate") ."','%m-%d-%Y')" | |
))->andReturn($mockWhere); | |
$mockSql = \Mockery::mock('Zend\Db\Sql\Select'); | |
$mockSql->shouldReceive('select')->andReturn($mockSql); | |
$mockSql->shouldReceive('__get')->with('where')->andReturn($mockWhere); | |
// The error that I receive is: Fatal error: Call to a member function greaterThanOrEqualTo() on a non-object |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
After a good chat on IRC and reading over https://github.com/padraic/mockery#php-magic-methods, I realise I've taken the wrong path and likely won't be able to test this.