Skip to content

Commit c7cf4ca

Browse files
author
Carl Sverre
committed
adding some tests, fixing devcontainer
1 parent e6fd63b commit c7cf4ca

File tree

5 files changed

+77
-44
lines changed

5 files changed

+77
-44
lines changed

.devcontainer/Dockerfile

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,6 @@
1-
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.231.6/containers/php/.devcontainer/base.Dockerfile
2-
3-
# [Choice] PHP version (use -bullseye variants on local arm64/Apple Silicon): 8, 8.1, 8.0, 7, 7.4, 7.3, 8-bullseye, 8.1-bullseye, 8.0-bullseye, 7-bullseye, 7.4-bullseye, 7.3-bullseye, 8-buster, 8.1-buster, 8.0-buster, 7-buster, 7.4-buster
4-
ARG VARIANT="8.1-apache-bullseye"
5-
FROM mcr.microsoft.com/vscode/devcontainers/php:0-${VARIANT}
6-
7-
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
8-
ARG NODE_VERSION="none"
9-
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
1+
ARG VARIANT="0-8"
2+
FROM mcr.microsoft.com/devcontainers/php:${VARIANT}
103

114
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
12-
RUN chmod +x /usr/local/bin/install-php-extensions && \
13-
install-php-extensions gd xdebug
14-
15-
RUN install-php-extensions pdo_mysql
16-
17-
# [Optional] Uncomment this section to install additional OS packages.
18-
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
19-
# && apt-get -y install --no-install-recommends <your-package-list-here>
20-
21-
# [Optional] Uncomment this line to install global node packages.
22-
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
5+
RUN chmod +x /usr/local/bin/install-php-extensions
6+
RUN install-php-extensions pdo_mysql

.devcontainer/devcontainer.json

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,27 @@
88
// Update VARIANT to pick a PHP version: 8, 8.1, 8.0, 7, 7.4
99
// Append -bullseye or -buster to pin to an OS version.
1010
// Use -bullseye variants on local on arm64/Apple Silicon.
11-
"VARIANT": "8",
12-
"NODE_VERSION": "lts/*"
11+
"VARIANT": "8"
1312
}
1413
},
1514

1615
// Set *default* container specific settings.json values on container create.
17-
"settings": {
18-
"php.validate.executablePath": "/usr/local/bin/php"
19-
},
20-
21-
// Add the IDs of extensions you want installed when the container is created.
22-
"extensions": [
23-
"xdebug.php-debug",
24-
"bmewburn.vscode-intelephense-client",
25-
"emallin.phpunit"
26-
],
16+
"customizations": {
17+
"vscode": {
18+
"settings": {
19+
"php.validate.executablePath": "/usr/local/bin/php"
20+
},
2721

28-
// Use 'forwardPorts' to make a list of ports inside the container available locally.
29-
"forwardPorts": [8080],
22+
// Add the IDs of extensions you want installed when the container is created.
23+
"extensions": [
24+
"xdebug.php-debug",
25+
"bmewburn.vscode-intelephense-client",
26+
"emallin.phpunit"
27+
]
28+
}
29+
},
3030

3131
// Use 'postCreateCommand' to run commands after the container is created.
3232
"postCreateCommand": "composer install",
33-
34-
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
35-
"remoteUser": "vscode"
33+
"forwardPorts": []
3634
}

tests/Hybrid/CreateTable/MiscCreateTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,18 @@ public function discussion_53()
7373
'create table `test` (`id` bigint unsigned not null auto_increment, `user_id` bigint unsigned not null, `template_id` varchar(255) not null, `data` longtext not null, `response_status_code` varchar(255) not null, `response_message` longtext not null, `created_at` timestamp null, `updated_at` timestamp null, index `test_id_index`(`id`), shard key(`user_id`))'
7474
);
7575
}
76+
77+
/** @test */
78+
public function json_column()
79+
{
80+
$blueprint = $this->createTable(function (Blueprint $table) {
81+
$table->id();
82+
$table->json('data');
83+
});
84+
85+
$this->assertCreateStatement(
86+
$blueprint,
87+
'create table `test` (`id` bigint unsigned not null auto_increment primary key, `data` json not null)'
88+
);
89+
}
7690
}

tests/Hybrid/Json/JsonWhereTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function singlestore_will_cast_all_types()
3131
$query3 = DB::table('test')->where('data->value1->value2', 1.5);
3232
$query4 = DB::table('test')->where('data->value1->value2', json_encode(['a' => 'b']));
3333

34-
if (! $this->runHybridIntegrations()) {
34+
if (!$this->runHybridIntegrations()) {
3535
return;
3636
}
3737

@@ -71,7 +71,7 @@ public function json_boolean()
7171
$query2->toSql()
7272
);
7373

74-
if (! $this->runHybridIntegrations()) {
74+
if (!$this->runHybridIntegrations()) {
7575
return;
7676
}
7777

@@ -105,15 +105,15 @@ public function nested_where()
105105
/** @test */
106106
public function where_null()
107107
{
108-
$query = DB::table('test')->whereNull('data->value1');
108+
$query = DB::table('test')->whereNull('data->value1')->orderBy('id');
109109

110110
$this->assertEquals(
111111
// @TODO check docs
112-
"select * from `test` where (JSON_EXTRACT_JSON(data, 'value1') IS NULL OR JSON_GET_TYPE(JSON_EXTRACT_JSON(data, 'value1')) = 'NULL')",
112+
"select * from `test` where (JSON_EXTRACT_JSON(data, 'value1') IS NULL OR JSON_GET_TYPE(JSON_EXTRACT_JSON(data, 'value1')) = 'NULL') order by `id` asc",
113113
$query->toSql()
114114
);
115115

116-
if (! $this->runHybridIntegrations()) {
116+
if (!$this->runHybridIntegrations()) {
117117
return;
118118
}
119119

@@ -139,11 +139,11 @@ public function where_not_null()
139139
$query->toSql()
140140
);
141141

142-
if (! $this->runHybridIntegrations()) {
142+
if (!$this->runHybridIntegrations()) {
143143
return;
144144
}
145145

146-
[$id1, , , $id4] = $this->insertJsonData([
146+
[$id1,,, $id4] = $this->insertJsonData([
147147
['value1' => ['value2' => 'string']],
148148
['value1' => null],
149149
[null],

tests/Hybrid/TransactionsTest.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace SingleStore\Laravel\Tests\Hybrid;
4+
5+
use Illuminate\Support\Facades\DB;
6+
use SingleStore\Laravel\Schema\Blueprint;
7+
use SingleStore\Laravel\Tests\BaseTest;
8+
9+
class TransactionsTest extends BaseTest
10+
{
11+
use HybridTestHelpers;
12+
13+
protected function setUp(): void
14+
{
15+
parent::setUp();
16+
17+
if ($this->runHybridIntegrations()) {
18+
$this->createTable(function (Blueprint $table) {
19+
$table->id();
20+
});
21+
}
22+
}
23+
24+
/** @test */
25+
public function multipleBegin()
26+
{
27+
if (!$this->runHybridIntegrations()) {
28+
return;
29+
}
30+
31+
DB::beginTransaction();
32+
DB::rollBack();
33+
DB::insert('select 1');
34+
DB::beginTransaction();
35+
DB::rollBack();
36+
}
37+
}

0 commit comments

Comments
 (0)