File tree Expand file tree Collapse file tree
tests/TestCase/View/Helper Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -120,4 +120,16 @@ public function get(?string $key = null): mixed
120120
121121 return Hash::get ($ this ->_identity , $ key );
122122 }
123+
124+ /**
125+ * Returns the identity instance.
126+ *
127+ * @return \Authentication\IdentityInterface|null
128+ */
129+ public function getIdentity (): ?IdentityInterface
130+ {
131+ return $ this ->_View
132+ ->getRequest ()
133+ ->getAttribute ($ this ->getConfig ('identityAttribute ' ));
134+ }
123135}
Original file line number Diff line number Diff line change @@ -91,4 +91,16 @@ public function testWithOutIdentity()
9191
9292 $ this ->assertFalse ($ helper ->is (1 ));
9393 }
94+
95+ public function testGetIdentity ()
96+ {
97+ $ identity = new Identity ([
98+ 'id ' => 1 ,
99+ ]);
100+ $ request = (new ServerRequest ())->withAttribute ('identity ' , $ identity );
101+ $ view = new View ($ request );
102+
103+ $ helper = new IdentityHelper ($ view );
104+ $ this ->assertSame ($ identity , $ helper ->getIdentity ());
105+ }
94106}
You can’t perform that action at this time.
0 commit comments