public function testAssertValidKeysInvalidKeys() { $options = array('testA' => 1, 'testD' => 2, 'testE' => 3); $valid = array('testA', 'testB', 'testC'); try { $validated = PHPUnit_Util_XML::assertValidKeys($options, $valid); $this->fail(); } catch (PHPUnit_Framework_Exception $e) { $this->assertEquals('Unknown key(s): testD, testE', $e->getMessage()); } }
public function testAssertValidKeysThrowsExceptionWhenTypeIsNotArray() { foreach (array(NULL, 'foo', 42) as $bad) { try { PHPUnit_Util_XML::assertValidKeys($bad, array()); $this->fail(); } catch (InvalidArgumentException $e) { $this->assertRegExp('/expected array/i', $e->getMessage()); } } }