Skip to content

Commit

Permalink
Add Drupal support in Codeception, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
agger-magenta committed Oct 26, 2021
1 parent 422ef63 commit 01b23ed
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
# Ignore composer.lock & vendor/
composer.lock
vendor/

# Ignore Vim swap files.
*.swp
5 changes: 5 additions & 0 deletions codeception.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ paths:
data: tests/_data
support: tests/_support
envs: tests/_envs
settings:
lint: true
report_useless_tests: true
actor_suffix: Tester
extensions:
enabled:
- Codeception\Extension\RunFailed
coverage:
enabled: true
5 changes: 4 additions & 1 deletion tests/unit.suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ modules:
enabled:
- Asserts
- \Helper\Unit
step_decorators: ~
- \Codeception\Module\Drupal8\Drupal8:
root: /opt/drupal/web
relative: no
step_decorators: ~
43 changes: 43 additions & 0 deletions tests/unit/GIRUtilsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

use Drupal\user\Entity\User;

use Drupal\os2forms_egir\GIRUtils;


class GIRUtilsTest extends \Codeception\Test\Unit
{
/**
* @var \UnitTester
*/
protected $tester;

protected function _before()
{
}

protected function _after()
{
}

// tests
public function testGetUserData()
{
$language = \Drupal::languageManager()->getCurrentLanguage()->getId();

$user = \Drupal\user\Entity\User::create();
$user->enforceIsNew();
$user->setPassword('password');
$user->setEmail('[email protected]');
$user->setUsername('egir5');
$user->set("init", 'mail');
$user->set("langcode", $language);
$user->set("preferred_langcode", $language);
$user->set("preferred_admin_langcode", $language);
$user->activate();
$user->save();
$name = $user->email; // GIRUtils::getUserData('egir', 'name');
$this->assertEquals($name, '');

}
}
13 changes: 13 additions & 0 deletions tests/unit/WebformHandlerCest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

class WebformHandlerCest
{
public function _before(UnitTester $I)
{
}

// tests
public function tryToTest(UnitTester $I)
{
}
}

0 comments on commit 01b23ed

Please sign in to comment.