Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
test_dead_assets.inc
1 <?php
28 {
29 
30 
37  public static function getName()
38  {
39  return 'Dead Assets Test';
40 
41  }//end getName()
42 
43 
50  public static function getDescription()
51  {
52  return 'A test to check for dead assets in the link table in Matrix';
53 
54  }//end getDescription()
55 
56 
66  public static function test(&$messages, &$errors)
67  {
68  $status = TRUE;
69  $minor_sql = 'SELECT minorid FROM sq_ast_lnk WHERE minorid NOT IN (select assetid FROM sq_ast) AND linkid <> 1';
70  $minor_result = MatrixDAL::executeSqlAssoc($minor_sql);
71 
72  foreach ($minor_result as $index => $result) {
73  $minor_result[$index] = $result['minorid'];
74  }
75  $minor_result = array_unique($minor_result);
76 
77  if (!empty($minor_result)) {
78  $status = FALSE;
79  foreach ($minor_result as $result) {
80  $errors[] = 'Asset #'.$result.' was not found on the system';
81  }//end foreach
82  }//end if
83  $major_sql = 'SELECT majorid FROM sq_ast_lnk WHERE majorid NOT IN (SELECT assetid FROM sq_ast) AND linkid <> 1';
84  $major_result = MatrixDAL::executeSqlAssoc($major_sql);
85 
86  foreach ($major_result as $index => $result) {
87  $major_result[$index] = $result['majorid'];
88  }
89  $major_result = array_unique($major_result);
90 
91  if (!empty($major_result)) {
92  $status = FALSE;
93  foreach ($major_result as $result) {
94  $errors[] = 'Asset #'.$result.' was not found on the system';
95  }//end foreach
96  }//end if
97 
98  if (!$status) {
99  $count = count($minor_result) + count($major_result);
100  $messages[] = 'There are '.$count.' dead asset(s) on the system';
101  }//end if
102 
103  return $status;
104 
105  }//end test()
106 
107 }//end class
108 ?>