public function testPurpose() { $inputData = ['name' => 'John Smith', 'unexpected' => 'data']; $hasInput = false; $mockInput = $this->getMock('AIV\\InputInterface'); $mockValidator = $this->getMock('AIV\\ValidatorInterface'); $mockValidator->expects($this->atLeastOnce())->method('setInput')->will($this->returnCallback(function ($input) use($mockInput, &$hasInput) { $this->assertSame($input, $mockInput); $hasInput = true; })); $mockValidator->expects($this->once())->method('hasErrors')->will($this->returnCallback(function () { return false; })); $mockValidator->expects($this->once())->method('getData')->will($this->returnCallback(function () use($inputData) { return $inputData; })); $manager = new Manager(); $manager->addValidator('test-form', $mockValidator); $manager->setInput($mockInput); $this->assertFalse($manager->hasErrors('test-form')); $this->assertEquals($inputData, $manager->getData('test-form')); }