From 1292098b652d33fc270fe6b1a44aa8d3ad3914fa Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 3 May 2021 09:44:03 +1000 Subject: [PATCH 1/4] More tests for generated numbers --- tests/Unit/GeneratesCounterTest.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/Unit/GeneratesCounterTest.php b/tests/Unit/GeneratesCounterTest.php index 5c06ed67293d..3893b977df4d 100644 --- a/tests/Unit/GeneratesCounterTest.php +++ b/tests/Unit/GeneratesCounterTest.php @@ -68,6 +68,10 @@ class GeneratesCounterTest extends TestCase $this->assertEquals($date_formatted."-0001", $invoice_number); $invoice_number = $this->getNextInvoiceNumber($this->client->fresh(), $this->invoice->fresh()); $this->assertEquals($date_formatted."-0002", $invoice_number); + $invoice_number = $this->getNextInvoiceNumber($this->client->fresh(), $this->invoice->fresh()); + $this->assertEquals($date_formatted."-0003", $invoice_number); + $invoice_number = $this->getNextInvoiceNumber($this->client->fresh(), $this->invoice->fresh()); + $this->assertEquals($date_formatted."-0004", $invoice_number); $settings->reset_counter_date = now($timezone->name)->format('Y-m-d'); $settings->reset_counter_frequency_id = RecurringInvoice::FREQUENCY_DAILY; @@ -83,6 +87,20 @@ class GeneratesCounterTest extends TestCase $invoice_number = $this->getNextInvoiceNumber($this->client->fresh(), $this->invoice->fresh()); $this->assertEquals($date_formatted."-0001", $invoice_number); + $invoice_number = $this->getNextInvoiceNumber($this->client->fresh(), $this->invoice->fresh()); + $this->assertEquals($date_formatted."-0002", $invoice_number); + + + $settings->reset_counter_date = now($timezone->name)->format('Y-m-d'); + $settings->reset_counter_frequency_id = RecurringInvoice::FREQUENCY_DAILY; + $this->company->settings = $settings; + $this->company->save(); + + $this->travel(5)->days(); + $date_formatted = now($timezone->name)->format('Ymd'); + + $invoice_number = $this->getNextInvoiceNumber($this->client->fresh(), $this->invoice->fresh()); + $this->assertEquals($date_formatted."-0001", $invoice_number); } public function testHasSharedCounter() From 4a3384e382f6544332c9941c5ea5b736db6f5fa3 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 3 May 2021 11:06:12 +1000 Subject: [PATCH 2/4] More tests for counters --- tests/Unit/GeneratesCounterTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/Unit/GeneratesCounterTest.php b/tests/Unit/GeneratesCounterTest.php index 3893b977df4d..8b6f0582a920 100644 --- a/tests/Unit/GeneratesCounterTest.php +++ b/tests/Unit/GeneratesCounterTest.php @@ -90,7 +90,6 @@ class GeneratesCounterTest extends TestCase $invoice_number = $this->getNextInvoiceNumber($this->client->fresh(), $this->invoice->fresh()); $this->assertEquals($date_formatted."-0002", $invoice_number); - $settings->reset_counter_date = now($timezone->name)->format('Y-m-d'); $settings->reset_counter_frequency_id = RecurringInvoice::FREQUENCY_DAILY; $this->company->settings = $settings; @@ -101,6 +100,9 @@ class GeneratesCounterTest extends TestCase $invoice_number = $this->getNextInvoiceNumber($this->client->fresh(), $this->invoice->fresh()); $this->assertEquals($date_formatted."-0001", $invoice_number); + + $this->travelBack(); + } public function testHasSharedCounter() From 9ba7d67ce0c30a24d05a07057ba21fdba7a5b8a0 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 3 May 2021 11:07:32 +1000 Subject: [PATCH 3/4] Remove travis --- .travis.yml | 90 ----------------------------------------------------- 1 file changed, 90 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 52e6a334b985..000000000000 --- a/.travis.yml +++ /dev/null @@ -1,90 +0,0 @@ -language: php - -sudo: true - -dist: xenial - -services: - - mysql - - xvfb - -# Prevent tests from taking more than 50 minutes -group: deprecated-2017Q4 - -php: -# - 7.3 - - 7.4 -# - nightly - -addons: - apt: - packages: - - libonig-dev - chrome: stable - hosts: - - www.ninja.test - -cache: - directories: - - vendor - - $HOME/.composer/cache - -env: - global: - - COMPOSER_DISCARD_CHANGES=true - - COMPOSER_NO_INTERACTION=1 - - COMPOSER_DISABLE_XDEBUG_WARN=1 - -before_install: - # set GitHub token and update composer - - if [ -n "$GH_TOKEN" ]; then composer config github-oauth.github.com ${GH_TOKEN}; fi; - - composer self-update 1.10.19 && composer -V -# - export USE_ZEND_ALLOC=0 - - rvm use 1.9.3 --install --fuzzy - - cp .env.travis .env - -install: - # install Composer dependencies - # - rm composer.lock - # these providers require referencing git commit's which cause Travis to fail - # - sed -i '/mollie/d' composer.json - # - sed -i '/2checkout/d' composer.json - - travis_retry composer install --no-interaction - -before_script: - # copy configuration files - - php artisan key:generate --no-interaction - - sed -i '$a NINJA_DEV=true' .env - # create the database and user - - mysql -u root -e "create database IF NOT EXISTS ninja01;" - - mysql -u root -e "create database IF NOT EXISTS ninja02;" - - mysql -u root -e "GRANT ALL PRIVILEGES ON ninja01.* To 'ninja'@'localhost' IDENTIFIED BY 'ninja'; FLUSH PRIVILEGES;" - - mysql -u root -e "GRANT ALL PRIVILEGES ON ninja02.* To 'ninja'@'localhost' IDENTIFIED BY 'ninja'; FLUSH PRIVILEGES;" - # migrate and seed the database - - php artisan migrate --database=db-ninja-01 --seed --no-interaction - - php artisan migrate --database=db-ninja-02 --seed --no-interaction - - php artisan optimize - - npm install - - npm run production - # migrate and seed the database - # Start webserver on ninja.test:8000 - # export DISPLAY=:99.0 - # sh -e /etc/init.d/xvfb start - # sleep 3 - # ./vendor/laravel/dusk/bin/chromedriver-linux & - - php artisan dusk:chrome-driver 80 - - php artisan serve & - -script: - - php ./vendor/bin/phpunit --debug --verbose --coverage-clover=coverage.xml - #- php artisan dusk - #- npm test -after_success: - - bash <(curl -s https://codecov.io/bash) - -notifications: - email: - on_success: never - on_failure: change - slack: - invoiceninja: SLraaKBDvjeRuRtY9o3Yvp1b From d68f96fb9846cec22d1d0f8845b13f4b8fff48ad Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 3 May 2021 11:46:46 +1000 Subject: [PATCH 4/4] Minor fixes for migrations --- app/Events/Product/ProductWasRestored.php | 1 + app/Http/Controllers/MigrationController.php | 2 +- app/Jobs/Util/StartMigration.php | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Events/Product/ProductWasRestored.php b/app/Events/Product/ProductWasRestored.php index 558b17ebfd6a..9d7ec6c7d3fb 100644 --- a/app/Events/Product/ProductWasRestored.php +++ b/app/Events/Product/ProductWasRestored.php @@ -12,6 +12,7 @@ namespace App\Events\Product; use App\Models\Company; +use App\Models\Product; use Illuminate\Queue\SerializesModels; /** diff --git a/app/Http/Controllers/MigrationController.php b/app/Http/Controllers/MigrationController.php index 8506f5159feb..afe76b9c1c80 100644 --- a/app/Http/Controllers/MigrationController.php +++ b/app/Http/Controllers/MigrationController.php @@ -349,7 +349,7 @@ class MigrationController extends BaseController // StartMigration::dispatch(base_path("storage/app/public/$migration_file"), $user, $fresh_company)->delay(now()->addSeconds(5)); nlog("starting migration job"); nlog($migration_file); - StartMigration::dispatch($migration_file, $user, $fresh_company); + StartMigration::dispatch($migration_file, $user, $fresh_company)->onQueue('migration'); // } catch (\Exception $e) { // nlog($e->getMessage()); // } diff --git a/app/Jobs/Util/StartMigration.php b/app/Jobs/Util/StartMigration.php index e26c7462ed74..8b5f09fcfbc6 100644 --- a/app/Jobs/Util/StartMigration.php +++ b/app/Jobs/Util/StartMigration.php @@ -109,7 +109,7 @@ class StartMigration implements ShouldQueue throw new NonExistingMigrationFile('Migration file does not exist, or it is corrupted.'); } - Import::dispatchNow($file, $this->company, $this->user); + Import::dispatchNow($file, $this->company, $this->user)->onQueue('migration'); Storage::deleteDirectory(public_path("storage/migrations/{$filename}"));