2016-08-05 15:10:28 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use function PMSIpilot\DockerComposeViz\readConfiguration;
|
|
|
|
|
2016-08-05 20:40:29 +02:00
|
|
|
require_once __DIR__.'/../vendor/autoload.php';
|
2016-08-05 15:10:28 +02:00
|
|
|
|
2016-08-05 20:40:29 +02:00
|
|
|
describe('Reading configuration', function () {
|
|
|
|
it('should check if file exists', function () {
|
2016-08-05 20:53:13 +02:00
|
|
|
expect(function () {
|
|
|
|
readConfiguration(uniqid());
|
|
|
|
})
|
2016-08-05 15:10:28 +02:00
|
|
|
->toThrow(new InvalidArgumentException());
|
|
|
|
});
|
|
|
|
|
2016-08-05 20:40:29 +02:00
|
|
|
it('should parse YAML and return an array', function () {
|
2016-08-05 15:10:28 +02:00
|
|
|
expect(readConfiguration(__DIR__.'/fixtures/read-configuration/valid.yml'))
|
|
|
|
->toBe(['version' => 2, 'services' => ['foo' => ['image' => 'bar']]]);
|
|
|
|
});
|
|
|
|
|
2016-08-05 20:40:29 +02:00
|
|
|
it('should report if YAML is invalid', function () {
|
2016-08-05 20:53:13 +02:00
|
|
|
expect(function () {
|
2020-07-23 20:55:49 +02:00
|
|
|
readConfiguration(__DIR__.'/fixtures/read-configuration/invalid.yml');
|
2016-08-05 20:53:13 +02:00
|
|
|
})
|
2016-08-05 15:10:28 +02:00
|
|
|
->toThrow(new InvalidArgumentException());
|
|
|
|
});
|
|
|
|
});
|