Пример #1
0
 public function testClockMock()
 {
     $date = (new \DateTime("2016-11-05 01:00:00", new \DateTimeZone("Asia/Colombo")))->format('U');
     ClockMock::withClockMock($date);
     $time = $this->AuthUserRepository->getApparentTime();
     $this->assertEquals("2016-11-05 01:00:00", $time);
     ClockMock::withClockMock(false);
 }
Пример #2
0
 public function testBOTH_USED()
 {
     $date = (new \DateTime("2016-06-05 00:30:00", new \DateTimeZone("Asia/Colombo")))->format('U');
     ClockMock::withClockMock($date);
     $response = $this->SlaveUserRepository->isOver("00000000000011", "NO FREE");
     $this->assertTrue($response);
     ClockMock::withClockMock(false);
 }
Пример #3
0
 /**
  * @group time-sensitive
  */
 public function testDummy()
 {
     /**
      * @var data_package
      */
     $date = (new \DateTime("2016-11-05 01:00:00", new \DateTimeZone("Asia/Colombo")))->format('U');
     ClockMock::withClockMock($date);
     $tags = $this->AuthUserRepository->getRunningDataPackage(22);
     $time = $this->AuthUserRepository->getApparentTime();
     //$this->assertInstanceOf("AppBundle\Entity\data_package",$tags);
     $this->assertEquals("2016-11-05 01:00:00", $time);
     ClockMock::withClockMock(false);
 }
Пример #4
0
 protected function setUp()
 {
     if (class_exists('Symfony\\Bridge\\PhpUnit\\ClockMock')) {
         ClockMock::register('Symfony\\Component\\HttpFoundation\\Request');
     }
     $this->kernel = null;
     $this->cache = null;
     $this->esi = null;
     $this->caches = array();
     $this->cacheConfig = array();
     $this->request = null;
     $this->response = null;
     $this->responses = array();
     $this->catch = false;
     $this->clearDirectory(sys_get_temp_dir() . '/http_cache');
 }
Пример #5
0
 public function endTest(\PHPUnit_Framework_Test $test, $time)
 {
     if ($this->expectedDeprecations) {
         restore_error_handler();
         try {
             $prefix = "@expectedDeprecation:\n  ";
             $test->assertStringMatchesFormat($prefix . implode("\n  ", $this->expectedDeprecations), $prefix . implode("\n  ", $this->gatheredDeprecations));
         } catch (\PHPUnit_Framework_AssertionFailedError $e) {
             $test->getTestResultObject()->addFailure($test, $e, $time);
         }
         $this->expectedDeprecations = $this->gatheredDeprecations = $this->previousErrorHandler = null;
     }
     if (-2 < $this->state && $test instanceof \PHPUnit_Framework_TestCase) {
         $groups = \PHPUnit_Util_Test::getGroups(get_class($test), $test->getName(false));
         if (in_array('time-sensitive', $groups, true)) {
             ClockMock::withClockMock(false);
         }
         if (in_array('dns-sensitive', $groups, true)) {
             DnsMock::withMockedHosts(array());
         }
     }
 }
Пример #6
0
 public function endTest(\PHPUnit_Framework_Test $test, $time)
 {
     if (-2 < $this->state && $test instanceof \PHPUnit_Framework_TestCase) {
         $groups = \PHPUnit_Util_Test::getGroups(get_class($test), $test->getName(false));
         if (in_array('time-sensitive', $groups, true)) {
             ClockMock::withClockMock(false);
         }
     }
 }
Пример #7
0
 public function tearDown()
 {
     parent::tearDown();
     ClockMock::withClockMock(false);
 }
Пример #8
-1
 /**
  * @group time-sensitive
  */
 public function setUp()
 {
     $kernel = static::createKernel();
     $kernel->boot();
     $this->SlaveRequestRepository = $kernel->getContainer()->get('doctrine.orm.entity_manager')->getRepository('AppBundle:slave_request');
     ClockMock::register(__CLASS__);
 }