Line 29... |
Line 29... |
29 |
$url = $this->creerUrl('observations');
|
29 |
$url = $this->creerUrl('observations');
|
30 |
$i = new Observations();
|
30 |
$i = new Observations();
|
31 |
$retour = $this->consulterDirectJson($i->consulter([], ['navigation.depart'=>0,'navigation.limite'=>12,'ordre'=>'asc','masque'=>'G']),
|
31 |
$retour = $this->consulterDirectJson($i->consulter([], ['navigation.depart'=>0,'navigation.limite'=>12,'ordre'=>'asc','masque'=>'G']),
|
32 |
$url);
|
32 |
$url);
|
33 |
$expected = unserialize(file_get_contents("masque=G.data.json"));
|
33 |
$expected = unserialize(file_get_contents("masque=G.data.json"));
|
- |
|
34 |
|
34 |
ksort($expected);
|
35 |
self::ignoreNullValuesAndSort($expected);
|
35 |
ksort($retour);
|
36 |
self::ignoreNullValuesAndSort($retour);
|
- |
|
37 |
|
- |
|
38 |
// echo implode(',', array_keys($retour['resultats'])) . "\n" . implode(',', array_keys($expected['resultats']));die;
|
36 |
$this->assertEquals($expected['resultats'], $retour['resultats'], "JSON error, $url");
|
39 |
$this->assertEquals(array_keys($expected['resultats']), array_keys($retour['resultats']), "JSON error, $url");
|
- |
|
40 |
$this->assertEquals($expected['resultats'], $retour['resultats'], "Différences dans le tableau, $url");
|
37 |
}
|
41 |
}
|
Line 38... |
Line 42... |
38 |
|
42 |
|
39 |
public function testMasqueEtType() {
|
43 |
public function testMasqueEtType() {
|
40 |
$url = $this->creerUrl('observations');
|
44 |
@$url = $this->creerUrl('observations');
|
41 |
$i = new Observations();
|
45 |
$i = new Observations();
|
42 |
$retour = $this->consulterDirectJson($i->consulter([], ['navigation.depart'=>0,'navigation.limite'=>12,'ordre'=>'asc','masque'=>'G','masque.type'=>'endiscussion']),
|
46 |
$retour = $this->consulterDirectJson($i->consulter([], ['navigation.depart'=>0,'navigation.limite'=>12,'ordre'=>'asc','masque'=>'G','masque.type'=>'endiscussion']),
|
43 |
$url);
|
47 |
$url);
|
- |
|
48 |
$expected = unserialize(file_get_contents("masque=G-masque.type=endiscussion.data.json"));
|
44 |
$expected = unserialize(file_get_contents("masque=G-masque.type=endiscussion.data.json"));
|
49 |
|
45 |
ksort($expected);
|
50 |
self::ignoreNullValuesAndSort($expected);
|
- |
|
51 |
self::ignoreNullValuesAndSort($retour);
|
- |
|
52 |
|
46 |
ksort($retour);
|
53 |
// echo implode(',', array_keys($retour['resultats'])) . "\n" . implode(',', array_keys($expected['resultats']));die;
|
- |
|
54 |
$this->assertEquals(array_keys($expected['resultats']), array_keys($retour['resultats']), "JSON error, $url");
|
47 |
$this->assertEquals($expected['resultats'], $retour['resultats'], "JSON error, $url");
|
55 |
$this->assertEquals($expected['resultats'], $retour['resultats'], "Différences dans le tableau, $url");
|
Line 48... |
Line 56... |
48 |
}
|
56 |
}
|
Line 59... |
Line 67... |
59 |
foreach($keys as $k) {
|
67 |
foreach($keys as $k) {
|
60 |
$this->assertArrayHasKey($k, $arr, "attribut {$k} manquant. Voir : $url");
|
68 |
$this->assertArrayHasKey($k, $arr, "attribut {$k} manquant. Voir : $url");
|
61 |
$this->assertNotEmpty($arr[$k], "attribut {$k} vide. Voir : $url");
|
69 |
$this->assertNotEmpty($arr[$k], "attribut {$k} vide. Voir : $url");
|
62 |
}
|
70 |
}
|
63 |
}
|
71 |
}
|
- |
|
72 |
|
- |
|
73 |
static function ignoreNullValuesAndSort(&$arr) {
|
- |
|
74 |
$arr['resultats'] = array_map('array_filter', $arr['resultats']);
|
- |
|
75 |
ksort($arr);
|
- |
|
76 |
}
|
64 |
}
|
77 |
}
|