-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[8.x] MySQL Builds #39415
[8.x] MySQL Builds #39415
Changes from 17 commits
31a4935
9574005
d7eefd2
58b9589
903e2b0
45518d0
c557679
853e5dd
675c099
edbfc97
d1677f5
923f35b
3939946
a148a64
8e57d1d
c33b439
3d8fe20
c8caab0
07471c8
5f2a79a
7338975
3c1fbff
fb96ca0
1f791f4
b48c479
e12a0da
6408970
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: databases | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
mysql: | ||
runs-on: ubuntu-20.04 | ||
|
||
services: | ||
mysql: | ||
image: mysql:5.7 | ||
env: | ||
MYSQL_ALLOW_EMPTY_PASSWORD: yes | ||
MYSQL_DATABASE: forge | ||
ports: | ||
- 3306:3306 | ||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
|
||
strategy: | ||
fail-fast: true | ||
|
||
name: MySQL 5.7 | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 8.0 | ||
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql | ||
tools: composer:v2 | ||
coverage: none | ||
|
||
- name: Install dependencies | ||
uses: nick-invision/retry@v1 | ||
with: | ||
timeout_minutes: 5 | ||
max_attempts: 5 | ||
command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress | ||
|
||
- name: Execute tests | ||
run: vendor/bin/phpunit tests/Integration/Database --verbose | ||
env: | ||
DB_CONNECTION: mysql | ||
DB_USERNAME: root |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,7 @@ protected function setUp(): void | |
|
||
Schema::create('posts_tags', function (Blueprint $table) { | ||
$table->integer('post_id'); | ||
$table->integer('tag_id'); | ||
$table->string('tag_id'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In one test we're storing the |
||
$table->string('flag')->default('')->nullable(); | ||
$table->timestamps(); | ||
}); | ||
|
@@ -132,7 +132,7 @@ public function testCustomPivotClass() | |
$post->tagsWithCustomPivot()->attach($tag->id); | ||
|
||
$this->assertInstanceOf(PostTagPivot::class, $post->tagsWithCustomPivot[0]->pivot); | ||
$this->assertEquals('1507630210', $post->tagsWithCustomPivot[0]->pivot->getAttributes()['created_at']); | ||
$this->assertEquals('1507630210', $post->tagsWithCustomPivot[0]->pivot->created_at); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Switch to an accessor instead of relying on SQLite's |
||
|
||
$this->assertInstanceOf(PostTagPivot::class, $post->tagsWithCustomPivotClass[0]->pivot); | ||
$this->assertSame('posts_tags', $post->tagsWithCustomPivotClass()->getTable()); | ||
|
@@ -213,8 +213,8 @@ public function testCustomPivotClassUpdatesTimestamps() | |
DB::table('posts_tags')->insert([ | ||
[ | ||
'post_id' => $post->id, 'tag_id' => $tag->id, 'flag' => 'empty', | ||
'created_at' => '1507630210', | ||
'updated_at' => '1507630210', | ||
'created_at' => '2017-10-10 10:10:10', | ||
'updated_at' => '2017-10-10 10:10:10', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use universal date formats instead of SQLite specific timestamps. |
||
], | ||
]); | ||
|
||
|
@@ -226,8 +226,8 @@ public function testCustomPivotClassUpdatesTimestamps() | |
); | ||
foreach ($post->tagsWithCustomExtraPivot as $tag) { | ||
$this->assertSame('exclude', $tag->pivot->flag); | ||
$this->assertEquals('1507630210', $tag->pivot->getAttributes()['created_at']); | ||
$this->assertEquals('1507630220', $tag->pivot->getAttributes()['updated_at']); // +10 seconds | ||
$this->assertEquals('2017-10-10 10:10:10', $tag->pivot->getAttributes()['created_at']); | ||
$this->assertEquals('2017-10-10 10:10:20', $tag->pivot->getAttributes()['updated_at']); // +10 seconds | ||
} | ||
} | ||
|
||
|
@@ -1068,7 +1068,11 @@ class UserPostPivot extends Pivot | |
class PostTagPivot extends Pivot | ||
{ | ||
protected $table = 'posts_tags'; | ||
protected $dateFormat = 'U'; | ||
|
||
public function getCreatedAtAttribute($value) | ||
{ | ||
return Carbon::parse($value)->format('U'); | ||
} | ||
} | ||
|
||
class TagWithGlobalScope extends Model | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,9 +67,10 @@ public function testSortingScopes() | |
$one = Model1::create(); | ||
$one->twos()->create(); | ||
|
||
$result = Model1::withCount('twos')->toSql(); | ||
$query = Model1::withCount('twos')->getQuery(); | ||
|
||
$this->assertSame('select "one".*, (select count(*) from "two" where "one"."id" = "two"."one_id") as "twos_count" from "one"', $result); | ||
$this->assertNull($query->orders); | ||
$this->assertSame([], $query->getRawBindings()['order']); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need to verify a specific query, just that the sorting got removed from the subquery. |
||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,11 +31,11 @@ public function testDropAllViews() | |
{ | ||
$this->expectNotToPerformAssertions(); | ||
|
||
DB::statement('create view "view"("id") as select 1'); | ||
DB::statement('create view foo (id) as select 1'); | ||
|
||
Schema::dropAllViews(); | ||
|
||
DB::statement('create view "view"("id") as select 1'); | ||
DB::statement('create view foo (id) as select 1'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the universal syntax of creating database views. |
||
} | ||
|
||
public function testRegisterCustomDoctrineType() | ||
|
@@ -50,20 +50,9 @@ public function testRegisterCustomDoctrineType() | |
$table->tinyInteger('test_column')->change(); | ||
}); | ||
|
||
$expected = [ | ||
'CREATE TEMPORARY TABLE __temp__test AS SELECT test_column FROM test', | ||
'DROP TABLE test', | ||
'CREATE TABLE test (test_column TINYINT NOT NULL)', | ||
'INSERT INTO test (test_column) SELECT test_column FROM __temp__test', | ||
'DROP TABLE __temp__test', | ||
]; | ||
|
||
$statements = $blueprint->toSql($this->getConnection(), new SQLiteGrammar); | ||
|
||
$blueprint->build($this->getConnection(), new SQLiteGrammar); | ||
|
||
$this->assertArrayHasKey(TinyInteger::NAME, Type::getTypesMap()); | ||
$this->assertSame('tinyinteger', Schema::getColumnType('test', 'test_column')); | ||
$this->assertEquals($expected, $statements); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need to check the expected queries as that should be a concern of the Doctrine test suite. Just checking if the test column got renamed is enough. |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we're not running an in-memory database anymore we'll need to wipe the database each time after every test. I want to refactor this to a RefreshDatabase trait later on but for now this is okay.