Packages

t

play.api.test

StubControllerComponentsFactory

trait StubControllerComponentsFactory extends StubPlayBodyParsersFactory with StubBodyParserFactory with StubMessagesFactory

Source
Helpers.scala
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. StubControllerComponentsFactory
  2. StubMessagesFactory
  3. StubBodyParserFactory
  4. StubPlayBodyParsersFactory
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  10. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  11. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  13. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  14. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  15. def stubBodyParser[T](content: T = AnyContentAsEmpty): BodyParser[T]

    Stub method that returns the content immediately.

    Stub method that returns the content immediately. Useful for unit testing.

    val stubParser = bodyParser(AnyContent("hello"))
    content

    the content to return, AnyContentAsEmpty by default

    returns

    a BodyParser for type T that returns Accumulator.done(Right(content))

    Definition Classes
    StubBodyParserFactory
  16. def stubControllerComponents(bodyParser: BodyParser[AnyContent] = stubBodyParser(AnyContentAsEmpty), playBodyParsers: PlayBodyParsers = stubPlayBodyParsers(NoMaterializer), messagesApi: MessagesApi = stubMessagesApi(), langs: Langs = stubLangs(), fileMimeTypes: FileMimeTypes = ..., executionContext: ExecutionContext = ExecutionContext.global): ControllerComponents

    Create a minimal controller components, useful for unit testing.

    Create a minimal controller components, useful for unit testing.

    In most cases, you'll want the standard defaults:

    val controller = new MyController(stubControllerComponents())

    A custom body parser can be used with bodyParser() to provide a request body to the controller:

    val cc = stubControllerComponents(bodyParser(AnyContent("request body text")))
    bodyParser

    the body parser used to parse any content, stubBodyParser(AnyContentAsEmpty) by default.

    playBodyParsers

    the playbodyparsers, defaults to stubPlayBodyParsers(NoMaterializer)

    langs

    the langs instance for messaging, new DefaultLangs() by default.

    fileMimeTypes

    the mime type associated with file extensions, new DefaultFileMimeTypes(FileMimeTypesConfiguration() by default.

    executionContext

    an execution context, defaults to ExecutionContext.global

    returns

    a fully configured ControllerComponents instance.

  17. def stubLangs(availables: Seq[Lang] = Seq(Lang.defaultLang)): Langs

    availables

    default as Seq(Lang.defaultLang).

    returns

    a stub Langs

    Definition Classes
    StubMessagesFactory
  18. def stubMessages(messagesApi: MessagesApi = stubMessagesApi(), requestHeader: RequestHeader = FakeRequest()): Messages

    Stub method that returns a play.api.i18n.Messages instance.

    Stub method that returns a play.api.i18n.Messages instance.

    messagesApi

    the messagesApi to use, uses stubMessagesApi by default.

    requestHeader

    the request to use, FakeRequest by default.

    returns

    the Messages instance

    Definition Classes
    StubMessagesFactory
  19. def stubMessagesApi(messages: Map[String, Map[String, String]] = Map.empty, langs: Langs = stubLangs(), langCookieName: String = "PLAY_LANG", langCookieSecure: Boolean = false, langCookieHttpOnly: Boolean = false, langCookieSameSite: Option[SameSite] = None, httpConfiguration: HttpConfiguration = HttpConfiguration()): MessagesApi

    Returns a stub DefaultMessagesApi with default values and an empty map.

    Returns a stub DefaultMessagesApi with default values and an empty map.

    messages

    map of languages to map of messages, empty by default.

    langs

    stubLangs() by default

    langCookieName

    "PLAY_LANG" by default

    langCookieSecure

    false by default

    langCookieHttpOnly

    false by default

    langCookieSameSite

    None by default

    httpConfiguration

    configuration, HttpConfiguration() by default.

    returns

    the messagesApi with minimal configuration.

    Definition Classes
    StubMessagesFactory
  20. def stubMessagesControllerComponents(): MessagesControllerComponents
  21. def stubMessagesRequest(messagesApi: MessagesApi = stubMessagesApi(), request: Request[AnyContentAsEmpty.type] = FakeRequest()): MessagesRequest[AnyContentAsEmpty.type]

    Stub method that returns a play.api.mvc.MessagesRequest instance.

    Stub method that returns a play.api.mvc.MessagesRequest instance.

    messagesApi

    the messagesApi to use, uses stubMessagesApi by default.

    request

    the request to use, FakeRequest by default.

    returns

    the Messages instance

    Definition Classes
    StubMessagesFactory
  22. def stubPlayBodyParsers(implicit mat: Materializer): PlayBodyParsers

    Stub method for unit testing, using NoTemporaryFileCreator.

    Stub method for unit testing, using NoTemporaryFileCreator.

    mat

    the input materializer.

    returns

    a minimal PlayBodyParsers for unit testing.

    Definition Classes
    StubPlayBodyParsersFactory
  23. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  24. def toString(): String
    Definition Classes
    AnyRef → Any
  25. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  26. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  27. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )

Inherited from StubMessagesFactory

Inherited from StubBodyParserFactory

Inherited from AnyRef

Inherited from Any

Ungrouped