Codeception / Codeception/Stub

Stub::update not working properly when changing method return value

未关闭
#7 0 条评论 5 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
PHP
星标
301
派生
19
PR 合并指标
30 天内没有已合并 PR

描述

Hello. The following snippet demonstrates the problem I'm having. Perhaps it's a bug?

```
class SomeCest{
public function stubUpdate(UnitTester $I) {
$object = new GenericClass();
$actualGetValue1= $object->getValue();
$actualAttr1= $object->attr;

$Stub = Stub::make($object, [
'getValue' => 'B',
'attr' => 'B'
]);
$actualGetValue2 = $Stub->getValue();
$actualAttr2= $Stub->attr;

Stub::update($Stub, [
'getValue' => "C",
'attr' => "C"
]);
$actualGetValue3 = $Stub->getValue();
$actualAttr3= $Stub->attr;

$I->assertEquals('A', $actualAttr1); // ok
$I->assertEquals('A', $actualGetValue1); // ok
$I->assertEquals('B', $actualAttr2); // ok
$I->assertEquals('B', $actualGetValue2); // ok
$I->assertEquals("C", $actualAttr3); // ok
$I->assertEquals("C", $actualGetValue3); // => fails, uses previous value (B)
}
}

class GenericClass {
public $attr = 'A';
public function getValue() {
return 'A';
}
}
```

composer show:
```
behat/gherkin v4.5.1 Gherkin DSL parser for PHP 5.3
brainmaestro/composer-git-hooks v2.4.3 Easily manage git hooks in your composer config
codeception/aspect-mock 3.0.0 Experimental Mocking Framework powered by Aspects
codeception/codeception 2.4.2 BDD-style testing framework
codeception/phpunit-wrapper 7.1.3 PHPUnit classes used by Codeception
codeception/stub 2.0.1 Flexible Stub wrapper for PHPUnit's Mock Builder
doctrine/annotations v1.6.0 Docblock Annotations Parser
doctrine/cache v1.7.1 Caching library offering an object-oriented API for many cache backends
doctrine/instantiator 1.1.0 A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer v1.0.1 Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.
fabpot/goutte v3.2.2 A simple PHP Web Scraper
facebook/webdriver 1.6.0 A PHP client for Selenium WebDriver
goaop/framework 2.2.0 Framework for aspect-oriented programming in PHP.
goaop/parser-reflection 1.4.1 Provides reflection information, based on raw source
guzzlehttp/guzzle 6.3.3 Guzzle is a PHP HTTP client library
guzzlehttp/promises v1.3.1 Guzzle promises library
guzzlehttp/psr7 1.4.2 PSR-7 message implementation that also provides common utility methods
jakubledl/dissect v1.0.1 Lexing and parsing in pure PHP
mpdf/mpdf v7.0.3 A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support
myclabs/deep-copy 1.8.0 Create deep copies (clones) of your objects
nikic/php-parser v3.1.5 A PHP parser written in PHP
paragonie/random_compat v2.0.12 PHP 5.x polyfill for random_bytes() and random_int() from PHP 7
phar-io/manifest 1.0.1 Component for reading phar.io manifest information from a PHP Archive (PHAR)
phar-io/version 1.0.1 Library for handling version information and constraints
phpdocumentor/reflection-common 1.0.1 Common reflection classes used by phpdocumentor to reflect the code structure
phpdocumentor/reflection-docblock 4.3.0 With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.
phpdocumentor/type-resolver 0.4.0
phpspec/prophecy 1.7.6 Highly opinionated mocking framework for PHP 5.3+
phpunit/php-code-coverage 6.0.5 Library that provides collection, processing, and rendering functionality for PHP code coverage information.
phpunit/php-file-iterator 1.4.5 FilterIterator implementation that filters files based on a list of suffixes.
phpunit/php-text-template 1.2.1 Simple template engine.
phpunit/php-timer 2.0.0 Utility class for timing
phpunit/php-token-stream 3.0.0 Wrapper around PHP's tokenizer extension.
phpunit/phpunit 7.1.5 The PHP Unit Testing framework.
phpunit/phpunit-mock-objects 6.1.2 Mock Object library for PHPUnit
psr/http-message 1.0.1 Common interface for HTTP messages
psr/log 1.0.2 Common interface for logging libraries
sebastian/code-unit-reverse-lookup 1.0.1 Looks up which function or method a line of code belongs to
sebastian/comparator 3.0.0 Provides the functionality to compare PHP values for equality
sebastian/diff 3.0.0 Diff implementation
sebastian/environment 3.1.0 Provides functionality to handle HHVM/PHP environments
sebastian/exporter 3.1.0 Provides the functionality to export PHP variables for visualization
sebastian/global-state 2.0.0 Snapshotting of global state
sebastian/object-enumerator 3.0.3 Traverses array structures and object graphs to enumerate all referenced objects
sebastian/object-reflector 1.1.1 Allows reflection of object attributes, including inherited and non-public ones
sebastian/recursion-context 3.0.0 Provides functionality to recursively process PHP variables
sebastian/resource-operations 1.0.0 Provides a list of PHP built-in functions that operate on resources
sebastian/version 2.0.1 Library that helps with managing the version number of Git-hosted PHP projects
setasign/fpdf 1.8.1 FPDF is a PHP class which allows to generate PDF files with pure PHP. F from FPDF stands for Free: you may use it for any kind of usage and modify it to suit your needs.
setasign/fpdi 1.6.2 FPDI is a collection of PHP classes facilitating developers to read pages from existing PDF documents and use them as templates in FPDF. Because it is also possible to use FPDI with TCPDF, there are no...
symfony/browser-kit v4.1.0 Symfony BrowserKit Component
symfony/console v4.1.0 Symfony Console Component
symfony/css-selector v4.1.0 Symfony CssSelector Component
symfony/dom-crawler v4.1.0 Symfony DomCrawler Component
symfony/event-dispatcher v3.4.9 Symfony EventDispatcher Component
symfony/finder v4.1.0 Symfony Finder Component
symfony/polyfill-ctype v1.8.0 Symfony polyfill for ctype functions
symfony/polyfill-mbstring v1.8.0 Symfony polyfill for the Mbstring extension
symfony/process v4.1.0 Symfony Process Component
symfony/yaml v4.1.0 Symfony Yaml Component
theseer/tokenizer 1.1.0 A small library for converting tokenized PHP source code into XML and potentially other formats
trf4/infra dev-desenv b05d89f Framework PHP desenvolvido pelo TRF4.
webmozart/assert 1.3.0 Assertions to validate method input/output with nice error messages.

```

贡献指南

这个仓库没有索引到贡献指南

调研方向

Locate the Stub::update entry point in the Codeception Stub package and reproduce the supplied PHP example. Compare the updated method and attribute results, then add coverage for the demonstrated behavior so the method returns C after the update while the attribute continues to do so.

由索引模型根据 Issue 内容生成。

评估

技术栈
php
领域
testing-qa
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
48/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。