controller = $this->getMock( 'Cake\Controller\Controller', ['header', 'redirect', 'render', '_stop'] ); $this->controller->Trait = $this->getMockForTrait('Users\Controller\Traits\CustomUsersTableTrait'); } public function tearDown() { parent::tearDown(); } public function testGetUsersTable() { $table = $this->controller->Trait->getUsersTable(); $this->assertEquals('Users.Users', $table->registryAlias()); $newTable = new Table(); $this->controller->Trait->setUsersTable($newTable); $this->assertSame($newTable, $this->controller->Trait->getUsersTable()); } }