hooks should be created in a module. The module which they are called from should be enabled.
So in the first instance you will need to create a .info and a .module file with the correct information in.
Then to implement a hook you must use the module name.
So the example code above would work if the php code is in a module called test which was enabled.
hook_menu() in a module called
test.module would be a function called
Secondly hooks will only be called when invoked, some get invoked rarely when for example building the menu system, and others are invoked when specific actions happen. You will need to read up on the documentation for the hook in question to find out more.
The same goes for parameters and return values, each hook is different. So the documentation is important there.
So a general checklist for hooks.
Is the hook in a module?
Is the module enabled?
Is the hook named the same as the module?
Is the action which is calling the hook being called?
Have I cleared the cache?
Am I using the hook in the correct way?