<commit_before><?php

namespace spec\SearchApi\Providers;

use SearchApi;
use SearchApi\Models;
use SearchApi\Services\Search;
use SearchApi\Builders\QueryBuilder;

use PhpSpec\ObjectBehavior;
use Prophecy\Argument;

/**
 * SolrSearchSpec - Spec test for SolrSearch
 */
class SolrSearchSpec extends ObjectBehavior {
  function it_is_initializable() {
    $this->shouldHaveType( 'SearchApi\Providers\SolrSearch' );
  }

  function it_should_call_query_builder( QueryBuilder $queryBuilder ) {
    $this->beConstructedWith( $queryBuilder );

    $keywords = array( new Models\SearchTerm() );

    $queryBuilder->build_query( $keywords )->shouldBeCalled();

    $this->query( $keywords );
  }

  function it_should_execute_query( QueryBuilder $queryBuilder ) {
    $this->beConstructedWith( $queryBuilder );

    $keywords = array( new Models\SearchTerm() );

    $queryString = 'query';
    $queryBuilder->build_query( Argument::any() )->shouldBeCalled()->willReturn( $queryString );

    $this->execute_query( $queryString )->shouldBeCalled();

    $this->query( $keywords );
  }

  function it_should_return_search_result_if_keywords_are_nonempty( QueryBuilder $queryBuilder ) {
    $this->beConstructedWith( $queryBuilder );

    $keywords = array( new Models\SearchTerm() );

    $queryBuilder->build_query( Argument::any() )->shouldBeCalled();
    $this->execute_query( Argument::any() )->shouldBeCalled()->willReturn( );

    $searchResult = new Models\SearchResult();
    $this->parse_result( Argument::any() )->shouldBeCalled()->willReturn( $searchResult );

    $result = $this->query( $keywords );
    $result->shouldHaveType( 'SearchApi\Models\SearchResult' );
  }
}
<commit_msg>Have SolrSearchSpec test behavior<commit_after><?php

namespace spec\SearchApi\Providers;

use SearchApi;
use SearchApi\Models;
use SearchApi\Services\Search;
use SearchApi\Builders\QueryBuilder;

use PhpSpec\ObjectBehavior;
use Prophecy\Argument;

/**
 * SolrSearchSpec - Spec test for SolrSearch
 */
class SolrSearchSpec extends ObjectBehavior {
  function it_is_initializable() {
    $this->shouldHaveType( 'SearchApi\Providers\SolrSearch' );
  }

  function it_should_call_query_builder( QueryBuilder $queryBuilder ) {
    $this->beConstructedWith( $queryBuilder );

    $queryBuilder->build_query( 'test', null )->shouldBeCalled();

    $this->query( 'test' );
  }

  function it_should_return_null_when_keywords_empty() {
    $result = $this->query( null );

    $result->shouldBeNull();
  }

  function it_should_return_search_result_when_keywords_not_empty() {
    $keywords = array( new Models\SearchTerm( 'test' ) );
    $result = $this->query( $keywords );

    $result->shouldHaveType( 'SearchApi\Models\SearchResult' );
  }
}

{'fraction_non_alphanumeric': 0.13499633162142333, 'fraction_numerical': 0.0, 'mean_word_length': 4.889848812095033, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, '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': '3131493', 'n_tokens_mistral': 871, 'n_tokens_neox': 839, 'n_words': 153}