Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
vitex committed May 21, 2021
1 parent ff0de6c commit a4d00ac
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 33 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ debian/php-abraflexi-bricks.debhelper.log
/debian/php-vitexsoftware-abraflexi-bricks-doc.substvars
/debian/php-vitexsoftware-abraflexi-bricks/
/debian/php-vitexsoftware-abraflexi-bricks-doc/
/nbproject/
/.phpunit.result.cache
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"autoload-dev": {
"psr-4": {
"Test\\Ease\\": "vendor/vitexsoftware/ease-core/tests/src/Ease",
"Test\\AbraFlexi\\": "vendor/spoje.net/flexibee/testing/src/AbraFlexi/",
"Test\\AbraFlexi\\": "vendor/spojenet/flexibee/testing/src/AbraFlexi/",
"Test\\AbraFlexi\\ui\\": "testing/AbraFlexi/ui",
"Test\\AbraFlexi\\Bricks\\": "testing/AbraFlexi/Bricks",
"Test\\": "testing/"
Expand Down
26 changes: 13 additions & 13 deletions src/AbraFlexi/Bricks/HookReciever.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ class HookReciever extends \AbraFlexi\Changes
/**
* Prijmac WebHooku
*/
public function __construct()
public function __construct($id = null,$options = [])
{
parent::__construct();
parent::__construct($id,$options);
$this->lastProcessedVersion = $this->getLastProcessedVersion();
}

Expand Down Expand Up @@ -143,17 +143,17 @@ public function saveLastProcessedVersion($version)
{
$this->lastProcessedVersion = $version;
$this->myCreateColumn = null;
$this->deleteFromSQL(['serverurl' => constant('ABRAFLEXI_URL')]);
if (is_null($this->insertToSQL(['serverurl' => constant('ABRAFLEXI_URL'),
'changeid' => $version]))) {
$this->addStatusMessage(_("Last Processed Change ID Saving Failed"),
'error');
} else {
if ($this->debug === true) {
$this->addStatusMessage(sprintf(_('Last Processed Change ID #%s Saved'),
$version));
}
}
// $this->deleteFromSQL(['serverurl' => constant('ABRAFLEXI_URL')]);
// if (is_null($this->insertToSQL(['serverurl' => constant('ABRAFLEXI_URL'),
// 'changeid' => $version]))) {
// $this->addStatusMessage(_("Last Processed Change ID Saving Failed"),
// 'error');
// } else {
// if ($this->debug === true) {
// $this->addStatusMessage(sprintf(_('Last Processed Change ID #%s Saved'),
// $version));
// }
// }
}

/**
Expand Down
33 changes: 14 additions & 19 deletions tests/src/AbraFlexi/Bricks/HookRecieverTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @author Vítězslav Dvořák <[email protected]>
* @copyright (c) 2018-2020, Vítězslav Dvořák
Expand All @@ -11,8 +12,8 @@
/**
* Generated by PHPUnit_SkeletonGenerator on 2018-04-20 at 20:42:56.
*/
class HookRecieverTest extends \Test\AbraFlexi\ChangesTest
{
class HookRecieverTest extends \Test\AbraFlexi\ChangesTest {

/**
* @var HookReciever
*/
Expand All @@ -23,34 +24,30 @@ class HookRecieverTest extends \Test\AbraFlexi\ChangesTest
*
* @return int
*/
public static function getFakeChangeId()
{
public static function getFakeChangeId() {
return time() - 1524247660;
}

/**
* Sets up the fixture, for example, opens a network connection
* This method is called before a test is executed.
*/
protected function setUp() : void
{
$this->object = new HookReciever(null, ['debug' => true]);
protected function setUp(): void {
$this->object = new HookReciever(null, ['debug' => true, 'throwException' => false]);
}

/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown() : void
{
protected function tearDown(): void {

}

/**
* @covers \AbraFlexi\Bricks\HookReciever::listen
*/
public function testListen()
{
public function testListen() {
$this->object->listen();
$this->object->listen('tests/config.json');
$this->object->listen('tests/phpunit.xml');
Expand All @@ -59,22 +56,20 @@ public function testListen()
/**
* @covers \AbraFlexi\Bricks\HookReciever::takeChanges
*/
public function testTakeChanges()
{
public function testTakeChanges() {
$this->object->takeChanges(null);
$this->assertEquals(254924,
$this->object->takeChanges($this->object->listen('tests/changes.json')));
$this->object->takeChanges($this->object->listen('tests/changes.json')));
}

/**
* @covers \AbraFlexi\Bricks\HookReciever::processChanges
* @depends testTakeChanges
*/
public function testProcessChanges()
{
public function testProcessChanges() {
$this->object->processChanges();
$globalVersion = self::getFakeChangeId();
$changes = $this->object->listen('tests/changes.json');
$changes = $this->object->listen('tests/changes.json');
foreach ($changes['winstrom']['changes'] as $chPos => $change) {
$changes['winstrom']['changes'][$chPos]['@in-version'] = $globalVersion++;
}
Expand All @@ -87,11 +82,11 @@ public function testProcessChanges()
* @covers \AbraFlexi\Bricks\HookReciever::saveLastProcessedVersion
* @covers \AbraFlexi\Bricks\HookReciever::getLastProcessedVersion
*/
public function testSaveLastProcessedVersion()
{
public function testSaveLastProcessedVersion() {
$this->object->saveLastProcessedVersion('X');
$fchid = self::getFakeChangeId();
$this->object->saveLastProcessedVersion($fchid);
$this->assertEquals($fchid, $this->object->getLastProcessedVersion());
}

}

0 comments on commit a4d00ac

Please sign in to comment.