0

I built some functionality around laravel 4's query builder, and to test out a certain part, i need to do something like this:

$dateTimeObject = new DateTime; // some other stuff with this object
$q->shouldReceive('where')->once()->with('baz', '>=', $dateTimeObject);

The issue is, that whenever I do this, mockery tries to convert it to a string, and i get the error:

Object of class DateTime could not be converted to string

How do I get round this ?

(I am using phpunit and mockery for testing)

Antonio Carlos Ribeiro
  • 86,191
  • 22
  • 213
  • 204
kapv89
  • 1,692
  • 1
  • 17
  • 20
  • it is not clear what the `$q->` part shoud do. if it is a query, i presume you have to deal with UNIX timestamps, not datetime objects. Anyway, what if you do `$dateTimeObject->format('Y-m-d H:i:s')` ? – Antonio Frignani Jun 04 '13 at 08:21
  • `$q` is a mock object, hence the shouldReceive , and i need to work with datetime objects – kapv89 Jun 04 '13 at 10:06
  • without seeing what you are actually testing against, it is a bit difficult for me to replicate the error, since if I mock $q as `$q = Mockery::mock('Illuminate\Database\Eloquent\Model');` it will pass the test. – Antonio Frignani Jun 08 '13 at 13:46

0 Answers0