当前位置: 首页>>代码示例>>PHP>>正文


PHP Carbon::setTestNow方法代码示例

本文整理汇总了PHP中Carbon\Carbon::setTestNow方法的典型用法代码示例。如果您正苦于以下问题:PHP Carbon::setTestNow方法的具体用法?PHP Carbon::setTestNow怎么用?PHP Carbon::setTestNow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Carbon\Carbon的用法示例。


在下文中一共展示了Carbon::setTestNow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: showLogsBySpecificDate

 public function showLogsBySpecificDate($day, $month, $year)
 {
     $date = $day . "/" . $month . "/" . $year;
     $today = $this->getCurrentDate();
     $currentDate = $today['currentDay'] . "/" . $today['currentMonth'] . "/" . $today['currentYear'];
     if ($date == $currentDate) {
         return redirect('day');
     }
     $targetDateObject = Carbon::createFromFormat('d/m/Y', $date);
     $targetDateArray = $this->dateObjectToArray($targetDateObject);
     Carbon::setTestNow($targetDateObject);
     $dateObjectYesterday = $targetDateObject->yesterday();
     $dateObjectTomorrow = $targetDateObject->tomorrow();
     $dateArrayYesterday = $this->dateObjectToArray($dateObjectYesterday);
     $dateArrayTomorrow = $this->dateObjectToArray($dateObjectTomorrow);
     $dayBefore = $dateArrayYesterday['currentDay'] . "/" . $dateArrayYesterday['currentMonth'] . "/" . $dateArrayYesterday['currentYear'];
     $dayAfter = $dateArrayTomorrow['currentDay'] . "/" . $dateArrayTomorrow['currentMonth'] . "/" . $dateArrayTomorrow['currentYear'];
     //checks if a lists exists for a corresponnding date. If there is no list, returns a null value.
     $currentList = $this->listRepository->getSpecificList($date);
     if (!empty($currentList)) {
         $currentListID = $currentList->id;
         $logsData = $this->logRepository->getSpecificLogs($currentListID);
         if (empty($logsData)) {
             $logsData = null;
         }
     } else {
         $logsData = null;
     }
     $data = ['thisDay' => "class = active ", 'thisWeek' => '', 'thisMonth' => '', 'id' => 'thisDay'];
     $dayName = $targetDateArray['currentDayName'];
     $monthName = $targetDateArray['currentMonthName'];
     $day = $targetDateArray['currentDay'];
     $year = $targetDateArray['currentYear'];
     return view('main-tabs.thisDay', $data)->with('logsData', $logsData)->with('dayBefore', $dayBefore)->with('dayAfter', $dayAfter)->with('dayName', $dayName)->with('monthName', $monthName)->with('day', $day)->with('year', $year);
 }
开发者ID:Timmerdev,项目名称:timmer_app,代码行数:35,代码来源:LogController.php

示例2: specificDatesOfWeek

 public function specificDatesOfWeek($year, $month, $day)
 {
     $weekSpecified = Carbon::create($year, $month, $day, 0);
     //setting the date passed as the current date for subtraction and addition using carbon functions
     Carbon::setTestNow($weekSpecified);
     $targetDay = $this->dateObjectToArray($weekSpecified);
     //retrieving data for the next 3 days prior and after the currentDate
     $dateDayAfter = $weekSpecified->tomorrow();
     $dateDayBefore = $weekSpecified->yesterday();
     $dateDayAfter2 = $weekSpecified->tomorrow()->addDay();
     $dateDayAfter3 = $weekSpecified->tomorrow()->addDays(2);
     $dateDayBefore2 = $weekSpecified->yesterday()->subDay();
     $dateDayBefore3 = $weekSpecified->yesterday()->subDays(2);
     $weekBeforeObject = $weekSpecified->yesterday()->subDays(6);
     $weekAfterObject = $weekSpecified->tomorrow()->addDays(6);
     //unsetting the date
     Carbon::setTestNow();
     //putting the data in the array using the function using the ObjectToArray Trait
     $dayAfter = $this->dateObjectToArray($dateDayAfter);
     $dayBefore = $this->dateObjectToArray($dateDayBefore);
     $dayAfter2 = $this->dateObjectToArray($dateDayAfter2);
     $dayAfter3 = $this->dateObjectToArray($dateDayAfter3);
     $dayBefore2 = $this->dateObjectToArray($dateDayBefore2);
     $dayBefore3 = $this->dateObjectToArray($dateDayBefore3);
     $weekBefore = $this->dateObjectToArray($weekBeforeObject);
     $weekAfter = $this->dateObjectToArray($weekAfterObject);
     $data = ['thisDay' => '', 'thisWeek' => "class = active ", 'thisMonth' => '', 'id' => 'thisWeek'];
     // $listdata = $this->listRepository->getLists();
     return view('main-tabs.thisWeek', $data)->with('targetDay', $targetDay)->with('dayBefore', $dayBefore)->with('dayAfter', $dayAfter)->with('dayAfter2', $dayAfter2)->with('dayAfter3', $dayAfter3)->with('dayBefore2', $dayBefore2)->with('dayBefore3', $dayBefore3)->with('weekYearBefore', $weekBefore['currentYear'])->with('weekYearAfter', $weekAfter['currentYear'])->with('weekMonthBefore', $weekBefore['currentMonth'])->with('weekMonthAfter', $weekAfter['currentMonth'])->with('weekDayBefore', $weekBefore['currentDay'])->with('weekDayAfter', $weekAfter['currentDay']);
 }
