SearchTest::test_search_all_meta PHP Method

test_search_all_meta() public method

Test search with all meta to not have SQL errors
    public function test_search_all_meta()
    {
        $itemtypeslist = array('Computer', 'Problem', 'Ticket', 'Printer', 'Monitor', 'Peripheral', 'Software', 'Phone');
        foreach ($itemtypeslist as $itemtype) {
            // do a search query
            $search_params = array('is_deleted' => 0, 'start' => 0, 'criteria' => array(0 => array('field' => 'view', 'searchtype' => 'contains', 'value' => '')), 'metacriteria' => array());
            $metacriteria = array();
            $metaList = Search::getMetaItemtypeAvailable($itemtype);
            foreach ($metaList as $metaitemtype) {
                $item = getItemForItemtype($metaitemtype);
                foreach ($item->getSearchOptions() as $key => $data) {
                    if (is_int($key)) {
                        if (isset($data['datatype']) && $data['datatype'] == 'bool') {
                            $metacriteria[] = array('link' => 'AND', 'field' => $key, 'searchtype' => 'equals', 'value' => 0);
                        } else {
                            $metacriteria[] = array('link' => 'AND', 'field' => $key, 'searchtype' => 'contains', 'value' => 'f');
                        }
                    }
                }
            }
            $search_params['metacriteria'] = $metacriteria;
            $data = $this->doSearch($itemtype, $search_params);
            // check for sql error (data key missing or empty)
            $this->assertArrayHasKey('data', $data, $data['last_errors']);
            $this->assertNotCount(0, $data['data'], $data['last_errors']);
        }
    }