* @author James Brooks */ abstract class AbstractTestCase extends TestCase { use CreatesApplicationTrait; /** * Test actor. * * @var \CachetHQ\Cachet\Models\User */ protected $user; /** * Sign in an user if it's the case. * * @param \CachetHQ\Cachet\Models\User|null $user * * @return \CachetHQ\Tests\Cachet\AbstractTestCase */ protected function signIn(User $user = null) { $this->user = $user ?: $this->createUser(); $this->be($this->user); return $this; } /** * Create and return a new user. * * @param array $properties * * @return \CachetHQ\Cachet\Models\User */ protected function createUser($properties = []) { return factory(User::class)->create($properties); } /** * Set up the needed configuration to be able to run the tests. * * @return \CachetHQ\Tests\Cachet\AbstractTestCase */ protected function setupConfig() { $env = $this->app->environment(); $repo = $this->app->make(Repository::class); $cache = $this->app->make(Cache::class); $loaded = $cache->load($env); if ($loaded === false) { $loaded = $repo->all(); $cache->store($env, $loaded); } $settings = array_merge($this->app->config->get('setting'), $loaded); $this->app->config->set('setting', $settings); return $this; } }