Skip to content

Commit

Permalink
Behat tests.
Browse files Browse the repository at this point in the history
* Added behat tests
* Fixed methods after tests
* Skiped tests on windows
* Disabled behat on appveyor
* Testing new phpspec/phpspec
  • Loading branch information
kuczek committed Mar 18, 2016
1 parent ba26bb8 commit b86736c
Show file tree
Hide file tree
Showing 79 changed files with 1,783 additions and 322 deletions.
16 changes: 16 additions & 0 deletions .phpspec/class.tpl
@@ -0,0 +1,16 @@
<?php

/**
* @author Krystian Kuczek <krystian@hexmedia.pl>
* @copyright 2013-2016 Hexmedia.pl
* @license @see LICENSE
*/%namespace_block%

/**
* Class Application
*
* @package %namespace%
*/
class %name%
{
}
1 change: 1 addition & 0 deletions .sensiolabs.yml
@@ -1,6 +1,7 @@
global_exclude_dirs:
- vendor
- Tests
- src-dev

rules:
git.user_specific_ignored_file:
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -29,7 +29,6 @@ matrix:
allow_failures:
- env: DEPS='dev'
- php: nightly
- php: 7.0

before_install:
- if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then cat $HOME/.phpenv/versions/$TRAVIS_PHP_VERSION/etc/conf.d/xdebug.ini > ./xdebug.ini ; fi
Expand All @@ -45,6 +44,7 @@ before_install:
- echo '#!/bin/bash' > install.sh
- echo -n "composer update" >> install.sh
- echo -n " --prefer-dist" >> install.sh
- 'if [ "$TRAVIS_PHP_VERSION" == "7.0" ] || [ "$TRAVIS_PHP_VERSION" == "nightly" ]; then cat composer.json | sed -e "$(cat composer.json | grep -n "phpspec/phpspec\": \"~2.4\"" | cut -f1 -d:)s/.*/\"phpspec\/phpspec\": \"~2.5@dev\",/" > crontab.json; fi'
- if [ "$DEPS" == "low" ]; then echo -n " --prefer-lowest" >> install.sh; fi;
- if [ "$DEPS" == "normal" ]; then echo -n " --prefer-stable" >> install.sh; fi;
- sed -n '/prefer-stable/!p' composer.json > tmp.json && mv tmp.json composer.json;
Expand Down
23 changes: 14 additions & 9 deletions TODO.md
@@ -1,19 +1,24 @@
Tests:
------
* Configure at least one osx(travis) environment to test if it is working on osx.

This version
------------
* System reader should also use factory.
* Read should be done always via System/*.php (eg. for Unix System/Unix.php)
* Configure at least one osx(travis) environment to test if it is working on osx.
* Readers needs to be checked and refactored
* Check names of all systems that should be supported. All Unix like.
* Add phpspec to existing commands
* Add specs to existing commands
* Try integration with Symfony CrontabBundle. This will need some commands to be rewritten
* Write behat tests
* Unify exception names.
* Change beforeComment to comment
* Add protection for special strings in unix, if they exists, this should not work.

Next Versions
------------
* support for windows Tasks (more info: http://stackoverflow.com/questions/132971/what-is-the-windows-version-of-cron, https://msdn.microsoft.com/en-us/library/windows/desktop/bb736357(v=vs.85).aspx)
* support for special strings in unix cron (only reading will be enough i think), and possibility to setup cron for startup.
* create comment object that can be added to task or variable
-------------
* support for special strings in unix cron, and possibility to setup cron for startup.
* support for comments in variables, currently, all comments between variables will be ignored, and removed.
* Why appveyor is not resulting in error after runing travis
* add support for importing tasks from crontab to file, should be interactive command.

In future
---------
* support for windows Tasks (more info: http://stackoverflow.com/questions/132971/what-is-the-windows-version-of-cron, https://msdn.microsoft.com/en-us/library/windows/desktop/bb736357(v=vs.85).aspx)
3 changes: 3 additions & 0 deletions Tests/example_configurations/empty.xml
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<tasks>
</tasks>
8 changes: 8 additions & 0 deletions Tests/example_configurations/test.ini
Expand Up @@ -22,3 +22,11 @@ machine = www103
variables.MAILTO = test@test.com
variables.NO_VALIDATE = true

[command_without_log_file]
command = ./some/command_without_log_file
minute = *
hour = *
day_of_month = *
day_of_week = *
month = *
machine = www103
27 changes: 19 additions & 8 deletions Tests/example_configurations/test.json
@@ -1,29 +1,40 @@
{
"s3_synchronize": {
"command": "mwe:photo:s3 asgasg afasf",
"command1": {
"command": "./some/command1",
"minute": "*/13",
"hour": "*",
"day_of_month": "*",
"day_of_week": "*",
"month": "*",
"log_file": "./logs/schema_validate.log",
"log_file": "./logs/some_log1.log",
"machine": "www*",
"comment": "this is some comment for this crontab",
"variables": {
"MAILTO": "k.kuczek@tvn.pl"
"MAILTO": "test@test.pl"
}
},
"s3_synchronize2": {
"command": "mwe:photo:s3 asgasg afasf",
"command2": {
"command": "./some/command2",
"minute": "*",
"hour": "*",
"day_of_month": "*",
"day_of_week": "*",
"month": "*",
"log_file": "./logs/schema_validate.log",
"log_file": "./logs/some_log2.log",
"machine": "www103",
"variables": {
"MAILTO": "j.zieba@tvn.pl"
"MAILTO": "test@test.com",
"NO_VALIDATE": true
}
},
"command_without_log_file": {
"command": "./some/command_without_log_file",
"minute": "*",
"hour": "*",
"day_of_month": "*",
"day_of_week": "*",
"month": "*",
"machine": "www103"
}
}

