Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion test/ExceptionCaptureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,6 @@ private function getProperty(string $property): mixed
{
$reflection = new \ReflectionClass(ExceptionCapture::class);
$propertyReflection = $reflection->getProperty($property);
$propertyReflection->setAccessible(true);

return $propertyReflection->getValue();
}
Expand Down
3 changes: 0 additions & 3 deletions test/ExceptionPayloadBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ public function testInAppFalseForVendorFrames(): void
{
$reflector = new \ReflectionClass(ExceptionPayloadBuilder::class);
$method = $reflector->getMethod('buildFrame');
$method->setAccessible(true);

$frame = $method->invoke(null, [
'file' => '/app/vendor/some/package/Foo.php',
Expand All @@ -108,7 +107,6 @@ public function testInAppTrueForAppFrames(): void
{
$reflector = new \ReflectionClass(ExceptionPayloadBuilder::class);
$method = $reflector->getMethod('buildFrame');
$method->setAccessible(true);

$frame = $method->invoke(null, [
'file' => '/app/src/Services/MyService.php',
Expand Down Expand Up @@ -387,7 +385,6 @@ public function testFunctionIncludesClass(): void
{
$reflector = new \ReflectionClass(ExceptionPayloadBuilder::class);
$method = $reflector->getMethod('buildFrame');
$method->setAccessible(true);

$frame = $method->invoke(null, [
'file' => '/app/src/Foo.php',
Expand Down
11 changes: 11 additions & 0 deletions test/FeatureFlagErrorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// comment out below to print all logs instead of failing tests
require_once 'test/error_log_mock.php';

use PHPUnit\Framework\Attributes\IgnoreDeprecations;
use PHPUnit\Framework\TestCase;
use PostHog\Client;
use PostHog\FeatureFlagError;
Expand Down Expand Up @@ -38,6 +39,7 @@ public function setUp($flagsEndpointResponse = MockedResponses::FLAGS_RESPONSE,
$errorMessages = [];
}

#[IgnoreDeprecations]
public function testFlagMissingError()
{
$this->executeAtFrozenDateTime(new \DateTime('2022-05-01'), function () {
Expand Down Expand Up @@ -68,6 +70,7 @@ public function testFlagMissingError()
});
}

#[IgnoreDeprecations]
public function testErrorsWhileComputingFlagsError()
{
$this->executeAtFrozenDateTime(new \DateTime('2022-05-01'), function () {
Expand Down Expand Up @@ -101,6 +104,7 @@ public function testErrorsWhileComputingFlagsError()
});
}

#[IgnoreDeprecations]
public function testMultipleErrors()
{
$this->executeAtFrozenDateTime(new \DateTime('2022-05-01'), function () {
Expand Down Expand Up @@ -135,6 +139,7 @@ public function testMultipleErrors()
});
}

#[IgnoreDeprecations]
public function testNoErrorWhenFlagEvaluatesSuccessfully()
{
$this->executeAtFrozenDateTime(new \DateTime('2022-05-01'), function () {
Expand Down Expand Up @@ -162,6 +167,7 @@ public function testNoErrorWhenFlagEvaluatesSuccessfully()
});
}

#[IgnoreDeprecations]
public function testUnknownErrorWhenExceptionThrown()
{
$this->executeAtFrozenDateTime(new \DateTime('2022-05-01'), function () {
Expand Down Expand Up @@ -239,6 +245,7 @@ public function testApiErrorMethod()
$this->assertEquals('api_error_429', FeatureFlagError::apiError(429));
}

#[IgnoreDeprecations]
public function testTimeoutError()
{
$this->executeAtFrozenDateTime(new \DateTime('2022-05-01'), function () {
Expand Down Expand Up @@ -285,6 +292,7 @@ public function testTimeoutError()
});
}

#[IgnoreDeprecations]
public function testConnectionError()
{
$this->executeAtFrozenDateTime(new \DateTime('2022-05-01'), function () {
Expand Down Expand Up @@ -331,6 +339,7 @@ public function testConnectionError()
});
}

#[IgnoreDeprecations]
public function testApiError500()
{
$this->executeAtFrozenDateTime(new \DateTime('2022-05-01'), function () {
Expand Down Expand Up @@ -376,6 +385,7 @@ public function testApiError500()
});
}

#[IgnoreDeprecations]
public function testQuotaLimitedError()
{
$this->executeAtFrozenDateTime(new \DateTime('2022-05-01'), function () {
Expand Down Expand Up @@ -424,6 +434,7 @@ public function testQuotaLimitedError()
});
}

#[IgnoreDeprecations]
public function testFailedFlagIsFilteredOutByFailedField()
{
$this->executeAtFrozenDateTime(new \DateTime('2022-05-01'), function () {
Expand Down
4 changes: 3 additions & 1 deletion test/FeatureFlagEvaluationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
require_once 'test/error_log_mock.php';

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
use PHPUnit\Framework\TestCase;
use PostHog\Client;
use PostHog\EvaluatedFlagRecord;
Expand Down Expand Up @@ -545,6 +546,7 @@ public function testLocalEvaluationResolvesPayloads(): void
}

#[DataProvider('falseFlagPayloadProvider')]
#[IgnoreDeprecations]
public function testLocalFalseFlagResolvesPayload(mixed $rawPayload, mixed $expectedPayload): void
{
$this->makeClient(
Expand Down Expand Up @@ -884,9 +886,9 @@ public static function dedupCallsProvider(): array
}

/**
* @dataProvider dedupCallsProvider
* @param list<array<string,string>> $groupsPerCall
*/
#[DataProvider('dedupCallsProvider')]
public function testFeatureFlagCalledDedupes(array $groupsPerCall, int $expectedCount): void
{
$this->makeClient();
Expand Down
12 changes: 3 additions & 9 deletions test/FeatureFlagLocalEvaluationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,7 @@ public function jsonSerialize(): mixed
self::assertTrue(FeatureFlag::matchProperty($exact, ["key" => $jsonSerializable]));
}

/**
* @dataProvider presentPresenceOperatorValuesProvider
*/
#[DataProvider('presentPresenceOperatorValuesProvider')]
public function testMatchPropertyPresenceOperatorsTreatPresentValuesAsSet($value): void
{
foreach (["is_set" => true, "is_not_set" => false] as $operator => $expected) {
Expand Down Expand Up @@ -1804,9 +1802,7 @@ public function testFlagGroupProperties()
$this->assertEquals(PostHog::getFeatureFlag('group-flag', 'some-distinct-id', ["company" => "amazon"], [], ["company" => []]), 'decide-fallback-value');
}

/**
* @dataProvider mixedTargetingProvider
*/
#[DataProvider('mixedTargetingProvider')]
public function testMixedTargetingLocalEvaluation(string $flagKey, array $opts, $expected, array $localFlags)
{
$this->http_client = new MockedHttpClient(host: "app.posthog.com", flagEndpointResponse: $localFlags);
Expand Down Expand Up @@ -5307,9 +5303,7 @@ private static function earlyExitFlag($earlyExit): array
return ["key" => "early-exit-flag", "filters" => $filters];
}

/**
* @dataProvider earlyExitRolloutExclusionProvider
*/
#[DataProvider('earlyExitRolloutExclusionProvider')]
public function testEarlyExitRolloutExclusion($earlyExit, bool $expected): void
{
$flag = self::earlyExitFlag($earlyExit);
Expand Down
Loading
Loading