forked from kimai/kimai1
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
17c3bf9
commit 2e04bfa
Showing
7 changed files
with
212 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
/** | ||
* This file is part of | ||
* Kimai - Open Source Time Tracking // http://www.kimai.org | ||
* (c) Kimai-Development-Team since 2006 | ||
* | ||
* Kimai is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; Version 3, 29 June 2007 | ||
* | ||
* Kimai is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Kimai; If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
namespace KimaiTest; | ||
|
||
use PHPUnit_Framework_TestCase; | ||
|
||
/** | ||
* Base and helper class for Kimai Unittests. | ||
*/ | ||
class TestCase extends PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
private $kgaLast; | ||
|
||
|
||
protected function setKga($kgaNew) | ||
{ | ||
global $kga; | ||
|
||
if (null !== $kga) { | ||
$this->kgaLast = clone $kga; | ||
} | ||
$kga = $kgaNew; | ||
} | ||
|
||
protected function resetKga() | ||
{ | ||
if (null === $this->kgaLast) { | ||
return; | ||
} | ||
|
||
global $kga; | ||
|
||
$kga = $this->kgaLast; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
/** | ||
* This file is part of | ||
* Kimai - Open Source Time Tracking // http://www.kimai.org | ||
* (c) Kimai-Development-Team since 2006 | ||
* | ||
* Kimai is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; Version 3, 29 June 2007 | ||
* | ||
* Kimai is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Kimai; If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
namespace KimaiTest; | ||
|
||
use Kimai_Format; | ||
|
||
/** | ||
* Class UserTest | ||
* | ||
* @coversDefaultClass Kimai_Format | ||
*/ | ||
class FormatTest extends TestCase | ||
{ | ||
|
||
/** | ||
* @covers ::hourminsec | ||
*/ | ||
public function testhourminsec() | ||
{ | ||
$actual = Kimai_Format::hourminsec(100000); | ||
$this->assertArrayHasKey('h', $actual); | ||
$this->assertArrayHasKey('i', $actual); | ||
$this->assertArrayHasKey('s', $actual); | ||
$this->assertEquals(3, $actual['h']); | ||
$this->assertEquals(46, $actual['i']); | ||
$this->assertEquals(40, $actual['s']); | ||
|
||
$actual = Kimai_Format::hourminsec(74159); | ||
$this->assertArrayHasKey('h', $actual); | ||
$this->assertArrayHasKey('i', $actual); | ||
$this->assertArrayHasKey('s', $actual); | ||
$this->assertEquals(20, $actual['h']); | ||
$this->assertEquals(35, $actual['i']); | ||
$this->assertEquals(59, $actual['s']); | ||
|
||
$actual = Kimai_Format::hourminsec(1); | ||
$this->assertArrayHasKey('h', $actual); | ||
$this->assertArrayHasKey('i', $actual); | ||
$this->assertArrayHasKey('s', $actual); | ||
$this->assertEquals(0, $actual['h']); | ||
$this->assertEquals(0, $actual['i']); | ||
$this->assertEquals(1, $actual['s']); | ||
} | ||
|
||
/** | ||
* @covers ::addEllipsis | ||
*/ | ||
public function testaddEllipsis() | ||
{ | ||
$actual = Kimai_Format::addEllipsis('HelloWorldThisIsMe', 40); | ||
$this->assertEquals('HelloWorldThisIsMe', $actual); | ||
|
||
$actual = Kimai_Format::addEllipsis('HelloWorldThisIsMe', 13); | ||
$this->assertEquals('HelloWorld...', $actual); | ||
|
||
$actual = Kimai_Format::addEllipsis('HelloWorldThisIsMe', 13, ' -/'); | ||
$this->assertEquals('HelloWorld -/', $actual); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
/** | ||
* This file is part of | ||
* Kimai - Open Source Time Tracking // http://www.kimai.org | ||
* (c) Kimai-Development-Team since 2006 | ||
* | ||
* Kimai is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; Version 3, 29 June 2007 | ||
* | ||
* Kimai is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Kimai; If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
namespace KimaiTest; | ||
|
||
use Kimai_View; | ||
|
||
/** | ||
* Class UserTest | ||
* | ||
* @coversDefaultClass Kimai_View | ||
*/ | ||
class ViewTest extends TestCase | ||
{ | ||
|
||
/** | ||
* @covers ::init | ||
*/ | ||
public function testInit() | ||
{ | ||
$myKga = array('foo' => 'bar'); | ||
$this->setKga($myKga); | ||
|
||
$view = new Kimai_View(); | ||
|
||
$helperPaths = $view->getHelperPaths(); | ||
$this->assertArrayHasKey('Zend_View_Helper_', $helperPaths); | ||
$this->assertContains(APPLICATION_PATH . '/templates/helpers/', $helperPaths['Zend_View_Helper_']); | ||
|
||
$scriptsPaths = $view->getScriptPaths(); | ||
$this->assertContains(APPLICATION_PATH . '/templates/scripts/', $scriptsPaths); | ||
|
||
$vars = $view->getVars(); | ||
$this->assertArrayHasKey('kga', $vars); | ||
|
||
$this->assertEquals($myKga, $vars['kga']); | ||
} | ||
} |