/** * @expectedException InvalidArgumentException */ public function test_config_throws_exception_on_bad_yaml_parse() { $file = 'fake.yaml'; $parser = m::mock('Symfony\\Component\\Yaml\\Parser[parse]', function ($mock) { $mock->shouldReceive('parse')->andThrow(new InvalidArgumentException('oops')); }); $file_dispatch = m::mock('Enzyme\\Parrot\\File[exists,getContents]', function ($mock) use($file) { $mock->shouldReceive('exists')->with($file)->times(1)->andReturn(true); $mock->shouldReceive('getContents')->with($file)->times(1)->andReturn('bad'); }); $config = new Config($parser, $file_dispatch, new Dot()); $config->parse($file); }