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

Looks like an issue with Phalcon 4 #6017

Closed
Raghu-Kanchiraju opened this issue Oct 28, 2020 · 7 comments
Closed

Looks like an issue with Phalcon 4 #6017

Raghu-Kanchiraju opened this issue Oct 28, 2020 · 7 comments

Comments

@Raghu-Kanchiraju
Copy link

What are you trying to achieve?

Trying to write a simple database test against a Phalcon model.

What do you get instead?

There were 2 errors:

---------
1) LocationTest: Some feature
 Test  tests/unit/LocationTest.php:testSomeFeature

  [Error] Interface 'Phalcon\Session\AdapterInterface' not found

#1  /data/xxx/vendor/composer/ClassLoader.php:444
#2  /data/xxx/vendor/composer/ClassLoader.php:322
#3  Composer\Autoload\ClassLoader->loadClass
#4  spl_autoload_call
#5  /data/xxx/vendor/symfony/event-dispatcher/EventDispatcher.php:230
#6  /data/xxx/vendor/symfony/event-dispatcher/EventDispatcher.php:59

---------
2) LocationTest: Some feature
 Test  tests/unit/LocationTest.php:testSomeFeature

  [PDOException] SQLSTATE[HY000]: General error: 1364 Field 'customer_id' doesn't have a default value

#1  PDOStatement->execute
#2  Phalcon\Db\Adapter\Pdo\AbstractPdo->executePrepared
#3  Phalcon\Db\Adapter\Pdo\AbstractPdo->execute
#4  Phalcon\Db\Adapter\AbstractAdapter->insert
#5  Phalcon\Mvc\Model->_doLowInsert
#6  /data/xxx/tests/unit/LocationTest.php:47

Provide console output if related. Use -vvv mode for more details.

Codeception PHP Testing Framework v4.1.9
Powered by PHPUnit 9.4.2 by Sebastian Bergmann and contributors.
Running with seed:


  [Connecting To Db] {"config":{"populate":true,"cleanup":true,"reconnect":false,"waitlock":0,"dump":"tests/_data/setup.sql","populator":null,"dsn":"mysql:host=es_mysql;dbname=xxx_test","user":"root","password":"","initial_queries":["create database if not exists xxx_test;","use xxx_test;"]},"options":[]}
  [Db] Connected to default xxx_test

Unit Tests (1) -------------------------------------------------------------------------------------------------------------------------------------------------------------------
Modules: Phalcon, Db, Asserts, \Helper\Unit
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
E LocationTest: Some feature
E LocationTest: Some feature (0.08s)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Time: 00:12.584, Memory: 19.77 MB

There were 2 errors:

---------
1) LocationTest: Some feature
 Test  tests/unit/LocationTest.php:testSomeFeature

  [Error] Interface 'Phalcon\Session\AdapterInterface' not found

/data/xxx/vendor/codeception/module-phalcon/src/Codeception/Lib/Connector/Phalcon/MemorySession.php:6
/data/xxx/vendor/composer/ClassLoader.php:444
/data/xxx/vendor/composer/ClassLoader.php:322
/data/xxx/vendor/codeception/module-phalcon/src/Codeception/Module/Phalcon.php:162
/data/xxx/vendor/codeception/codeception/src/Codeception/Subscriber/Module.php:56
/data/xxx/vendor/symfony/event-dispatcher/EventDispatcher.php:230
/data/xxx/vendor/symfony/event-dispatcher/EventDispatcher.php:59
/data/xxx/vendor/codeception/phpunit-wrapper/src/DispatcherWrapper.php:22
/data/xxx/vendor/codeception/phpunit-wrapper/src/Listener.php:134
/data/xxx/vendor/codeception/phpunit-wrapper/src/Listener.php:103
/data/xxx/vendor/phpunit/phpunit/src/Framework/TestResult.php:437
/data/xxx/vendor/phpunit/phpunit/src/Framework/TestResult.php:665
/data/xxx/vendor/phpunit/phpunit/src/Framework/TestCase.php:883
/data/xxx/vendor/phpunit/phpunit/src/Framework/TestSuite.php:669
/data/xxx/vendor/codeception/phpunit-wrapper/src/Runner.php:117
/data/xxx/vendor/codeception/codeception/src/Codeception/SuiteManager.php:161
/data/xxx/vendor/codeception/codeception/src/Codeception/Codecept.php:208
/data/xxx/vendor/codeception/codeception/src/Codeception/Codecept.php:162
/data/xxx/vendor/codeception/codeception/src/Codeception/Command/Run.php:511
/data/xxx/vendor/codeception/codeception/src/Codeception/Command/Run.php:405
/data/xxx/vendor/symfony/console/Command/Command.php:258
/data/xxx/vendor/symfony/console/Application.php:920
/data/xxx/vendor/symfony/console/Application.php:266
/data/xxx/vendor/symfony/console/Application.php:142
/data/xxx/vendor/codeception/codeception/src/Codeception/Application.php:117
/data/xxx/vendor/codeception/codeception/app.php:46
/data/xxx/vendor/codeception/codeception/app.php:47
/data/xxx/vendor/codeception/codeception/codecept:7


