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

Made changes to upgrade the libraries #12

Closed
wants to merge 13 commits into from

Conversation

snakindia
Copy link

No description provided.

@snakindia snakindia closed this Oct 22, 2024
@snakindia snakindia reopened this Oct 22, 2024
@snakindia snakindia closed this Oct 22, 2024
@@ -210,7 +213,7 @@ public function whenTryToFindNewXpathButNotFoundItShouldLogItAndResetVariant():
Log::shouldReceive('warning')
->with("Field ':field-2:' with value ':value-2:' not found for ':scrape-url:'.");

$this->expectsEvents(ConfigurationScraped::class);
Event::assertNotDispatched(ConfigurationScraped::class);
Copy link
Owner

Choose a reason for hiding this comment

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

We should expect the event to be dispatched. This issue is repeated bellow a few times and in other tests.

@@ -112,18 +115,20 @@ public function whenIsCalculatedItShouldReturnExtractedDataAndStoreTheNewConfig(
Log::getFacadeRoot()
);

$this->expectsEvents(Scraped::class);
// $this->expectsEvents(Scraped::class);
Copy link
Owner

Choose a reason for hiding this comment

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

Avoid to leave dead code as comments

Copy link
Author

Choose a reason for hiding this comment

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

Removed.

$configureScraper->handle(new InvalidConfiguration(new ScrapeRequest($this->url, $this->type)));

/** @var Scraped $event */
$event = collect($this->firedEvents)->filter(function ($event): bool {
$firedEvents = collect(Event::dispatched(Scraped::class));
$event = $firedEvents->each(function ($event) {
Copy link
Owner

Choose a reason for hiding this comment

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

What is the purpose of these iterations? The same happens in the next test.

Copy link
Author

Choose a reason for hiding this comment

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

Unwanted code. Removed it.

@@ -63,10 +60,11 @@ public function whenDatasetExistsItShouldBeUpdated(): void
*/
public function whenDatasetDoesNotExistAndTheDatasetsLimitHasNotBeenReachedItShouldBeSaved(): void
{
factory(ScrapedDataset::class, UpdateDataset::DATASET_AMOUNT_LIMIT - 1)->create([
ScrapedDataset::factory()->count(UpdateDataset::DATASET_AMOUNT_LIMIT - 1)->create([
Copy link
Owner

Choose a reason for hiding this comment

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

Nice! I like the count usage here. Could you change in the other tests to use factory->count($amount) instead of use factory($amount) to be consistent?

Copy link
Author

Choose a reason for hiding this comment

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

Changes have been at all places. Can you please which is missing?

Copy link
Owner

Choose a reason for hiding this comment

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

You can find it searching in this pr something like factory(<something>)

@@ -101,7 +99,7 @@ public function whenDatasetDoesNotExistAndTheDatasetsLimitHasNotBeenReachedItSho
public function whenDatasetDoesNotExistAndTheDatasetsLimitHasReachedItShouldDeleteTheExcess(): void
{
$type = ':type:';
factory(ScrapedDataset::class, UpdateDataset::DATASET_AMOUNT_LIMIT + 10)->create([
ScrapedDataset::factory()->count(UpdateDataset::DATASET_AMOUNT_LIMIT)->create([
Copy link
Owner

Choose a reason for hiding this comment

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

Why this change in behavior? Is the test testing what it is supposed after this change?

Copy link
Author

Choose a reason for hiding this comment

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

We are inserting the 100 records and testing below in the function with assertion that the number of records fetched are equal to the number of records stored.

Copy link
Owner

Choose a reason for hiding this comment

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

The test should fulfill the purpose described in the test name. In this case DeleteTheExcess.

@snakindia
Copy link
Author

Reopened

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