Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Provide Easy Mocking For Cake3 Table Classes

Open
#140 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
php
Domain
backend, testing

Research direction

Start with the CakePHP 3 test setup and the shown getMock flow for a Table class. Determine whether the requested getTableMock($tableName, $methodsToMock = []) trait alone is sufficient or whether an IntegrationTestCase subclass is also needed; done means the example controller-testing flow can mock a Table class and configure method expectations.

Written by the indexing model from the issue text.

Description

3.x enhancement

Create a Trait that provide a getTableMock($tableName, $methodsToMock = []) method.

Maybe also create a class that extends IntegrationTestCase that pulls that trait in by default.

This is the basic flow to mock a Table Class for a Controller Structure.

$connection = \Cake\Datasource\ConnectionManager::get('test');
$config = ['connection' => $connection];

$UsersTable = $this->getMock(
    'App\Model\Table\UsersTable',
    ['save'],
    [$config]
);

$UsersTable->expects($this->once())
    ->method('save')
    ->will($this->returnValue(false));
Dominant language
PHP
Stars
10
Forks
1
PR merge metrics
No merged PRs in 30d

Getting set up

We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from loadsys/CakePHP-Skeleton

All issues in loadsys/CakePHP-Skeleton

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.