diff --git a/phpunit.xml b/phpunit.xml index b8af39d..4aa8062 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -2,13 +2,13 @@ - ./tests/FlexiPeeHP + ./tests/src/FlexiPeeHP - FlexiPeeHP + src/FlexiPeeHP diff --git a/src/FlexiPeeHP/Bricks/Convertor.php b/src/FlexiPeeHP/Bricks/Convertor.php index 489ff50..8ac7c67 100644 --- a/src/FlexiPeeHP/Bricks/Convertor.php +++ b/src/FlexiPeeHP/Bricks/Convertor.php @@ -52,6 +52,7 @@ public function __construct(\FlexiPeeHP\FlexiBeeRO $input = null, } /** + * Set Source Documnet * * @param \FlexiPeeHP\FlexiBeeRO $source */ @@ -61,6 +62,7 @@ public function setSource(\FlexiPeeHP\FlexiBeeRO $source) } /** + * Set Destination document * * @param \FlexiPeeHP\FlexiBeeRO $destinantion */ @@ -141,18 +143,19 @@ public function prepareRules() break; default : throw new \Ease\Exception(sprintf(_('Unsupported Source document type %s'), - get_class($this->output))); + get_class($this->output))); break; } break; default: throw new \Ease\Exception(sprintf(_('Unsupported Source document type %s'), - get_class($this->input))); + get_class($this->input))); break; } } /** + * Convert FlexiBee document * * @param boolean $keepId keep item IDs * @param boolean $addExtId add ext:originalEvidence:originalId @@ -165,18 +168,7 @@ public function convertDocument($keepId = false, $addExtId = false, } /** - * - * @param boolean $keepId keep item IDs - * @param boolean $addExtId add ext:originalEvidence:originalId - * @param boolean $keepCode keep items code - */ - public function convertDocument($keepId = false, $addExtId = false, - $keepCode = false) - { - $this->convertItems($keepId, $addExtId, $keepCode); - } - - /** + * Convert FlexiBee documnet's subitems * * @param string $columnToTake usually "polozkyDokladu" * @param boolean $keepId keep item IDs @@ -235,7 +227,7 @@ public function convertItems($keepId = false, $addExtId = true, } foreach (self::removeRoColumns($this->rules, $this->output) as $columnToTake => $subitemColumns) { if (is_array($subitemColumns)) { - if(!empty($this->input->getSubItems())){ + if (!empty($this->input->getSubItems())) { $this->convertSubitems($columnToTake, $keepId, $keepCode); } } else { @@ -257,9 +249,9 @@ public function convertItems($keepId = false, $addExtId = true, */ public static function removeRoColumns(array $rules, $engine) { - foreach ($rules as $index=>$subrules) { + foreach ($rules as $index => $subrules) { if (is_array($subrules)) { - $eback = $engine->getEvidence(); + $eback = $engine->getEvidence(); $engine->setEvidence($engine->getEvidence().'-polozka'); $rules[$index] = self::removeRoColumns($subrules, $engine); $engine->setEvidence($eback); @@ -274,6 +266,7 @@ public static function removeRoColumns(array $rules, $engine) } /** + * Return itemes that same on both sides * * @return array */ @@ -282,4 +275,24 @@ public function commonItems() return array_intersect(array_keys($this->input->getColumnsInfo()), array_keys($this->output->getColumnsInfo())); } + + /** + * Get input object here + * + * @return \FlexiPeeHP\FlexiBeeRO + */ + public function getInput() + { + return $this->input; + } + + /** + * Get output object here + * + * @return \FlexiPeeHP\FlexiBeeRO + */ + public function getOutput() + { + return $this->output; + } } diff --git a/tests/src/FlexiPeeHP/Bricks/ConvertorTest.php b/tests/src/FlexiPeeHP/Bricks/ConvertorTest.php new file mode 100644 index 0000000..ff9360a --- /dev/null +++ b/tests/src/FlexiPeeHP/Bricks/ConvertorTest.php @@ -0,0 +1,164 @@ +object = new Convertor(); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + + } + + /** + * @covers FlexiPeeHP\Bricks\Convertor::setSource + */ + public function testSetSource() + { + $sourcer = new \FlexiPeeHP\FakturaVydana(); + $this->object->setSource($sourcer); + $this->assertEquals($sourcer, $this->object->getInput()); + } + + /** + * @covers FlexiPeeHP\Bricks\Convertor::setDestination + */ + public function testSetDestination() + { + $dester = new \FlexiPeeHP\FakturaPrijata(); + $this->object->setDestination($dester); + $this->assertEquals($dester, $this->object->getOutput()); + } + + /** + * @covers FlexiPeeHP\Bricks\Convertor::conversion + * @expectedException \Ease\Exception + */ + public function testConversion() + { + $this->object->conversion(); + } + + /** + * @covers FlexiPeeHP\Bricks\Convertor::baseClassName + */ + public function testBaseClassName() + { + $this->assertEquals('FakturaVydana', + $this->object->baseClassName(new \FlexiPeeHP\FakturaVydana())); + } + + /** + * @covers FlexiPeeHP\Bricks\Convertor::prepareRules + * @todo Implement testPrepareRules(). + */ + public function testPrepareRules() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FlexiPeeHP\Bricks\Convertor::convertDocument + * @todo Implement testConvertDocument(). + */ + public function testConvertDocument() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FlexiPeeHP\Bricks\Convertor::convertSubitems + * @todo Implement testConvertSubitems(). + */ + public function testConvertSubitems() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FlexiPeeHP\Bricks\Convertor::convertItems + * @todo Implement testConvertItems(). + */ + public function testConvertItems() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FlexiPeeHP\Bricks\Convertor::removeRoColumns + * @todo Implement testRemoveRoColumns(). + */ + public function testRemoveRoColumns() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FlexiPeeHP\Bricks\Convertor::commonItems + * @todo Implement testCommonItems(). + */ + public function testCommonItems() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers FlexiPeeHP\Bricks\Convertor::getInput + */ + public function testGetInput() + { + $test = new \FlexiPeeHP\Adresar(); + $this->object->setSource($test); + $this->assertEquals($test, $this->object->getInput()); + } + + /** + * @covers FlexiPeeHP\Bricks\Convertor::getOutput + */ + public function testGetOutput() + { + $test = new \FlexiPeeHP\Adresar(); + $this->object->setDestination($test); + $this->assertEquals($test, $this->object->getOutput()); + } +} diff --git a/tests/FlexiPeeHP/Bricks/HookRecieverTest.php b/tests/src/FlexiPeeHP/Bricks/HookRecieverTest.php similarity index 100% rename from tests/FlexiPeeHP/Bricks/HookRecieverTest.php rename to tests/src/FlexiPeeHP/Bricks/HookRecieverTest.php diff --git a/tests/FlexiPeeHP/Bricks/ParovacFakturTest.php b/tests/src/FlexiPeeHP/Bricks/ParovacFakturTest.php similarity index 100% rename from tests/FlexiPeeHP/Bricks/ParovacFakturTest.php rename to tests/src/FlexiPeeHP/Bricks/ParovacFakturTest.php diff --git a/tests/FlexiPeeHP/Bricks/WebHookHandlerTest.php b/tests/src/FlexiPeeHP/Bricks/WebHookHandlerTest.php similarity index 100% rename from tests/FlexiPeeHP/Bricks/WebHookHandlerTest.php rename to tests/src/FlexiPeeHP/Bricks/WebHookHandlerTest.php