29 changes: 21 additions & 8 deletions Tests/example_configurations/test.xml
@@ -1,30 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<tasks>
<task>
<name>s3_synchornize</name>
<command>mwe:photo:s3 asgasg afasf</command>
<name>command1</name>
<command>./some/command1</command>
<minute>*/13</minute>
<hour>*</hour>
<dayOfWeek>*</dayOfWeek>
<dayOfMonth>*</dayOfMonth>
<month>*</month>
<logFile>./logs/schema_validate.log</logFile>
<logFile>./logs/some_log1.log</logFile>
<machine>www*</machine>
<comment>this is some comment for this crontab</comment>
<variables>
<variable name="MAILTO">k.kuczek@tvn.pl</variable>
<variable name="MAILTO">test@test.pl</variable>
</variables>
</task>
<task>
<name>s3_synchornize2</name>
<command>mwe:photo:s3 asgasg afasf</command>
<name>command2</name>
<command>./some/command2</command>
<minute>*</minute>
<hour>*</hour>
<dayOfWeek>*</dayOfWeek>
<dayOfMonth>*</dayOfMonth>
<month>*</month>
<logFile>./logs/schema_validate.log</logFile>
<logFile>./logs/some_log2.log</logFile>
<machine>www103</machine>
<variables>
<variable name="MAILTO">j.zieba@tvn.pl</variable>
<variable name="MAILTO">test@test.com</variable>
<variable name="NO_VALIDATE">1</variable>
</variables>
</task>
<task>
<name>command_without_log_file</name>
<command>./some/command_without_log_file</command>
<minute>*</minute>
<hour>*</hour>
<dayOfWeek>*</dayOfWeek>
<dayOfMonth>*</dayOfMonth>
<month>*</month>
<machine>www103</machine>
</task>
</tasks>
Expand Up @@ -22,4 +22,12 @@ command2:
variables:
MAILTO: test@test.com
NO_VALIDATE: true
command_without_log_file:
command: "./some/command_without_log_file"
minute: '*'
hour: '*'
day_of_month: '*'
day_of_week: '*'
month: '*'
machine: www103

29 changes: 29 additions & 0 deletions Tests/features/echo.feature
@@ -0,0 +1,29 @@
Feature: Echoing crontab
As a Developer
I want to echo crontab from app
#
# Scenario:
# When I run echo command with ini type
# Then The exit code should be 0
# And The display should contain:
# """
#Your crontab will look like:
##WARNING!!!
##This crontab file it at least partially managed by Crontab by Hexmedia, please check all restrictions that comes with that library at: https://github.com/Hexmedia/Crontab/blob/master/README.md
##EOT
#
#
#
## ------------ CURRENTLY MANAGED by Test --------------
#
##DO NOT MODIFY! This task is managed by Crontab library by Hexmedia 0cbc6611f5341b9a85da40865f5647c
##
#MAILTO=test@test.pl
#*/13 * * * * ./some/command1 > ./logs/some_log1.log
##DO NOT MODIFY! This task is managed by Crontab library by Hexmedia 0cbc6611f5f6034d349bc599edc77a3
##
#MAILTO=test@test.com
#NO_VALIDATE=1
#* * * * * ./some/command2 > ./logs/some_log2.log
# """
#

0 comments on commit b86736c

Please sign in to comment.