Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
2.78% |
1 / 36 |
CRAP | |
4.41% |
6 / 136 |
SandTest | |
0.00% |
0 / 1 |
|
2.78% |
1 / 36 |
1167.93 | |
4.41% |
6 / 136 |
setUp | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
tearDown | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
testConstructor | |
100.00% |
1 / 1 |
1 | |
100.00% |
6 / 6 |
|||
testAddStatusMessage | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 3 |
|||
testGetStatusMessages | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 3 |
|||
testCleanMessages | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 3 |
|||
testAttachObject | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 3 |
|||
testSetObjectName | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 6 |
|||
testGetObjectName | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
testSetObjectIdentity | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
testSaveObjectIdentity | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
testRestoreObjectIdentity | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
testResetObjectIdentity | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
testDivDataArray | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 7 |
|||
testDataReset | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 3 |
|||
testSetData | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 7 |
|||
testGetData | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 4 |
|||
testGetDataCount | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 4 |
|||
testGetDataValue | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 5 |
|||
testSetDataValue | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 3 |
|||
testUnsetDataValue | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 6 |
|||
testTakeData | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 7 |
|||
testRip | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
testEaseEncrypt | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 3 |
|||
testEaseDecrypt | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 3 |
|||
testRandomNumber | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 7 |
|||
testRandomString | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 4 |
|||
testRecursiveIconv | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 7 |
|||
testArrayIconv | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 5 |
|||
testAddToLog | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
test__toString | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
test__sleep | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
testHumanFilesize | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 7 |
|||
testReindexArrayBy | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 4 |
|||
testDraw | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 3 |
|||
test__wakeup | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
<?php | |
namespace Test\Ease; | |
/** | |
* Generated by PHPUnit_SkeletonGenerator on 2016-01-17 at 09:50:39. | |
*/ | |
class SandTest extends AtomTest | |
{ | |
/** | |
* @var Sand | |
*/ | |
protected $object; | |
/** | |
* Sets up the fixture, for example, opens a network connection. | |
* This method is called before a test is executed. | |
*/ | |
protected function setUp() | |
{ | |
$this->object = new \Ease\Sand(); | |
} | |
/** | |
* Tears down the fixture, for example, closes a network connection. | |
* This method is called after a test is executed. | |
*/ | |
protected function tearDown() | |
{ | |
} | |
public function testConstructor() | |
{ | |
$classname = get_class($this->object); | |
// Get mock, without the constructor being called | |
$mock = $this->getMockBuilder($classname) | |
->disableOriginalConstructor() | |
->getMockForAbstractClass(); | |
$mock->__construct(); | |
} | |
/** | |
* @covers Ease\Sand::addStatusMessage | |
*/ | |
public function testAddStatusMessage() | |
{ | |
$this->object->addStatusMessage('Message1'); | |
$this->assertNotEmpty($this->object->getStatusMessages()); | |
} | |
/** | |
* @covers Ease\Sand::getStatusMessages | |
*/ | |
public function testGetStatusMessages() | |
{ | |
$this->object->addStatusMessage('Message2'); | |
$this->assertNotEmpty($this->object->getStatusMessages(true)); | |
} | |
/** | |
* @covers Ease\Sand::cleanMessages | |
*/ | |
public function testCleanMessages() | |
{ | |
$this->object->cleanMessages(); | |
$this->assertEmpty($this->object->getStatusMessages()); | |
} | |
/** | |
* @covers Ease\Sand::attachObject | |
*/ | |
public function testAttachObject() | |
{ | |
$this->object->attachObject('user', new \stdClass()); | |
$this->assertEquals(new \stdClass(), $this->object->user); | |
} | |
/** | |
* @covers Ease\Sand::setObjectName | |
*/ | |
public function testSetObjectName() | |
{ | |
$this->object->setObjectName('Testing'); | |
$this->assertEquals('Testing', $this->object->getObjectName()); | |
$this->object->setObjectName(); | |
$this->assertEquals(get_class($this->object), | |
$this->object->getObjectName()); | |
} | |
/** | |
* @covers Ease\Sand::getObjectName | |
*/ | |
public function testGetObjectName() | |
{ | |
$this->assertNotEmpty($this->object->getObjectName()); | |
} | |
/** | |
* @covers Ease\Sand::setObjectIdentity | |
*/ | |
public function testSetObjectIdentity() | |
{ | |
$this->object->setObjectIdentity(['myKeyColumn' => 'index_key']); | |
} | |
/** | |
* @covers Ease\Sand::saveObjectIdentity | |
*/ | |
public function testSaveObjectIdentity() | |
{ | |
$this->object->saveObjectIdentity(); | |
} | |
/** | |
* @covers Ease\Sand::restoreObjectIdentity | |
* | |
* @todo Implement testRestoreObjectIdentity(). | |
*/ | |
public function testRestoreObjectIdentity() | |
{ | |
$this->object->resetObjectIdentity(); | |
} | |
/** | |
* @covers Ease\Sand::resetObjectIdentity | |
* | |
* @todo Implement testResetObjectIdentity(). | |
*/ | |
public function testResetObjectIdentity() | |
{ | |
$this->object->resetObjectIdentity(); | |
} | |
/** | |
* @covers Ease\Sand::divDataArray | |
*/ | |
public function testDivDataArray() | |
{ | |
$sourceArray = [1 => 'a', 2 => 'b']; | |
$destinationArray = []; | |
$this->object->divDataArray($sourceArray, $destinationArray, 2); | |
$this->assertEquals([2 => 'b'], $destinationArray); | |
$this->assertFalse($this->object->divDataArray($sourceArray, | |
$destinationArray, 'none')); | |
} | |
/** | |
* @covers Ease\Sand::dataReset | |
*/ | |
public function testDataReset() | |
{ | |
$this->object->dataReset(); | |
$this->assertEmpty($this->object->getData()); | |
} | |
/** | |
* @covers Ease\Sand::setData | |
*/ | |
public function testSetData() | |
{ | |
$this->assertNull($this->object->setData(null)); | |
$data = ['a' => 1, 'b' => 2]; | |
$this->object->setData($data, true); | |
$this->assertEquals($data, $this->object->getData()); | |
$this->object->data = null; | |
$this->assertEquals(1, $this->object->setData(1)); | |
} | |
/** | |
* @covers Ease\Sand::getData | |
* @depends testSetData | |
*/ | |
public function testGetData() | |
{ | |
$data = ['a' => 1, 'b' => 2]; | |
$this->object->setData($data); | |
$this->assertEquals($data, $this->object->getData()); | |
} | |
/** | |
* @covers Ease\Sand::getDataCount | |
*/ | |
public function testGetDataCount() | |
{ | |
$data = ['a' => 1, 'b' => 2]; | |
$this->object->setData($data); | |
$this->assertEquals(2, $this->object->getDataCount()); | |
} | |
/** | |
* @covers Ease\Sand::getDataValue | |
*/ | |
public function testGetDataValue() | |
{ | |
$data = ['a' => 1, 'b' => 2]; | |
$this->object->setData($data); | |
$this->assertEquals(2, $this->object->getDataValue('b')); | |
$this->assertNull($this->object->getDataValue('c')); | |
} | |
/** | |
* @covers Ease\Sand::setDataValue | |
* | |
* @todo Implement testSetDataValue(). | |
*/ | |
public function testSetDataValue() | |
{ | |
$this->object->setDataValue('c', 3); | |
$this->assertEquals(3, $this->object->getDataValue('c')); | |
} | |
/** | |
* @covers Ease\Sand::unsetDataValue | |
*/ | |
public function testUnsetDataValue() | |
{ | |
$data = ['a' => 1, 'b' => 2]; | |
$this->object->setData($data); | |
$this->assertTrue($this->object->unsetDataValue('a')); | |
$this->assertNull($this->object->getDataValue('a')); | |
$this->assertFalse($this->object->unsetDataValue('c')); | |
} | |
/** | |
* @covers Ease\Sand::takeData | |
*/ | |
public function testTakeData() | |
{ | |
$data = ['d' => 4, 'e' => 5]; | |
$this->object->takeData($data); | |
$this->assertEquals(5, $this->object->getDataValue('e')); | |
$data = ['f' => 6, 'g' => 7]; | |
$this->object->takeData($data); | |
$this->assertEquals(4, $this->object->getDataValue('d')); | |
} | |
/** | |
* @covers Ease\Sand::rip | |
*/ | |
public function testRip() | |
{ | |
$this->assertEquals('kuprikladu', $this->object->rip('kupříkladu')); | |
} | |
/** | |
* @covers Ease\Sand::easeEncrypt | |
*/ | |
public function testEaseEncrypt() | |
{ | |
$enc = $this->object->easeEncrypt('secret', 'key'); | |
$this->assertEquals($this->object->easeDecrypt($enc, 'key'), 'secret'); | |
} | |
/** | |
* @covers Ease\Sand::easeDecrypt | |
*/ | |
public function testEaseDecrypt() | |
{ | |
$enc = $this->object->easeEncrypt('secret', 'key'); | |
$this->assertEquals($this->object->easeDecrypt($enc, 'key'), 'secret'); | |
} | |
/** | |
* @covers Ease\Sand::randomNumber | |
*/ | |
public function testRandomNumber() | |
{ | |
$a = $this->object->randomNumber(); | |
$b = $this->object->randomNumber(); | |
$this->assertFalse($a == $b); | |
$this->assertGreaterThan(9, $this->object->randomNumber(10, 20)); | |
$this->assertLessThan(21, $this->object->randomNumber(10, 20)); | |
$this->assertFalse($this->object->randomNumber(30, 20)); | |
} | |
/** | |
* @covers Ease\Sand::randomString | |
*/ | |
public function testRandomString() | |
{ | |
$a = $this->object->randomString(22); | |
$b = $this->object->randomString(); | |
$this->assertFalse($a == $b); | |
} | |
/** | |
* @covers Ease\Sand::recursiveIconv | |
*/ | |
public function testRecursiveIconv() | |
{ | |
$original = ["\x80", "\x95"]; | |
$exepted = ["\xe2\x82\xac", "\xe2\x80\xa2"]; | |
$this->assertEquals($exepted, | |
$this->object->recursiveIconv('cp1252', 'utf-8', $original)); | |
$this->assertEquals($exepted[0], | |
$this->object->recursiveIconv('cp1252', 'utf-8', $original[0])); | |
} | |
/** | |
* @covers Ease\Sand::arrayIconv | |
*/ | |
public function testArrayIconv() | |
{ | |
$original = "\x80"; | |
$exepted = "\xe2\x82\xac"; | |
$this->object->arrayIconv($original, 0, ['cp1252', 'utf-8']); | |
$this->assertEquals($exepted, $original); | |
} | |
/** | |
* @covers Ease\Sand::addToLog | |
* | |
* @todo Implement testAddToLog(). | |
*/ | |
public function testAddToLog() | |
{ | |
$this->object->addToLog('Message'); | |
} | |
/** | |
* @covers Ease\Sand::__toString | |
* | |
* @todo Implement test__toString(). | |
*/ | |
public function test__toString() | |
{ | |
$this->object->__toString(); | |
} | |
/** | |
* @covers Ease\Sand::__sleep | |
* | |
* @todo Implement test__sleep(). | |
*/ | |
public function test__sleep() | |
{ | |
$this->object->__sleep(); | |
} | |
/** | |
* @covers Ease\Sand::humanFilesize | |
* | |
* @todo Implement testHumanFilesize(). | |
*/ | |
public function testHumanFilesize() | |
{ | |
$this->assertEquals('1.18 MB', $this->object->humanFilesize('1234545')); | |
$this->assertEquals('11.5 GB', | |
$this->object->humanFilesize('12345453453')); | |
$this->assertEquals('1.1 PB', | |
$this->object->humanFilesize('1234545345332235')); | |
$this->assertEquals('NaN', $this->object->humanFilesize(false)); | |
} | |
/** | |
* @covers Ease\Sand::reindexArrayBy | |
*/ | |
public function testReindexArrayBy() | |
{ | |
$a = [ | |
['id' => '2', 'name' => 'b'], | |
['id' => '1', 'name' => 'a'], | |
['id' => '3', 'name' => 'c'], | |
]; | |
$c = [ | |
'a' => ['id' => '1', 'name' => 'a'], | |
'b' => ['id' => '2', 'name' => 'b'], | |
'c' => ['id' => '3', 'name' => 'c'], | |
]; | |
$this->assertEquals($c, $this->object->reindexArrayBy($a, 'name')); | |
} | |
/** | |
* @covers Ease\Sand::draw | |
*/ | |
public function testDraw($whatWant = null) | |
{ | |
$this->assertEquals('Object: '.get_class($this->object), | |
$this->object->draw()); | |
} | |
/** | |
* @covers Ease\Sand::__wakeup | |
* | |
* @todo Implement test__wakeup(). | |
*/ | |
public function test__wakeup() | |
{ | |
$this->object->__wakeup(); | |
} | |
} |