mirror of
https://github.com/Oreolek/kangana.git
synced 2024-06-16 15:01:09 +03:00
Unit tests and sending tasks
This commit is contained in:
parent
36cbc7d6f3
commit
5dc340f056
|
@ -1,8 +1,12 @@
|
|||
language: php
|
||||
php:
|
||||
- "7.0"
|
||||
cache:
|
||||
directories:
|
||||
- vendor
|
||||
before_script:
|
||||
phpenv config-rm xdebug.ini
|
||||
- composer install --prefer-dist
|
||||
- phpenv config-rm xdebug.ini
|
||||
# install CodeSniffer for Kohana Coding Standards checks
|
||||
# - git clone https://github.com/squizlabs/PHP_CodeSniffer.git php-codesniffer --depth=1
|
||||
# Install Kohana Coding Standards
|
||||
|
@ -11,4 +15,5 @@ before_script:
|
|||
# - scripts/phpcs --config-set installed_paths ../kohana-coding-standards
|
||||
script:
|
||||
- find . -name "*.php" -print0 | xargs -0 -n1 -P8 php -l | grep -v '^No syntax errors detected' ; test $? -eq 1
|
||||
# - php-codesniffer/scripts/phpcs -p -s -v -n --standard=Kohana --extensions=php application
|
||||
- vendor/bin/phpunit -c application/tests
|
||||
# - php-codesniffer/scripts/phpcs -p -s -v -n --standard=Kohana --extensions=php application
|
||||
|
|
|
@ -57,8 +57,9 @@ class Task_Prepare extends Minion_Task
|
|||
*
|
||||
* @return null
|
||||
*/
|
||||
protected function _execute(array $params)
|
||||
protected function _execute()
|
||||
{
|
||||
$params = $this->get_options();
|
||||
$db = Database::instance();
|
||||
$db->begin();
|
||||
try
|
||||
|
|
|
@ -16,8 +16,9 @@ class Task_Send extends Minion_Task
|
|||
* @return null
|
||||
* TODO: group by letters and send them using Bcc instead of one at a time
|
||||
*/
|
||||
protected function _execute(array $params)
|
||||
protected function _execute()
|
||||
{
|
||||
$params = $this->get_options();
|
||||
$db = Database::instance();
|
||||
$db->begin();
|
||||
try
|
||||
|
|
|
@ -15,37 +15,48 @@ class CoursesTest extends Unittest_Database_TestCase
|
|||
return $this->createXMLDataSet(Kohana::find_file('tests', 'test_data/courses', 'xml'));
|
||||
}
|
||||
|
||||
public function get_setup_operation()
|
||||
{
|
||||
// whether you want cascading truncates
|
||||
// set false if unsure
|
||||
$cascade_truncates = false;
|
||||
|
||||
return new PHPUnit_Extensions_Database_Operation_Composite(array(
|
||||
new PHPUnit_Extensions_Database_Operation_MySQL55Truncate($cascade_truncates),
|
||||
PHPUnit_Extensions_Database_Operation_Factory::INSERT()
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group Mail
|
||||
**/
|
||||
function test_prepare_course()
|
||||
{
|
||||
Minion_Task::factory(array('task' => 'prepare'))->execute();
|
||||
$status = DB::select('status')->from('tasks')->where('letter_id', '=', '1')->and_where('client_id','=','1')->execute()->get('status');
|
||||
DB::delete('tasks')
|
||||
->where('letter_id', '=', 1)
|
||||
->and_where('client_id','=',1)
|
||||
->execute();
|
||||
Minion_Task::factory(['prepare'])
|
||||
->execute();
|
||||
$status = DB::select('status')
|
||||
->from('tasks')
|
||||
->where('letter_id', '=', 1)
|
||||
->and_where('client_id','=',1)
|
||||
->execute()
|
||||
->get('status');
|
||||
$this->assertEquals(Model_Task::STATUS_PENDING, $status);
|
||||
}
|
||||
|
||||
function test_send_course()
|
||||
{
|
||||
$status = DB::select('status')->from('tasks')->where('letter_id', '=', '1')->and_where('client_id','=','1')->execute()->get('status');
|
||||
if (is_null($status))
|
||||
$status = DB::select('status')
|
||||
->from('tasks')
|
||||
->where('letter_id', '=', 1)
|
||||
->and_where('client_id','=',1)
|
||||
->execute()
|
||||
->get('status');
|
||||
if (is_null($status) or $status !== Model_Task::STATUS_PENDING)
|
||||
{
|
||||
DB::insert('tasks', array('letter_id', 'client_id', 'date', 'status'))->values(array('1','1',date('Y-m-d'), Model_Task::STATUS_PENDING))->execute();
|
||||
DB::insert('tasks', array('letter_id', 'client_id', 'date', 'status'))
|
||||
->values(array(1,1,date('Y-m-d'), Model_Task::STATUS_PENDING))
|
||||
->execute();
|
||||
}
|
||||
Minion_Task::factory(array('task' => 'send'))->execute();
|
||||
$status = DB::select('status')->from('tasks')->where('letter_id', '=', '1')->and_where('client_id','=','1')->execute()->get('status');
|
||||
Minion_Task::factory(['send'])
|
||||
->execute();
|
||||
$status = DB::select('status')
|
||||
->from('tasks')
|
||||
->where('letter_id', '=', 1)
|
||||
->and_where('client_id','=',1)
|
||||
->execute()
|
||||
->get('status');
|
||||
$this->assertEquals(Model_Task::STATUS_SENT, $status);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,3 @@
|
|||
<?php
|
||||
require_once '../../modules/unittest/bootstrap.php';
|
||||
class PHPUnit_Extensions_Database_Operation_MySQL55Truncate extends PHPUnit_Extensions_Database_Operation_Truncate
|
||||
{
|
||||
public function execute(PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection, PHPUnit_Extensions_Database_DataSet_IDataSet $data_set)
|
||||
{
|
||||
$connection->getConnection()->query("SET @PHAKE_PREV_foreign_key_checks = @@foreign_key_checks");
|
||||
$connection->getConnection()->query("SET foreign_key_checks = 0");
|
||||
parent::execute($connection, $data_set);
|
||||
$connection->getConnection()->query("SET foreign_key_checks = @PHAKE_PREV_foreign_key_checks");
|
||||
}
|
||||
}
|
||||
$vendor_path = 'vendor/';
|
||||
require_once 'vendor/kohana/unittest/bootstrap.php';
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<phpunit colors="true" bootstrap="./bootstrap.php">
|
||||
<testsuites>
|
||||
<testsuite name="Application Tests">
|
||||
<file>../../modules/unittest/tests.php</file>
|
||||
<file>CoursesTest.php</file>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<groups>
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
"require-dev": {
|
||||
"phing/phing": "dev-master",
|
||||
"kohana/unittest": "3.4.*",
|
||||
"phpunit/dbunit": ">=1.2",
|
||||
"kohana/userguide": "3.4.*",
|
||||
"kohana/coding-standards": "*"
|
||||
},
|
||||
|
|
83
composer.lock
generated
83
composer.lock
generated
|
@ -4,8 +4,8 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"hash": "3fb8fd5b0f087861ad3c0a1e03f59d52",
|
||||
"content-hash": "e508757e467a827fae945dd82d99f251",
|
||||
"hash": "0295e4c854e48a9ec363ef38f3e8a912",
|
||||
"content-hash": "40b364e8231443d0204b42349ef17ef2",
|
||||
"packages": [
|
||||
{
|
||||
"name": "composer/installers",
|
||||
|
@ -1261,20 +1261,20 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phingofficial/phing.git",
|
||||
"reference": "a7c32b2daa5e4e5a9de6f79ad2351daa5e2d1ace"
|
||||
"reference": "3fc2648716aba899dfcbda94f2eb609443a088a1"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phingofficial/phing/zipball/a7c32b2daa5e4e5a9de6f79ad2351daa5e2d1ace",
|
||||
"reference": "a7c32b2daa5e4e5a9de6f79ad2351daa5e2d1ace",
|
||||
"url": "https://api.github.com/repos/phingofficial/phing/zipball/3fc2648716aba899dfcbda94f2eb609443a088a1",
|
||||
"reference": "3fc2648716aba899dfcbda94f2eb609443a088a1",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.2.0"
|
||||
"php": ">=5.2.0",
|
||||
"symfony/yaml": "^3.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-pdo_sqlite": "*",
|
||||
"lastcraft/simpletest": "@dev",
|
||||
"mikey179/vfsstream": "^1.6",
|
||||
"pdepend/pdepend": "2.x",
|
||||
"pear/archive_tar": "1.4.x",
|
||||
|
@ -1290,8 +1290,8 @@
|
|||
"sebastian/git": "~1.0",
|
||||
"sebastian/phpcpd": "2.x",
|
||||
"siad007/versioncontrol_hg": "^1.0",
|
||||
"squizlabs/php_codesniffer": "~2.2",
|
||||
"symfony/yaml": "~2.7"
|
||||
"simpletest/simpletest": "^1.1",
|
||||
"squizlabs/php_codesniffer": "~2.2"
|
||||
},
|
||||
"suggest": {
|
||||
"pdepend/pdepend": "PHP version of JDepend",
|
||||
|
@ -1346,7 +1346,7 @@
|
|||
"task",
|
||||
"tool"
|
||||
],
|
||||
"time": "2016-10-21 09:54:47"
|
||||
"time": "2016-11-10 11:10:29"
|
||||
},
|
||||
{
|
||||
"name": "phpdocumentor/reflection-common",
|
||||
|
@ -1557,6 +1557,61 @@
|
|||
],
|
||||
"time": "2016-10-02 13:12:17"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/dbunit",
|
||||
"version": "dev-master",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/dbunit.git",
|
||||
"reference": "38f88a393cbdb50c78287a7b84dc1439a3afa518"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/dbunit/zipball/38f88a393cbdb50c78287a7b84dc1439a3afa518",
|
||||
"reference": "38f88a393cbdb50c78287a7b84dc1439a3afa518",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-pdo": "*",
|
||||
"ext-simplexml": "*",
|
||||
"php": ">=5.4",
|
||||
"phpunit/phpunit": "~4|~5",
|
||||
"symfony/yaml": "~2.1|~3.0"
|
||||
},
|
||||
"bin": [
|
||||
"dbunit"
|
||||
],
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sb@sebastian-bergmann.de",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"description": "DbUnit port for PHP/PHPUnit to support database interaction testing.",
|
||||
"homepage": "https://github.com/sebastianbergmann/dbunit/",
|
||||
"keywords": [
|
||||
"database",
|
||||
"testing",
|
||||
"xunit"
|
||||
],
|
||||
"time": "2016-08-18 09:31:47"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-code-coverage",
|
||||
"version": "2.2.x-dev",
|
||||
|
@ -2381,12 +2436,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/yaml.git",
|
||||
"reference": "3d42c56f989688ad0790dcdc3c706d60748af6a6"
|
||||
"reference": "e0c8bd45fdab197ccdd4723125e4ed424f54288d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/yaml/zipball/3d42c56f989688ad0790dcdc3c706d60748af6a6",
|
||||
"reference": "3d42c56f989688ad0790dcdc3c706d60748af6a6",
|
||||
"url": "https://api.github.com/repos/symfony/yaml/zipball/e0c8bd45fdab197ccdd4723125e4ed424f54288d",
|
||||
"reference": "e0c8bd45fdab197ccdd4723125e4ed424f54288d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2428,7 +2483,7 @@
|
|||
],
|
||||
"description": "Symfony Yaml Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2016-10-21 21:10:51"
|
||||
"time": "2016-11-06 16:24:48"
|
||||
},
|
||||
{
|
||||
"name": "webmozart/assert",
|
||||
|
|
Loading…
Reference in a new issue