<?php
/**
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf
 */

use Kufer\Mail\Sender\Result\EMailSentStatusCode;

class EMailSentStatusCodeTest extends \PHPUnit\Framework\TestCase
{
  public function setUp(): void
  {
  }

  public function tearDown(): void
  {
  }

  /**
   * @test
   * @covers \Kufer\Mail\Sender\EMailSendState::isSuccess
   */
  public function isSuccess_Success_True()
  {
    $this->assertTrue(EMailSentStatusCode::isSuccess(EMailSentStatusCode::SUCCESSFULL));
  }

  /**
   * @test
   * @covers \Kufer\Mail\Sender\EMailSendState::isSuccess
   */
  public function isSuccess_Warnings_False()
  {
    $this->assertFalse(EMailSentStatusCode::isSuccess(EMailSentStatusCode::WARNING_EMAIL_SENDER_NOT_FOUND));
  }

  /**
   * @test
   * @covers \Kufer\Mail\Sender\EMailSendState::isSuccess
   */
  public function isSuccess_Failures_False()
  {
    $this->assertFalse(EMailSentStatusCode::isSuccess(EMailSentStatusCode::FAILURE_UNKNOWN_ERROR));
    $this->assertFalse(EMailSentStatusCode::isSuccess(EMailSentStatusCode::FAILURE_EMAIL_NOT_FOUND));
  }

  /**
   * @test
   * @covers \Kufer\Mail\Sender\EMailSendState::hasError
   */
  public function hasError_Success_False()
  {
    $this->assertFalse(EMailSentStatusCode::hasError(EMailSentStatusCode::SUCCESSFULL));
  }

  /**
   * @test
   * @covers \Kufer\Mail\Sender\EMailSendState::hasError
   */
  public function hasError_Warnings_False()
  {
    $this->assertFalse(EMailSentStatusCode::hasError(EMailSentStatusCode::WARNING_EMAIL_SENDER_NOT_FOUND));
  }

  /**
   * @test
   * @covers \Kufer\Mail\Sender\EMailSendState::hasError
   */
  public function hasError_Failures_True()
  {
    $this->assertTrue(EMailSentStatusCode::hasError(EMailSentStatusCode::FAILURE_UNKNOWN_ERROR));
    $this->assertTrue(EMailSentStatusCode::hasError(EMailSentStatusCode::FAILURE_EMAIL_NOT_FOUND));
  }

  /**
   * @test
   * @covers \Kufer\Mail\Sender\EMailSendState::isAllSuccess
   */
  public function isAllSuccess_Success_True()
  {
    $this->assertTrue(EMailSentStatusCode::isAllSuccess(array(
      EMailSentStatusCode::SUCCESSFULL
    )));
    $this->assertTrue(EMailSentStatusCode::isAllSuccess(array(
      EMailSentStatusCode::SUCCESSFULL,
      EMailSentStatusCode::SUCCESSFULL
    )));
  }

  /**
   * @test
   * @covers \Kufer\Mail\Sender\EMailSendState::isAllSuccess
   */
  public function isAllSuccess_Warnings_False()
  {
    $this->assertFalse(EMailSentStatusCode::isAllSuccess(array(
      EMailSentStatusCode::WARNING_EMAIL_SENDER_NOT_FOUND
    )));
    $this->assertFalse(EMailSentStatusCode::isAllSuccess(array(
      EMailSentStatusCode::SUCCESSFULL,
      EMailSentStatusCode::WARNING_EMAIL_SENDER_NOT_FOUND,
      EMailSentStatusCode::SUCCESSFULL
    )));
  }

  /**
   * @test
   * @covers \Kufer\Mail\Sender\EMailSendState::hasAnyError
   */
  public function hasAnyError_SuccessWarnings_False()
  {
    $this->assertFalse(EMailSentStatusCode::hasAnyError(array(
      EMailSentStatusCode::SUCCESSFULL
    )));
    $this->assertFalse(EMailSentStatusCode::hasAnyError(array(
      EMailSentStatusCode::SUCCESSFULL,
      EMailSentStatusCode::SUCCESSFULL
    )));
    $this->assertFalse(EMailSentStatusCode::hasAnyError(array(
      EMailSentStatusCode::WARNING_EMAIL_SENDER_NOT_FOUND
    )));
    $this->assertFalse(EMailSentStatusCode::hasAnyError(array(
      EMailSentStatusCode::SUCCESSFULL,
      EMailSentStatusCode::WARNING_EMAIL_SENDER_NOT_FOUND
    )));
  }

  /**
   * @test
   * @covers \Kufer\Mail\Sender\EMailSendState::hasAnyError
   */
  public function hasAnyError_Failure_True()
  {
    $this->assertTrue(EMailSentStatusCode::hasAnyError(array(
      EMailSentStatusCode::FAILURE_EMAIL_NOT_FOUND
    )));

    $this->assertTrue(EMailSentStatusCode::hasAnyError(array(
      EMailSentStatusCode::SUCCESSFULL,
      EMailSentStatusCode::FAILURE_EMAIL_NOT_FOUND,
      EMailSentStatusCode::SUCCESSFULL
    )));

    $this->assertTrue(EMailSentStatusCode::hasAnyError(array(
      EMailSentStatusCode::WARNING_EMAIL_SENDER_NOT_FOUND,
      EMailSentStatusCode::FAILURE_EMAIL_NOT_FOUND,
      EMailSentStatusCode::WARNING_EMAIL_SENDER_NOT_FOUND
    )));

    $this->assertTrue(EMailSentStatusCode::hasAnyError(array(
      EMailSentStatusCode::SUCCESSFULL,
      EMailSentStatusCode::FAILURE_EMAIL_NOT_FOUND,
      EMailSentStatusCode::FAILURE_EMAIL_NOT_FOUND,
      EMailSentStatusCode::WARNING_EMAIL_SENDER_NOT_FOUND
    )));
  }
}
