<commit_before><?php

namespace Boomerang;

use Boomerang\ExpectationResults\FailingExpectationResult;
use Boomerang\ExpectationResults\PassingExpectationResult;

class ResponseValidator implements Interfaces\Validator {

	private $expectations = array();
	/**
	 * @var Response
	 */
	private $response;

	public function __construct( Response $response ) {
		$this->response = $response;
	}

	/**
	 * @return \Boomerang\Response
	 */
	public function getResponse() {
		return $this->response;
	}

	/**
	 * @param int  $expected_status
	 * @param null $hop
	 * @return $this
	 */
	public function expectStatus( $expected_status = 200, $hop = null ) {

		$status = $this->response->getStatus($hop);

		if( $status != $expected_status ) {
			$this->expectations[] = new FailingExpectationResult($this, "Unexpected HTTP Status", $expected_status, $status);
		} else {
			$this->expectations[] = new PassingExpectationResult($this, "Expected HTTP Status", $status);
		}

		return $this;
	}

	/**
	 * @param string   $key
	 * @param string   $value
	 * @param null|int $hop
	 * @return $this
	 */
	public function expectHeader( $key, $value, $hop = null ) {
		$header = $this->response->getHeader($key, $hop);

		if( $header != $value ) {
			$this->expectations[] = new FailingExpectationResult($this, 'Unexpected header exact match' . var_export($key, true), $value, $header);
		} else {
			$this->expectations[] = new PassingExpectationResult($this, "Expected header exact match" . var_export($key, true), $header);
		}

		return $this;
	}

	/**
	 * @param  string  $key
	 * @param   string $value
	 * @param null|int $hop
	 * @return $this
	 */
	public function expectHeaderContains( $key, $value, $hop = null ) {
		$header = $this->response->getHeader($key, $hop);

		if( !$header || strpos($header, $value) === false ) {
			$this->expectations[] = new FailingExpectationResult($this, 'Unexpected header contains' . var_export($key, true), $value, $header);
		} else {
			$this->expectations[] = new PassingExpectationResult($this, "Expected header contains" . var_export($key, true), $header);
		}

		return $this;
	}

	/**
	 * @param string $expectedContent
	 * @return $this
	 */
	public function expectBody( $expectedContent ) {
		$content = $this->response->getBody();

		if( $content != $expectedContent ) {
			$this->expectations[] = new FailingExpectationResult($this, 'Unexpected body', $expectedContent, $content);
		} else {
			$this->expectations[] = new PassingExpectationResult($this, 'Expected body', $content);
		}

		return $this;
	}

	/**
	 * @param string $expectedContent
	 * @return $this
	 */
	public function expectBodyContains( $expectedContent ) {
		$content = $this->response->getBody();

		if( $content != $expectedContent ) {
			$this->expectations[] = new FailingExpectationResult($this, 'Unexpected body contains', $expectedContent, $content);
		} else {
			$this->expectations[] = new PassingExpectationResult($this, 'Expected body contains', $expectedContent);
		}

		return $this;
	}

	public function getExpectationResults() {
		return $this->expectations;
	}

}<commit_msg>Fixed expectBodyContains doing equality rather than containment<commit_after><?php

namespace Boomerang;

use Boomerang\ExpectationResults\FailingExpectationResult;
use Boomerang\ExpectationResults\PassingExpectationResult;

class ResponseValidator implements Interfaces\Validator {

	private $expectations = array();
	/**
	 * @var Response
	 */
	private $response;

	public function __construct( Response $response ) {
		$this->response = $response;
	}

	/**
	 * @return \Boomerang\Response
	 */
	public function getResponse() {
		return $this->response;
	}

	/**
	 * @param int  $expected_status
	 * @param null $hop
	 * @return $this
	 */
	public function expectStatus( $expected_status = 200, $hop = null ) {

		$status = $this->response->getStatus($hop);

		if( $status != $expected_status ) {
			$this->expectations[] = new FailingExpectationResult($this, "Unexpected HTTP Status", $expected_status, $status);
		} else {
			$this->expectations[] = new PassingExpectationResult($this, "Expected HTTP Status", $status);
		}

		return $this;
	}

	/**
	 * @param string   $key
	 * @param string   $value
	 * @param null|int $hop
	 * @return $this
	 */
	public function expectHeader( $key, $value, $hop = null ) {
		$header = $this->response->getHeader($key, $hop);

		if( $header != $value ) {
			$this->expectations[] = new FailingExpectationResult($this, 'Unexpected header exact match' . var_export($key, true), $value, $header);
		} else {
			$this->expectations[] = new PassingExpectationResult($this, "Expected header exact match" . var_export($key, true), $header);
		}

		return $this;
	}

	/**
	 * @param  string  $key
	 * @param   string $value
	 * @param null|int $hop
	 * @return $this
	 */
	public function expectHeaderContains( $key, $value, $hop = null ) {
		$header = $this->response->getHeader($key, $hop);

		if( !$header || strpos($header, $value) === false ) {
			$this->expectations[] = new FailingExpectationResult($this, 'Unexpected header contains' . var_export($key, true), $value, $header);
		} else {
			$this->expectations[] = new PassingExpectationResult($this, "Expected header contains" . var_export($key, true), $header);
		}

		return $this;
	}

	/**
	 * @param string $expectedContent
	 * @return $this
	 */
	public function expectBody( $expectedContent ) {
		$content = $this->response->getBody();

		if( $content != $expectedContent ) {
			$this->expectations[] = new FailingExpectationResult($this, 'Unexpected body', $expectedContent, $content);
		} else {
			$this->expectations[] = new PassingExpectationResult($this, 'Expected body', $content);
		}

		return $this;
	}

	/**
	 * @param string $expectedContent
	 * @return $this
	 */
	public function expectBodyContains( $expectedContent ) {
		$content = $this->response->getBody();

		if( strpos($content, $expectedContent) === false ) {
			$this->expectations[] = new FailingExpectationResult($this, 'Unexpected body contains', $expectedContent, $content);
		} else {
			$this->expectations[] = new PassingExpectationResult($this, 'Expected body contains', $expectedContent);
		}

		return $this;
	}

	public function getExpectationResults() {
		return $this->expectations;
	}

}
{'fraction_non_alphanumeric': 0.1538216560509554, 'fraction_numerical': 0.0009554140127388535, 'mean_word_length': 4.350085178875639, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3500767', 'n_tokens_mistral': 2081, 'n_tokens_neox': 1892, 'n_words': 473}