Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing: Declaration of Cake\Chronos\Traits\FrozenTimeTrait #106

Closed
1 of 3 tasks
ADmad opened this issue Nov 11, 2016 · 6 comments
Closed
1 of 3 tasks

Testing: Declaration of Cake\Chronos\Traits\FrozenTimeTrait #106

ADmad opened this issue Nov 11, 2016 · 6 comments
Assignees
Labels
Milestone

Comments

@ADmad
Copy link
Member

ADmad commented Nov 11, 2016

From @mirko-pagliai on November 11, 2016 11:50

This is a (multiple allowed):

  • bug

  • enhancement

  • feature-discussion (RFC)

  • CakePHP Version: 3.3.8

What you did

For my tests, I'm just trying to load some fixtures (from cakephp core) and find records from the database, as described in the cookbook.

Full code is here.

Essentially:

class BackupExportAndImportTest extends TestCase
{
    public $fixtures = ['core.articles', 'core.comments'];

    public function setUp()
    {
        parent::setUp();

        $this->Articles = TableRegistry::get('Articles');
        $this->Comments = TableRegistry::get('Comments');
    }

    /**
     * Internal method to get all records from the database
     * @return array
     */
    protected function _allRecords()
    {
        return [
            'Articles' => $this->Articles->find('all')->hydrate(false)->toArray(),
            'Comments' => $this->Comments->find('all')->hydrate(false)->toArray(),
        ];
    }
    
    public function testExample()
    {
        $this->_allRecords();
    }
}

What happened

Calling:

$this->Articles->find('all')->hydrate(false)->toArray()

I have:

Declaration of Cake\Chronos\Traits\FrozenTimeTrait::setTime($hours, $minutes, $seconds = 0) should be compatible with DateTime::setTime($hour, $minute, $second = NULL, $microseconds = NULL)

I can not reproduce in the error locally, I only get on travis.

Stacktrace:

There was 1 error:
1) MysqlBackup\Test\TestCase\Utility\BackupExportAndImportTest::testExportAndImport
Declaration of Cake\Chronos\Traits\FrozenTimeTrait::setTime($hours, $minutes, $seconds = 0) should be compatible with DateTime::setTime($hour, $minute, $second = NULL, $microseconds = NULL)
/home/travis/build/mirko-pagliai/cakephp-mysql-backup/vendor/cakephp/chronos/src/MutableDate.php:24
/home/travis/build/mirko-pagliai/cakephp-mysql-backup/vendor/cakephp/cakephp/src/I18n/Date.php:26
/home/travis/build/mirko-pagliai/cakephp-mysql-backup/vendor/cakephp/cakephp/src/Database/Type/DateTimeType.php:265
/home/travis/build/mirko-pagliai/cakephp-mysql-backup/vendor/cakephp/cakephp/src/Database/Type/DateTimeType.php:94
/home/travis/build/mirko-pagliai/cakephp-mysql-backup/vendor/cakephp/cakephp/src/Database/Type.php:107
/home/travis/build/mirko-pagliai/cakephp-mysql-backup/vendor/cakephp/cakephp/src/Database/Type.php:122
/home/travis/build/mirko-pagliai/cakephp-mysql-backup/vendor/cakephp/cakephp/src/Database/FieldTypeConverter.php:51
/home/travis/build/mirko-pagliai/cakephp-mysql-backup/vendor/cakephp/cakephp/src/Database/Query.php:194
/home/travis/build/mirko-pagliai/cakephp-mysql-backup/vendor/cakephp/cakephp/src/ORM/Query.php:958
/home/travis/build/mirko-pagliai/cakephp-mysql-backup/vendor/cakephp/cakephp/src/Datasource/QueryTrait.php:276
/home/travis/build/mirko-pagliai/cakephp-mysql-backup/vendor/cakephp/cakephp/src/ORM/Query.php:906
/home/travis/build/mirko-pagliai/cakephp-mysql-backup/vendor/cakephp/cakephp/src/Datasource/QueryTrait.php:293
/home/travis/build/mirko-pagliai/cakephp-mysql-backup/tests/TestCase/Utility/BackupExportAndImportTest.php:77
/home/travis/build/mirko-pagliai/cakephp-mysql-backup/tests/TestCase/Utility/BackupExportAndImportTest.php:90
/home/travis/build/mirko-pagliai/cakephp-mysql-backup/tests/TestCase/Utility/BackupExportAndImportTest.php:145

Full log job:
https://travis-ci.org/mirko-pagliai/cakephp-mysql-backup/jobs/175041605

Copied from original issue: cakephp/cakephp#9745

@ADmad ADmad added the Defect label Nov 11, 2016
@ADmad
Copy link
Member Author

ADmad commented Nov 11, 2016

Looks like the signature of DateTime::setTime() has been changed in PHP 7.1

@ADmad
Copy link
Member Author

ADmad commented Nov 11, 2016

From @mirko-pagliai on November 11, 2016 12:2

@ADmad maybe you're right. In fact, the test fails only with PHP 7.1

@markstory
Copy link
Member

The documentation hasn't been updated yet 😢

@markstory markstory self-assigned this Nov 11, 2016
@markstory markstory added this to the 1.0.1 milestone Nov 11, 2016
markstory added a commit that referenced this issue Nov 11, 2016
@markstory
Copy link
Member

Pull request up now.

@saidulhaque21
Copy link

change below code in vendor\cakephp\chronos\src\Traits\FrozenTimeTrait.php
public function setTime($hours, $minutes, $seconds = 0)
{
return parent::setTime(0, 0, 0);
}

as like
public function setTime($hours, $minutes, $seconds = 0, $microseconds = null)
{
return parent::setTime(0, 0, 0, 0);
}

@markstory
Copy link
Member

@pclanguage See #168

nh2018gc added a commit to nh2018gc/bookmarker-tutorial that referenced this issue Dec 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants