From d7ffcfcf7b5b3019d852277ec617ed807eed9c10 Mon Sep 17 00:00:00 2001 From: eai04191 Date: Wed, 3 Jul 2019 16:29:38 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88=E3=82=92?= =?UTF-8?q?=E6=A4=9C=E7=B4=A2=E5=AF=BE=E8=B1=A1=E3=81=AB=E5=90=AB=E3=81=BE?= =?UTF-8?q?=E3=82=8C=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/UpdateFixture.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/UpdateFixture.php b/app/Console/Commands/UpdateFixture.php index 2c36a0e..28c8c51 100644 --- a/app/Console/Commands/UpdateFixture.php +++ b/app/Console/Commands/UpdateFixture.php @@ -44,8 +44,21 @@ class UpdateFixture extends Command $this->info($this->argument('resolver') . 'ResolverTest.php is found.'); $test_file = file_get_contents($test_file_path); - preg_match_all('~file_get_contents\(__DIR__ . \'/(.+)\'\);~', $test_file, $fixtures); - preg_match_all('~\$this->assertSame\(\'(.+)\', \(string\) \$this->handler->getLastRequest\(\)->getUri\(\)\);~', $test_file, $urls); + $test_file_without_comment = ''; + // コメントを削除する + $tokens = token_get_all($test_file); + foreach ($tokens as $token) { + if (is_string($token)) { + $test_file_without_comment .= $token; + } else { + list($id, $text) = $token; + if (token_name($id) != 'T_COMMENT') { + $test_file_without_comment .= $text; + } + } + } + preg_match_all('~file_get_contents\(__DIR__ . \'/(.+)\'\);~', $test_file_without_comment, $fixtures); + preg_match_all('~\$this->assertSame\(\'(.+)\', \(string\) \$this->handler->getLastRequest\(\)->getUri\(\)\);~m', $test_file_without_comment, $urls); $update_list = array_combine($fixtures[1], $urls[1]); $progress = $this->output->createProgressBar(count($update_list));