6 Commits
0.0.8 ... 0.0.9

Author SHA1 Message Date
Meritoo
e902568a91 Participant & Survey - update creating instance od DateTime from string 2017-10-22 18:20:01 +02:00
Meritoo
626174953b Participant has completed survey - fix getting proper information 2017-10-22 18:18:16 +02:00
Meritoo
ddb568adf7 Tests - Docker - update Xdebug configuration
Required to fix problem "Connection with XDebug 2.5.1 was not established. Validate installation."
2017-10-22 17:56:24 +02:00
Meritoo
835c4325b8 Tests - missing description of method 2017-10-19 21:57:35 +02:00
Meritoo
24a3d478b5 Tests - use Docker (as environment guard) 2017-10-19 21:44:25 +02:00
Meritoo
e38df1a8f2 Start names of special directories with dot 2017-10-18 21:21:53 +02:00
16 changed files with 130 additions and 24 deletions

64
.docker/config/Dockerfile Normal file
View File

@@ -0,0 +1,64 @@
FROM php:5.6-cli
#
# Tools & libraries
#
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
vim \
git \
zip \
unzip \
zlib1g-dev \
libicu-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
#
# PHP extensions
#
RUN docker-php-ext-install \
zip \
intl \
mbstring
#
# PHP configuration:
# - default configuration
# - timezone
#
COPY php.ini /usr/local/etc/php/php.ini
ARG TIMEZONE
RUN echo "\n""date.timezone = $TIMEZONE""\n" >> /usr/local/etc/php/php.ini
#
# Xdebug
#
RUN pecl install xdebug \
&& docker-php-ext-enable xdebug
COPY xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
#
# Phing
#
RUN pear channel-discover pear.phing.info \
&& pear install [--alldeps] phing/phing
#
# Composer + https://packagist.org/packages/hirak/prestissimo package
#
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
&& php -r "if (hash_file('SHA384', 'composer-setup.php') === \
'544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo \
'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" \
&& php composer-setup.php --install-dir=/usr/local/bin --filename=composer \
&& php -r "unlink('composer-setup.php');" \
&& composer global require --no-plugins --no-scripts hirak/prestissimo \
&& rm -rf /root/.composer/cache/*
#
# Bash
#
RUN sed -i 's/^# export/export/g' /root/.bashrc \
&& sed -i 's/^# alias/alias/g' /root/.bashrc \
&& echo "\n"'export PATH=/project/vendor/bin:$PATH'"\n" >> /root/.bashrc

3
.docker/config/php.ini Normal file
View File

@@ -0,0 +1,3 @@
display_errors = On
display_startup_errors = On
error_reporting = E_ALL

View File

@@ -0,0 +1,6 @@
[xdebug]
zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_port=9001
xdebug.remote_host=10.254.254.254

1
.env Normal file
View File

@@ -0,0 +1 @@
TIMEZONE=Europe/Warsaw

10
.gitignore vendored
View File

@@ -17,7 +17,7 @@
# ---------------------------------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------------------------------
### Phing ### Phing
# ---------------------------------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------------------------------
/phing/properties /.phing/properties
# ---------------------------------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------------------------------
### PHPUnit ### PHPUnit
@@ -29,10 +29,16 @@
# ---------------------------------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------------------------------
/.php_cs.cache /.php_cs.cache
# ----------------------------------------------------------------------------------------------------------------------
### Build files
# ----------------------------------------------------------------------------------------------------------------------
/.build/
# ---------------------------------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------------------------------
### Generated databases ### Generated databases
# ---------------------------------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------------------------------
/data/tmp /.data/tmp
*.sql *.sql
*.sqlite *.sqlite

View File

@@ -2,12 +2,12 @@
<project name="Meritoo Package" basedir="." default="build:main" phingVersion="2.14.0"> <project name="Meritoo Package" basedir="." default="build:main" phingVersion="2.14.0">
<!-- Properties --> <!-- Properties -->
<if> <if>
<available file="phing/properties" property="custom.properties.available"/> <available file=".phing/properties" property="custom.properties.available"/>
<then> <then>
<property file="phing/properties" /> <property file=".phing/properties" />
</then> </then>
<else> <else>
<property file="phing/properties.dist" /> <property file=".phing/properties.dist" />
</else> </else>
</if> </if>

View File

@@ -59,7 +59,7 @@ composer.validate = false
# System directories # System directories
# #
dir.data = ${project.basedir}/data dir.data = ${project.basedir}/.data
dir.src = ${project.basedir}/src dir.src = ${project.basedir}/src
dir.tests = ${project.basedir}/tests dir.tests = ${project.basedir}/tests
@@ -67,7 +67,7 @@ dir.tests = ${project.basedir}/tests
# Build directories # Build directories
# -------------------------------------------------------------------------------- # --------------------------------------------------------------------------------
dir.build = ${project.basedir}/build dir.build = ${project.basedir}/.build
dir.reports = ${dir.build}/logs dir.reports = ${dir.build}/logs
dir.reports.pdepend = ${dir.reports}/pdepend dir.reports.pdepend = ${dir.reports}/pdepend
dir.reports.coverage = ${dir.reports}/phpunit_coverage dir.reports.coverage = ${dir.reports}/phpunit_coverage

View File

@@ -11,12 +11,12 @@
<!-- Properties --> <!-- Properties -->
<if> <if>
<available file="phing/properties" property="custom.properties.available"/> <available file=".phing/properties" property="custom.properties.available"/>
<then> <then>
<property file="phing/properties" /> <property file=".phing/properties" />
</then> </then>
<else> <else>
<property file="phing/properties.dist" /> <property file=".phing/properties.dist" />
</else> </else>
</if> </if>

View File

@@ -2,12 +2,12 @@
<project name="Meritoo Package" basedir="." default="build:main" phingVersion="2.14.0"> <project name="Meritoo Package" basedir="." default="build:main" phingVersion="2.14.0">
<!-- Properties --> <!-- Properties -->
<if> <if>
<available file="phing/properties" property="custom.properties.available"/> <available file=".phing/properties" property="custom.properties.available"/>
<then> <then>
<property file="phing/properties" /> <property file=".phing/properties" />
</then> </then>
<else> <else>
<property file="phing/properties.dist" /> <property file=".phing/properties.dist" />
</else> </else>
</if> </if>
@@ -18,12 +18,12 @@
<!-- Build app --> <!-- Build app -->
<target name="build:app" description="Prepares app to build and tests"> <target name="build:app" description="Prepares app to build and tests">
<phing phingfile="phing/app.xml" haltonfailure="true" /> <phing phingfile=".phing/app.xml" haltonfailure="true" />
</target> </target>
<!-- Build tests --> <!-- Build tests -->
<target name="build:tests" description="Runs all tests, checks and creates docs"> <target name="build:tests" description="Runs all tests, checks and creates docs">
<phing phingfile="phing/tests.xml" haltonfailure="true" /> <phing phingfile=".phing/tests.xml" haltonfailure="true" />
<!-- <!--
Conditional running of tests. Conditional running of tests.
@@ -35,7 +35,7 @@
<if> <if>
<equals arg1="${env}" arg2="test" /> <equals arg1="${env}" arg2="test" />
<then> <then>
<phing phingfile="phing/tests.xml" haltonfailure="true" /> <phing phingfile=".phing/tests.xml" haltonfailure="true" />
</then> </then>
<else> <else>
<echo message="[Skipped] Running tests, checks and creating docs, because it's a not 'test' environment..." /> <echo message="[Skipped] Running tests, checks and creating docs, because it's a not 'test' environment..." />

View File

@@ -3,7 +3,7 @@
"description": "Client of LimeSurvey API", "description": "Client of LimeSurvey API",
"type": "library", "type": "library",
"license": "MIT", "license": "MIT",
"version": "0.0.8", "version": "0.0.9",
"authors": [ "authors": [
{ {
"name": "Meritoo", "name": "Meritoo",
@@ -11,6 +11,7 @@
} }
], ],
"require": { "require": {
"php": ">=5.6",
"fguillot/json-rpc": "^1.2", "fguillot/json-rpc": "^1.2",
"meritoo/common-library": "~0.0.1" "meritoo/common-library": "~0.0.1"
}, },

15
docker-compose.yml Normal file
View File

@@ -0,0 +1,15 @@
version: '3'
services:
php-cli:
image: meritoo/limesurvey-api-client
container_name: meritoo-limesurvey-api-client
working_dir: /project
entrypoint: php
command: -S 0.0.0.0:9999
build:
context: ./.docker/config
args:
- TIMEZONE=$TIMEZONE
volumes:
- .:/project

View File

@@ -30,6 +30,6 @@
</groups> </groups>
<logging> <logging>
<log type="coverage-html" target="./build/logs/phpunit_coverage/html" /> <log type="coverage-html" target="./.build/logs/phpunit_coverage/html" />
</logging> </logging>
</phpunit> </phpunit>

View File

@@ -199,7 +199,12 @@ class Participant extends BaseItem
break; break;
case 'completed': case 'completed':
$this->completed = 'Y' === trim(strtoupper($value)); if ('N' === trim(strtoupper($value))) {
$this->completed = false;
break;
}
$this->completed = Date::isValidDate($value, true);
break; break;
case 'usesleft': case 'usesleft':
@@ -211,7 +216,7 @@ class Participant extends BaseItem
break; break;
} }
$this->validFrom = Date::getDateTime($value, false, 'Y-m-d H:i:s'); $this->validFrom = Date::getDateTime($value, true);
break; break;
case 'validuntil': case 'validuntil':
@@ -219,7 +224,7 @@ class Participant extends BaseItem
break; break;
} }
$this->validUntil = Date::getDateTime($value, false, 'Y-m-d H:i:s'); $this->validUntil = Date::getDateTime($value, true);
break; break;
} }
} }

View File

@@ -74,7 +74,7 @@ class Survey extends BaseItem
break; break;
} }
$this->startsAt = Date::getDateTime($value, false, 'Y-m-d H:i:s'); $this->startsAt = Date::getDateTime($value, true);
break; break;
case 'expires': case 'expires':
@@ -82,7 +82,7 @@ class Survey extends BaseItem
break; break;
} }
$this->expiresAt = Date::getDateTime($value, false, 'Y-m-d H:i:s'); $this->expiresAt = Date::getDateTime($value, true);
break; break;
case 'active': case 'active':

View File

@@ -38,6 +38,11 @@ class MissingParticipantOfSurveyExceptionTest extends BaseTestCase
static::assertEquals($expectedMessage, $exception->getMessage()); static::assertEquals($expectedMessage, $exception->getMessage());
} }
/**
* Provides ID of survey and e-mail address of the participant
*
* @return Generator
*/
public function provideSurveyIdAndEmail() public function provideSurveyIdAndEmail()
{ {
$template = 'Participant with e-mail %s of survey with ID %s is missing. Maybe was not added to the survey?'; $template = 'Participant with e-mail %s of survey with ID %s is missing. Maybe was not added to the survey?';

View File

@@ -200,7 +200,7 @@ class ParticipantTest extends BaseTestCase
'sent' => 'Y', 'sent' => 'Y',
'remindersent' => 'N', 'remindersent' => 'N',
'remindercount' => 1, 'remindercount' => 1,
'completed' => 'Y', 'completed' => (new DateTime())->format('Y-m-d H:i'),
'usesleft' => 5, 'usesleft' => 5,
'validfrom' => (new DateTime())->format('Y-m-d H:i:s'), 'validfrom' => (new DateTime())->format('Y-m-d H:i:s'),
'validuntil' => null, 'validuntil' => null,