From f145622207ffc3f09c6580fd667293044aed1c46 Mon Sep 17 00:00:00 2001 From: Nick Liu <deltik@gmx.com> Date: Wed, 31 Oct 2018 08:06:42 -0500 Subject: [PATCH] Added tests for e_shims --- .gitlab-ci.yml | 48 --------------------------- e107 | 2 +- tests/unit/e107/Shims/e_shimsTest.php | 35 +++++++++++++++++++ 3 files changed, 36 insertions(+), 49 deletions(-) delete mode 100644 .gitlab-ci.yml create mode 100644 tests/unit/e107/Shims/e_shimsTest.php diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 79d258ed3..000000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,48 +0,0 @@ -# This file is a template, and might need editing before it works on your project. -# Select image from https://hub.docker.com/_/php/ -image: php:apache - -# Select what we should cache between builds -cache: - paths: - - vendor/ - -before_script: -- apt-get update -y -- apt-get install -y git unzip #libmcrypt-dev libpq-dev libcurl4-gnutls-dev libicu-dev libvpx-dev libjpeg-dev libpng-dev libxpm-dev zlib1g-dev libfreetype6-dev libxml2-dev libexpat1-dev libbz2-dev libgmp3-dev libldap2-dev unixodbc-dev libsqlite3-dev libaspell-dev libsnmp-dev libpcre3-dev libtidy-dev -## Install PHP extensions -#- docker-php-ext-install mbstring mcrypt pdo_pgsql curl json intl gd xml zip bz2 opcache -# Install & enable Xdebug for code coverage reports -- pecl install xdebug -- docker-php-ext-enable xdebug -# Install and run Composer -- curl -sS https://getcomposer.org/installer | php -- php composer.phar install -- git submodule update --init --recursive --remote -#- yum install -y epel-release yum-utils -#- yum install -y "http://rpms.remirepo.net/enterprise/remi-release-$(rpm -q --queryformat '%{VERSION}' centos-release).rpm" -#- yum list -q 'php[0-9][0-9]' | awk '/php/ {print $1}' | xargs yum install -y -#- yum install -y mariadb -#- service mariadb restart -#- yum install -y httpd -#- sed -i 's/AllowOverride None/AllowOverride All/ig' /etc/httpd/conf/httpd.conf -#- curl -sS https://getcomposer.org/installer | php -#- php composer.phar install - -# Bring in any services we need http://docs.gitlab.com/ee/ci/docker/using_docker_images.html#what-is-a-service -# See http://docs.gitlab.com/ce/ci/services/README.html for examples. -services: -- mysql:5.7 - -# Set any variables we need -variables: - # Configure mysql environment variables (https://hub.docker.com/r/_/mysql/) - MYSQL_DATABASE: mysql_database - MYSQL_ROOT_PASSWORD: mysql_strong_password - -# Run our tests -# If Xdebug was installed you can generate a coverage report and see code coverage metrics. -test:php7.0: - image: php:7.0-apache - script: - - ./vendor/bin/codecept run --steps --debug --coverage --coverage-xml --coverage-html \ No newline at end of file diff --git a/e107 b/e107 index 3b25fe86b..ee1a5b127 160000 --- a/e107 +++ b/e107 @@ -1 +1 @@ -Subproject commit 3b25fe86b6c8e44996b34775647e0275b99ba51f +Subproject commit ee1a5b1278a4c6e47f93800d29b0b58504fd232c diff --git a/tests/unit/e107/Shims/e_shimsTest.php b/tests/unit/e107/Shims/e_shimsTest.php new file mode 100644 index 000000000..2506d39ec --- /dev/null +++ b/tests/unit/e107/Shims/e_shimsTest.php @@ -0,0 +1,35 @@ +<?php +/** + * e107 website system + * + * Copyright (C) 2008-2018 e107 Inc (e107.org) + * Released under the terms and conditions of the + * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) + * + */ + +class e_shimsTest extends \Codeception\Test\Unit +{ + public function testReadfile() + { + $this->testReadfileImplementation(array(e_shims::class, 'readfile')); + } + + public function testReadfileAlt() + { + $this->testReadfileImplementation(array(e_shims::class, 'readfile_alt')); + } + + private function testReadfileImplementation($implementation) + { + $tmp_handle = tmpfile(); + $tmp_filename = stream_get_meta_data($tmp_handle)['uri']; + $garbage = str_pad('', 16384, 'x'); + fwrite($tmp_handle, $garbage); + ob_start(); + call_user_func($implementation, $tmp_filename); + $output = ob_get_clean(); + fclose($tmp_handle); + $this->assertEquals($garbage, $output); + } +}