Completed
Push — translationunittests ( 09f392...fc199f )
by
unknown
14:09
created

TranslationFilesTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 7
dl 0
loc 15
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A loopLang() 0 13 5
1
<?php
2
3
namespace Tests\Unit;
4
5
use Tests\TestCase;
6
7
class TranslationFilesTest extends TestCase
8
{
9
    public function loopLang()
10
    {
11
$dir_path = "resources\lang\en"; //Per step 4 I specified EN to start with but the scope should encompass the whole lang folder and its subfolders.
12
    if (is_dir($dir_path))
13
    {
14
        $files = scandir($dir_path);
15
      // echo($files); This will print the files in the directory. Edited out but useful to check what you want is being searched through. 
16
       
17
    for ($i = 0; $i < count($files); $i++)
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function count() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.

If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration:

for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}

// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
18
    {
19
        if($files[$i] != '.' && $files[$i] != '..')
20
        {
21
            echo "File $i -> $files[$i]<br>";
22
        }
23
    }
24
    }
25
}
26
}
27
// instead of checking if specific files exists, check if every file in the lang folder returns an array. Do it for french and english at ghe same time no seperate test needed.
28
// 
29
//  Prefix: Write a function, make it a function that returns an array of everything that you could use to pass into Lang::get. (return auth, manager/applicant, everything under resources/lang/en. For now.) 
30
 // Loop through that array and make sure everything is passable into Lang::get and use that for other tests. 
31
32
/*---
33
 * 
34
 * 1) Use Scandir to get everything in the folder and loop through them. (same function as step 7) (its a recursive function, if its a file, turn that into a string that we can pass into Lang::get, if its a folder, we need to call this function again using that folder as a location.
35
 * 2) If its a file, you need to use the name of the file, and pass it to lang::get. 
36
 * 3) and then use Assert InternalType array. The Assert is to check what comes back from Lang::get. Its possible Lang::get causes an exception, but will show up in tests (probably) 
37
 * 4) Resources/Lang/EN or FR is where you start looking.
38
 * 5) Function needs to take a second argument, what am I going to prefix the filename with(arugment 1 is the directory you are looking in), for the Lang::get funcction, start with empty string. (argument 2 is an empty string. ''), 
39
 * 6) Check Applicant Profile Controller line 43 for a working example of Lang::get. 
40
 * 
41
 * ---
42
 * 
43
 * Put the test in one function, but have the function contain two starting points. One for EN/ one for FR. 
44
 * 
45
 */