开发者ID:Timmerdev,项目名称:timmer_app,代码行数:30,代码来源:ListsController.php

示例3: setUp

 public function setUp()
 {
     Carbon::setTestNow(Carbon::createFromTimeStampUTC(123));
     $this->claimFactory = Mockery::mock('Tymon\\JWTAuth\\Claims\\Factory');
     $this->validator = Mockery::mock('Tymon\\JWTAuth\\Validators\\PayloadValidator');
     $this->factory = new PayloadFactory($this->claimFactory, Request::create('/foo', 'GET'), $this->validator);
 }
开发者ID:w0rd-driven,项目名称:jwt-auth,代码行数:7,代码来源:PayloadFactoryTest.php

示例4: testSendMessage

 public function testSendMessage()
 {
     // Create an old email to purge
     Config::set('mail-tracker.expire-days', 1);
     $old_email = \jdavidbakr\MailTracker\Model\SentEmail::create(['hash' => str_random(32)]);
     $old_url = \jdavidbakr\MailTracker\Model\SentEmailUrlClicked::create(['sent_email_id' => $old_email->id, 'hash' => str_random(32)]);
     // Go into the future to make sure that the old email gets removed
     \Carbon\Carbon::setTestNow(\Carbon\Carbon::now()->addWeek());
     $faker = Faker\Factory::create();
     $email = $faker->email;
     $subject = $faker->sentence;
     $name = $faker->firstName . ' ' . $faker->lastName;
     \View::addLocation(__DIR__);
     \Mail::send('email.test', [], function ($message) use($email, $subject, $name) {
         $message->from('from@johndoe.com', 'From Name');
         $message->sender('sender@johndoe.com', 'Sender Name');
         $message->to($email, $name);
         $message->cc('cc@johndoe.com', 'CC Name');
         $message->bcc('bcc@johndoe.com', 'BCC Name');
         $message->replyTo('reply-to@johndoe.com', 'Reply-To Name');
         $message->subject($subject);
         $message->priority(3);
     });
     $this->seeInDatabase('sent_emails', ['recipient' => $name . ' <' . $email . '>', 'subject' => $subject, 'sender' => 'From Name <from@johndoe.com>', 'recipient' => "{$name} <{$email}>"]);
     $this->assertNull($old_email->fresh());
     $this->assertNull($old_url->fresh());
 }
开发者ID:jdavidbakr,项目名称:mail-tracker,代码行数:27,代码来源:MailTrackerTest.php

