Skip to content
Merged
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
8 changes: 6 additions & 2 deletions tests/Commands/SetupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,28 @@ public function testRun(): void
$command->run([]);

$auth = file_get_contents($appFolder . 'Config/Auth.php');
$this->assertIsString($auth);
$this->assertStringContainsString('namespace Config;', $auth);
$this->assertStringContainsString('use CodeIgniter\Shield\Config\Auth as ShieldAuth;', $auth);

$authToken = file_get_contents($appFolder . 'Config/AuthToken.php');
$this->assertIsString($authToken);
$this->assertStringContainsString('namespace Config;', $authToken);
$this->assertStringContainsString('use CodeIgniter\Shield\Config\AuthToken as ShieldAuthToken;', $authToken);

$autoload = file_get_contents($appFolder . 'Config/Autoload.php');
$this->assertIsString($autoload);
$this->assertStringContainsString('$helpers = [\'auth\', \'setting\'];', $autoload);

$routes = file_get_contents($appFolder . 'Config/Routes.php');
$this->assertIsString($routes);
$this->assertStringContainsString('service(\'auth\')->routes($routes);', $routes);

$security = file_get_contents($appFolder . 'Config/Security.php');
$this->assertIsString($security);
$this->assertStringContainsString('$csrfProtection = \'session\';', $security);

$result = $this->getOutputWithoutColorCode();

$this->assertStringContainsString(
' Created: vfs://root/Config/Auth.php
Created: vfs://root/Config/AuthGroups.php
Expand Down Expand Up @@ -135,7 +139,7 @@ public function testUpdateAutoloadHelpers(): void
{
$command = new Setup(Services::logger(), Services::commands());

$updateAutoloadHelpers = $this->getPrivateMethodInvoker($command, 'updateAutoloadHelpers');
$updateAutoloadHelpers = self::getPrivateMethodInvoker($command, 'updateAutoloadHelpers');

$content = <<<'EOL'
class Autoload extends AutoloadConfig
Expand Down
20 changes: 15 additions & 5 deletions tests/Controllers/ActionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,16 @@ public function testEmail2FAHandleSendsEmail(): void
$result->assertStatus(200);
$result->assertSee(lang('Auth.emailEnterCode'));

$archive = service('email')->archive;
$this->assertIsArray($archive);
$this->assertArrayHasKey('body', $archive);
$this->assertIsString($archive['body']);

// Should have sent an email with the code....
$this->assertStringContainsString('Your authentication code is:', service('email')->archive['body']);
$this->assertStringContainsString('Your authentication code is:', $archive['body']);

// Should have included the username in the email
$this->assertStringContainsString($this->user->username, service('email')->archive['body']);
$this->assertStringContainsString($this->user->username, $archive['body']);
}

public function testEmail2FAVerifyFails(): void
Expand Down Expand Up @@ -242,18 +247,23 @@ public function testEmailActivateShow(): void

$result->assertStatus(200);

$archive = service('email')->archive;
$this->assertIsArray($archive);
$this->assertArrayHasKey('body', $archive);
$this->assertIsString($archive['body']);

// Should have sent an email with the link....
$this->assertStringContainsString(
'Please use the code below to activate your account and start using the site',
service('email')->archive['body'],
$archive['body'],
);
$this->assertMatchesRegularExpression(
'!<h1>[0-9]{6}</h1>!',
service('email')->archive['body'],
$archive['body'],
);

// Should have included the username in the email
$this->assertStringContainsString($this->user->username, service('email')->archive['body']);
$this->assertStringContainsString($this->user->username, $archive['body']);
}

public function testEmailActivateVerify(): void
Expand Down
Loading