/**
  * Создать объект и получить даты
  */
 public function testMakeRangeAndGetDates()
 {
     $dateStart = new DateTime('2000-01-01 15:16:17');
     $dateEnd = new DateTime('2000-01-20 16:17:18');
     $range = new myDatetimeRange($dateStart, $dateEnd);
     $this->assertEquals($dateStart, $range->getStart(), 'Start date');
     $this->assertEquals($dateEnd, $range->getEnd(), 'End date');
     // Not same
     $this->assertNotSame($dateStart, $range->getStart(), 'NOT same: Start date');
     $this->assertNotSame($dateEnd, $range->getEnd(), 'NOT same: End date');
 }
 /**
  * Конструктор
  * Инициализирует запрос
  *
  * @param  myDatetimeRange $range
  * @param  int             $userId
  * @param  string          $alias
  * @return void
  */
 public function __construct(myDatetimeRange $range, $userId, $alias = 'a')
 {
     $modelName = $this->getModelName();
     $table = Doctrine::getTable($modelName);
     $dateStart = $range->getStart()->format('Y-m-d H:i:s');
     $dateEnd = $range->getEnd()->format('Y-m-d H:i:s');
     $this->_query = Doctrine_Query::create()->from("{$modelName} {$alias}")->andWhere("{$alias}.updated_at BETWEEN CAST(? AS DATETIME) AND CAST(? AS DATETIME)", array($dateStart, $dateEnd));
     if ($table->hasColumn('user_id')) {
         $this->_query->andWhere("{$alias}.user_id = ?", (int) $userId);
     }
     $this->_extendQuery($range, $userId, $alias);
 }