There are times, often in tests or upgrade paths, where we want to programmatically install a module. Here's how:
Can you say a bit more about this? Where does this code go?
This code can go pretty much anywhere. My most recent use for it was in a test where I wanted to add some content, then install a module, and test how the module reacted to the content which was there before the module was installed. For this I just added the code in the test method of a functional browser test.