Skip to content
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

AspectMock don't mock DateTime object #163

Closed
tupikoff opened this issue Nov 6, 2018 · 2 comments
Closed

AspectMock don't mock DateTime object #163

tupikoff opened this issue Nov 6, 2018 · 2 comments

Comments

@tupikoff
Copy link

tupikoff commented Nov 6, 2018

I have a problem with mocking php Datetime object. Does AspectMock work correctly with global php objects?

code

$datetime = test::double(DateTime::class, ['format' => '1979-06-18']);
$date = (new DateTime())->format('Y-m-d');
$datetime->verifyInvoked('format');
$this->assertEquals('1979-06-18', $date);

will raise

Expected DateTime::format to be invoked but it never occurred
@pablowillians
Copy link

pablowillians commented Aug 2, 2019

I'm currently using Chronos instead of using \DateTime, because I had the same problem trying to double \DateTime class

@Naktibalda
Copy link
Member

This is a missing feature of goaop: goaop/framework#188

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants