예제 #1
0
 public function testDefaulsStringValue()
 {
     $factory = new Factory($this->mongator, $this->faker);
     $blueprint = new Blueprint($factory, 'Model\\Article', array('points' => 2, 'text' => 'faker::paragraph(2)', 'line' => 'faker::name', 'title' => 'text example %s', 'updatedAt' => '1st May 2010, 01:30:00', 'votes', 'author', 'categories' => 2, 'source'));
     $data = $blueprint->build();
     $this->assertEquals(2, $data['points']);
     $this->assertEquals('text example 0', $data['title']);
     $this->assertEquals(strtotime('1st May 2010, 01:30:00'), $data['updatedAt']->getTimestamp());
 }
예제 #2
0
 public static function embedded(Factory $factory, $class, $value = null)
 {
     if (!$value) {
         $value = array();
     } else {
         if ($value instanceof $class) {
             return $value->toArray();
         }
     }
     $bp = new Blueprint($factory, $class);
     return $bp->build($value, false);
 }