示例5: testParseRelativeWithTestValueSet

 public function testParseRelativeWithTestValueSet()
 {
     $notNow = Carbon::parse('2013-09-01 05:15:05');
     Carbon::setTestNow($notNow);
     $this->assertEquals('2013-09-01 05:10:05', Carbon::parse('5 minutes ago')->toDateTimeString());
     $this->assertEquals('2013-08-25 05:15:05', Carbon::parse('1 week ago')->toDateTimeString());
     $this->assertEquals('2013-09-02 00:00:00', Carbon::parse('tomorrow')->toDateTimeString());
     $this->assertEquals('2013-08-31 00:00:00', Carbon::parse('yesterday')->toDateTimeString());
     $this->assertEquals('2013-09-02 05:15:05', Carbon::parse('+1 day')->toDateTimeString());
     $this->assertEquals('2013-08-31 05:15:05', Carbon::parse('-1 day')->toDateTimeString());
     $this->assertEquals('2013-09-02 00:00:00', Carbon::parse('next monday')->toDateTimeString());
     $this->assertEquals('2013-09-03 00:00:00', Carbon::parse('next tuesday')->toDateTimeString());
     $this->assertEquals('2013-09-04 00:00:00', Carbon::parse('next wednesday')->toDateTimeString());
     $this->assertEquals('2013-09-05 00:00:00', Carbon::parse('next thursday')->toDateTimeString());
     $this->assertEquals('2013-09-06 00:00:00', Carbon::parse('next friday')->toDateTimeString());
     $this->assertEquals('2013-09-07 00:00:00', Carbon::parse('next saturday')->toDateTimeString());
     $this->assertEquals('2013-09-08 00:00:00', Carbon::parse('next sunday')->toDateTimeString());
     $this->assertEquals('2013-08-26 00:00:00', Carbon::parse('last monday')->toDateTimeString());
     $this->assertEquals('2013-08-27 00:00:00', Carbon::parse('last tuesday')->toDateTimeString());
     $this->assertEquals('2013-08-28 00:00:00', Carbon::parse('last wednesday')->toDateTimeString());
     $this->assertEquals('2013-08-29 00:00:00', Carbon::parse('last thursday')->toDateTimeString());
     $this->assertEquals('2013-08-30 00:00:00', Carbon::parse('last friday')->toDateTimeString());
     $this->assertEquals('2013-08-31 00:00:00', Carbon::parse('last saturday')->toDateTimeString());
     $this->assertEquals('2013-08-25 00:00:00', Carbon::parse('last sunday')->toDateTimeString());
     $this->assertEquals('2013-09-02 00:00:00', Carbon::parse('this monday')->toDateTimeString());
     $this->assertEquals('2013-09-03 00:00:00', Carbon::parse('this tuesday')->toDateTimeString());
     $this->assertEquals('2013-09-04 00:00:00', Carbon::parse('this wednesday')->toDateTimeString());
     $this->assertEquals('2013-09-05 00:00:00', Carbon::parse('this thursday')->toDateTimeString());
     $this->assertEquals('2013-09-06 00:00:00', Carbon::parse('this friday')->toDateTimeString());
     $this->assertEquals('2013-09-07 00:00:00', Carbon::parse('this saturday')->toDateTimeString());
     $this->assertEquals('2013-09-01 00:00:00', Carbon::parse('this sunday')->toDateTimeString());
     $this->assertEquals('2013-10-01 05:15:05', Carbon::parse('first day of next month')->toDateTimeString());
     $this->assertEquals('2013-09-30 05:15:05', Carbon::parse('last day of this month')->toDateTimeString());
 }
开发者ID:Thomvh,项目名称:turbine,代码行数:34,代码来源:TestingAidsTest.php

示例6: should_be_invalid_when_expired

 /** @test */
 public function should_be_invalid_when_expired()
 {
     Carbon::setTestNow(Carbon::create(2014, 10, 11, 10, 23, 34));
     $reminder = new Reminder($this->id, $this->email, $this->code);
     Carbon::setTestNow(Carbon::create(2014, 10, 11, 11, 25, 12));
     $this->assertFalse($reminder->isValid());
 }
开发者ID:kfuchs,项目名称:cribbb,代码行数:8,代码来源:ReminderTest.php

示例7: createApplication

 /**
  * Creates a Lumen application.
  *
  * @return \Laravel\Lumen\Application
  */
 protected function createApplication()
 {
     putenv('APP_ENV=' . $this->getEnv());
     $app = (require $this->appPath);
     Carbon::setTestNow(Carbon::now());
     return $app;
 }
开发者ID:josborne,项目名称:phpspec-lumen,代码行数:12,代码来源:Lumen.php

示例8: createApplication

 /**
  * Creates a Laravel application.
  *
  * @return \Illuminate\Foundation\Application
  */
 protected function createApplication()
 {
     putenv('APP_ENV=' . $this->getEnv());
     $app = (require $this->appPath);
     $app->bootstrapWith(['Illuminate\\Foundation\\Bootstrap\\DetectEnvironment', 'Illuminate\\Foundation\\Bootstrap\\LoadConfiguration', 'Illuminate\\Foundation\\Bootstrap\\ConfigureLogging', 'Illuminate\\Foundation\\Bootstrap\\HandleExceptions', 'Illuminate\\Foundation\\Bootstrap\\RegisterFacades', 'Illuminate\\Foundation\\Bootstrap\\SetRequestForConsole', 'Illuminate\\Foundation\\Bootstrap\\RegisterProviders', 'Illuminate\\Foundation\\Bootstrap\\BootProviders']);
     Carbon::setTestNow(Carbon::now());
     return $app;
 }
开发者ID:benconstable,项目名称:phpspec-laravel,代码行数:13,代码来源:Laravel.php

示例9: should_find_reminder_and_return_false_when_invalid

 /** @test */
 public function should_find_reminder_and_return_false_when_invalid()
 {
     Carbon::setTestNow(Carbon::create(2014, 10, 11, 10, 23, 34));
     $reminder = new Reminder($this->fixture['id'], $this->fixture['email'], $this->fixture['code']);
     Carbon::setTestNow();
     $this->reminders->shouldReceive('findReminderByEmailAndCode')->andReturn($reminder);
     $this->assertFalse($this->service->check('name@domain.com', 'abc123'));
 }
开发者ID:Evyy,项目名称:cffs-api,代码行数:9,代码来源:ReminderServiceTest.php

