chg: clean test
parent
e9e9c7f43e
commit
6479fd6183
|
@ -7,6 +7,7 @@ namespace App\Test\TestCase\Api\Users;
|
||||||
use Cake\TestSuite\TestCase;
|
use Cake\TestSuite\TestCase;
|
||||||
use App\Test\Fixture\AuthKeysFixture;
|
use App\Test\Fixture\AuthKeysFixture;
|
||||||
use App\Test\Helper\ApiTestTrait;
|
use App\Test\Helper\ApiTestTrait;
|
||||||
|
use Authentication\PasswordHasher\DefaultPasswordHasher;
|
||||||
|
|
||||||
class CreateInboxEntryApiTest extends TestCase
|
class CreateInboxEntryApiTest extends TestCase
|
||||||
{
|
{
|
||||||
|
@ -31,24 +32,31 @@ class CreateInboxEntryApiTest extends TestCase
|
||||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||||
|
|
||||||
$url = sprintf("%s/%s/%s", self::ENDPOINT, 'User', 'Registration');
|
$url = sprintf("%s/%s/%s", self::ENDPOINT, 'User', 'Registration');
|
||||||
|
$password = 'Password12345!';
|
||||||
|
$email = 'john@example.com';
|
||||||
$this->post(
|
$this->post(
|
||||||
$url,
|
$url,
|
||||||
[
|
[
|
||||||
'email' => 'john@example.com',
|
'email' => $email,
|
||||||
'password' => 'Password12345!'
|
'password' => $password
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$this->assertResponseOk();
|
||||||
|
|
||||||
|
$response = $this->getJsonResponseAsArray();
|
||||||
|
$userId = $response['data']['id'];
|
||||||
|
|
||||||
|
$createdInboxMessage = $this->getRecordFromDb(
|
||||||
|
'Inbox',
|
||||||
|
[
|
||||||
|
'id' => $userId,
|
||||||
|
'scope' => 'User',
|
||||||
|
'action' => 'Registration'
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertResponseOk();
|
$this->assertTrue((new DefaultPasswordHasher())->check($password, $createdInboxMessage['data']['password']));
|
||||||
$this->assertResponseContains('"email": "john@example.com"');
|
$this->assertEquals($email, $createdInboxMessage['data']['email']);
|
||||||
$this->assertDbRecordExists(
|
|
||||||
'Inbox',
|
|
||||||
[
|
|
||||||
'id' => 3, // hacky, but `data` is json string cannot verify the value because of the hashed password
|
|
||||||
'scope' => 'User',
|
|
||||||
'action' => 'Registration',
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAddUserRegistrationInboxNotAllowedAsRegularUser(): void
|
public function testAddUserRegistrationInboxNotAllowedAsRegularUser(): void
|
||||||
|
|
Loading…
Reference in New Issue