Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Add Docker files and documentation #840

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM php:7.2-cli

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
libzip-dev \
locales \
locales-all \
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add locales for comma separator tests

zip \
&& docker-php-ext-configure zip --with-libzip \
&& docker-php-ext-install zip

COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer
RUN chmod +x /usr/local/bin/composer
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ For information, the performance tests take about 10 minutes to run (processing

> Performance tests status: [![Build Status](https://travis-ci.org/box/spout.svg?branch=perf-tests)](https://travis-ci.org/box/spout)

### Running test with Docker

First install the dependencies with docker-compose

```bash
docker-compose run --rm -u ${UID} php composer install
```

Then launch the tests

```bash
docker-compose run --rm php vendor/bin/phpunit
```

## Support

Expand Down
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: '3'
services:
php:
build: .
working_dir: /srv/spout
volumes:
- $PWD:/srv/spout
- $PWD/tests/generated/resources/unwritable:/srv/spout/tests/resources/generated/unwritable:ro
5 changes: 5 additions & 0 deletions tests/Spout/Writer/ODS/WriterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,17 @@ public function testAddRowShouldSupportFloatValuesInDifferentLocale()
// Installed locales differ from one system to another, so we can't pick
// a given locale.
$supportedLocales = explode("\n", shell_exec('locale -a'));
$foundCommaLocale = false;
foreach ($supportedLocales as $supportedLocale) {
\setlocale(LC_ALL, $supportedLocale);
if (\localeconv()['decimal_point'] === ',') {
$foundCommaLocale = true;
break;
}
}
if (!$foundCommaLocale) {
$this->markTestSkipped('No locale with comma decimal separator');
}
Comment on lines +302 to +304
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can happen on system without comma separator

$this->assertEquals(',', \localeconv()['decimal_point']);

$fileName = 'test_add_row_should_support_float_values_in_different_locale.xlsx';
Expand Down
5 changes: 5 additions & 0 deletions tests/Spout/Writer/XLSX/WriterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,12 +406,17 @@ public function testAddRowShouldSupportFloatValuesInDifferentLocale()
// Installed locales differ from one system to another, so we can't pick
// a given locale.
$supportedLocales = explode("\n", shell_exec('locale -a'));
$foundCommaLocale = false;
foreach ($supportedLocales as $supportedLocale) {
\setlocale(LC_ALL, $supportedLocale);
if (\localeconv()['decimal_point'] === ',') {
$foundCommaLocale = true;
break;
}
}
if (!$foundCommaLocale) {
$this->markTestSkipped('No locale with comma decimal separator');
}
$this->assertEquals(',', \localeconv()['decimal_point']);

$fileName = 'test_add_row_should_support_float_values_in_different_locale.xlsx';
Expand Down