Exemplo n.º 1
0
    /**
     * @test
     */
    public function it_skips_assertions_of_current_chain_after_failure()
    {
        $this->setExpectedException('Assert\\LazyAssertionException', <<<EXC
The following 1 assertions failed:
1) foo: Value "<NULL>" is empty, but non empty value was expected.
EXC
);
        \Assert\lazy()->that(null, 'foo')->notEmpty()->string()->verifyNow();
    }
Exemplo n.º 2
0
    /**
     * @test
     */
    public function it_collects_errors_until_assertall()
    {
        $this->setExpectedException('Assert\\LazyAssertionException', <<<EXC
The following 3 assertions failed:
1) foo: Value "10" expected to be string, type integer given.
2) bar: Value "<NULL>" is empty, but non empty value was expected.
3) baz: Value "string" is not an array.
EXC
);
        \Assert\lazy()->that(10, 'foo')->string()->that(null, 'bar')->notEmpty()->that('string', 'baz')->isArray()->verifyNow();
    }
Exemplo n.º 3
0
 }
 /** @var ExtendedPdo $pdo */
 $pdo = $this->get('pdo');
 $stm = "SELECT * FROM indiegogo WHERE Email = :email";
 $bind = ['email' => $postParams['email']];
 $sth = $pdo->perform($stm, $bind);
 $result = $sth->fetch(PDO::FETCH_ASSOC);
 if (!$result) {
     $flash->addMessage('error', 'No entry found for that email');
     return $response->withStatus(302)->withHeader('Location', $this->router->pathFor('getForm') . '?' . http_build_query(['email' => $postParams['email']]));
 }
 try {
     if ($result['Perk ID'] == 3613098) {
         \Assert\lazy()->that($postParams, 'Shirt Type')->keyExists('shirtType', 'You must select a shirt type')->notEmptyKey('shirtType', 'You must select a shirt type')->that($postParams, 'Shirt Size')->keyExists('shirtSize', 'You must select a shirt size')->notEmptyKey('shirtSize', 'You must select a shirt size')->verifyNow();
     } elseif ($result['Perk ID'] == 3633662) {
         \Assert\lazy()->that($postParams, 'Hoodie Size')->keyExists('hoodieSize', 'You must select a hoodie size')->notEmptyKey('hoodieSize', 'You must select a hoodie size')->verifyNow();
     }
 } catch (Assert\LazyAssertionException $e) {
     /** @var \Assert\InvalidArgumentException[] $errorExceptions */
     $errorExceptions = $e->getErrorExceptions();
     foreach ($errorExceptions as $errorException) {
         $flash->addMessage('error', $errorException->getMessage());
     }
     return $response->withStatus(302)->withHeader('Location', $this->router->pathFor('getForm') . '?' . http_build_query(['email' => $postParams['email']]));
 } catch (\Exception $e) {
     $flash->addMessage('error', $e->getMessage());
     return $response->withStatus(302)->withHeader('Location', $this->router->pathFor('getForm') . '?' . http_build_query(['email' => $postParams['email']]));
 }
 /*
  * Save results and redirect
  */