示例10: testSetDefaultEndDate

 public function testSetDefaultEndDate()
 {
     $knownDate = Carbon::createFromDate(2001, 5, 21);
     // create testing date
     Carbon::setTestNow($knownDate);
     $this->salary->setEndDate();
     $this->assertEquals('2001-12-31', $this->tester->getPrivateProperty($this->salary, 'endDate')->toDateString());
 }
开发者ID:Oxyaction,项目名称:salary-calendar,代码行数:8,代码来源:SalaryCalendarTest.php

示例11: setUp

 public function setUp()
 {
     Carbon::setTestNow(Carbon::createFromTimeStampUTC(123));
     $claims = [new Subject(1), new Issuer('http://example.com'), new Expiration(123 + 3600), new NotBefore(123), new IssuedAt(123), new JwtId('foo')];
     $this->validator = Mockery::mock('Tymon\\JWTAuth\\Validators\\PayloadValidator');
     $this->validator->shouldReceive('setRefreshFlow->check');
     $this->payload = new Payload($claims, $this->validator);
 }
开发者ID:w0rd-driven,项目名称:jwt-auth,代码行数:8,代码来源:PayloadTest.php

示例12: setUp

 public function setUp()
 {
     Carbon::setTestNow(Carbon::createFromTimeStampUTC(123));
     $this->storage = Mockery::mock('Tymon\\JWTAuth\\Providers\\Storage\\StorageInterface');
     $this->blacklist = new Blacklist($this->storage);
     $this->blacklist->setRefreshTTL(20160);
     $this->validator = Mockery::mock('Tymon\\JWTAuth\\Validators\\PayloadValidator');
     $this->validator->shouldReceive('setRefreshFlow->check');
 }
开发者ID:w0rd-driven,项目名称:jwt-auth,代码行数:9,代码来源:BlacklistTest.php

示例13: testSaveWithGoodData

 public function testSaveWithGoodData()
 {
     // prevent tests breaking due to rolling into the next second
     Carbon::setTestNow($c = Carbon::now());
     $expected = ['id' => 12345, 'name' => 'Foo Baz', 'username' => 'baz', 'email' => 'baz@foo.com', 'updated_at' => (string) $c, 'created_at' => (string) $c];
     $user = User::create(['id' => '12345', 'name' => 'Foo Baz', 'username' => 'baz', 'email' => 'baz@foo.com', 'token' => str_repeat('a', 40)]);
     $this->assertInstanceOf(User::class, $user);
     $this->assertSame($expected, $user->toArray());
 }
开发者ID:clarkeash,项目名称:StyleCI,代码行数:9,代码来源:UserTest.php

示例14: testSaveWithGoodData

 public function testSaveWithGoodData()
 {
     // prevent tests breaking due to rolling into the next second
     Carbon::setTestNow($c = Carbon::now());
     $expected = ['id' => 12345, 'user_id' => 4242, 'name' => 'Foo/Baz', 'default_branch' => 'lol', 'updated_at' => (string) $c, 'created_at' => (string) $c];
     $repo = Repo::create(['id' => '12345', 'user_id' => '4242', 'name' => 'Foo/Baz', 'default_branch' => 'lol', 'token' => str_repeat('a', 20)]);
     $this->assertInstanceOf(Repo::class, $repo);
     $this->assertSame($expected, $repo->toArray());
 }
开发者ID:mikaelmattsson,项目名称:StyleCI,代码行数:9,代码来源:RepoTest.php

示例15: it_edits_a_album_review_with_an_album_cover

 /** @test */
 public function it_edits_a_album_review_with_an_album_cover()
 {
     $album = TestDummy::create('WITR\\AlbumReview', ['img_name' => '01234-review.jpg']);
     copy(__DIR__ . '/files/review.jpg', public_path() . '/img/albums/01234-review.jpg');
     $form = TestDummy::attributesFor('WITR\\AlbumReview', ['band_name' => 'test band_name', 'album_name' => 'test album', 'review' => 'test review', 'img_name' => __DIR__ . '/files/review.jpg']);
     Carbon::setTestNow(Carbon::create(2014, 5, 21, 12));
     $dbEntry = $form;
     $dbEntry['img_name'] = Carbon::now()->timestamp . '-review.jpg';
     $this->beEditor();
     $this->visit('/admin/reviews/' . $album->id)->onPage('/admin/reviews/' . $album->id)->submitForm('Update Review', $form)->andSee('Album Review Saved!')->onPage('/admin/reviews')->verifyInDatabase('album_reviews', $dbEntry)->cannotSeeFile(public_path() . '/img/albums/' . $album->img_name)->seeFile(public_path() . '/img/albums/' . $dbEntry['img_name']);
 }
开发者ID:woolensculpture,项目名称:pulse,代码行数:12,代码来源:AlbumReviewControllerTest.php


注:本文中的Carbon\Carbon::setTestNow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。