Exemplo n.º 1
0
    function test_find_where_clause_by_pattern()
    {
        $parser = new SQL_Parser();
        $compiler = new SQL_Compiler();
        $sql = 'select clients_translation.id_clients_prefix, clients_translation.rule_number,
			   clients_translation.pattern, clients_translation.rule
			   from clients, clients_prefix, clients_translation
			   where (clients.id_softswitch = 5)
				 and (clients.id_clients = clients_prefix.id_clients)
				 and clients.enable=\'y\'
				 and clients.unused=\'n\'
				 and (clients_translation.id_clients_prefix = clients_prefix.id_clients_prefix)
				 order by clients_translation.id_clients_prefix,clients_translation.rule_number';
        $parsed = $parser->parse($sql);
        $wrapper = new SQL_Parser_wrapper($parsed);
        $found = $wrapper->findWhereClausesWithPattern('/y/');
        $expected = array(array('arg_1' => array('value' => 'clients.enable', 'type' => 'ident'), 'op' => '=', 'arg_2' => array('value' => 'y', 'type' => 'text_val')));
        $this->assertEquals($expected, $found);
    }