Show only the name and email, not who the account books for
CI / Tests (PHP 8.2) (pull_request) Successful in 42s
CI / PHPStan (pull_request) Successful in 2m56s
CI / Coding Standards (pull_request) Successful in 2m57s
CI / Tests (PHP 8.3) (pull_request) Successful in 2m44s
CI / Tests (PHP 8.1) (pull_request) Successful in 53s
CI / No Debug Code (pull_request) Successful in 2s
CI / Build Plugin Zip (pull_request) Skipped
CI / Tests (PHP 8.2) (pull_request) Successful in 42s
CI / PHPStan (pull_request) Successful in 2m56s
CI / Coding Standards (pull_request) Successful in 2m57s
CI / Tests (PHP 8.3) (pull_request) Successful in 2m44s
CI / Tests (PHP 8.1) (pull_request) Successful in 53s
CI / No Debug Code (pull_request) Successful in 2s
CI / Build Plugin Zip (pull_request) Skipped
The block reports who is signed in and nothing more. Dropping the "Booking for …" line takes GuardianService with it — it was the only reason the page had a dependency at all, so AccountPage now constructs with no arguments. Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
@@ -6,20 +6,17 @@ namespace Unsupervised\Schedular\Tests\Unit\Auth;
|
||||
use Brain\Monkey\Functions;
|
||||
use Mockery;
|
||||
use Unsupervised\Schedular\Auth\AccountPage;
|
||||
use Unsupervised\Schedular\Guardian\GuardianService;
|
||||
use Unsupervised\Schedular\Tests\Unit\TestCase;
|
||||
|
||||
class AccountPageTest extends TestCase
|
||||
{
|
||||
private GuardianService&Mockery\MockInterface $guardians;
|
||||
private AccountPage $page;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->guardians = Mockery::mock(GuardianService::class);
|
||||
$this->page = new AccountPage($this->guardians);
|
||||
$this->page = new AccountPage();
|
||||
|
||||
Functions\when('is_user_logged_in')->justReturn(true);
|
||||
Functions\when('get_current_user_id')->justReturn(5);
|
||||
@@ -47,16 +44,8 @@ class AccountPageTest extends TestCase
|
||||
return $user;
|
||||
}
|
||||
|
||||
/** @param list<array{id: int, name: string, is_self: bool}> $students */
|
||||
private function bookable(array $students): void
|
||||
{
|
||||
$this->guardians->shouldReceive('bookableStudents')->with(5)->andReturn($students);
|
||||
}
|
||||
|
||||
public function testShowsTheSignedInNameAndEmail(): void
|
||||
{
|
||||
$this->bookable([['id' => 5, 'name' => 'Grace Hopper', 'is_self' => true]]);
|
||||
|
||||
$html = $this->page->render([]);
|
||||
|
||||
self::assertStringContainsString('Grace Hopper', $html);
|
||||
@@ -64,32 +53,8 @@ class AccountPageTest extends TestCase
|
||||
self::assertStringContainsString('Sign out', $html);
|
||||
}
|
||||
|
||||
public function testNamesTheStudentsTheAccountBooksFor(): void
|
||||
{
|
||||
$this->bookable([
|
||||
['id' => 42, 'name' => 'Ada', 'is_self' => false],
|
||||
['id' => 43, 'name' => 'Alan', 'is_self' => false],
|
||||
['id' => 5, 'name' => 'Grace Hopper', 'is_self' => true],
|
||||
]);
|
||||
|
||||
self::assertStringContainsString('Booking for Ada, Alan', $this->page->render([]));
|
||||
}
|
||||
|
||||
/**
|
||||
* An account that only books for itself has nothing to add — "Booking for
|
||||
* Grace Hopper" under "Grace Hopper" is noise.
|
||||
*/
|
||||
public function testSaysNothingAboutStudentsOnAPlainAccount(): void
|
||||
{
|
||||
$this->bookable([['id' => 5, 'name' => 'Grace Hopper', 'is_self' => true]]);
|
||||
|
||||
self::assertStringNotContainsString('Booking for', $this->page->render([]));
|
||||
}
|
||||
|
||||
public function testSigningOutReturnsToTheConfiguredLoginPage(): void
|
||||
{
|
||||
$this->bookable([['id' => 5, 'name' => 'Grace Hopper', 'is_self' => true]]);
|
||||
|
||||
self::assertStringContainsString(
|
||||
rawurlencode('https://studio.test/sign-in/'),
|
||||
$this->page->render(['loginPageId' => 9])
|
||||
@@ -102,8 +67,6 @@ class AccountPageTest extends TestCase
|
||||
*/
|
||||
public function testSigningOutReturnsToTheCurrentPageWhenNoLoginPageIsSet(): void
|
||||
{
|
||||
$this->bookable([['id' => 5, 'name' => 'Grace Hopper', 'is_self' => true]]);
|
||||
|
||||
self::assertStringContainsString(
|
||||
rawurlencode('https://studio.test/current/'),
|
||||
$this->page->render([])
|
||||
@@ -112,8 +75,6 @@ class AccountPageTest extends TestCase
|
||||
|
||||
public function testTheShortcodeAttributeNameIsAccepted(): void
|
||||
{
|
||||
$this->bookable([['id' => 5, 'name' => 'Grace Hopper', 'is_self' => true]]);
|
||||
|
||||
self::assertStringContainsString(
|
||||
rawurlencode('https://studio.test/sign-in/'),
|
||||
$this->page->render(['login_page_id' => 9])
|
||||
@@ -127,7 +88,6 @@ class AccountPageTest extends TestCase
|
||||
public function testRendersNothingForASignedOutVisitorWithNoLoginPage(): void
|
||||
{
|
||||
Functions\when('is_user_logged_in')->justReturn(false);
|
||||
$this->guardians->shouldNotReceive('bookableStudents');
|
||||
|
||||
self::assertSame('', $this->page->render([]));
|
||||
}
|
||||
@@ -135,7 +95,6 @@ class AccountPageTest extends TestCase
|
||||
public function testOffersASignInLinkToASignedOutVisitorWhenAPageIsChosen(): void
|
||||
{
|
||||
Functions\when('is_user_logged_in')->justReturn(false);
|
||||
$this->guardians->shouldNotReceive('bookableStudents');
|
||||
|
||||
$html = $this->page->render(['loginPageId' => 9]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user