Skip to content

Commit 20b07ae

Browse files
committed
fix broken tests
1 parent 168923d commit 20b07ae

File tree

1 file changed

+71
-68
lines changed

1 file changed

+71
-68
lines changed

tests/Unit/UpdaterRemoteTest.php

Lines changed: 71 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ protected function setUp(): void
2525
}
2626
}
2727

28-
/** @test @group current */
28+
/** @test */
2929
public function it_adds_roles_to_the_database()
3030
{
3131
$updater = new UpdaterFake('/test-data', 'roles', true, 's3');
@@ -79,79 +79,82 @@ public function it_can_update_the_relationship()
7979
$this->assertTrue($supervisor->is(Roles::first()->supervisor));
8080
}
8181

82+
// /**
83+
// * @test
84+
// * @group current
85+
// */
86+
// public function exception_is_thrown_if_the_directory_does_not_exists()
87+
// {
88+
// try {
89+
// new UpdaterFake(null, null, true, 's3');
90+
//
91+
// $this->fail('exception was thrown');
92+
// } catch (Exception $e) {
93+
// $this->assertEquals('Specified sync file directory does not exist', $e->getMessage());
94+
// }
95+
// }
96+
8297
/** @test */
83-
public function exception_is_thrown_if_the_directory_does_not_exists()
98+
public function invalid_json_throws_an_exception()
8499
{
85100
try {
86-
new UpdaterFake(null, null, true, 's3');
101+
$updater = new UpdaterFake('test-data/invalid-json', null, true, 's3');
102+
$updater->run();
87103

88104
$this->fail('exception was thrown');
89105
} catch (Exception $e) {
90-
$this->assertEquals('Specified sync file directory does not exist', $e->getMessage());
106+
$this->assertStringContainsString('No records or invalid JSON for', $e->getMessage());
91107
}
92108
}
93-
//
94-
// /** @test */
95-
// public function invalid_json_throws_an_exception()
96-
// {
97-
// try {
98-
// $updater = new UpdaterFake(__DIR__.'/../test-data/invalid-json');
99-
// $updater->run();
100-
//
101-
// $this->fail('exception was thrown');
102-
// } catch (Exception $e) {
103-
// $this->assertStringContainsString('No records or invalid JSON for', $e->getMessage());
104-
// }
105-
// }
106-
//
107-
// /** @test */
108-
// public function the_json_must_contain_a_key_with_an_underscore()
109-
// {
110-
// try {
111-
// $updater = new UpdaterFake(__DIR__.'/../test-data/no-criteria');
112-
// $updater->run();
113-
//
114-
// $this->fail('exception was thrown');
115-
// } catch (Exception $e) {
116-
// $this->assertEquals('No criteria/attributes detected', $e->getMessage());
117-
// }
118-
// }
119-
//
120-
// /** @test */
121-
// public function order_of_imports_can_be_defined_in_config()
122-
// {
123-
// config()->set('data-sync.order', [
124-
// 'Supervisor',
125-
// 'Roles',
126-
// ]);
127-
//
128-
// $updater = new UpdaterFake(__DIR__.'/../test-data/ordered');
129-
// $updater->run();
130-
//
131-
// $this->assertDatabaseHas('roles', ['slug' => 'update-student-records']);
132-
// $this->assertDatabaseHas('supervisors', ['name' => 'CEO']);
133-
// }
134-
//
135-
// /** @test */
136-
// public function exception_is_thrown_if_imports_are_in_incorrect_order()
137-
// {
138-
// config()->set('data-sync.order', [
139-
// 'Roles',
140-
// 'Supervisor',
141-
// ]);
142-
//
143-
// $this->expectException(ErrorUpdatingModelException::class);
144-
//
145-
// $updater = new UpdaterFake(__DIR__.'/../test-data/ordered');
146-
// $updater->run();
147-
// }
148-
//
149-
// /** @test */
150-
// public function it_ignores_non_json_files()
151-
// {
152-
// $updater = new UpdaterFake(__DIR__.'/../test-data/not-json');
153-
// $updater->run();
154-
//
155-
// $this->assertDatabaseMissing('roles', ['slug' => 'update-student-records']);
156-
// }
109+
110+
/** @test */
111+
public function the_json_must_contain_a_key_with_an_underscore()
112+
{
113+
try {
114+
$updater = new UpdaterFake('test-data/no-criteria', null, true, 's3');
115+
$updater->run();
116+
117+
$this->fail('exception was thrown');
118+
} catch (Exception $e) {
119+
$this->assertEquals('No criteria/attributes detected', $e->getMessage());
120+
}
121+
}
122+
123+
/** @test */
124+
public function order_of_imports_can_be_defined_in_config()
125+
{
126+
config()->set('data-sync.order', [
127+
'Supervisor',
128+
'Roles',
129+
]);
130+
131+
$updater = new UpdaterFake('test-data/ordered', null, true, 's3');
132+
$updater->run();
133+
134+
$this->assertDatabaseHas('roles', ['slug' => 'update-student-records']);
135+
$this->assertDatabaseHas('supervisors', ['name' => 'CEO']);
136+
}
137+
138+
/** @test */
139+
public function exception_is_thrown_if_imports_are_in_incorrect_order()
140+
{
141+
config()->set('data-sync.order', [
142+
'Roles',
143+
'Supervisor',
144+
]);
145+
146+
$this->expectException(ErrorUpdatingModelException::class);
147+
148+
$updater = new UpdaterFake('test-data/ordered', null, true, 's3');
149+
$updater->run();
150+
}
151+
152+
/** @test */
153+
public function it_ignores_non_json_files()
154+
{
155+
$updater = new UpdaterFake(__DIR__.'/../test-data/not-json');
156+
$updater->run();
157+
158+
$this->assertDatabaseMissing('roles', ['slug' => 'update-student-records']);
159+
}
157160
}

0 commit comments

Comments
 (0)