Overview

Namespaces

  • expect
    • config
    • configurator
    • context
    • factory
    • matcher
      • strategy
    • package
    • registry
    • reporter

Classes

  • expect\config\ConfigurationLoader
  • expect\config\DefaultConfiguration
  • expect\config\RuntimeConfiguration
  • expect\configurator\DefaultConfigurator
  • expect\configurator\FileConfigurator
  • expect\context\DefaultContextFactory
  • expect\context\EvaluateContext
  • expect\Dictionary
  • expect\Expect
  • expect\factory\DefaultMatcherFactory
  • expect\FailedMessage
  • expect\matcher\PatternMatcher
  • expect\matcher\strategy\ArrayInclusionStrategy
  • expect\matcher\strategy\InclusionResult
  • expect\matcher\strategy\StringInclusionStrategy
  • expect\matcher\ToBe
  • expect\matcher\ToBeA
  • expect\matcher\ToBeAbove
  • expect\matcher\ToBeAn
  • expect\matcher\ToBeAnInstanceOf
  • expect\matcher\ToBeArray
  • expect\matcher\ToBeBelow
  • expect\matcher\ToBeBoolean
  • expect\matcher\ToBeEmpty
  • expect\matcher\ToBeFalse
  • expect\matcher\ToBeFalsey
  • expect\matcher\ToBeFloat
  • expect\matcher\ToBeGreaterThan
  • expect\matcher\ToBeInteger
  • expect\matcher\ToBeLessThan
  • expect\matcher\ToBeNull
  • expect\matcher\ToBeString
  • expect\matcher\ToBeTrue
  • expect\matcher\ToBeTruthy
  • expect\matcher\ToBeWithin
  • expect\matcher\ToContain
  • expect\matcher\ToEndWith
  • expect\matcher\ToEqual
  • expect\matcher\ToHaveKey
  • expect\matcher\ToHaveLength
  • expect\matcher\ToMatch
  • expect\matcher\ToPrint
  • expect\matcher\ToStartWith
  • expect\matcher\ToThrow
  • expect\matcher\TruthyMatcher
  • expect\MatcherDictionary
  • expect\MatcherEvaluator
  • expect\MatcherPackage
  • expect\package\DefaultMatcherPackage
  • expect\package\DefaultPackageRegistrar
  • expect\package\MatcherClass
  • expect\package\ReflectionIterator
  • expect\registry\DefaultMatcherRegistry
  • expect\reporter\ExceptionReporter
  • expect\reporter\TextMessageReporter
  • expect\Result

Interfaces

  • expect\Configurable
  • expect\Configuration
  • expect\Configurator
  • expect\Context
  • expect\ContextFactory
  • expect\Evaluator
  • expect\Matcher
  • expect\matcher\ReportableMatcher
  • expect\matcher\strategy\InclusionStrategy
  • expect\MatcherContainer
  • expect\MatcherFactory
  • expect\MatcherRegistry
  • expect\Message
  • expect\PackageRegistrar
  • expect\RegisterablePackage
  • expect\ResultReporter

Traits

  • expect\config\ConfigurableConfiguration
  • expect\matcher\EqualMatcherDelegatable
  • expect\matcher\GreaterThanMatcherDelegatable
  • expect\matcher\LengthMatcherDelegatable
  • expect\matcher\LessThanMatcherDelegatable
  • expect\matcher\TypeMatcherDelegatable
  • expect\MatcherLookupTable

Exceptions

  • expect\config\ConfigurationFileNotFoundException
  • expect\config\NotAvailableException
  • expect\package\ComposerJsonNotFoundException
  • expect\registry\MatcherAlreadyRegisteredException
  • expect\registry\MatcherNotRegisteredException
  • expect\reporter\FailedException

Functions

  • expect\expect
  • Overview
  • Namespace
  • Class
  1: <?php
  2: 
  3: /**
  4:  * This file is part of expect package.
  5:  *
  6:  * (c) Noritaka Horio <holy.shared.design@gmail.com>
  7:  *
  8:  * This source file is subject to the MIT license that is bundled
  9:  * with this source code in the file LICENSE.
 10:  */
 11: namespace expect\matcher;
 12: 
 13: use expect\FailedMessage;
 14: 
 15: /**
 16:  * Verify whether the value is greater than the value of the expected value.
 17:  *
 18:  * <code>
 19:  * $matcher = new ToBeGreaterThan(100);
 20:  * $matcher->match(100); //return true
 21:  *
 22:  * $matcher->match(1); //return false
 23:  * </code>
 24:  *
 25:  * @author Noritaka Horio <holy.shared.design@gmail.com>
 26:  * @copyright Noritaka Horio <holy.shared.design@gmail.com>
 27:  */
 28: final class ToBeGreaterThan implements ReportableMatcher
 29: {
 30:     /**
 31:      * @var int|float
 32:      */
 33:     private $actual;
 34: 
 35:     /**
 36:      * @var int|float
 37:      */
 38:     private $expected;
 39: 
 40:     /**
 41:      * Create a new matcher.
 42:      *
 43:      * @param int|float $expected expected value
 44:      */
 45:     public function __construct($expected)
 46:     {
 47:         $this->expected = $expected;
 48:     }
 49: 
 50:     /**
 51:      * {@inheritdoc}
 52:      */
 53:     public function match($actual)
 54:     {
 55:         $this->actual = $actual;
 56: 
 57:         return $this->actual >= $this->expected;
 58:     }
 59: 
 60:     /**
 61:      * {@inheritdoc}
 62:      */
 63:     public function reportFailed(FailedMessage $message)
 64:     {
 65:         $detail = $this->createDetailMessage();
 66:         $message->appendText('Expected ')
 67:             ->appendValue($this->actual)
 68:             ->appendText(' to be greater than ')
 69:             ->appendValue($this->expected)
 70:             ->appendText($detail);
 71:     }
 72: 
 73:     /**
 74:      * {@inheritdoc}
 75:      */
 76:     public function reportNegativeFailed(FailedMessage $message)
 77:     {
 78:         $detail = $this->createDetailMessage(' not');
 79:         $message->appendText('Expected ')
 80:             ->appendValue($this->actual)
 81:             ->appendText(' not to be greater than ')
 82:             ->appendValue($this->expected)
 83:             ->appendText($detail);
 84:     }
 85: 
 86:     private function createDetailMessage($prefixMessage = '')
 87:     {
 88:         $message = FailedMessage::fromString("\n\n");
 89:         $message->appendText('    expected')
 90:             ->appendText($prefixMessage)
 91:             ->appendText(': >= ')
 92:             ->appendValue($this->expected)
 93:             ->appendText("\n")
 94:             ->appendSpace(strlen($prefixMessage))
 95:             ->appendText('         got:    ')
 96:             ->appendValue($this->actual);
 97: 
 98:         return (string) $message;
 99:     }
100: }
101: 
Expect API documentation generated by ApiGen