Hi,
I am trying to get a Gitlab CI pipeline up and running for my laravel project. It is running tests, the one problem is: it gives other results than local.
When i run Phpunit in my homestead env it is all green. The functionality works by manual testing. But when ran in Gitlab CI the test fails.
Gitlab cannot find a specific column (which does not exists in any situation, as it is a "custom property" appended to the model).
So i got this test:
/**
* @test
*/
public function a_call_can_be_removed()
{
$this->signIn();
$call = create('App\Call');
$response = $this->withoutExceptionHandling()->json('DELETE', "/call/{$call->id}");
$response->assertStatus(200);
$this->assertDatabaseMissing('calls', $call->toArray());
}
Data structure of Call:
Id, person_id, user_id, comment, status, attention, timestamps.
Model:
class Call extends Model
{
protected $guarded = [];
protected $appends = ['statusDescription'];
public function person()
{
return $this->belongsTo(Person::class);
}
public function user()
{
return $this->belongsTo(User::class);
}
public function getStatusDescriptionAttribute()
{
return Status::fromCode($this->status)['description'];
}
}
Locally the test runs green, but Gitlab CI gives me this:
) Tests\Feature\CallControllerTest::a_call_can_be_removed
Illuminate\Database\QueryException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'statusDescription' in 'where clause' (SQL: select count(*) as aggregate from `calls` where (`comment` = Nam consequatur aliquam magni occaecati ullam et. Ipsum eum dolorem occaecati occaecati cumque dicta laborum. In provident ad et nam. Harum neque ut non quia recusandae dolorum. and `status` = 3 and `person_id` = 1 and `user_id` = 2 and `updated_at` = 2018-05-24 20:40:36 and `created_at` = 2018-05-24 20:40:36 and `id` = 1 and `statusDescription` = 'statusDesc'))
My Gitlab ci yml:
stages:
- test
variables:
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: homestead
MYSQL_PASSWORD: secret
MYSQL_DATABASE: homestead
DB_HOST: mysql
cache:
paths:
- vendor/
- node_modules/
- public/
test:
stage: test
services:
- mysql:5.7
image: edbizarro/gitlab-ci-pipeline-php:7.2-alpine-lts
script:
- composer install --prefer-dist --no-ansi --no-interaction --no-progress
- npm install
- cp .env.gitlab .env
- npm run dev
- php artisan key:generate
- php artisan config:cache
- php artisan migrate:refresh --seed
- ./vendor/phpunit/phpunit/phpunit -v --coverage-text --colors=never --stderr
Any other Database test goes well.
Totally clueless. Does anyone have any idea?