Start setup for unit tests.
This commit is contained in:
parent
8487298a1c
commit
a5d02adf1d
|
@ -9,13 +9,39 @@ settings:
|
|||
bootstrap: _bootstrap.php
|
||||
colors: true
|
||||
memory_limit: 1024M
|
||||
error_level: "E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED"
|
||||
extensions:
|
||||
enabled:
|
||||
- Codeception\Extension\RunFailed
|
||||
modules:
|
||||
config:
|
||||
Db:
|
||||
dsn: ''
|
||||
user: ''
|
||||
password: ''
|
||||
dump: tests/_data/dump.sql
|
||||
coverage:
|
||||
enabled: true
|
||||
include:
|
||||
- app/*
|
||||
exclude:
|
||||
# Loaded before tests
|
||||
- app/library/App/Tests/Module.php
|
||||
- app/library/App/Doctrine/EntityManagerFactory.php
|
||||
|
||||
# Not used in entire application
|
||||
- app/library/App/Crypto.php
|
||||
- app/library/App/Messenger
|
||||
- app/library/App/Forms/Element/Recaptcha.php
|
||||
- app/library/App/Paginator/Doctrine.php
|
||||
- app/library/App/Doctrine/Type/*.php
|
||||
- app/library/App/Doctrine/Platform/*.php
|
||||
- app/library/App/Doctrine/Filter/*.php
|
||||
- app/library/App/Doctrine/Paginate/*.php
|
||||
- app/library/App/Radio/Frontend/Shoutcast*.php
|
||||
|
||||
# Used in application, but not used in tests
|
||||
- app/library/App/Doctrine/Logger/EchoSQL.php
|
||||
- app/library/App/Console/Command/*.php
|
||||
- app/**/*.conf.sample.php
|
||||
- app/models/Migration/*
|
||||
- app/locale/**/*
|
||||
- app/locale/*
|
||||
|
||||
# Used in application, but not detected properly by the coverage tool :(
|
||||
- app/**/route.php
|
||||
- app/**/*.conf.php
|
|
@ -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
|
||||
{
|
||||
|
||||
}
|
|
@ -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 \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
|
||||
*
|
||||
* @SuppressWarnings(PHPMD)
|
||||
*/
|
||||
class UnitTester extends \Codeception\Actor
|
||||
{
|
||||
use _generated\UnitTesterActions;
|
||||
|
||||
/**
|
||||
* Define custom actions here
|
||||
*/
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
<?php //[STAMP] eb6a677a9c9f69ac06aca8232c6a74d8
|
||||
<?php //[STAMP] 6a9ca7e4811fbc354c53725a292e8412
|
||||
namespace _generated;
|
||||
|
||||
// This class was automatically generated by build task
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
<?php //[STAMP] af3fbe5984db98c30260344b4f49f0c2
|
||||
namespace _generated;
|
||||
|
||||
// This class was automatically generated by build task
|
||||
// You should not change it manually as it will be overwritten on next build
|
||||
// @codingStandardsIgnoreFile
|
||||
|
||||
use Helper\Unit;
|
||||
|
||||
trait UnitTesterActions
|
||||
{
|
||||
/**
|
||||
* @return \Codeception\Scenario
|
||||
*/
|
||||
abstract protected function getScenario();
|
||||
|
||||
|
||||
}
|
|
@ -13,34 +13,4 @@ modules:
|
|||
depends: \App\Tests\Module
|
||||
- REST:
|
||||
depends: \App\Tests\Module
|
||||
- Cli
|
||||
|
||||
coverage:
|
||||
enabled: true
|
||||
include:
|
||||
- app/*
|
||||
exclude:
|
||||
# Loaded before tests
|
||||
- app/library/App/Tests/Module.php
|
||||
- app/library/App/Doctrine/EntityManagerFactory.php
|
||||
|
||||
# Not used in entire application
|
||||
- app/library/App/Crypto.php
|
||||
- app/library/App/Forms/Element/Recaptcha.php
|
||||
- app/library/App/Paginator/Doctrine.php
|
||||
- app/library/App/Doctrine/Type/*.php
|
||||
- app/library/App/Radio/Frontend/Shoutcast*.php
|
||||
|
||||
# Used in application, but not used in tests
|
||||
- app/library/App/Doctrine/Logger/EchoSQL.php
|
||||
- app/library/App/Console/Command/*.php
|
||||
- app/**/*.conf.sample.php
|
||||
- app/models/Migration/*
|
||||
- app/locale/**/*
|
||||
- app/locale/*
|
||||
|
||||
# Used in application, but not detected properly by the coverage tool :(
|
||||
- app/**/route.php
|
||||
- app/**/*.conf.php
|
||||
|
||||
error_level: "E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED"
|
||||
- Cli
|
|
@ -0,0 +1,6 @@
|
|||
class_name: UnitTester
|
||||
modules:
|
||||
enabled:
|
||||
- \Helper\Unit
|
||||
|
||||
error_level: "E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED"
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
class ExportsTest extends \Codeception\Test\Unit
|
||||
{
|
||||
/**
|
||||
* @var \UnitTester
|
||||
*/
|
||||
protected $tester;
|
||||
|
||||
public function testExports()
|
||||
{
|
||||
$raw_data = [
|
||||
[
|
||||
'test_field_a' => 'Test Field A',
|
||||
'test_field_b' => 'Test Field B',
|
||||
]
|
||||
];
|
||||
|
||||
$csv = \App\Export::csv($raw_data, false);
|
||||
$this->assertContains('"test_field_a","test_field_b"', $csv);
|
||||
|
||||
$raw_data = '<test><subtest>Contents</subtest></test>';
|
||||
$xml_array = \App\Export::xml_to_array($raw_data);
|
||||
|
||||
$this->assertArrayHasKey('test', $xml_array);
|
||||
|
||||
$xml = \App\Export::array_to_xml($xml_array);
|
||||
|
||||
$this->assertContains($raw_data, $xml);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
<?php
|
||||
// Here you can initialize variables that will be available to your tests
|
Loading…
Reference in New Issue