Skip to content

Commit

Permalink
Merge pull request #13456 from cakephp/4.x-decimaltype-docblock
Browse files Browse the repository at this point in the history
Update docblocks.
  • Loading branch information
markstory committed Aug 2, 2019
2 parents a821293 + d6d2387 commit 677d1c4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 27 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Expand Up @@ -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
Expand All @@ -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:
Expand Down
12 changes: 6 additions & 6 deletions src/Database/Type/DecimalType.php
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/TestSuite/TestCase.php
Expand Up @@ -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();
Expand All @@ -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();

Expand Down
21 changes: 4 additions & 17 deletions tests/TestCase/TestSuite/TestCaseTest.php
Expand Up @@ -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());
}

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -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());
}
}

0 comments on commit 677d1c4

Please sign in to comment.