From c7c8cc9e5eb8a2a8b86e31067cc4a7afba768a39 Mon Sep 17 00:00:00 2001 From: ADmad Date: Fri, 2 Aug 2019 11:20:16 +0530 Subject: [PATCH 1/3] Update docblocks. --- src/Database/Type/DecimalType.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Database/Type/DecimalType.php b/src/Database/Type/DecimalType.php index 7e354bc373b..95297585e45 100644 --- a/src/Database/Type/DecimalType.php +++ b/src/Database/Type/DecimalType.php @@ -45,7 +45,7 @@ class DecimalType extends BaseType implements BatchCastingInterface protected $_useLocaleParser = false; /** - * Convert integer data into the database format. + * Convert decimal strings into the database format. * * @param mixed $value The value to convert. * @param \Cake\Database\DriverInterface $driver The driver instance to convert with. @@ -76,7 +76,7 @@ public function toDatabase($value, DriverInterface $driver) } /** - * Convert float values to PHP floats + * Convert numeric values to strings representing decimal. * * @param mixed $value The value to convert. * @param \Cake\Database\DriverInterface $driver The driver instance to convert with. @@ -111,7 +111,7 @@ public function manyToPHP(array $values, array $fields, DriverInterface $driver) } /** - * Get the correct PDO binding type for integer data. + * Get the correct PDO binding type for decimal data. * * @param mixed $value The value being bound. * @param \Cake\Database\DriverInterface $driver The driver. @@ -123,7 +123,7 @@ public function toStatement($value, DriverInterface $driver): int } /** - * Marshalls request data into PHP floats. + * Marshalls request data into decimal strings. * * @param mixed $value The value to convert. * @return string|null Converted value. @@ -173,8 +173,8 @@ public function useLocaleParser(bool $enable = true) } /** - * Converts a string into a float point after parsing it using the locale - * aware parser. + * Converts localized string into a decimal string after parsing it using + * the locale aware parser. * * @param string $value The value to parse and convert to an float. * @return string From 2b47b1f55b6776a819a353711f97b60a8675f753 Mon Sep 17 00:00:00 2001 From: ADmad Date: Fri, 2 Aug 2019 11:42:14 +0530 Subject: [PATCH 2/3] Update use of deprecated MockBuilder::setMethods(). As a result TestCase::getMockModel() no longer accepts null or non existent methods for it's $methods argument. --- src/TestSuite/TestCase.php | 6 +++--- tests/TestCase/TestSuite/TestCaseTest.php | 21 ++++----------------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/src/TestSuite/TestCase.php b/src/TestSuite/TestCase.php index 6c0d43b2d1e..e59ebb7499f 100644 --- a/src/TestSuite/TestCase.php +++ b/src/TestSuite/TestCase.php @@ -753,12 +753,12 @@ protected function skipUnless($condition, $message = '') * Mock a model, maintain fixtures and table association * * @param string $alias The model to get a mock for. - * @param array|null $methods The list of methods to mock + * @param array $methods The list of methods to mock * @param array $options The config data for the mock's constructor. * @throws \Cake\ORM\Exception\MissingTableClassException * @return \Cake\ORM\Table|\PHPUnit\Framework\MockObject\MockObject */ - public function getMockForModel(string $alias, ?array $methods = [], array $options = []) + public function getMockForModel(string $alias, array $methods = [], array $options = []) { $className = $this->_getTableClassName($alias, $options); $connectionName = $className::defaultConnectionName(); @@ -772,7 +772,7 @@ public function getMockForModel(string $alias, ?array $methods = [], array $opti /** @var \Cake\ORM\Table|\PHPUnit\Framework\MockObject\MockObject $mock */ $mock = $this->getMockBuilder($className) - ->setMethods($methods) + ->onlyMethods($methods) ->setConstructorArgs([$options]) ->getMock(); diff --git a/tests/TestCase/TestSuite/TestCaseTest.php b/tests/TestCase/TestSuite/TestCaseTest.php index fb23349d296..301cb119ccb 100644 --- a/tests/TestCase/TestSuite/TestCaseTest.php +++ b/tests/TestCase/TestSuite/TestCaseTest.php @@ -359,12 +359,10 @@ public function testGetMockForModel() ->will($this->returnValue('mocked')); $this->assertSame('mocked', $Posts->save($entity)); $this->assertSame('Cake\ORM\Entity', $Posts->getEntityClass()); - - $Posts = $this->getMockForModel('Posts', ['doSomething']); $this->assertInstanceOf('Cake\Database\Connection', $Posts->getConnection()); $this->assertSame('test', $Posts->getConnection()->configName()); - $Tags = $this->getMockForModel('Tags', ['doSomething']); + $Tags = $this->getMockForModel('Tags', ['save']); $this->assertSame('TestApp\Model\Entity\Tag', $Tags->getEntityClass()); } @@ -411,7 +409,7 @@ public function testGetMockForModelWithPlugin() $this->assertTrue($TestPluginComment->save($entity)); $this->assertFalse($TestPluginComment->save($entity)); - $TestPluginAuthors = $this->getMockForModel('TestPlugin.Authors', ['doSomething']); + $TestPluginAuthors = $this->getMockForModel('TestPlugin.Authors', ['save']); $this->assertInstanceOf('TestPlugin\Model\Table\AuthorsTable', $TestPluginAuthors); $this->assertSame('TestPlugin\Model\Entity\Author', $TestPluginAuthors->getEntityClass()); $this->clearPlugins(); @@ -453,17 +451,6 @@ public function testGetMockForModelTable() $result = $this->getTableLocator()->get('Comments'); $this->assertInstanceOf(Table::class, $result); $this->assertEmpty([], $allMethodsStubs->getAlias()); - - $allMethodsMocks = $this->getMockForModel( - 'Table', - null, - ['alias' => 'Comments', 'className' => Table::class] - ); - $result = $this->getTableLocator()->get('Comments'); - $this->assertInstanceOf(Table::class, $result); - $this->assertSame('Comments', $allMethodsMocks->getAlias()); - - $this->assertNotEquals($allMethodsStubs, $allMethodsMocks); } /** @@ -475,10 +462,10 @@ public function testGetMockForModelSetTable() { static::setAppNamespace(); - $I18n = $this->getMockForModel('I18n', ['doSomething']); + $I18n = $this->getMockForModel('I18n', ['save']); $this->assertSame('custom_i18n_table', $I18n->getTable()); - $Tags = $this->getMockForModel('Tags', ['doSomething']); + $Tags = $this->getMockForModel('Tags', ['save']); $this->assertSame('tags', $Tags->getTable()); } } From d6d2387260a128f607a452f711c2526c6168b04f Mon Sep 17 00:00:00 2001 From: ADmad Date: Fri, 2 Aug 2019 23:09:43 +0530 Subject: [PATCH 3/3] Use pcov instead of phpdbg for code coverge. Refs https://github.com/sebastianbergmann/phpunit/issues/3772 --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9e4cf44884c..f49358d7034 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,7 +39,9 @@ matrix: before_install: - echo cakephp version && tail -1 VERSION.txt + - phpenv config-rm xdebug.ini + - if [ $CODECOVERAGE == 1 ]; then pecl install pcov; fi - if [ $DB = 'mysql' ]; then mysql -u root -e 'CREATE DATABASE cakephp_test;'; fi - if [ $DB = 'pgsql' ]; then psql -c 'CREATE DATABASE cakephp_test;' -U postgres; fi @@ -58,7 +60,7 @@ before_script: - composer install --prefer-dist --no-interaction script: - - if [[ $CODECOVERAGE == 1 ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=clover.xml; fi + - if [[ $CODECOVERAGE == 1 ]]; then vendor/bin/phpunit --coverage-clover=clover.xml; fi - if [[ $CODECOVERAGE != 1 ]]; then vendor/bin/phpunit; fi after_script: