|
| 1 | +<?php |
| 2 | + |
| 3 | +beforeEach(function () { |
| 4 | + $this->testPath = __DIR__ . '/..'; |
| 5 | + $this->rootPath = __DIR__ . '/../..'; |
| 6 | + $this->outputFilePath = "$this->testPath/output/lang.js"; |
| 7 | + $this->langPath = "$this->testPath/fixtures/lang"; |
| 8 | +}); |
| 9 | + |
| 10 | +test('it generates the JS language file successfully', function () { |
| 11 | + $this->artisan('lang:js', ['target' => $this->outputFilePath]) |
| 12 | + ->expectsOutputToContain('Created:') |
| 13 | + ->assertExitCode(0); |
| 14 | + |
| 15 | + $this->assertFileExists($this->outputFilePath); |
| 16 | + |
| 17 | + $template = "$this->rootPath/src/Generators/Templates/langjs_with_messages.js"; |
| 18 | + $this->assertFileExists($template); |
| 19 | + $this->assertFileNotEquals($template, $this->outputFilePath); |
| 20 | + |
| 21 | + $this->cleanupOutputDirectory($this->testPath); |
| 22 | +}); |
| 23 | + |
| 24 | +test('template should have handlebars', function () { |
| 25 | + $template = "$this->rootPath/src/Generators/Templates/langjs_with_messages.js"; |
| 26 | + $this->assertFileExists($template); |
| 27 | + |
| 28 | + $contents = file_get_contents($template); |
| 29 | + $this->assertNotEmpty($contents); |
| 30 | + $this->assertHasHandlebars('messages', $contents); |
| 31 | + $this->assertHasHandlebars('langjs', $contents); |
| 32 | +}); |
| 33 | + |
| 34 | +test('output should not have handlebars', function () { |
| 35 | + $this->artisan('lang:js', ['target' => $this->outputFilePath]) |
| 36 | + ->expectsOutputToContain('Created:') |
| 37 | + ->assertExitCode(0); |
| 38 | + |
| 39 | + $this->assertFileExists($this->outputFilePath); |
| 40 | + |
| 41 | + $contents = file_get_contents($this->outputFilePath); |
| 42 | + $this->assertNotEmpty($contents); |
| 43 | + $this->assertHasNotHandlebars('messages', $contents); |
| 44 | + $this->assertHasNotHandlebars('langjs', $contents); |
| 45 | + |
| 46 | + $this->cleanupOutputDirectory($this->testPath); |
| 47 | +}); |
0 commit comments