Example #1
0
 public function testSkipNull()
 {
     $source = new SourcePost();
     $source->description = null;
     $destination = new DestinationPost();
     $destination->description = 'Foo bar';
     $mapper = new Mapper();
     $mapper->createMap('BCC\\AutoMapperBundle\\Tests\\Fixtures\\SourcePost', 'BCC\\AutoMapperBundle\\Tests\\Fixtures\\DestinationPost')->setSkipNull(true);
     try {
         $mapper->map($source, $destination);
     } catch (\Exception $e) {
         $this->fail('should not catch an exception - ' . $e->getMessage());
     }
     $this->assertEquals('Foo bar', $destination->description);
 }
 /**
  * @expectedException \BCC\AutoMapperBundle\Mapper\Exception\InvalidClassConstructorException
  */
 public function testMapInvalidConstructor()
 {
     $source = new SourceAuthor();
     $mapper = new Mapper();
     $mapper->createMap('BCC\\AutoMapperBundle\\Tests\\Fixtures\\SourceAuthor', 'BCC\\AutoMapperBundle\\Tests\\Fixtures\\DestinationComplexAuthor');
     $result = $mapper->map($source, 'BCC\\AutoMapperBundle\\Tests\\Fixtures\\DestinationComplexAuthor');
 }