public function getCommonCallingCardValidations() { return array('cardExists' => Node::createValidatorInfo(function (Node $node) { $node->saveCustomData('myCardEntity', new Card()); return true; }, 'pp/11'), 'cardIsNotExpired' => Node::createValidatorInfo(function (Node $node) { $card = $node->getCustomData('myCardEntity'); return !$card->isExpired(); }, 'pp/12'), 'cardIsNotDued' => Node::createValidatorInfo(function (Node $node) { $card = $node->getCustomData('myCardEntity'); return !$card->isDued(); }, 'pp/15'), 'cardIsNotInUse' => Node::createValidatorInfo(function (Node $node) { $card = $node->getCustomData('myCardEntity'); return !$card->inUse(); }, 'pp/34')); }
/** * @test */ public function can_create_validator_info() { $validatorInfo = Node::createValidatorInfo(function ($node) { return true; }, 'sound'); $this->assertEquals($validatorInfo['soundOnError'], 'sound'); $this->assertTrue($validatorInfo['callback'](null)); }