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

#145: Mock class not assert arguments with the empty arg list #114

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tests/AuthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function testLoginAsAuthorizedUser()

public function testRegisterAuthorizedUser()
{
$this->mockBcryptHasher();
$this->mockBcryptHasher('666999');

$data = $this->getJsonFixture('new_user.json');

Expand All @@ -115,7 +115,7 @@ public function testRegisterAuthorizedUser()

public function testRegisterFromGuestUser()
{
$this->mockBcryptHasher();
$this->mockBcryptHasher('666999');

$data = $this->getJsonFixture('new_user.json');

Expand Down Expand Up @@ -290,7 +290,7 @@ public function testForgotPasswordThrottled()

public function testRestorePassword()
{
$this->mockBcryptHasher();
$this->mockBcryptHasher('new_password');

$data = $this->getJsonFixture('restore_password.json');

Expand Down
8 changes: 6 additions & 2 deletions tests/Support/AuthTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,25 @@ trait AuthTestTrait
{
use MockTrait;

public function mockOpensslRandomPseudoBytes(): void
public function mockOpensslRandomPseudoBytes(string $password): void
{
//hash_hmac('sha256', $password, 'b"DÉV&´G"áËa\x1Ae&õš,Ü\x16½\x1A\x15‘\x07CM—ºSVxÅ\x16"');

$this->mockNativeFunction('Illuminate\Auth\Passwords', [
$this->functionCall(
name: 'hash_hmac',
arguments: ['sha256', $password, 'b"DÉV&´G"áËa\x1Ae&õš,Ü\x16½\x1A\x15‘\x07CM—ºSVxÅ\x16"'],
result: '5qw6rdsyd4sa65d4zxfc65ds4fc',
),
]);
}

public function mockBcryptHasher(): void
public function mockBcryptHasher(string $password): void
{
$this->mockNativeFunction('Illuminate\Hashing', [
$this->functionCall(
name: 'password_hash',
arguments: [$password, PASSWORD_DEFAULT, ['cost' => 12]],
result: '$2y$12$p9Bub8AaSl7EHfoGMgaXReK7Cs50kjHswxzNPTB5B4mcoRWfHnv7u',
),
]);
Expand Down
2 changes: 1 addition & 1 deletion tests/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function setUp(): void

public function testCreate()
{
$this->mockBcryptHasher();
$this->mockBcryptHasher('123123');

$data = $this->getJsonFixture('create_user.json');

Expand Down
Loading