Skip to content

Commit

Permalink
Using addresses.id automatic type detection in migrations
Browse files Browse the repository at this point in the history
- Test fixes
  • Loading branch information
fulopattila122 committed Oct 18, 2023
1 parent 2aa5581 commit da5f0e6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ jobs:
- name: Create SQLite Database
run: mkdir -p database && touch database/database.sqlite
- name: Run Tests [sqlite]
run: php vendor/bin/phpunit --testdox
run: php vendor/bin/phpunit --testdox --stop-on-error --display-errors
env:
TEST_DB_ENGINE: sqlite
- name: Run Tests [mysql 5.7]
run: php vendor/bin/phpunit
run: php vendor/bin/phpunit --testdox --stop-on-error --display-errors
env:
TEST_DB_ENGINE: mysql
TEST_DB_PORT: ${{ job.services.mysql.ports[3306] }}
- name: Run Tests [mysql 8.0]
run: php vendor/bin/phpunit --testdox
run: php vendor/bin/phpunit --testdox --stop-on-error --display-errors
env:
TEST_DB_ENGINE: mysql
TEST_DB_PORT: ${{ job.services.mysql8.ports[3306] }}
- name: Run Tests [postgres]
run: php vendor/bin/phpunit --testdox
run: php vendor/bin/phpunit --testdox --stop-on-error --display-errors
env:
TEST_DB_ENGINE: pgsql
TEST_DB_PORT: ${{ job.services.postgres.ports[5432] }}
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"konekt/enum": "^4.1",
"konekt/user": "^3.0",
"konekt/address": "^3.0",
"konekt/laravel-migration-compatibility": "^1.6",
"laravel/framework": "^10.0"
},
"require-dev": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
public function up(): void
{
Schema::table('customers', function (Blueprint $table) {
$table->unsignedInteger('default_billing_address_id')->nullable();
$table->unsignedInteger('default_shipping_address_id')->nullable();
$table->intOrBigIntBasedOnRelated('default_billing_address_id', Schema::connection(null), 'addresses.id')->nullable();
$table->intOrBigIntBasedOnRelated('default_shipping_address_id', Schema::connection(null), 'addresses.id')->nullable();

$table->foreign('default_billing_address_id')->references('id')->on('addresses')->nullOnDelete();
$table->foreign('default_shipping_address_id')->references('id')->on('addresses')->nullOnDelete();
Expand Down
7 changes: 7 additions & 0 deletions tests/AddressDefaultsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,17 @@
namespace Konekt\Customer\Tests;

use Konekt\Address\Models\Address;
use Konekt\Address\Models\Country;
use Konekt\Customer\Models\Customer;

class AddressDefaultsTest extends TestCase
{
public function setUp(): void
{
parent::setUp();
Country::firstOrCreate(['id' => 'UK'], ['id' => 'UK', 'name' => 'United Kingdom', 'phonecode' => '44', 'is_eu_member' => false]);
}

/** @test */
public function customer_has_no_default_addresses_by_default()
{
Expand Down

0 comments on commit da5f0e6

Please sign in to comment.