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

Create phpunit tests #69

Open
8 of 19 tasks
georgmaisser opened this issue Jan 5, 2025 · 1 comment
Open
8 of 19 tasks

Create phpunit tests #69

georgmaisser opened this issue Jan 5, 2025 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@georgmaisser
Copy link
Contributor

georgmaisser commented Jan 5, 2025

Currently, we have mostly behat tests in place.

We need the following unit tests, to help make sure that all the functionality still works during development.

  • General functionality (create demo table, return the correct number of items)
  • Sorting
  • Caching
  • Pagination (on a table with eg. 35 items, check that we get four pages à 10 items, check that we have 5 on the last etc.)
  • requirelogin
  • requirecapability
  • General Filter (standardfilter, localization etc.)
  • Hierarchical filter
  • Datepicker
  • Intrange filter
  • Exploding strings for columns storing multiple values in filter
  • Handle json objects in filter
  • Standard Sorting
  • New sortable classes
  • weekdays filter
  • hourlist filter
  • Fulltextsearch
  • Action button functionalities
  • Action Form functionalities
@semteacher
Copy link
Contributor

Made refactoring to separate seracheing / filtering tests into separate method (see 97e2a0c).
Worked OK until I have added a Datepicker filter.

  • once call has been added
        $nrofrows = $this->get_rowscount_for_table(
            $table,
            0,
            null,
            null,
            null,
            null,
            null,
            //'{"enddate":{"Course end date":{"<":' . strtotime('today') . '}}}'
            "{\"enddate\":{\"Course end date\":{\"<\":1763528940}}}"
        );
        $this->assertEquals(2, $nrofrows);
  • the following error starts to appers:
user@debian:/var/www/moodle$ php vendor/bin/phpunit local/wunderbyte_table/tests/base_test.php
Moodle 4.5+ (Build: 20241101), acff633e392763a5d61723257efa1bd2ade463a2
Php: 8.3.13, pgsql: 15.8 (Debian 15.8-0+deb12u1), OS: Linux 6.1.0-20-amd64 x86_64
PHPUnit 9.6.21 by Sebastian Bergmann and contributors.

.E                                                                  2 / 2 (100%)

Time: 00:15.865, Memory: 64.50 MB

There was 1 error:

1) local_wunderbyte_table\base_test::test_basic_search_filtering_cached
PHPUnit\Framework\Exception: PHP Fatal error:  Uncaught Exception: Serialization of 'PgSql\Connection' is not allowed in Standard input code:87
Stack trace:
#0 Standard input code(87): serialize(Array)
#1 Standard input code(127): __phpunit_run_isolated_test()
#2 {main}
  thrown in Standard input code on line 87

ERRORS!
Tests: 2, Assertions: 5, Errors: 1.

Debugging shown that it appears after test_query_db_cached() had been executed and before test_basic_search_filtering_cached() started. Have tried @runTestsInSeparateProcesses and @runInSeparateProcess but without success.
@georgmaisser may I ask about hint/assistance?

semteacher pushed a commit that referenced this issue Jan 9, 2025
semteacher added a commit that referenced this issue Jan 9, 2025
semteacher pushed a commit that referenced this issue Jan 15, 2025
semteacher added a commit that referenced this issue Jan 15, 2025
semteacher pushed a commit that referenced this issue Jan 16, 2025
semteacher added a commit that referenced this issue Jan 16, 2025
semteacher added a commit that referenced this issue Feb 1, 2025
eynimeni pushed a commit that referenced this issue Feb 18, 2025
eynimeni pushed a commit that referenced this issue Feb 18, 2025
eynimeni pushed a commit that referenced this issue Feb 18, 2025
…atepicker() (#69)

got error
1) local_wunderbyte_table\base_test::test_filter_datepicker
PHPUnit\Framework\Exception: PHP Fatal error:  Uncaught Exception: Serialization of 'PgSql\Connection' is not allowed in Standard input code:87
Stack trace:
#0 Standard input code(87): serialize(Array)
#1 Standard input code(127): __phpunit_run_isolated_test()
#2 {main}
  thrown in Standard input code on line 87
eynimeni pushed a commit that referenced this issue Feb 18, 2025
eynimeni pushed a commit that referenced this issue Feb 18, 2025
semteacher added a commit that referenced this issue Feb 18, 2025
semteacher added a commit that referenced this issue Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: In Progress
Development

No branches or pull requests

2 participants