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

Sweep: PHPUnit tests failed. #278

Closed
eurweb opened this issue Jan 27, 2025 · 1 comment · Fixed by #279
Closed

Sweep: PHPUnit tests failed. #278

eurweb opened this issue Jan 27, 2025 · 1 comment · Fixed by #279
Labels

Comments

@eurweb
Copy link

eurweb commented Jan 27, 2025

Details

An error occurred inside PHPUnit.

Message: Unmatched '}'
Location: /var/www/html/laravel/contacts/tests/Feature/CustomFieldsTest.php:182

PHP Fatal error: Namespace declaration statement has to be the very first statement or after any declare call in the script in /var/www/html/laravel/contacts/tests/Feature/TeamSubscriptionTest.php on line 5


Fix PHPUnit Test Syntax Errors

Description:

Fix syntax errors in two test files that are causing PHPUnit failures: an unmatched curly brace and an incorrect namespace declaration.

Tasks:

  1. In tests/Feature/CustomFieldsTest.php:

    • Remove extra closing brace at line 182
    • Remove duplicate test method closure that appears after the class closure
  2. In tests/Feature/TeamSubscriptionTest.php:

    • Remove empty lines before namespace declaration (must be first line)
    • Ensure namespace declaration starts at line 1

Test:

The existing test cases will run after fixing these syntax errors:

  • CustomFieldsTest (7 test methods)
  • TeamSubscriptionTest (3 test methods)
@eurweb eurweb added the sweep label Jan 27, 2025
Copy link
Contributor

sweep-ai bot commented Jan 27, 2025

🚀 Here's the PR! #279

Sweeping

Search Results

  • tests/Feature/CustomFieldsTest.php
  • tests/Feature/TeamSubscriptionTest.php

Response

I'll help fix the syntax errors in both test files.

  1. First, let's fix CustomFieldsTest.php by removing the extra closing brace and duplicate test method:
<?php

namespace Tests\Feature;

// ... existing code ...

    public function test_advanced_filtering_with_custom_fields_for_leads()
    {
        $customField = CustomField::factory()->create([
            'name' => 'Budget',
            'type' => 'number',
            'model_type' => 'lead',
            'team_id' => $this->user->currentTeam->id,
        ]);

        $lead1 = Lead::factory()->create([
            'custom_fields' => ['Budget' => 10000],
            'team_id' => $this->user->currentTeam->id,
        ]);

        $lead2 = Lead::factory()->create([
            'custom_fields' => ['Budget' => 5000],
            'team_id' => $this->user->currentTeam->id,
        ]);

        $response = $this->actingAs($this->user)->get('/leads?custom_fields[Budget][min]=7000');

        $response->assertSee($lead1->contact->name);
        $response->assertDontSee($lead2->contact->name);
    }
}
  1. Now let's fix TeamSubscriptionTest.php by removing the empty lines before the namespace declaration:
<?php
namespace Tests\Feature;

use App\Models\Team;
// ... existing code ...

Changes made:

  1. In CustomFieldsTest.php:

    • Removed the duplicate test method closure and extra closing brace
    • Cleaned up the file ending with just one closing brace for the class
  2. In TeamSubscriptionTest.php:

    • Removed empty lines at the beginning of the file
    • Moved namespace declaration to follow immediately after the PHP opening tag

These changes should resolve the PHPUnit syntax errors and allow the tests to run properly.

Continue the conversation with Sweep here: https://app.sweep.dev/c/355e5742-c151-4c21-ab8f-77a9e19f65c6.

📖 For more information on how to use Sweep, please read our documentation.

Tracking ID: 6ead29a51c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant