From a11778ebc78ec822f024e50f0a7d4cd798b04e30 Mon Sep 17 00:00:00 2001 From: zunyu Date: Wed, 23 Jun 2021 19:14:58 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=E4=B8=AD=E6=97=A0=E6=B3=95=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=88=B0=E5=BD=93=E5=89=8D=E7=9A=84=E9=AA=8C=E8=AF=81=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Validate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Validate.php b/src/Validate.php index b84a1d8..ac3f0e6 100644 --- a/src/Validate.php +++ b/src/Validate.php @@ -213,7 +213,7 @@ class Validate extends RuleManager } if (method_exists($this, 'scene' . ucfirst($sceneName))) { - $scene = new ValidateScene($this->rule); + $scene = new ValidateScene($this->rule, $this->checkData); call_user_func([$this, 'scene' . ucfirst($sceneName)], $scene); $this->event = array_merge($this->event, $scene->events); $this->afters = array_merge($this->afters, $scene->afters); -- Gitee From e324cf2dd31284c446ff8f9341fa7aea217c17e2 Mon Sep 17 00:00:00 2001 From: zunyu Date: Wed, 23 Jun 2021 19:26:47 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=92=88=E5=AF=B9?= =?UTF-8?q?=E6=9C=AC=E6=AC=A1BUG=E7=9A=84=E5=8D=95=E5=85=83=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/Test/TestBug.php | 44 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 tests/Test/TestBug.php diff --git a/tests/Test/TestBug.php b/tests/Test/TestBug.php new file mode 100644 index 0000000..710b530 --- /dev/null +++ b/tests/Test/TestBug.php @@ -0,0 +1,44 @@ + + * + * This is not a free software + * Using it under the license terms + * visited https://www.w7.cc for more details + */ + +namespace W7\Tests\Test; + +use W7\Tests\Material\BaseTestValidate; +use W7\Validate\Support\ValidateScene; +use W7\Validate\Validate; + +class TestBug extends BaseTestValidate +{ + public function testBug5() + { + $v = new class extends Validate { + public $checkData = []; + + protected $rule = [ + 'name' => 'required' + ]; + + protected function sceneTest(ValidateScene $scene) + { + $this->checkData = $scene->getData(); + $scene->only(['name']); + } + }; + + $v->scene('test')->check([ + 'name' => 123 + ]); + + $this->assertArrayHasKey('name', $v->checkData); + $this->assertEquals(123, $v->checkData['name']); + } +} -- Gitee