Skip to content

Commit

Permalink
Add a basic test
Browse files Browse the repository at this point in the history
  • Loading branch information
joecorall committed Nov 17, 2024
1 parent 365fa8d commit 38576fe
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

- name: lint+test
working-directory: ci
run: docker compose up -d --quiet-pull
run: docker compose up --quiet-pull
env:
PHP_VERSION: ${{ matrix.php-version }}
DRUPAL_VERSION: ${{ matrix.drupal-version }}
20 changes: 20 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "drupal/turnstile_protect",
"description": "Put your site routes behind a Cloudflare Turnstile",
"type": "drupal-module",
"license": "GPL-2.0+",
"homepage": "https://www.drupal.org/project/turnstile_protect",
"support": {
"issues": "https://www.drupal.org/project/issues/turnstile_protect"
},
"authors": [
{
"name": "Joe Corall",
"email": "[email protected]",
"role": "Owner"
}
],
"require" : {
"drupal/turnstile": "^1"
}
}
39 changes: 39 additions & 0 deletions tests/src/Kernel/TurnstileProtectTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace Drupal\Tests\turnstile_protect\Kernel;

use Drupal\KernelTests\KernelTestBase;

/**
* Tests basic functionality of the YourModule module.
*
* @group turnstile_protect
*/
class TurnstileProtectTest extends KernelTestBase {

/**
* {@inheritdoc}
*/
protected static $modules = [
'turnstile_protect',
'system',
];

/**
* Tests if the module is enabled.
*/
public function testModuleEnabled() {
\Drupal::messenger()->addStatus("OK");
$this->assertTrue($this->container->get('module_handler')->moduleExists('turnstile_protect'), 'The turnstile_protect module is enabled.');
}

/**
* Tests basic configuration or service.
*/
public function testBasicFunctionality() {
// Example: Check a service or configuration provided by your module.
$config = $this->config('turnstile_protect.settings');
$this->assertNotEmpty($config, 'turnstile_protect settings configuration is available.');
}

}

0 comments on commit 38576fe

Please sign in to comment.