---------
2) LocationTest: Some feature
 Test  tests/unit/LocationTest.php:testSomeFeature

  [PDOException] SQLSTATE[HY000]: General error: 1364 Field 'customer_id' doesn't have a default value

/data/xxx/tests/unit/LocationTest.php:47
/data/xxx/vendor/phpunit/phpunit/src/Framework/TestCase.php:1536
/data/xxx/vendor/phpunit/phpunit/src/Framework/TestCase.php:1142
/data/xxx/vendor/phpunit/phpunit/src/Framework/TestResult.php:730
/data/xxx/vendor/phpunit/phpunit/src/Framework/TestCase.php:883
/data/xxx/vendor/phpunit/phpunit/src/Framework/TestSuite.php:669
/data/xxx/vendor/codeception/phpunit-wrapper/src/Runner.php:117
/data/xxx/vendor/codeception/codeception/src/Codeception/SuiteManager.php:161
/data/xxx/vendor/codeception/codeception/src/Codeception/Codecept.php:208
/data/xxx/vendor/codeception/codeception/src/Codeception/Codecept.php:162
/data/xxx/vendor/codeception/codeception/src/Codeception/Command/Run.php:511
/data/xxx/vendor/codeception/codeception/src/Codeception/Command/Run.php:405
/data/xxx/vendor/symfony/console/Command/Command.php:258
/data/xxx/vendor/symfony/console/Application.php:920
/data/xxx/vendor/symfony/console/Application.php:266
/data/xxx/vendor/symfony/console/Application.php:142
/data/xxx/vendor/codeception/codeception/src/Codeception/Application.php:117
/data/xxx/vendor/codeception/codeception/app.php:46
/data/xxx/vendor/codeception/codeception/app.php:47
/data/xxx/vendor/codeception/codeception/codecept:7

Provide test source code if related

// nothing special - simple model object creation and calling save on it

Details

  • Codeception version: 4.1.9
  • PHP Version: 7.4.11
  • Operating System: Debian GNU/Linux 10 (buster)
  • Installation type: Composer
@zsilbi
Copy link

zsilbi commented Oct 28, 2020

I can verify, that using version 4.1.9 can lead to errors with Phalcon 4.

The modifications in src/Codeception/Lib/Di.php 3dd13ed#diff-4e510f78018cec23695b82dcc731c983a2a5c96013e787d8e8c7cee86998299c

broke some of our tests here:

https://github.com/phalcon/cphalcon/pull/15187/checks?check_run_id=1311692350

Using version 4.1.8 (or reverting the changes in Di.php) fixed this issue.

@Raghu-Kanchiraju
Copy link
Author

Issue persists with Codeception 4.1.8.

@Naktibalda
Copy link
Member

I don't see how SQL error relates to Codeception.

If Phalcon\Session\AdapterInterface does not exist in Phalcon 4, then module-phalcon does not support Phalcon 4 (it hasn't been updated for a year), please make the necessary changes to support Phalcon 4.

@Naktibalda
Copy link
Member

@zsilbi The problem is that your tests use JWTTrait which has public method newToken, so Codeception thinks that each of these classes have newToken test method and executes it.
Correct fix is to make newToken protected or private, like methods of other fixture traits.

@Naktibalda
Copy link
Member

@zsilbi If you insist that your issue must be fixed by Codeception, please raise a separate issue.

@zsilbi
Copy link

zsilbi commented Oct 29, 2020

@zsilbi If you insist that your issue must be fixed by Codeception, please raise a separate issue.

@Naktibalda thank you, my issue is solved

@Naktibalda
Copy link
Member

There is a separate module for Phalcon 4 at https://github.com/Codeception/module-phalcon4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants