[GH-ISSUE #1011] Running local tests #540

Closed
opened 2026-02-25 21:35:18 +03:00 by kerem · 10 comments
Owner

Originally created by @jonocodes on GitHub (May 7, 2024).
Original GitHub issue: https://github.com/cypht-org/cypht/issues/1011

Originally assigned to: @IrAlfred on GitHub.

💬 Question

What is the test methodology in cypht? Asking because I am trying to run at least the unit tests locally and getting failures.

$ cd /tests/phpunit
$ phpunit
PHPUnit 11.1.0 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.2.17
Configuration: /home/jono/src/cypht/tests/phpunit/phpunit.xml

.....FFFF................FEF..FFFF.......

ERRORS!
Tests: 168, Assertions: 374, Errors: 3, Failures: 10, Warnings: 4, Deprecations: 3401.

I see tests being run in the .travis dir, but I would think devs would want to run tests locally while they are working, not just in CI. Perhaps adding some development notes to the read me with instructions on how to run tests would be helpful.

Originally created by @jonocodes on GitHub (May 7, 2024). Original GitHub issue: https://github.com/cypht-org/cypht/issues/1011 Originally assigned to: @IrAlfred on GitHub. ## 💬 Question What is the test methodology in cypht? Asking because I am trying to run at least the unit tests locally and getting failures. ``` $ cd /tests/phpunit $ phpunit PHPUnit 11.1.0 by Sebastian Bergmann and contributors. Runtime: PHP 8.2.17 Configuration: /home/jono/src/cypht/tests/phpunit/phpunit.xml .....FFFF................FEF..FFFF....... ERRORS! Tests: 168, Assertions: 374, Errors: 3, Failures: 10, Warnings: 4, Deprecations: 3401. ``` I see tests being run in the .travis dir, but I would think devs would want to run tests locally while they are working, not just in CI. Perhaps adding some development notes to the read me with instructions on how to run tests would be helpful.
kerem closed this issue 2026-02-25 21:35:18 +03:00
Author
Owner

@marclaporte commented on GitHub (May 9, 2024):

@josaphatim please advise

<!-- gh-comment-id:2101875997 --> @marclaporte commented on GitHub (May 9, 2024): @josaphatim please advise
Author
Owner

@josaphatim commented on GitHub (May 9, 2024):

@jonocodes
please just make sure you have a database, database user and password with the value cypht_test

$config->set('db_host', '127.0.0.1');
$config->set('db_name', 'cypht_test');
$config->set('db_user', 'cypht_test');
$config->set('db_pass', 'cypht_test');

If not you can change setup_db function in tests/phpunit/mocks.php and also change Hm_Test_DB::test_build_dsn in tests/phpunit/db.php to your own values. You can add the port to db_host if not using 3306 for mysql

I personally run tests with php vendor/phpunit/phpunit/phpunit --configuration tests/phpunit/phpunit.xml from the root folder

<!-- gh-comment-id:2103279250 --> @josaphatim commented on GitHub (May 9, 2024): @jonocodes please just make sure you have a database, database user and password with the value **cypht_test** ``` $config->set('db_host', '127.0.0.1'); $config->set('db_name', 'cypht_test'); $config->set('db_user', 'cypht_test'); $config->set('db_pass', 'cypht_test'); ``` If not you can change setup_db function in **tests/phpunit/mocks.php** and also change Hm_Test_DB::test_build_dsn in tests/phpunit/db.php to your own values. You can add the port to db_host if not using 3306 for mysql I personally run tests with `php vendor/phpunit/phpunit/phpunit --configuration tests/phpunit/phpunit.xml` from the root folder
Author
Owner

@jonocodes commented on GitHub (May 17, 2024):

Thanks @josaphatim. By editing a few files and manually running some scripts I was able to get the tests to pass.

My suggestion is to make this frictionless, which would be fairly simple from what is there. The idea is I should be able to check out the code from git, and run a single command that will run the tests right away to see that they pass. This is very valuable for developers and new users. If we default to using sqlite instead of mysql this is very easy since no services need to be installed/started. So lets start by focusing on sqlite only, unit tests only.

Here is what I suggest.

  1. move /.github/tests/* into /tests/
  2. update .env and mocks.php to use sqlite
  3. automate the db setup. for now this is in setup.sh but that needs a bit of adjustment to work locally. it also should be using common table creation scripts, not its own.

I can probably work on this if it sounds good.

<!-- gh-comment-id:2118504139 --> @jonocodes commented on GitHub (May 17, 2024): Thanks @josaphatim. By editing a few files and manually running some scripts I was able to get the tests to pass. My suggestion is to make this frictionless, which would be fairly simple from what is there. The idea is I should be able to check out the code from git, and run a single command that will run the tests right away to see that they pass. This is very valuable for developers and new users. If we default to using sqlite instead of mysql this is very easy since no services need to be installed/started. So lets start by focusing on sqlite only, unit tests only. Here is what I suggest. 1. move /.github/tests/* into /tests/ 2. update .env and mocks.php to use sqlite 3. automate the db setup. for now this is in setup.sh but that needs a bit of adjustment to work locally. it also should be using common table creation scripts, not its own. I can probably work on this if it sounds good.
Author
Owner

@marclaporte commented on GitHub (May 18, 2024):

@kroky thoughts?

<!-- gh-comment-id:2118605436 --> @marclaporte commented on GitHub (May 18, 2024): @kroky thoughts?
Author
Owner

@kroky commented on GitHub (May 20, 2024):

.github is specific to the CI, let's keep it there and not move it to tests.

+1 for the rest - devs should just be able to run phpunit and even selenium to execute their tests locally. If any specific setup is required and can't be done automatically, we should include documentation in a readme how to run the tests.

<!-- gh-comment-id:2119847480 --> @kroky commented on GitHub (May 20, 2024): .github is specific to the CI, let's keep it there and not move it to tests. +1 for the rest - devs should just be able to run phpunit and even selenium to execute their tests locally. If any specific setup is required and can't be done automatically, we should include documentation in a readme how to run the tests.
Author
Owner

@jonocodes commented on GitHub (May 22, 2024):

Ok, for now I wont move anything out of .github. I will start by copying it out an modifying it. Here is the basic idea:
https://github.com/cypht-org/cypht/pull/1042

<!-- gh-comment-id:2125730848 --> @jonocodes commented on GitHub (May 22, 2024): Ok, for now I wont move anything out of .github. I will start by copying it out an modifying it. Here is the basic idea: https://github.com/cypht-org/cypht/pull/1042
Author
Owner

@IrAlfred commented on GitHub (Sep 26, 2025):

Related issue: https://github.com/cypht-org/cypht/issues/1710

<!-- gh-comment-id:3340706718 --> @IrAlfred commented on GitHub (Sep 26, 2025): Related issue: https://github.com/cypht-org/cypht/issues/1710
Author
Owner

@IrAlfred commented on GitHub (Nov 20, 2025):

https://github.com/cypht-org/cypht/wiki/Running-local-Tests-in-Cypht

<!-- gh-comment-id:3559707416 --> @IrAlfred commented on GitHub (Nov 20, 2025): [https://github.com/cypht-org/cypht/wiki/Running-local-Tests-in-Cypht](https://github.com/cypht-org/cypht/wiki/Running-local-Tests-in-Cypht)
Author
Owner

@marclaporte commented on GitHub (Nov 22, 2025):

@jonocodes I look forward to your feedback :-)

<!-- gh-comment-id:3566958054 --> @marclaporte commented on GitHub (Nov 22, 2025): @jonocodes I look forward to your feedback :-)
Author
Owner

@jonocodes commented on GitHub (Nov 24, 2025):

Yes, this is very much what I had in mind. And great writeup @IrAlfred .

<!-- gh-comment-id:3568910461 --> @jonocodes commented on GitHub (Nov 24, 2025): Yes, this is very much what I had in mind. And great writeup @IrAlfred .
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/cypht#540
No description provided.