Skip to content

Commit

Permalink
Merge pull request #1 from activecollab/mixed-improvement
Browse files Browse the repository at this point in the history
Mixed improvement
  • Loading branch information
ilijastuden committed Apr 26, 2016
2 parents 1c2a1d7 + 8bdb0a9 commit c7b0af1
Show file tree
Hide file tree
Showing 14 changed files with 162 additions and 38 deletions.
50 changes: 50 additions & 0 deletions .php_cs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

/*
* This file is part of the Active Collab ID project.
*
* (c) A51 doo <[email protected]>. All rights reserved.
*/

$header = <<<EOF
This file is part of the Active Collab DateValue project.
(c) A51 doo <[email protected]>. All rights reserved.
EOF;

Symfony\CS\Fixer\Contrib\HeaderCommentFixer::setHeader($header);

return (new Symfony\CS\Config\Config('psr2'))->fixers([
'header_comment',
'array_element_no_space_before_comma',
'array_element_white_space_after_comma',
'double_arrow_multiline_whitespaces',
'hash_to_slash_comment',
'include',
'join_function',
'multiline_array_trailing_comma',
'namespace_no_leading_whitespace',
'no_blank_lines_after_class_opening ',
'no_empty_lines_after_phpdocs',
'phpdoc_scalar',
'phpdoc_short_description',
'self_accessor',
'single_array_no_trailing_comma',
'single_blank_line_before_namespace',
'spaces_after_semicolon',
'spaces_before_semicolon',
'spaces_cast',
'standardize_not_equal',
'ternary_spaces',
'trim_array_spaces',
'unused_use',
'whitespacy_lines',
'ordered_use',
'short_array_syntax',
'phpdoc_params',
'-phpdoc_separation',
'-phpdoc_no_package',
'-print_to_echo',
'-concat_without_spaces',
'-empty_return',
])->finder((new Symfony\CS\Finder\DefaultFinder())->in([__DIR__ . '/src', __DIR__ . '/test']));
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ php:
- 5.6
- '7'
install: composer install --dev
script: phpunit -c test/phpunit.xml
script: phpunit
19 changes: 19 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<phpunit bootstrap="./test/bootstrap.php"
backupGlobals="false"
backupStaticAttributes="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
syntaxCheck="false"
processIsolation="false"
colors="true">
<testsuites>
<testsuite name="DateFile">
<directory>./test/src</directory>
</testsuite>
</testsuites>
</phpunit>
6 changes: 6 additions & 0 deletions src/DateTimeValue.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<?php

/*
* This file is part of the Active Collab DateValue project.
*
* (c) A51 doo <[email protected]>. All rights reserved.
*/

namespace ActiveCollab\DateValue;

use Carbon\Carbon;
Expand Down
11 changes: 10 additions & 1 deletion src/DateTimeValueInterface.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
<?php

/*
* This file is part of the Active Collab DateValue project.
*
* (c) A51 doo <[email protected]>. All rights reserved.
*/

namespace ActiveCollab\DateValue;

use DateTimeInterface;
use JsonSerializable;

/**
* @package ActiveCollab\DateValue
*/
interface DateTimeValueInterface extends \DateTimeInterface, \JsonSerializable
interface DateTimeValueInterface extends DateTimeInterface, JsonSerializable
{
}
8 changes: 7 additions & 1 deletion src/DateValue.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<?php

/*
* This file is part of the Active Collab DateValue project.
*
* (c) A51 doo <[email protected]>. All rights reserved.
*/

namespace ActiveCollab\DateValue;

use Carbon\Carbon;
Expand All @@ -12,7 +18,7 @@ class DateValue extends Carbon implements DateValueInterface
/**
* Create a new DateValue instance.
*
* @param string $time
* @param string $time
* @param \DateTimeZone|string $tz
*/
public function __construct($time = null, $tz = null)
Expand Down
11 changes: 10 additions & 1 deletion src/DateValueInterface.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
<?php

/*
* This file is part of the Active Collab DateValue project.
*
* (c) A51 doo <[email protected]>. All rights reserved.
*/

namespace ActiveCollab\DateValue;

use DateTimeInterface;
use JsonSerializable;

/**
* @package ActiveCollab\DateValue
*/
interface DateValueInterface extends \DateTimeInterface, \JsonSerializable
interface DateValueInterface extends DateTimeInterface, JsonSerializable
{
}
8 changes: 7 additions & 1 deletion test/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
<?php

/*
* This file is part of the Active Collab DateValue project.
*
* (c) A51 doo <[email protected]>. All rights reserved.
*/

defined('BASE_PATH') || define('BASE_PATH', realpath(__DIR__));
date_default_timezone_set('GMT');

require dirname(__DIR__).'/vendor/autoload.php';
require __DIR__.'/src/TestCase.php';
require __DIR__.'/src/TestCase/TestCase.php';
7 changes: 0 additions & 7 deletions test/phpunit.xml

