You are here

public function PropertyNormalizerTest::provideCallbacks in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/serializer/Tests/Normalizer/PropertyNormalizerTest.php \Symfony\Component\Serializer\Tests\Normalizer\PropertyNormalizerTest::provideCallbacks()

File

vendor/symfony/serializer/Tests/Normalizer/PropertyNormalizerTest.php, line 300

Class

PropertyNormalizerTest

Namespace

Symfony\Component\Serializer\Tests\Normalizer

Code

public function provideCallbacks() {
  return array(
    array(
      array(
        'bar' => function ($bar) {
          return 'baz';
        },
      ),
      'baz',
      array(
        'foo' => '',
        'bar' => 'baz',
      ),
      'Change a string',
    ),
    array(
      array(
        'bar' => function ($bar) {
          return;
        },
      ),
      'baz',
      array(
        'foo' => '',
        'bar' => null,
      ),
      'Null an item',
    ),
    array(
      array(
        'bar' => function ($bar) {
          return $bar
            ->format('d-m-Y H:i:s');
        },
      ),
      new \DateTime('2011-09-10 06:30:00'),
      array(
        'foo' => '',
        'bar' => '10-09-2011 06:30:00',
      ),
      'Format a date',
    ),
    array(
      array(
        'bar' => function ($bars) {
          $foos = '';
          foreach ($bars as $bar) {
            $foos .= $bar
              ->getFoo();
          }
          return $foos;
        },
      ),
      array(
        new PropertyConstructorDummy('baz', ''),
        new PropertyConstructorDummy('quux', ''),
      ),
      array(
        'foo' => '',
        'bar' => 'bazquux',
      ),
      'Collect a property',
    ),
    array(
      array(
        'bar' => function ($bars) {
          return count($bars);
        },
      ),
      array(
        new PropertyConstructorDummy('baz', ''),
        new PropertyConstructorDummy('quux', ''),
      ),
      array(
        'foo' => '',
        'bar' => 2,
      ),
      'Count a property',
    ),
  );
}