Codeception / Codeception/AspectMock

Aspect Mock broken by comments

Open
#70 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
PHP
Stars
784
Forks
132
PR merge metrics
No merged PRs in 30d

Description

Method declaration such as `function myMethod( ) /* {{{ */ {` cannot be mocked with Aspect Mock.

On line 98 current code gets the first open bracket { amd inserts the injection code after it
`$pos = strpos($dataArray[$i], '{');`

https://github.com/Codeception/AspectMock/blob/master/src/AspectMock/Intercept/BeforeMockTransformer.php#L98

This turns the method declaration to
`function myMethod( ) /* { if (($__am_res = __amock_before($this, __CLASS__, __FUNCTION__, array(), false)) !== __AM_CON
TINUE__) return $__am_res; {{ */ {
`

Which basically commented all Aspect Mock injection code.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in src/AspectMock/Intercept/BeforeMockTransformer.php at line 98 and inspect how the first opening brace is located in a method declaration. Reproduce the issue with a declaration containing a comment before the brace; done means the generated comment no longer comments out the Aspect Mock injection code.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.