This file was deleted.

19 changes: 13 additions & 6 deletions test/src/ClassesTest.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
<?php

/*
* This file is part of the Active Collab DateValue project.
*
* (c) A51 doo <[email protected]>. All rights reserved.
*/

namespace ActiveCollab\DateValue\Test;

use ActiveCollab\DateValue\DateValueInterface;
use ActiveCollab\DateValue\DateValue;
use ActiveCollab\DateValue\DateTimeValueInterface;
use ActiveCollab\DateValue\DateTimeValue;
use ActiveCollab\DateValue\DateTimeValueInterface;
use ActiveCollab\DateValue\DateValue;
use ActiveCollab\DateValue\DateValueInterface;
use ActiveCollab\DateValue\Test\TestCase\TestCase;
use ReflectionClass;

/**
Expand All @@ -14,7 +21,7 @@
class ClassesTest extends TestCase
{
/**
* Test if date value class exists
* Test if date value class exists.
*/
public function testDateValueClass()
{
Expand All @@ -23,11 +30,11 @@ public function testDateValueClass()
}

/**
* Test if date time value class exists
* Test if date time value class exists.
*/
public function testDateTimeValueClass()
{
$this->assertTrue(class_exists(DateTimeValue::class, true));
$this->assertTrue((new ReflectionClass(DateTimeValue::class))->implementsInterface(DateTimeValueInterface::class));
}
}
}
19 changes: 13 additions & 6 deletions test/src/JsonSerializeTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
<?php

/*
* This file is part of the Active Collab DateValue project.
*
* (c) A51 doo <[email protected]>. All rights reserved.
*/

namespace ActiveCollab\DateValue\Test;

use ActiveCollab\DateValue\DateValue;
use ActiveCollab\DateValue\DateTimeValue;
use ActiveCollab\DateValue\DateValue;
use ActiveCollab\DateValue\Test\TestCase\TestCase;

/**
* @package ActiveCollab\DateValue\Test
Expand All @@ -16,7 +23,7 @@ class JsonSerializeTest extends TestCase
private $reference;

/**
* Set up test environment
* Set up test environment.
*/
public function setUp()
{
Expand All @@ -28,7 +35,7 @@ public function setUp()
}

/**
* Tear down test environment
* Tear down test environment.
*/
public function tearDown()
{
Expand All @@ -38,7 +45,7 @@ public function tearDown()
}

/**
* Test date serialization
* Test date serialization.
*/
public function testSerializeDate()
{
Expand All @@ -54,7 +61,7 @@ public function testSerializeDate()
}

/**
* Test date time serialization
* Test date time serialization.
*/
public function testSerializeDateTime()
{
Expand All @@ -65,4 +72,4 @@ public function testSerializeDateTime()

$this->assertEquals($this->reference->getTimestamp(), json_decode(json_encode(new DateTimeValue()), true));
}
}
}
18 changes: 11 additions & 7 deletions test/src/NowTest.php
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
<?php

/*
* This file is part of the Active Collab DateValue project.
*
* (c) A51 doo <[email protected]>. All rights reserved.
*/

namespace ActiveCollab\DateValue\Test;

use ActiveCollab\DateValue\DateValueInterface;
use ActiveCollab\DateValue\DateValue;
use ActiveCollab\DateValue\DateTimeValueInterface;
use ActiveCollab\DateValue\DateTimeValue;
use ReflectionClass;
use ActiveCollab\DateValue\DateValue;
use ActiveCollab\DateValue\Test\TestCase\TestCase;

/**
* @package ActiveCollab\DateValue\Test
*/
class NowTest extends TestCase
{
/**
* Test if now uses current timestamp
* Test if now uses current timestamp.
*/
public function testRealNow()
{
$this->assertEquals((new DateTimeValue())->format('Y-m-d H:i:s'), date('Y-m-d H:i:s'));
}

/**
* Test if now can be overriden, for test purposes
* Test if now can be overriden, for test purposes.
*/
public function testTestNow()
{
DateTimeValue::setTestNow(new DateTimeValue('2013-10-02 11:18:32'));

$this->assertEquals((new DateTimeValue())->format('Y-m-d H:i:s'), date('2013-10-02 11:18:32'));
}
}
}
7 changes: 0 additions & 7 deletions test/src/TestCase.php

This file was deleted.

15 changes: 15 additions & 0 deletions test/src/TestCase/TestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

/*
* This file is part of the Active Collab DateValue project.
*
* (c) A51 doo <[email protected]>. All rights reserved.
*/

namespace ActiveCollab\DateValue\Test\TestCase;

use PHPUnit_Framework_TestCase;

abstract class TestCase extends PHPUnit_Framework_TestCase
{
}

0 comments on commit c7b0af1

Please sign in to comment.