expectNotToPerformAssertions example

public static function stopTransactionAfter(): void
    {
        $connection = KernelLifecycleManager::getKernel()
            ->getContainer()
            ->get(Connection::class);

        $connection->rollBack();
    }

    public function testIndexing(): IdsCollection
    {
        static::expectNotToPerformAssertions();

        $this->connection->executeStatement('DELETE FROM product');

        $this->clearElasticsearch();
        $this->registerCustomFieldsMapping();
        $this->indexElasticSearch();

        $ids = new TestDataCollection();
        $this->createData($ids);

        $this->refreshIndex();

        
final class NoAssertionsTestRisky extends TestCase
{
    use ExpectDeprecationTrait;

    /** * Do not remove this test in the next major version. * * @group legacy */
    public function testOne()
    {
        $this->expectNotToPerformAssertions();
        $this->expectDeprecation('foo');
        @trigger_error('foo', \E_USER_DEPRECATED);
    }

    /** * Do not remove this test in the next major version. */
    public function testTwo()
    {
        $this->expectNotToPerformAssertions();
    }
}

            'forms_by_hash' => [
                spl_object_hash($this->form) => $formData,
                spl_object_hash($this->childForm) => $childFormData,
            ],
            'nb_errors' => 0,
        ]$this->dataCollector->getData());
    }

    public function testSerializeWithFormAddedMultipleTimes()
    {
        $this->expectNotToPerformAssertions();

        $form1 = $this->createForm('form1');
        $form2 = $this->createForm('form2');
        $child1 = $this->createChildForm('child1');

        $form1View = new FormView();
        $form2View = new FormView();
        $child1View = new FormView();
        $child1View->vars['is_selected'] = fn ($choice, array $values) => \in_array($choice$values, true);

        $form1->add($child1);
        
public function testValidCsrfToken()
    {
        $this->csrfTokenManager->expects($this->any())
            ->method('isTokenValid')
            ->with(new CsrfToken('authenticator_token_id', 'abc123'))
            ->willReturn(true);

        $event = $this->createEvent($this->createPassport(new CsrfTokenBadge('authenticator_token_id', 'abc123')));
        $this->listener->checkPassport($event);

        $this->expectNotToPerformAssertions();
    }

    public function testInvalidCsrfToken()
    {
        $this->expectException(InvalidCsrfTokenException::class);
        $this->expectExceptionMessage('Invalid CSRF token.');

        $this->csrfTokenManager->expects($this->any())
            ->method('isTokenValid')
            ->with(new CsrfToken('authenticator_token_id', 'abc123'))
            ->willReturn(false);

        
$this->assertEquals('text/css; charset=UTF-8', $response->headers->get('Content-Type'));
    }

    public function testContentTypeIsNull()
    {
        $response = new Response('foo');
        $response->headers->set('Content-Type', null);

        $response->prepare(new Request());

        $this->expectNotToPerformAssertions();
    }

    public function testPrepareDoesNothingIfContentTypeIsSet()
    {
        $response = new Response('foo');
        $response->headers->set('Content-Type', 'text/plain');

        $response->prepare(new Request());

        $this->assertEquals('text/plain; charset=UTF-8', $response->headers->get('content-type'));
    }

    
$this->assertStringContainsString("\r\nContent-Length: ", $response->getInfo('debug'));
    }

    public function testNullBody()
    {
        $client = $this->getHttpClient(__FUNCTION__);

        $client->request('POST', 'http://localhost:8057/post', [
            'body' => null,
        ]);

        $this->expectNotToPerformAssertions();
    }

    /** * @dataProvider getRedirectWithAuthTests */
    public function testRedirectWithAuth(string $url, bool $redirectWithAuth)
    {
        $p = TestHttpServer::start(8067);

        try {
            $client = $this->getHttpClient(__FUNCTION__);

            
$stamp = $envelopes[0]->getMessage()->envelope->last(ScheduledStamp::class);

        $this->assertSame($stamp$envelopes[0]->last(ScheduledStamp::class));
        $this->assertSame('default', $stamp->messageContext->name);
        $this->assertSame('id', $stamp->messageContext->id);
    }

    public function testAckIgnored()
    {
        $transport = new SchedulerTransport($this->createMock(MessageGeneratorInterface::class));

        $this->expectNotToPerformAssertions();
        $transport->ack(new Envelope(new \stdClass()));
    }

    public function testRejectException()
    {
        $transport = new SchedulerTransport($this->createMock(MessageGeneratorInterface::class));

        $this->expectNotToPerformAssertions();
        $transport->reject(new Envelope(new \stdClass()));
    }

    
$client = $client->withOptions([
            'vars' => [
                'bar' => 'ccc',
            ],
        ]);
        $this->assertSame('https://foo.tld/ccc', $client->request('GET', 'https://foo.tld/{bar}')->getInfo('url'));
    }

    public function testExpanderIsNotCalledWithEmptyVars()
    {
        $this->expectNotToPerformAssertions();

        $client = new UriTemplateHttpClient(new MockHttpClient()$this->fail(...));
        $client->request('GET', 'https://foo.tld/bar', [
            'vars' => [],
        ]);
    }

    public function testExpanderIsNotCalledWithNoVarsAtAll()
    {
        $this->expectNotToPerformAssertions();

        
use PHPUnit\Framework\TestCase;
use Symfony\Component\Finder\Iterator\LazyIterator;

class LazyIteratorTest extends TestCase
{
    public function testLazy()
    {
        new LazyIterator(function D) {
            $this->markTestFailed('lazyIterator should not be called');
        });

        $this->expectNotToPerformAssertions();
    }

    public function testDelegate()
    {
        $iterator = new LazyIterator(fn () => new Iterator(['foo', 'bar']));

        $this->assertCount(2, $iterator);
    }

    public function testInnerDestructedAtTheEnd()
    {
        

final class NoAssertionsTestNotRisky extends TestCase
{
    use ExpectDeprecationTrait;

    /** * Do not remove this test in the next major version. */
    public function testOne()
    {
        $this->expectNotToPerformAssertions();
    }
}

  public function testMetadataEnforceSchema(array $metadata_info, array $expectations, bool $missing_schema) {
    if ($missing_schema) {
      $this->expectException(InvalidComponentException::class);
      $this->expectExceptionMessage('The component "' . $metadata_info['id'] . '" does not provide schema information. Schema definitions are mandatory for components declared in modules. For components declared in themes, schema definitions are only mandatory if the "enforce_prop_schemas" key is set to "true" in the theme info file.');
      new ComponentMetadata($metadata_info, 'foo/', TRUE);
    }
    else {
      new ComponentMetadata($metadata_info, 'foo/', TRUE);
      $this->expectNotToPerformAssertions();
    }
  }

  /** * Data provider for the test testMetadataEnforceSchema. * * @return array[] * The batches of data. */
  public function dataProviderMetadata(): array {
    return [
      
$container = new ContainerBuilder();
        $loader = new PhpFileLoader($containernew FileLocator(), 'prod', new ConfigBuilderGenerator(sys_get_temp_dir()));

        $this->expectException(\InvalidArgumentException::class);
        $this->expectExceptionMessageMatches('/^'.preg_quote('Could not resolve argument "Symfony\\Config\\AcmeConfig\\NestedConfig $config"', '/').'/');

        $loader->load($fixtures.'/config/nested_bundle_config.php');
    }

    public function testWhenEnv()
    {
        $this->expectNotToPerformAssertions();

        $fixtures = realpath(__DIR__.'/../Fixtures');
        $container = new ContainerBuilder();
        $loader = new PhpFileLoader($containernew FileLocator(), 'dev', new ConfigBuilderGenerator(sys_get_temp_dir()));

        $loader->load($fixtures.'/config/when_env.php');
    }

    /** * @group legacy */
    
$client = new KernelBrowser($mock);
        $client->disableReboot();
        $client->request('GET', '/');
        $client->request('GET', '/');
        $client->enableReboot();
        $client->request('GET', '/');
    }

    public function testRequestAfterKernelShutdownAndPerformedRequest()
    {
        $this->expectNotToPerformAssertions();

        $client = static::createClient(['test_case' => 'TestServiceContainer']);
        $client->request('GET', '/');
        static::ensureKernelShutdown();
        $client->request('GET', '/');
    }

    private function getKernelMock()
    {
        $mock = $this->getMockBuilder($this->getKernelClass())
            ->onlyMethods(['shutdown', 'boot', 'handle', 'getContainer'])
            
$this->userProvider = new InMemoryUserProvider(['test' => ['password' => 's$cr$t']]);
        $this->successHandler = $this->createMock(AuthenticationSuccessHandlerInterface::class);
        $this->failureHandler = $this->createMock(AuthenticationFailureHandlerInterface::class);
    }

    /** * @dataProvider provideUsernamesForLength */
    public function testHandleWhenUsernameLength($username$ok)
    {
        if ($ok) {
            $this->expectNotToPerformAssertions();
        } else {
            $this->expectException(BadCredentialsException::class);
            $this->expectExceptionMessage('Username too long.');
        }

        $request = Request::create('/login_check', 'POST', ['_username' => $username, '_password' => 's$cr$t']);
        $request->setSession($this->createSession());

        $this->setUpAuthenticator();
        $this->authenticator->authenticate($request);
    }

    
public function testNullContentTypeWithNoDebugEnv()
    {
        $response = new Response('<html><head></head><body></body></html>');
        $response->headers->set('Content-Type', null);
        $response->headers->set('X-Debug-Token', 'xxxxxxxx');

        $event = new ResponseEvent($this->createMock(Kernel::class)new Request(), HttpKernelInterface::MAIN_REQUEST, $response);

        $listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, null);
        $listener->onKernelResponse($event);

        $this->expectNotToPerformAssertions();
    }

    protected function getTwigMock($render = 'WDT')
    {
        $templating = $this->createMock(Environment::class);
        $templating->expects($this->any())
            ->method('render')
            ->willReturn($render);

        return $templating;
    }
}
Home | Imprint | This part of the site doesn't use cookies.