I'm new to PHPUnit, and unit testing in general. I can't seem to find a clear tutorial or resource on how best to test:
- Passing no argument fails.
- How to pass an argument for a constructor test.
- Passing an empty argument results in the expected exception.
How would I approach testing this constructor?
<?php
class SiteManagement {
public function __construct (array $config) {
// Make sure we actually passed a config
if (empty($config)) {
throw new \Exception('Configuration not valid', 100);
}
// Sanity check the site list
if (empty($config['siteList'])) {
throw new \Exception('Site list not set', 101);
}
}
}