diff --git a/Module/ModuleAbstract.php b/Module/ModuleAbstract.php index b313a8765..2574f963c 100644 --- a/Module/ModuleAbstract.php +++ b/Module/ModuleAbstract.php @@ -263,13 +263,13 @@ abstract class ModuleAbstract protected function createModel(int $account, $obj, string $mapper, string $trigger, string $ip) : void { $this->app->eventManager->trigger('PRE:Module:' . static::MODULE_NAME . '-' . $trigger . '-create', '', $obj); - $mapper::create($obj); + $id = $mapper::create($obj); $this->app->eventManager->trigger('POST:Module:' . static::MODULE_NAME . '-' . $trigger . '-create', '', [ $account, null, $obj, StringUtils::intHash(\is_string($mapper) ? $mapper : \get_class($mapper)), 0, static::MODULE_NAME, - (string) $obj->getId(), + (string) $id, '', $ip, ]); @@ -292,13 +292,13 @@ abstract class ModuleAbstract { foreach ($objs as $obj) { $this->app->eventManager->trigger('PRE:Module:' . static::MODULE_NAME . '-' . $trigger . '-create', '', $obj); - $mapper::create($obj); + $id = $mapper::create($obj); $this->app->eventManager->trigger('POST:Module:' . static::MODULE_NAME . '-' . $trigger . '-create', '', [ $account, null, $obj, StringUtils::intHash(\is_string($mapper) ? $mapper : \get_class($mapper)), 0, static::MODULE_NAME, - (string) $obj->getId(), + (string) $id, '', $ip, ]); @@ -322,8 +322,9 @@ abstract class ModuleAbstract protected function updateModel(int $account, $old, $new, $mapper, string $trigger, string $ip) : void { $this->app->eventManager->trigger('PRE:Module:' . static::MODULE_NAME . '-' . $trigger . '-update', '', $old); + $id = 0; if (\is_string($mapper)) { - $mapper::update($new); + $id = $mapper::update($new); } elseif ($mapper instanceof \Closure) { $mapper(); } @@ -332,7 +333,7 @@ abstract class ModuleAbstract $old, $new, StringUtils::intHash(\is_string($mapper) ? $mapper : \get_class($mapper)), 0, static::MODULE_NAME, - (string) $old->getId(), + (string) $id, '', $ip, ]); @@ -354,13 +355,13 @@ abstract class ModuleAbstract protected function deleteModel(int $account, $obj, string $mapper, string $trigger, string $ip) : void { $this->app->eventManager->trigger('PRE:Module:' . static::MODULE_NAME . '-' . $trigger . '-delete', '', $obj); - $mapper::delete($obj); + $id = $mapper::delete($obj); $this->app->eventManager->trigger('POST:Module:' . static::MODULE_NAME . '-' . $trigger . '-delete', '', [ $account, $obj, null, StringUtils::intHash(\is_string($mapper) ? $mapper : \get_class($mapper)), 0, static::MODULE_NAME, - (string) $obj->getId(), + (string) $id, '', $ip, ]); diff --git a/tests/Module/PackageManagerTest.php b/tests/Module/PackageManagerTest.php index 7e3838119..854da5fea 100644 --- a/tests/Module/PackageManagerTest.php +++ b/tests/Module/PackageManagerTest.php @@ -228,8 +228,8 @@ class PackageManagerTest extends \PHPUnit\Framework\TestCase $package->extract(__DIR__ . '/testPackageExtracted'); $package->cleanup(); - self::assertFileNotExists(__DIR__ . '/testPackage.zip'); - self::assertFileNotExists(__DIR__ . '/testPackageExtracted'); + self::assertFileDoesNotExist(__DIR__ . '/testPackage.zip'); + self::assertFileDoesNotExist(__DIR__ . '/testPackageExtracted'); } public static function tearDownAfterClass() : void diff --git a/tests/Uri/UriFactoryTest.php b/tests/Uri/UriFactoryTest.php index 9c024b54d..01fdefa1b 100644 --- a/tests/Uri/UriFactoryTest.php +++ b/tests/Uri/UriFactoryTest.php @@ -220,7 +220,6 @@ class UriFactoryTest extends \PHPUnit\Framework\TestCase $escaped = '{/base}{/rootPath}{/}?id=\{\?id\}&ab={?ab}#{#}'; $unescaped = 'http://www.test-uri.com/path/here?id={?id}&ab=c#fragi'; - var_dump('TEST:'); UriFactory::setupUriBuilder(new HttpUri($uri)); self::assertEquals($unescaped, UriFactory::build($escaped)); diff --git a/tests/Utils/IO/Zip/GzTest.php b/tests/Utils/IO/Zip/GzTest.php index 3379d3ae9..f9538bab1 100644 --- a/tests/Utils/IO/Zip/GzTest.php +++ b/tests/Utils/IO/Zip/GzTest.php @@ -40,7 +40,7 @@ class GzTest extends \PHPUnit\Framework\TestCase $a = \file_get_contents(__DIR__ . '/test a.txt'); \unlink(__DIR__ . '/test a.txt'); - self::assertFileNotExists(__DIR__ . '/test a.txt'); + self::assertFileDoesNotExist(__DIR__ . '/test a.txt'); self::assertTrue(Gz::unpack(__DIR__ . '/test.gz', __DIR__ . '/test a.txt')); self::assertFileExists(__DIR__ . '/test a.txt'); diff --git a/tests/Utils/Parser/Markdown/MarkdownTest.php b/tests/Utils/Parser/Markdown/MarkdownTest.php index 715165e7b..519627c7f 100644 --- a/tests/Utils/Parser/Markdown/MarkdownTest.php +++ b/tests/Utils/Parser/Markdown/MarkdownTest.php @@ -30,9 +30,9 @@ class MarkdownTest extends \PHPUnit\Framework\TestCase $data = \explode('.', $file); if ($data[1] === 'md' - && (\file_get_contents(__DIR__ . '/data/' . $data[0] . '.html') !== Markdown::parse(\file_get_contents(__DIR__ . '/data/' . $data[0] . '.md'))) + && (\file_get_contents(__DIR__ . '/data/' . $data[0] . '.html') !== ($parsed = Markdown::parse(\file_get_contents(__DIR__ . '/data/' . $data[0] . '.md')))) ) { - self::assertTrue(false, $file); + self::assertTrue(false, $file . "\n\n" . $parsed); } } diff --git a/tests/Utils/Parser/Markdown/data/xss_bad_url.html b/tests/Utils/Parser/Markdown/data/xss_bad_url.html index 888232f17..f65caf302 100644 --- a/tests/Utils/Parser/Markdown/data/xss_bad_url.html +++ b/tests/Utils/Parser/Markdown/data/xss_bad_url.html @@ -1,11 +1,11 @@

xss

xss

xss

-

xss

+

xss

xss

xss

xss

-

xss

+

xss

xss

xss

xss

diff --git a/tests/Utils/RnG/FileTest.php b/tests/Utils/RnG/FileTest.php index c8b707885..ad6592d08 100644 --- a/tests/Utils/RnG/FileTest.php +++ b/tests/Utils/RnG/FileTest.php @@ -30,6 +30,6 @@ class FileTest extends \PHPUnit\Framework\TestCase */ public function testRnGExtension() : void { - self::assertRegExp('/^[a-z0-9]{1,5}$/', File::generateExtension()); + self::assertMatchesRegularExpression('/^[a-z0-9]{1,5}$/', File::generateExtension()); } } diff --git a/tests/Utils/RnG/PhoneTest.php b/tests/Utils/RnG/PhoneTest.php index 971ffbeea..fa37b042f 100644 --- a/tests/Utils/RnG/PhoneTest.php +++ b/tests/Utils/RnG/PhoneTest.php @@ -30,6 +30,6 @@ class PhoneTest extends \PHPUnit\Framework\TestCase */ public function testRnG() : void { - self::assertRegExp('/^\+\d{1,2} \(\d{3,4}\) \d{3,5}\-\d{3,8}$/', Phone::generatePhone()); + self::assertMatchesRegularExpression('/^\+\d{1,2} \(\d{3,4}\) \d{3,5}\-\d{3,8}$/', Phone::generatePhone()); } } diff --git a/tests/Utils/StringUtilsTest.php b/tests/Utils/StringUtilsTest.php index 87f359774..e8f0e782a 100644 --- a/tests/Utils/StringUtilsTest.php +++ b/tests/Utils/StringUtilsTest.php @@ -111,7 +111,7 @@ class StringUtilsTest extends \PHPUnit\Framework\TestCase */ public function testDifferentHash() : void { - self::assertEquals(StringUtils::intHash('test1'), StringUtils::intHash('test2')); + self::assertNotEquals(StringUtils::intHash('test1'), StringUtils::intHash('test2')); } /**