public function testDocumentArrayValidatorNoArray() { $validator = new phpillowDocumentValidator(); try { $validator->validate(false); $this->fail('Expected phpillowValidationException.'); } catch (phpillowValidationException $e) { $this->assertSame('Invalid document type provided.', $e->getText()); } }
/** * Validate input as string * * @param mixed $input * @return string */ public function validate($input) { // We expect an array of documents, and if this isn't an array, we can // bail out immediately. if (!is_array($input)) { throw new phpillowValidationException('Invalid document type provided.', array()); } // Reuse the document validator to validate the single documents in the // array. foreach ($input as $key => $value) { $input[$key] = parent::validate($value); } // If no exception has been thrown during the process, return the valid // array return $input; }