diff --git a/Dockerfile b/Dockerfile index 870d44d7e..69befa3ac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,12 +24,19 @@ RUN apt-get update \ # For rewrite rules && a2enmod rewrite \ # Needed for gluedev/laravel-stackdriver - && pecl install opencensus-alpha \ - && docker-php-ext-enable opencensus \ + && pecl install opencensus-alpha xdebug \ + && docker-php-ext-enable opencensus xdebug \ && rm -rf /var/lib/apt/lists/* ENV APACHE_DOCUMENT_ROOT /var/www/html/public +RUN echo "zend_extension=xdebug\n\n\ +[xdebug]\n\ +xdebug.mode=develop,debug\n\ +xdebug.client_host=192.168.1.13\n\ +xdebug.client_port=9003\n\ +" > /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini + # Change the document root RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf \ && sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf diff --git a/tests/Jobs/CirrusSearch/ElasticSearchIndexInitTest.php b/tests/Jobs/CirrusSearch/ElasticSearchIndexInitTest.php index 439440f33..4a152a07d 100644 --- a/tests/Jobs/CirrusSearch/ElasticSearchIndexInitTest.php +++ b/tests/Jobs/CirrusSearch/ElasticSearchIndexInitTest.php @@ -4,6 +4,7 @@ use App\User; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; use App\Jobs\CirrusSearch\ElasticSearchIndexInit; use App\Http\Curl\HttpRequest; @@ -18,7 +19,7 @@ class ElasticSearchIndexInitTest extends TestCase { - use DatabaseTransactions; + use RefreshDatabase; use DispatchesJobs; private $wiki; @@ -95,7 +96,7 @@ public function testSuccess() // feature should get enabled $this->assertSame( - 1, + 1, WikiSetting::where( ['wiki_id' => $this->wiki->id, 'name' => WikiSetting::wwExtEnableElasticSearch, 'value' => true])->count() ); } @@ -125,7 +126,7 @@ public function testUpdate() // feature should get enabled $this->assertSame( - 1, + 1, WikiSetting::where( ['wiki_id' => $this->wiki->id, 'name' => WikiSetting::wwExtEnableElasticSearch, 'value' => true])->count() ); } @@ -150,16 +151,16 @@ public function testFailure( $request, string $expectedFailure, $mockResponse ) $mockJob->expects($this->once()) ->method('fail') ->with(new \RuntimeException(str_replace('', $this->wiki->id, $expectedFailure))); - + $request->method('execute')->willReturn(json_encode($mockResponse)); $job = new ElasticSearchIndexInit($this->wiki->id); $job->setJob($mockJob); $job->handle($request); - + $this->assertSame( - 0, + 0, WikiSetting::where( ['wiki_id' => $this->wiki->id, 'name' => WikiSetting::wwExtEnableElasticSearch, 'value' => true])->count() ); } diff --git a/tests/Jobs/CirrusSearch/ForceSearchIndexTest.php b/tests/Jobs/CirrusSearch/ForceSearchIndexTest.php index a0f69d9a7..1261a55db 100644 --- a/tests/Jobs/CirrusSearch/ForceSearchIndexTest.php +++ b/tests/Jobs/CirrusSearch/ForceSearchIndexTest.php @@ -4,6 +4,7 @@ use App\User; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; use App\Jobs\CirrusSearch\ElasticSearchIndexInit; use App\Http\Curl\HttpRequest; @@ -22,7 +23,7 @@ class ForceSearchIndexTest extends TestCase { - use DatabaseTransactions; + use RefreshDatabase; use DispatchesJobs; private $wiki; private $wikiDb; diff --git a/tests/Jobs/CirrusSearch/QueueSearchIndexBatchesTest.php b/tests/Jobs/CirrusSearch/QueueSearchIndexBatchesTest.php index cbc6f1318..accb8d63d 100644 --- a/tests/Jobs/CirrusSearch/QueueSearchIndexBatchesTest.php +++ b/tests/Jobs/CirrusSearch/QueueSearchIndexBatchesTest.php @@ -4,6 +4,7 @@ use App\User; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; use App\Jobs\CirrusSearch\ElasticSearchIndexInit; use App\Http\Curl\HttpRequest; @@ -22,7 +23,7 @@ class QueueSearchIndexBatchesTest extends TestCase { - use DatabaseTransactions; + use RefreshDatabase; use DispatchesJobs; private $wiki; @@ -50,7 +51,7 @@ public function setUp(): void { public function testSuccess() { Queue::fake(); - + $mockResponse = [ 'warnings' => [], 'wbstackQueueSearchIndexBatches' => [ diff --git a/tests/Jobs/DeleteQueryserviceNamespaceJobTest.php b/tests/Jobs/DeleteQueryserviceNamespaceJobTest.php index 5506dc2f0..46e4be398 100644 --- a/tests/Jobs/DeleteQueryserviceNamespaceJobTest.php +++ b/tests/Jobs/DeleteQueryserviceNamespaceJobTest.php @@ -2,7 +2,7 @@ namespace Tests\Jobs; -use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; use App\Http\Curl\HttpRequest; use App\Jobs\DeleteQueryserviceNamespaceJob; @@ -16,7 +16,7 @@ class DeleteQueryserviceNamespaceJobTest extends TestCase { - use DatabaseTransactions; + use RefreshDatabase; public function testDeleteNamespace() { @@ -44,8 +44,8 @@ public function testDeleteNamespace() $request->expects($this->exactly(1)) ->method('setOptions') - ->with( - [ + ->with( + [ CURLOPT_URL => $dbRow->backend.'/bigdata/namespace/' . $namespace, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', @@ -59,12 +59,12 @@ public function testDeleteNamespace() ] ]); - + $job = new DeleteQueryserviceNamespaceJob($wiki->id); $job->handle( $request ); $this->assertSame( - 0, + 0, QueryserviceNamespace::where( ['namespace' => $namespace ])->count() ); } @@ -105,4 +105,4 @@ public function testNoNamespace() { $job->handle($request); } -} \ No newline at end of file +} diff --git a/tests/Jobs/DeleteWikiDispatcherJobTest.php b/tests/Jobs/DeleteWikiDispatcherJobTest.php index 2592407ff..e344018f6 100644 --- a/tests/Jobs/DeleteWikiDispatcherJobTest.php +++ b/tests/Jobs/DeleteWikiDispatcherJobTest.php @@ -2,7 +2,7 @@ namespace Tests\Jobs; -use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; use App\QueryserviceNamespace; use Illuminate\Contracts\Queue\Job; @@ -29,7 +29,7 @@ class DeleteWikiDispatcherJobTest extends TestCase { - use DatabaseTransactions; + use RefreshDatabase; public function setUp(): void { parent::setUp(); @@ -94,6 +94,7 @@ public function testNothingDispatchesUntilItsTime() { $job->handle(); Log::assertLogged('info', function ($message, $context) { + echo $message; return Str::contains($message, 'Found no soft deleted wikis over threshold. exiting.'); }); @@ -120,10 +121,10 @@ public function testDeleteWithOptionalResources() $this->assertNotNull($nsAssignment); WikiSetting::factory()->create( - [ + [ 'wiki_id' => $this->wiki->id, 'name' => WikiSetting::wwExtEnableElasticSearch, - 'value' => true + 'value' => true ] ); @@ -147,7 +148,7 @@ public function testDeleteWithOptionalResources() public function testActuallyRunningJobsThatDelete() { $this->wiki->update(['domain' => 'asdasdaf' . Config::get('wbstack.subdomain_suffix')]); - + // create db to be deleted $job = new ProvisionWikiDbJob('great_job', 'the_test_database', null); $job->handle( $this->app->make('db') ); @@ -159,7 +160,7 @@ public function testActuallyRunningJobsThatDelete() $this->assertTrue( $res ); $this->assertNotNull( WikiDb::where([ 'wiki_id' => $this->wiki->id ])->first() ); - + $mockJob = $this->createMock(Job::class); $job = new DeleteWikiDispatcherJob(); $job->setJob($mockJob); @@ -177,4 +178,4 @@ public function testActuallyRunningJobsThatDelete() $mockJob->expects($this->never())->method('fail'); } -} \ No newline at end of file +} diff --git a/tests/Jobs/DeleteWikiFinalizeJobTest.php b/tests/Jobs/DeleteWikiFinalizeJobTest.php index 5ba04c268..519f4dc1b 100644 --- a/tests/Jobs/DeleteWikiFinalizeJobTest.php +++ b/tests/Jobs/DeleteWikiFinalizeJobTest.php @@ -4,6 +4,7 @@ use App\User; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; use App\WikiManager; use App\Wiki; @@ -18,7 +19,7 @@ class DeleteWikiFinalizeJobTest extends TestCase { - use DatabaseTransactions; + use RefreshDatabase; public function setUp(): void { parent::setUp(); diff --git a/tests/Jobs/DeleteWikiJobTest.php b/tests/Jobs/DeleteWikiJobTest.php index 0c7b032d6..d92ecdf38 100644 --- a/tests/Jobs/DeleteWikiJobTest.php +++ b/tests/Jobs/DeleteWikiJobTest.php @@ -2,7 +2,7 @@ namespace Tests\Jobs; -use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; use App\Jobs\DeleteWikiDbJob; use App\User; @@ -20,18 +20,10 @@ class DeleteWikiJobTest extends TestCase { - use DatabaseTransactions; + use RefreshDatabase; use DispatchesJobs; private $wiki; - protected $connectionsToTransact = ['mysql', 'mw']; - - protected function setUp(): void { - parent::setUp(); - DB::delete( "DELETE FROM wiki_dbs WHERE name='the_test_database';" ); - DB::delete( "DELETE FROM wiki_dbs WHERE name='the_test_database_not_to_be_deleted';" ); - DB::connection('mysql')->getPdo()->exec('DROP DATABASE IF EXISTS the_test_database; DROP DATABASE IF EXISTS the_test_database_not_to_be_deleted'); - } private function getExpectedDeletedDatabaseName( $wiki ): string { return "mwdb_deleted_1631534400_" . $wiki->id; @@ -78,13 +70,13 @@ public function testDeletesWiki() // Would be injected by the app $manager = $this->app->make('db'); - + $job = new ProvisionWikiDbJob($databases[0]['prefix'], $databases[0]['name'], null); $job->handle($manager); // Would be injected by the app $manager = $this->app->make('db'); - + $job = new ProvisionWikiDbJob($databases[1]['prefix'], $databases[1]['name'], null); $job->handle($manager); @@ -117,7 +109,7 @@ public function testDeletesWiki() // this job will kill the underlying connection $job = new DeleteWikiDbJob( $this->wiki->id ); - $job->setJob($mockJob); +// $job->setJob($mockJob); $job->handle($manager); // get a new connection and take a look at the database tables and newly created databases @@ -167,7 +159,7 @@ public function testFailure( $wiki_id, $deleted_at, string $expectedFailure) $mockJob->expects($this->once()) ->method('fail') ->with(new \RuntimeException(str_replace('', $wiki_id, $expectedFailure))); - + $job = new DeleteWikiDbJob($wiki_id); $job->setJob($mockJob); $job->handle($mockMananger); diff --git a/tests/Jobs/ElasticSearch/ElasticSearchIndexDeleteTest.php b/tests/Jobs/ElasticSearch/ElasticSearchIndexDeleteTest.php index fcba3e5a2..3ef7e2081 100644 --- a/tests/Jobs/ElasticSearch/ElasticSearchIndexDeleteTest.php +++ b/tests/Jobs/ElasticSearch/ElasticSearchIndexDeleteTest.php @@ -4,6 +4,7 @@ use App\User; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; use App\Http\Curl\HttpRequest; use App\WikiManager; @@ -16,7 +17,8 @@ class ElasticSearchIndexDeleteTest extends TestCase { - use DatabaseTransactions; + use RefreshDatabase; + private $wiki; private $user; private $wikiDb; @@ -57,7 +59,7 @@ public function testDeletesElasticSearchIndex() $request->expects($this->exactly(2)) ->method('setOptions') - ->withConsecutive( + ->withConsecutive( [[ CURLOPT_URL => $this->elasticSearchHost.'/_cat/indices/'.$this->wikiDb->name.'*?v&s=index&h=index', CURLOPT_RETURNTRANSFER => true, @@ -74,7 +76,7 @@ public function testDeletesElasticSearchIndex() CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'DELETE', ]]); - + $mockJob = $this->createMock(Job::class); $mockJob->expects($this->never())->method('fail'); @@ -85,7 +87,7 @@ public function testDeletesElasticSearchIndex() // feature should get disabled $this->assertSame( - 1, + 1, WikiSetting::where( ['wiki_id' => $this->wiki->id, 'name' => WikiSetting::wwExtEnableElasticSearch, 'value' => false])->count() ); } @@ -113,9 +115,9 @@ public function testFailure( $request, string $expectedFailure, $mockResponse, $ $job = new ElasticSearchIndexDelete($this->wiki->id); $job->setJob($mockJob); $job->handle( $request ); - + $this->assertSame( - 1, + 1, WikiSetting::where( ['wiki_id' => $this->wiki->id, 'name' => WikiSetting::wwExtEnableElasticSearch, 'value' => $settingStateInDatabase])->count() ); diff --git a/tests/Jobs/Integration/ElasticSearchIndexDeleteTest.php b/tests/Jobs/Integration/ElasticSearchIndexDeleteTest.php index b350c4781..6dff39b80 100644 --- a/tests/Jobs/Integration/ElasticSearchIndexDeleteTest.php +++ b/tests/Jobs/Integration/ElasticSearchIndexDeleteTest.php @@ -4,6 +4,7 @@ use App\User; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; use App\WikiManager; use App\WikiSetting; @@ -16,18 +17,18 @@ use Illuminate\Support\Facades\Config; /** - * This is only meant to run when services is started with + * This is only meant to run when services is started with * additional services from docker-compose.integration.yml - * + * * Delete all local indices: - * + * * curl -X DELETE "localhost:9200/*?pretty" - * + * * Example: docker-compose exec -e RUN_PHPUNIT_INTEGRATION_TEST=1 -e ELASTICSEARCH_HOST=elasticsearch.svc:9200 -T api vendor/bin/phpunit tests/Jobs/Integration/ElasticSearchIndexDeleteTest.php */ class ElasticSearchIndexDeleteTest extends TestCase { - use DatabaseTransactions; + use RefreshDatabase; use DispatchesJobs; private $wiki; @@ -36,7 +37,7 @@ class ElasticSearchIndexDeleteTest extends TestCase public function makeRequest( $url, $method = 'GET' ) { // create some dummy index $curlRequest = new CurlRequest(); - $curlRequest->setOptions( + $curlRequest->setOptions( [ CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, @@ -54,7 +55,7 @@ public function makeRequest( $url, $method = 'GET' ) { var_dump($err); } $curlRequest->close(); - + return json_decode($response, true); } diff --git a/tests/Jobs/Integration/QueryserviceNamespaceJobTest.php b/tests/Jobs/Integration/QueryserviceNamespaceJobTest.php index 84715ab89..182fad7fe 100644 --- a/tests/Jobs/Integration/QueryserviceNamespaceJobTest.php +++ b/tests/Jobs/Integration/QueryserviceNamespaceJobTest.php @@ -3,6 +3,7 @@ namespace Tests\Jobs\Integration; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; use App\Jobs\ProvisionQueryserviceNamespaceJob; use App\QueryserviceNamespace; @@ -16,21 +17,21 @@ use Illuminate\Foundation\Bus\DispatchesJobs; /** - * This is only meant to run when services is started with + * This is only meant to run when services is started with * additional services from docker-compose.integration.yml - * + * * Example: docker-compose exec -e RUN_PHPUNIT_INTEGRATION_TEST=1 -T api vendor/bin/phpunit tests/Jobs/Integration/QueryserviceNamespaceJobTest.php */ class QueryserviceNamespaceJobTest extends TestCase { - use DatabaseTransactions; + use RefreshDatabase; use DispatchesJobs; public function setUp(): void { parent::setUp(); if ( !getenv('RUN_PHPUNIT_INTEGRATION_TEST') ) { $this->markTestSkipped('No blazegraph instance to connect to'); - } + } } public function testIntegrationCreate() @@ -63,4 +64,4 @@ public function testIntegrationCreate() ); } -} \ No newline at end of file +} diff --git a/tests/Jobs/KubernetesIngressCreateTest.php b/tests/Jobs/KubernetesIngressCreateTest.php index ec47c4f2b..c340fd6b4 100644 --- a/tests/Jobs/KubernetesIngressCreateTest.php +++ b/tests/Jobs/KubernetesIngressCreateTest.php @@ -4,6 +4,7 @@ use App\User; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; use App\Wiki; use App\WikiManager; @@ -17,7 +18,7 @@ class KubernetesIngressCreateTest extends TestCase { - use DatabaseTransactions; + use RefreshDatabase; public function testCreateIngressJobDoesNotFail() { diff --git a/tests/Jobs/KubernetesIngressDeleteJobTest.php b/tests/Jobs/KubernetesIngressDeleteJobTest.php index ebdbc288b..953eacdf0 100644 --- a/tests/Jobs/KubernetesIngressDeleteJobTest.php +++ b/tests/Jobs/KubernetesIngressDeleteJobTest.php @@ -4,6 +4,7 @@ use App\User; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; use App\Jobs\KubernetesIngressDeleteJob; use App\Wiki; @@ -14,15 +15,15 @@ class KubernetesIngressDeleteJobTest extends TestCase { - use DatabaseTransactions; + use RefreshDatabase; public function testDoesNotDeleteNonDeletedWikis() { - + $user = User::factory()->create(['verified' => true]); $wiki = Wiki::factory()->create( [ 'deleted_at' => null ] ); WikiManager::factory()->create(['wiki_id' => $wiki->id, 'user_id' => $user->id]); - + $mockJob = $this->createMock(Job::class); $mockJob->expects($this->once()) ->method('fail') @@ -30,7 +31,7 @@ public function testDoesNotDeleteNonDeletedWikis() $job = new KubernetesIngressDeleteJob($wiki->id); $job->setJob($mockJob); - + App::call(function ( Client $client ) use ($job) { $job->handle( $client ); } ); diff --git a/tests/Jobs/MigrationWikiCreateTest.php b/tests/Jobs/MigrationWikiCreateTest.php index 61742a47e..a0e17142f 100644 --- a/tests/Jobs/MigrationWikiCreateTest.php +++ b/tests/Jobs/MigrationWikiCreateTest.php @@ -12,6 +12,7 @@ use App\WikiSetting; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Contracts\Queue\Job; +use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; use App\Jobs\KubernetesIngressCreate; use Illuminate\Support\Facades\Bus; @@ -19,7 +20,7 @@ class MigrationWikiCreateTest extends TestCase { - use DatabaseTransactions; + use RefreshDatabase; public function testMigrationWithCustomDomainAndWithoutUserRunsAndCreatesUser(): void { diff --git a/tests/Jobs/PlatformStatsSummaryJobTest.php b/tests/Jobs/PlatformStatsSummaryJobTest.php index c06acd343..6f447360c 100644 --- a/tests/Jobs/PlatformStatsSummaryJobTest.php +++ b/tests/Jobs/PlatformStatsSummaryJobTest.php @@ -3,6 +3,7 @@ namespace Tests\Jobs; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; use App\User; use App\Wiki; @@ -16,7 +17,7 @@ class PlatformStatsSummaryJobTest extends TestCase { - use DatabaseTransactions; + use RefreshDatabase; private $numWikis = 5; private $wikis = []; @@ -26,21 +27,10 @@ class PlatformStatsSummaryJobTest extends TestCase protected function setUp(): void { parent::setUp(); - for($n = 0; $n < $this->numWikis; $n++ ) { - DB::connection('mysql')->getPdo()->exec("DROP DATABASE IF EXISTS {$this->db_name}{$n};"); - } $this->seedWikis(); $this->manager = $this->app->make('db'); } - protected function tearDown(): void { - foreach($this->wikis as $wiki) { - $wiki['wiki']->wikiDb()->forceDelete(); - $wiki['wiki']->forceDelete(); - } - parent::tearDown(); - } - private function seedWikis() { $manager = $this->app->make('db'); for($n = 0; $n < $this->numWikis; $n++ ) { @@ -82,7 +72,7 @@ public function testGroupings() $job = new PlatformStatsSummaryJob(); $job->setJob($mockJob); - + $testWikis = [ Wiki::factory()->create( [ 'deleted_at' => null, 'domain' => 'wiki1.com' ] ), Wiki::factory()->create( [ 'deleted_at' => null, 'domain' => 'wiki2.com' ] ), @@ -99,7 +89,7 @@ public function testGroupings() 'version' => 'asdasdasdas', 'prefix' => 'asdasd', 'wiki_id' => $wiki->id - ]); + ]); } $stats = [ [ // inactive @@ -145,10 +135,10 @@ public function testGroupings() "platform_summary_version" => "v1" ], ]; - + $groups = $job->prepareStats($stats, $testWikis); - + $this->assertEquals( [ "total" => 4, @@ -162,7 +152,7 @@ public function testGroupings() "total_non_deleted_edits" => 1, "platform_summary_version" => "v1" ], - $groups, + $groups, ); } diff --git a/tests/Jobs/ProvisionQueryserviceNamespaceJobTest.php b/tests/Jobs/ProvisionQueryserviceNamespaceJobTest.php index 40eb2ca73..4396e6190 100644 --- a/tests/Jobs/ProvisionQueryserviceNamespaceJobTest.php +++ b/tests/Jobs/ProvisionQueryserviceNamespaceJobTest.php @@ -3,6 +3,7 @@ namespace Tests\Jobs; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; use App\Http\Curl\HttpRequest; use App\Jobs\ProvisionQueryserviceNamespaceJob; @@ -11,7 +12,7 @@ class ProvisionQueryserviceNamespaceJobTest extends TestCase { - use DatabaseTransactions; + use RefreshDatabase; public function testCreatesNamespace() { @@ -30,8 +31,8 @@ public function testCreatesNamespace() $request->expects($this->exactly(1)) ->method('setOptions') - ->with( - [ + ->with( + [ CURLOPT_URL => config('app.queryservice_host').'/bigdata/namespace', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', @@ -46,12 +47,12 @@ public function testCreatesNamespace() ] ]); - + $job = new ProvisionQueryserviceNamespaceJob($namespace, null); $job->handle($request); $this->assertSame( - 1, + 1, QueryserviceNamespace::where( ['namespace' => $namespace ])->count() ); } @@ -66,7 +67,7 @@ public function testMaxFree() $request->expects($this->never()) ->method('setOptions'); - + QueryserviceNamespace::where([ 'wiki_id' => null, ])->delete(); @@ -84,8 +85,8 @@ public function testMaxFree() $job->handle($request); $this->assertSame( - 0, + 0, QueryserviceNamespace::where( ['namespace' => $namespace ])->count() ); } -} \ No newline at end of file +} diff --git a/tests/Jobs/SetWikiLogoTest.php b/tests/Jobs/SetWikiLogoTest.php index c51a29d32..285a429a6 100644 --- a/tests/Jobs/SetWikiLogoTest.php +++ b/tests/Jobs/SetWikiLogoTest.php @@ -11,6 +11,7 @@ use Illuminate\Contracts\Queue\Job; use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Support\Facades\Storage; use Intervention\Image\Facades\Image; use Tests\TestCase; @@ -18,7 +19,7 @@ class SetWikiLogoTest extends TestCase { - use DatabaseTransactions; + use RefreshDatabase; use DispatchesJobs; private function assertJobFails(string $wikiKey, string $wikiValue, string $logoPath) diff --git a/tests/Routes/Auth/LoginTest.php b/tests/Routes/Auth/LoginTest.php index 15590421e..9df89df4c 100644 --- a/tests/Routes/Auth/LoginTest.php +++ b/tests/Routes/Auth/LoginTest.php @@ -4,6 +4,7 @@ use App\User; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\Routes\Traits\OptionsRequestAllowed; use Tests\TestCase; @@ -12,7 +13,7 @@ class LoginTest extends TestCase protected $route = 'auth/login'; use OptionsRequestAllowed; - use DatabaseTransactions; + use RefreshDatabase; public function testLoginFail_noExistingUser() { diff --git a/tests/Routes/User/RegisterTest.php b/tests/Routes/User/RegisterTest.php index 0994f1bbb..201aa58cf 100644 --- a/tests/Routes/User/RegisterTest.php +++ b/tests/Routes/User/RegisterTest.php @@ -6,6 +6,7 @@ use App\Notifications\UserCreationNotification; use App\User; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Support\Facades\Notification; use Tests\Routes\Traits\OptionsRequestAllowed; use Tests\TestCase; @@ -15,7 +16,7 @@ class RegisterTest extends TestCase protected $route = 'user/register'; use OptionsRequestAllowed; - use DatabaseTransactions; + use RefreshDatabase; // TODO test password length when not deving diff --git a/tests/Routes/User/SelfTest.php b/tests/Routes/User/SelfTest.php index 6cd960402..f4111f0dc 100644 --- a/tests/Routes/User/SelfTest.php +++ b/tests/Routes/User/SelfTest.php @@ -4,6 +4,7 @@ use App\User; use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\Routes\Traits\OptionsRequestAllowed; use Tests\Routes\Traits\PostRequestNeedAuthentication; use Tests\TestCase; @@ -14,7 +15,7 @@ class SelfTest extends TestCase use OptionsRequestAllowed; use PostRequestNeedAuthentication; - use DatabaseTransactions; + use RefreshDatabase; public function testGet() { diff --git a/tests/Routes/Wiki/CreateTest.php b/tests/Routes/Wiki/CreateTest.php index 6016a9ac6..848a5062b 100644 --- a/tests/Routes/Wiki/CreateTest.php +++ b/tests/Routes/Wiki/CreateTest.php @@ -2,6 +2,7 @@ namespace Tests\Routes\Wiki\Managers; +use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\Routes\Traits\OptionsRequestAllowed; use Tests\TestCase; use Illuminate\Foundation\Testing\DatabaseTransactions; @@ -22,7 +23,7 @@ class CreateTest extends TestCase protected $route = 'wiki/create'; use OptionsRequestAllowed; - use DatabaseTransactions; + use RefreshDatabase; /** * @dataProvider createProvider diff --git a/tests/Routes/Wiki/SettingUpdateTest.php b/tests/Routes/Wiki/SettingUpdateTest.php index 8a6c36331..ea5de0eb4 100644 --- a/tests/Routes/Wiki/SettingUpdateTest.php +++ b/tests/Routes/Wiki/SettingUpdateTest.php @@ -8,6 +8,7 @@ use App\WikiSetting; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Database\Eloquent\Factories\HasFactory; +use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\Routes\Traits\OptionsRequestAllowed; use Tests\Routes\Traits\PostRequestNeedAuthentication; use Tests\TestCase; @@ -19,7 +20,7 @@ class SettingUpdateTest extends TestCase protected $route = 'wiki/setting/foo/update'; - use DatabaseTransactions; + use RefreshDatabase; use OptionsRequestAllowed; use PostRequestNeedAuthentication;