Skip to content
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

Merged
merged 7 commits into from
Dec 26, 2024

Conversation

yogyrton
Copy link
Contributor

The branch was created from this

@yogyrton yogyrton changed the base branch from master to 117-implement-table-test-state-class December 10, 2024 07:13
Base automatically changed from 117-implement-table-test-state-class to master December 12, 2024 00:57
Copy link
Collaborator

@DenTray DenTray left a 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

@@ -40,6 +46,7 @@ public function assertNotChanged(): void
public function assertChangesEqualsFixture(string $fixture, bool $exportMode = false): void
{
$changes = $this->getChanges();
$exportMode = $this->globalExportMode || $exportMode;
Copy link
Collaborator

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

$globalExportMode = $this->globalExportMode ?? false;

@DenTray DenTray assigned yogyrton and unassigned DenTray Dec 12, 2024
@yogyrton yogyrton assigned DenTray and unassigned yogyrton Dec 17, 2024
Comment on lines 45 to 46
$mock = $this->getMockBuilder(TestCase::class)
->disableOriginalConstructor()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$mock = $this->getMockBuilder(TestCase::class)
->disableOriginalConstructor()
$mock = $this
->getMockBuilder(TestCase::class)
->disableOriginalConstructor()


$reflection = new ReflectionClass($mock);

$this->assertFalse($reflection->getProperty('globalExportMode')->getValue($mock));
Copy link
Collaborator

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

Comment on lines 53 to 54
$setGlobalExportMode = $reflection->getMethod('setGlobalExportMode');
$setGlobalExportMode->invoke($mock);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$setGlobalExportMode = $reflection->getMethod('setGlobalExportMode');
$setGlobalExportMode->invoke($mock);
$reflection->getMethod('setGlobalExportMode')->invoke($mock);

$prepareModelTestState = $reflection->getMethod('prepareModelTestState');
$prepareModelTestState->invoke($mock, TestModel::class);

$this->assertTrue($reflection->getProperty('globalExportMode')->getValue($mock));
Copy link
Collaborator

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

@DenTray DenTray assigned yogyrton and unassigned DenTray Dec 23, 2024
@yogyrton yogyrton assigned DenTray and unassigned yogyrton Dec 25, 2024
$datasetMock = collect($this->getJsonFixture('initialization/dataset.json'));
$this->mockGettingDataset($datasetMock);

$mock = $this
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$mock = $this
$testCaseMock = $this

->disableOriginalConstructor()
->getMockForAbstractClass();

$reflection = new ReflectionClass($mock);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$reflection = new ReflectionClass($mock);
$testCase = new ReflectionClass($mock);

Comment on lines 34 to 43
$mock = $this
->getMockBuilder(TestCase::class)
->disableOriginalConstructor()
->getMockForAbstractClass();

$reflection = new ReflectionClass($mock);

$reflection->getMethod('setGlobalExportMode')->invoke($mock);

$prepareTableTestState = $reflection->getMethod('prepareTableTestState')->invoke($mock, 'test_models');
Copy link
Collaborator

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

@DenTray DenTray assigned yogyrton and unassigned DenTray Dec 26, 2024
@yogyrton yogyrton assigned DenTray and unassigned yogyrton Dec 26, 2024
@DenTray DenTray merged commit ffb76d3 into master Dec 26, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants