dir = sys_get_temp_dir().'/release-test-'.uniqid(); mkdir($this->dir); }); afterEach(function () { @unlink($this->dir.'/RELEASE'); @rmdir($this->dir); }); test('the configured value wins over the release file', function () { file_put_contents($this->dir.'/RELEASE', "abc1234\n"); expect(Release::current('v1.2.0', $this->dir))->toBe('v1.2.0'); }); test('the release file is used when nothing is configured', function () { file_put_contents($this->dir.'/RELEASE', "98c465b-dirty\n"); expect(Release::current(null, $this->dir))->toBe('98c465b-dirty') ->and(Release::current(' ', $this->dir))->toBe('98c465b-dirty'); }); test('without file or with garbage there is no release', function () { expect(Release::current(null, $this->dir))->toBeNull(); file_put_contents($this->dir.'/RELEASE', ' # bei jedem Deploy'); expect(Release::current(null, $this->dir))->toBeNull(); });