|
554 | 554 | expect($requestHeaders['header_testing'][0])->toEqual(123);
|
555 | 555 | });
|
556 | 556 |
|
| 557 | +test('dbConnectionsSignup handles phone_number correctly', function (): void { |
| 558 | + $clientSecret = uniqid(); |
| 559 | + |
| 560 | + $password = uniqid(); |
| 561 | + $connection = uniqid(); |
| 562 | + $phoneNumber = '+1234567890'; |
| 563 | + |
| 564 | + $this->configuration->setClientSecret($clientSecret); |
| 565 | + $authentication = $this->sdk->authentication(); |
| 566 | + $authentication->getHttpClient()->mockResponses([HttpResponseGenerator::create()]); |
| 567 | + |
| 568 | + // Test with phone_number |
| 569 | + $authentication->dbConnectionsSignup($email, $password, $connection, ['phone_number' => $phoneNumber]); |
| 570 | + $requestWithPhone = $authentication->getHttpClient()->getLastRequest()->getLastRequest(); |
| 571 | + $requestBodyWithPhone = json_decode($requestWithPhone->getBody()->__toString(), true); |
| 572 | + |
| 573 | + $this->assertArrayHasKey('phone_number', $requestBodyWithPhone); |
| 574 | + expect($requestBodyWithPhone['phone_number'])->toEqual($phoneNumber); |
| 575 | + |
| 576 | + // Test without phone_number |
| 577 | + $authentication->dbConnectionsSignup($email, $password, $connection); |
| 578 | + $requestWithoutPhone = $authentication->getHttpClient()->getLastRequest()->getLastRequest(); |
| 579 | + $requestBodyWithoutPhone = json_decode($requestWithoutPhone->getBody()->__toString(), true); |
| 580 | + |
| 581 | + $this->assertArrayNotHasKey('phone_number', $requestBodyWithoutPhone); |
| 582 | +}); |
| 583 | + |
| 584 | +test('dbConnectionsSignup handles flexible identifiers and precedence', function (): void { |
| 585 | + $clientSecret = uniqid(); |
| 586 | + |
| 587 | + $password = uniqid(); |
| 588 | + $connection = uniqid(); |
| 589 | + $phoneNumber = '+1234567890'; |
| 590 | + |
| 591 | + $this->configuration->setClientSecret($clientSecret); |
| 592 | + $authentication = $this->sdk->authentication(); |
| 593 | + $authentication->getHttpClient()->mockResponses([HttpResponseGenerator::create()]); |
| 594 | + |
| 595 | + $authentication->dbConnectionsSignup($email, $password, $connection, ['phone_number' => $phoneNumber]); |
| 596 | + $request = $authentication->getHttpClient()->getLastRequest()->getLastRequest(); |
| 597 | + $requestBody = json_decode($request->getBody()->__toString(), true); |
| 598 | + |
| 599 | + expect($requestBody['email'])->toEqual($email); |
| 600 | + expect($requestBody['phone_number'])->toEqual($phoneNumber); |
| 601 | +}); |
| 602 | + |
557 | 603 | test('dbConnectionsChangePassword() is properly formatted', function(): void {
|
558 | 604 | $clientSecret = uniqid();
|
559 | 605 |
|
|
587 | 633 | expect($requestHeaders['header_testing'][0])->toEqual(123);
|
588 | 634 | });
|
589 | 635 |
|
| 636 | +test('dbConnectionsChangePassword handles phone_number correctly', function (): void { |
| 637 | + $clientSecret = uniqid(); |
| 638 | + |
| 639 | + |
| 640 | + $connection = uniqid(); |
| 641 | + $phoneNumber = '+1234567890'; |
| 642 | + |
| 643 | + $this->configuration->setClientSecret($clientSecret); |
| 644 | + $authentication = $this->sdk->authentication(); |
| 645 | + $authentication->getHttpClient()->mockResponses([HttpResponseGenerator::create()]); |
| 646 | + |
| 647 | + // Test with phone_number |
| 648 | + $authentication->dbConnectionsChangePassword($email, $connection, ['phone_number' => $phoneNumber]); |
| 649 | + $requestWithPhone = $authentication->getHttpClient()->getLastRequest()->getLastRequest(); |
| 650 | + $requestBodyWithPhone = json_decode($requestWithPhone->getBody()->__toString(), true); |
| 651 | + |
| 652 | + $this->assertArrayHasKey('phone_number', $requestBodyWithPhone); |
| 653 | + expect($requestBodyWithPhone['phone_number'])->toEqual($phoneNumber); |
| 654 | + |
| 655 | + // Test without phone_number |
| 656 | + $authentication->dbConnectionsChangePassword($email, $connection); |
| 657 | + $requestWithoutPhone = $authentication->getHttpClient()->getLastRequest()->getLastRequest(); |
| 658 | + $requestBodyWithoutPhone = json_decode($requestWithoutPhone->getBody()->__toString(), true); |
| 659 | + |
| 660 | + $this->assertArrayNotHasKey('phone_number', $requestBodyWithoutPhone); |
| 661 | +}); |
| 662 | + |
590 | 663 | test('pushedAuthorizationRequest() returns an instance of Auth0\SDK\API\Authentication\PushedAuthorizationRequest', function () {
|
591 | 664 | $authentication = $this->sdk->authentication();
|
592 | 665 | $pushedAuthorizationRequest = $authentication->pushedAuthorizationRequest();
|
|
0 commit comments