From 6c7dc3725bb82a707dfcb7ddcfa2568598ebd601 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sat, 2 Mar 2019 13:15:34 +0900 Subject: [PATCH 1/2] =?UTF-8?q?UniTest=E7=94=A8=E3=81=AB=E3=82=AD=E3=83=BC?= =?UTF-8?q?=E7=94=9F=E6=88=90=E5=87=A6=E7=90=86=E3=82=92=E3=82=AB=E3=82=B9?= =?UTF-8?q?=E3=82=BF=E3=83=9E=E3=82=A4=E3=82=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/Behavior/OriginalKeyBehavior.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Model/Behavior/OriginalKeyBehavior.php b/Model/Behavior/OriginalKeyBehavior.php index f393fcc5..e8f5d0b1 100644 --- a/Model/Behavior/OriginalKeyBehavior.php +++ b/Model/Behavior/OriginalKeyBehavior.php @@ -59,7 +59,9 @@ public function beforeSave(Model $model, $options = array()) { return true; } if (! isset($model->data[$model->alias]['key']) || $model->data[$model->alias]['key'] === '') { - $model->data[$model->alias]['key'] = self::generateKey($model->alias, $model->useDbConfig); + $plugin = Inflector::underscore($model->alias); + $keyNumber = $model->find('count', ['recursive' => -1]) + 1; + $model->data[$model->alias]['key'] = $plugin . '_key_' . $keyNumber; } return true; } @@ -74,7 +76,7 @@ public function beforeSave(Model $model, $options = array()) { public static function generateKey($plugin, $dataSource) { if ($dataSource !== 'test' || self::$isUnitRandomKey) { return Security::hash($plugin . mt_rand() . microtime(), 'md5'); - } else { + } else { return Security::hash($plugin, 'md5'); } } From 10640830830c03cd4a3d83d2278fd4f96c4b79bc Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Mon, 4 Mar 2019 11:43:33 +0900 Subject: [PATCH 2/2] =?UTF-8?q?php7=E7=B3=BB=E4=BB=A5=E5=A4=96=E3=81=AF?= =?UTF-8?q?=E3=80=81Fixture=E3=81=8C=E3=83=AD=E3=83=BC=E3=83=89=E3=81=95?= =?UTF-8?q?=E3=82=8C=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB=E3=81=97?= =?UTF-8?q?=E3=80=81=E3=83=86=E3=82=B9=E3=83=88=E3=81=8C=E5=AE=9F=E8=A1=8C?= =?UTF-8?q?=E3=81=95=E3=82=8C=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TestSuite/NetCommonsTreeBehaviorCase.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/TestSuite/NetCommonsTreeBehaviorCase.php b/TestSuite/NetCommonsTreeBehaviorCase.php index 207f1917..9e0cbba4 100644 --- a/TestSuite/NetCommonsTreeBehaviorCase.php +++ b/TestSuite/NetCommonsTreeBehaviorCase.php @@ -60,18 +60,20 @@ abstract class NetCommonsTreeBehaviorCase extends NetCommonsModelTestCase { public $plugin = 'net_commons'; /** - * Runs the test case and collects the results in a TestResult object. - * If no TestResult object is passed a new one will be created. - * This method is run for each test method in this class + * Fixtures load * - * @param PHPUnit_Framework_TestResult $result The test result object - * @return PHPUnit_Framework_TestResult - * @throws InvalidArgumentException + * @param string $name The name parameter on PHPUnit_Framework_TestCase::__construct() + * @param array $data The data parameter on PHPUnit_Framework_TestCase::__construct() + * @param string $dataName The dataName parameter on PHPUnit_Framework_TestCase::__construct() + * @return void */ - public function run(PHPUnit_Framework_TestResult $result = null) { - if (version_compare(PHP_VERSION, '7.0.0') >= 0) { - return parent::run($result); + public function __construct($name = null, array $data = array(), $dataName = '') { + if (version_compare(PHP_VERSION, '7.0.0') < 0) { + $this->autoFixtures = false; + $this->fixtures = null; + $this->markTestSkipped('php 7.x以上でテストができます。'); } + parent::__construct($name, $data, $dataName); } /**