Skip to content

Commit c6cc150

Browse files
authored
Updated travis config (#1)
* Updated travis config * Added tests
1 parent 0e57229 commit c6cc150

File tree

4 files changed

+50
-3
lines changed

4 files changed

+50
-3
lines changed

.travis.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,19 @@ env:
2222
- SYMFONY_VERSION=3.2.*
2323
- SYMFONY_VERSION=2.7.*
2424

25+
matrix:
26+
fast_finish: true
27+
include:
28+
- php: 5.5
29+
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" COVERAGE=true TEST_COMMAND="composer test-ci" SYMFONY_VERSION=2.7.*
30+
2531
install:
26-
- travis_retry composer update --prefer-dist --no-interaction
32+
- composer require symfony/symfony:${SYMFONY_VERSION} --no-update
33+
- travis_retry composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction
2734

2835
script:
2936
- $TEST_COMMAND
37+
38+
after_success:
39+
- if [[ $COVERAGE = true ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi
40+
- if [[ $COVERAGE = true ]]; then php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml; fi

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
],
1111
"require": {
1212
"php": "^5.5 || ^7.0",
13-
"php-translation/common": "^0.1",
13+
"php-translation/common": "^0.2.1",
1414
"symfony/translation": "^2.7 || ^3.0"
1515
},
1616
"require-dev": {
17-
"phpunit/phpunit": "^4.5 || ^5.4"
17+
"phpunit/phpunit": "^4.5 || ^5.4",
18+
"symfony/framework-bundle": "^2.7 || ^3.0"
1819
},
1920
"autoload": {
2021
"psr-4": {

src/FileStorage.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ public function __construct(TranslationWriter $writer, $loader, array $dir)
5555
throw new \LogicException('Second parameter of FileStorage must be a Symfony translation loader or implement Translation\SymfonyStorage\TranslationLoader');
5656
}
5757

58+
if (empty($dir)) {
59+
throw new \LogicException('Third parameter of FileStorage cannot be empty');
60+
}
61+
5862
$this->writer = $writer;
5963
$this->loader = $loader;
6064
$this->dir = $dir;

tests/FileStorageTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace Translation\SymfonyStorage\Tests;
4+
5+
use Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader;
6+
use Symfony\Component\Translation\Writer\TranslationWriter;
7+
use Translation\SymfonyStorage\FileStorage;
8+
9+
class FileStorageTest extends \PHPUnit_Framework_TestCase
10+
{
11+
public function testConstructor()
12+
{
13+
$storage = new FileStorage(new TranslationWriter(), new TranslationLoader(), ['foo']);
14+
}
15+
16+
/**
17+
* @expectedException \LogicException
18+
*/
19+
public function testConstructorInvalidLoader()
20+
{
21+
$storage = new FileStorage(new TranslationWriter(), new TranslationWriter(), ['foo']);
22+
}
23+
24+
/**
25+
* @expectedException \LogicException
26+
*/
27+
public function testConstructorEmptyArray()
28+
{
29+
$storage = new FileStorage(new TranslationWriter(), new TranslationLoader(), []);
30+
}
31+
}

0 commit comments

Comments
 (0)