Skip to content

Mocking OAuth not working since 2.0.9 #32

@langemeijer

Description

@langemeijer

Since the oauth 2.0.9 I cannot mock (using phpunit) the OAuth class anymore. This worked using 2.0.7. I'm on latest PHP 8.3.

To Reproduce
This test succeeded with 2.0.7 and breaks with 2.0.9:

use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;

#[Group('unit')]
final class AuthorizationTest extends TestCase
{
    #[Test]
    public function minimalTestCase(): void {
        $consumerKey = 'ajkshjdng';
        $consumerSecret = 'asdhj3h4h34j';

        $oauth = $this->getMockBuilder(OAuth::class)
            ->setConstructorArgs([$consumerKey, $consumerSecret])
            ->getMock();

        $oauth
            ->method('getRequestToken')
            ->with()
            ->willReturnMap(
                [
                    ['fakeurl.org', null, ['oauth_token' => 'liajsdjwiu34', 'oauth_token_secret' => 'asdfhhherwer3']],
                ]
            );

        $tokenData = $oauth->getRequestToken('fakeurl.org');

        self::assertEquals('liajsdjwiu34', $tokenData['oauth_token']);
        self::assertEquals('asdfhhherwer3', $tokenData['oauth_token_secret']);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions