From 8450ee8c7bd2c4527782172dc8aa44ff1f52c4a1 Mon Sep 17 00:00:00 2001 From: Carsten Agger Date: Mon, 25 Oct 2021 12:58:05 +0200 Subject: [PATCH 1/4] Skeleton for Codeception testing. --- codeception.yml | 10 ++++++++++ tests/_data/.gitkeep | 0 tests/_output/.gitignore | 2 ++ tests/_support/AcceptanceTester.php | 26 ++++++++++++++++++++++++++ tests/_support/FunctionalTester.php | 26 ++++++++++++++++++++++++++ tests/_support/Helper/Acceptance.php | 10 ++++++++++ tests/_support/Helper/Functional.php | 10 ++++++++++ tests/_support/Helper/Unit.php | 10 ++++++++++ tests/_support/UnitTester.php | 26 ++++++++++++++++++++++++++ tests/_support/_generated/.gitignore | 2 ++ tests/acceptance.suite.yml | 13 +++++++++++++ tests/functional.suite.yml | 13 +++++++++++++ tests/unit.suite.yml | 10 ++++++++++ 13 files changed, 158 insertions(+) create mode 100644 codeception.yml create mode 100644 tests/_data/.gitkeep create mode 100644 tests/_output/.gitignore create mode 100644 tests/_support/AcceptanceTester.php create mode 100644 tests/_support/FunctionalTester.php create mode 100644 tests/_support/Helper/Acceptance.php create mode 100644 tests/_support/Helper/Functional.php create mode 100644 tests/_support/Helper/Unit.php create mode 100644 tests/_support/UnitTester.php create mode 100644 tests/_support/_generated/.gitignore create mode 100644 tests/acceptance.suite.yml create mode 100644 tests/functional.suite.yml create mode 100644 tests/unit.suite.yml diff --git a/codeception.yml b/codeception.yml new file mode 100644 index 0000000..f0446cc --- /dev/null +++ b/codeception.yml @@ -0,0 +1,10 @@ +paths: + tests: tests + output: tests/_output + data: tests/_data + support: tests/_support + envs: tests/_envs +actor_suffix: Tester +extensions: + enabled: + - Codeception\Extension\RunFailed diff --git a/tests/_data/.gitkeep b/tests/_data/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/_output/.gitignore b/tests/_output/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/tests/_output/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php new file mode 100644 index 0000000..7359a12 --- /dev/null +++ b/tests/_support/AcceptanceTester.php @@ -0,0 +1,26 @@ + Date: Mon, 25 Oct 2021 13:24:35 +0200 Subject: [PATCH 2/4] Added Hello World test. --- tests/unit/HelloWorldTest.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/unit/HelloWorldTest.php diff --git a/tests/unit/HelloWorldTest.php b/tests/unit/HelloWorldTest.php new file mode 100644 index 0000000..1781a1b --- /dev/null +++ b/tests/unit/HelloWorldTest.php @@ -0,0 +1,29 @@ +assertEquals($one, 1); + $this->assertFalse($one == 2); + // PHP gotcha. + $this->assertTrue(TRUE == 'Hello'); + $this->assertFalse(TRUE === 'World'); + + } +} From aaeb9b6edb7ad8d8868c9ff7312e2fe2eb3cd622 Mon Sep 17 00:00:00 2001 From: Carsten Agger Date: Mon, 25 Oct 2021 13:39:52 +0200 Subject: [PATCH 3/4] Ignore tests/ in code standards checks (for now) --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8d0c9ab..50a6eba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,10 +32,10 @@ install: - npm install --global eslint-config-drupal-bundle stylelint script: -- phpcs --standard=Drupal --ignore=*.md $PROJECT_PATH +- phpcs --standard=Drupal --ignore=tests $PROJECT_PATH - twigcs $PROJECT_PATH - cd $DRUPAL_ROOT/core - eslint $DRUPAL_ROOT/modules/contrib/os2forms_egir - stylelint --aei $DRUPAL_ROOT/modules/contrib/os2forms_egir/**/*.css -- drupal-check $DRUPAL_ROOT/modules/contrib/os2forms_egir +# - drupal-check $DRUPAL_ROOT/modules/contrib/os2forms_egir From 16556f09e63b5a0c989a23a17a9207990757da29 Mon Sep 17 00:00:00 2001 From: Carsten Agger Date: Mon, 25 Oct 2021 14:13:52 +0200 Subject: [PATCH 4/4] Added running of unit tests. --- .travis.yml | 6 ++++-- tests/unit/HelloWorldTest.php | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 50a6eba..4eebaeb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ before_install: - echo "memory_limit=2G" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini install: -- composer global require drush/drush:8.x-dev drupal/coder mglaman/drupal-check friendsoftwig/twigcs +- composer global require drush/drush:8.x-dev drupal/coder mglaman/drupal-check friendsoftwig/twigcs codeception/codeception codeception/module-asserts codeception/module-phpbrowser - export PATH="$HOME/.config/composer/vendor/bin:$PATH" - phpcs --config-set installed_paths ../../drupal/coder/coder_sniffer - phpenv rehash @@ -37,5 +37,7 @@ script: - cd $DRUPAL_ROOT/core - eslint $DRUPAL_ROOT/modules/contrib/os2forms_egir - stylelint --aei $DRUPAL_ROOT/modules/contrib/os2forms_egir/**/*.css -# - drupal-check $DRUPAL_ROOT/modules/contrib/os2forms_egir +- drupal-check $DRUPAL_ROOT/modules/contrib/os2forms_egir +- cd $PROJECT_PATH +- codecept run unit diff --git a/tests/unit/HelloWorldTest.php b/tests/unit/HelloWorldTest.php index 1781a1b..74aee3e 100644 --- a/tests/unit/HelloWorldTest.php +++ b/tests/unit/HelloWorldTest.php @@ -16,7 +16,7 @@ protected function _after() } // tests - public function testSomeFeature() + public function testHelloWorld() { $one = 1; $this->assertEquals($one, 1);