wpAdapter = $this->createMock( WpAdapter::class ); $this->latteEngine = $this->createMock( Engine::class ); $this->bugReportAttachment = $this->createMock( BugReportAttachment::class ); return new BugReportEmail( $this->wpAdapter, 'support@packeta.com', $this->latteEngine, $this->bugReportAttachment, ); } public function testSuccessWithSpecialCharacters(): void { $bugReportEmail = $this->createBugReportEmail(); $specialEmail = 'test+tag@example.com'; $specialMessage = 'Test message with and special chars: áčďéěíňóřšťúůýž'; $this->wpAdapter->method( 'sanitizeEmail' ) ->with( self::TEST_EMAIL ) ->willReturn( self::TEST_EMAIL ); $this->wpAdapter->method( 'wpKsesPost' ) ->with( self::TEST_MESSAGE ) ->willReturn( self::TEST_MESSAGE ); $this->wpAdapter->method( 'getBlogInfo' ) ->with( 'name', 'raw' ) ->willReturn( self::TEST_SITE_NAME ); $this->wpAdapter->method( 'currentTime' ) ->with( 'Y-m-d_H-i-s', false ) ->willReturn( self::TEST_TIMESTAMP ); $this->wpAdapter->method( 'wpMail' ) ->willReturn( true ); $this->wpAdapter->method( '__' ) ->willReturnCallback( function ( $text ) { return $text; } ); $this->assertTrue( $bugReportEmail->sendBugReport( $specialEmail, $specialMessage, false ) ); } public function testSuccessWithWooCommerceSystemStatus(): void { $bugReportEmail = $this->createBugReportEmail(); $this->wpAdapter->method( 'sanitizeEmail' ) ->with( self::TEST_EMAIL ) ->willReturn( self::TEST_EMAIL ); $this->wpAdapter->method( 'wpKsesPost' ) ->with( self::TEST_MESSAGE ) ->willReturn( self::TEST_MESSAGE ); $this->wpAdapter->method( 'getBlogInfo' ) ->with( 'name', 'raw' ) ->willReturn( self::TEST_SITE_NAME ); $this->wpAdapter->method( 'currentTime' ) ->with( 'Y-m-d_H-i-s', false ) ->willReturn( self::TEST_TIMESTAMP ); $this->wpAdapter->method( 'wpMail' ) ->willReturn( true ); $this->wpAdapter->method( '__' ) ->willReturnCallback( function ( $text ) { return $text; } ); $this->assertTrue( $bugReportEmail->sendBugReport( self::TEST_EMAIL, self::TEST_MESSAGE, false ) ); } public function testSuccessWithoutZipArchive(): void { $bugReportEmail = $this->createBugReportEmail(); $this->wpAdapter->method( 'sanitizeEmail' ) ->with( self::TEST_EMAIL ) ->willReturn( self::TEST_EMAIL ); $this->wpAdapter->method( 'wpKsesPost' ) ->with( self::TEST_MESSAGE ) ->willReturn( self::TEST_MESSAGE ); $this->wpAdapter->method( 'getBlogInfo' ) ->with( 'name', 'raw' ) ->willReturn( self::TEST_SITE_NAME ); $this->wpAdapter->method( 'currentTime' ) ->with( 'Y-m-d_H-i-s', false ) ->willReturn( self::TEST_TIMESTAMP ); $this->wpAdapter->method( 'wpMail' ) ->willReturn( true ); $this->wpAdapter->method( '__' ) ->willReturnCallback( function ( $text ) { return $text; } ); $this->assertTrue( $bugReportEmail->sendBugReport( self::TEST_EMAIL, self::TEST_MESSAGE, false ) ); } public function testSuccessWithoutWooCommerceSystemStatus(): void { $bugReportEmail = $this->createBugReportEmail(); $this->wpAdapter->method( 'sanitizeEmail' ) ->with( self::TEST_EMAIL ) ->willReturn( self::TEST_EMAIL ); $this->wpAdapter->method( 'wpKsesPost' ) ->with( self::TEST_MESSAGE ) ->willReturn( self::TEST_MESSAGE ); $this->wpAdapter->method( 'getBlogInfo' ) ->with( 'name', 'raw' ) ->willReturn( self::TEST_SITE_NAME ); $this->wpAdapter->method( 'currentTime' ) ->with( 'Y-m-d_H-i-s', false ) ->willReturn( self::TEST_TIMESTAMP ); $this->wpAdapter->method( 'wpMail' ) ->willReturn( true ); $this->wpAdapter->method( '__' ) ->willReturnCallback( function ( $text ) { return $text; } ); $this->assertTrue( $bugReportEmail->sendBugReport( self::TEST_EMAIL, self::TEST_MESSAGE, false ) ); } public function testSuccessWithFullZipCreation(): void { $bugReportEmail = $this->createBugReportEmail(); $this->wpAdapter->method( 'sanitizeEmail' ) ->with( self::TEST_EMAIL ) ->willReturn( self::TEST_EMAIL ); $this->wpAdapter->method( 'wpKsesPost' ) ->with( self::TEST_MESSAGE ) ->willReturn( self::TEST_MESSAGE ); $this->wpAdapter->method( 'getBlogInfo' ) ->with( 'name', 'raw' ) ->willReturn( self::TEST_SITE_NAME ); $this->wpAdapter->method( 'currentTime' ) ->with( 'Y-m-d_H-i-s', false ) ->willReturn( self::TEST_TIMESTAMP ); $this->wpAdapter->method( 'wpMail' ) ->willReturn( true ); $this->wpAdapter->method( '__' ) ->willReturnCallback( function ( $text ) { return $text; } ); $this->assertTrue( $bugReportEmail->sendBugReport( self::TEST_EMAIL, self::TEST_MESSAGE, false ) ); } }