diff --git a/.docker/config/Dockerfile b/.docker/config/Dockerfile deleted file mode 100644 index 13802c4..0000000 --- a/.docker/config/Dockerfile +++ /dev/null @@ -1,64 +0,0 @@ -FROM php:5.5-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 diff --git a/.env b/.env index c6eb126..c493cdb 100644 --- a/.env +++ b/.env @@ -1 +1,15 @@ +# ----------------------------------------------------------------------------- +### Docker +# ----------------------------------------------------------------------------- + +# +# All containers +# +DOCKER_CONTAINER_OWNER=meritoo +DOCKER_CONTAINER_PROJECT=limesurvey-api-client + +# +# PHP configuration: +# - timezone +# TIMEZONE=Europe/Warsaw diff --git a/.gitignore b/.gitignore index 5a8bdc3..a5199ef 100644 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,7 @@ # ---------------------------------------------------------------------------------------------------------------------- ### Phing # ---------------------------------------------------------------------------------------------------------------------- -/.phing/properties +/phing/properties # ---------------------------------------------------------------------------------------------------------------------- ### PHPUnit diff --git a/.phing/app.xml b/.phing/app.xml deleted file mode 100644 index 028fe2b..0000000 --- a/.phing/app.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/.phing/tests.xml b/.phing/tests.xml deleted file mode 100644 index 4567626..0000000 --- a/.phing/tests.xml +++ /dev/null @@ -1,315 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/README.md b/README.md index 8b6a233..a88c205 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,18 @@ Run [Composer](https://getcomposer.org) to install this package in your project: > How to install Composer: https://getcomposer.org/download +## Configuration of LimeSurvey + +1. Login to the LimeSurvey administration, e.g. using https://your-domain/admin address +2. Go to menu: `Configuration` -> `Global settings` +3. Open `Interfaces` tab +4. For `RPC interface enabled` select `JSON-RPC` option +5. Enable `Publish API on /admin/remotecontrol` option + +It should look like here: +![Configuration of LimeSurvey](http://www.meritoo.pl/packages/github/limesurvey-api-client/readme/configuration-interfaces.png) +More information: https://manual.limesurvey.org/RemoteControl_2_API#Introduction + ## Usage 1. First of all you have to prepare configuration of connection and create instance of a client: diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..6e8bf73 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.1.0 diff --git a/build.xml b/build.xml index fccc179..50088c8 100644 --- a/build.xml +++ b/build.xml @@ -2,40 +2,40 @@ - + - + - + + description="Builds everything and runs all tests"/> - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/phing/filesets.xml b/phing/filesets.xml new file mode 100644 index 0000000..13dcb7f --- /dev/null +++ b/phing/filesets.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/.phing/properties.dist b/phing/properties.dist similarity index 58% rename from .phing/properties.dist rename to phing/properties.dist index 992dbb6..eb4b0db 100644 --- a/.phing/properties.dist +++ b/phing/properties.dist @@ -9,7 +9,7 @@ # not special chars. This way you can create pseudo-namespaces # # You can refer to values of other properties by enclosing their keys in "${}". -# Example: dir.js = ${dir.web}/js +# Example: dir.js = ${dir.public}/js # # Everything behind the equal sign is the value, you do # not have to enclose strings: text=This is some text, Your OS is ${php.os} @@ -22,13 +22,15 @@ # env = dev -# Install assets using symlinks -# -assets.installWithSymlink = true - # Clear cache with the "warmup" option # -cache.clearWithWarmup = true +# The cache:clear command should always be called with the --no-warmup option. Warmup should be done via the cache:warmup command. +# https://github.com/symfony/symfony/blob/master/UPGRADE-3.3.md#frameworkbundle +# +# Meritoo +# 2017-06-06 +# +cache.clearWithWarmup = false # -------------------------------------------------------------------------------- # Composer @@ -39,7 +41,6 @@ composer.download_command = php -r "eval('?>'.file_get_contents('https://getcomp # Path to composer executable or composer.phar file # composer.path = composer.phar -#composer.path = /usr/local/bin/composer # Path to php executable used by composer # @@ -49,77 +50,49 @@ composer.php = php # composer.self-update = false -# Validate the composer.json file -# -composer.validate = false - # -------------------------------------------------------------------------------- # Directories # -------------------------------------------------------------------------------- # System directories # -dir.data = ${project.basedir}/.data dir.src = ${project.basedir}/src +dir.var = ${project.basedir}/tests/Resources/var +dir.cache = ${dir.var}/cache +dir.logs = ${dir.var}/log +dir.sessions = ${dir.var}/sessions +dir.data = ${project.basedir}/data dir.tests = ${project.basedir}/tests -# -------------------------------------------------------------------------------- # Build directories -# -------------------------------------------------------------------------------- - -dir.build = ${project.basedir}/.build +# +dir.build = ${project.basedir}/build dir.reports = ${dir.build}/logs dir.reports.pdepend = ${dir.reports}/pdepend -dir.reports.coverage = ${dir.reports}/phpunit_coverage -# -# Disabled, because unnecessary right now -# phpdocumentor/phpdocumentor cannot be installed via Composer -# -# Krzysztof Niziol -# 2017-02-22 -# -#dir.docs = ${dir.build}/docs -#dir.docs.phpdoc2 = ${dir.docs}/phpdoc2 -# -------------------------------------------------------------------------------- # Data directories -# -------------------------------------------------------------------------------- - +# dir.data.tests = ${dir.data}/tests dir.data.temporary = ${dir.data}/tmp +# Docker directories +# +dir.docker = ${project.basedir}/docker +dir.docker.data = ${dir.docker}/data/db +dir.docker.logs = ${dir.docker}/logs/nginx + # -------------------------------------------------------------------------------- # Testing # -------------------------------------------------------------------------------- +# Path of the PHP Coding Standards Fixer (http://cs.sensiolabs.org) +# +tests.cs_fixer.path = ./vendor/bin/php-cs-fixer + # Test database path # tests.database = ${dir.data.temporary}/database.sqlite +# Path of the framework used to run unit tests # -# Disabled, because unnecessary right now -# PHPUnit is installed and loaded by Composer -# -# Krzysztof Niziol -# 2017-02-22 -# -# Run PHPUnit using exec task instead of phpunitTask -#phpunit.useExec = false - -# -# Disabled, because unnecessary right now -# We want generate code coverage always -# -# Krzysztof Niziol -# 2017-02-22 -# -# Collect coverage data during tests -#phpunit.withCoverage = true - -# Path of the PHPUnit (https://phpunit.de) -# -phpUnit.path = ./vendor/bin/phpunit - -# Path of the PHP Coding Standards Fixer (http://cs.sensiolabs.org) -# -phpCsFixer.path = ./vendor/bin/php-cs-fixer +tests.framework.path = ./vendor/bin/phpunit --verbose --no-coverage diff --git a/phing/tests.xml b/phing/tests.xml new file mode 100644 index 0000000..398ee31 --- /dev/null +++ b/phing/tests.xml @@ -0,0 +1,230 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Base/Result/BaseParticipantsCollection.php b/src/Base/Result/BaseParticipantsCollection.php index 38db099..406f5fc 100644 --- a/src/Base/Result/BaseParticipantsCollection.php +++ b/src/Base/Result/BaseParticipantsCollection.php @@ -18,7 +18,7 @@ abstract class BaseParticipantsCollection extends Collection */ public function add($element, $index = null) { - throw new DisabledMethodException(__METHOD__, 'addParticipant'); + throw DisabledMethodException::create(__METHOD__, 'addParticipant'); } /** @@ -26,7 +26,7 @@ abstract class BaseParticipantsCollection extends Collection */ public function addMultiple($elements, $useIndexes = false) { - throw new DisabledMethodException(__METHOD__, 'addParticipants'); + throw DisabledMethodException::create(__METHOD__, 'addParticipants'); } /** @@ -34,7 +34,7 @@ abstract class BaseParticipantsCollection extends Collection */ public function has($element) { - throw new DisabledMethodException(__METHOD__, 'hasParticipantsOfSurvey'); + throw DisabledMethodException::create(__METHOD__, 'hasParticipantsOfSurvey'); } /** diff --git a/src/Configuration/ConnectionConfiguration.php b/src/Configuration/ConnectionConfiguration.php index 0faa62e..1e40bf0 100644 --- a/src/Configuration/ConnectionConfiguration.php +++ b/src/Configuration/ConnectionConfiguration.php @@ -77,6 +77,7 @@ class ConnectionConfiguration * turned off. * @param bool $verifySslCertificate (optional) If is set to true, the SSL certificate verification is turned * on. Otherwise - turned off. + * @throws InvalidUrlException */ public function __construct($baseUrl, $username, $password, $debugMode = false, $verifySslCertificate = true) { diff --git a/src/Exception/UnknownMethodException.php b/src/Exception/UnknownMethodException.php index a207bd7..8c8391c 100644 --- a/src/Exception/UnknownMethodException.php +++ b/src/Exception/UnknownMethodException.php @@ -20,10 +20,16 @@ use Meritoo\LimeSurvey\ApiClient\Type\MethodType; class UnknownMethodException extends UnknownTypeException { /** - * {@inheritdoc} + * Creates exception + * + * @param string $unknownMethod Name of unknown method used while talking to the LimeSurvey's API + * @return UnknownMethodException */ - public function __construct($unknownType) + public static function createException($unknownMethod) { - parent::__construct($unknownType, new MethodType(), 'name of method used while talking to the LimeSurvey\'s API'); + /* @var UnknownMethodException $exception */ + $exception = parent::create($unknownMethod, new MethodType(), 'name of method used while talking to the LimeSurvey\'s API'); + + return $exception; } } diff --git a/src/Result/Collection/SurveysSummaries.php b/src/Result/Collection/SurveysSummaries.php index 91d66c6..e41cf8c 100644 --- a/src/Result/Collection/SurveysSummaries.php +++ b/src/Result/Collection/SurveysSummaries.php @@ -25,7 +25,7 @@ class SurveysSummaries extends Collection */ public function add($element, $index = null) { - throw new DisabledMethodException(__METHOD__, 'addSurveySummary'); + throw DisabledMethodException::create(__METHOD__, 'addSurveySummary'); } /** @@ -33,7 +33,7 @@ class SurveysSummaries extends Collection */ public function addMultiple($elements, $useIndexes = false) { - throw new DisabledMethodException(__METHOD__, 'addSurveysSummaries'); + throw DisabledMethodException::create(__METHOD__, 'addSurveysSummaries'); } /** @@ -41,7 +41,7 @@ class SurveysSummaries extends Collection */ public function has($element) { - throw new DisabledMethodException(__METHOD__, 'hasSurveySummary'); + throw DisabledMethodException::create(__METHOD__, 'hasSurveySummary'); } /** diff --git a/tests/Exception/UnknownMethodExceptionTest.php b/tests/Exception/UnknownMethodExceptionTest.php index 681bcfb..a56979d 100644 --- a/tests/Exception/UnknownMethodExceptionTest.php +++ b/tests/Exception/UnknownMethodExceptionTest.php @@ -24,7 +24,7 @@ class UnknownMethodExceptionTest extends BaseTestCase { public function testConstructorVisibilityAndArguments() { - static::assertConstructorVisibilityAndArguments(UnknownMethodException::class, OopVisibilityType::IS_PUBLIC, 1, 1); + static::assertConstructorVisibilityAndArguments(UnknownMethodException::class, OopVisibilityType::IS_PUBLIC, 3); } /** @@ -35,7 +35,7 @@ class UnknownMethodExceptionTest extends BaseTestCase */ public function testConstructorMessage($unknownType, $expectedMessage) { - $exception = new UnknownMethodException($unknownType); + $exception = UnknownMethodException::createException($unknownType); static::assertEquals($expectedMessage, $exception->getMessage()); } diff --git a/tests/Resources/var/cache/.gitkeep b/tests/Resources/var/cache/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/Resources/var/log/.gitkeep b/tests/Resources/var/log/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/Resources/var/sessions/.gitkeep b/tests/Resources/var/sessions/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/Result/Item/SurveySummaryTest.php b/tests/Result/Item/SurveySummaryTest.php index 07534be..7389f6a 100644 --- a/tests/Result/Item/SurveySummaryTest.php +++ b/tests/Result/Item/SurveySummaryTest.php @@ -32,7 +32,7 @@ class SurveySummaryTest extends BaseTestCase * @param array $rawData Raw data of survey's summary * @dataProvider provideRawData */ - public function testCreateOfTheSurveySummary($rawData) + public function testCreateOfTheSurveySummary(array $rawData) { $processor = new ResultProcessor(); $processed = $processor->process(MethodType::GET_SUMMARY, $rawData);