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

Don't mock the ISecure #20379

Closed
wants to merge 1 commit into from
Closed

Don't mock the ISecure #20379

wants to merge 1 commit into from

Conversation

hutchic
Copy link
Contributor

@hutchic hutchic commented Nov 7, 2015

Should get #18485 tests passing

Mocked ISecure leads to a fatal error when user controller calls

$this->secureRandom->getMediumStrengthGenerator()->generate( ... )

I didn't see any reason this needed to be mocked so I nuked the mock

@MorrisJobke
Copy link
Contributor

cc @LukasReschke

@LukasReschke
Copy link
Member

I'd prefer a proper unit test instead of removing it completely. You basically need to do some more mocking here. Checkout

$randomToken = $this->container['SecureRandom'];
$this->container['SecureRandom']
->expects($this->once())
->method('generate')
->with('21')
->will($this->returnValue('ThisIsMaybeANotSoSecretToken!'));
$this->container['UserManager']
->expects($this->once())
->method('userExists')
->with('ExistingUser')
->will($this->returnValue(true));
$this->container['Config']
->expects($this->once())
->method('getUserValue')
->with('ExistingUser', 'settings', 'email')
->will($this->returnValue('test@example.com'));
$this->container['SecureRandom']
->expects($this->once())
->method('getMediumStrengthGenerator')
->will($this->returnValue($randomToken));
for reference.

👎 from my side for this approach.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants