Skip to content
Open
Changes from all 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
66 changes: 35 additions & 31 deletions tests/lang/EsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,63 @@
namespace Laraveles\Spanish\Tests\Lang;

use Laraveles\Spanish\Tests\TestCase;
use Illuminate\Support\Facades\Artisan;

class EsTest extends TestCase
{
public function setUp(): void
{
parent::setUp(); // TODO: Change the autogenerated stub
$this->app['config']->set('app.locale', 'es');

Artisan::call('laraveles:install-lang');
}

/** @test */
public function tenemos_traduccion_para_la_autentificacion_fallida()
public function comprueba_traducciones()
{
$this->assertEquals(
trans('auth.failed'),
'Estas credenciales no coinciden con nuestros registros.'
);
}
foreach (['validation', 'passwords', 'pagination', 'auth'] as $fichero) {
$claves = array_keys(trans($fichero));
$traduccion = (include __DIR__ . "/../../resources/lang/es/" . $fichero . ".php");

/** @test */
public function tenemos_traduccion_para_plantilla()
{
$this->assertEquals(
__('Name'),
'Nombre'
);
foreach ($claves as $clave) {
if ( ! isset($traduccion[$clave])) {
throw new \Exception("Falta traducción para $fichero.$clave");
}

if ($traduccion[$clave] === '') {
throw new \Exception("Traducción para $fichero.$clave vacía");
}
}
}
}

/** @test */
public function formato_json_correcto()
{
$fileJson = join(DIRECTORY_SEPARATOR, array(
\Artisan::call('laraveles:install-lang');

\App::setLocale('es');

$fileJson = join(DIRECTORY_SEPARATOR, [
dirname(__FILE__),
'..',
'..',
'resources',
'lang',
'es.json'
));
'es.json',
]);

$jsonData = file_get_contents($fileJson);

$this->assertJson($jsonData);

$traductions = json_decode($jsonData, true);
$traducciones = json_decode($jsonData, true);

foreach ($traductions as $key => $traduction) {
$this->assertEquals(
__($key),
$traduction
);
foreach ($traducciones as $key => $traduccion) {
if (__($key) !== $traduccion) {
throw new \Exception("Traducción errónea: $key");
}
}
}

/**
* @test
* Si el comando no existe lanzará CommandNotFoundException
* */
public function comprueba_instala_comando_artisan()
{
\Artisan::call('laraveles:install-lang');
}
}