-
Notifications
You must be signed in to change notification settings - Fork 14
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
#124 Implemented helper to generate test state #162
#124 Implemented helper to generate test state #162
Conversation
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.
please cover new logic by autotests
src/Tests/TableTestState.php
Outdated
@@ -40,6 +46,7 @@ public function assertNotChanged(): void | |||
public function assertChangesEqualsFixture(string $fixture, bool $exportMode = false): void | |||
{ | |||
$changes = $this->getChanges(); | |||
$exportMode = $this->globalExportMode || $exportMode; |
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.
the assertEqualsFixture
method already checking the globalExportMode
property of the class
laravel-helpers/src/Traits/FixturesTrait.php
Line 104 in c5a92fd
$globalExportMode = $this->globalExportMode ?? false; |
# Conflicts: # src/Tests/ModelTestState.php
tests/ModelTestStateTest.php
Outdated
$mock = $this->getMockBuilder(TestCase::class) | ||
->disableOriginalConstructor() |
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.
$mock = $this->getMockBuilder(TestCase::class) | |
->disableOriginalConstructor() | |
$mock = $this | |
->getMockBuilder(TestCase::class) | |
->disableOriginalConstructor() |
tests/ModelTestStateTest.php
Outdated
|
||
$reflection = new ReflectionClass($mock); | ||
|
||
$this->assertFalse($reflection->getProperty('globalExportMode')->getValue($mock)); |
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.
no reasons to check the initial value of the test case class
tests/ModelTestStateTest.php
Outdated
$setGlobalExportMode = $reflection->getMethod('setGlobalExportMode'); | ||
$setGlobalExportMode->invoke($mock); |
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.
$setGlobalExportMode = $reflection->getMethod('setGlobalExportMode'); | |
$setGlobalExportMode->invoke($mock); | |
$reflection->getMethod('setGlobalExportMode')->invoke($mock); |
tests/ModelTestStateTest.php
Outdated
$prepareModelTestState = $reflection->getMethod('prepareModelTestState'); | ||
$prepareModelTestState->invoke($mock, TestModel::class); | ||
|
||
$this->assertTrue($reflection->getProperty('globalExportMode')->getValue($mock)); |
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.
what this test case testing? you need to test that the global export mode property of created test state has the same value as in the TestCase class
tests/ModelTestStateTest.php
Outdated
$datasetMock = collect($this->getJsonFixture('initialization/dataset.json')); | ||
$this->mockGettingDataset($datasetMock); | ||
|
||
$mock = $this |
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.
$mock = $this | |
$testCaseMock = $this |
tests/ModelTestStateTest.php
Outdated
->disableOriginalConstructor() | ||
->getMockForAbstractClass(); | ||
|
||
$reflection = new ReflectionClass($mock); |
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.
$reflection = new ReflectionClass($mock); | |
$testCase = new ReflectionClass($mock); |
tests/TableTestStateTest.php
Outdated
$mock = $this | ||
->getMockBuilder(TestCase::class) | ||
->disableOriginalConstructor() | ||
->getMockForAbstractClass(); | ||
|
||
$reflection = new ReflectionClass($mock); | ||
|
||
$reflection->getMethod('setGlobalExportMode')->invoke($mock); | ||
|
||
$prepareTableTestState = $reflection->getMethod('prepareTableTestState')->invoke($mock, 'test_models'); |
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.
let's move it to the separate method which will return reflection of the TestCase class with enabled global export mode
The branch was created from this