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

[#46508] Skeleton for Codeception testing and Hello World unit test #16

Merged
merged 4 commits into from
Oct 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -32,10 +32,12 @@ 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
- cd $PROJECT_PATH
- codecept run unit

10 changes: 10 additions & 0 deletions codeception.yml
Original file line number Diff line number Diff line change
@@ -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
Empty file added tests/_data/.gitkeep
Empty file.
2 changes: 2 additions & 0 deletions tests/_output/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
26 changes: 26 additions & 0 deletions tests/_support/AcceptanceTester.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php


/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method void pause()
*
* @SuppressWarnings(PHPMD)
*/
class AcceptanceTester extends \Codeception\Actor
{
use _generated\AcceptanceTesterActions;

/**
* Define custom actions here
*/
}
26 changes: 26 additions & 0 deletions tests/_support/FunctionalTester.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php


/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method void pause()
*
* @SuppressWarnings(PHPMD)
*/
class FunctionalTester extends \Codeception\Actor
{
use _generated\FunctionalTesterActions;

/**
* Define custom actions here
*/
}
10 changes: 10 additions & 0 deletions tests/_support/Helper/Acceptance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace Helper;

// here you can define custom actions
// all public methods declared in helper class will be available in $I

class Acceptance extends \Codeception\Module
{

}
10 changes: 10 additions & 0 deletions tests/_support/Helper/Functional.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace Helper;

// here you can define custom actions
// all public methods declared in helper class will be available in $I

class Functional extends \Codeception\Module
{

}
10 changes: 10 additions & 0 deletions tests/_support/Helper/Unit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace Helper;

// here you can define custom actions
// all public methods declared in helper class will be available in $I

class Unit extends \Codeception\Module
{

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


/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method void pause()
*
* @SuppressWarnings(PHPMD)
*/
class UnitTester extends \Codeception\Actor
{
use _generated\UnitTesterActions;

/**
* Define custom actions here
*/
}
2 changes: 2 additions & 0 deletions tests/_support/_generated/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
13 changes: 13 additions & 0 deletions tests/acceptance.suite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Codeception Test Suite Configuration
#
# Suite for acceptance tests.
# Perform tests in browser using the WebDriver or PhpBrowser.
# If you need both WebDriver and PHPBrowser tests - create a separate suite.

actor: AcceptanceTester
modules:
enabled:
- PhpBrowser:
url: http://localhost/myapp
- \Helper\Acceptance
step_decorators: ~
13 changes: 13 additions & 0 deletions tests/functional.suite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Codeception Test Suite Configuration
#
# Suite for functional tests
# Emulate web requests and make application process them
# Include one of framework modules (Symfony2, Yii2, Laravel5, Phalcon4) to use it
# Remove this suite if you don't use frameworks

actor: FunctionalTester
modules:
enabled:
# add a framework module here
- \Helper\Functional
step_decorators: ~
10 changes: 10 additions & 0 deletions tests/unit.suite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Codeception Test Suite Configuration
#
# Suite for unit or integration tests.

actor: UnitTester
modules:
enabled:
- Asserts
- \Helper\Unit
step_decorators: ~
29 changes: 29 additions & 0 deletions tests/unit/HelloWorldTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

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

protected function _before()
{
}

protected function _after()
{
}

// tests
public function testHelloWorld()
{
$one = 1;
$this->assertEquals($one, 1);
$this->assertFalse($one == 2);
// PHP gotcha.
$this->assertTrue(TRUE == 'Hello');
$this->assertFalse(TRUE === 'World');

}
}