Skip to content

Instantly share code, notes, and snippets.

@jsdecena
Created October 9, 2021 05:12
Show Gist options
  • Save jsdecena/86836c561d30bbf4ae6734a42b3e1fd2 to your computer and use it in GitHub Desktop.
Save jsdecena/86836c561d30bbf4ae6734a42b3e1fd2 to your computer and use it in GitHub Desktop.
Simple TDD - Timezone test - success
<?php
namespace Jsdecena\Simpletdd\Tests\Unit;
use Carbon\Carbon;
use DateTimeZone;
use Illuminate\Foundation\Application;
use Orchestra\Testbench\TestCase;
class TimezoneTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
}
/**
* Define environment setup.
*
* @param Application $app
* @return void
*/
protected function getEnvironmentSetUp($app)
{
// Setup default database to use sqlite :memory:
$app['config']->set('simpletdd.timezone', 'America/Los_Angeles');
}
/**
* @param Application $app
* @return array
*/
protected function getPackageProviders($app)
{
return ['Jsdecena\SimpleTdd\ServiceProvider'];
}
/** @test */
public function it_should_get_the_config_tz()
{
$tzNow = Carbon::now(new DateTimeZone(config('simpletdd.timezone')));
$this->assertEquals("America/Los_Angeles", $tzNow->getTimezone()->getName());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment