Skip to content

Conversation

@wage-slave-montyakku
Copy link
Contributor

以下の2箇所は == ではなく === で比較しないと正しく無いのにテストをすり抜けるパターンが出てしまう

下記は修正されているので、恐らくバグだろう

phpは0と文字列の比較は、==だとtrueになってしまう

var_dump(0=="文字列");  //bool(true)

例えば引数の配列に0が入っていて、比較対象を文字列にした場合問題が起きる

$args = [1,2, "文字列"] ;
$params = [1,2, 0] 
var_dump($this->onlyExpectedArguments($params, $args) == $params);  //bool(true)

// 同じじゃねーだろ!!

$equals = 0;
foreach ($calls as $args) {
if ($this->onlyExpectedArguments($params, $args) == $params) $equals++;
if ($this->onlyExpectedArguments($params, $args) === $params) $equals++;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline control structures are not allowed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

それもとからやん!!

$params = ArgumentsFormatter::toString($params);
foreach ($calls as $args) {
if ($this->onlyExpectedArguments($params, $args) == $params) throw new fail(sprintf($this->neverInvoked, $this->className));
if ($this->onlyExpectedArguments($params, $args) === $params) throw new fail(sprintf($this->neverInvoked, $this->className));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline control structures are not allowed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

それもとからやん!!

$params = ArgumentsFormatter::toString($params);
foreach ($calls as $args) {
if ($this->onlyExpectedArguments($params, $args) == $params) throw new fail(sprintf($this->neverInvoked, $this->className));
if ($this->onlyExpectedArguments($params, $args) === $params) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected 16 spaces, found 17

if ($this->onlyExpectedArguments($params, $args) == $params) throw new fail(sprintf($this->neverInvoked, $this->className));
if ($this->onlyExpectedArguments($params, $args) === $params) {
throw new fail(sprintf($this->neverInvoked, $this->className));
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected 20 spaces, found 17

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これも 元からやろ!!

}
if (count($calls)) throw new fail(sprintf($this->neverInvoked, $this->className.$separator.$name));
if (is_array($params)) {
if (empty($calls)) return;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline control structures are not allowed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (empty($calls)) {
    return;
}

}
return;
}
if (count($calls)) throw new fail(sprintf($this->neverInvoked, $this->className.$separator.$name));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline control structures are not allowed

}
if (count($calls)) throw new fail(sprintf($this->neverInvoked, $this->className.$separator.$name));
if (is_array($params)) {
if (empty($calls)) return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (empty($calls)) {
    return;
}

@wage-slave-montyakku
Copy link
Contributor Author

指摘事項は修正済みです

@sergeyklay
Copy link
Contributor

I will keep this open for a day or two to allow other contributors a chance to speak up, and to take a fresh look at it later. But at the moment it seems good to me.

@DavertMik
Copy link
Member

Thanks for the PR and for fixing the codestyle.
I'd like to ask you write next comments in English, so we could understand them. Thanks

@DavertMik DavertMik merged commit 7a13a26 into Codeception:master Jan 31, 2017
@sergeyklay sergeyklay changed the title 入力値チェックの比較が不完全 Use strict comparison for onlyExpectedArguments Jan 31, 2017
@wage-slave-montyakku
Copy link
Contributor Author

Thank you!! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants