Beispiel #1
0
 /**
  * @dataProvider formatDateDataProvider
  *
  * expectedFormat is to be in the Y-m-d type format for the date you are expecting,
  * expectedResult is if a specific date is expected.
  */
 public function testFormatDate($date, $includeTime, $expectedFormat, $expectedResult = null)
 {
     $dateTime = new \Magento\Framework\Stdlib\DateTime();
     $actual = $dateTime->formatDate($date, $includeTime);
     if ($expectedFormat != '') {
         $expectedResult = date($expectedFormat);
     } else {
         if ($expectedResult === null) {
             $expectedResult = '';
         }
     }
     $this->assertEquals($expectedResult, $actual);
 }
Beispiel #2
0
 public function testAddUpdatedDaysBeforeFilter()
 {
     $select = $this->getMock('Zend_Db_Select', [], [], '', false);
     $select->expects($this->any())->method('where')->with(self::TEST_WHERE_CONDITION);
     $collection = $this->_getCollection($select);
     /** @var $connection \PHPUnit_Framework_MockObject_MockObject */
     $connection = $collection->getResource()->getReadConnection();
     $connection->expects($this->any())->method('prepareSqlCondition')->will($this->returnCallback([$this, 'verifyPrepareSqlCondition']));
     // expected date without time
     $datetime = new \DateTime();
     $storeInterval = new \DateInterval('P' . self::TEST_DAYS_BEFORE . 'D');
     $datetime->sub($storeInterval);
     $dateTimeLib = new \Magento\Framework\Stdlib\DateTime();
     $expectedDate = $dateTimeLib->formatDate($datetime->getTimestamp());
     $this->_expectedConditions['data'][1][1]['lt'] = $expectedDate;
     $collection->addUpdatedDaysBeforeFilter(self::TEST_DAYS_BEFORE);
 }