controller = $this->getMock( 'Cake\Controller\Controller', null, [$request, $response] ); $registry = new ComponentRegistry($this->controller); $this->superuserAuthorize = new SuperuserAuthorize($registry); } /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. */ public function tearDown() { unset($this->superuserAuthorize, $this->controller); } /** * @covers CakeDC\Users\Auth\SuperuserAuthorize::authorize */ public function testAuthorizeIsSuperuser() { $user = [ 'is_superuser' => true, ]; $request = new Request(); $result = $this->superuserAuthorize->authorize($user, $request); $this->assertTrue($result); } /** * @covers CakeDC\Users\Auth\SuperuserAuthorize::authorize */ public function testAuthorizeIsNotSuperuser() { $user = [ 'is_superuser' => false, ]; $request = new Request(); $result = $this->superuserAuthorize->authorize($user, $request); $this->assertFalse($result); } /** * @covers CakeDC\Users\Auth\SuperuserAuthorize::authorize */ public function testAuthorizeWeirdUser() { $request = new Request(); $user = 'non array'; $result = $this->superuserAuthorize->authorize($user, $request); $this->assertFalse($result); } }