8 files changed
+2988
-4
No files matched your search
@@ -0,0 +1,4 @@
|
||||
vendor/
|
||||
.idea/
|
||||
*.phpunit.result.cache
|
||||
*.bat
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
language: php
|
||||
|
||||
sudo: true
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- php: 7.2
|
||||
env: LARAVEL_VERSION=5.1.*
|
||||
- php: 7.2
|
||||
env: LARAVEL_VERSION=5.3.*
|
||||
- php: 7.2
|
||||
env: LARAVEL_VERSION=5.5.*
|
||||
- php: 7.2
|
||||
env: LARAVEL_VERSION=5.6.*
|
||||
- php: 7.2
|
||||
env: LARAVEL_VERSION=5.7.*
|
||||
- php: 7.2
|
||||
env: LARAVEL_VERSION=5.7.*
|
||||
- php: 7.3
|
||||
env: LARAVEL_VERSION=5.7.*
|
||||
- php: 7.2
|
||||
env: LARAVEL_VERSION=5.8.*
|
||||
- php: 7.3
|
||||
env: LARAVEL_VERSION=5.8.*
|
||||
|
||||
before_install:
|
||||
- composer self-update --stable -n
|
||||
|
||||
install:
|
||||
- travis_retry composer install --no-suggest
|
||||
|
||||
script:
|
||||
- vendor/bin/phpunit --coverage-clover clover.xml;
|
||||
|
||||
after_script:
|
||||
- wget https://scrutinizer-ci.com/ocular.phar;
|
||||
- php ocular.phar code-coverage:upload --format=php-clover clover.xml;
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
+11
-2
@@ -12,9 +12,13 @@
|
||||
"require": {
|
||||
"php": ">=5.5",
|
||||
"hekmatinasser/notowo": "^1.0",
|
||||
"illuminate/validation": "^5"
|
||||
"illuminate/validation": "^5",
|
||||
"illuminate/support": "^5"
|
||||
},
|
||||
"require-dev" : {
|
||||
"phpunit/phpunit": "7.2.*",
|
||||
"mockery/mockery": "^1.0"
|
||||
},
|
||||
"require-dev" : {},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Hekmatinasser\\Verta\\": "src"
|
||||
@@ -23,6 +27,11 @@
|
||||
"src/helpers.php"
|
||||
]
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Hekmatinasser\\VertaTests\\": "tests"
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
|
||||
Generated
+2830
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
beStrictAboutTestsThatDoNotTestAnything="false"
|
||||
bootstrap="tests/bootstrap.php"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnError="false"
|
||||
stopOnFailure="false"
|
||||
verbose="true"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Laravel Test Suite">
|
||||
<directory suffix="Test.php">./tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">./src</directory>
|
||||
<exclude>
|
||||
<directory suffix=".blade.php">./src/</directory>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
<php>
|
||||
<!--
|
||||
<env name="REDIS_HOST" value="127.0.0.1" />
|
||||
<env name="REDIS_PORT" value="6379" />
|
||||
-->
|
||||
</php>
|
||||
</phpunit>
|
||||
+3
-2
@@ -13,6 +13,7 @@ namespace Hekmatinasser\Verta;
|
||||
|
||||
use DateTime;
|
||||
use DateTimeZone;
|
||||
use Illuminate\Support\Carbon;
|
||||
use InvalidArgumentException;
|
||||
use Hekmatinasser\Notowo\Notowo;
|
||||
|
||||
@@ -246,7 +247,7 @@ class Verta extends DateTime {
|
||||
*/
|
||||
public function __construct($datetime = null, $timezone = null) {
|
||||
if ($datetime === null) {
|
||||
$instance = time();
|
||||
$instance = Carbon::now()->getTimestamp();
|
||||
}
|
||||
elseif (is_string($datetime)){
|
||||
$object = date_create($datetime);
|
||||
@@ -508,7 +509,7 @@ class Verta extends DateTime {
|
||||
public static function createGregorian($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $timezone = null)
|
||||
{
|
||||
|
||||
$now = date('Y-n-j-G-i-s', time());
|
||||
$now = date('Y-n-j-G-i-s', Carbon::now()->getTimestamp());
|
||||
$defaults = array_combine(array('year', 'month', 'day', 'hour', 'minute', 'second'), explode('-', $now));
|
||||
|
||||
$year = $year === null ? intval($defaults['year']) : $year;
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace Hekmatinasser\VertaTests;
|
||||
|
||||
use Hekmatinasser\Verta\Facades\Verta as VertaFacade;
|
||||
use Hekmatinasser\Verta\Verta;
|
||||
use Illuminate\Support\Carbon;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class SampleTest extends TestCase
|
||||
{
|
||||
public function testVertaNow()
|
||||
{
|
||||
Carbon::setTestNow('2019-01-01 00:00:00');
|
||||
|
||||
$shamsiDate = (string)Verta::now();
|
||||
$this->assertEquals('1397-10-11 00:00:00', $shamsiDate);
|
||||
}
|
||||
|
||||
public function testVertaNow2()
|
||||
{
|
||||
Carbon::setTestNow('2019-01-01 00:00:01');
|
||||
|
||||
$shamsiDate = (string)Verta::now();
|
||||
$this->assertEquals('1397-10-11 00:00:01', $shamsiDate);
|
||||
}
|
||||
|
||||
public function testYesterday()
|
||||
{
|
||||
Carbon::setTestNow('2019-01-01 10:20:11');
|
||||
$shamsiDate = (string)Verta::yesterday();
|
||||
$this->assertEquals('1397-10-10 00:00:00', $shamsiDate);
|
||||
$shamsiDate = (string)Verta::tomorrow();
|
||||
$this->assertEquals('1397-10-12 00:00:00', $shamsiDate);
|
||||
$shamsiDate = (string)Verta::today();
|
||||
$this->assertEquals('1397-10-11 00:00:00', $shamsiDate);
|
||||
}
|
||||
|
||||
public function testCreateFromString()
|
||||
{
|
||||
$v = new Verta('2019-01-01 10:20:11');
|
||||
$this->assertEquals('1397-10-11 10:20:11', (string)$v);
|
||||
|
||||
$v = new Verta('2019-01-02 10:20:11');
|
||||
$this->assertEquals('1397-10-12 10:20:11', (string)$v);
|
||||
|
||||
$v = Verta::instance('2019-01-01 10:20:11');
|
||||
$this->assertEquals('1397-10-11 10:20:11', (string)$v);
|
||||
|
||||
$app = ['verta' => new Verta];
|
||||
VertaFacade::setFacadeApplication($app);
|
||||
|
||||
$v = VertaFacade::instance('2019-01-01 10:20:11');
|
||||
|
||||
$this->assertEquals('1397-10-11 10:20:11', (string)$v);
|
||||
}
|
||||
|
||||
public function testDatetime()
|
||||
{
|
||||
$d = new \DateTime('2019-01-01 10:20:11');
|
||||
$f1 = new Verta($d);
|
||||
|
||||
$f2 = new Verta('2019-01-01 10:20:11');
|
||||
|
||||
$this->assertEquals((string)$f1, (string)$f2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<?php
|
||||
Reference in new issue
Block a user